Beispiel #1
0
 public function run()
 {
     $promos = S::user()->castes()->groups()->filter('ns', Group::NS_PROMO);
     $promos->add(Group::from('on_platal'));
     $uf = new UserFilter(new PFC_And(new UFC_Birthday('=', new FrankizDateTime()), new UFC_Group($promos)));
     $us = $uf->get();
     $us->select(UserSelect::birthday());
     $formations = array();
     $users = array();
     foreach ($us as $u) {
         $study = $u->studies();
         $first = array_shift($study);
         $formations[$first->formation()->abbrev()] = $first->formation();
         $users[$first->formation()->abbrev()][$first->promo()][] = $u;
     }
     $this->assign('formations', $formations);
     $this->assign('users', $users);
 }
Beispiel #2
0
 function handler_chat_avatar($page, $hruid)
 {
     global $globals;
     $filter = new UFC_Hruid($hruid);
     $uf = new UserFilter($filter);
     $user = $uf->get(true);
     //add boolean
     if (!$user) {
         header($_SERVER['SERVER_PROTOCOL'] . '404 Not Found');
         $image = new StaticImage($globals->images->man);
         // for some reason mime isn't picked up: for valid images mime == null is enough to be displayed correctly
         // for $globals->images->man neither 1 nor null does the trick
     } else {
         $user->select(UserSelect::login());
         $image = $user->image();
     }
     $image->send("micro");
     exit;
 }
Beispiel #3
0
 public function sendmailfinal($isok)
 {
     if (is_null($this->user->bestEmail())) {
         $this->user->select(UserSelect::base());
     }
     $mail = new FrankizMailer('validate/mail.valid.tol.tpl');
     if (Env::has("ans")) {
         $mail->assign('comm', Env::v('ans'));
     }
     $mail->assign('isOk', $isok);
     if ($isok) {
         $mail->Subject = '[Frankiz] Ta photo tol a été validée';
     } else {
         $mail->Subject = '[Frankiz] Ta photo tol a été refusée';
     }
     $mail->SetFrom($this->_mail_from_addr(), $this->_mail_from_disp());
     $mail->AddAddress($this->user->bestEmail(), $this->user->displayName());
     $mail->AddCC($this->_mail_from_addr(), $this->_mail_from_disp());
     $mail->Send(false);
 }
Beispiel #4
0
 function handler_icalendar($page, $type = 'friends', $user = null, $hash = null)
 {
     $user = User::from($user);
     if (!$user) {
         return PL_FORBIDDEN;
     }
     $user->select(UserSelect::base());
     if ($user->hash_rss() != $hash) {
         return PL_FORBIDDEN;
     }
     if ($type == 'participate') {
         $activities = new ActivityInstanceFilter(new PFC_AND(new AIFC_Participants(S::user()), new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER)));
     } else {
         $activities = new ActivityInstanceFilter(new PFC_Or(new PFC_And(new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER), new AIFC_User($user, 'restricted')), new PFC_And(new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER), new AIFC_User($user, 'everybody'))));
     }
     $c = $activities->get();
     $c->select(ActivityInstanceSelect::all());
     $page->assign('view', $type);
     $page->assign('activities', $c);
     $page->changeTpl('activity/icalendar.tpl', NO_SKIN);
     pl_content_headers("text/calendar");
 }
Beispiel #5
0
 public static function getSilentWithValues($login, $values)
 {
     global $globals;
     if ($login == 0) {
         // If the anonymous_user is already in session
         if (S::has('anonymous_user')) {
             return S::v('anonymous_user');
         }
         $uid = IPAddress::getInstance()->is_x_internal() ? $globals->anonymous->internal : $globals->anonymous->external;
         S::set('newuid', $uid);
         try {
             $u = new User($uid);
             $u->select(UserSelect::login());
         } catch (Exception $e) {
             S::kill('newuid');
             throw $e;
         }
         S::kill('newuid');
         S::set('anonymous_user', $u);
         return $u;
     }
     throw new Exception('DEPRECATED call to getSilentWithValues()');
 }
Beispiel #6
0
 /** Check that we have at least $level auth
  */
 protected function doAuth($level)
 {
     //If only AUTH_COOKIE is required, and we haven't checked the presence of a cookie, do it now
     if ($level == AUTH_COOKIE && !S::has('cookie_uid')) {
         $this->tryCookie();
     }
     //If AUTH_COOKIE is required, and it has succeeded
     if ($level == AUTH_COOKIE && S::has('cookie_uid')) {
         if (!S::logged()) {
             S::set('auth', AUTH_COOKIE);
         }
         $uid = S::i('cookie_uid');
         S::set('newuid', $uid);
         try {
             $u = new User($uid);
             $u->select(UserSelect::login());
         } catch (Exception $e) {
             S::kill('newuid');
             throw $e;
         }
         S::kill('newuid');
         return $u;
     }
     /*If we are here, we want AUTH_MDP
       So we check if the required fields are here */
     // FIXME : lesser checks until new mechanism is ready
     //if(!Post::has('username') || !Post::has('response') || !S::has('challenge'))
     if (!Post::has('username') || !Post::has('password')) {
         return null;
     }
     /* So we come from an authentication form */
     if (S::suid()) {
         $login = S::suid('uid');
         $redirect = false;
     } else {
         $login = Env::v('username');
         $redirect = false;
         if (Post::has('domain')) {
             Cookie::set('domain', Post::v('domain'), 300);
         }
     }
     // FIXME : using Post::v('password') until new authentication mechanism is ready
     $uid = $this->checkPassword($login, Post::v('password'), is_numeric($login) ? 'uid' : 'alias');
     if (!is_null($uid) && S::suid()) {
         if (S::suid('uid') == $uid) {
             $uid = S::i('uid');
         } else {
             $uid = null;
         }
     }
     if (!is_null($uid)) {
         S::set('auth', AUTH_MDP);
         S::kill('challenge');
         // Register a temporary session UID to query well user information
         S::set('newuid', $uid);
         try {
             $user = new User($uid);
             S::logger($uid)->log('auth_ok');
             $user->select(UserSelect::login());
             S::kill('newuid');
         } catch (Exception $e) {
             throw $e;
         }
         S::kill('newuid');
         return $user;
     }
 }
Beispiel #7
0
 function handler_debug($page)
 {
     global $globals;
     if (Env::has("reload")) {
         S::user()->select(UserSelect::login());
     }
     if ($globals->debug & DEBUG_BT) {
         $sessions = array();
         foreach ($_SESSION as $key => $val) {
             ob_start();
             var_dump($val);
             $str = ob_get_clean();
             $str = str_replace("\n", '', $str);
             $str = str_replace('{', '</span><ul><li><span>', $str);
             $str = str_replace('[', '</span></li><li><span>[', $str);
             $str = str_replace('}', '</li></span></ul>', $str);
             $str = preg_replace('/<span> *<\\/span>/i', '', $str);
             $str = preg_replace('/<li> *<\\/li>/i', '', $str);
             $sessions[$key] = $str;
         }
         $page->assign('session', $sessions);
     }
     $page->assign('title', 'Debug');
     $page->changeTpl('admin/debug.tpl');
 }
Beispiel #8
0
 public static function points(FrankizDateTime $begin, FrankizDateTime $end)
 {
     $res = XDB::query('SELECT  uid,
                                SUM( _vote1*5 + _vote2*2 + _vote3 - _vote4*13 + _vote5*4.2 +
                                     _vote6*6.9 + _vote7*3.14 + _vote8*3 + _vote9*7 + _vote10*7.1) as total,
                                SUM(_vote1) as nb1,
                                SUM(_vote2) as nb2,
                                SUM(_vote3) as nb3,
                                SUM(_vote4) as nb4,
                                SUM(_vote5) as nb5,
                                SUM(_vote6) as nb6,
                                SUM(_vote7) as nb7,
                                SUM(_vote8) as nb8,
                                SUM(_vote9) as nb9,
                                SUM(_vote10) as nb10
                          FROM  (
                                SELECT  uid,
                                        if(rule = 1, count(*), 0) as _vote1,
                                        if(rule = 2, count(*), 0) as _vote2,
                                        if(rule = 3, count(*), 0) as _vote3,
                                        if(rule = 4, count(*), 0) as _vote4,
                                        if(rule = 5, count(*), 0) as _vote5,
                                       if(rule = 6, count(*), 0) as _vote6,
                                       if(rule = 7, count(*), 0) as _vote7,
                                       if(rule = 8, count(*), 0) as _vote8,
                                       if(rule = 9, count(*), 0) as _vote9,
                                       if(rule = 10, count(*), 0) as _vote10
                                 FROM  qdj_votes AS qv
                           INNER JOIN  qdj AS q
                                   ON  qv.qdj = q.id
                                WHERE  qv.rule >0
                                  AND  q.date BETWEEN {?} AND {?}
                                  AND  uid NOT IN (
                                       SELECT  uid
                                         FROM  groups AS g
                                         JOIN  castes AS c ON g.gid = c.group
                                         JOIN  castes_users AS cu ON cu.cid = c.cid
                                        WHERE  g.name = "qdj" AND c.rights = "admin"
                                        )
                             GROUP BY  rule, uid
                                ) AS aux
                      GROUP BY  uid
                      ORDER BY  total DESC', $begin->toDb(), $end->toDb())->fetchAllAssoc();
     $users = new collection('User');
     foreach ($res as $key => $e) {
         $res[$key]['average'] = ($e['nb1'] + $e['nb2'] + $e['nb3'] + $e['nb4'] + $e['nb5'] + $e['nb6'] + $e['nb7'] + $e['nb8'] + $e['nb9'] + $e['nb10']) / 10;
         $res[$key]['user'] = $users->addget($e['uid']);
         unset($res[$key]['uid']);
         $res[$key]['deviation'] = round(sqrt((pow($e['nb1'], 2) + pow($e['nb2'], 2) + pow($e['nb3'], 2) + pow($e['nb4'], 2) + pow($e['nb5'], 2) + pow($e['nb6'], 2) + pow($e['nb7'], 2) + pow($e['nb8'], 2) + pow($e['nb9'], 2) + pow($e['nb10'], 2)) / 10 - pow($res[$key]['average'], 2)), 2);
     }
     $users->select(UserSelect::base());
     return $res;
 }
Beispiel #9
0
 public function userHasRights()
 {
     $this->writer->select(UserSelect::castes());
     return License::hasRights($this->writer);
 }
Beispiel #10
0
 public static function news()
 {
     return new NewsSelect(array_merge(self::$natives, array('read', 'star')), array('writer' => UserSelect::base(), 'target' => CasteSelect::group(), 'origin' => GroupSelect::base()));
 }
Beispiel #11
0
 function handler_group_unsubscribe($page, $group)
 {
     S::assert_xsrf_token();
     $group = Group::fromId($group);
     if (!$group) {
         $page->assign('title', "Ce groupe n'existe pas");
         $page->changeTpl('groups/no_group.tpl');
         return;
     }
     $group->select(GroupSelect::subscribe());
     if ($group->leavable()) {
         $group->removeUser(S::user());
         S::user()->select(UserSelect::castes());
     }
     pl_redirect('groups/see/' . $group->name());
     exit;
 }
Beispiel #12
0
 public function handler_recovery($page)
 {
     global $globals;
     $page->addCssLink('profile.css');
     $page->changeTpl('profile/recovery.tpl');
     $page->assign('title', 'Nouveau mot de passe');
     // Step 1 : Ask the email
     $page->assign('step', 'ask');
     // Step 2 : Send the recovery mail
     if (Env::t('mail', '') != '') {
         // TODO: Accept forlife too
         list($forlife, $domain) = explode('@', Env::t('mail'), 2);
         $uf = new UserFilter(new UFC_Forlife($forlife, $domain));
         $user = $uf->get(true);
         if (!$user) {
             $page->assign('error', 'true');
             return;
         }
         $user->select(UserSelect::base());
         $page->assign('email', Env::t('mail'));
         $mail = new FrankizMailer('profile/recovery.mail.tpl');
         $hash = rand_url_id();
         $user->hash($hash);
         $mail->assign('hash', $hash);
         $mail->assign('uid', $user->id());
         $mail->SetFrom($globals->mails->web, 'Les Webmestres de Frankiz');
         $mail->AddAddress($user->bestEmail(), $user->displayName());
         $mail->subject('[Frankiz] Changement de mot de passe');
         $mail->Send($user->isEmailFormatHtml());
         $page->assign('step', 'mail');
     }
     // Step 2 : Send a new password
     if (Env::v('hash', '') != '' && Env::v('uid', '') != '') {
         $user = new User(Env::v('uid'));
         $user->select(UserSelect::base());
         if (Env::v('hash') == $user->hash()) {
             // TODO: log the session opening
             $mail = new FrankizMailer('profile/recovery_new.mail.tpl');
             $new = rand_url_id();
             $user->hash('');
             $user->password($new);
             $mail->assign('new_password', $new);
             $mail->SetFrom($globals->mails->web, 'Les Webmestres de Frankiz');
             $mail->AddAddress($user->bestEmail(), $user->displayName());
             $mail->subject('[Frankiz] Nouveau mot de passe');
             $mail->Send($user->isEmailFormatHtml());
             $page->assign('step', 'password');
         } else {
             $page->assign('step', 'expired');
         }
     }
 }
Beispiel #13
0
 /**
  * @param $page      The page
  * @param $login     The hruid of the user
  * @param $token     The hash_rss for identification
  */
 public function run(FrankizPage $page, $login, $token)
 {
     $uf = new UserFilter(new UFC_Hruid($login));
     $user = $uf->get(true);
     if (!$user) {
         return PL_FORBIDDEN;
     }
     $user->select(UserSelect::feed());
     if ($user->hash_rss() != $token) {
         return PL_FORBIDDEN;
     }
     $page->assign('rss_hash', $token);
     pl_content_headers("application/rss+xml");
     $this->iterator = $this->fetch($user);
     $page->coreTpl('feed.rss2.tpl', NO_SKIN);
     $page->assign_by_ref('feed', $this);
     $page->run();
 }
Beispiel #14
0
 public function objects()
 {
     return array('writer' => UserSelect::base());
 }
Beispiel #15
0
 $u = new User();
 $u->insert();
 //    $u->password($datas['passwd'], false);
 $u->firstname(ucwords(strtolower(conv($datas[$firstname]))));
 $u->lastname(ucwords(strtolower(conv($datas[$lastname]))));
 //    $u->nickname(conv($datas['surnom']));
 $u->birthdate(new FrankizDateTime($datas[$birthdate]));
 if ($gender != null) {
     $u->gender($datas[$gender] == 'F' ? User::GENDER_FEMALE : User::GENDER_MALE);
 }
 if (!empty($datas[$email])) {
     $u->email($datas[$email]);
 }
 $u->skin('default');
 //setting default minimodules
 $u->select(UserSelect::minimodules());
 $u->copyMinimodulesFromUser(11794);
 /*    try {
         $u->cellphone(new Phone($datas['portable']));
     } catch(Exception $e) {
         echo 'Error for phone ' . $datas['portable'] . "\n";
     }*/
 //    $u->poly($datas['login']);
 // Linking with the room
 if ($room_id != null) {
     $room = $datas[$room_id];
     if (!empty($room)) {
         if (preg_match('/^[0-9]+[a-z]?$/', $room)) {
             $room = 'X' . $room;
         }
         if ($room = Room::from($room)) {
Beispiel #16
0
 function handler_tol_ajax_sheet($page, $uid)
 {
     $f = new UserFilter(new UFC_Uid($uid));
     $u = $f->get(true);
     if ($u) {
         $u->select(UserSelect::tol());
     }
     $page->assign('user', S::user());
     $page->assign('result', $u);
     try {
         $sheet = $page->filteredFetch(FrankizPage::getTplPath('tol/sheet.tpl'));
     } catch (Exception $e) {
         $sheet = "La fiche de l'utilisateur comporte des erreurs";
         XDB::execute('INSERT INTO tol_errors SET error = {?}', $u->id());
     }
     $page->jsonAssign('sheet', $sheet);
     $page->jsonAssign('success', true);
     return PL_JSON;
 }
Beispiel #17
0
 public function sendmailfinal($isok)
 {
     if ($this->writer->bestEmail() === null) {
         $this->writer->select(UserSelect::base());
     }
     $mail = new FrankizMailer('validate/mail.valid.activity.tpl');
     $mail->assign('isok', $isok);
     $mail->assign('valid_origin', $this->valid_origin);
     $mail->assign('comm', Env::v('ans', ''));
     $mail->assign('targetGroup', $this->target->group());
     $mail->assign('origin', $this->origin);
     if ($isok && !$this->valid_origin) {
         $mail->Subject = '[Frankiz] Ton activité a été validée';
     } elseif ($isok) {
         $mail->Subject = '[Frankiz] Le groupe d\'origine de ton activité a été validé';
     } else {
         $mail->Subject = '[Frankiz] Ton activité a été refusée';
     }
     $mail->SetFrom($this->_mail_from_addr(), $this->_mail_from_disp());
     $mail->AddAddress($this->writer->bestEmail(), $this->writer->displayName());
     $mail->AddCC($this->_mail_from_addr(), $this->_mail_from_disp());
     $mail->Send(false);
 }
Beispiel #18
0
 function handler_admin($page)
 {
     $mixed = func_get_args();
     array_shift($mixed);
     $mixed = implode('/', $mixed);
     if (empty($mixed)) {
         $wikis = Wiki::selectAll(Wiki::SELECT_BASE | Wiki::SELECT_COUNT);
         $page->assign('wikis', $wikis);
         $page->addCssLink('wiki.css');
         $page->assign('title', 'Admin Wiki');
         $page->changeTpl('wiki/list.tpl');
     } else {
         if (Wiki::isId($mixed)) {
             $wiki = new Wiki($mixed);
         } else {
             $wiki = Wiki::from($mixed, true);
             // Create the Wiki if it doesn't exist
         }
         if (Env::has('newcontent')) {
             $wiki->update(Env::s('newcontent'));
         }
         $wiki->select(Wiki::SELECT_BASE | Wiki::SELECT_COUNT);
         $wiki->select(array(Wiki::SELECT_VERSION => array('versions' => array('last'), 'options' => UserSelect::base())));
         $page->assign('wiki', $wiki);
         $page->addCssLink('wiki.css');
         $page->assign('title', 'Admin Wiki: ' . $wiki->name());
         $page->changeTpl('wiki/admin.tpl');
     }
 }
Beispiel #19
0
 public static function validate($subs = null)
 {
     return new self(array('writer', 'type', 'group', 'created', 'item'), array('writer' => UserSelect::base(), 'group' => GroupSelect::base()));
 }
Beispiel #20
0
 public static function see()
 {
     return self::all(array('ips' => IpSelect::base(), 'users' => UserSelect::base(), 'groups' => GroupSelect::base()));
 }
Beispiel #21
0
 public function objects()
 {
     return array('writer' => UserSelect::base(), 'formation' => GroupSelect::base(), 'origin' => GroupSelect::base());
 }
Beispiel #22
0
}
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());
$uf = new UserFilter(new PFC_And(new UFC_Study(new Formation(1)), new UFC_Promo(2010)));
$us = $uf->get()->select(UserSelect::tol());
$nf = new GroupFilter(new GFC_Name('sport_judo'));
$n = $nf->get(true);
$n->select(GroupSelect::castes());
/*
XDB::execute('DELETE FROM users_minimodules WHERE uid = 0 AND col = "COL_FLOAT"');
XDB::execute('INSERT INTO users_minimodules (uid,name,col,row) VALUES
                          (0, "activate_account",  "COL_FLOAT",  0 )');
XDB::execute('INSERT INTO users_minimodules (uid,name,col,row) VALUES
                          (0, "quicksearch",       "COL_FLOAT",  1 )');
XDB::execute('INSERT INTO users_minimodules (uid,name,col,row) VALUES
                          (0, "links",             "COL_FLOAT",  2 )');
*/
$users = $us->count();
$k = 0;
foreach ($us as $u) {
Beispiel #23
0
 *  http://br.binets.fr/                                                   *
 *                                                                         *
 *  This program is free software; you can redistribute it and/or modify   *
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation; either version 2 of the License, or      *
 *  (at your option) any later version.                                    *
 *                                                                         *
 *  This program is distributed in the hope that it will be useful,        *
 *  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                *
 ***************************************************************************/
/**
/**
* Force a skin to every user in groupe on_platal
*/
require_once dirname(__FILE__) . '/../connect.db.inc.php';
// Get all users
$userfilter = new UserFilter(new UFC_Group(Group::from('on_platal')));
$users = $userfilter->get();
$users->select(UserSelect::base());
$skin = empty($argv[1]) ? 'default' : $argv[1];
foreach ($users as $u) {
    echo 'Forcing skin to ' . $u->login() . PHP_EOL;
    $u->skin($skin);
}
Beispiel #24
0
 public static function all($subs = null)
 {
     return new ActivityInstanceSelect(array_merge(self::$natives, array('participants')), array('writer' => UserSelect::base(), 'activity' => ActivitySelect::base(), 'participants' => UserSelect::base()));
 }