Переглянути джерело

Sort all Group select boxes by group_name asc.
Create User now allows to select a single Group to add User to at time of User creation.

Nate Jones 11 роки тому
батько
коміт
7926d00ec5

+ 1 - 0
core/menu/menu_item_edit.php

@@ -407,6 +407,7 @@ else {
 	echo "<br />\n";
 	echo "<br />\n";
 	$sql = "SELECT * FROM v_groups ";
 	$sql = "SELECT * FROM v_groups ";
 	$sql .= "where domain_uuid = '".$domain_uuid."' ";
 	$sql .= "where domain_uuid = '".$domain_uuid."' ";
+	$sql .= "order by group_name asc ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();
 	$prep_statement->execute();
 	echo "<select name=\"group_name\" class='formfld' style='width: auto; margin-right: 3px;'>\n";
 	echo "<select name=\"group_name\" class='formfld' style='width: auto; margin-right: 3px;'>\n";

+ 5 - 0
core/users/app_languages.php

@@ -142,6 +142,11 @@
 	$text['label-user_info']['pt-pt'] = "Informação do Utilizador";
 	$text['label-user_info']['pt-pt'] = "Informação do Utilizador";
 	$text['label-user_info']['fr-fr'] = "Informations sur l'utilisateur";
 	$text['label-user_info']['fr-fr'] = "Informations sur l'utilisateur";
 
 
+	$text['label-group']['en-us'] = "Group";
+	$text['label-group']['es-cl'] = "Grupo";
+	$text['label-group']['pt-pt'] = "Grupo";
+	$text['label-group']['fr-fr'] = "Group";
+
 	$text['label-groups']['en-us'] = "Groups";
 	$text['label-groups']['en-us'] = "Groups";
 	$text['label-groups']['es-cl'] = "Grupos";
 	$text['label-groups']['es-cl'] = "Grupos";
 	$text['label-groups']['pt-pt'] = "Grupos";
 	$text['label-groups']['pt-pt'] = "Grupos";

+ 47 - 1
core/users/signup.php

@@ -44,10 +44,12 @@ else {
 $username = check_str($_POST["username"]);
 $username = check_str($_POST["username"]);
 $password = check_str($_POST["password"]);
 $password = check_str($_POST["password"]);
 $confirmpassword = check_str($_POST["confirmpassword"]);
 $confirmpassword = check_str($_POST["confirmpassword"]);
+$group_name = check_str($_POST["group_name"]);
+$user_email = check_str($_POST["user_email"]);
 $contact_organization = check_str($_POST["contact_organization"]);
 $contact_organization = check_str($_POST["contact_organization"]);
 $contact_name_given = check_str($_POST["contact_name_given"]);
 $contact_name_given = check_str($_POST["contact_name_given"]);
 $contact_name_family = check_str($_POST["contact_name_family"]);
 $contact_name_family = check_str($_POST["contact_name_family"]);
-$user_email = check_str($_POST["user_email"]);
+
 
 
 if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 
 
@@ -106,6 +108,7 @@ if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 
 
 	//prepare the uuids
 	//prepare the uuids
 	$user_uuid = uuid();
 	$user_uuid = uuid();
+	$group_user_uuid = uuid();
 	$contact_uuid = uuid();
 	$contact_uuid = uuid();
 
 
 	//add the user
 	//add the user
@@ -136,6 +139,28 @@ if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 	$db->exec(check_sql($sql));
 	$db->exec(check_sql($sql));
 	unset($sql);
 	unset($sql);
 
 
+	//add the user to the group
+	if (strlen($group_name) > 0) {
+		if ( ($group_name == "superadmin" && if_group("superadmin")) || $group_name != "superadmin") {
+			$sql = "insert into v_group_users ";
+			$sql .= "( ";
+			$sql .= "group_user_uuid, ";
+			$sql .= "domain_uuid, ";
+			$sql .= "group_name, ";
+			$sql .= "user_uuid ";
+			$sql .= ") ";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'".$group_user_uuid."', ";
+			$sql .= "'".$domain_uuid."', ";
+			$sql .= "'".$group_name."', ";
+			$sql .= "'".$user_uuid."' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+		}
+	}
+
 	//add to contacts
 	//add to contacts
 	$sql = "insert into v_contacts ";
 	$sql = "insert into v_contacts ";
 	$sql .= "(";
 	$sql .= "(";
@@ -214,6 +239,27 @@ if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 	echo "		<td class='vtable'><input type='text' class='formfld' name='user_email' value='$user_email'></td>";
 	echo "		<td class='vtable'><input type='text' class='formfld' name='user_email' value='$user_email'></td>";
 	echo "	</tr>";
 	echo "	</tr>";
 	echo "	<tr>";
 	echo "	<tr>";
+	echo "		<td class='vncell' valign='top'>".$text['label-group'].":</td>";
+	echo "		<td class='vtable'>";
+	$sql = "SELECT * FROM v_groups ";
+	$sql .= "where domain_uuid = '".$domain_uuid."' ";
+	$sql .= "order by group_name asc ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	echo "			<select name=\"group_name\" class='formfld' style='width: auto; margin-right: 3px;'>\n";
+	echo "				<option value=\"\"></option>\n";
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach($result as $field) {
+		if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; }	//only show the superadmin group to other users in the superadmin group
+		if (!in_array($field["group_name"], $assigned_groups)) {
+			echo "		<option value='".$field['group_name']."'>".$field['group_name']."</option>\n";
+		}
+	}
+	echo "			</select>";
+	unset($sql, $result);
+	echo "		</td>";
+	echo "	</tr>";
+	echo "	<tr>";
 	echo "		<td class='vncell'>".$text['label-first_name'].":</td>";
 	echo "		<td class='vncell'>".$text['label-first_name'].":</td>";
 	echo "		<td class='vtable'><input type='text' class='formfld' name='contact_name_given' value='$contact_name_given'></td>";
 	echo "		<td class='vtable'><input type='text' class='formfld' name='contact_name_given' value='$contact_name_given'></td>";
 	echo "	</tr>";
 	echo "	</tr>";

+ 1 - 0
core/users/usersupdate.php

@@ -454,6 +454,7 @@ else {
 	echo "<br />\n";
 	echo "<br />\n";
 	$sql = "SELECT * FROM v_groups ";
 	$sql = "SELECT * FROM v_groups ";
 	$sql .= "where domain_uuid = '".$domain_uuid."' ";
 	$sql .= "where domain_uuid = '".$domain_uuid."' ";
+	$sql .= "order by group_name asc ";
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement = $db->prepare(check_sql($sql));
 	$prep_statement->execute();
 	$prep_statement->execute();
 	echo "<select name=\"group_name\" class='formfld' style='width: auto; margin-right: 3px;'>\n";
 	echo "<select name=\"group_name\" class='formfld' style='width: auto; margin-right: 3px;'>\n";