Example #1
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();
 }
Example #2
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);
 }
Example #3
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;
 }
Example #4
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);
}
Example #5
0
$res = XDB::query('SELECT  id, target, writer, writername, title, body, ishtml
                     FROM  mails
                    WHERE  processed IS NULL')->fetchAllRow();
$ids = array();
if (count($res) == 0) {
    exit;
}
foreach ($res as $r) {
    $ids[] = $r[0];
}
XDB::execute('UPDATE  mails
                 SET  processed = NOW()
               WHERE  id IN {?}', $ids);
XDB::commit();
foreach ($res as $r) {
    $uf = new UserFilter($r[1]);
    $users = $uf->get();
    $users->select(UserSelect::base());
    foreach ($users as $user) {
        $mail = new FrankizMailer();
        $mail->addAddress($user->bestEmail(), $user->fullName());
        $mail->SetFrom($r[2], $r[3]);
        $mail->subject($r[4]);
        $mail->body($r[5]);
        $mail->send($r[6]);
    }
    XDB::execute('UPDATE  mails
                     SET  done = NOW()
                   WHERE  id = {?}', $r[0]);
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
Example #6
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) {
Example #7
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;
 }
Example #8
0
 function handler_group_ajax_admin_users($page)
 {
     $group = Group::fromId(Json::i('gid'));
     $limit = 10;
     $total = 0;
     $users = false;
     if ($group) {
         $users = array();
         $order = new UFO_Name(UFO_Name::LASTNAME);
         $filters = array();
         $rights = Rights::everybody();
         if (Json::s('rights', '') != '') {
             $rights = new Rights(Json::s('rights'));
         }
         $filters[] = new UFC_Group($group, $rights);
         if (Json::t('promo', '') != '') {
             $filters[] = new UFC_Group(explode(';', Json::v('promo')));
         }
         if (Json::t('name', '') != '') {
             $filters[] = new UFC_Name(Json::t('name'), UFC_Name::LASTNAME | UFC_Name::FIRSTNAME | UFC_Name::NICKNAME, UFC_Name::CONTAINS);
         }
         $uf = new UserFilter(new PFC_And($filters), $order);
         $users = $uf->get(new PlLimit($limit, (Json::i('page', 1) - 1) * $limit));
         $total = $uf->getTotalCount();
         $export = array();
         if ($users->count() > 0) {
             $users->select(UserSelect::base());
             /*
              * Fetching rights
              */
             $users_rights = $group->selectRights($users);
             /*
              * Fetching comments
              */
             $users_comments = array();
             $iter = XDB::iterRow('SELECT  uid, comment
                                     FROM  users_comments
                                    WHERE  gid = {?} AND uid IN {?}', $group->id(), $users->ids());
             while (list($uid, $comment) = $iter->next()) {
                 $users_comments[$uid] = $comment;
             }
             /*
              * Exporting
              */
             $page->assign('defaultrights', array(Rights::admin(), Rights::member(), Rights::friend()));
             foreach ($users as $uid => $u) {
                 $page->assign('user', $u);
                 $page->assign('rights', empty($users_rights[$uid]) ? array() : $users_rights[$uid]);
                 $page->assign('comment', empty($users_comments[$uid]) ? "" : $users_comments[$uid]);
                 $export[$uid] = $page->filteredFetch(FrankizPage::getTplPath('groups/admin_user.tpl'));
             }
         }
     }
     $page->jsonAssign('limit', $limit);
     $page->jsonAssign('total', $total);
     $page->jsonAssign('users', $export);
     return PL_JSON;
 }
Example #9
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');
         }
     }
 }