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


PHP eZRole类代码示例

本文整理汇总了PHP中eZRole的典型用法代码示例。如果您正苦于以下问题:PHP eZRole类的具体用法?PHP eZRole怎么用?PHP eZRole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了eZRole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

    function execute( $xml )
    {
        include_once( 'kernel/classes/ezrole.php' );
        $assignmentList = $xml->getElementsByTagName( 'RoleAssignment' );
        foreach ( $assignmentList as $roleAssignment )
        {
            $roleID            = $this->getReferenceID( $roleAssignment->getAttribute( 'roleID' ) );
            $assignTo          = $this->getReferenceID( $roleAssignment->getAttribute( 'assignTo' ) );
            $sectionLimitation = $this->getReferenceID( $roleAssignment->getAttribute( 'sectionLimitation' ) );
            $subtreeLimitation = $this->getReferenceID( $roleAssignment->getAttribute( 'subtreeLimitation' ) );

            $role = eZRole::fetch( $roleID );
            if ( !$role )
            {
                $this->writeMessage( "\tRole $roleID does not exist.", 'warning' );
                continue;
            }

            $referenceID = $this->getReferenceID( $assignTo );
            if ( !$referenceID )
            {
                $this->writeMessage( "\tInvalid object $referenceID does not exist.", 'warning' );
                continue;
            }

            if ( $sectionLimitation )
            {
                $section = $this->getReferenceID( $sectionLimitation );
                if ( $section )
                {
                    $role->assignToUser( $referenceID, 'section', $section );
                    $this->writeMessage( "\tAssigned role $roleID: $referenceID to $section", 'notice' );
                }
                else
                {
                    $this->writeMessage( "\tInvalid section $sectionLimitation does not exist.", 'warning' );
                    continue;
                }
            }
            elseif ( $subtreeLimitation )
            {
                $subtree = $this->getReferenceID( $subtreeLimitation );
                if ( $subtree )
                {
                    $role->assignToUser( $referenceID, 'subtree', $subtree );
                    $this->writeMessage( "\tAssigned role $roleID: $referenceID to $subtree", 'notice' );
                }
                else
                {
                    $this->writeMessage( "\tInvalid section $subtreeLimitation does not exist.", 'warning' );
                    continue;
                }
            }
            else
            {
                $role->assignToUser( $referenceID );
                    $this->writeMessage( "\tAssigned role $roleID: $referenceID", 'notice' );
            }
        }
      }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:60,代码来源:ezassignroles.php

示例2: getRoles

 /**
  * We do our best to sort in a way that makes matching easy when ids are different
  * @return array
  *
  * @todo finish obj to array conversion ($users) to make it easier to have non-html output
  * @todo sorting of same-policies-w.-different-limitations in a role is far from perfect despite our efforts
  */
 public static function getRoles()
 {
     $roles = eZRole::fetchByOffset(0, false, true, true);
     // scrap original array, create a new one where policies are sorted. Can you follow the logic?
     foreach ($roles as $role) {
         $policies = array();
         $users = array();
         foreach ($role->attribute('policies') as $policy) {
             $limitations = array();
             foreach ($policy->attribute('limitations') as $limitation) {
                 $values = $limitation->attribute('values_as_array_with_names');
                 // We only use the "name" in each limitation.
                 // This might cause fake-positives when comparing, f.e. different node-limitations on different folders all having the same name
                 // But comparing what is inside the limitation is hard (eg node-ids, which we do not want to compare)
                 $valNames = array();
                 foreach ($values as $item) {
                     $valNames[] = $item["Name"];
                 }
                 $limName = $limitation->attribute('identifier') . '_' . md5(serialize($valNames));
                 $limitations[$limName] = array('identifier' => $limitation->attribute('identifier'), 'values_as_array_with_names' => $values);
             }
             ksort($limitations);
             $policy = array('module_name' => $policy->attribute('module_name'), 'function_name' => $policy->attribute('function_name'), 'limitations' => array_values($limitations));
             $policies[$policy['module_name'] . '_' . $policy['function_name'] . '_' . md5(serialize(array_keys($limitations)))] = $policy;
         }
         ksort($policies);
         foreach ($role->fetchUserByRole() as $user) {
             $users[$user['user_object']->attribute('name')] = $user;
         }
         ksort($users);
         $roles[$role->attribute('name')] = array('name' => $role->attribute('name'), 'policies' => $policies, 'user_array' => $users);
     }
     ksort($roles);
     return array_values($roles);
 }
开发者ID:gggeek,项目名称:ggsysinfo,代码行数:42,代码来源:ezpoliciesreport.php

示例3: execute

 function execute($xml)
 {
     $roleList = $xml->getElementsByTagName('Role');
     $refArray = array();
     foreach ($roleList as $roleNode) {
         $roleName = $roleNode->getAttribute('name');
         $createRoleIfNotExists = $roleNode->getAttribute('createRole');
         $replacePolicies = $roleNode->getAttribute('replacePolicies');
         $referenceID = $roleNode->getAttribute('referenceID');
         $this->writeMessage("\tRole '{$roleName}' will be created.", 'notice');
         $rolePolicyList = $roleNode->getElementsByTagName('Policy');
         $policyList = array();
         foreach ($rolePolicyList as $policyNode) {
             $policyModule = $policyNode->getAttribute('module');
             $policyFunction = $policyNode->getAttribute('function');
             $policyLimitationList = array();
             $policyLimitationNodeList = $policyNode->getElementsByTagName('Limitations')->item(0);
             if ($policyLimitationNodeList) {
                 $limitations = $policyLimitationNodeList->childNodes;
                 foreach ($limitations as $limitation) {
                     if ($limitation->nodeType == XML_ELEMENT_NODE) {
                         if (!array_key_exists($limitation->nodeName, $policyLimitationList)) {
                             $policyLimitationList[$limitation->nodeName] = array();
                         }
                         $policyLimitationList[$limitation->nodeName][] = $this->getLimitationValue($limitation->nodeName, $limitation->textContent);
                     }
                 }
             }
             $policyList[] = array('module' => $policyModule, 'function' => $policyFunction, 'limitation' => $policyLimitationList);
         }
         $role = eZRole::fetchByName($roleName);
         if (is_object($role) || $createRoleIfNotExists == "true") {
             if (!is_object($role)) {
                 $role = eZRole::create($roleName);
                 $role->store();
             }
             $roleID = $role->attribute('id');
             if (count($policyList) > 0) {
                 if ($replacePolicies == "true") {
                     $role->removePolicies();
                     $role->store();
                 }
                 foreach ($policyList as $policyDefinition) {
                     if (isset($policyDefinition['limitation'])) {
                         $role->appendPolicy($policyDefinition['module'], $policyDefinition['function'], $policyDefinition['limitation']);
                     } else {
                         $role->appendPolicy($policyDefinition['module'], $policyDefinition['function']);
                     }
                 }
             }
             if ($referenceID) {
                 $refArray[$referenceID] = $role->attribute('id');
             }
         } else {
             $this->writeMessage("\tRole '{$roleName}' doesn't exist.", 'notice');
         }
     }
     $this->addReference($refArray);
 }
开发者ID:heliopsis,项目名称:ezxmlinstaller,代码行数:59,代码来源:ezcreaterole.php

示例4: testFetchIDListByUser

 /**
  * Unit test for eZRole::fetchIDListByUser()
  **/
 public function testFetchIDListByUser()
 {
     // fetch roles ID for anonymous group
     $roles = eZRole::fetchIDListByUser(array(self::$anonymousGroupID));
     $this->assertType('array', $roles, "The method should have returned an array");
     $this->assertEquals(1, count($roles), "The array should contain one item");
     $this->assertEquals(1, $roles[0], "The returned role ID should be 1 (anonymous role)");
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:11,代码来源:ezrole_test.php

示例5: testPolicyList

 /**
  * Test for eZRole::policyList()
  * Checks that policyList doesn't return temporary policies
  */
 public function testPolicyList()
 {
     $role = array_shift(eZRole::fetchByUser(array(self::$anonymousUserID), true));
     $policy = array_shift($role->policyList());
     // create a temporary copy of one of the role's policies
     $policy->createTemporaryCopy();
     // check that the role's policies all are final (not temporary)
     foreach ($role->policyList() as $policy) {
         $this->assertType('eZPolicy', $policy);
         $this->assertEquals(0, $policy->attribute('original_id'));
     }
 }
开发者ID:rmiguel,项目名称:ezpublish,代码行数:16,代码来源:ezrole_test.php

示例6: __construct

 public function __construct()
 {
     $this->eZDataType(self::DATA_TYPE_STRING, ezpI18n::tr('extension/nxc_captcha', 'NXC Captcha'), array('serialize_supported' => true, 'object_serialize_map' => array('data_text' => 'captcha_code', 'data_int' => 'checked')));
     if (count(self::$definition['type']['possible_values']) === 0) {
         self::$definition['type']['possible_values'] = array(self::TYPE_ALPHABETIC => ezpI18n::tr('extension/nxc_captcha', 'Alphabetic'), self::TYPE_NUMERIC => ezpI18n::tr('extension/nxc_captcha', 'Numeric'), self::TYPE_ALPHANUMERIC => ezpI18n::tr('extension/nxc_captcha', 'Alphanumeric'));
     }
     if (count(self::$definition['skip_role_ids']['possible_values']) === 0) {
         $roles = eZRole::fetchList();
         foreach ($roles as $role) {
             self::$definition['skip_role_ids']['possible_values'][$role->attribute('id')] = $role->attribute('name');
         }
     }
 }
开发者ID:philandteds,项目名称:nxc_captcha,代码行数:13,代码来源:nxccaptchatype.php

示例7: foreach

}
// Redirect to content node browse in the user tree
// Assign the role for a user or group
if ($Module->isCurrentAction('AssignRole')) {
    $selectedObjectIDArray = eZContentBrowse::result('AssignRole');
    foreach ($selectedObjectIDArray as $objectID) {
        $role->assignToUser($objectID);
    }
    // Clear role caches.
    eZRole::expireCache();
    // Clear all content cache.
    eZContentCacheManager::clearAllContentCache();
}
if ($http->hasPostVariable('NewButton')) {
    $role = eZRole::createNew();
    return $Module->redirectToView('edit', array($role->attribute('id')));
}
$viewParameters = array('offset' => $offset);
$tpl = eZTemplate::factory();
$roles = eZRole::fetchByOffset($offset, $limit, $asObject = true, $ignoreTemp = true);
$roleCount = eZRole::roleCount();
$tempRoles = eZRole::fetchList($temporaryVersions = true);
$tpl->setVariable('roles', $roles);
$tpl->setVariable('role_count', $roleCount);
$tpl->setVariable('temp_roles', $tempRoles);
$tpl->setVariable('module', $Module);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('limit', $limit);
$Result = array();
$Result['content'] = $tpl->fetch('design:role/list.tpl');
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/role', 'Role list')));
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:list.php

示例8: array

$Module = $Params['Module'];
$policyID = $Params['PolicyID'];

$policy = eZPolicy::fetchTemporaryCopy( $policyID );
$policyID = $policy->attribute( 'id' );
$originalPolicyID = $policy->attribute( 'original_id' );

if( $policy === null )
{
    return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );
}

$currentModule = $policy->attribute( 'module_name' );
$currentFunction = $policy->attribute( 'function_name' );
$roleID = $policy->attribute( 'role_id' );
$role = eZRole::fetch( $roleID );
$roleName = $role->attribute( 'name' );
$limitationValueList = $policy->limitationList();
$nodeList = array();
$subtreeList = array();

if ( $currentModule == '*' )
{
    $functions = array();
}
else
{
    $mod = eZModule::exists( $currentModule );
    $functions = $mod->attribute( 'available_functions' );
}
$currentFunctionLimitations = array();
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:31,代码来源:policyedit.php

示例9: array

    $originalRoleID = $originalRole->attribute('id');
    // Who changes which role(s) should be logged.
    if ($http->hasSessionVariable('RoleWasChanged') and $http->sessionVariable('RoleWasChanged') === true) {
        eZAudit::writeAudit('role-change', array('Role ID' => $originalRoleID, 'Role name' => $originalRoleName, 'Comment' => 'Changed the current role: kernel/role/edit.php'));
        $http->removeSessionVariable('RoleWasChanged');
    }
    $originalRole->revertFromTemporaryVersion();
    eZContentCacheManager::clearAllContentCache();
    $Module->redirectTo($Module->functionURI('view') . '/' . $originalRoleID . '/');
    /* Clean up policy cache */
    eZUser::cleanupCache();
}
if ($http->hasPostVariable('Discard')) {
    $http->removeSessionVariable('RoleWasChanged');
    $role = eZRole::fetch($roleID);
    $originalRole = eZRole::fetch($role->attribute('version'));
    $role->removeThis();
    if ($originalRole != null && $originalRole->attribute('is_new') == 1) {
        $originalRole->remove();
    }
    $Module->redirectTo($Module->functionURI('list') . '/');
}
if ($http->hasPostVariable('ChangeRoleName')) {
    $role->setAttribute('name', $http->postVariable('NewName'));
    // Set flag for audit. If true audit will be processed
    $http->setSessionVariable('RoleWasChanged', true);
}
if ($http->hasPostVariable('AddModule')) {
    if ($http->hasPostVariable('Modules')) {
        $currentModule = $http->postVariable('Modules');
    } else {
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:31,代码来源:edit.php

示例10: role

 function role()
 {
     if ($this->ID) {
         return eZPersistentObject::fetchObject(eZRole::definition(), null, array('id' => $this->RoleID), true);
     }
     return false;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:7,代码来源:ezpolicy.php

示例11: move

 function move($newParentNodeID, $nodeID = 0)
 {
     if ($nodeID == 0) {
         $node = $this;
         $nodeID = $node->attribute('node_id');
     } else {
         $node = eZContentObjectTreeNode::fetch($nodeID);
     }
     $oldPath = $node->attribute('path_string');
     $oldParentNodeID = $node->attribute('parent_node_id');
     $newParentNodeID = (int) $newParentNodeID;
     if ($oldParentNodeID != $newParentNodeID) {
         $node->updateAndStoreModified();
         // Who moves which content should be logged.
         $object = $node->object();
         eZAudit::writeAudit('content-move', array('Node ID' => $node->attribute('node_id'), 'Old parent node ID' => $oldParentNodeID, 'New parent node ID' => $newParentNodeID, 'Object ID' => $object->attribute('id'), 'Content Name' => $object->attribute('name'), 'Comment' => 'Moved the node to the given node: eZContentObjectTreeNode::move()'));
         $newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID);
         $newParentPath = $newParentNode->attribute('path_string');
         $newParentDepth = $newParentNode->attribute('depth');
         $newPath = $newParentPath . $nodeID;
         $oldDepth = $node->attribute('depth');
         $oldPathLength = strlen($oldPath);
         $moveQuery = "UPDATE\n                                 ezcontentobject_tree\n                          SET\n                                 parent_node_id = {$newParentNodeID}\n                          WHERE\n                                 node_id = {$nodeID}";
         $db = eZDB::instance();
         $subStringString = $db->subString('path_string', $oldPathLength);
         $newPathString = $db->concatString(array("'{$newPath}'", $subStringString));
         $moveQuery1 = "UPDATE\n                                 ezcontentobject_tree\n                           SET\n                                 path_identification_string = " . $db->concatString(array("'" . $db->escapeString($newParentNode->PathIdentificationString) . "'", $db->subString("path_identification_string", mb_strlen($node->PathIdentificationString) + 1))) . ",\n                                 path_string = {$newPathString},\n                                 depth = depth + {$newParentDepth} - {$oldDepth} + 1\n                           WHERE\n                                 path_string LIKE '{$oldPath}%'";
         $db->begin();
         $db->query($moveQuery);
         $db->query($moveQuery1);
         /// role system clean up
         // Clean up policies and limitations
         $expireRoleCache = false;
         $limitationsToFix = eZPolicyLimitation::findByType('SubTree', $node->attribute('path_string'), false);
         if (count($limitationsToFix) > 0) {
             $limitationIDString = $db->generateSQLINStatement($limitationsToFix, 'limitation_id');
             $subStringString = $db->subString('value', $oldPathLength);
             $newValue = $db->concatString(array("'{$newPath}'", $subStringString));
             $query = "UPDATE\n                                ezpolicy_limitation_value\n                          SET\n                                value = {$newValue}\n                          WHERE\n                                value LIKE '{$oldPath}%' AND {$limitationIDString}";
             $db->query($query);
             $expireRoleCache = true;
         }
         // clean up limitations on role assignment level
         $countRows = $db->arrayQuery("SELECT COUNT(*) AS row_count FROM ezuser_role WHERE limit_identifier='Subtree' AND limit_value LIKE '{$oldPath}%'");
         $assignmentsToFixCount = $countRows[0]['row_count'];
         if ($assignmentsToFixCount > 0) {
             $subStringString = $db->subString('limit_value', $oldPathLength);
             $newValue = $db->concatString(array("'{$newPath}'", $subStringString));
             $db->query("UPDATE\n                                ezuser_role\n                             SET\n                                limit_value = {$newValue}\n                             WHERE\n                                limit_identifier='Subtree' AND limit_value LIKE '{$oldPath}%'");
             $expireRoleCache = true;
         }
         if ($expireRoleCache) {
             eZRole::expireCache();
         }
         // Update "is_invisible" node attribute.
         $newNode = eZContentObjectTreeNode::fetch($nodeID);
         eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
         $db->commit();
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:60,代码来源:ezcontentobjecttreenode.php

示例12: fetchByOffset

 static function fetchByOffset($offset, $limit, $asObject = true, $ignoreTemp = false, $ignoreNew = true)
 {
     if ($ignoreTemp && $ignoreNew) {
         $igTemp = array('version' => '0', 'is_new' => '0');
     } elseif ($ignoreTemp) {
         $igTemp = array('version' => '0');
     } elseif ($ignoreNew) {
         $igTemp = array('is_new' => '0');
     } else {
         $igTemp = null;
     }
     return eZPersistentObject::fetchObjectList(eZRole::definition(), null, $igTemp, array('name' => 'ASC'), array('offset' => $offset, 'length' => $limit), $asObject);
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:13,代码来源:ezrole.php

示例13: roleIDList

 function roleIDList()
 {
     // If the user object is not the currently logged in user we cannot use the session cache
     $useCache = $this->ContentObjectID == eZSession::get('eZUserLoggedInID', self::anonymousId());
     if ($useCache) {
         $userCache = $this->getUserCache();
         return $userCache['roles'];
     }
     $groups = $this->attribute('groups');
     $groups[] = $this->attribute('contentobject_id');
     return eZRole::fetchIDListByUser($groups);
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:12,代码来源:ezuser.php

示例14: fetchRole

 function fetchRole($roleID)
 {
     $role = eZRole::fetch($roleID);
     return array('result' => $role);
 }
开发者ID:legende91,项目名称:ez,代码行数:5,代码来源:ezrolefunctioncollection.php

示例15: fetchUserRoles

 function fetchUserRoles($sectionID)
 {
     $userRoles = eZRole::fetchRolesByLimitation('section', $sectionID);
     return array('result' => $userRoles);
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:5,代码来源:ezsectionfunctioncollection.php


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