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


PHP ilObjRole::_getIdsForTitle方法代码示例

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


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

示例1: importSimpleXml

 /**
  * Import using simplexml
  * @param SimpleXMLElement $role
  */
 public function importSimpleXml(SimpleXMLElement $role)
 {
     global $rbacadmin, $rbacreview, $lng;
     $import_id = (string) $role['id'];
     $GLOBALS['ilLog']->write(__METHOD__ . ' Importing role with import id ' . $import_id);
     if (!$this->initRole($import_id)) {
         return 0;
     }
     $this->getRole()->setTitle(trim((string) $role->title));
     $this->getRole()->setDescription(trim((string) $role->description));
     $type = ilObject::_lookupType($this->getRoleFolderId(), true);
     $exp = explode("_", $this->getRole()->getTitle());
     if (count($exp) > 0 && $exp[0] === "il") {
         if (count($exp) > 1 && $exp[1] !== $type) {
             throw new ilRoleImporterException(sprintf($lng->txt("rbac_cant_import_role_wrong_type"), $lng->txt('obj_' . $exp[1]), $lng->txt('obj_' . $type)));
         }
         $exp[3] = $this->getRoleFolderId();
         $id = ilObjRole::_getIdsForTitle(implode("_", $exp));
         if ($id[0]) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Overwrite role ' . implode("_", $exp));
             $this->getRole()->setId($id[0]);
             $this->getRole()->read();
         }
     }
     // Create or update
     if ($this->getRole()->getId()) {
         $rbacadmin->deleteRolePermission($this->getRole()->getId(), $this->getRoleFolderId());
         $this->getRole()->update();
     } else {
         $this->getRole()->create();
     }
     $this->assignToRoleFolder();
     $protected = (string) $role['protected'];
     if ($protected) {
         $rbacadmin->setProtected(0, $this->getRole()->getId(), 'y');
     }
     // Add operations
     $ops = $rbacreview->getOperations();
     $operations = array();
     foreach ($ops as $ope) {
         $operations[$ope['operation']] = $ope['ops_id'];
     }
     foreach ($role->operations as $sxml_operations) {
         foreach ($sxml_operations as $sxml_op) {
             $ops_group = (string) $sxml_op['group'];
             $ops_id = (int) $operations[trim((string) $sxml_op)];
             $ops = trim((string) $sxml_op);
             if ($ops_group and $ops_id) {
                 $rbacadmin->setRolePermission($this->getRole()->getId(), $ops_group, array($ops_id), $this->getRoleFolderId());
             } else {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot create operation for...');
                 $GLOBALS['ilLog']->write(__METHOD__ . ': New operation for group ' . $ops_group);
                 $GLOBALS['ilLog']->write(__METHOD__ . ': New operation ' . $ops);
                 $GLOBALS['ilLog']->write(__METHOD__ . ': New operation ' . $ops_id);
             }
         }
     }
     return $this->getRole()->getId();
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:63,代码来源:class.ilRoleXmlImporter.php


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