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


PHP eZRole::create方法代码示例

本文整理汇总了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);
 }
开发者ID:heliopsis,项目名称:ezxmlinstaller,代码行数:59,代码来源:ezcreaterole.php

示例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) {
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:67,代码来源:ezstep_create_sites.php

示例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.");
    }
}
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:31,代码来源:updatetipafriendpolicy.php

示例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 );
                }
            }
        }
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:39,代码来源:ezsiteinstaller.php


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