# HG changeset patch # User Dan Fuhry # Date 1361065665 18000 # Node ID faf6f7941e8f1e640bbcf781f92e8a867f82b731 # Parent 3ac4e03f28b28f92cb29d7e41e407d1fb6bfd50f Enhancements to User CP - handle attribute deletion/mod more gracefully diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/templates/header.tpl --- a/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/templates/header.tpl Sat Feb 16 19:02:51 2013 -0500 +++ b/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/templates/header.tpl Sat Feb 16 20:47:45 2013 -0500 @@ -5,7 +5,7 @@ {$title} • SSO-in-a-Box Control Panel - + diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/templates/my-account.tpl --- a/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/templates/my-account.tpl Sat Feb 16 19:02:51 2013 -0500 +++ b/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/templates/my-account.tpl Sat Feb 16 20:47:45 2013 -0500 @@ -26,7 +26,7 @@
- +

Enter an e-mail address if you want to be able to use password recovery.

diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/index.php --- a/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/index.php Sat Feb 16 19:02:51 2013 -0500 +++ b/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/index.php Sat Feb 16 20:47:45 2013 -0500 @@ -42,10 +42,36 @@ break; case 'profile-update': // header('Content-type: text/plain'); print_r(!empty($_POST['sshPublicKey']) ? $_POST['sshPublicKey'] : array()); exit; - $result = ldap_mod_replace($_ldapconn, ldap_make_user_dn($_SERVER['REMOTE_USER']), array( - 'mail' => array($_POST['mail']) - , 'sshPublicKey' => !empty($_POST['sshPublicKey']) ? array_unique($_POST['sshPublicKey']) : array() - )); + $ui = ldap_get_user($_SERVER['REMOTE_USER']); + + foreach ( array('mail', 'sshPublicKey') as $field ) + { + if ( empty($_POST[$field]) && empty($ui[$field]) ) + { + // both empty, do nothing + } + else if ( empty($_POST[$field]) && !empty($ui[$field]) ) + { + // POST empty, database not. Delete attr. + $result = ldap_mod_del($_ldapconn, ldap_make_user_dn($_SERVER['REMOTE_USER']), array( + $field => array() + )); + } + else if ( !empty($_POST[$field]) && empty($ui[$field]) ) + { + // POST filled, database empty. Add attr. + $result = ldap_mod_add($_ldapconn, ldap_make_user_dn($_SERVER['REMOTE_USER']), array( + $field => is_array($_POST[$field]) ? array_unique($_POST[$field]) : array($_POST[$field]) + )); + } + else if ( !empty($_POST[$field]) && !empty($ui[$field]) ) + { + // POST and database filled. Replace attr. + $result = ldap_mod_replace($_ldapconn, ldap_make_user_dn($_SERVER['REMOTE_USER']), array( + $field => is_array($_POST[$field]) ? array_unique($_POST[$field]) : array($_POST[$field]) + )); + } + } if ( $result || ldap_error($_ldapconn) === 'Success' ) { diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/asc.gif Binary file packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/asc.gif has changed diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/bg.gif Binary file packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/bg.gif has changed diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/desc.gif Binary file packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/desc.gif has changed diff -r 3ac4e03f28b2 -r faf6f7941e8f packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/style.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/res/tablesorter/themes/bootstrap/style.css Sat Feb 16 20:47:45 2013 -0500 @@ -0,0 +1,14 @@ +/* tables */ + +table.tablesorter thead tr .header { + background-image: url(bg.gif); + background-repeat: no-repeat; + background-position: center right; + cursor: pointer; +} +table.tablesorter thead tr .headerSortUp { + background-image: url(asc.gif); +} +table.tablesorter thead tr .headerSortDown { + background-image: url(desc.gif); +}