예제 #1
0
 public function __construct(User $_user, Profile $_profile, $_id, $_name, $_acronym, $_url, $_email, $_tel, $_fax, $_address, $_stamp = 0)
 {
     parent::__construct($_user, $_profile, false, 'entreprise', $_stamp);
     $this->id = $_id;
     $this->name = $_name;
     $this->acronym = $_acronym;
     $this->url = $_url;
     $this->email = $_email;
     $this->tel = $_tel;
     $this->fax = $_fax;
     $this->address = $_address;
     $_name = preg_replace('/[^0-9a-z]/i', ' ', strtolower(replace_accent($_name)));
     $name = explode(" ", $_name);
     $name_array = array_map("trim", $name);
     $length = count($name_array);
     $where = "";
     for ($i = 0; $i < $length; $i++) {
         if (strlen($name_array[$i]) > 2) {
             if ($where !== "") {
                 $where .= " OR ";
             }
             $where .= "name LIKE '%" . $name_array[$i] . "%'";
         }
     }
     if ($where != '') {
         $res = XDB::iterator('SELECT  name
                                 FROM  profile_job_enum
                                WHERE  ' . $where);
         $this->suggestions = "| ";
         while ($sug = $res->next()) {
             $this->suggestions .= $sug['name'] . " | ";
         }
     }
 }
예제 #2
0
파일: survey.php 프로젝트: netixx/frankiz
 public static function batchSelect(array $questions, $options = null)
 {
     if (empty($questions)) {
         return;
     }
     if (empty($options)) {
         $options = self::SELECT_BASE;
     }
     $bits = self::optionsToBits($options);
     $questions = array_combine(self::toIds($questions), $questions);
     if ($bits & self::SELECT_BASE) {
         $iter = XDB::iterator('SELECT  qid AS id, rank, label, description,
                                        mandatory, type, datas
                                  FROM  surveys_questions
                                 WHERE  qid IN {?}
                              GROUP BY  qid', self::toIds($questions));
         while ($datas = $iter->next()) {
             $questions[$datas['id']]->decodeDatas(json_decode($datas['datas']));
             unset($datas['datas']);
             $questions[$datas['id']]->fillFromArray($datas);
         }
     }
     if ($bits & self::SELECT_ANSWERS) {
         $iter = XDB::iterRow('SELECT  ssid, qid, datas
                                 FROM  surveys_answers
                                WHERE  qid IN {?}
                             GROUP BY  qid', self::toIds($questions));
         while (list($ssid, $qid, $datas) = $iter->next()) {
             $questions[$qid]->decodeAnswer($ssid, json_decode($datas));
         }
     }
 }
예제 #3
0
파일: feed.inc.php 프로젝트: Ekleog/platal
 protected function fetch(PlUser $user)
 {
     global $globals;
     if (!is_null($user)) {
         return new UserFilterIterator(XDB::iterator("SELECT  id, titre AS title, texte, contacts,\n                                          create_date AS publication,\n                                          FIND_IN_SET('photo', flags) AS photo,\n                                          CONCAT({?}, '/#art', id) AS link\n                                    FROM  group_announces\n                                   WHERE  expiration >= NOW() AND asso_id = {?}", $this->link, $globals->asso('id'), $user));
     } else {
         return XDB::iterator("SELECT  id, titre AS title, texte, create_date AS publication,\n                                           CONCAT({?}, '/#art', id) AS link,\n                                           NULL AS photo, NULL AS contacts\n                                     FROM  group_announces\n                                    WHERE  FIND_IN_SET('public', flags) AND expiration >= NOW() AND asso_id = {?}", $this->link, $globals->asso('id'));
     }
 }
예제 #4
0
 protected function handler_participants(Collection $activities, $fields)
 {
     $res = XDB::iterator('SELECT  id, participant
                             FROM  activities_participants
                            WHERE  id IN {?}', $activities->ids());
     $users = new Collection('User');
     $part = array();
     while ($datas = $res->next()) {
         $part[$datas['id']][] = $users->addget($datas['participant']);
     }
     foreach ($part as $key => $obj) {
         $activities->get($key)->participants($obj);
     }
     $users->select($this->subs['participants']);
 }
예제 #5
0
파일: gadgets.php 프로젝트: Ekleog/platal
 function handler_ig_events($page)
 {
     require_once 'gadgets/gadgets.inc.php';
     init_igoogle_html('gadgets/ig-events.tpl', AUTH_COOKIE);
     $events = XDB::iterator("SELECT  SQL_CALC_FOUND_ROWS\n                                         e.id, e.titre, UNIX_TIMESTAMP(e.creation_date) AS creation_date,\n                                         ev.uid IS NULL AS nonlu, e.uid\n                                   FROM  announces     AS e\n                              LEFT JOIN  announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?})\n                                  WHERE  FIND_IN_SET('valide', e.flags) AND expiration >= NOW()\n                               ORDER BY  e.creation_date DESC", S::i('uid'));
     $page->assign('event_count', XDB::query("SELECT FOUND_ROWS()")->fetchOneCell());
     Platal::load('events', 'feed.inc.php');
     $user = S::user();
     $data = array();
     while ($e = PlFeed::nextEvent($events, $user)) {
         $data[] = $e;
         if (count($data) == 5) {
             break;
         }
     }
     $page->assign('events', $data);
 }
예제 #6
0
파일: jobterms.php 프로젝트: Ekleog/platal
 /** Retreives subterms of a term to display in a tree
  * @param $parent_jtid the id of the parent jobterm
  * @param $filter enable filtering on jobterms that have been used in jobs or in mentors, in
  *  that case, each row as an 'nb' field that counts all profiles that match
  * @param $token_filter a text (usually ending by %) the retreived subterms to jobterms that
  *  contains this tokens or that one of their children contains it.
  * @return an iterator over jobterms with jtid, name, full_name and nb
  */
 public static function getSubTerms($parent_jtid, $filter = self::ALL, $token_filter = null)
 {
     switch ($filter) {
         case self::ALL:
         default:
             $table = '';
             break;
         case self::ONLY_JOBS:
             $table = 'profile_job_term';
             break;
         case self::ONLY_MENTORS:
             $table = 'profile_mentor_term';
             break;
     }
     // we are in a tree looking for certain job terms:
     $countingterms = false;
     if ($table) {
         $count = ', COUNT(DISTINCT j.pid) AS nb';
         $join = ' INNER JOIN  profile_job_term_relation AS r2 ON (r2.jtid_1 = e.jtid)
                   INNER JOIN  ' . $table . ' AS j ON (j.jtid = r2.jtid_2)';
         $countingterms = 'j.jtid';
     } else {
         $count = $join = '';
     }
     if (!empty($token_filter)) {
         $join .= ' INNER JOIN  profile_job_term_relation AS rtf ON (rtf.jtid_1 = e.jtid) ' . self::token_join_query(self::tokenize($token_filter), 'rtf', 'jtid_2');
         if (!$countingterms) {
             $countingterms = 'rtf.jtid_2';
         }
     }
     if (!$countingterms) {
         $select_leaf = 'IF(r_subbranch.jtid_1 IS NULL,1,0)';
         $join .= ' LEFT JOIN  profile_job_term_relation AS r_subbranch ON (r_subbranch.jtid_1 = e.jtid AND r_subbranch.computed = "original") ';
     } else {
         // branches that have counting terms different that
         // main branch will have subbranches
         $select_leaf = 'MIN(' . $countingterms . ' = e.jtid)';
     }
     return XDB::iterator('SELECT  e.jtid, e.name, e.full_name' . $count . ', ' . $select_leaf . ' AS leaf
                             FROM  profile_job_term_enum AS e
                       INNER JOIN  profile_job_term_relation AS r ON (r.jtid_2 = e.jtid)' . $join . '
                            WHERE  r.jtid_1 = {?} AND r.computed = "original"
                         GROUP BY  e.jtid
                         ORDER BY  e.name', $parent_jtid);
 }
예제 #7
0
파일: admin.php 프로젝트: netixx/frankiz
 function handler_logs_sessions($page)
 {
     $iter = XDB::iterator('SELECT  id, uid, host, ip, forward_ip, forward_host,
                                    browser, suid, flags, start
                              FROM  log_sessions
                          ORDER BY  start DESC
                             LIMIT  50');
     $sessions = array();
     $users = new Collection('User');
     while ($session = $iter->next()) {
         $user = $users->addget($session['uid']);
         $sessions[$session['id']] = array('user' => $user, 'host' => $session['host'], 'ip' => uint_to_ip($session['ip']), 'forward_host' => $session['forward_host'], 'forward_ip' => uint_to_ip($session['forward_ip']), 'browser' => $session['browser'], 'suid' => $session['suid'], 'flags' => $session['flags'], 'start' => new FrankizDateTime($session['start']));
     }
     $users->select(UserSelect::base());
     $page->assign('title', "Logs des sessions");
     $page->assign('sessions', $sessions);
     $page->changeTpl('admin/logs_sessions.tpl');
 }
예제 #8
0
파일: feed.inc.php 프로젝트: Ekleog/platal
 protected function fetch(PlUser $user)
 {
     global $globals;
     $events = XDB::iterator('SELECT  e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id,
                                      p.attachmime IS NOT NULL AS photo, FIND_IN_SET(\'wiki\', e.flags) AS wiki,
                                      e.uid, e.promo_min, e.promo_max
                                FROM  announces       AS e
                           LEFT JOIN  announce_photos AS p ON (p.eid = e.id)
                               WHERE  FIND_IN_SET("valide", e.flags) AND expiration >= NOW()');
     $data = array();
     while ($e = self::nextEvent($events, $user)) {
         $author = User::getWithUID($e['uid']);
         $promo = $author->promo();
         $e['author'] = $author->fullName() . ($promo ? ' (' . $promo . ')' : '');
         $e['link'] = $globals->baseurl . '/events#newsid' . $e['id'];
         $data[] = $e;
     }
     return PlIteratorUtils::fromArray($data, 1, true);
 }
예제 #9
0
function education_options($current = 0)
{
    $html = '<option value="-1">&nbsp;</option>';
    $res = XDB::iterator("SELECT  e.id AS id, gc.country,\n                                   IF(CHAR_LENGTH(e.name) > 76, e.abbreviation, e.name) AS name\n                             FROM  profile_education_enum AS e\n                        LEFT JOIN  geoloc_countries       AS gc ON (e.country = gc.iso_3166_1_a2)\n                     WHERE EXISTS  (SELECT  *\n                                      FROM  profile_education_degree AS d\n                                     WHERE  e.id = d.eduid) AND e.name != {?}\n                         ORDER BY  gc.country, e.name", Profile::EDU_X);
    $country = "";
    while ($arr_edu = $res->next()) {
        if ($arr_edu["country"] != $country) {
            if ($country) {
                $html .= '</optgroup>';
            }
            $country = $arr_edu["country"];
            $html .= '<optgroup label="' . $country . '">';
        }
        $html .= '<option value="' . $arr_edu["id"] . '"';
        if ($arr_edu["id"] == $current) {
            $html .= " selected='selected'";
        }
        $html .= '>' . htmlspecialchars($arr_edu["name"]) . "</option>\n";
    }
    if ($country) {
        $html .= '</optgroup>';
    }
    return $html;
}
예제 #10
0
파일: platal.php 프로젝트: Ekleog/platal
 function handler_skin($page)
 {
     global $globals;
     $page->changeTpl('platal/skins.tpl');
     $page->setTitle('Skins');
     if (Env::has('newskin')) {
         // formulaire soumis, traitons les données envoyées
         XDB::execute('UPDATE  accounts
                          SET  skin = {?}
                        WHERE  uid = {?}', Env::i('newskin'), S::i('uid'));
         S::kill('skin');
         Platal::session()->setSkin();
     }
     $res = XDB::query('SELECT  id
                          FROM  skins
                         WHERE  skin_tpl = {?}', S::v('skin'));
     $page->assign('skin_id', $res->fetchOneCell());
     $sql = 'SELECT  s.*, auteur, COUNT(*) AS nb
               FROM  skins AS s
          LEFT JOIN  accounts AS a ON (a.skin = s.id)
              WHERE  skin_tpl != \'\' AND ext != \'\'
           GROUP BY  id ORDER BY s.date DESC';
     $page->assign('skins', XDB::iterator($sql));
 }
예제 #11
0
파일: marketing.php 프로젝트: Ekleog/platal
 function handler_relance($page)
 {
     $page->changeTpl('marketing/relance.tpl');
     if (Post::has('relancer')) {
         global $globals;
         $nbdix = $globals->core->NbIns;
         $sent = array();
         $users = User::getBulkUsersWithUIDs($_POST['relance']);
         foreach ($users as $user) {
             if ($tmp = Marketing::relance($user, $nbdix)) {
                 $sent[] = $tmp . ' a été relancé.';
             }
         }
         $page->assign('sent', $sent);
     }
     $page->assign('relance', XDB::iterator('SELECT  r.date, r.relance, r.uid
                                               FROM  register_pending AS r
                                              WHERE  hash != \'INSCRIT\'
                                           ORDER BY  date DESC'));
 }
예제 #12
0
    // to add a forlife-looking nickname at some point, we'll do it manually.
    if (!preg_match('/^[-a-z]+\\.[-a-z]+\\.\\d{4}$/', $nickname['nickname'])) {
        $pending_tasks = XDB::fetchOneCell("SELECT  COUNT(*)\n               FROM  gapps_queue\n              WHERE  q_recipient_id = {?} AND p_status = 'idle' AND j_type = 'n_create' AND j_parameters = {?}", $nickname['id'], json_encode($nickname));
        if ($pending_tasks == 0) {
            XDB::execute("INSERT  INTO gapps_queue\n                    SET  q_recipient_id = {?}, p_entry_date = NOW(), p_notbefore_date = NOW(),\n                         p_priority = 'offline', j_type = 'n_create', j_parameters = {?}", $nickname['id'], json_encode($nickname));
        }
    }
}
/* Checks that all nicknames in GoogleApps are also aliases on plat/al side.
   Deletes the invalid ones. */
$res = XDB::iterator("SELECT  g.l_userid AS id, g.g_nickname AS nickname\n       FROM  gapps_nicknames AS g\n  LEFT JOIN  email_source_account AS s ON (s.uid = g.l_userid AND s.type = 'alias' AND s.email = g.g_nickname)\n      WHERE  g.l_userid IS NOT NULL AND s.email IS NULL");
while ($nickname = $res->next()) {
    $pending_tasks = XDB::fetchOneCell("SELECT  COUNT(*)\n           FROM  gapps_queue\n          WHERE  q_recipient_id = {?} AND p_status = 'idle' AND j_type = 'n_delete' AND j_parameters = {?}", $nickname['id'], json_encode($nickname));
    if ($pending_tasks == 0) {
        XDB::execute("INSERT  INTO gapps_queue\n                SET  q_recipient_id = {?}, p_entry_date = NOW(), p_notbefore_date = NOW(),\n                     p_priority = 'offline', j_type = 'n_delete', j_parameters = {?}", $nickname['id'], json_encode($nickname));
    }
}
/* Retrieves successful job queues for post-queue processing. */
$res = XDB::iterator("SELECT  q_id, q_recipient_id, j_type, j_parameters\n       FROM  gapps_queue\n      WHERE  p_status = 'success' AND q_recipient_id IS NOT NULL");
while ($job = $res->next()) {
    if ($job['j_type'] == 'u_create') {
        post_queue_u_create($job);
    } else {
        if ($job['j_type'] == 'u_update') {
            post_queue_u_update($job);
        }
    }
}
/* Removes successful jobs, and old failed jobs. */
XDB::execute("DELETE  FROM gapps_queue\n      WHERE  p_status = 'success' OR\n             (p_status = 'hardfail' AND p_end_date < DATE_SUB(NOW(), INTERVAL 15 DAY))");
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
예제 #13
0
파일: jobs.inc.php 프로젝트: Ekleog/platal
 public function _prepare(PlPage $page, $id)
 {
     require_once 'emails.combobox.inc.php';
     fill_email_combobox($page, array('redirect', 'job', 'stripped_directory'), $this->owner);
     if (!S::user()->isMe($this->owner)) {
         $res = XDB::iterator('SELECT  id, name
                                 FROM  profile_corps_enum
                             ORDER BY  id = 1 DESC, name');
         $page->assign('original_corps', $res->fetchAllAssoc());
     }
     $res = XDB::iterator("SELECT  id, name\n                                FROM  profile_corps_enum\n                               WHERE  still_exists = 1\n                            ORDER BY  id = 1 DESC, name");
     $page->assign('current_corps', $res->fetchAllAssoc());
     $res = XDB::iterator("SELECT  id, name\n                                FROM  profile_corps_rank_enum\n                            ORDER BY  id = 1 DESC, name");
     $page->assign('corps_rank', $res->fetchAllAssoc());
 }
예제 #14
0
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
$globals->debug = 0;
//do not store backtraces
$terms = XDB::iterator('SELECT `jtid`, `name` FROM `profile_job_term_enum`');
while ($term = $terms->next()) {
    $tokens = array_unique(JobTerms::tokenize($term['name']));
    if (!count($tokens)) {
        continue;
    }
    $values = array();
    foreach ($tokens as $t) {
        $values[] = '(' . XDB::escape($t) . ',' . XDB::escape($term['jtid']) . ')';
    }
    XDB::execute('INSERT IGNORE INTO `profile_job_term_search` (`search`,`jtid`) VALUES ' . implode(',', $values));
}
/* vim:set et sw=4 sts=4 ts=4: */
예제 #15
0
파일: user.php 프로젝트: pombredanne/platal
 public static function getPendingAccounts($login, $iterator = false)
 {
     if (strpos($login, '@') === false) {
         return null;
     }
     list($login, $domain) = explode('@', $login);
     if ($domain && !self::isMainMailDomain($domain)) {
         return null;
     }
     $sql = "SELECT  uid, full_name\n                  FROM  accounts\n                 WHERE  state = 'pending' AND REPLACE(hruid, '-', '') LIKE\n                        CONCAT('%', REPLACE(REPLACE(REPLACE({?}, ' ', ''), '-', ''), '\\'', ''), '%')\n              ORDER BY  full_name";
     if ($iterator) {
         return XDB::iterator($sql, $login);
     } else {
         $res = XDB::query($sql, $login);
         return $res->fetchAllAssoc();
     }
 }
예제 #16
0
파일: select.php 프로젝트: netixx/frankiz
 protected function helper_main(Collection $metas, array $cols, array $joins)
 {
     $table = $this->schema->table();
     $as = $this->schema->tableAs();
     $id = $this->schema->id();
     $sql_fields = self::arrayToSqlCols($cols);
     $sql_joins = PlSqlJoin::formatJoins($joins, array());
     $collections = array();
     foreach ($cols as $fields) {
         foreach ($fields as $field) {
             if ($this->schema->isCollection($field)) {
                 // TODO: is this code used ?
                 //$collections[$field] = new Collection($this->schema->collectionType($field));
                 throw new Exception("Oops, there is a main handler for collections now ?");
             } elseif (!empty($this->subs) && array_key_exists($field, $this->subs)) {
                 $collections[$field] = new Collection($this->schema->objectType($field));
             }
         }
     }
     $iter = XDB::iterator("SELECT  {$as}.{$id} AS id, {$sql_fields}\n                                 FROM  {$table} AS {$as}\n                                       {$sql_joins}\n                                WHERE  {$as}.{$id} IN {?}", $metas->ids());
     while ($datas = $iter->next()) {
         foreach ($datas as $key => $value) {
             if ($this->schema->isObject($key)) {
                 $class = $this->schema->objectType($key);
                 $datas[$key] = new $class($value);
             }
             if (array_key_exists($key, $collections) && $value !== null) {
                 $datas[$key] = $collections[$key]->addget($value);
             }
             if ($value === null) {
                 /*
                  * /!\ Null in the DB means false in here.
                  * Therefore Boolean fields must *not* be nullable !
                  */
                 $datas[$key] = false;
             }
         }
         $metas->get($datas['id'])->fillFromArray($datas);
     }
     foreach ($collections as $field => $collection) {
         $collection->select($this->subs[$field]);
     }
 }
예제 #17
0
 private function load_pending_updates()
 {
     $res = XDB::iterator("SELECT  j_parameters\n               FROM  gapps_queue\n              WHERE  q_recipient_id = {?} AND\n                     p_status IN ('idle', 'active', 'softfail') AND\n                     j_type = 'u_update'", $this->user->id());
     while ($update = $res->next()) {
         $update_data = json_decode($update["j_parameters"], true);
         if (isset($update_data["suspended"])) {
             $this->pending_update_suspension = true;
         } elseif (isset($update_data["password"])) {
             $this->pending_update_password = true;
         } elseif (isset($update_data["admin"])) {
             $this->pending_update_admin = true;
         } else {
             $this->pending_update_other = true;
         }
     }
 }
예제 #18
0
 // adds sector as term
 XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ( {?}, {?} )', $oldsector['name'], $oldsector['name'] . ' (secteur)');
 $sector_id = XDB::insertId();
 // links to root for sectors
 XDB::execute('INSERT INTO `profile_job_term_relation` VALUES ({?}, {?}, "narrower", "original"), ({?}, {?}, "narrower", "computed")', $root_sector_id, $sector_id, $sector_id, $sector_id);
 // adds sector term to linked jobs and linked mentorships
 XDB::execute('INSERT INTO `profile_job_term`
               SELECT  `pid`, `id`, {?}, "original"
                 FROM  `profile_job`
                WHERE  `sectorid` = {?} AND `subsectorid` = 0', $sector_id, $oldsector['id']);
 XDB::execute('INSERT INTO `profile_mentor_term`
               SELECT  `pid`, {?}
                 FROM  `profile_mentor_sector`
                WHERE  `sectorid` = {?} AND `subsectorid` = 0', $sector_id, $oldsector['id']);
 // loops through subsectors
 $subsectors = XDB::iterator('SELECT `id`, `name` FROM `profile_job_subsector_enum` WHERE sectorid = {?}', $oldsector['id']);
 while ($oldsubsector = $subsectors->next()) {
     if ($oldsubsector['name'] == $oldsector['name']) {
         // adds sector term to jobs and mentorships linked to subsector with same name as sector
         XDB::execute('INSERT INTO `profile_job_term`
                       SELECT  `pid`, `id`, {?}, "original"
                         FROM  `profile_job`
                        WHERE  `sectorid` = {?} AND `subsectorid` = {?}', $sector_id, $oldsector['id'], $oldsubsector['id']);
         XDB::execute('INSERT INTO `profile_mentor_term`
                       SELECT  `pid`, {?}
                         FROM  `profile_mentor_sector`
                        WHERE  `sectorid` = {?} AND `subsectorid` = {?}', $sector_id, $oldsector['id'], $oldsubsector['id']);
         continue;
     }
     // adds subsector as term
     XDB::execute('INSERT INTO `profile_job_term_enum` (`name`, `full_name`) VALUES ( {?}, {?} )', $oldsubsector['name'], $oldsubsector['name'] . ' (secteur)');
예제 #19
0
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program; if not, write to the Free Software            *
 *  Foundation, Inc.,                                                      *
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 ***************************************************************************/
require_once 'connect.db.inc.php';
require_once 'plmailer.php';
global $globals;
$res = XDB::iterator('SELECT  p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, ap.uid
                        FROM  profile_modifications AS pm
                  INNER JOIN  accounts              AS a  ON (pm.uid = a.uid)
                  INNER JOIN  profiles              AS p  ON (pm.pid = p.pid)
                  INNER JOIN  profile_display       AS pd ON (pm.pid = pd.pid)
                  INNER JOIN  account_profiles      AS ap ON (pm.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms))
                       WHERE  pm.type = \'third_party\' AND pm.field != \'deathdate\'
                    ORDER BY  pm.pid, pm.field, pm.timestamp');
if ($res->total() > 0) {
    $date = time();
    $values = $res->next();
    $pid = $values['pid'];
    $sex = $values['sex'] == 'female' ? 1 : 0;
    $yourself = $values['yourself'];
    $user = User::getSilentWithUID($values['uid']);
    $hrpid = $values['hrpid'];
    $modifications = array();
    $modifications[] = array('full_name' => $values['full_name'], 'field' => $values['field'], 'oldText' => $values['oldText'], 'newText' => $values['newText']);
    while ($values = $res->next()) {
        if ($values['pid'] != $pid) {
예제 #20
0
 function handler_admin_user($page, $user = null)
 {
     require_once 'emails.inc.php';
     require_once 'googleapps.inc.php';
     $page->changeTpl('googleapps/admin.user.tpl');
     $page->setTitle('Administration Google Apps');
     $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
     if (!$user && Post::has('login')) {
         $user = Post::v('login');
     }
     $user = User::get($user);
     if ($user) {
         $account = new GoogleAppsAccount($user);
         // Apply requested actions.
         if (Post::has('suspend') && $account->active() && !$account->pending_update_suspension) {
             S::assert_xsrf_token();
             $account->suspend();
             $page->trigSuccess('Le compte est en cours de suspension.');
         } else {
             if (Post::has('unsuspend') && $account->suspended() && !$account->pending_update_suspension) {
                 S::assert_xsrf_token();
                 $account->do_unsuspend();
                 $page->trigSuccess('Le compte est en cours de réactivation.');
             } else {
                 if (Post::has('forcesync') && $account->active() && $account->sync_password) {
                     $account->set_password($user->password());
                     $page->trigSuccess('Le mot de passe est en cours de synchronisation.');
                 } else {
                     if (Post::has('sync') && $account->active()) {
                         $account->set_password($user->password());
                         $account->set_password_sync(true);
                     } else {
                         if (Post::has('nosync') && $account->active()) {
                             $account->set_password_sync(false);
                         }
                     }
                 }
             }
         }
         // Displays basic account information.
         $page->assign('account', $account);
         $page->assign('admin_account', GoogleAppsAccount::is_administrator($user->id()));
         $page->assign('googleapps_storage', Email::is_active_storage($user, 'googleapps'));
         $page->assign('user', $user->id());
         // Retrieves user's pending requests.
         $res = XDB::iterator("SELECT  q_id, q_recipient_id, p_status, j_type, UNIX_TIMESTAMP(p_entry_date) AS p_entry_date\n                   FROM  gapps_queue\n                  WHERE  q_recipient_id = {?}\n               ORDER BY  p_entry_date DESC", $user->id());
         $page->assign('requests', $res);
     }
 }
예제 #21
0
파일: admin.php 프로젝트: Ekleog/platal
 function handler_phd($page, $promo = null, $validate = false)
 {
     $page->changeTpl('admin/phd.tpl');
     $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES);
     $eduDegrees = array_flip($eduDegrees);
     // get the list of the years when phd students are supposed to finish but have not yet been flagged as completed
     $promo_list = XDB::fetchColumn('SELECT  DISTINCT(grad_year)
                                       FROM  profile_education
                                      WHERE  FIND_IN_SET(\'primary\', flags) AND NOT FIND_IN_SET(\'completed\', flags) AND degreeid = {?}
                                   ORDER BY  grad_year', $eduDegrees[Profile::DEGREE_D]);
     // case when no promo was selected that is the admin/phd page
     if (is_null($promo)) {
         $page->assign('promo_list', $promo_list);
         $page->assign('nothing', count($promo_list) == 0);
         return;
     }
     // case when we want to add a list and we have data, that is admin/phd/bulk/validate
     if ($promo == "bulk" && Post::has('people')) {
         S::assert_xsrf_token();
         $lines = explode("\n", Post::t('people'));
         $separator = Env::t('separator');
         foreach ($lines as $line) {
             $infos = explode($separator, $line);
             if (sizeof($infos) !== 2) {
                 $page->trigError("La ligne {$line} n'a pas été ajoutée : mauvais nombre de champs.");
                 continue;
             }
             $infos = array_map('trim', $infos);
             // $info[0] is prenom.nom or hrid. We first try the hrid case, then we try over the possible promos.
             // We trigger an error if the search was unsuccessful.
             $user = User::getSilent($infos[0]);
             if (is_null($user)) {
                 foreach ($promo_list as $promo_possible) {
                     $user = User::getSilent($infos[0] . '.d' . $promo_possible);
                     if (!is_null($user)) {
                         break;
                     }
                 }
                 if (is_null($user)) {
                     $page->trigError("La ligne {$line} n'a pas été ajoutée : aucun compte trouvé.");
                     continue;
                 }
             }
             if ($user->type !== 'phd') {
                 $page->trigError("La ligne {$line} n'a pas été ajoutée : le compte n'est pas celui d'un doctorant.");
                 continue;
             }
             $grad_year = $infos[1];
             if (!$grad_year) {
                 $page->trigError("La ligne {$line} n'a pas été ajoutée : année de soutenance vide.");
                 continue;
             }
             $profile = $user->profile();
             // We have the pid, we now need the id that completes the PK in profile_education.
             $res = XDB::fetchOneCell('SELECT  pe.id
                                         FROM  profile_education AS pe
                                        WHERE  FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags)
                                               AND pe.pid = {?}', $profile->id());
             if (!$res) {
                 $page->trigError("Le profil " . $profile->hrid() . " a déjà une année de soutenance indiquée.");
                 continue;
             }
             // When we are here, we have the pid, id for profile_education table, and $grad_year. Time to UPDATE !
             XDB::execute('UPDATE  profile_education
                              SET  flags = CONCAT(flags, \',completed\'), grad_year = {?}
                            WHERE  pid = {?} AND id = {?}', $grad_year, $profile->id(), $res);
             XDB::execute('UPDATE  profile_display
                              SET  promo = {?}
                            WHERE  pid = {?}', 'D' . $grad_year, $profile->id());
             $page->trigSuccess("Promotion de " . $profile->fullName() . " validée.");
         }
         $errors = $page->nb_errs();
         if ($errors == 0) {
             $page->trigSuccess("L'opération a été effectuée avec succès.");
         } else {
             $page->trigSuccess('L\'opération a été effectuée avec succès, sauf pour ' . ($errors == 1 ? 'l\'erreur signalée' : "les {$errors} erreurs signalées") . ' ci-dessus.');
         }
     } elseif ($validate) {
         S::assert_xsrf_token();
         $list = XDB::iterator('SELECT  pe.pid, pd.directory_name
                                  FROM  profile_education AS pe
                            INNER JOIN  profile_display   AS pd ON (pe.pid = pd.pid)
                                 WHERE  FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags)
                                        AND pe.degreeid = {?} AND pe.grad_year = {?}', $eduDegrees[Profile::DEGREE_D], $promo);
         while ($res = $list->next()) {
             $pid = $res['pid'];
             $name = $res['directory_name'];
             if (Post::b('completed_' . $pid)) {
                 $grad_year = Post::t('grad_year_' . $pid);
                 XDB::execute('UPDATE  profile_education
                                  SET  flags = CONCAT(flags, \',completed\'), grad_year = {?}
                                WHERE  FIND_IN_SET(\'primary\', flags) AND pid = {?}', $grad_year, $pid);
                 XDB::execute('UPDATE  profile_display
                                  SET  promo = {?}
                                WHERE  pid = {?}', 'D' . $grad_year, $pid);
                 $page->trigSuccess("Promotion de {$name} validée.");
             }
         }
     }
     // case we are on a graduation year page, e.g. admin/phd/2007 or admin/phd/2007/validate
     $list = XDB::iterator('SELECT  pe.pid, pd.directory_name
                              FROM  profile_education AS pe
                        INNER JOIN  profile_display   AS pd ON (pe.pid = pd.pid)
                             WHERE  FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags)
                                    AND pe.degreeid = {?} AND pe.grad_year = {?}
                          ORDER BY  pd.directory_name', $eduDegrees[Profile::DEGREE_D], $promo);
     $page->assign('list', $list);
     $page->assign('promo', $promo);
 }
예제 #22
0
파일: geocoding.php 프로젝트: Ekleog/platal
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
require_once 'geocoding.inc.php';
$globals->debug = 0;
// Do not store backtraces.
$res = XDB::query('SELECT  MIN(pid), MAX(pid)
                     FROM  profiles');
$pids = $res->fetchOneRow();
$minPid = $pids[0];
$maxPid = $pids[1];
echo "Filling the 'text' fied is over. Geocoding will start now and will take a few days.\n";
// Tries to geocode all the addresses.
for ($pid = $minPid; $pid < $maxPid + 1; ++$pid) {
    $res = XDB::iterator('SELECT  *
                            FROM  profile_addresses
                           WHERE  pid = {?}', $pid);
    while ($address = $res->next()) {
        $updateTime = $address['updateTime'];
        $gmapsGeocoder = new GMapsGeocoder();
        $address = $gmapsGeocoder->getGeocodedAddress($address);
        if (!isset($address['geoloc'])) {
            // TODO: use address and phone classes to update profile_job_enum and profile_phones once they are done.
            XDB::execute('DELETE FROM  profile_addresses
                                WHERE  pid = {?} AND id = {?} AND type = {?}', $address['pid'], $address['id'], $address['type']);
            Geocoder::getAreaId($address, 'administrativeArea');
            Geocoder::getAreaId($address, 'subAdministrativeArea');
            Geocoder::getAreaId($address, 'locality');
            XDB::execute('INSERT INTO  profile_addresses (pid, type, id, flags, accuracy,
                                                          text, postalText, postalCode, localityId,
                                                          subAdministrativeAreaId, administrativeAreaId,
예제 #23
0
파일: import.php 프로젝트: netixx/frankiz
}
function conv_name($str)
{
    $str = str_replace(array('É'), 'e', $str);
    $str = strtolower(conv($str));
    $str = str_replace(array('é', 'è', 'ë', 'ê'), 'e', $str);
    $str = str_replace(array('à', 'ä', 'â'), 'a', $str);
    $str = str_replace(array('î', 'ï'), 'i', $str);
    $str = str_replace(array('ç'), 'c', $str);
    return preg_replace("/[^a-z0-9_-]/", "", $str);
}
$gf = new GroupFilter(new GFC_Name('tol'));
$group = $gf->get(true)->select(GroupSelect::castes());
$tol_caste = $group->caste(Rights::everybody());
$iter = XDB::iterator('SELECT  nom, prenom, sexe, nationalite,
                               promo, email,
                               SUBSTR(email, 1, LENGTH(email) - 18) AS hruid
                         FROM  dev.temp_tol_2k10');
$users = $iter->total();
$k = 0;
while ($datas = $iter->next()) {
    $t = microtime(true);
    // Creating the User
    $u = new User();
    $u->insert();
    //    $u->password($datas['passwd'], false);
    $u->firstname(ucwords(strtolower(conv($datas['prenom']))));
    $u->lastname(ucwords(strtolower(conv($datas['nom']))));
    //    $u->nickname(conv($datas['surnom']));
    //    $u->birthdate(new FrankizDateTime($datas['date_nais']));
    $u->gender($datas['sexe'] == 'F' ? User::GENDER_FEMALE : User::GENDER_MALE);
    if (!empty($datas['email'])) {
예제 #24
0
파일: languages.php 프로젝트: Ekleog/platal
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
$globals->debug = 0;
// Do not store backtraces.
// First build the list provided by the iso codes.
$list = array();
exec('isoquery --iso=639', $list);
foreach ($list as $key => $item) {
    $array = explode("\t", $item);
    unset($list[$key]);
    $list[$array[0]] = array();
    foreach (array('iso_639_2t', 'iso_639_1') as $i => $field) {
        $list[$array[0]][$field] = $array[$i + 1];
    }
}
$res = XDB::iterator('SELECT  iso_639_2b
                        FROM  profile_langskill_enum
                       WHERE  iso_639_2b IN {?}', array_keys($list));
while ($item = $res->next()) {
    $id = $item['iso_639_2b'];
    XDB::execute('UPDATE  profile_langskill_enum
                     SET  iso_639_2t = {?}, iso_639_1 = {?}
                   WHERE  iso_639_2b = {?}', $list[$id]['iso_639_2t'], $list[$id]['iso_639_1'] ? $list[$id]['iso_639_1'] : null, $id);
}
/* vim:set et sw=4 sts=4 ts=4: */
예제 #25
0
파일: qdj.php 프로젝트: netixx/frankiz
 public static function all()
 {
     $res = XDB::iterator('SELECT  id, date, question, answer1, answer2, count1, count2, writer
                           FROM  qdj
                          WHERE  date!="0000-00-00" AND date<NOW()
                          ORDER  BY date DESC');
     $qdjs = new Collection('QDJ');
     $users = new Collection('User');
     while ($datas = $res->next()) {
         $datas['writer'] = $users->addget($datas['writer']);
         $datas['date'] = new FrankizDateTime($datas['date']);
         $qdjs->addget($datas['id'])->fillFromArray($datas);
     }
     $users->select(UserSelect::base());
     return $qdjs;
 }
예제 #26
0
파일: address.php 프로젝트: Ekleog/platal
 public function __construct(array $pids, array $types, array $jobids, $visibility, $_where)
 {
     $where = array();
     if (!is_null($_where)) {
         $where[] = $_where;
     }
     if (count($pids) != 0) {
         $where[] = XDB::format('(pa.pid IN {?})', $pids);
     }
     if (count($types) != 0) {
         $where[] = XDB::format('(pa.type IN {?})', $types);
     }
     if (count($jobids) != 0) {
         $where[] = XDB::format('(pa.jobid IN {?})', $jobids);
     }
     if ($visibility == null || !$visibility instanceof Visibility) {
         $visibility = Visibility::defaultForRead();
     }
     $where[] = 'pve.best_display_level+0 <= pa.pub+0';
     $sql = 'SELECT  pa.pid, pa.jobid, pa.groupid, pa.type, pa.id, pa.flags, pa.text, pa.postalText, pa.pub, pa.comment,
                     pa.types, pa.formatted_address, pa.location_type, pa.partial_match, pa.latitude, pa.longitude,
                     pa.southwest_latitude, pa.southwest_longitude, pa.northeast_latitude, pa.northeast_longitude,
                     pa.geocoding_date, pa.geocoding_calls,
                     GROUP_CONCAT(DISTINCT pc.component_id SEPARATOR \',\') AS componentsIds,
                     GROUP_CONCAT(pace1.long_name) AS postalCode, GROUP_CONCAT(pace2.long_name) AS locality,
                     GROUP_CONCAT(pace3.long_name) AS administrativeArea, GROUP_CONCAT(pace4.long_name) AS country
               FROM  profile_addresses                 AS pa
          LEFT JOIN  profile_addresses_components      AS pc    ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid
                                                                    AND pa.type = pc.type AND pa.id = pc.id)
          LEFT JOIN  profile_addresses_components_enum AS pace1 ON (FIND_IN_SET(\'postal_code\', pace1.types) AND pace1.id = pc.component_id)
          LEFT JOIN  profile_addresses_components_enum AS pace2 ON (FIND_IN_SET(\'locality\', pace2.types) AND pace2.id = pc.component_id)
          LEFT JOIN  profile_addresses_components_enum AS pace3 ON (FIND_IN_SET(\'administrative_area_level_1\', pace3.types) AND pace3.id = pc.component_id)
          LEFT JOIN  profile_addresses_components_enum AS pace4 ON (FIND_IN_SET(\'country\', pace4.types) AND pace4.id = pc.component_id)
          LEFT JOIN  profile_visibility_enum AS pve ON (pve.access_level = {?})
              WHERE  ' . implode(' AND ', $where) . '
           GROUP BY  pa.pid, pa.jobid, pa.groupid, pa.type, pa.id
           ORDER BY  pa.pid, pa.jobid, pa.id';
     $this->dbiter = XDB::iterator($sql, $visibility->level());
     $this->visibility = $visibility;
 }
예제 #27
0
function get_event_participants(&$evt, $item_id, array $tri = array(), $limit = null, $offset = 0)
{
    global $globals;
    $eid = $evt['eid'];
    $money = $evt['money'] && function_exists('may_update') && may_update();
    $pay_id = $evt['paiement_id'];
    $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
    $query = XDB::fetchAllAssoc('uid', 'SELECT  ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
                                                FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
                                          FROM  group_event_participants AS ep
                                         WHERE  ep.eid = {?} AND nb > 0 ' . $append . '
                                      GROUP BY  ep.uid', $eid);
    $uf = new UserFilter(new PFC_True(), $tri);
    $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), new PlLimit($limit, $offset)));
    $tab = array();
    foreach ($users as $user) {
        $uid = $user->id();
        $tab[$uid] = $query[$uid];
        $tab[$uid]['user'] = $user;
    }
    if ($item_id) {
        return $tab;
    }
    $evt['adminpaid'] = 0;
    $evt['telepaid'] = 0;
    $evt['topay'] = 0;
    $evt['paid'] = 0;
    foreach ($tab as $uid => &$u) {
        $u['adminpaid'] = (double) $u['paid'];
        $u['montant'] = 0;
        if ($money && $pay_id) {
            $montant = XDB::fetchOneCell('SELECT  SUM(amount)
                                            FROM  payment_transactions AS t
                                           WHERE  status = "confirmed" AND ref = {?} AND uid = {?}', $pay_id, $uid);
            $u['paid'] += $montant;
        }
        $u['telepayment'] = $u['paid'] - $u['adminpaid'];
        $res_ = XDB::iterator('SELECT  ep.nb, ep.item_id, ei.montant
                                 FROM  group_event_participants AS ep
                           INNER JOIN  group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
                                WHERE  ep.eid = {?} AND ep.uid = {?}', $eid, $uid);
        while ($i = $res_->next()) {
            $u[$i['item_id']] = $i['nb'];
            $u['montant'] += $i['montant'] * $i['nb'];
        }
        $evt['telepaid'] += $u['telepayment'];
        $evt['adminpaid'] += $u['adminpaid'];
        $evt['paid'] += $u['paid'];
        $evt['topay'] += $u['montant'];
    }
    return $tab;
}
예제 #28
0
 public function getResultArray($sid, $qid)
 {
     $sql = 'SELECT answer, COUNT(id) AS count
               FROM survey_answers
              WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
                AND question_id={?}
           GROUP BY answer ASC';
     $res = XDB::iterator($sql, $sid, $qid);
     $result = array();
     for ($i = 0; $i < count($this->subquestions); $i++) {
         $result[$i] = array_fill(0, count($this->choices), 0);
     }
     while ($r = $res->next()) {
         list($i, $j) = explode(':', $r['answer']);
         $result[$i][$j] = $r['count'];
     }
     return $result;
 }
예제 #29
0
function get_annuaire_infos($method, $params)
{
    global $error_mat, $error_key, $globals;
    // Password verification.
    if (!isset($params[0]) || $params[0] != $globals->manageurs->manageurs_pass) {
        return false;
    }
    // If address == -1, we do not retrieve any address.
    if (isset($params[2]) && $params[2] == -1) {
        unset($params[2]);
    }
    // We check we actually have an identification number.
    if (!empty($params[1])) {
        // We only retrieve addresses when required.
        if (!isset($params[2])) {
            $res = XDB::iterRow("SELECT  pp.display_tel AS cell, p.birthdate AS age\n                                   FROM  profiles       AS p\n                              LEFT JOIN  profile_phones AS pp ON (pp.pid = p.pid AND pp.link_type = 'user'\n                                                                  AND pp.tel_type = 'mobile')\n                                  WHERE  p.xorg_id = {?} LIMIT 1", $params[1]);
            $array = $res->next();
        } else {
            $res = XDB::iterRow("SELECT  p.birthdate, pa.text, GROUP_CONCAT(pace3.short_name), GROUP_CONCAT(pace2.short_name),\n                                         GROUP_CONCAT(pace1.short_name), p.pid, pa.id\n                                   FROM  profiles                          AS p\n                              LEFT JOIN  profile_addresses                 AS pa    ON (pa.pid = p.pid)\n                              LEFT JOIN  profile_addresses_components      AS pc    ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid\n                                                                                        AND pa.type = pc.type AND pa.id = pc.id)\n                              LEFT JOIN  profile_addresses_components_enum AS pace1 ON (FIND_IN_SET(\\'country\\', pace1.types) AND pace1.id = pc.component_id)\n                              LEFT JOIN  profile_addresses_components_enum AS pace2 ON (FIND_IN_SET(\\'locality\\', pace2.types) AND pace2.id = pc.component_id)\n                              LEFT JOIN  profile_addresses_components_enum AS pace3 ON (FIND_IN_SET(\\'postal_code\\', pace3.types) AND pace3.id = pc.component_id)\n                                  WHERE  p.xorg_id = {?} AND NOT FIND_IN_SET('job', pa.flags)\n                               ORDER BY  NOT FIND_IN_SET('current', pa.flags),\n                                         FIND_IN_SET('secondary', pa.flags),\n                                         NOT FIND_IN_SET('mail', pa.flags)\n                               GROUP BY  pa.pid, pa.jobid, pa.groupid, pa.id, pa.type", $params[1]);
            // Process the addresses we got.
            if (list($age, $text, $adr['cp'], $adr['ville'], $adr['pays'], $pid, $adr['adrid']) = $res->next()) {
                list($adr['adr1'], $adr['adr2'], $adr['adr3']) = explode("\n", Geocoder::getFirstLines($text, $adr['cp'], 3));
                $sql = XDB::query("SELECT  display_tel\n                                     FROM  profile_phones\n                                    WHERE  pid = {?} AND link_type = 'user' AND tel_type = 'mobile'\n                                    LIMIT  1", $pid);
                if ($sql->numRows() > 0) {
                    $array['cell'] = $sql->fetchOneCell();
                } else {
                    $array['cell'] = '';
                }
                $array['age'] = $age;
                $array['adresse'][] = $adr;
                // We limit the address number by the number of available addresses.
                $adresse = min((int) $params[2], $res->total());
                if ($adresse != 1) {
                    // We don't want the first address.
                    $i = 2;
                    while (list($age, $text, $adr['cp'], $adr['ville'], $adr['pays'], , $adr['adrid']) = $res->next()) {
                        list($adr['adr1'], $adr['adr2'], $adr['adr3']) = explode("\n", Geocoder::getFirstLines($text, $adr['cp'], 3));
                        if ($adresse == $i) {
                            // If we want this particular address.
                            $array['adresse'][0] = $adr;
                            //$res->free();
                            break;
                        } elseif ($adresse == 0) {
                            // If we want every address.
                            $array['adresse'][] = $adr;
                        }
                        $i++;
                    }
                }
                // We add the phone numbers.
                $adrid_index = array();
                foreach ($array['adresse'] as $i => $a) {
                    $adrid_index[$a['adrid']] = $i;
                }
                $restel = XDB::iterator("SELECT  pp.display_tel AS tel, pp..tel_type, pp.link_id as adrid\n                                           FROM  profile_phones    AS pp\n                                     INNER JOIN  profile_addresses AS pa ON (pp.link_id = pa.id AND pp.pid = pa.pid)\n                                          WHERE  pp.pid = {?} AND pp.link_type = 'address'\n                                                 AND NOT FIND_IN_SET('pro', pa.statut)", $pid);
                while ($tel = $restel->next()) {
                    $array['adresse'][$adrid_index[$tel['adrid']]]['tels'][] = $tel;
                }
                foreach ($array['adresse'] as $i => $adr) {
                    unset($lasttel);
                    foreach ($adr['tels'] as $j => $t) {
                        if (!isset($array['adresse'][$i]['tel']) && strpos($t['tel_type'], 'Tél') === 0) {
                            $array['adresse'][$i]['tel'] = $t['tel'];
                        } elseif (!isset($array['adresse'][$i]['fax']) && strpos($t['tel_type'], 'Fax') === 0) {
                            $array['adresse'][$i]['fax'] = $t['tel'];
                        } else {
                            $lasttel = $t['tel'];
                        }
                        if (isset($array['adresse'][$i]['tel']) && isset($array['adresse'][$i]['fax'])) {
                            break;
                        }
                    }
                    if (!isset($array['adresse'][$i]['tel']) && isset($lasttel)) {
                        $array['adresse'][$i]['tel'] = $lasttel;
                    } elseif (!isset($array['adresse'][$i]['fax']) && isset($lasttel)) {
                        $array['adresse'][$i]['fax'] = $lasttel;
                    }
                    unset($array['adresse'][$i]['adrid']);
                    unset($array['adresse'][$i]['tels']);
                }
            } else {
                $array = false;
            }
        }
        if ($array) {
            // We did get a result: the identification number was rigth.
            // We only send the age to manageurs.com; the format is YYYY-MM-DD 0123-56-89.
            $year = (int) substr($array['age'], 0, 4);
            $month = (int) substr($array['age'], 5, 2);
            $day = (int) substr($array['age'], 8, 2);
            $age = (int) date('Y') - $year - 1;
            if ($month < (int) date('m') || $month == (int) date('m') && $day >= (int) date('d')) {
                $age += 1;
            }
            $array['age'] = $age;
            // We start the encryption of the data.
            if (manageurs_encrypt_init($params[1]) == 1) {
                // We did not find the key to encryptthe data.
                $args = array("erreur" => 3, "erreurstring" => $error_key);
                $reply = xmlrpc_encode_request(NULL, $args);
            } else {
                $reply = manageurs_encrypt_array($array);
                manageurs_encrypt_close();
            }
        } else {
            // The identification number was not valid.
            $args = array("erreur" => 2, "erreurstring" => $erreur_mat);
            $reply = xmlrpc_encode_request(NULL, $args);
        }
    } else {
        // The identification number was not in argument.
        $args = array("erreur" => 1, "erreurstring" => $error_mat);
        $reply = xmlrpc_encode_request(NULL, $args);
    }
    return $reply;
}
예제 #30
0
파일: fusionax.php 프로젝트: Ekleog/platal
 function handler_promo($page, $action = '')
 {
     $page->changeTpl('fusionax/promo.tpl');
     $res = XDB::iterator("SELECT  pid, ax_id, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo\n                                FROM  fusionax_promo\n                               WHERE  !(promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 3 = promo_sortie_xorg)\n                                      AND !(promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 4 = promo_sortie_xorg)\n                                      AND !(promo_etude_ax = promo_etude_xorg + 1) AND groupe_promo = 'X'\n                            ORDER BY  promo_etude_xorg");
     $nbMissmatchingPromos = $res->total();
     $page->assign('nbMissmatchingPromos', $res->total());
     $page->assign('missmatchingPromos', $res);
     $res = XDB::iterator("SELECT  pid, ax_id, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo\n                                FROM  fusionax_promo\n                               WHERE  promo_etude_ax = promo_etude_xorg + 1 AND groupe_promo = 'X'\n                            ORDER BY  promo_etude_xorg");
     $nbMissmatchingPromos += $res->total();
     $page->assign('nbMissmatchingPromos1', $res->total());
     $page->assign('missmatchingPromos1', $res);
     $res = XDB::iterator("SELECT  pid, ax_id, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo\n                                FROM  fusionax_promo\n                               WHERE  promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 3 = promo_sortie_xorg AND groupe_promo = 'X'\n                            ORDER BY  promo_etude_xorg");
     $nbMissmatchingPromos += $res->total();
     $page->assign('nbMissmatchingPromos2', $res->total());
     $page->assign('missmatchingPromos2', $res);
     $res = XDB::iterator("SELECT  pid, ax_id, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo\n                                FROM  fusionax_promo\n                               WHERE  promo_etude_ax + 1 = promo_etude_xorg AND promo_etude_xorg + 4 = promo_sortie_xorg AND groupe_promo = 'X'\n                            ORDER BY  promo_etude_xorg");
     $nbMissmatchingPromos += $res->total();
     $page->assign('nbMissmatchingPromos3', $res->total());
     $page->assign('missmatchingPromos3', $res);
     $res = XDB::iterator("SELECT  pid, ax_id, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo\n                                FROM  fusionax_promo\n                               WHERE  groupe_promo = 'M'\n                            ORDER BY  promo_etude_xorg");
     $nbMissmatchingPromos += $res->total();
     $page->assign('nbMissmatchingPromosM', $res->total());
     $page->assign('missmatchingPromosM', $res);
     $res = XDB::iterator("SELECT  pid, ax_id, private_name, promo_etude_xorg, promo_sortie_xorg, promo_etude_ax, promo\n                                FROM  fusionax_promo\n                               WHERE  groupe_promo = 'D'\n                            ORDER BY  promo_etude_xorg");
     $nbMissmatchingPromos += $res->total();
     $page->assign('nbMissmatchingPromosD', $res->total());
     $page->assign('missmatchingPromosD', $res);
     $page->assign('nbMissmatchingPromosTotal', $nbMissmatchingPromos);
 }