/**
  * 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();
 }