本文整理汇总了PHP中Rights::logic方法的典型用法代码示例。如果您正苦于以下问题:PHP Rights::logic方法的具体用法?PHP Rights::logic怎么用?PHP Rights::logic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rights
的用法示例。
在下文中一共展示了Rights::logic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: handler_group_ajax_users
function handler_group_ajax_users($page)
{
$group = Json::i('gid');
$limit = 25;
$group = Group::fromId($group);
$users = false;
if ($group) {
$users = array();
$group->select(GroupSelect::castes());
$order = new UFO_Name(UFO_Name::LASTNAME);
$filters = new PFC_True();
if (strlen(Json::t('promo')) > 0) {
$filters = new UFC_Group(explode(';', Json::v('promo')));
}
$uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::admin())), $filters), $order);
$admins = $uf->get(new PlLimit($limit, (Json::i('admin_page', 1) - 1) * $limit));
$admins_total = $uf->getTotalCount();
$uf = new UserFilter(new PFC_And(new UFC_Caste(array($group->caste(Rights::member()), $group->caste(Rights::logic()))), $filters), $order);
$members = $uf->get(new PlLimit($limit, (Json::i('member_page', 1) - 1) * $limit));
$members_total = $uf->getTotalCount();
$uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::friend())), $filters), $order);
$friends = $uf->get(new PlLimit($limit, (Json::i('friend_page', 1) - 1) * $limit));
$friends_total = $uf->getTotalCount();
$all = new Collection('User');
$all->safeMerge(array($admins, $members, $friends));
$all->select(UserSelect::base());
$admins_export = $admins->export(User::EXPORT_MICRO, true);
$members_export = $members->export(User::EXPORT_MICRO, true);
$friends_export = $friends->export(User::EXPORT_MICRO, true);
if ($all->count() > 0) {
$iter = XDB::iterRow('SELECT uid, comment
FROM users_comments
WHERE gid = {?} AND uid IN {?}', $group->id(), $all->ids());
while (list($uid, $comment) = $iter->next()) {
if ($admins_export[$uid]) {
$admins_export[$uid]['comments'] = $comment;
}
if ($members_export[$uid]) {
$members_export[$uid]['comments'] = $comment;
}
if ($friends_export[$uid]) {
$friends_export[$uid]['comments'] = $comment;
}
}
}
$users['admin'] = array('total' => $admins_total, 'users' => $admins_export);
$users['member'] = array('total' => $members_total, 'users' => $members_export);
$users['friend'] = array('total' => $friends_total, 'users' => $friends_export);
}
$page->jsonAssign('limit', $limit);
$page->jsonAssign('users', $users);
return PL_JSON;
}