User Edit: Only list Contacts not already assigned to a User. Contact Edit: Display button to User the Contact is assigned to (if any).

This commit is contained in:
Nate 2019-03-06 19:54:12 -07:00
parent e30443e290
commit 06a0fa7235
3 changed files with 41 additions and 4 deletions

View File

@ -5381,4 +5381,24 @@ $text['button-add']['ru-ru'] = "Добавить";
$text['button-add']['sv-se'] = "Lägg Till"; $text['button-add']['sv-se'] = "Lägg Till";
$text['button-add']['uk-ua'] = "Додати"; $text['button-add']['uk-ua'] = "Додати";
$text['button-user']['en-us'] = "User";
$text['button-user']['ar-eg'] = "";
$text['button-user']['de-at'] = "Benutzer"; //copied from de-de
$text['button-user']['de-ch'] = "Benutzer"; //copied from de-de
$text['button-user']['de-de'] = "Benutzer";
$text['button-user']['es-cl'] = "Usuario";
$text['button-user']['es-mx'] = "Usuario"; //copied from es-cl
$text['button-user']['fr-ca'] = "Utilisateurs"; //copied from fr-fr
$text['button-user']['fr-fr'] = "Utilisateurs";
$text['button-user']['he-il'] = "";
$text['button-user']['it-it'] = "Utente";
$text['button-user']['nl-nl'] = "";
$text['button-user']['pl-pl'] = "Użytkownik";
$text['button-user']['pt-br'] = "Usuário";
$text['button-user']['pt-pt'] = "Utilizador";
$text['button-user']['ro-ro'] = "";
$text['button-user']['ru-ru'] = "Пользователь";
$text['button-user']['sv-se'] = "Användare";
$text['button-user']['uk-ua'] = "Користувач";
?> ?>

View File

@ -285,6 +285,16 @@
$users = $prep_statement->fetchAll(PDO::FETCH_NAMED); $users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement, $sql); unset($prep_statement, $sql);
//determine if contact assigned to a user
if (is_array($users) && sizeof($users) != 0) {
foreach($users as $user) {
if ($user['contact_uuid'] == $contact_uuid) {
$contact_user_uuid = $user['user_uuid'];
break;
}
}
}
//get the users assigned to this contact //get the users assigned to this contact
$sql = "SELECT u.username, u.user_uuid, a.contact_user_uuid FROM v_contacts as c, v_users as u, v_contact_users as a "; $sql = "SELECT u.username, u.user_uuid, a.contact_user_uuid FROM v_contacts as c, v_users as u, v_contact_users as a ";
$sql .= "where c.contact_uuid = '".$contact_uuid."' "; $sql .= "where c.contact_uuid = '".$contact_uuid."' ";
@ -416,6 +426,9 @@
if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/certificates')) { if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/certificates')) {
echo " <input type='button' class='btn' name='' alt='".$text['button-certificate']."' onclick=\"window.location='".PROJECT_PATH."/app/certificates/index.php?name=".urlencode(escape($contact_name_given)." ".escape($contact_name_family))."'\" value='".$text['button-certificate']."'>\n"; echo " <input type='button' class='btn' name='' alt='".$text['button-certificate']."' onclick=\"window.location='".PROJECT_PATH."/app/certificates/index.php?name=".urlencode(escape($contact_name_given)." ".escape($contact_name_family))."'\" value='".$text['button-certificate']."'>\n";
} }
if ($action == "update" && permission_exists('user_edit') && is_uuid($contact_user_uuid)) {
echo " <input type='button' class='btn' name='' alt='".$text['button-user']."' onclick=\"window.location='".PROJECT_PATH."/core/users/user_edit.php?id=".$contact_user_uuid."'\" value='".$text['button-user']."'>\n";
}
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";

View File

@ -730,9 +730,13 @@
echo " <tr>"; echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-contact']."</td>"; echo " <td class='vncell' valign='top'>".$text['label-contact']."</td>";
echo " <td class='vtable'>\n"; echo " <td class='vtable'>\n";
$sql = " select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname from v_contacts "; $sql = "select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname from v_contacts ";
$sql .= " where domain_uuid = '".escape($domain_uuid)."' "; $sql .= "where domain_uuid = '".escape($domain_uuid)."' ";
$sql .= " order by contact_organization desc, contact_name_family asc, contact_name_given asc, contact_nickname asc "; $sql .= "and ( ";
$sql .= " contact_uuid = '".escape($contact_uuid)."' or ";
$sql .= " contact_uuid not in (select contact_uuid from v_users where domain_uuid = '".escape($domain_uuid)."') ";
$sql .= ") ";
$sql .= "order by contact_organization desc, contact_name_family asc, contact_name_given asc, contact_nickname asc ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);