本文整理汇总了PHP中eZRole::fetchByName方法的典型用法代码示例。如果您正苦于以下问题:PHP eZRole::fetchByName方法的具体用法?PHP eZRole::fetchByName怎么用?PHP eZRole::fetchByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZRole
的用法示例。
在下文中一共展示了eZRole::fetchByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: initializePackage
//.........这里部分代码省略.........
if (!$siteINIStored) {
$siteINI = eZINI::create('site.ini');
// Set ReadOnlySettingsCheck to false: towards
// Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
$siteINI->setReadOnlySettingsCheck(false);
$siteINI->setVariables($siteINIChanges);
$siteINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
$siteINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
$siteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", true);
}
if (!$designINIStored) {
$designINI = eZINI::create('design.ini');
// Set ReadOnlySettingsCheck to false: towards
// Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
$designINI->setReadOnlySettingsCheck(false);
if ($siteCSS) {
$designINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
}
if ($classesCSS) {
$designINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
}
$designINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
}
eZDir::mkdir("design/" . $userDesignName);
eZDir::mkdir("design/" . $userDesignName . "/templates");
eZDir::mkdir("design/" . $userDesignName . "/stylesheets");
eZDir::mkdir("design/" . $userDesignName . "/images");
eZDir::mkdir("design/" . $userDesignName . "/override");
eZDir::mkdir("design/" . $userDesignName . "/override/templates");
if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_KEEP) {
return true;
}
// Try and remove user/login without limitation from the anonymous user
$anonRole = eZRole::fetchByName('Anonymous');
if (is_object($anonRole)) {
$anonPolicies = $anonRole->policyList();
foreach ($anonPolicies as $anonPolicy) {
if ($anonPolicy->attribute('module_name') == 'user' and $anonPolicy->attribute('function_name') == 'login') {
$anonPolicy->removeThis();
break;
}
}
}
// Setup all roles according to site chosen and addons
if (function_exists('eZSiteRoles')) {
$extraRoles = eZSiteRoles($parameters);
foreach ($extraRoles as $extraRole) {
if (!$extraRole) {
continue;
}
$extraRoleName = $extraRole['name'];
$role = eZRole::fetchByName($extraRoleName);
if (!is_object($role)) {
$role = eZRole::create($extraRoleName);
$role->store();
}
$roleID = $role->attribute('id');
if (isset($extraRole['policies'])) {
$extraPolicies = $extraRole['policies'];
foreach ($extraPolicies as $extraPolicy) {
if (isset($extraPolicy['limitation'])) {
$role->appendPolicy($extraPolicy['module'], $extraPolicy['function'], $extraPolicy['limitation']);
} else {
$role->appendPolicy($extraPolicy['module'], $extraPolicy['function']);
}
}
示例3: array
$userRootNodeID = $contentIni->variable('NodeSettings', 'UserRootNode');
$siteIni = eZINI::instance('site.ini');
$anonymousUserID = $siteIni->variable('UserSettings', 'AnonymousUserID');
$anonymousUser = eZUser::fetch($anonymousUserID);
$anonymousUsers = array();
if (is_object($anonymousUser)) {
$anonymousUsers = $anonymousUser->groups();
$anonymousUsers[] = $anonymousUserID;
}
$topUserNodes = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1), $userRootNodeID);
if (count($topUserNodes) == 0) {
$cli->warning("Unable to retrieve the user root node. Please make sure\n" . "you log in to the system with the administrator's user\n" . "acount by using the -l and -p command line options.");
$script->shutdown(1);
}
$roleName = 'Tipafriend Role';
$role = eZRole::fetchByName($roleName);
if (is_object($role)) {
$cli->warning("The 'Tipafriend Role' already exists in the system. This means that\n" . "the script was already run before or the same role was added manually.\n" . "The role will not be added. Check the role settings of the system.");
} else {
$userInput = '';
$usersToAssign = array();
$stdin = fopen("php://stdin", "r+");
foreach ($topUserNodes as $userNode) {
if ($userInput != 'a') {
$name = $userNode->getName();
if (in_array($userNode->attribute('contentobject_id'), $anonymousUsers)) {
$cli->output("Note: the '{$name}' group/user is anonymous.");
}
$cli->output("Assign 'Tipafriend Role' to the '{$name}' group/user? y(yes)/n(no)/a(all)/s(skip all): ", false);
$userInput = fgets($stdin);
$userInput = trim($userInput);
示例4: updateRoles
function updateRoles( $params )
{
foreach( $params['roles'] as $roleData )
{
$roleName = $roleData['name'];
$role = eZRole::fetchByName( $roleName );
if( !is_object( $role ) )
{
$role = eZRole::create( $roleName );
$role->store();
}
$roleID = $role->attribute( 'id' );
if( isset( $roleData['policies'] ) )
{
$policies = $roleData['policies'];
foreach( $policies as $policy )
{
$role->appendPolicy( $policy['module'], $policy['function'], isset( $policy['limitation'] ) ? $policy['limitation'] : array() );
}
}
if( isset( $roleData['assignments'] ) )
{
$roleAssignments = $roleData['assignments'];
foreach( $roleAssignments as $roleAssignment )
{
$assignmentIdentifier = false;
$assignmentValue = false;
if( isset( $roleAssignment['limitation'] ) )
{
$assignmentIdentifier = $roleAssignment['limitation']['identifier'];
$assignmentValue = $roleAssignment['limitation']['value'];
}
$role->assignToUser( $roleAssignment['user_id'], $assignmentIdentifier, $assignmentValue );
}
}
}
}