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


PHP Permission::Load方法代码示例

本文整理汇总了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();
                }
            }
        }
    }
}
开发者ID:riazuddinahmed1,项目名称:icehrm-1,代码行数:25,代码来源:modules.php

示例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);
开发者ID:bluegate010,项目名称:ysaward,代码行数:17,代码来源:deletepermission.php

示例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;
 }
开发者ID:bluegate010,项目名称:ysaward,代码行数:41,代码来源:Member.php


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