List last profile modifications for secretary verifications (Closes #1362).
authorStéphane Jacob <sj@m4x.org>
Mon, 6 Dec 2010 14:38:25 +0000 (15:38 +0100)
committerStéphane Jacob <sj@m4x.org>
Mon, 6 Dec 2010 15:50:05 +0000 (16:50 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/admin.php
modules/profile/page.inc.php
templates/admin/index.tpl

index 30db8ef..0ef787e 100644 (file)
@@ -51,6 +51,7 @@ class AdminModule extends PLModule
             'admin/account/watch'          => $this->make_hook('account_watch',          AUTH_MDP, 'admin'),
             'admin/account/types'          => $this->make_hook('account_types',          AUTH_MDP, 'admin'),
             'admin/jobs'                   => $this->make_hook('jobs',                   AUTH_MDP, 'admin,edit_directory'),
+            'admin/profile'                => $this->make_hook('profile',                AUTH_MDP, 'admin,edit_directory')
         );
     }
 
@@ -1539,6 +1540,37 @@ class AdminModule extends PLModule
             }
         }
     }
+
+    function handler_profile(&$page)
+    {
+        $page->changeTpl('admin/profile.tpl');
+
+        if (Post::has('checked')) {
+            S::assert_xsrf_token();
+            $res = XDB::iterator('SELECT  DISTINCT(pm.pid), pd.public_name
+                                    FROM  profile_modifications AS pm
+                              INNER JOIN  profile_display       AS pd ON (pm.pid = pd.pid)
+                                   WHERE  pm.type = \'self\'');
+
+            while ($profile = $res->next()) {
+                if (Post::has('checked_' . $profile['pid'])) {
+                    XDB::execute('DELETE FROM  profile_modifications
+                                        WHERE  type = \'self\' AND pid = {?}', $profile['pid']);
+
+                    $page->trigSuccess('Profil de ' . $profile['public_name'] . ' vérifié.');
+                }
+            }
+        }
+
+        $res = XDB::iterator('SELECT  p.hrpid, pm.pid, pd.directory_name, GROUP_CONCAT(pm.field SEPARATOR \', \') AS field
+                                FROM  profile_modifications AS pm
+                          INNER JOIN  profiles              AS p  ON (pm.pid = p.pid)
+                          INNER JOIN  profile_display       AS pd ON (pm.pid = pd.pid)
+                               WHERE  pm.type = \'self\'
+                            GROUP BY  pd.directory_name
+                            ORDER BY  pd.directory_name');
+        $page->assign('updates', $res);
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index becd6d1..5487bdf 100644 (file)
@@ -310,7 +310,8 @@ abstract class ProfilePage implements PlWizardPage
                                    VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, NOW())
                   ON DUPLICATE KEY UPDATE  uid = VALUES(uid), oldText = IF(VALUES(type) != type, VALUES(oldText), oldText),
                                            newText = VALUES(newText), type = VALUES(type), timestamp = NOW()',
-                             $this->pid(), $user->id(), $field, $values[0], $values[1], ($owner->id() == $user->id()) ? 'self' : 'third_party');
+                             $this->pid(), $user->id(), Profile::$descriptions[$field], $values[0], $values[1],
+                             ($owner->id() == $user->id()) ? 'self' : 'third_party');
             }
         }
         return true;
index 48e621e..d5360c7 100644 (file)
       <a href="admin/names">Noms</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/networking">Networking</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/profile">Modifications récentes</a>
     </td>
   </tr>
   <tr class="pair">