本文整理汇总了PHP中Rights::everybody方法的典型用法代码示例。如果您正苦于以下问题:PHP Rights::everybody方法的具体用法?PHP Rights::everybody怎么用?PHP Rights::everybody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rights
的用法示例。
在下文中一共展示了Rights::everybody方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: target_picker_to_caste_group
static function target_picker_to_caste_group($id)
{
$target_rights = Rights::restricted();
if (Env::has('target_everybody_' . $id)) {
$target_rights = Rights::everybody();
}
if (S::user()->group()->id() == Env::i('target_group_' . $id)) {
$target_rights = Rights::restricted();
}
$target_group = new Group(Env::i('target_group_' . $id));
$target_filter = new CasteFilter(new PFC_And(new CFC_Group($target_group), new CFC_Rights($target_rights)));
return array($target_filter->get(true), $target_group);
}
示例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);
}
示例3: create_promo_image
/**
* Create an image for a promotion, for a group, if needed
*/
function create_promo_image(Group $g, $promo)
{
$g->select(GroupSelect::base());
if ($g->image()) {
return;
}
if ($promo % 2 == 0) {
$upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/rouje.png');
$label = 'Chic à la rouje';
} else {
$upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/jone.png');
$label = 'Chic à la jone';
}
$i = new FrankizImage();
$i->insert();
$i->caste($g->caste(Rights::everybody()));
$i->label($label);
$i->image($upload, false);
$g->image($i);
}
示例4: smarty_function_target_picker
function smarty_function_target_picker($params, &$smarty)
{
// Get user groups
$everybody_groups = S::user()->castes(Rights::everybody())->groups();
// Get Frankiz special groups
$fkz = new Collection('Group');
$fkz->add(array('everybody', 'public'));
$fkz->select(new GroupSelect(array('description')));
// BDE, study and promo groups
$study_groups = $everybody_groups->filter('ns', Group::NS_BDE);
$study_groups->merge($everybody_groups->filter('ns', Group::NS_PROMO));
$study_groups->merge($everybody_groups->filter('ns', Group::NS_STUDY));
// Get all groups user is admin, without the user one
$gs = S::user()->castes(Rights::admin())->groups();
$gs->diff($fkz);
$gs->filter(function ($g) {
return $g->ns() != Group::NS_USER;
});
if ($params['even_only_friend']) {
$gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::everybody())), new GFO_Score());
$gso = $gfo->get()->diff($gs)->diff($fkz);
$temp = new Collection();
$temp->merge($gs)->merge($gso);
$temp->select(GroupSelect::base());
$smarty->assign('only_friend', $gso);
$temp = new Collection();
$temp->merge($gs)->merge($fkz)->merge($gso);
$temp->select(GroupSelect::base());
} else {
$temp = new Collection();
$temp->merge($gs)->merge($fkz);
$temp->select(GroupSelect::base());
}
$smarty->assign($params['user_groups'], $gs);
$smarty->assign($params['fkz_groups'], $fkz);
$smarty->assign($params['study_groups'], $study_groups);
$smarty->assign($params['own_group'], S::user()->group());
}
示例5: buildCondition
public function buildCondition(PlFilter $f)
{
$c = $f->addCasteFilter();
$cu = $f->addUserFilter();
return XDB::format("{$c}.rights = {?} OR ({$c}.rights = {?} AND {$cu}.uid IN {?})", (string) Rights::everybody(), (string) Rights::restricted(), $this->uids);
}
示例6: handler_images
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');
}
示例7: str_replace
$str = str_replace("'", "'", $str);
return $str;
}
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']));
示例8: buildCondition
public function buildCondition(PlFilter $f)
{
return XDB::format('c.rights IN ({?}, {?})', (string) Rights::everybody(), (string) Rights::restricted());
}
示例9: canSee
/**
* Returns true if the user is allowed to see the content of the caste
* taking into account the level of AUTH
* @param $caste the rights of the caste must be already fetched
*/
public function canSee(Caste $caste)
{
// If we are inside the platal & the caste is of type everybody
if (S::i('auth') >= AUTH_INTERNAL && $caste->rights()->isMe(Rights::everybody())) {
return true;
}
// If we are here, it means we are outside or that the caste is restricted
// In either case, in order to see the content, the user must be part of the caste
if (S::user()->castes()->get($caste) != false) {
return true;
}
return false;
}
示例10: 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 *
***************************************************************************/
/*
* This script updates the score field of the groups.
* SCORE = | EVERYBODY |
*/
require_once dirname(__FILE__) . '/../connect.db.inc.php';
XDB::execute('UPDATE groups AS g
SET g.score = (SELECT COUNT(cu.uid)
FROM castes_users AS cu
INNER JOIN castes AS c ON c.cid = cu.cid
WHERE c.`group` = g.gid AND c.rights = {?})', (string) Rights::everybody());
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
示例11: insert
public function insert($id = null, $type = 'all')
{
if ($id == null) {
$this->name = uniqid();
XDB::execute('INSERT INTO groups SET name = {?}', $this->name);
$this->id = XDB::insertId();
} else {
$this->name = 'g_' . $id;
XDB::execute('INSERT INTO groups SET gid = {?}, name= {?}', $id, $this->name);
$this->id = $id;
}
/*
* Create the castes
*/
if ($type == 'user') {
// A user group only needs an admin caste & a restricted caste.
$this->addCaste(Rights::admin());
$this->addCaste(Rights::restricted());
} else {
$admins = $this->addCaste(Rights::admin());
$members = $this->addCaste(Rights::member());
$logics = $this->addCaste(Rights::logic());
$friends = $this->addCaste(Rights::friend());
/*
* Create the 'restricted' caste
*/
$restricted = new UserFilter(new UFC_Caste(array($admins, $members, $logics)));
$this->addCaste(Rights::restricted())->userfilter($restricted);
/*
* Create the 'everybody' caste
* It's better not to refer to the restricted caste, as we don't know in what
* order the bubbling is going to happen
*/
$everybody = new UserFilter(new UFC_Caste(array($admins, $members, $logics, $friends)));
$this->addCaste(Rights::everybody())->userfilter($everybody);
}
}
示例12: 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());
}
示例13: handler_group_ajax_admin_users
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;
}
示例14: 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.';
//.........这里部分代码省略.........