public function simpleExportExcel() { $ilOrgUnitExporter = new ilOrgUnitExporter(); $ilOrgUnitExporter->simpleExportExcel(ilObjOrgUnit::getRootOrgRefId()); }
public function getTabs(&$tabs_gui) { if ($this->ilAccess->checkAccess('read', '', $this->object->getRefId())) { $this->tabs_gui->addTab("view_content", $this->lng->txt("content"), $this->ctrl->getLinkTarget($this, "")); $this->tabs_gui->addTab("info_short", "Info", $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")); } //Tabs for OrgUnits exclusive root! if ($this->object->getRefId() != ilObjOrgUnit::getRootOrgRefId()) { if (ilObjOrgUnitAccess::_checkAccessStaff($this->object->getRefId())) { $this->tabs_gui->addTab("orgu_staff", $this->lng->txt("orgu_staff"), $this->ctrl->getLinkTargetByClass("ilOrgUnitStaffGUI", "showStaff")); } if ($this->ilAccess->checkAccess('write', '', $this->object->getRefId())) { $this->tabs_gui->addTab("settings", $this->lng->txt("settings"), $this->ctrl->getLinkTargetByClass("ilTranslationGUI", "editTranslations")); } if (ilObjOrgUnitAccess::_checkAccessAdministrateUsers($this->object->getRefId())) { $this->tabs_gui->addTab("administrate_users", $this->lng->txt("administrate_users"), $this->ctrl->getLinkTargetByClass("ilLocalUserGUI", "index")); } } if ($this->ilAccess->checkAccess('write', '', $this->object->getRefId())) { $this->tabs_gui->addTarget('export', $this->ctrl->getLinkTargetByClass('ilorgunitexportgui', ''), 'export', 'ilorgunitexportgui'); } parent::getTabs($tabs_gui); }
/** * @param $orgu ilObjOrgUnit * @return array */ private function getAttrForOrgu($orgu) { global $tree; $parent_ref = $tree->getParentId($orgu->getRefId()); if ($parent_ref != ilObjOrgUnit::getRootOrgRefId()) { $parent = new ilObjOrgUnit($parent_ref); $ou_parent_id = $parent->getRefId(); } else { $ou_parent_id = "__ILIAS"; } // Only the ref id is guaranteed to be unique. $ou_id = $orgu->getRefId(); $attr = array("ou_id" => $ou_id, "ou_id_type" => "reference_id", "ou_parent_id" => $ou_parent_id, "ou_parent_id_type" => "reference_id", "action" => "create"); return $attr; }
public function getRootNode() { return $this->getTree()->getNodeData(ilObjOrgUnit::getRootOrgRefId()); }
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); } }
/** * Specify eg. level 1 and it will return on which orgunit on the first level after the root node the specified orgu_ref is a subunit of. * eg: * 0 * - - * 1 2 * - - - * 3 4 5 * - * 6 * * (6, 1) = 1; (4, 1) = 2; (6, 2) = 3; * @param $orgu_ref * @param $level * @throws Exception in case there's a thread of an infinite loop or if you try to fetch the third level but there are only two (e.g. you want to fetch lvl 1 but give the root node as reference). * @return int|bool ref_id of the orgu or false if not found. */ public function getLevelXOfTreenode($orgu_ref, $level) { $line = array($orgu_ref); $current_ref = $orgu_ref; while ($current_ref != ilObjOrgUnit::getRootOrgRefId()) { $current_ref = $this->getParent($current_ref); if ($current_ref) { $line[] = $current_ref; } else { break; } if (count($line) > 100) { throw new Exception("There's either a non valid call of the getLevelXOfTreenode in ilObjOrgUnitTree or your nesting of orgunits is higher than 100 units, which isn't encouraged"); } } $line = array_reverse($line); if (count($line) > $level) { return $line[$level]; } else { throw new Exception("you want to fetch level " . $level . " but the line to the length of the line is only " . count($line) . ". The line of the given org unit is: " . print_r($line, true)); } }
/** * @param $orgu ilObjOrgUnit * @return array */ private function getAttributesForOrgu($orgu) { global $tree; $parent_ref = $tree->getParentId($orgu->getRefId()); if ($parent_ref != ilObjOrgUnit::getRootOrgRefId()) { $ou_parent_id = $this->buildExternalId($parent_ref); } else { $ou_parent_id = "__ILIAS"; } // Only the ref id is guaranteed to be unique. $ref_id = $orgu->getRefId(); $attr = array("ou_id" => $this->buildExternalId($ref_id), "ou_id_type" => "external_id", "ou_parent_id" => $ou_parent_id, "ou_parent_id_type" => "external_id", "action" => "create"); return $attr; }