本文整理汇总了PHP中eZRole::create方法的典型用法代码示例。如果您正苦于以下问题:PHP eZRole::create方法的具体用法?PHP eZRole::create怎么用?PHP eZRole::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZRole
的用法示例。
在下文中一共展示了eZRole::create方法的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
//.........这里部分代码省略.........
$installParameters['ini'] = array();
$siteINIChanges = array();
$url = $siteType['url'];
if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
$url = $matches[1];
}
$siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
$siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
$siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
$siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
$siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
if (trim($dbSocket) != '') {
$siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
} else {
$siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
}
if ($admin['email']) {
$siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false);
$siteINIChanges['UserSettings'] = array('RegistrationEmail' => false);
$siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false);
}
$siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages);
if ($primaryLanguage->localeCode() == 'eng-GB') {
$siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
} else {
$siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
}
$installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
$installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
$installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
$installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
$installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName;
$installParameters['variables']['design'] = $userDesignName;
$tmpSiteINI = eZINI::create('site.ini');
// Set ReadOnlySettingsCheck to false: towards
// Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
$tmpSiteINI->setReadOnlySettingsCheck(false);
$tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']);
// Change the current translation variables, before other parts start using them
$tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']);
$tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']);
$tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']);
$tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
/*
$typeFunctionality = eZSetupFunctionality( $siteType['identifier'] );
$extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ?
$this->PersistenceList['additional_packages'] :
array(),
$typeFunctionality['required'] );
$extraFunctionality = array_unique( $extraFunctionality );
*/
// Add a policy to permit editors using OE
eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
// Install site package and it's required packages
$sitePackageName = $this->chosenSitePackage();
$sitePackage = eZPackage::fetch($sitePackageName);
if (!is_object($sitePackage)) {
$resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
return false;
}
$dependecies = $sitePackage->attribute('dependencies');
$requires = $dependecies['requires'];
$requiredPackages = array();
// Include setting files
$settingsFiles = $sitePackage->attribute('settings-files');
foreach ($settingsFiles as $settingsFileName) {
示例3: y
}
$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);
}
if ($userInput == 'y' or $userInput == 'a') {
$usersToAssign[] = $userNode->attribute('contentobject_id');
} else {
if ($userInput == 's') {
break;
}
}
}
fclose($stdin);
if (count($usersToAssign) > 0) {
$role = eZRole::create($roleName);
$role->store();
$role->appendPolicy('content', 'tipafriend');
$role->store();
foreach ($usersToAssign as $userID) {
$role->assignToUser($userID);
}
// clear role cache
eZRole::expireCache();
eZContentCacheManager::clearAllContentCache();
// clear policy cache
eZUser::cleanupCache();
} else {
$cli->notice("\nThe role wasn't added because you didn't choose any group to assign.");
}
}
示例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 );
}
}
}
}