本文整理汇总了PHP中Rights::restricted方法的典型用法代码示例。如果您正苦于以下问题:PHP Rights::restricted方法的具体用法?PHP Rights::restricted怎么用?PHP Rights::restricted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rights
的用法示例。
在下文中一共展示了Rights::restricted方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_origin_picker
function smarty_function_origin_picker($params, &$smarty)
{
$gf = new GroupFilter(new PFC_And(new PFC_Not(new GFC_Namespace(Group::NS_USER)), new GFC_User(S::user(), Rights::admin())), new GFO_Score());
$gs = $gf->get();
if ($params['not_only_admin']) {
$gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::restricted())), new GFO_Score());
$gso = $gfo->get()->diff($gs);
$temp = new Collection();
$temp->merge($gs)->merge($gso);
$temp->select(GroupSelect::base());
$smarty->assign('not_admin', $gso);
} else {
$gs = $gf->get()->select(GroupSelect::base());
}
$smarty->assign($params['out'], $gs);
}
示例2: 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);
}
示例3: buildCondition
public function buildCondition(PlFilter $f)
{
return XDB::format('c.rights IN ({?}, {?})', (string) Rights::everybody(), (string) Rights::restricted());
}
示例4: 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 {
示例5: insert
public function insert($id = null)
{
if ($id == null) {
XDB::execute('INSERT INTO account SET perms = "user"');
$this->id = XDB::insertId();
} else {
XDB::execute('INSERT INTO account SET uid = {?}, perms= "user"', $id);
$this->id = $id;
}
$group = new Group();
$group->insert(null, 'user');
$group->ns(Group::NS_USER);
$group->name('user_' . $this->id());
$group->leavable(false);
$group->visible(false);
$group->label('Groupe personnel de ' . $this->fullName());
XDB::execute('UPDATE account SET `group` = {?} WHERE uid = {?}', $group->id(), $this->id());
$group->caste(Rights::admin())->addUser($this);
$group->caste(Rights::restricted())->addUser($this);
$this->group = $group;
}
示例6: 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);
}
}
示例7: __construct
public function __construct($gs, Rights $rights = null)
{
if ($gs instanceof Collection) {
$this->gids = $gs->ids();
} else {
$this->gids = Group::toIds(unflatten($gs));
}
$this->rights = empty($rights) ? Rights::restricted() : $rights;
self::$instances[] = $this;
}
示例8: handler_mail
function handler_mail($page)
{
$subject = Env::t('subject', '');
$body = Env::t('mail_body', '');
$no_wiki = Env::has('no_wiki');
// Retrieve the years on_platal of each formation
$formations = Formation::selectAll(FormationSelect::on_platal());
if (Env::has('send')) {
try {
$required_fields = array('subject' => 'Il faut donner un sujet à ton mail', 'mail_body' => 'Tu ne veux pas envoyer de mail vide à tous. Si ?');
foreach ($required_fields as $field => $msg) {
if (Env::v($field, '') == '') {
throw new Exception($msg);
}
}
if (Env::t('origin_mail_proposal') == 'false') {
$origin = false;
} else {
$origin = new Group(Env::i('origin_mail_proposal'));
}
if ($origin !== false && !S::user()->hasRights($origin, Rights::admin())) {
throw new Exception("Invalid credentials for origin Group");
}
if (Env::t('type_mail_proposal') == 'group') {
// Mail to a group
list($temp, $target_group) = self::target_picker_to_caste_group('mail');
$target = new Collection('Caste');
$target->add($temp);
$target_group->select(GroupSelect::validate());
$nv = new MailValidate(array('writer' => S::user(), 'type_mail' => Env::t('type_mail_proposal'), 'origin' => $origin, 'targets' => $target, 'subject' => $subject, 'body' => $body, 'nowiki' => $no_wiki, 'formation' => $target_group));
$el = new Validate(array('item' => $nv, 'group' => $target_group, 'writer' => S::user(), 'type' => 'mail'));
$el->insert();
} elseif (Env::t('type_mail_proposal') == 'promo') {
// Target group is a Collection of formation groups, which validate requests
$target_group = new Collection('Group');
// Group promos by formation
$promos = unflatten(Env::v('promos'));
$promosByFormation = array();
foreach ($promos as $formation_promo) {
$formation_promo = trim($formation_promo);
if (!$formation_promo) {
continue;
}
if (!preg_match('/^([0-9]+)_([0-9]+)$/', $formation_promo, $matches)) {
throw new Exception("Oops, mauvais format de destinataire.");
}
$formid = (int) $matches[1];
$promo = (int) $matches[2];
if (isset($promosByFormation[$formid])) {
$promosByFormation[$formid][] = $promo;
} else {
$promosByFormation[$formid] = array($promo);
}
}
if (empty($promosByFormation)) {
throw new Exception("Il faut indiquer au moins un destinataire.");
}
foreach ($promosByFormation as $formid => $promos) {
// Now, $promos are the list of promos of formation $formid
$form = $formations->get($formid);
// Study group are the people the mail is sent to, array of CasteFilterCondition
$cfc_study_groups = array();
foreach ($promos as $promo) {
if (!$form->hasPlatalYear($promo)) {
throw new Exception("Mauvaise promo " . $promo . " pour " . $form->label() . ".");
}
$cfc_study_groups[] = new CFC_Group($form->getGroupForPromo($promo), Rights::restricted());
}
$target = new CasteFilter(new PFC_Or($cfc_study_groups));
$target = $target->get();
$target->select(CasteSelect::validate());
// $target_group is the group which validates this email
$target_group = $form->getGroup();
$target_group->select(GroupSelect::validate());
$nv = new MailValidate(array('writer' => S::user(), 'type_mail' => Env::t('type_mail_proposal'), 'origin' => $origin, 'targets' => $target, 'subject' => $subject, 'body' => $body, 'nowiki' => $no_wiki, 'formation' => $target_group));
$el = new Validate(array('item' => $nv, 'group' => $target_group, 'writer' => S::user(), 'type' => 'mail'));
$el->insert();
}
}
$page->assign('envoye', true);
} catch (Exception $e) {
$page->trigError($e->getMessage());
}
}
$page->assign('subject', $subject);
$page->assign('body', $body);
$page->assign('nowiki', $no_wiki);
$page->assign('formations', $formations);
$page->assign('title', 'Envoi des mails');
$page->addCssLink('validate.css');
$page->changeTpl('validate/prop.mail.tpl');
}
示例9: hasRights
public static function hasRights($user)
{
return $user->hasRights(Group::from('licenses'), Rights::restricted());
}