Example #1
0
 public function __construct()
 {
     global $globals;
     parent::__construct();
     // Set the default page
     $this->changeTpl('platal/index.tpl');
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
         $this->addJsLink('json2.js');
     }
     $this->addJsLink('jquery.xorg.js');
     $this->addJsLink('overlib.js');
     $this->addJsLink('core.js');
     $this->addJsLink('xorg.js');
     if ($globals->core->sentry_js_dsn) {
         $this->addJsLink('raven.min.js');
     }
     $this->setTitle('le site des élèves et anciens élèves de l\'École polytechnique');
     if (S::logged() && S::user()->checkPerms('admin')) {
         $types = array(S::user()->type);
         $perms = DirEnum::getOptions(DirEnum::ACCOUNTTYPES);
         ksort($perms);
         foreach ($perms as $type => $perm) {
             if (!empty($perm) && $type != $types[0]) {
                 $types[] = $type;
             }
         }
         $this->assign('account_types_list', $types);
         $skins = DirEnum::getOptions(DirEnum::SKINS);
         asort($skins);
         $this->assign('skin_list', $skins);
     }
 }
Example #2
0
 public function getText($value)
 {
     $medalsList = DirEnum::getOptions(DirEnum::MEDALS);
     $medals = array();
     foreach ($value as $id => $medal) {
         $medals[] = $medalsList[$id];
     }
     return implode(', ', $medals);
 }
Example #3
0
 protected function buildEntry($pf)
 {
     global $globals;
     $pf = $pf['value'];
     $entry = new PlVCardEntry($pf->firstNames(), $pf->lastNames(), null, null, $pf->nickname);
     $user = $pf->owner();
     // Free text
     $freetext = '(' . $pf->promo . ')';
     if ($this->freetext) {
         $freetext .= "\n" . $this->freetext;
     }
     $entry->set('NOTE', $freetext);
     if ($pf->mobile) {
         $entry->addTel(null, $pf->mobile, false, true, true, false, true, true);
     }
     // Emails
     if (!is_null($user)) {
         $entry->addMail(null, $user->bestalias, true);
         if ($user->forlife != $user->bestalias) {
             $entry->addMail(null, $user->forlife);
         }
         if ($user->forlife_alternate != $user->bestalias) {
             $entry->addMail(null, $user->forlife_alternate);
         }
     }
     // Homes
     $adrs = $pf->iterAddresses(Profile::ADDRESS_PERSO);
     while ($adr = $adrs->next()) {
         if (!$adr->postalCode || !$adr->locality || !$adr->country) {
             $group = $entry->addHome($adr->text, null, null, null, null, $adr->administrativeArea, null, $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail'));
         } else {
             $group = $entry->addHome(trim(Geocoder::getFirstLines($adr->text, $adr->postalCode, 4)), null, null, $adr->postalCode, $adr->locality, $adr->administrativeArea, $adr->country, $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail'));
         }
         foreach ($adr->phones() as $phone) {
             if ($phone->link_type == Phone::TYPE_FIXED) {
                 $entry->addTel($group, $phone->display, false, true, true, false, false, $adr->hasFlag('current') && empty($pf->mobile));
             } else {
                 if ($phone->link_type == Phone::TYPE_FAX) {
                     $entry->addTel($group, $phone->display, true, false, false, false, false, false);
                 }
             }
         }
     }
     // Pro
     $jobs = $pf->getJobs();
     foreach ($jobs as $job) {
         $terms_array = array();
         foreach ($job->terms as $term) {
             $terms_array[] = $term->full_name;
         }
         $terms = implode(', ', $terms_array);
         if ($job->address) {
             if (!$job->address->postalCode || !$job->address->locality || !$job->address->country) {
                 $group = $entry->addWork($job->company->name, null, $job->description, $terms, $job->address->text, null, null, null, null, $job->address->administrativeArea, null);
             } else {
                 $group = $entry->addWork($job->company->name, null, $job->description, $terms, trim(Geocoder::getFirstLines($job->address->text, $job->address->postalCode, 4)), null, null, $job->address->postalCode, $job->address->locality, $job->address->administrativeArea, $job->address->country);
             }
         } else {
             $group = $entry->addWork($job->company->name, null, $job->description, $terms, null, null, null, null, null, null, null);
         }
         if ($job->user_email) {
             $entry->addMail($group, $job->user_email);
         }
         foreach ($job->phones as $phone) {
             if ($phone->type == Phone::TYPE_MOBILE) {
                 $entry->addTel($group, $phone->display, false, true, true, false, true);
             } else {
                 if ($phone->type == Phone::TYPE_FAX) {
                     $entry->addTel($group, $phone->display, true);
                 } else {
                     $entry->addTel($group, $phone->display, false, true, true);
                 }
             }
         }
     }
     // Melix
     if (!is_null($user)) {
         $alias = $user->emailAlias();
         if (!is_null($alias) && $pf->alias_pub == 'public') {
             $entry->addMail(null, $alias);
         }
     }
     // Custom fields
     if (!is_null($user)) {
         $groups = $user->groups(true, true);
         if (count($groups)) {
             $gn = DirEnum::getOptions(DirEnum::GROUPESX);
             $gns = array();
             foreach (array_keys($groups) as $gid) {
                 $gns[$gid] = $gn[$gid];
             }
             $entry->set('X-GROUPS', join(', ', $gns));
         }
     }
     $binets = $pf->getBinets();
     if (count($binets)) {
         $bn = DirEnum::getOptions(DirEnum::BINETS);
         $bns = array();
         foreach ($binets as $bid) {
             $bns[$bid] = $bn[$bid];
         }
         $entry->set('X-BINETS', join(', ', $bns));
     }
     if (!empty($pf->section)) {
         $entry->set('X-SECTION', $pf->section);
     }
     // Photo
     if ($this->photos) {
         $res = XDB::query("SELECT  attach, attachmime\n                       FROM  profile_photos\n                      WHERE  pid = {?} AND pub IN ('public', {?})", $pf->id(), $this->visibility->level());
         if ($res->numRows()) {
             list($data, $type) = $res->fetchOneRow();
             $entry->setPhoto($data, strtoupper($type));
         }
     }
     return $entry;
 }
Example #4
0
 /** Import de l'annuaire de l'AX depuis l'export situé dans le home de jacou */
 function handler_import($page, $action = 'index', $file = '')
 {
     global $globals;
     if ($action == 'index') {
         $page->changeTpl('fusionax/import.tpl');
         return;
     }
     // toutes les actions sont faites en ajax en utilisant jquery
     header('Content-type: text/javascript; charset=utf-8');
     // log des actions
     $report = array();
     $modulepath = realpath(dirname(__FILE__) . '/fusionax/') . '/';
     $spoolpath = realpath(dirname(__FILE__) . '/../spool/fusionax/') . '/';
     if ($action == 'launch') {
         if ($file == '') {
             $report[] = 'Nom de fichier non renseigné.';
         } elseif (!file_exists(dirname(__FILE__) . '/../spool/fusionax/' . $file)) {
             $report[] = 'Le fichier ne se situe pas au bon endroit.';
         } else {
             // séparation de l'archive en fichiers par tables
             $file = $spoolpath . $file;
             // Split export into specialised files
             exec('grep "^AD" ' . $file . ' > ' . $spoolpath . 'Adresses.txt');
             exec('grep "^AN" ' . $file . ' > ' . $spoolpath . 'Anciens.txt');
             exec('grep "^FO.[0-9]\\{4\\}[MD][0-9]\\{3\\}.Etudiant" ' . $file . ' > ' . $spoolpath . 'Formations_MD.txt');
             exec('grep "^FO.[0-9]\\{4\\}[MD][0-9]\\{3\\}.Doct. de" ' . $file . ' >> ' . $spoolpath . 'Formations_MD.txt');
             exec('grep "^FO" ' . $file . ' > ' . $spoolpath . 'Formations.txt');
             exec('grep "^AC" ' . $file . ' > ' . $spoolpath . 'Activites.txt');
             exec('grep "^EN" ' . $file . ' > ' . $spoolpath . 'Entreprises.txt');
             exec($modulepath . 'formation.pl');
             exec('mv -f ' . $spoolpath . 'Formations_out.txt ' . $spoolpath . 'Formations.txt');
             exec('mv -f ' . $spoolpath . 'Formations_MD_out.txt ' . $spoolpath . 'Formations_MD.txt');
             $report[] = 'Fichier parsé.';
             $report[] = 'Import dans la base en cours...';
             XDB::execute("UPDATE  profiles\n                                 SET  ax_id = NULL\n                               WHERE  ax_id = ''");
             $next = 'integrateSQL';
         }
     } elseif ($action == 'integrateSQL') {
         // intégration des données dans la base MySQL
         // liste des fichiers sql à exécuter
         $filesSQL = array(0 => 'Activites.sql', 1 => 'Adresses.sql', 2 => 'Anciens.sql', 3 => 'Formations.sql', 4 => 'Entreprises.sql', 5 => 'Formations_MD.sql');
         if ($file != '') {
             // récupère le contenu du fichier sql
             $queries = explode(';', file_get_contents($modulepath . $filesSQL[$file]));
             $db = mysqli_init();
             $db->options(MYSQLI_OPT_LOCAL_INFILE, true);
             $db->real_connect($globals->dbhost, $globals->dbuser, $globals->dbpwd, $globals->dbdb);
             $db->autocommit(true);
             $db->set_charset($globals->dbcharset);
             foreach ($queries as $q) {
                 if (trim($q)) {
                     // coupe le fichier en requêtes individuelles
                     if (substr($q, 0, 2) == '--') {
                         // affiche les commentaires dans le report
                         $lines = explode("\n", $q);
                         $l = $lines[0];
                         $report[] = addslashes($l);
                     }
                     // exécute la requête
                     $res = $db->query(str_replace('{?}', $spoolpath, $q));
                     if ($res === false) {
                         throw new XDBException($q, $db->error);
                     }
                 }
             }
             $db->close();
             // trouve le prochain fichier à exécuter
             $nextfile = $file + 1;
         } else {
             $nextfile = 0;
         }
         if ($nextfile > 5) {
             // tous les fichiers ont été exécutés, on passe à l'étape suivante
             $next = 'adds1920';
         } else {
             // on passe au fichier suivant
             $next = 'integrateSQL/' . $nextfile;
         }
     } elseif ($action == 'adds1920') {
         // Adds promotion 1920 from AX db.
         $report[] = 'Ajout de la promotion 1920';
         $res = XDB::iterator('SELECT  prenom, Nom_complet, ax_id
                                 FROM  fusionax_anciens
                                WHERE  promotion_etude = 1920;');
         $eduSchools = DirEnum::getOptions(DirEnum::EDUSCHOOLS);
         $eduSchools = array_flip($eduSchools);
         $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES);
         $eduDegrees = array_flip($eduDegrees);
         $degreeid = $eduDegrees[Profile::DEGREE_X];
         $entry_year = 1920;
         $grad_year = 1923;
         $promo = 'X1920';
         $hrpromo = '1920';
         $sex = 'male';
         $xorgId = 19200000;
         $type = 'x';
         while ($new = $res->next()) {
             $firstname = $new['prenom'];
             $lastname = $new['Nom_complet'];
             $ax_id = $new['ax_id'];
             $hrid = User::makeHrid($firstname, $lastname, $hrpromo);
             $res1 = XDB::query('SELECT  COUNT(*)
                                   FROM  accounts
                                  WHERE  hruid = {?}', $hrid);
             $res2 = XDB::query('SELECT  COUNT(*)
                                   FROM  profiles
                                  WHERE  hrpid = {?}', $hrid);
             if (is_null($hrid) || $res1->fetchOneCell() > 0 || $res2->fetchOneCell() > 0) {
                 $report[] = $ax_id . ' non ajouté';
             }
             $fullName = $firstname . ' ' . $lastname;
             $directoryName = $lastname . ' ' . $firstname;
             ++$xorgId;
             XDB::execute('INSERT INTO  profiles (hrpid, xorg_id, ax_id, sex)
                                VALUES  ({?}, {?}, {?}, {?})', $hrid, $xorgId, $ax_id, $sex);
             $pid = XDB::insertId();
             XDB::execute('INSERT INTO  profile_public_names (pid, lastname_initial, firstname_initial, lastname_main, firstname_main)
                                VALUES  ({?}, {?}, {?}, {?}, {?})', $pid, $lastname, $firstname, $lastname, $firstname);
             XDB::execute('INSERT INTO  profile_display (pid, yourself, public_name, private_name,
                                                         directory_name, short_name, sort_name, promo)
                                VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $pid, $firstname, $fullName, $fullName, $directoryName, $fullName, $directoryName, $promo);
             XDB::execute('INSERT INTO  profile_education (pid, eduid, degreeid, entry_year, grad_year, flags)
                                VALUES  ({?}, {?}, {?}, {?}, {?}, {?})', $pid, $eduSchools[Profile::EDU_X], $degreeid, $entry_year, $grad_year, 'primary');
             XDB::execute('INSERT INTO  accounts (hruid, type, is_admin, state, full_name, directory_name, display_name, lastname, firstname, sex)
                                VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', $hrid, $type, 0, 'pending', $fullName, $directoryName, $firstname, $lastname, $firstname, $sex);
             $uid = XDB::insertId();
             XDB::execute('INSERT INTO  account_profiles (uid, pid, perms)
                                VALUES  ({?}, {?}, {?})', $uid, $pid, 'owner');
         }
         $report[] = 'Promo 1920 ajoutée.';
         $next = 'view';
     } elseif ($action == 'view') {
         XDB::execute('CREATE OR REPLACE ALGORITHM=MERGE VIEW  fusionax_xorg_anciens AS
                                                       SELECT  p.pid, p.ax_id, pd.promo, pd.private_name, pd.public_name,
                                                               pd.sort_name, pd.short_name, pd.directory_name
                                                         FROM  profiles        AS p
                                                   INNER JOIN  profile_display AS pd ON (pd.pid = p.pid)');
         $next = 'clean';
     } elseif ($action == 'clean') {
         // nettoyage du fichier temporaire
         //exec('rm -Rf ' . $spoolpath);
         $report[] = 'Import finit.';
     }
     foreach ($report as $t) {
         // affiche les lignes de report
         echo "\$('#fusionax').append('" . $t . "<br/>');\n";
     }
     if (isset($next)) {
         // lance le prochain script s'il y en a un
         echo "\$.getScript('fusionax/import/" . $next . "');";
     }
     // exit pour ne pas afficher la page template par défaut
     exit;
 }
Example #5
0
 function handler_add_secondary_edu($page)
 {
     $page->changeTpl('admin/add_secondary_edu.tpl');
     if (!(Post::has('verify') || Post::has('add'))) {
         return;
     } elseif (!Post::has('people')) {
         $page->trigWarning("Aucune information n'a été fournie.");
         return;
     }
     require_once 'name.func.inc.php';
     $lines = explode("\n", Post::t('people'));
     $separator = Post::t('separator');
     $degree = Post::v('degree');
     $promotion = Post::i('promotion');
     $schoolsList = array_flip(DirEnum::getOptions(DirEnum::EDUSCHOOLS));
     $degreesList = array_flip(DirEnum::getOptions(DirEnum::EDUDEGREES));
     $edu_id = $schoolsList[Profile::EDU_X];
     $degree_id = $degreesList[$degree];
     $res = array('incomplete' => array(), 'empty' => array(), 'multiple' => array(), 'already' => array(), 'new' => array());
     $old_pids = array();
     $new_pids = array();
     foreach ($lines as $line) {
         $line = trim($line);
         $line_array = explode($separator, $line);
         array_walk($line_array, 'trim');
         if (count($line_array) != 3) {
             $page->trigError("La ligne « {$line} » est incomplète.");
             $res['incomplete'][] = $line;
             continue;
         }
         $cond = new PFC_And(new UFC_NameTokens(split_name_for_search($line_array[0]), array(), false, false, Profile::LASTNAME));
         $cond->addChild(new UFC_NameTokens(split_name_for_search($line_array[1]), array(), false, false, Profile::FIRSTNAME));
         $cond->addChild(new UFC_Promo('=', UserFilter::DISPLAY, $line_array[2]));
         $uf = new UserFilter($cond);
         $pid = $uf->getPIDs();
         $count = count($pid);
         if ($count == 0) {
             $page->trigError("La ligne « {$line} » ne correspond à aucun profil existant.");
             $res['empty'][] = $line;
             continue;
         } elseif ($count > 1) {
             $page->trigError("La ligne « {$line} » correspond à plusieurs profils existant.");
             $res['multiple'][] = $line;
             continue;
         } else {
             $count = XDB::fetchOneCell('SELECT  COUNT(*) AS count
                                           FROM  profile_education
                                          WHERE  pid = {?} AND eduid = {?} AND degreeid = {?}', $pid, $edu_id, $degree_id);
             if ($count == 1) {
                 $res['already'][] = $line;
                 $old_pids[] = $pid[0];
             } else {
                 $res['new'][] = $line;
                 $new_pids[] = $pid[0];
             }
         }
     }
     $display = array();
     foreach ($res as $type => $res_type) {
         if (count($res_type) > 0) {
             $display = array_merge($display, array('--------------------' . $type . ':'), $res_type);
         }
     }
     $page->assign('people', implode("\n", $display));
     $page->assign('promotion', $promotion);
     $page->assign('degree', $degree);
     if (Post::has('add')) {
         $entry_year = $promotion - Profile::educationDuration($degree);
         if (Post::b('force_addition')) {
             $pids = array_unique(array_merge($old_pids, $new_pids));
         } else {
             $pids = array_unique($new_pids);
             // Updates years.
             if (count($old_pids)) {
                 XDB::execute('UPDATE  profile_education
                                  SET  entry_year = {?}, grad_year = {?}, promo_year = {?}
                                WHERE  pid IN {?} AND eduid = {?} AND degreeid = {?}', $entry_year, $promotion, $promotion, $old_pids, $edu_id, $degree_id);
             }
         }
         // Precomputes values common to all users.
         $select = XDB::format('MAX(id) + 1, pid, {?}, {?}, {?}, {?}, {?}, \'secondary\'', $edu_id, $degree_id, $entry_year, $promotion, $promotion);
         XDB::startTransaction();
         foreach ($pids as $pid) {
             XDB::execute('INSERT INTO  profile_education (id, pid, eduid, degreeid, entry_year, grad_year, promo_year, flags)
                                SELECT  ' . $select . '
                                  FROM  profile_education
                                 WHERE  pid = {?}
                              GROUP BY  pid', $pid);
         }
         XDB::commit();
     }
 }
Example #6
0
 public function getText($value)
 {
     static $pubs = array('public' => 'publique', 'ax' => 'annuaire papier', 'private' => 'privé', 'hidden' => 'administrateurs');
     $corpsList = DirEnum::getOptions(DirEnum::ORIGINCORPS);
     $rankList = DirEnum::getOptions(DirEnum::CORPSRANKS);
     return $corpsList[$value['current']] . ', ' . $corpsList[$value['rank']] . ' (' . 'corps d\'origine : ' . $corpsList[$value['original']] . ', affichage ' . $pubs[$value['pub']] . ')';
 }
Example #7
0
 public function getText($value)
 {
     $fieldsList = DirEnum::getOptions(DirEnum::EDUFIELDS);
     $educations = array();
     foreach ($value as $item) {
         $details = array($this->cycles[$item['degreeid']]);
         if ($item['program']) {
             $details[] = '« ' . $item['program'] . ' »';
         }
         if ($item['fieldid']) {
             $details[] = $fieldsList[$item['fieldid']];
         }
     }
     return implode(', ', $educations);
 }
Example #8
0
 /**
  * Retrieve the name of the corps which has been done.
  *
  * Note: this function first tries getCorps(), and if this field is blank
  * tries to find an education which degree is "Corps".
  *
  * Returns an empty string if nothing has been found.
  */
 public function getCorpsName()
 {
     $corps = $this->getCorps();
     if ($corps && $corps->current) {
         $corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS);
         return $corpsList[$corps->current];
     }
     foreach ($this->getExtraEducations() as $edu) {
         if (!strcasecmp($edu->degree, 'Corps')) {
             if ($edu->school_short) {
                 return $edu->school_short;
             } elseif ($edu->school) {
                 return $edu->school;
             }
         }
     }
     return '';
 }
Example #9
0
 function handler_broken_addr($page)
 {
     require_once 'emails.inc.php';
     $page->changeTpl('emails/broken_addr.tpl');
     if (Env::has('sort_broken')) {
         S::assert_xsrf_token();
         $list = trim(Env::v('list'));
         if ($list == '') {
             $page->trigError('La liste est vide.');
         } else {
             $valid_emails = array();
             $invalid_emails = array();
             $broken_list = explode("\n", $list);
             sort($broken_list);
             foreach ($broken_list as $orig_email) {
                 $orig_email = trim($orig_email);
                 if ($orig_email != '') {
                     $email = valide_email($orig_email);
                     if (empty($email) || $email == '@') {
                         $invalid_emails[] = trim($orig_email) . ': invalid email';
                     } elseif (!in_array($email, $valid_emails)) {
                         $nb = XDB::fetchOneCell('SELECT  COUNT(*)
                                                    FROM  email_redirect_account
                                                   WHERE  redirect = {?}', $email);
                         if ($nb > 0) {
                             $valid_emails[] = $email;
                         } else {
                             $invalid_emails[] = $orig_email . ': no such redirection';
                         }
                     }
                 }
             }
             $page->assign('valid_emails', $valid_emails);
             $page->assign('invalid_emails', $invalid_emails);
         }
     }
     if (Env::has('process_broken')) {
         S::assert_xsrf_token();
         $list = trim(Env::v('list'));
         if ($list == '') {
             $page->trigError('La liste est vide.');
         } else {
             require_once 'notifs.inc.php';
             $broken_user_list = array();
             $broken_user_email_count = array();
             $broken_user_profiles = array();
             $broken_list = explode("\n", $list);
             sort($broken_list);
             foreach ($broken_list as $email) {
                 $email = trim($email);
                 $userobj = null;
                 if ($user = mark_broken_email($email, true)) {
                     $userobj = User::getSilentWithUID($user['uid']);
                 }
                 if (is_null($userobj)) {
                     continue;
                 }
                 $profile = $userobj->profile();
                 if (is_null($profile)) {
                     continue;
                 }
                 if ($user['nb_mails'] > 0 && $user['notify']) {
                     $mail = new PlMailer('emails/broken.mail.tpl');
                     $mail->setTo($userobj);
                     $mail->assign('user', $user);
                     $mail->assign('email', $email);
                     $mail->send();
                 } else {
                     WatchProfileUpdate::register($profile, 'broken');
                 }
                 $pid = $profile->id();
                 if (!isset($broken_user_list[$pid])) {
                     $broken_user_list[$pid] = array($email);
                 } else {
                     $broken_user_list[$pid][] = $email;
                 }
                 $broken_user_email_count[$pid] = $user['nb_mails'];
                 $broken_user_profiles[$pid] = $profile;
             }
             XDB::execute('UPDATE  email_redirect_account
                              SET  broken_level = broken_level - 1
                            WHERE  flags = \'active\' AND broken_level > 1
                                   AND DATE_ADD(last, INTERVAL 1 MONTH) < CURDATE()');
             XDB::execute('UPDATE  email_redirect_account
                              SET  broken_level = 0
                            WHERE  flags = \'active\' AND broken_level = 1
                                   AND DATE_ADD(last, INTERVAL 1 YEAR) < CURDATE()');
             // Sort $broken_user_list with (promo, sortname, pid)
             $sortable_array = array();
             foreach ($broken_user_list as $pid => $mails) {
                 $profile = $broken_user_profiles[$pid];
                 $sortable_array[$pid] = array($profile->promo(), $profile->sortName(), $pid);
             }
             asort($sortable_array);
             // Output the list of users with recently broken addresses,
             // along with the count of valid redirections.
             pl_cached_content_headers('text/x-csv', null, 1, 'broken.csv');
             $csv = fopen('php://output', 'w');
             fputcsv($csv, array('nom', 'promo', 'bounces', 'nbmails', 'url', 'corps', 'job', 'networking'), ';');
             $corpsList = DirEnum::getOptions(DirEnum::CURRENTCORPS);
             foreach (array_keys($sortable_array) as $pid) {
                 $mails = $broken_user_list[$pid];
                 $profile = $broken_user_profiles[$pid];
                 $current_corps = $profile->getCorpsName();
                 $jobs = $profile->getJobs();
                 $companies = array();
                 foreach ($jobs as $job) {
                     $companies[] = $job->company->name;
                 }
                 $networkings = $profile->getNetworking(Profile::NETWORKING_ALL);
                 $networking_list = array();
                 foreach ($networkings as $networking) {
                     $networking_list[] = $networking['address'];
                 }
                 fputcsv($csv, array($profile->fullName(), $profile->promo(), join(',', $mails), $broken_user_email_count[$pid], 'https://www.polytechnique.org/marketing/broken/' . $profile->hrid(), $current_corps, implode(',', $companies), implode(',', $networking_list)), ';');
             }
             fclose($csv);
             exit;
         }
     }
 }
Example #10
0
 public function getText($value)
 {
     $sectionsList = DirEnum::getOptions(DirEnum::SECTIONS);
     return $sectionsList[$value];
 }
Example #11
0
 /** Compute the conditions to use for the current request.
  * @return A PlFilterCondition instance (actually a PFC_And)
  */
 protected function getCond()
 {
     $cond = new PFC_And();
     foreach ($this->criteria as $criterion => $value) {
         switch ($criterion) {
             // ENUM fields
             case WSRequestCriteria::SCHOOL:
                 // Useless criterion: we don't need to check on origin school
                 if (WSRequestCriteria::$choices_enum[$criterion][$value]) {
                     $cond->addChild(new PFC_True());
                 } else {
                     $cond->addChild(new PFC_False());
                 }
                 break;
             case WSRequestCriteria::DIPLOMA:
                 $diploma = WSRequestCriteria::$choices_enum[$criterion][$value];
                 $id_X = XDB::fetchOneCell('SELECT  id
                                          FROM  profile_education_enum
                                         WHERE  abbreviation = {?}', 'X');
                 $cond->addChildren(array(new UFC_EducationSchool($id_X), new UFC_EducationDegree($diploma)));
                 break;
                 // TEXT fields
             // TEXT fields
             case WSRequestCriteria::FIRSTNAME:
             case WSRequestCriteria::LASTNAME:
                 $cond->addChild(new UFC_NameTokens($value, UFC_NameTokens::FLAG_PUBLIC, false, false, $criterion));
                 break;
             case WSRequestCriteria::PROMOTION:
                 $cond->addChild(new PFC_Or(new UFC_Promo(UserFilter::OP_EQUALS, UserFilter::GRADE_ING, $value), new UFC_Promo(UserFilter::OP_EQUALS, UserFilter::GRADE_MST, $value), new UFC_Promo(UserFilter::OP_EQUALS, UserFilter::GRADE_PHD, $value)));
                 break;
             case WSRequestCriteria::ALT_DIPLOMA:
                 $cond->addChild(new UFC_EducationDegree(DirEnum::getIds(DirEnum::EDUDEGREES, $value)));
                 break;
             case WSRequestCriteria::DIPLOMA_FIELD:
                 $cond->addChild(new UFC_EducationField(DirEnum::getIds(DirEnum::EDUFIELDS, $value)));
                 break;
             case WSRequestCriteria::CITY:
                 $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_LOCALITY, UFC_Address::TYPE_HOME, UFC_Address::FLAG_CURRENT));
                 break;
             case WSRequestCriteria::COUNTRY:
                 $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_COUNTRY, UFC_Address::TYPE_HOME, UFC_Address::FLAG_CURRENT));
                 break;
             case WSRequestCriteria::ZIPCODE:
                 $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_ZIPCODE, UFC_Address::TYPE_HOME, UFC_Address::FLAG_CURRENT));
                 break;
             case WSRequestCriteria::JOB_ANY_COUNTRY:
                 $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_COUNTRY, UFC_Address::TYPE_PRO, UFC_Address::FLAG_ANY));
                 break;
             case WSRequestCriteria::JOB_CURRENT_CITY:
                 $cond->addChild(new UFC_AddressField($value, UFC_AddressField::FIELD_LOCALITY, UFC_Address::TYPE_PRO, UFC_Address::FLAG_ANY));
                 break;
             case WSRequestCriteria::JOB_ANY_COMPANY:
             case WSRequestCriteria::JOB_CURRENT_COMPANY:
                 $cond->addChild(new UFC_Job_Company(UFC_Job_Company::JOBNAME, $value));
                 break;
             case WSRequestCriteria::JOB_ANY_SECTOR:
             case WSRequestCriteria::JOB_CURRENT_SECTOR:
             case WSRequestCriteria::JOB_CURRENT_TITLE:
                 $cond->addChild(new UFC_Job_Terms(DirEnum::getIds(DirEnum::JOBTERMS, $value)));
                 break;
                 // LIST fields
             // LIST fields
             case WSRequestCriteria::HOBBIES:
                 $subcond = new PFC_Or();
                 foreach ($value as $val) {
                     $subcond->addChild(new UFC_Comment($value));
                 }
                 $cond->addChild($subcond);
                 break;
             case WSRequestCriteria::JOB_COMPETENCIES:
             case WSRequestCriteria::JOB_RESUME:
             case WSRequestCriteria::PROFESSIONAL_PROJECT:
                 $subcond = new PFC_Or();
                 foreach ($value as $val) {
                     $subcond->addChild(new UFC_Job_Description($value, UserFilter::JOB_USERDEFINED));
                 }
                 $cond->addChild($subcond);
                 break;
             case WSRequestCriteria::NOT_UID:
                 $cond->addChild(new PFC_Not(new UFC_PartnerSharingID($this->partner->id, $value)));
                 break;
             default:
                 break;
         }
     }
     return $cond;
 }
Example #12
0
 public static function simpleUserProvider()
 {
     self::checkPlatal();
     $tests = array();
     $tests['id'] = array(array(self::buildAccountQuery('INNER JOIN  account_profiles AS ap2 ON (ap2.uid = a.uid)
                                             WHERE  FIND_IN_SET(\'owner\', ap2.perms)'), new UFC_HasProfile(), -1), array(self::buildAccountQuery('WHERE  a.hruid = {?}', 'florent.bruneau.2003'), new UFC_Hruid('florent.bruneau.2003'), 1), array(self::buildAccountQuery('WHERE  a.hruid = {?}', 'florent.bruneau.2004'), new UFC_Hruid('florent.bruneau.2004'), 0), array(self::buildAccountQuery('WHERE  a.hruid IN {?}', array('florent.bruneau.2003', 'stephane.jacob.2004')), new UFC_Hruid('florent.bruneau.2003', 'stephane.jacob.2004'), 2), array(self::buildAccountQuery('WHERE  a.hruid IN {?}', array('florent.bruneau.2004', 'stephane.jacob.2004')), new UFC_Hruid('florent.bruneau.2004', 'stephane.jacob.2004'), 1), array(self::buildProfileQuery('WHERE  p.hrpid = {?}', 'florent.bruneau.2003'), new UFC_Hrpid('florent.bruneau.2003'), 1), array(self::buildProfileQuery('WHERE  p.hrpid = {?}', 'florent.bruneau.2004'), new UFC_Hrpid('florent.bruneau.2004'), 0), array(self::buildProfileQuery('WHERE  p.hrpid IN {?}', array('florent.bruneau.2003', 'stephane.jacob.2004')), new UFC_Hrpid('florent.bruneau.2003', 'stephane.jacob.2004'), 2), array(self::buildProfileQuery('WHERE  p.hrpid IN {?}', array('florent.bruneau.2004', 'stephane.jacob.2004')), new UFC_Hrpid('florent.bruneau.2004', 'stephane.jacob.2004'), 1), array(self::buildAccountQuery('INNER JOIN  log_sessions AS s ON (s.uid = a.uid)
                                             WHERE  s.ip = {?} OR s.forward_ip = {?}', ip_to_uint('129.104.247.2'), ip_to_uint('129.104.247.2')), new UFC_Ip('129.104.247.2'), -1));
     /* TODO: UFC_Comment
      */
     /* UFC_Promo
      */
     $tests['promo'] = array(array(self::buildProfileQuery('INNER JOIN  profile_display AS pd ON (pd.pid = p.pid)
                                             WHERE  pd.promo = {?}', 'X2004'), new UFC_Promo('=', UserFilter::DISPLAY, 'X2004'), -1), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_enum AS pee ON (pe.eduid = pee.id)
                                         LEFT JOIN  profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
                                             WHERE  pe.entry_year = {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2004', 'Ing.'), new UFC_Promo('=', UserFilter::GRADE_ING, 2004), -1), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_enum AS pee ON (pe.eduid = pee.id)
                                         LEFT JOIN  profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
                                             WHERE  pe.entry_year <= {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '1960', 'Ing.'), new UFC_Promo('<=', UserFilter::GRADE_ING, 1960), -1), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_enum AS pee ON (pe.eduid = pee.id)
                                         LEFT JOIN  profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
                                             WHERE  pe.entry_year > {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2004', 'Ing.'), new UFC_Promo('>', UserFilter::GRADE_ING, 2004), -1), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_enum AS pee ON (pe.eduid = pee.id)
                                         LEFT JOIN  profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
                                             WHERE  pe.entry_year < {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '1900', 'Ing.'), new UFC_Promo('<', UserFilter::GRADE_ING, 1900), 0));
     /* UFC_SchoolId
      */
     $tests['schoolid'] = array(array(self::buildProfileQuery('WHERE  p.xorg_id = {?}', 20060076), new UFC_SchoolId(UFC_SchoolId::Xorg, 20060076), 1), array(self::buildProfileQuery('WHERE  p.ax_id = {?}', 20060062), new UFC_SchoolId(UFC_SchoolId::AX, 20060062), 1), array(self::buildProfileQuery('WHERE  p.xorg_id = {?}', 07), new UFC_SchoolId(UFC_SchoolId::Xorg, 07), 0), array(self::buildProfileQuery('WHERE  p.ax_id = {?}', 07), new UFC_SchoolId(UFC_SchoolId::AX, 07), 0));
     /* UFC_EducationSchool
      */
     $id_X = XDB::fetchOneCell('SELECT  id
                                  FROM  profile_education_enum
                                 WHERE  abbreviation = {?}', 'X');
     $id_HEC = XDB::fetchOneCell('SELECT  id
                                    FROM  profile_education_enum
                                   WHERE  abbreviation = {?}', 'HEC');
     $tests['school'] = array(array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_enum AS pee ON (pe.eduid = pee.id)
                                             WHERE  pee.abbreviation = {?}', 'X'), new UFC_EducationSchool($id_X), -1), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_enum AS pee ON (pe.eduid = pee.id)
                                             WHERE  pee.abbreviation IN {?}', array('X', 'HEC')), new UFC_EducationSchool($id_X, $id_HEC), -1));
     /* UFC_EducationDegree
      */
     $id_DegreeIng = XDB::fetchOneCell('SELECT  id
                                          FROM  profile_education_degree_enum
                                         WHERE  abbreviation = {?}', 'Ing.');
     $id_DegreePhd = XDB::fetchOneCell('SELECT  id
                                          FROM  profile_education_degree_enum
                                         WHERE  abbreviation = {?}', 'PhD');
     $tests['degree'] = array(array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
                                             WHERE  pede.abbreviation = {?}', 'Ing.'), new UFC_EducationDegree($id_DegreeIng), -1), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
                                             WHERE  pede.abbreviation IN {?}', array('Ing.', 'PhD')), new UFC_EducationDegree($id_DegreeIng, $id_DegreePhd), -1));
     /* UFC_EducationField
      */
     $id_FieldInfo = XDB::fetchOneCell('SELECT  id
                                          FROM  profile_education_field_enum
                                         WHERE  field = {?}', 'Informatique');
     $id_FieldDroit = XDB::fetchOneCell('SELECT  id
                                           FROM  profile_education_field_enum
                                          WHERE  field = {?}', 'Droit');
     // FIXME: Replace 0 by -1 in following queries when profile_education will be filled with fieldids
     $tests['edufield'] = array(array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_field_enum AS pefe ON (pe.fieldid = pefe.id)
                                             WHERE  pefe.field = {?}', 'Informatique'), new UFC_EducationField($id_FieldInfo), 0), array(self::buildProfileQuery('INNER JOIN  profile_education AS pe ON (pe.pid = p.pid)
                                         LEFT JOIN  profile_education_field_enum AS pefe ON (pe.fieldid = pefe.id)
                                             WHERE  pefe.field IN {?}', array('Informatique', 'Droit')), new UFC_EducationField($id_FieldInfo, $id_FieldDroit), 0));
     /* UFC_Name
      */
     $id_Lastname = DirEnum::getID(DirEnum::NAMETYPES, Profile::LASTNAME);
     $id_Firstname = DirEnum::getID(DirEnum::NAMETYPES, Profile::FIRSTNAME);
     $id_Nickname = DirEnum::getID(DirEnum::NAMETYPES, Profile::NICKNAME);
     $id_Lastname_Marital = DirEnum::getID(DirEnum::NAMETYPES, Profile::LASTNAME . '_' . Profile::VN_MARITAL);
     $id_Lastname_Ordinary = DirEnum::getID(DirEnum::NAMETYPES, Profile::LASTNAME . '_' . Profile::VN_ORDINARY);
     $tests['name'] = array(array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (pn.pid = p.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid = {?}', 'BARROIS', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'BARROIS', UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (pn.pid = p.pid)
                                            WHERE  pn.name LIKE \'BARR%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'BARR', UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (pn.pid = p.pid)
                                            WHERE  pn.name LIKE \'%OIS\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'OIS', UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%ARRO%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'ARRO', UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%ZZZZZZ%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'ZZZZZZ', UFC_Name::CONTAINS), 0), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid = {?}', 'Raphaël', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'Raphaël', UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'Raph%\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'Raph', UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%aël\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'aël', UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%apha%\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'apha', UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%zzzzzz%\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'zzzzzz', UFC_Name::CONTAINS), 0), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid = {?}', 'Xelnor', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'Xelnor', UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'Xel%\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'Xel', UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%nor\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'nor', UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%lno%\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'lno', UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE \'%zzzzzz%\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'zzzzzz', UFC_Name::CONTAINS), 0), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  CONCAT(pn.particle, \' \', pn.name) LIKE {?} AND pn.typeid = {?}', 'DE SINGLY', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'DE SINGLY', UFC_Name::PARTICLE | UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  CONCAT(pn.particle, \' \', pn.name) LIKE \'DE SI%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'DE SI', UFC_Name::PARTICLE | UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  CONCAT(pn.particle, \' \', pn.name) LIKE \'%GLY\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'GLY', UFC_NAME::PARTICLE | UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  CONCAT(pn.particle, \' \', pn.name) LIKE \'%E SIN%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'E SIN', UFC_Name::PARTICLE | UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  CONCAT(pn.particle, \' \', pn.name) LIKE \'%ZZZZZZ%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'ZZZZZZ', UFC_Name::PARTICLE | UFC_Name::CONTAINS), 0), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid IN {?}', 'ALBIZZATI', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ALBIZZATI', UFC_Name::VARIANTS | UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid IN {?}', 'ALBIZ%', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ALBIZ', UFC_Name::VARIANTS | UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid IN {?}', '%ZATI', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ZATI', UFC_NAME::VARIANTS | UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid IN {?}', '%BIZZ%', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'BIZZ', UFC_Name::VARIANTS | UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN  profile_name AS pn ON (p.pid = pn.pid)
                                            WHERE  pn.name LIKE {?} AND pn.typeid IN {?}', '%ZZZZZZ%', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ZZZZZZ', UFC_Name::VARIANTS | UFC_Name::CONTAINS), 0));
     /* UFC_NameTokens
      */
     $tests['nametoken'] = array(array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token LIKE \'xelnor%\''), new UFC_NameTokens('xelnor'), 1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token LIKE \'xe%\''), new UFC_NameTokens('xe'), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token LIKE \'xe%\' OR sn.token LIKE \'barr%\''), new UFC_NameTokens(array('xe', 'barr')), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token LIKE \'zzzzzzzz%\''), new UFC_NameTokens('zzzzzzzz'), 0), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token LIKE \'barr%\' AND FIND_IN_SET(\'public\', sn.flags)'), new UFC_NameTokens('barr', UFC_NameTokens::FLAG_PUBLIC), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token = \'xelnor\''), new UFC_NameTokens('xelnor', array(), false, true), 1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token IN (\'xelnor\', \'barrois\')'), new UFC_NameTokens(array('xelnor', 'barrois'), array(), false, true), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token = \'zzzzzzzz\''), new UFC_NameTokens('zzzzzzzz', array(), false, true), 0), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token IN (\'zzzzzzzz\', \'yyyyyyyy\')'), new UFC_NameTokens(array('zzzzzzzz', 'yyyyyyyy'), array(), false, true), 0), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.token = \'barrois\' AND FIND_IN_SET(\'public\', sn.flags)'), new UFC_NameTokens('barrois', UFC_NameTokens::FLAG_PUBLIC, false, true), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.soundex = \'XLNO\''), new UFC_NameTokens('xelnor', array(), true), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.soundex IN (\'XLNO\', \'BROS\')'), new UFC_NameTokens(array('xelnor', 'barrois'), array(), true), -1), array(self::buildProfileQuery('LEFT JOIN  search_name AS sn ON (p.pid = sn.pid)
                                            WHERE  sn.soundex = \'BROS\' AND FIND_IN_SET(\'public\', sn.flags)'), new UFC_NameTokens('barrois', UFC_NameTokens::FLAG_PUBLIC, true), -1));
     /* UFC_Nationality
      */
     $tests['nationality'] = array(array(self::buildProfileQuery('WHERE p.nationality1 IN {?} OR p.nationality2 IN {?} OR p.nationality3 IN {?}', array('BR'), array('BR'), array('BR')), new UFC_Nationality('BR'), -1), array(self::buildProfileQuery('WHERE p.nationality1 IN {?} OR p.nationality2 IN {?} OR p.nationality3 IN {?}', array('BR', 'US'), array('BR', 'US'), array('BR', 'US')), new UFC_Nationality('BR', 'US'), -1), array(self::buildProfileQuery('WHERE p.nationality1 IN {?} OR p.nationality2 IN {?} OR p.nationality3 IN {?}', array('__'), array('__'), array('__')), new UFC_Nationality('__'), 0));
     /* UFC_Dead
      */
     $tests['dead'] = array(array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL'), new UFC_Dead(), -1), array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL AND p.deathdate > {?}', '2008-01-01'), new UFC_Dead('>', '2008-01-01'), -1), array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL AND p.deathdate < {?}', '1600-01-01'), new UFC_Dead('<', '1600-01-01'), 0), array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL AND p.deathdate > {?}', date('Y-m-d')), new UFC_Dead('>', 'now'), 0));
     /* UFC_Registered
      */
     $tests['register'] = array(array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state = \'active\''), new UFC_Registered(true), -1), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state != \'pending\''), new UFC_Registered(), -1), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state = \'active\' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date > {?}', '2008-01-01'), new UFC_Registered(true, '>', '2008-01-01'), -1), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state != \'pending\' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date > {?}', '2008-01-01'), new UFC_Registered(false, '>', '2008-01-01'), -1), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state = \'active\' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date < {?}', '1700-01-01'), new UFC_Registered(true, '<', '1700-01-01'), 0), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state != \'pending\' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date < {?}', '1700-01-01'), new UFC_Registered(false, '<', '1700-01-01'), 0), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state = \'active\' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date > {?}', date('Y-m-d')), new UFC_Registered(true, '>', 'now'), 0), array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state != \'pending\' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date > {?}', date('Y-m-d')), new UFC_Registered(false, '>', 'now'), 0));
     $testcases = array();
     foreach ($tests as $name => $t) {
         foreach ($t as $id => $case) {
             $testcases[$name . '-' . $id] = $case;
         }
     }
     return $testcases;
 }
Example #13
0
 protected function check(UserFilterBuilder $ufb)
 {
     if ($ufb->blank($this->envfieldindex) && !$ufb->hasAlnum($this->envfield)) {
         $this->empty = true;
         return true;
     }
     if (!$ufb->blank($this->envfieldindex)) {
         $index = $ufb->v($this->envfieldindex);
         if (is_int($index)) {
             $index = intval($index);
         } else {
             $index = strtoupper($index);
         }
         $this->val = array($index);
     } else {
         $indexes = DirEnum::getIDs($this->direnum, $ufb->t($this->envfield), $ufb->b('exact') ? XDB::WILDCARD_EXACT : XDB::WILDCARD_CONTAINS);
         if (count($indexes) == 0) {
             return false;
         }
         $this->val = $indexes;
     }
     return true;
 }
Example #14
0
 private static function profile_to_contact($p)
 {
     $contact = array('Prénom' => $p->firstName(), 'Nom' => $p->lastName(), 'Notes' => '(' . $p->promo . ')', 'Tél. mobile' => $p->mobile, 'Anniversaire' => $p->birthdate, 'Surnom' => $p->nickname);
     // Homes
     $adrs = $p->iterAddresses(Profile::ADDRESS_PERSO);
     if ($adr = $adrs->next()) {
         Outlook::add_address($adr, $contact, 'domicile');
     }
     if ($adr = $adrs->next()) {
         Outlook::add_address($adr, $contact, 'autre');
     }
     // Pro
     $adrs = $p->iterAddresses(Profile::ADDRESS_PRO);
     if ($adr = $adrs->next()) {
         Outlook::add_address($adr, $contact, 'bureau');
     }
     $mainjob = $p->getMainJob();
     if ($mainjob && $mainjob->company) {
         $contact['Société '] = $mainjob->company->name;
     }
     if (!empty($p->section)) {
         $contact['Utilisateur 2'] = 'Section : ' . $p->section;
     }
     if ($p->isFemale()) {
         $contact['Sexe'] = 'Féminin';
     } else {
         $contact['Sexe'] = 'Masculin';
     }
     $binets = $p->getBinets();
     if (count($binets)) {
         $bn = DirEnum::getOptions(DirEnum::BINETS);
         $bns = array();
         foreach (array_keys($binets) as $bid) {
             if (!empty($bn[$bid])) {
                 $bns[$bid] = $bn[$bid];
             }
         }
         if (count($bns) > 0) {
             $contact['Utilisateur 3'] = 'Binets : ' . join(', ', $bns);
         }
     }
     $user = $p->owner();
     if ($user) {
         $contact['Adresse de messagerie'] = $user->bestalias;
         $contact['Nom complet de l\'adresse de messagerie'] = $p->fullName() . ' <' . $user->bestalias . '>';
         if ($user->bestalias != $user->forlife) {
             $contact['Adresse de messagerie 3'] = $user->forlife;
             $contact['Nom complet de l\'adresse de messagerie 3'] = $p->fullName() . ' <' . $user->forlife . '>';
         }
         $groups = $user->groups();
         if (count($groups)) {
             $gn = DirEnum::getOptions(DirEnum::GROUPESX);
             $gns = array();
             foreach (array_keys($groups) as $gid) {
                 if (!empty($gn[$gid])) {
                     $gns[$gid] = $gn[$gid];
                 }
             }
             if (count($gns) > 0) {
                 $contact['Utilisateur 1'] = 'Groupes X : ' . join(', ', $gns);
             }
         }
     }
     return $contact;
 }
Example #15
0
 function handler_list($page, $type = null, $idVal = null)
 {
     $page->assign('name', $type);
     $page->assign('with_text_value', true);
     $page->assign('onchange', "document.forms.recherche.{$type}Txt.value = this.options[this.selectedIndex].text");
     // Give the list of all values possible of type and builds a select input for it
     $ids = null;
     switch ($type) {
         case 'binet':
             $ids = DirEnum::getOptionsIter(DirEnum::BINETS);
             break;
         case 'networking_type':
             $ids = DirEnum::getOptionsIter(DirEnum::NETWORKS);
             break;
         case 'country':
             $ids = DirEnum::getOptionsIter(DirEnum::COUNTRIES);
             $page->assign('onchange', 'changeAddressComponents(\'' . $type . '\', this.value)');
             break;
         case 'administrative_area_level_1':
         case 'administrative_area_level_2':
         case 'locality':
             $page->assign('onchange', 'changeAddressComponents(\'' . $type . '\', this.value)');
         case 'postal_code':
             $ids = XDB::iterator("SELECT  pace1.id, pace1.long_name AS field\n                                    FROM  profile_addresses_components_enum AS pace1\n                              INNER JOIN  profile_addresses_components      AS pac1  ON (pac1.component_id = pace1.id)\n                              INNER JOIN  profile_addresses_components      AS pac2  ON (pac1.pid = pac2.pid AND pac1.jobid = pac2.jobid AND pac1.id = pac2.id\n                                                                                         AND pac1.groupid = pac2.groupid AND pac1.type = pac2.type)\n                              INNER JOIN  profile_addresses_components_enum AS pace2 ON (pac2.component_id = pace2.id AND FIND_IN_SET({?}, pace2.types))\n                                   WHERE  pace2.id = {?} AND FIND_IN_SET({?}, pace1.types) AND pac1.type = 'home'\n                                GROUP BY  pace1.long_name", Env::v('previous'), Env::v('value'), $type);
             break;
         case 'diploma':
             if (Env::has('school') && Env::i('school') != 0) {
                 $ids = DirEnum::getOptionsIter(DirEnum::EDUDEGREES, Env::i('school'));
             } else {
                 $ids = DirEnum::getOptionsIter(DirEnum::EDUDEGREES);
             }
             break;
         case 'groupex':
             $ids = DirEnum::getOptionsIter(DirEnum::GROUPESX);
             break;
         case 'nationalite':
             $ids = DirEnum::getOptionsIter(DirEnum::NATIONALITIES);
             break;
         case 'school':
             $ids = DirEnum::getOptionsIter(DirEnum::EDUSCHOOLS);
             $page->assign('onchange', 'changeSchool(this.value)');
             break;
         case 'section':
             $ids = DirEnum::getOptionsIter(DirEnum::SECTIONS);
             break;
         case 'jobterm':
             if (Env::has('jtid')) {
                 JobTerms::ajaxGetBranch($page, JobTerms::ONLY_JOBS);
                 return;
             } else {
                 pl_content_headers('text/xml');
                 echo '<div>';
                 // global container so that response is valid xml
                 echo '<input name="jobtermTxt" type="text" style="display:none" size="32" />';
                 echo '<input name="jobterm" type="hidden"/>';
                 echo '<div class="term_tree"></div>';
                 // container where to create the tree
                 echo '<script type="text/javascript" src="javascript/jquery.jstree.js"></script>';
                 echo '<script type="text/javascript" src="javascript/jobtermstree.js"></script>';
                 echo '<script type="text/javascript">createJobTermsTree(".term_tree", "search/list/jobterm", "search", "searchForJobTerm");</script>';
                 echo '</div>';
                 exit;
             }
         default:
             exit;
     }
     if (isset($idVal)) {
         pl_content_headers("text/plain");
         echo $ids[$idVal];
         exit;
     }
     pl_content_headers("text/xml");
     $page->changeTpl('include/field.select.tpl', NO_SKIN);
     $page->assign('list', $ids);
 }