コード例 #1
0
 /**
  * Remove objects from system
  */
 function removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder = false)
 {
     global $lng;
     if (!is_array($a_ref_ids) || count($a_ref_ids) == 0) {
         ilUtil::sendFailure($lng->txt("no_checkbox"), true);
         return false;
     } else {
         include_once "./Services/Repository/classes/class.ilRepUtil.php";
         try {
             ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
             ilUtil::sendSuccess($lng->txt("msg_removed"), true);
         } catch (Exception $e) {
             ilUtil::sendFailure($e->getMessage(), true);
             return false;
         }
     }
     return true;
 }
コード例 #2
0
 /**
  * Recursive method to insert all saved nodes of the clipboard
  */
 private function insertSavedNodes($a_source_id, $a_dest_id, $a_tree_id, &$a_affected_ids)
 {
     global $rbacadmin, $rbacreview, $log, $tree;
     $tree->insertNode($a_source_id, $a_dest_id, IL_LAST_NODE, true);
     $a_affected_ids[$a_source_id] = $a_source_id;
     // write log entry
     $log->write("ilRepUtil::insertSavedNodes(), restored ref_id {$a_source_id} from trash");
     // SET PERMISSIONS
     $parentRoles = $rbacreview->getParentRoleIds($a_dest_id);
     $obj =& ilObjectFactory::getInstanceByRefId($a_source_id);
     foreach ($parentRoles as $parRol) {
         $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $obj->getType(), $parRol["parent"]);
         $rbacadmin->grantPermission($parRol["obj_id"], $ops, $a_source_id);
     }
     $saved_tree = new ilTree($a_tree_id);
     $childs = $saved_tree->getChilds($a_source_id);
     foreach ($childs as $child) {
         ilRepUtil::insertSavedNodes($child["child"], $a_source_id, $a_tree_id, $a_affected_ids);
     }
 }
コード例 #3
0
 protected function afterServiceAuth()
 {
     global $ilCtrl, $lng;
     try {
         if ($this->plugin_service->afterAuthService()) {
             $this->object->setRootId("root", true);
             $this->object->setAuthComplete(true);
             $this->object->update();
             ilUtil::sendSuccess($lng->txt("cld_object_added"), true);
             $ilCtrl->redirectByClass("ilCloudPluginSettingsGUI", "editSettings");
         } else {
             include_once "./Services/Repository/classes/class.ilRepUtil.php";
             ilRepUtil::deleteObjects($this->object->getRefId(), $this->object->getRefId());
             ilUtil::sendFailure($lng->txt("cld_auth_failed_no_object_created"), true);
             ilObjectGUI::redirectToRefId($this->parent_id);
         }
     } catch (Exception $e) {
         ilUtil::sendFailure($e->getMessage(), true);
         ilObjectGUI::redirectToRefId($this->parent_id);
     }
 }
コード例 #4
0
 public function simpleImportElement(SimpleXMLElement $o)
 {
     global $tree, $tpl, $ilUser;
     $title = $o->title;
     $description = $o->description;
     $external_id = $o->external_id;
     $create_mode = true;
     $attributes = $o->attributes();
     $action = (string) $attributes->action;
     $ou_id = (string) $attributes->ou_id;
     $ou_id_type = (string) $attributes->ou_id_type;
     $ou_parent_id = (string) $attributes->ou_parent_id;
     $ou_parent_id_type = (string) $attributes->ou_parent_id_type;
     if ($ou_id == ilObjOrgUnit::getRootOrgRefId()) {
         $this->addWarning("cannot_change_root_node", $ou_id ? $ou_id : $external_id, $action);
         return;
     }
     if ($ou_parent_id == "__ILIAS") {
         $ou_parent_id = ilObjOrgUnit::getRootOrgRefId();
         $ou_parent_id_type = "reference_id";
     }
     $ref_id = $this->buildRef($ou_id, $ou_id_type);
     $parent_ref_id = $this->buildRef($ou_parent_id, $ou_parent_id_type);
     if ($action == "delete") {
         if (!$parent_ref_id) {
             $this->addError("ou_parent_id_not_valid", $ou_id ? $ou_id : $external_id, $action);
             return;
         }
         if (!$ref_id) {
             $this->addError("ou_id_not_valid", $ou_id ? $ou_id : $external_id, $action);
             return;
         }
         include_once "./Services/Repository/classes/class.ilRepUtil.php";
         $ru = new ilRepUtil($this);
         try {
             $ru->deleteObjects($parent_ref_id, array($ref_id)) !== false;
             $this->stats["deleted"]++;
         } catch (Excpetion $e) {
             $this->addWarning("orgu_already_deleted", $ou_id ? $ou_id : $external_id, $action);
         }
         return;
     } elseif ($action == "update") {
         if (!$parent_ref_id) {
             $this->addError("ou_parent_id_not_valid", $ou_id ? $ou_id : $external_id, $action);
             return;
         }
         if (!$ref_id) {
             $this->addError("ou_id_not_valid", $ou_id ? $ou_id : $external_id, $action);
             return;
         }
         $object = new ilObjOrgUnit($ref_id);
         $object->setTitle($title);
         $arrTranslations = $object->getTranslations();
         $object->updateTranslation($title, $description, $ilUser->getLanguage(), "");
         $object->setDescription($description);
         $object->update();
         $object->setImportId($external_id);
         if ($parent_ref_id != $tree->getParentId($ref_id)) {
             try {
                 $tree->moveTree($ref_id, $parent_ref_id);
             } catch (Exception $e) {
                 global $ilLog;
                 $this->addWarning("not_movable", $ou_id ? $ou_id : $external_id, $action);
                 $ilLog->write($e->getMessage() . "\\n" . $e->getTraceAsString());
             }
         }
         $this->stats["updated"]++;
     } elseif ($action == "create") {
         if (!$parent_ref_id) {
             $this->addError("ou_parent_id_not_valid", $ou_id ? $ou_id : $external_id, $action);
             return;
         }
         if ($external_id) {
             $obj_id = ilObject::_lookupObjIdByImportId($external_id);
             if (ilObject::_hasUntrashedReference($obj_id)) {
                 $this->addError("ou_external_id_exists", $ou_id ? $ou_id : $external_id, $action);
                 return;
             }
         }
         $object = new ilObjOrgUnit();
         $object->setTitle($title);
         $object->setDescription($description);
         $object->setImportId($external_id);
         $object->create();
         $object->createReference();
         $object->putInTree($parent_ref_id);
         $object->setPermissions($ou_parent_id);
         $this->stats["created"]++;
     } else {
         $this->addError("no_valid_action_given", $ou_id, $action);
     }
 }