当前位置: 首页>>代码示例>>PHP>>正文


PHP Group::from方法代码示例

本文整理汇总了PHP中Group::from方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::from方法的具体用法?PHP Group::from怎么用?PHP Group::from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group::from方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handler_ajax_modify

 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;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:30,代码来源:qdj.php

示例2: handler_upload

 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);
 }
开发者ID:netixx,项目名称:frankiz,代码行数:49,代码来源:images.php

示例3: sendmailadmin

 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);
 }
开发者ID:netixx,项目名称:frankiz,代码行数:15,代码来源:tolvalidate.php

示例4: handler_home

 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');
 }
开发者ID:netixx,项目名称:frankiz,代码行数:16,代码来源:frankiz.php

示例5: run

 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);
 }
开发者ID:netixx,项目名称:frankiz,代码行数:18,代码来源:birthday.php

示例6: dirname

<?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:
开发者ID:netixx,项目名称:frankiz,代码行数:31,代码来源:import.pa.php

示例7: handler_remote

 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) {
//.........这里部分代码省略.........
开发者ID:netixx,项目名称:frankiz,代码行数:101,代码来源:remote.php

示例8: dirname

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 {
开发者ID:netixx,项目名称:frankiz,代码行数:31,代码来源:check.groups.php

示例9: handler_links_admin

 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');
 }
开发者ID:netixx,项目名称:frankiz,代码行数:40,代码来源:links.php

示例10: dirname

 *  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);
}
开发者ID:netixx,项目名称:frankiz,代码行数:31,代码来源:skin.force.php

示例11: handler_tol_birthday

 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;
 }
开发者ID:netixx,项目名称:frankiz,代码行数:35,代码来源:tol.php

示例12: handler_licenses_final

 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);
         }
     }
 }
开发者ID:netixx,项目名称:frankiz,代码行数:30,代码来源:licenses.php

示例13: buildCondition

 public function buildCondition(PlFilter $f)
 {
     $g = Group::from('temp')->select(GroupSelect::castes());
     $temp = $g->caste(Rights::everybody());
     return XDB::format('i.caste = {?}', $temp->id());
 }
开发者ID:netixx,项目名称:frankiz,代码行数:6,代码来源:imagefilter.php

示例14: getGroupForPromo

 /**
  * 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));
 }
开发者ID:netixx,项目名称:frankiz,代码行数:9,代码来源:formation.php

示例15: handler_admin_account

 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.';
//.........这里部分代码省略.........
开发者ID:netixx,项目名称:frankiz,代码行数:101,代码来源:profile.php


注:本文中的Group::from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。