public function actionPerformRequest() { $return = array(); $current_user = $this->_environment->getCurrentUser(); $session = $this->_environment->getSessionItem(); // get request data $item_id = $this->_data['item_id']; $module = $this->_data['module']; $current_page = $this->_data['current_page']; $restrictions = $this->_data['restrictions']; // get item $item_manager = $this->_environment->getItemManager(); $temp_item = $item_manager->getItem($item_id); if (isset($temp_item)) { if ($temp_item->getItemType() == 'label') { $label_manager = $this->_environment->getLabelManager(); $label_item = $label_manager->getItem($temp_item->getItemID()); $manager = $this->_environment->getManager($label_item->getLabelType()); } else { $manager = $this->_environment->getManager($temp_item->getItemType()); } $item = $manager->getItem($item_id); } $current_context = $item !== null ? $item->getContextItem() : $this->_environment->getCurrentContextItem(); // get ids of linked items $selected_ids = $item_id !== "NEW" ? $this->getLinkedItemIDArray($item) : array(); // build item list $item_list = new cs_list(); $item_ids = array(); $count_all = 0; if (!($item_id === "NEW" && $restrictions['only_linked'] === true)) { // get current room modules $room_modules = array(); $current_room_modules = $current_context->getHomeConf(); if (!empty($current_room_modules)) { $room_modules = explode(',', $current_room_modules); } if ($current_context->isPrivateRoom()) { $rubric_array = array(CS_MATERIAL_TYPE, CS_DISCUSSION_TYPE, CS_DISCUSSION_TYPE, CS_DATE_TYPE); } else { $rubric_array = array(); foreach ($room_modules as $room_module) { list($name, $display) = explode('_', $room_module); if ($display != 'none' && !($current_context->isPrivateRoom() && $name == 'user') && !($name == CS_USER_TYPE && ($module == CS_MATERIAL_TYPE || $module == CS_DISCUSSION_TYPE || $module == CS_ANNOUNCEMENT_TYPE || $module == CS_TOPIC_TYPE))) { $rubric_array[] = $name; } } if ($module == CS_USER_TYPE) { $rubric_array = array(); if ($current_context->withRubric(CS_GROUP_TYPE)) { $rubric_array[] = CS_GROUP_TYPE; } if ($current_context->withRubric(CS_INSTITUTION_TYPE)) { $rubric_array[] = CS_INSTITUTION_TYPE; } } } // perform rubric restriction if (!empty($restrictions['rubric']) && $restrictions['rubric'] !== "all") { $rubric_array = array(); $rubric_array[] = $restrictions['rubric']; } if ($restrictions['only_linked'] === true && empty($selected_ids)) { $rubric_array = array(); } // deactivate assigning user to groups if item is a group $current_user_is_grouproom_moderator = false; if ($item && $item->getType() == CS_LABEL_TYPE && $item->getLabelType() == CS_GROUP_TYPE) { if ($item->isGrouproomActivated()) { $group_manager = $this->_environment->getGroupManager(); $group_item = $group_manager->getItem($item->getItemID()); $group_room_item = $group_item->getGroupRoomItem(); $moderator_list = $group_room_item->getModeratorList(); $moderator_item = $moderator_list->getFirst(); while ($moderator_item) { if ($moderator_item->getUserID() == $current_user->getUserID()) { $current_user_is_grouproom_moderator = true; } $moderator_item = $moderator_list->getNext(); } if (!$current_user->isModerator()) { // dont show user and group items if grouproom is activated if (!$current_user_is_grouproom_moderator) { if (($key = array_search('user', $rubric_array)) !== false) { unset($rubric_array[$key]); } } if (($key = array_search('group', $rubric_array)) !== false) { unset($rubric_array[$key]); } } } } foreach ($rubric_array as $rubric) { $rubric_list = new cs_list(); $rubric_manager = $this->_environment->getManager($rubric); if (isset($rubric_manager) && $rubric != CS_MYROOM_TYPE) { if ($rubric != CS_PROJECT_TYPE) { $rubric_manager->setContextLimit($current_context->getItemID()); } if ($rubric == CS_DATE_TYPE) { $rubric_manager->setWithoutDateModeLimit(); } if ($rubric == CS_USER_TYPE) { if (!$current_user->isModerator() && $item->isGrouproomActivated() && !$current_user_is_grouproom_moderator) { continue; } $rubric_manager->setUserLimit(); if ($current_user->isUser()) { $rubric_manager->setVisibleToAllAndCommsy(); } else { $rubric_manager->setVisibleToAll(); } } $count_all += $rubric_manager->getCountAll(); // set restrictions if (!empty($restrictions['search'])) { $rubric_manager->setSearchLimit($restrictions['search']); } if ($restrictions['only_linked'] === true) { $rubric_manager->setIDArrayLimit($selected_ids); } if ($restrictions['type'] == 2) { $rubric_manager->showNoNotActivatedEntries(); } $rubric_manager->selectDistinct(); $rubric_list = $rubric_manager->get(); // show hidden entries only if user is moderator or owner if ($restrictions['type'] != 2 && !$current_user->isModerator()) { // check if user is owner $entry = $rubric_list->getFirst(); while ($entry) { if ($entry->isNotActivated() && $entry->getCreatorID() != $current_user->getItemID()) { // remove item from list $rubric_list->removeElement($entry); } $entry = $rubric_list->getNext(); } } // add rubric list to item list $item_list->addList($rubric_list); $temp_rubric_ids = $rubric_manager->getIDArray(); if (!empty($temp_rubric_ids)) { //$session->setValue('cid'.$environment->getCurrentContextID().'_item_attach_index_ids', $rubric_ids); $item_ids = array_merge($item_ids, $temp_rubric_ids); } } } } $interval = CS_LIST_INTERVAL; $from = $current_page * $interval; // get sublist - paging $sublist = $item_list->getSublist($from, $interval); // prepare return $return['list'] = array(); $item = $sublist->getFirst(); while ($item) { if ($item->getItemType() == CS_USER_TYPE) { $title = $item->getFullName(); } else { $title = $item->getTitle(); } if ($item->getType() == CS_LABEL_TYPE && $item->getLabelType() == CS_GROUP_TYPE && $module == "user" && $current_user->isModerator()) { if ($item->isGrouproomActivated()) { $item = $sublist->getNext(); continue; } } $entry = array(); $entry['item_id'] = $item->getItemID(); $entry['title'] = $title; if ($item->getType() == "date") { $entry['modification_date'] = $item->getDateTime_start(); } else { $entry['modification_date'] = $item->getModificationDate(); } //$entry['modification_date'] = $item->getModificationDate(); $entry['modificator'] = $item->getModificatorItem()->getFullName(); $entry['system_label'] = $item->isSystemLabel(); $entry['checked'] = false; if (in_array($item->getItemID(), $selected_ids)) { $entry['checked'] = true; } $return['list'][] = $entry; $item = $sublist->getNext(); } $return['paging']['pages'] = ceil(count($item_ids) / $interval); $return['num_selected_total'] = count($selected_ids); $this->setSuccessfullDataReturn($return); echo $this->_return; }