Example #1
0
 function handler_ajax_modify($page)
 {
     S::assert_xsrf_token();
     if (!S::user()->hasRights(Group::from('qdj'), Rights::admin())) {
         return PL_FORBIDDEN;
     }
     $qdj = new QDJ(Json::i('id'));
     $page->jsonAssign('success', false);
     if (Json::has('date')) {
         $date = Json::t('date');
         if (!$date) {
             $qdj->date(false);
             $page->jsonAssign('success', true);
         } else {
             try {
                 $qdj->date(new FrankizDateTime($date));
                 $page->jsonAssign('success', true);
             } catch (Exception $e) {
             }
         }
     } else {
         if (Json::has('delete')) {
             if (Json::b('delete')) {
                 $qdj->delete();
                 $page->jsonAssign('success', true);
             }
         }
     }
     return PL_JSON;
 }
Example #2
0
 function handler_upload($page)
 {
     $page->assign('exception', false);
     $page->assign('image', false);
     if (FrankizUpload::has('file')) {
         $g = Group::from('temp')->select(GroupSelect::castes());
         $temp = $g->caste(Rights::everybody());
         try {
             $upload = FrankizUpload::v('file');
             $secret = uniqid();
             $i = new FrankizImage();
             $i->insert();
             $i->caste($temp);
             $i->label($secret);
             $i->image($upload);
             $page->assign('image', $i);
             $page->assign('secret', $secret);
         } catch (Exception $e) {
             try {
                 if ($i) {
                     $i->delete();
                 }
             } catch (Exception $eb) {
                 $page->assign('exception', $eb);
             }
             $page->assign('exception', $e);
             if ($e instanceof ImageSizeException) {
                 $page->assign('pixels', true);
             } else {
                 if ($e instanceof UploadSizeException) {
                     $page->assign('bytes', true);
                 } else {
                     if ($e instanceof ImageFormatException) {
                         $page->assign('format', true);
                     }
                 }
             }
         }
     }
     if (Env::has('delete')) {
         $image = new FrankizImage(Env::i('iid'));
         $image->select(FrankizImageSelect::base());
         if ($image->label() == Env::s('secret')) {
             $image->delete();
         }
     }
     $page->addCssLink('upload.css');
     $page->changeTpl('images/upload.tpl', SIMPLE);
 }
Example #3
0
 public function sendmailadmin()
 {
     if (is_null($this->user->bestEmail())) {
         $this->user->select(UserSelect::base());
     }
     $mail = new FrankizMailer('validate/mail.admin.tol.tpl');
     $mail->assign('user', $this->user->displayName());
     $group = Group::from('tol');
     $group->select(GroupSelect::base());
     $mail->assign('targetGroup', $group);
     $mail->subject("[Frankiz] Validation d'une photo tol");
     $mail->SetFrom($this->user->bestEmail(), $this->user->displayName());
     $mail->AddAddress($this->_mail_from_addr(), $this->_mail_from_disp());
     $mail->Send(false);
 }
Example #4
0
 function handler_home($page)
 {
     $page->assign('MiniModules_COL_LEFT', FrankizMiniModule::get(S::user()->minimodules(FrankizMiniModule::COL_LEFT)));
     $page->assign('MiniModules_COL_MIDDLE', FrankizMiniModule::get(S::user()->minimodules(FrankizMiniModule::COL_MIDDLE)));
     $page->assign('MiniModules_COL_RIGHT', FrankizMiniModule::get(S::user()->minimodules(FrankizMiniModule::COL_RIGHT)));
     $postit = Group::from('postit');
     // /!\ : Everybody can read the post-it, you don't have to be member of the group
     $nf = new NewsFilter(new PFC_And(new NFC_Current(), new NFC_TargetGroup($postit)), new NFO_Begin(true));
     $postit_news = $nf->get(true);
     if ($postit_news) {
         $postit_news->select(NewsSelect::news());
     }
     $page->assign('postit_news', $postit_news);
     $page->assign('title', 'Accueil');
     $page->changeTpl('frankiz/home.tpl');
 }
Example #5
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 #6
0
<?php 
/***************************************************************************
 *  Copyright (C) 2004-2012 Binet Réseau                                   *
 *  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                *
 ***************************************************************************/
require_once dirname(__FILE__) . '/../connect.db.inc.php';
$iter = XDB::iterRow('SELECT uid, pa FROM temp');
while (list($uid, $paname) = $iter->next()) {
    $pa = Group::from($paname);
    $u = new User($uid);
    $pa->select(GroupSelect::castes());
    $pa->caste(Rights::member())->addUser($u);
    echo ".";
}
echo 'Over';
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
Example #7
0
 function handler_remote($page)
 {
     global $globals, $platal;
     if (!(Env::has('timestamp') && Env::has('site') && Env::has('hash') && Env::has('request'))) {
         $page->trigError("Requête non valide");
         return;
     }
     // Read request
     $timestamp = Env::s('timestamp');
     if (abs($timestamp - time()) > $globals->remote->lag) {
         $page->trigError("Delai d'attente dépassé");
         return;
     }
     $site = Env::s('site');
     $request = Env::s('request');
     // Load remote information
     try {
         $remote = Remote::from(Env::s('site'));
         $remote->select(RemoteSelect::groups());
     } catch (ItemNotFoundException $e) {
         $page->trigError("Ton site n'est pas renseigné dans la base de données");
         return;
     }
     // Check request
     if (md5($timestamp . $site . $remote->privkey() . $request) != Env::s('hash')) {
         $page->trigError("Erreur de validation de la requête d'authentification");
         return;
     }
     $request = json_decode($request, true);
     // Force login
     $user = Platal::session()->doAuthWithoutStart(AUTH_COOKIE);
     if (empty($user)) {
         $page->assign('remote_site', $remote->label());
         $platal->force_login($page);
         return PL_FORBIDDEN;
     }
     // Build response
     $response = array('uid' => $user->id());
     if ($remote->hasRight('names') && in_array('names', $request)) {
         $response['hruid'] = $user->login();
         $response['firstname'] = $user->firstname();
         $response['lastname'] = $user->lastname();
         $response['nickname'] = $user->nickname();
     }
     if ($remote->hasRight('email') && in_array('email', $request)) {
         $response['email'] = $user->email();
     }
     if ($remote->hasRight('rights') && in_array('rights', $request)) {
         $r = array();
         foreach ($remote->groups() as $g) {
             $r[$g->name()] = array_map(function ($r) {
                 return (string) $r;
             }, $user->rights($g));
         }
         if (!empty($r)) {
             $response['rights'] = $r;
         }
     }
     if ($remote->hasRight('sport') && in_array('sport', $request)) {
         $groups = $user->castes()->groups();
         $group = $groups->filter('ns', Group::NS_SPORT)->first();
         if ($group) {
             $response['sport'] = $group->label();
         }
     }
     if ($remote->hasRight('promo') && in_array('promo', $request)) {
         $groups = $user->castes()->groups()->filter('ns', Group::NS_PROMO);
         $groups = $groups->remove(Group::from('on_platal'));
         // Extract promos from group labels
         // For backward compatibility, compute the minimal promo year
         $promo = 0;
         $promos = array();
         foreach ($groups as $g) {
             $matches = array();
             if (preg_match('/^promo_([a-z_]+)([1-9][0-9]{3})$/', $g->name(), $matches)) {
                 $promos[] = $matches[1] . $matches[2];
                 $year = (int) $matches[2];
                 if (!$promo || $year < $promo) {
                     $promo = $year;
                 }
             }
         }
         if ($promo) {
             $response['promo'] = $promo;
             $response['promos'] = $promos;
         }
     }
     if ($remote->hasRight('photo') && in_array('photo', $request)) {
         $img = $user->photo();
         if ($img === false) {
             $img = $user->original();
         }
         if ($img !== false) {
             $response['photo'] = $globals->baseurl . '/' . $img->src('full');
         }
     }
     if ($remote->hasRight('binets_admin') && in_array('binets_admin', $request)) {
         $gf = new GroupFilter(new PFC_And(new GFC_User($user, Rights::admin()), new GFC_Namespace('binet')));
         $gs = $gf->get();
         if ($gs->count() > 0) {
             $gs->select(GroupSelect::base());
             $r = array();
             foreach ($gs as $g) {
                 $r[$g->name()] = $g->label();
             }
             if (!empty($r)) {
                 $response['binets_admin'] = $r;
             }
         }
     }
     // Send response
     $response = json_encode($response);
     $location = Env::s('location');
     header('Location: ' . $site . '?location=' . $location . '&timestamp=' . $timestamp . '&response=' . $response . '&hash=' . md5($timestamp . $remote->privkey() . $response));
 }
Example #8
0
require_once dirname(__FILE__) . '/../connect.db.inc.php';
//$available_rights = Rights::rights();
$available_rights = array('admin', 'logic', 'member', 'friend', 'restricted', 'everybody');
// Get webmaster caste
$ufc_web = new UFC_Group(Group::from('webmasters'), Rights::member());
// Get kes admins
$ufc_kes = new UFC_Group(Group::from('kes'), Rights::admin());
// Shalom-CCX-AMEP
$shccxamep_groups = new Collection();
$shccxamep_groups->add(Group::from('shalom'));
$shccxamep_groups->add(Group::from('ccx'));
$shccxamep_groups->add(Group::from('amep'));
$ufc_shalom_ccx_amep = new UFC_Group($shccxamep_groups, Rights::admin());
unset($shccxamep_groups);
// licenses members = on_platal and X
$ufc_licenses = new PFC_And(array(new UFC_Group(Group::from('formation_x'), Rights::restricted()), new UFC_Group(Group::from('on_platal'), Rights::restricted())));
// Get formations
$formations = array();
foreach (Formation::selectAll(FormationSelect::base()) as $form) {
    $formations[$form->abbrev()] = intval($form->id());
}
// Test wether the userfilter which is in the database is the expected one
function test_userfilters($grouptext, $rights, $db_caste, $expected_condition = null)
{
    $castetext = $rights . " userfilter (caste " . $db_caste->id() . ")";
    $db_userfilter = $db_caste->userfilter();
    if (is_null($expected_condition)) {
        if ($db_userfilter) {
            echo "Info: group " . $grouptext . " has unexpected " . $castetext . " " . json_encode($db_userfilter->export()) . "\n";
        }
    } else {
Example #9
0
 function handler_links_admin($page)
 {
     if (!S::user()->perms()->hasFlag('admin')) {
         return PL_FORBIDDEN;
     }
     $collec = Link::all();
     $collec->select(LinkSelect::all());
     $results = $collec->split('ns');
     if (Env::has('modify')) {
         $id = Env::i('id');
         $link = $collec->get($id);
         if ($link !== false) {
             if (Env::has('image')) {
                 try {
                     $group = Group::from('partnership');
                     $group->select();
                     $image = new FrankizImage();
                     $image->insert();
                     $image->label($link->label());
                     $image->caste($group->caste('everybody'));
                     $image->image(FrankizUpload::v('image'));
                     $link->image($image);
                 } catch (Exception $e) {
                     $page->assign('err', $e->getMessage());
                 }
             }
             $link->label(Env::t('label'));
             $link->link(Env::t('link'));
             $link->description(Env::t('description'));
             $link->comment(Env::t('comment'));
         } else {
             $err = 'Le lien modifié n\'existe plus.';
             $page->assign('err', $err);
         }
     }
     $page->addCssLink('links.css');
     $page->assign('links', $results);
     $page->assign('title', 'Administrer les liens');
     $page->changeTpl('links/admin_links.tpl');
 }
Example #10
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 #11
0
 function handler_tol_birthday($page, $nice = 1)
 {
     $on_platal = Group::from('on_platal');
     $next_week = new FrankizDateTime();
     $week = new DateInterval('P7D');
     $next_week = $next_week->add($week);
     if ($nice) {
         $order = array(new UFO_Promo(), new UFO_Birthday());
     } else {
         $order = new UFO_Birthday();
     }
     $uf = new UserFilter(new PFC_And(new UFC_Group($on_platal, Rights::member()), new UFC_Birthday('>=', new FrankizDateTime()), new UFC_Birthday('<=', $next_week)), $order);
     $users = $uf->get()->select(UserSelect::tol());
     $old_promo = 0;
     header('Content-Type: text/html; charset=utf-8');
     echo '<pre>';
     foreach ($users as $u) {
         $study = reset($u->studies());
         $promo = $study->promo();
         if ($nice && $old_promo != $promo) {
             if ($old_promo != 0) {
                 echo "\n";
             }
             echo "Promotion " . $promo . "\n";
             $old_promo = $promo;
         }
         if ($nice) {
             echo $u->birthdate()->format('d/m/Y') . ' ' . $u->firstname() . ' ' . $u->lastname() . "\n";
         } else {
             echo $promo . ',' . $u->birthdate()->format('d/m/Y') . ',' . $u->lastname() . ',' . $u->firstname() . "\n";
         }
     }
     echo '</pre>';
     exit;
 }
Example #12
0
 public function handler_licenses_final($page, $no_reason = false)
 {
     $softwares = License::getSoftwares();
     $keys = array();
     if (Post::has('disagree') || !$no_reason && !Post::has('resend') && (!Post::has('reason') || Post::v('reason') == "") || !Post::has('software') || !in_array(Post::v('software'), array_keys($softwares))) {
         $this->handler_licenses($page);
     } else {
         $page->changeTpl('licenses/licenses_final.tpl');
         $page->assign('title', "Demande de licence pour {$softwares[Post::v('software')]}");
         $page->assign('software', Post::s('software'));
         $page->assign('software_name', $softwares[Post::s('software')]);
         if (($key = License::adminKey(Post::s('software'))) && License::hasRights(S::user())) {
             $key->give(S::user());
             $page->assign('direct', true);
         } elseif (Post::has('resend')) {
             $l = License::fetch(array('id' => Post::i('id')));
             if ($l[0]->uid() == S::user()->id()) {
                 License::send($l);
             } else {
                 die("La license n'appartient pas à l'utilisateur courant");
             }
             $page->assign('direct', true);
         } else {
             $lv = new LicensesValidate(Post::s('software'), Post::s('reason'));
             $v = new Validate(array('writer' => S::user(), 'group' => Group::from('licenses'), 'item' => $lv, 'type' => 'licenses'));
             $v->insert();
             $page->assign('direct', false);
         }
     }
 }
Example #13
0
 public function buildCondition(PlFilter $f)
 {
     $g = Group::from('temp')->select(GroupSelect::castes());
     $temp = $g->caste(Rights::everybody());
     return XDB::format('i.caste = {?}', $temp->id());
 }
Example #14
0
 /**
  * Get associated group for this formation and promo
  * @param integer $promo
  * @return Group
  */
 public function getGroupForPromo($promo)
 {
     return Group::from('promo_' . $this->abbrev . sprintf('%04d', $promo));
 }
Example #15
0
 public function handler_admin_account($page, $hruid = null, $added = false)
 {
     $err = array();
     $msg = array();
     $add = false;
     if ($added) {
         $msg[] = "L'utilisateur a été ajouté avec succès";
     }
     if ($hruid === null) {
         $user = new User();
         $add = true;
     } else {
         $user = new UserFilter(new UFC_Hruid($hruid));
         $user = $user->get(true);
         if ($user !== false) {
             $user->select(UserSelect::tol());
         } else {
             throw new Exception("Impossible de charger les données de l'utilisateur " . $hruid);
         }
     }
     if (Env::has('add_room') && !$add) {
         $r = Room::batchFrom(array(Env::t('rid')));
         if ($r->count() == 0) {
             $err[] = "La chambre entrée n'existe pas.";
         } else {
             $user->addRoom($r->pop());
         }
     }
     if (Env::has('del_room') && !$add) {
         $r = Room::batchFrom(array(Env::t('rid')));
         if ($r->count() == 0) {
             $err[] = "La chambre entrée n'existe pas.";
         } else {
             $user->removeRoom($r->pop());
         }
     }
     if (Env::has('add_perm') && !$add && S::user()->isAdmin()) {
         $user->addPerm(Env::t('perm'));
     }
     if (Env::has('del_perm') && !$add && S::user()->isAdmin()) {
         $user->removePerm(Env::t('perm'));
     }
     if (Env::has('upd_study') && !$add) {
         $user->updateStudy(Env::t('formation_id'), Env::t('forlife'), Env::t('year_in'), Env::t('year_out'), Env::t('promo'));
     }
     if (Env::has('add_study') && !$add) {
         $user->addStudy(Env::t('formation_id'), Env::t('year_in'), Env::t('year_out'), Env::t('promo'), Env::t('forlife'));
     }
     if (Env::has('del_study') && !$add) {
         $user->removeStudy(Env::t('formation_id'), Env::t('forlife'));
     }
     if (Env::has('add_group') && !$add) {
         $g = Group::from(Env::t('name'))->select(GroupSelect::castes());
         $g->caste(Rights::member())->addUser($user);
     }
     if (Env::has('del_group') && !$add) {
         $g = Group::from(Env::t('name'))->select(GroupSelect::castes());
         $g->caste(Rights::member())->removeUser($user);
     }
     if (Env::has('change_profile')) {
         if ($add) {
             if (Env::blank('hruid')) {
                 $hruid = Env::t('firstname') . '.' . Env::t('lastname');
                 $hruid = strtolower($hruid);
                 $already = new UserFilter(new UFC_Hruid($hruid));
                 $nbr = 1;
                 while ($already->getTotalCount() > 0) {
                     $nbr++;
                     $hruid = Env::t('firstname') . '.' . Env::t('lastname') . '.' . $nbr;
                     $hruid = strtolower($hruid);
                     $already = new UserFilter(new UFC_Hruid($hruid));
                 }
             } else {
                 $hruid = Env::t('hruid');
                 $already = new UserFilter(new UFC_Hruid($hruid));
                 if ($already->getTotalCount() > 0) {
                     throw new Exception("Le hruid spécifié est déjà pris.");
                 }
             }
             $user->insert();
             if (Env::blank('hruid')) {
                 $user->hruid($hruid);
             }
             $msg[] = "L'utilisateur a été ajouté.";
         }
         if (Env::has('image')) {
             $group = Group::from('tol')->select(GroupSelect::castes());
             $image = new ImageFilter(new PFC_And(new IFC_Id(Env::i('image')), new IFC_Temp()));
             $image = $image->get(true);
             if (!$image) {
                 throw new Exception("This image doesn't exist anymore");
             }
             $image->select(FrankizImageSelect::caste());
             $image->label($user->fullName());
             $image->caste($group->caste(Rights::everybody()));
             $tv = new TolValidate($image, $user);
             $v = new Validate(array('writer' => $user, 'group' => $group, 'item' => $tv, 'type' => 'tol'));
             $v->insert();
             $msg[] = 'La demande de changement de photo tol a été prise en compte.
                 Les tolmestres essaieront de te la valider au plus tôt.';
         }
         if (Env::has('password')) {
             $user->password(Env::t('password'));
         }
         if (!Env::blank('hruid')) {
             $user->hruid(Env::t('hruid'));
         }
         $user->nickname(Env::t('nickname'));
         $user->lastname(Env::t('lastname'));
         $user->firstname(Env::t('firstname'));
         $user->birthdate(new FrankizDateTime(Env::t('birthdate')));
         $user->gender(Env::t('gender') == 'man' ? User::GENDER_MALE : User::GENDER_FEMALE);
         $user->email(Env::t('bestalias'));
         $user->cellphone(new Phone(Env::t('cellphone')));
         $user->skin(Env::t('skin'));
         $user->email_format(Env::t('format') == 'text' ? User::FORMAT_TEXT : User::FORMAT_HTML);
         $user->comment(Env::t('comment'));
         if ($add) {
             //Let's add common minimodules if requested (we copy them from anonymous.internal (uid 0) one's)
             if (Env::has('addCommonMinimodules')) {
                 $user->select(UserSelect::minimodules());
                 $user->copyMinimodulesFromUser(0);
             }
             pl_redirect('profile/admin/account/' . $user->hruid() . '/added');
         }
     }
     if (!empty($err)) {
         $page->assign('err', $err);
     }
     if (!empty($msg)) {
         $page->assign('msg', $msg);
     }
     $page->assign('formations', XDB::query("SELECT formation_id, label FROM formations")->fetchAllAssoc());
     $gfun = new GroupFilter(new PFC_And(new GFC_Namespace('nationality'), new GFC_User($user)));
     $page->assign('user_nationalities', $gfun->get()->select(GroupSelect::base())->toArray());
     $gfn = new GroupFilter(new GFC_Namespace('nationality'));
     $page->assign('nationalities', $gfn->get()->select(GroupSelect::base())->toArray());
     $gfus = new GroupFilter(new PFC_And(new GFC_Namespace('sport'), new GFC_User($user)));
     $page->assign('user_sports', $gfus->get()->select(GroupSelect::base())->toArray());
     $gfs = new GroupFilter(new GFC_Namespace('sport'));
     $page->assign('sports', $gfs->get()->select(GroupSelect::base())->toArray());
     $page->assign('userEdit', $user);
     $page->addCssLink('profile.css');
     $page->assign('add', $add);
     $page->assign('title', "Changement du profil : " . $user->fullName());
     if ($add) {
         $page->assign('title', "Création d'un utilisateur");
     }
     $page->assign('perms', array('admin'));
     $page->changeTpl('profile/admin_account.tpl');
 }
Example #16
0
 function handler_qdj($page)
 {
     $question = Env::t('quest');
     $answer1 = Env::t('ans1');
     $answer2 = Env::t('ans2');
     if (Env::has('send')) {
         if ($question == '' || $answer1 == '' || $answer2 == '') {
             $page->assign('msg', 'Il manque des informations.');
         } else {
             $qv = new QDJValidate($question, $answer1, $answer2);
             $v = new Validate(array('writer' => S::user(), 'group' => Group::from('qdj'), 'item' => $qv, 'type' => 'qdj'));
             $v->insert();
             $page->assign('envoye', true);
         }
     }
     $page->addCssLink('validate.css');
     $page->assign('title', 'Proposition d\'une qdj');
     $page->changeTpl('validate/prop.qdj.tpl');
 }
Example #17
0
 function handler_images($page)
 {
     $temp = Group::from('temp');
     $temp->select(GroupSelect::castes());
     $everybody_temp = $temp->caste(Rights::everybody());
     $if = new ImageFilter(new IFC_Caste($everybody_temp), new IFO_Created());
     $images = $if->get(new PlLimit(50))->select(FrankizImageSelect::base());
     $page->assign('title', 'Images du groupe temporaire');
     $page->assign('images', $images);
     $page->addCssLink('admin.css');
     $page->changeTpl('admin/images.tpl');
 }
Example #18
0
 public function commit()
 {
     $mail = new FrankizMailer();
     $sub = $this->type_mail == 'promo' ? 'promo' : $this->formation->label();
     $mail->subject('[Mail ' . $sub . '] ' . $this->subject);
     if ($this->origin) {
         global $globals;
         $mail->setFrom($this->origin->name() . '@' . $globals->mails->group_suffix, 'Frankiz - ' . $this->origin->label() . '');
     } else {
         $mail->setFrom($this->writer->bestEmail(), $this->writer->fullName());
     }
     if ($this->type_mail == 'promo' && !$this->targets) {
         $uf = new UserFilter(new PFC_AND(new UFC_Group($this->formation), new UFC_Group(Group::from('on_platal'))));
     } else {
         if ($this->type_mail == 'promo') {
             $uf = new UserFilter(new PFC_AND(new UFC_Group($this->formation), new UFC_Caste($this->targets), new UFC_Group(Group::from('on_platal'))));
         } else {
             $uf = new UserFilter(new PFC_AND(new UFC_Caste($this->targets->first()), new UFC_Group(Group::from('on_platal'))));
         }
     }
     if (!$this->nowiki) {
         $mail->body(MiniWiki::wikiToHTML($this->body, false));
     } else {
         $mail->body(MiniWiki::wikiToText($this->body, false, 0, 80));
     }
     $mail->ToUserFilter($uf);
     $mail->sendLater(!$this->nowiki);
     return true;
 }
Example #19
0
 public static function login()
 {
     $cb = function ($users) {
         $web = Group::from('webmasters');
         foreach ($users as $u) {
             if ($u->hasRights($web, Rights::member())) {
                 $u->perms()->addFlag('web');
             }
         }
     };
     return new UserSelect(array_merge(self::$natives, array('rooms', 'minimodules', 'castes', 'poly', 'comments', 'defaultfilters', 'studies', 'cuvisibility')), array('castes' => CasteSelect::group(), 'defaultfilters' => GroupSelect::base()), $cb);
 }
Example #20
0
    $i->image($upload, false);
    $g->image($i);
}
// Update formations
$formations = Formation::selectAll(FormationSelect::base());
foreach ($formations as $form) {
    // Update group
    $f = new UserFilter(new UFC_Study(new Formation($form->id())));
    $g = update_group('formation_' . $form->abbrev(), $form->label(), Group::NS_STUDY, $f);
    $g->description($form->description());
    // Admin caste
    if ($form->abbrev() == 'x') {
        $c = $g->caste(Rights::admin());
        $c->select(CasteSelect::base());
        if (!$c->userfilter()) {
            $uf_kes = new UserFilter(new UFC_Group(Group::from('kes'), Rights::admin()));
            $c->userfilter($uf_kes);
        }
    }
}
// Update promotions
$iter = XDB::iterRow('SELECT promo FROM studies GROUP BY promo ORDER BY promo');
while (list($promo) = $iter->next()) {
    $f = new UserFilter(new UFC_Promo($promo, '='));
    $g = update_group('promo_' . $promo, $promo, Group::NS_PROMO, $f);
    create_promo_image($g, $promo);
}
// Update promotions by formation
$iter = XDB::iterRow('SELECT  s.promo, s.formation_id, f.abbrev, f.label
                        FROM  studies AS s
                   LEFT JOIN  formations AS f ON (f.formation_id = s.formation_id)
Example #21
0
 public static function hasRights($user)
 {
     return $user->hasRights(Group::from('licenses'), Rights::restricted());
 }