Merge commit 'origin/fusionax' into account
authorVincent Zanotti <vincent.zanotti@m4x.org>
Fri, 10 Apr 2009 16:48:39 +0000 (18:48 +0200)
committerVincent Zanotti <vincent.zanotti@m4x.org>
Fri, 10 Apr 2009 16:48:39 +0000 (18:48 +0200)
Conflicts:
modules/admin.php

Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
1  2 
Makefile
include/wiki/farmconfig.php
modules/admin.php
modules/profile.php
modules/profile/jobs.inc.php
modules/profile/mentor.inc.php
templates/xnetgrp/inscrire.tpl

diff --cc Makefile
Simple merge
Simple merge
@@@ -49,7 -48,7 +49,8 @@@ class AdminModule extends PLModul
              'admin/ipwatch'                => $this->make_hook('ipwatch', AUTH_MDP, 'admin'),
              'admin/icons'                  => $this->make_hook('icons', AUTH_MDP, 'admin'),
              'admin/accounts'               => $this->make_hook('accounts', AUTH_MDP, 'admin'),
 +            'admin/account/types'          => $this->make_hook('account_types', AUTH_MDP, 'admin'),
+             'admin/jobs'                   => $this->make_hook('jobs', AUTH_MDP, 'admin'),
          );
      }
  
      function handler_accounts(&$page)
      {
          $page->changeTpl('admin/accounts.tpl');
 -        $page->assign('disabled', XDB::iterator('SELECT  u.nom, u.prenom, u.promo, u.comment, u.hruid
 -                                                   FROM  auth_user_md5 AS u
 -                                                  WHERE  perms = \'disabled\'
 -                                               ORDER BY  nom, prenom'));
 -        $page->assign('admins', XDB::iterator('SELECT  u.nom, u.prenom, u.promo, u.hruid
 -                                                 FROM  auth_user_md5 AS u
 -                                                WHERE  perms = \'admin\'
 -                                             ORDER BY  nom, prenom'));
 +        $page->assign('disabled', XDB::iterator('SELECT  a.hruid, FIND_IN_SET(\'watch\', a.flags) AS watch,
 +                                                         a.state = \'disabled\' AS disabled, a.comment
 +                                                   FROM  accounts AS a
 +                                                  WHERE  a.state = \'disabled\' OR FIND_IN_SET(\'watch\', a.flags)
 +                                               ORDER BY  a.hruid'));
 +        $page->assign('admins', XDB::iterator('SELECT  a.hruid
 +                                                 FROM  accounts AS a
 +                                                WHERE  a.is_admin
 +                                             ORDER BY  a.hruid'));
      }
+     function handler_jobs(&$page, $id = -1)
+     {
+         $page->changeTpl('admin/jobs.tpl');
+         if (Env::has('search')) {
+             $res = XDB::query("SELECT  e.id, e.name, e.acronym
+                                  FROM  profile_job_enum AS e
+                                 WHERE  e.name LIKE CONCAT('% ', {?}, '%') OR e.acronym LIKE CONCAT('% ', {?}, '%')",
+                               Env::t('job'), Env::t('job'));
+             if ($res->numRows() <= 20) {
+                 $page->assign('jobs', $res->fetchAllAssoc());
+             } else {
+                 $page->trigError("Il y a trop d'entreprises correspondant à ton choix. Affine-le !");
+             }
+             $page->assign('askedJob', Env::v('job'));
+             return;
+         }
+         if (Env::has('edit')) {
+             S::assert_xsrf_token();
+             $selectedJob = Env::has('selectedJob');
+             if (Env::has('change')) {
+                 XDB::execute('UPDATE  profile_job
+                                  SET  jobid = {?}
+                                WHERE  jobid = {?}',
+                              Env::i('newJobId'), $id);
+                 XDB::execute('DELETE FROM  profile_job_enum
+                                     WHERE  id = {?}',
+                              $id);
+                 $page->trigSuccess("L'entreprise a bien été remplacée.");
+             } else {
+                 XDB::execute('UPDATE  profile_job_enum
+                                  SET  name = {?}, acronym = {?}, url = {?}, email = {?},
+                                       NAF_code = {?}, AX_code = {?}, holdingid = {?}
+                                WHERE  id = {?}',
+                              Env::t('name'), Env::t('acronym'), Env::t('url'), Env::t('email'),
+                              Env::t('NAF_code'), Env::i('AX_code'), Env::i('holdingId'), $id);
+                 $page->trigSuccess("L'entreprise a bien été mise à jour.");
+             }
+         }
+         if (!Env::has('change') && $id != -1) {
+             $res = XDB::query('SELECT  e.id, e.name, e.acronym, e.url, e.email, e.NAF_code, e.AX_code,
+                                        h.id AS holdingId, h.name AS holdingName, h.acronym AS holdingAcronym
+                                  FROM  profile_job_enum AS e
+                             LEFT JOIN  profile_job_enum AS h ON (e.holdingid = h.id)
+                                 WHERE  e.id = {?}',
+                               $id);
+             if ($res->numRows() == 0) {
+                 $page->trigError('Auncune entreprise ne correspond à cet identifiant.');
+             } else {
+                 $page->assign('selectedJob', $res->fetchOneAssoc());
+             }
+         }
+     }
  }
  
  // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
Simple merge
@@@ -227,9 -227,9 +227,9 @@@ class ProfileJobs extends ProfilePag
                            LEFT JOIN  profile_addresses             AS ah ON (ah.jobid = j.jobid AND ah.type = 'hq')
                                WHERE  j.uid = {?}
                             ORDER BY  j.id",
 -                            S::i('uid'));
 +                            $this->pid());
          $this->values['jobs'] = array();
-         while (list($id, $jobid, $name, $function, $sector, $subSector, $subSubSector,
+         while (list($id, $jobid, $name, $sector, $subSector, $subSubSector,
                      $subSubSectorName, $description, $w_email, $w_emailPub, $w_url, $pub,
                      $hq_acronym, $hq_url, $hq_email,
                      $w_accuracy, $w_text, $w_postalText, $w_postalCode, $w_localityId,
@@@ -61,11 -61,11 +61,11 @@@ class ProfileSectors implements Profile
          if (!count($value)) {
              return;
          }
-         foreach ($value as $id=>&$sect) {
-             foreach ($sect as $sid=>&$name) {
+         foreach ($value as $id => $sect) {
+             foreach ($sect as $sid => $name) {
                  XDB::execute("INSERT INTO  profile_mentor_sector (uid, sectorid, subsectorid)
                                     VALUES  ({?}, {?}, {?})",
 -                             S::i('uid'), $id, $sid);
 +                             $page->pid(), $id, $sid);
              }
          }
      }
@@@ -125,9 -125,9 +125,9 @@@ class ProfileMentor extends ProfilePag
      protected function _fetchData()
      {
          $res = XDB::query("SELECT  expertise
-                              FROM  mentor
+                              FROM  profile_mentor
                              WHERE  uid = {?}",
 -                          S::i('uid'));
 +                          $this->pid());
          $this->values['expertise'] = $res->fetchOneCell();
      }
  
          if ($this->changed['expertise']) {
              $expertise = trim($this->values['expertise']);
              if (empty($expertise)) {
-                 XDB::execute("DELETE FROM  mentor
+                 XDB::execute("DELETE FROM  profile_mentor
                                      WHERE  uid = {?}",
 -                             S::i('uid'));
 +                             $this->pid());
                  $this->values['expertise'] = null;
              } else {
-                 XDB::execute("REPLACE INTO  mentor (uid, expertise)
+                 XDB::execute("REPLACE INTO  profile_mentor (uid, expertise)
                                      VALUES  ({?}, {?})",
 -                             S::i('uid'), $expertise);
 +                             $this->pid(), $expertise);
                  $this->values['expertise'] = $expertise;
              }
          }
Simple merge