From: Stéphane Jacob Date: Sat, 17 Jul 2010 11:47:34 +0000 (+0200) Subject: Adds notion of directory name for users. X-Git-Tag: xorg/1.0.1~330 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;ds=sidebyside;h=d081acb2132aa95d1c70197a6735b7103df103f3;p=platal.git Adds notion of directory name for users. Signed-off-by: Stéphane Jacob --- diff --git a/classes/user.php b/classes/user.php index 2a399ad..55d8d1a 100644 --- a/classes/user.php +++ b/classes/user.php @@ -179,7 +179,7 @@ class User extends PlUser CONCAT(af.alias, \'@' . $globals->mail->domain2 . '\') AS forlife_alternate, IF (ab.alias IS NULL, a.email, CONCAT(ab.alias, \'@' . $globals->mail->domain . '\')) AS bestalias, CONCAT(ab.alias, \'@' . $globals->mail->domain2 . '\') AS bestalias_alternate, - a.full_name, a.display_name, a.sex = \'female\' AS gender, + a.full_name, a.directory_name, a.display_name, a.sex = \'female\' AS gender, IF(a.state = \'active\', at.perms, \'\') AS perms, a.email_format, a.is_admin, a.state, a.type, a.skin, FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment, @@ -307,7 +307,7 @@ class User extends PlUser public function directoryName() { if (!$this->hasProfile()) { - return $this->full_name; + return $this->directory_name; } return $this->profile()->directory_name; } diff --git a/modules/admin.php b/modules/admin.php index 5f3ba19..9621f21 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -421,6 +421,10 @@ class AdminModule extends PLModule // XXX: Update profile if a profile is associated $to_update['display_name'] = Post::s('display_name'); } + if (Post::s('directory_name') != $user->directoryName()) { + // XXX: Update profile if a profile is associated + $to_update['directory_name'] = Post::s('directory_name'); + } if (Post::s('sex') != ($user->isFemale() ? 'female' : 'male')) { $to_update['sex'] = Post::s('sex'); } diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 7cf8d26..b46ffed 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -867,9 +867,9 @@ class XnetGrpModule extends PLModule $from_email = $user->forlifeEmail(); if (!$user->profile()) { XDB::query('UPDATE accounts - SET full_name = {?}, display_name = {?}, sex = {?}, email = {?}, type = {?} + SET full_name = {?}, directory_name = {?}, display_name = {?}, sex = {?}, email = {?}, type = {?} WHERE uid = {?}', - Post::v('full_name'), Post::v('display_name'), (Post::v('sex') == 'male')?'male':'female', Post::v('email'), (Post::v('type') == 'xnet')?'xnet':'virtual', + Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'), (Post::v('sex') == 'male')?'male':'female', Post::v('email'), (Post::v('type') == 'xnet')?'xnet':'virtual', $user->id()); if (XDB::affectedRows()) { $page->trigSuccess('Données de l\'utilisateur mise à jour.'); diff --git a/templates/admin/user.tpl b/templates/admin/user.tpl index 9ee2da7..115b517 100644 --- a/templates/admin/user.tpl +++ b/templates/admin/user.tpl @@ -130,6 +130,10 @@ $(document).ready(function() { + Nom annuaire + + + Nom affiché diff --git a/templates/xnetgrp/membres-edit.tpl b/templates/xnetgrp/membres-edit.tpl index 1b506c6..fe25f63 100644 --- a/templates/xnetgrp/membres-edit.tpl +++ b/templates/xnetgrp/membres-edit.tpl @@ -93,6 +93,14 @@ profile()} disabled="disabled"{/if} /> + + + Nom annuaire : + + + profile()} disabled="disabled"{/if} /> + + type eq "virtual"}style="display: none"{/if}> Sexe : diff --git a/upgrade/1.0.1/02_accounts.sql b/upgrade/1.0.1/02_accounts.sql new file mode 100644 index 0000000..342e174 --- /dev/null +++ b/upgrade/1.0.1/02_accounts.sql @@ -0,0 +1,8 @@ +ALTER TABLE accounts ADD COLUMN directory_name VARCHAR(255) DEFAULT NULL; +UPDATE accounts AS a + SET a.directory_name = (SELECT pd.directory_name + FROM profile_display AS pd + INNER JOIN account_profiles AS ap ON (ap.uid = pd.pid AND FIND_IN_SET('owner', perms)) + WHERE a.uid = ap.uid); + +-- vim:set syntax=mysql: