本文整理汇总了PHP中Permission::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::Load方法的具体用法?PHP Permission::Load怎么用?PHP Permission::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::Load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPermissions
function createPermissions($meta, $moduleId)
{
$permData = $meta->permissions;
if (empty($permData)) {
return;
}
foreach ($permData as $key => $val) {
if (!empty($val)) {
foreach ($val as $permissionString => $defaultValue) {
$permissionObj = new Permission();
$permissionObj->Load("user_level = ? and module_id = ? and permission = ?", array($key, $moduleId, $permissionString));
if (empty($permissionObj->id) && $permissionObj->module_id == $moduleId) {
} else {
$permissionObj = new Permission();
$permissionObj->user_level = $key;
$permissionObj->module_id = $moduleId;
$permissionObj->permission = $permissionString;
$permissionObj->value = $defaultValue;
$permissionObj->meta = '["value", {"label":"Value","type":"select","source":[["Yes","Yes"],["No","No"]]}]';
$permissionObj->Save();
}
}
}
}
}
示例2: protectPage
<?php
require_once "../../lib/init.php";
protectPage(9);
@($id = DB::Safe($_GET['id']));
// Verify...
if (!$id) {
fail("Could not delete permission; please specify a valid ID.");
}
// Load the permission and make sure it belongs in the ward
$p = Permission::Load($id);
if (!$p->InWard($MEMBER->WardID)) {
fail("That permission is not within your own ward...");
}
// Delete this permission.
$p->Delete(true);
Response::Send(200);
示例3: Permissions
public function Permissions($removeOverlap = false)
{
$permissions = array();
// Get permissions based on member ID...
// Be careful changing this because we append later!
$q = "SELECT ID FROM Permissions WHERE (ObjectID='{$this->ID}' AND ObjectType='Member') OR (";
// Now permissions based on callings for this member
$callings = $this->Callings();
foreach ($callings as $calling) {
$q .= "ObjectID=" . $calling->ID() . " OR ";
}
// Trim the trailing OR bit...
if (strrpos('(', $q) == strlen($q) - 1) {
$q = substr($q, 0, strlen($q) - 5);
} else {
$q = substr($q, 0, strlen($q) - 4);
}
if (count($callings) > 0) {
$q .= " AND ObjectType='Calling')";
}
// don't forget this
$r = DB::Run($q);
while ($row = mysql_fetch_array($r)) {
$per = Permission::Load($row['ID']);
// Prevent duplicates questions/overlap of permissions?
if ($removeOverlap) {
$found = false;
foreach ($permissions as $p) {
if ($p->QuestionID() == $per->QuestionID()) {
$found = true;
break;
}
}
if ($found) {
continue;
}
}
$permissions[] = $per;
}
return $permissions;
}