/**
  * @param $id
  * @param $type
  *
  * @return bool|int
  */
 protected function buildRef($id, $type)
 {
     if ($type == 'reference_id') {
         if (!ilObjOrgUnit::_exists($id, true)) {
             return false;
         }
         return $id;
     } elseif ($type == 'external_id') {
         $obj_id = ilObject::_lookupObjIdByImportId($id);
         if (!ilObject::_hasUntrashedReference($obj_id)) {
             return false;
         }
         $ref_ids = ilObject::_getAllReferences($obj_id);
         if (!count($ref_ids)) {
             return false;
         }
         foreach ($ref_ids as $ref_id) {
             if (!ilObject::_isInTrash($ref_id)) {
                 return $ref_id;
             }
         }
         return false;
     } else {
         return false;
     }
 }
 /**
  * get current term id for import id (static)
  *
  * @param	int		$a_import_id		import id
  *
  * @return	int		id
  */
 function _getIdForImportId($a_import_id)
 {
     global $ilDB;
     if ($a_import_id == "") {
         return 0;
     }
     $q = "SELECT * FROM glossary_term WHERE import_id = " . $ilDB->quote($a_import_id, "text") . " ORDER BY create_date DESC";
     $term_set = $ilDB->query($q);
     while ($term_rec = $ilDB->fetchAssoc($term_set)) {
         $glo_id = ilGlossaryTerm::_lookGlossaryID($term_rec["id"]);
         if (ilObject::_hasUntrashedReference($glo_id)) {
             return $term_rec["id"];
         }
     }
     return 0;
 }
 /**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 static function handleEvent($a_component, $a_event, $a_parameter)
 {
     include_once "./Services/Tagging/classes/class.ilTagging.php";
     switch ($a_component) {
         case "Services/Object":
             switch ($a_event) {
                 case "toTrash":
                     if (!ilObject::_hasUntrashedReference($a_parameter["obj_id"])) {
                         ilTagging::setTagsOfObjectOffline($a_parameter["obj_id"], ilObject::_lookupType($a_parameter["obj_id"]), 0, "");
                     }
                     break;
                 case "undelete":
                     ilTagging::setTagsOfObjectOffline($a_parameter["obj_id"], ilObject::_lookupType($a_parameter["obj_id"]), 0, "", false);
                     break;
                 case "delete":
                     $ref_ids = ilObject::_getAllReferences($a_parameter["obj_id"]);
                     if (count($ref_ids) == 0) {
                         ilTagging::deleteTagsOfObject($a_parameter["obj_id"], $a_parameter["type"], 0, "");
                     }
                     break;
             }
             break;
     }
 }
 /**
  * Look for all skill level that have a trigger and update
  * the user skill level information, if it has changed
  */
 public static function updateSkillLevelsByTriggerRef($a_user_id, $a_ref_id)
 {
     global $ilDB;
     die("ilBasicSkill::updateSkillLevelsByTriggerRef is deprecated.");
     $set = $ilDB->query("SELECT id, trigger_obj_id FROM skl_level WHERE " . " trigger_ref_id = " . $ilDB->quote($a_ref_id, "integer"));
     while ($rec = $ilDB->fetchAssoc($set)) {
         $skill_level_id = $rec["id"];
         $tr_obj_id = $rec["trigger_obj_id"];
         if (ilObject::_hasUntrashedReference($tr_obj_id)) {
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             $completed = ilLPStatusWrapper::_lookupCompletedForObject($tr_obj_id);
             foreach ($completed as $user_id) {
                 if ($a_user_id == $user_id) {
                     ilBasicSkill::writeUserSkillLevelStatus($skill_level_id, $user_id, ilBasicSkill::ACHIEVED);
                 }
             }
         }
     }
 }
 /**
  * Get SCORM modules that assign a certain glossary
  *
  * @param
  * @return
  */
 static function getScormModulesForGlossary($a_glo_id)
 {
     global $ilDB;
     $set = $ilDB->query("SELECT DISTINCT id FROM sahs_lm WHERE " . " glossary = " . $ilDB->quote($a_glo_id, "integer"));
     $sms = array();
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (ilObject::_hasUntrashedReference($rec["id"])) {
             $sms[] = $rec["id"];
         }
     }
     return $sms;
 }
 /**
  * Returns a List of Meetings that takes place in the time between $startDate and $endDate.
  * A Meeting is in range if $startDate > start_date < $endDate or $startDate > end_date < $endDate.
  * @param integer $startDate unixtimestamp
  * @param integer $endDate   unixtimestamp
  */
 public static function getMeetingsInRange($startDate, $endDate)
 {
     /**
      * @var $ilDB ilDB
      */
     global $ilDB;
     $query = 'SELECT * FROM rep_robj_xavc_data WHERE (start_date > %s AND start_date < %s) OR (end_date > %s AND end_date < %s) ORDER BY start_date';
     $types = array('integer', 'integer', 'integer', 'integer');
     $values = array($startDate, $endDate, $startDate, $endDate);
     $res = $ilDB->queryF($query, $types, $values);
     $objects = array();
     while ($row = $ilDB->fetchObject($res)) {
         if (ilObject::_hasUntrashedReference($row->id)) {
             $objects[] = $row;
         }
     }
     return $objects;
 }
 public function checkConcurrentMeetingDates(ilDateTime $endDate, ilDateTime $startDate = null, $ignoreId = null)
 {
     /**
      * @var $ilDB ilDB
      */
     global $ilDB;
     if ($startDate == null) {
         $startDate = new ilDateTime(time(), IL_CAL_UNIX);
     }
     $sim = array();
     $srv = ilAdobeConnectServer::_getInstance();
     $new_start_date = $startDate->getUnixTime() - $srv->getBufferBefore();
     $new_end_date = $endDate->getUnixTime() + $srv->getBufferAfter();
     $query = array('SELECT * FROM rep_robj_xavc_data', 'WHERE (', '(%s > start_date AND %s < end_date) OR', '(%s > start_date AND %s < end_date) OR', '(%s < start_date AND %s > end_date)', ')');
     $types = array('integer', 'integer', 'integer', 'integer', 'integer', 'integer');
     $values = array($new_start_date, $new_start_date, $new_end_date, $new_end_date, $new_start_date, $new_end_date);
     if ($ignoreId !== null) {
         $query[] = 'AND id <> %s';
         $types[] = 'integer';
         $values[] = $ignoreId;
     }
     $res = $ilDB->queryF(join(' ', $query), $types, $values);
     while ($row = $ilDB->fetchObject($res)) {
         if (ilObject::_hasUntrashedReference($row->id)) {
             $sim[] = $row;
         }
     }
     return $sim;
 }
 /**
  * Get Node ID for import ID (static)
  *
  * import ids can exist multiple times (if the same learning module
  * has been imported multiple times). we get the object id of
  * the last imported object, that is not in trash
  *
  * @param	int		$a_import_id		import id
  *
  * @return	int		id
  */
 function _getIdForImportId($a_import_id)
 {
     global $ilDB;
     $ilDB->setLimit(1);
     $q = "SELECT * FROM sahs_sc13_tree_node WHERE import_id = " . $ilDB->quote($a_import_id, "text") . " " . " ORDER BY create_date DESC";
     $obj_set = $ilDB->query($q);
     while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
         $slm_id = ilSCORM2004Node::_lookupSLMID($obj_rec["obj_id"]);
         // link only in learning module, that is not trashed
         if (ilObject::_hasUntrashedReference($slm_id)) {
             return $obj_rec["obj_id"];
         }
     }
     return 0;
 }
 /**
  * Returns true, if the question pool is writeable by a given user
  * 
  * @param integer $object_id The object id of the question pool
  * @param integer $user_id The database id of the user
  * @access public
  */
 function _isWriteable($object_id, $user_id)
 {
     global $rbacsystem;
     global $ilDB;
     $refs = ilObject::_getAllReferences($object_id);
     $result = false;
     foreach ($refs as $ref) {
         if ($rbacsystem->checkAccess("write", $ref) && ilObject::_hasUntrashedReference($object_id)) {
             $result = true;
         }
     }
     return $result;
 }
 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);
     }
 }
 /**
  *
  */
 public function forcePublicRoom()
 {
     $ref_id = ilObjChatroom::_getPublicRefId();
     if (!$ref_id) {
         $this->createPublicRoom();
         return;
     }
     $instance = ilObjectFactory::getInstanceByRefId($ref_id, false);
     if (!$instance) {
         $this->createPublicRoom();
         return;
     }
     $obj_id = ilObject::_lookupObjId($ref_id);
     if (!$obj_id) {
         $this->createPublicRoom();
         return;
     }
     if (!ilObject::_hasUntrashedReference($obj_id)) {
         $this->createPublicRoom();
         return;
     }
     require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
     ilChatroomInstaller::ensureCorrectPublicChatroomTreeLocation($ref_id);
 }
Exemple #12
0
 public function testTreeTrash()
 {
     global $tree;
     $obj = new ilObject();
     $obj->setType("xxx");
     $obj->setTitle("TestObject");
     $obj->setDescription("TestDescription");
     $obj->setImportId("imp_44");
     $obj->create();
     $obj->createReference();
     $id = $obj->getId();
     $ref_id = $obj->getRefId();
     $obj = new ilObject($ref_id);
     $obj->putInTree(ROOT_FOLDER_ID);
     $obj->createRoleFolder();
     $obj->setPermissions(ROOT_FOLDER_ID);
     if ($tree->isInTree($ref_id)) {
         $value .= "tree1-";
     }
     if (ilObject::_hasUntrashedReference($id)) {
         $value .= "tree2-";
     }
     // isSaved() uses internal cache!
     $tree->useCache(false);
     $tree->saveSubTree($ref_id, true);
     if ($tree->isDeleted($ref_id)) {
         $value .= "tree3-";
     }
     if ($tree->isSaved($ref_id)) {
         $value .= "tree4-";
     }
     if (ilObject::_isInTrash($ref_id)) {
         $value .= "tree5-";
     }
     if (!ilObject::_hasUntrashedReference($id)) {
         $value .= "tree6-";
     }
     $saved_tree = new ilTree(-(int) $ref_id);
     $node_data = $saved_tree->getNodeData($ref_id);
     $saved_tree->deleteTree($node_data);
     if (!ilObject::_isInTrash($ref_id)) {
         $value .= "tree7-";
     }
     $obs = ilUtil::_getObjectsByOperations("cat", "read");
     foreach ($obs as $ob) {
         if (ilObject::_lookupType(ilObject::_lookupObjId($ob)) != "cat") {
             $value .= "nocat-";
         }
     }
     $obj->delete();
     $this->assertEquals("tree1-tree2-tree3-tree4-tree5-tree6-tree7-", $value);
 }
 public function forcePublicRoom()
 {
     $ref_id = ilObjChatroom::_getPublicRefId();
     if (!$ref_id) {
         $this->createPublicRoom();
         return;
     }
     $instance = ilObjectFactory::getInstanceByRefId($ref_id, false);
     if (!$instance) {
         $this->createPublicRoom();
         return;
     }
     $obj_id = ilObject::_lookupObjId($ref_id);
     if (!$obj_id) {
         $this->createPublicRoom();
         return;
     }
     if (!ilObject::_hasUntrashedReference($obj_id)) {
         $this->createPublicRoom();
         return;
     }
 }
 /**
  * Show user's courses
  */
 public function showMyCourses()
 {
     global $lng, $ilUser, $ilObjDataCache, $tree, $tpl, $rbacsystem;
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
     $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
     $_GET['view'] = 'mycourses';
     $lng->loadLanguageModule('crs');
     include_once 'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
     $table = new ilMailSearchCoursesTableGUI($this, "crs", $_GET["ref"]);
     $table->setId('search_crs_tbl');
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs');
     $counter = 0;
     $tableData = array();
     if (is_array($crs_ids) && count($crs_ids) > 0) {
         $num_courses_hidden_members = 0;
         include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
         foreach ($crs_ids as $crs_id) {
             /**
              * @var $oTmpCrs ilObjCourse
              */
             $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
             $isOffline = !$oTmpCrs->isActivated();
             $hasUntrashedReferences = ilObject::_hasUntrashedReference($crs_id);
             $showMemberListEnabled = (bool) $oTmpCrs->getShowMembers();
             $ref_ids = array_keys(ilObject::_getAllReferences($crs_id));
             $isPrivilegedUser = $rbacsystem->checkAccess('write', $ref_ids[0]);
             if ($hasUntrashedReferences && (!$isOffline && $showMemberListEnabled || $isPrivilegedUser)) {
                 $oCrsParticipants = ilCourseParticipants::_getInstanceByObjId($crs_id);
                 $crs_members = $oCrsParticipants->getParticipants();
                 foreach ($crs_members as $key => $member) {
                     $tmp_usr = new ilObjUser($member);
                     if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) {
                         unset($crs_members[$key]);
                     }
                 }
                 unset($tmp_usr);
                 $hiddenMembers = false;
                 if ((int) $oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
                     ++$num_courses_hidden_members;
                     $hiddenMembers = true;
                 }
                 unset($oTmpCrs);
                 $ref_ids = ilObject::_getAllReferences($crs_id);
                 $ref_id = current($ref_ids);
                 $path_arr = $tree->getPathFull($ref_id, $tree->getRootId());
                 $path_counter = 0;
                 $path = '';
                 foreach ($path_arr as $data) {
                     if ($path_counter++) {
                         $path .= " -> ";
                     }
                     $path .= $data['title'];
                 }
                 $path = $this->lng->txt('path') . ': ' . $path;
                 $current_selection_list = new ilAdvancedSelectionListGUI();
                 $current_selection_list->setListTitle($this->lng->txt("actions"));
                 $current_selection_list->setId("act_" . $counter);
                 $this->ctrl->setParameter($this, 'search_crs', $crs_id);
                 $this->ctrl->setParameter($this, 'view', 'mycourses');
                 if ($_GET["ref"] == "mail") {
                     if ($this->mailing_allowed) {
                         $current_selection_list->addItem($this->lng->txt("mail_members"), '', $this->ctrl->getLinkTarget($this, "mail"));
                     }
                 } else {
                     if ($_GET["ref"] == "wsp") {
                         $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $this->ctrl->getLinkTarget($this, "share"));
                     }
                 }
                 $current_selection_list->addItem($this->lng->txt("mail_list_members"), '', $this->ctrl->getLinkTarget($this, "showMembers"));
                 $this->ctrl->clearParameters($this);
                 $rowData = array("CRS_ID" => $crs_id, "CRS_NAME" => $ilObjDataCache->lookupTitle($crs_id), "CRS_NO_MEMBERS" => count($crs_members), "CRS_PATH" => $path, 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(), "hidden_members" => $hiddenMembers);
                 $counter++;
                 $tableData[] = $rowData;
             }
         }
         //if((int)$counter)
         //{
         //	$table->addCommandButton('mail',$lng->txt('mail_members'));
         //	$table->addCommandButton('showMembers',$lng->txt('mail_list_members'));
         //}
         if ($num_courses_hidden_members > 0) {
             $searchTpl->setCurrentBlock('caption_block');
             $searchTpl->setVariable('TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt('mail_crs_list_members_not_available'));
             $searchTpl->parseCurrentBlock();
         }
     }
     $searchTpl->setVariable('TXT_MARKED_ENTRIES', $lng->txt('marked_entries'));
     $table->setData($tableData);
     if ($_GET['ref'] == 'mail') {
         $this->tpl->setVariable('BUTTON_CANCEL', $lng->txt('cancel'));
     }
     $searchTpl->setVariable('TABLE', $table->getHtml());
     $tpl->setContent($searchTpl->get());
     if ($_GET["ref"] != "wsp") {
         $tpl->show();
     }
 }
 final function _hasUntrashedReference($a_obj_id)
 {
     return parent::_hasUntrashedReference($a_obj_id);
 }
 /**
 * Returns true, if the question pool is writeable by a given user
 * 
 * @param integer $object_id The object id of the question pool object
 * @param integer $user_id The database id of the user
 * @access public
 */
 function _isWriteable($object_id, $user_id)
 {
     global $rbacsystem;
     include_once "./Services/Object/classes/class.ilObject.php";
     $refs = ilObject::_getAllReferences($object_id);
     if (count($refs)) {
         foreach ($refs as $ref_id) {
             if ($rbacsystem->checkAccess("write", $ref_id) && ilObject::_hasUntrashedReference($object_id)) {
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * get all objects of a certain type
  *
  * @param	string		$a_type			desired object type
  * @param	boolean		$a_omit_trash	omit objects, that are in trash only
  *										(default: false)
  *
  * @return	array		array of object data arrays ("id", "title", "type",
  *						"description")
  */
 function _getObjectsDataForType($a_type, $a_omit_trash = false)
 {
     global $ilDB;
     $q = "SELECT * FROM object_data WHERE type = " . $ilDB->quote($a_type, "text");
     $obj_set = $ilDB->query($q);
     $objects = array();
     while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
         if (!$a_omit_trash || ilObject::_hasUntrashedReference($obj_rec["obj_id"])) {
             $objects[$obj_rec["title"] . "." . $obj_rec["obj_id"]] = array("id" => $obj_rec["obj_id"], "type" => $obj_rec["type"], "title" => $obj_rec["title"], "description" => $obj_rec["description"]);
         }
     }
     ksort($objects);
     return $objects;
 }
 /**
  * Show user's courses
  */
 public function showMyGroups()
 {
     global $lng, $ilUser, $ilObjDataCache, $tree;
     include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
     $this->tpl->setTitle($this->lng->txt('mail_addressbook'));
     $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
     $_GET['view'] = 'mygroups';
     $lng->loadLanguageModule('crs');
     $this->ctrl->setParameter($this, 'view', 'mygroups');
     include_once 'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php';
     $table = new ilMailSearchCoursesTableGUI($this, 'grp', $_GET["ref"]);
     $table->setId('search_grps_tbl');
     $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp');
     $counter = 0;
     $tableData = array();
     if (is_array($grp_ids) && count($grp_ids) > 0) {
         include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
         foreach ($grp_ids as $grp_id) {
             if (ilObject::_hasUntrashedReference($grp_id)) {
                 $oGroupParticipants = ilGroupParticipants::_getInstanceByObjId($grp_id);
                 $grp_members = $oGroupParticipants->getParticipants();
                 foreach ($grp_members as $key => $member) {
                     $tmp_usr = new ilObjUser($member);
                     if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) {
                         unset($grp_members[$key]);
                     }
                 }
                 unset($tmp_usr);
                 $ref_ids = ilObject::_getAllReferences($grp_id);
                 $ref_id = current($ref_ids);
                 $path_arr = $tree->getPathFull($ref_id, $tree->getRootId());
                 $path_counter = 0;
                 $path = '';
                 foreach ($path_arr as $data) {
                     if ($path_counter++) {
                         $path .= " -> ";
                     }
                     $path .= $data['title'];
                 }
                 $path = $this->lng->txt('path') . ': ' . $path;
                 $current_selection_list = new ilAdvancedSelectionListGUI();
                 $current_selection_list->setListTitle($this->lng->txt("actions"));
                 $current_selection_list->setId("act_" . $counter);
                 $this->ctrl->setParameter($this, 'search_grp', $grp_id);
                 $this->ctrl->setParameter($this, 'view', 'mygroups');
                 if ($_GET["ref"] == "mail") {
                     if ($this->mailing_allowed) {
                         $current_selection_list->addItem($this->lng->txt("mail_members"), '', $this->ctrl->getLinkTarget($this, "mail"));
                     }
                 } else {
                     if ($_GET["ref"] == "wsp") {
                         $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $this->ctrl->getLinkTarget($this, "share"));
                     }
                 }
                 $current_selection_list->addItem($this->lng->txt("mail_list_members"), '', $this->ctrl->getLinkTarget($this, "showMembers"));
                 $this->ctrl->clearParameters($this);
                 $rowData = array('CRS_ID' => $grp_id, 'CRS_NAME' => $ilObjDataCache->lookupTitle($grp_id), 'CRS_NO_MEMBERS' => count($grp_members), 'CRS_PATH' => $path, 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML());
                 $counter++;
                 $tableData[] = $rowData;
             }
         }
     }
     $table->setData($tableData);
     if ($counter > 0) {
         $this->tpl->setVariable('TXT_MARKED_ENTRIES', $lng->txt('marked_entries'));
     }
     $searchTpl->setVariable('TABLE', $table->getHtml());
     $this->tpl->setContent($searchTpl->get());
     if ($_GET["ref"] != "wsp") {
         $this->tpl->show();
     }
 }
 /**
  *	Returns a array of object ids which match the references id, given by a comma seperated string.
  *
  *	@param	string $sid	Session ID
  *	@param	array of int $ref ids as comma separated list
  *	@return	array of ref ids, same order as object ids there for there might by duplicates
  *
  */
 function getObjIdsByRefIds($sid, $ref_ids)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!count($ref_ids) || !is_array($ref_ids)) {
         return $this->__raiseError('No reference id(s) given.', 'Client');
     }
     $obj_ids = array();
     if (count($ref_ids)) {
         foreach ($ref_ids as $ref_id) {
             $ref_id = trim($ref_id);
             if (!is_numeric($ref_id)) {
                 return $this->__raiseError('Reference ID has to be numeric. Value: ' . $ref_id, 'Client');
             }
             $obj_id = ilObject::_lookupObjectId($ref_id);
             if (!$obj_id) {
                 return $this->__raiseError('No object found for reference ID. Value: ' . $ref_id, 'Client');
             }
             if (!ilObject::_hasUntrashedReference($obj_id)) {
                 return $this->__raiseError('No untrashed reference found for reference ID. Value: ' . $ref_id, 'Client');
             }
             $obj_ids[] = $obj_id;
         }
     }
     return $obj_ids;
 }
Exemple #20
0
 /**
  * Get all items for an import ID
  *
  * (only for items notnot in trash)
  *
  * @param	int		$a_import_id		import id
  *
  * @return	int		id
  */
 function _getAllObjectsForImportId($a_import_id, $a_in_lm = 0)
 {
     global $ilDB;
     $where = $a_in_lm > 0 ? " AND lm_id = " . $ilDB->quote($a_in_lm, "integer") . " " : "";
     $q = "SELECT * FROM lm_data WHERE import_id = " . $ilDB->quote($a_import_id, "text") . " " . $where . " ORDER BY create_date DESC";
     $obj_set = $ilDB->query($q);
     $items = array();
     while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
         // check, whether lm is not trashed
         if (ilObject::_hasUntrashedReference($obj_rec["lm_id"])) {
             $items[] = $obj_rec;
         }
     }
     return $items;
 }
 public static function handleDeletedGroups()
 {
     global $ilDB;
     $query = 'SELECT child, obd.obj_id FROM tree ' . 'JOIN object_reference obr ON child = ref_id ' . 'JOIN object_data obd ON obr.obj_id = obd.obj_id ' . 'WHERE type = ' . $ilDB->quote('xvit', 'text') . ' ' . 'AND tree < ' . $ilDB->quote(0, 'integer');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!ilObject::_hasUntrashedReference($row->obj_id)) {
             try {
                 $vgroup_id = ilObjVitero::lookupVGroupId($row->obj_id);
                 if (!$vgroup_id) {
                     continue;
                 }
                 $start = new ilDate(time(), IL_CAL_UNIX);
                 $end = clone $start;
                 $start->increment(IL_CAL_YEAR, -2);
                 $end->increment(IL_CAL_YEAR, 2);
                 $booking_service = new ilViteroBookingSoapConnector();
                 $books = $booking_service->getByGroupAndDate($vgroup_id, $start, $end);
                 if (is_object($books->booking)) {
                     try {
                         $booking_service->deleteBooking($books->booking->bookingid);
                     } catch (ilViteroConnectorException $e) {
                         $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting deprecated booking failed with message: ' . $e->getMessage());
                     }
                 }
                 if (is_array($books->booking)) {
                     foreach ((array) $books->booking as $book) {
                         try {
                             $booking_service->deleteBooking($book->bookingid);
                         } catch (ilViteroConnectorException $e) {
                             $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting deprecated booking failed with message: ' . $e->getMessage());
                         }
                     }
                 }
             } catch (ilViteroConnectorException $e) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot read bookings of group "' . $vgroup_id . '": ' . $e->getMessage());
             }
         }
         // Delete group
         try {
             $groups = new ilViteroGroupSoapConnector();
             $groupDefinition = new ilViteroGroupSoap();
             $groupDefinition->groupid = $vgroup_id;
             $groups->delete($groupDefinition);
             // Update vgroup id
             $query = 'UPDATE rep_robj_xvit_data ' . 'SET vgroup_id = 0 ' . 'WHERE obj_id = ' . $ilDB->quote($row->obj_id, 'integer');
             $ilDB->manipulate($query);
         } catch (ilViteroConnectorException $e) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Delete group failed: "' . $vgroup_id . '": ' . $e->getMessage());
         }
     }
 }