public function getNetnavigationForUser($item) { $return = array(); $current_context = $this->_environment->getCurrentContextItem(); $current_user = $this->_environment->getCurrentUser(); $translator = $this->_environment->getTranslationObject(); $converter = $this->_environment->getTextConverter(); if ($current_context->isProjectRoom()) { $link_items = $item->getLinkItemList(CS_GROUP_TYPE); } elseif ($current_context->isCommunityRoom()) { $link_items = $item->getLinkItemList(CS_INSTITUTION_TYPE); } else { $link_items = new cs_list(); } // remove items from list the current user is not allowed to see or ??? $count_item = $link_items->getFirst(); while ($count_item) { $linked_item = $count_item->getLinkedItem($item); if (isset($linked_item)) { $type = $linked_item->getType(); } $module = Type2Module($type); if ($module === CS_USER_TYPE && ($item->getItemType() == CS_GROUP_TYPE || (!$linked_item->isUser() || !$linked_item->maySee($current_user)))) { $link_items->removeElement($count_item); } $count_item = $link_items->getNext(); } $count_link_item = $link_items->getCount(); $return['count'] = $count_link_item; /* * $this->_right_box_config['title_string'] .= $separator.'"'.$this->_translator->getMessage('COMMON_NETNAVIGATION_ENTRIES').' ('.$count_link_item.')"'; $this->_right_box_config['desc_string'] .= $separator.'""'; $this->_right_box_config['size_string'] .= $separator.'"10"'; if($current_context->isNetnavigationShowExpanded()){ $this->_right_box_config['config_string'] .= $separator.'true'; } else { $this->_right_box_config['config_string'] .= $separator.'false'; } $html .= '<div class="commsy_panel" style="margin-bottom:1px;">'.LF; $html .= '<div class="right_box">'.LF; */ $return['items'] = array(); if (!$link_items->isEmpty()) { $link_item = $link_items->getFirst(); while ($link_item) { $entry = array('creator' => ''); $link_creator = $link_item->getCreatorItem(); if (isset($link_creator) && !$link_creator->isDeleted()) { $entry['creator'] = $link_creator->getFullname(); // create the list entry $linked_item = $link_item->getLinkedItem($item); if (isset($linked_item)) { $type = $linked_item->getType(); if ($type === 'label') { $type = $linked_item->getLabelType(); } $link_created = $translator->getDateInLang($link_item->getCreationDate()); switch (mb_strtoupper($type, 'UTF-8')) { case 'ANNOUNCEMENT': $text = $translator->getMessage('COMMON_ONE_ANNOUNCEMENT'); $img = 'announcement.png'; break; case 'DATE': $text = $translator->getMessage('COMMON_ONE_DATE'); $img = 'date.png'; break; case 'DISCUSSION': $text = $translator->getMessage('COMMON_ONE_DISCUSSION'); $img = 'discussion.png'; break; case 'GROUP': $text = $translator->getMessage('COMMON_ONE_GROUP'); $img = 'group.png'; break; case 'INSTITUTION': $text = $translator->getMessage('COMMON_ONE_INSTITUTION'); $img = ''; break; case 'MATERIAL': $text = $translator->getMessage('COMMON_ONE_MATERIAL'); $img = 'material.png'; break; case 'PROJECT': $text = $translator->getMessage('COMMON_ONE_PROJECT'); $img = ''; break; case 'TODO': $text = $translator->getMessage('COMMON_ONE_TODO'); $img = 'todo.png'; break; case 'TOPIC': $text = $translator->getMessage('COMMON_ONE_TOPIC'); $img = 'topic.png'; break; case 'USER': $text = $translator->getMessage('COMMON_ONE_USER'); $img = 'user.png'; break; default: $text = $translator->getMessage('COMMON_MESSAGETAB_ERROR'); $img = ''; break; } $link_creator_text = $text . ' - ' . $translator->getMessage('COMMON_LINK_CREATOR') . ' ' . $entry['creator'] . ', ' . $link_created; switch ($type) { case CS_DISCARTICLE_TYPE: $linked_iid = $linked_item->getDiscussionID(); $discussion_manager = $this->_environment->getDiscussionManager(); $linked_item = $discussion_manager->getItem($linked_iid); break; case CS_SECTION_TYPE: $linked_iid = $linked_item->getLinkedItemID(); $material_manager = $this->_environment->getMaterialManager(); $linked_item = $material_manager->getItem($linked_iid); break; default: $linked_iid = $linked_item->getItemID(); } $entry['link_id'] = $link_item->getItemID(); $entry['linked_iid'] = $linked_iid; $entry['sorting_place'] = $link_item->getSortingPlace(); $module = Type2Module($type); $user = $this->_environment->getCurrentUser(); if (!($module == CS_USER_TYPE && (!$linked_item->isUser() || !$linked_item->maySee($user)))) { if ($linked_item->isNotActivated() && !($linked_item->getCreatorID() === $user->getItemID() || $user->isModerator())) { $activating_date = $linked_item->getActivatingDate(); if (strstr($activating_date, '9999-00-00')) { $link_creator_text .= ' (' . $translator->getMessage('COMMON_NOT_ACTIVATED') . ')'; } else { $link_creator_text .= ' (' . $translator->getMessage('COMMON_ACTIVATING_DATE') . ' ' . getDateInLang($linked_item->getActivatingDate()) . ')'; } if ($module === CS_USER_TYPE) { $title = $linked_item->getFullName(); } else { $title = $linked_item->getTitle(); } $title = $converter->text_as_html_short($title); $entry['module'] = $module; $entry['img'] = $img; $entry['title'] = $link_creator_text; $entry['link_text'] = $title; /* * TODO: check if working $html .= ahref_curl( $this->_environment->getCurrentContextID(), $module, 'detail', $params, '<img src="' . $img . '" style="padding-right:3px;" title="' . $link_creator_text . '"/>', $link_creator_text, '_self', $fragment, '', '', '', 'class="disabled"', '', '', true); $html .= ahref_curl( $this->_environment->getCurrentContextID(), $module, 'detail', $params, $link_title, $link_creator_text, '_self', $fragment, '', '', '', 'class="disabled"', '', '', true); unset($params); */ } else { if ($module === CS_USER_TYPE) { $title = $linked_item->getFullName(); } else { $title = $linked_item->getTitle(); } $title = $converter->text_as_html_short($title); $entry['module'] = $module; $entry['img'] = $img; $entry['title'] = $link_creator_text; $entry['link_text'] = $title; /* * TODO: check if needed - $link_creator_text is empty!!! * * * $html .= ahref_curl( $this->_environment->getCurrentContextID(), $module, 'detail', $params, '<img src="' . $img . '" style="padding-right:3px;" title="' . $link_creator_text . '"/>', $link_creator_text, '_self', $fragment, '', '', '', 'style=""'); $html .= ahref_curl( $this->_environment->getCurrentContextID(), $module, 'detail', $params, $link_title, $link_creator_text, '_self', $fragment, '', '', '', 'style=""'); unset($params); */ } $return['items'][] = $entry; } } } $link_item = $link_items->getNext(); } } return $return; }
function moveRoom(cs_environment $environment, cs_list $afterList, cs_room_item $roomItem, $exec = false, $newPortalId) { $linkedProjectedRoomItems = new cs_list(); if ($exec) { if ($roomItem) { global $environment; $oldPortalId = $roomItem->getContextID(); $portalManager = $environment->getPortalManager(); $oldPortal = $portalManager->getItem($oldPortalId); $userManager = $environment->getUserManager(); $roomList = new cs_list(); $roomList->add($roomItem); // search for associated project rooms in list after this entry if ($roomItem->isCommunityRoom()) { $projectRoomList = $roomItem->getProjectRoomList(); $afterListItem = $afterList->getFirst(); while ($afterListItem) { if ($projectRoomList->inList($afterListItem)) { $linkedProjectedRoomItems->add($afterListItem); } $afterListItem = $afterList->getNext(); } $roomList->addList($linkedProjectedRoomItems); } else if ($roomItem->isGrouproomActive()) { $groupManager = $environment->getGroupManager(); $groupManager->setContextLimit($roomItem->getItemID()); $groupManager->select(); $groupList = $groupManager->get(); if ($groupList->isNotEmpty()) { $groupItem = $groupList->getFirst(); while($groupItem) { if ($groupItem->isGroupRoomActivated()) { $groupRoomItem = $groupItem->getGroupRoomItem(); if (isset($groupRoomItem) && !empty($groupRoomItem)) { $roomList->add($groupRoomItem); } } $groupItem = $groupList->getNext(); } } } $roomNameArray = array(); $userArray = array(); $authSourceArray = array(); $roomListItem = $roomList->getFirst(); while ($roomListItem) { $roomNameArray[$roomListItem->getItemID()] = $roomListItem->getTitle(); $userManager->resetLimits(); $userManager->setContextLimit($roomListItem->getItemID()); $userManager->select(); $userList = $userManager->get(); if ($userList->isNotEmpty()) { $userItem = $userList->getFirst(); while($userItem) { $authSourceArray[$userItem->getAuthSource()] = $userItem->getAuthSource(); $userIdTest = $userItem->getUserID(); if (!empty($userIdTest)) { $userRoomArray[$userItem->getUserID() . "__CS__" . $userItem->getAuthSource()] = $roomListItem->getItemID(); if (empty($userArray[$userItem->getUserID()])) { $portalUserItem = $userItem->getRelatedCommSyUserItem(); if (isset($portalUserItem)) { $userArray[$userItem->getUserID() . "__CS__" . $userItem->getAuthSource()] = $portalUserItem; } } $userIdTest = $userItem->getUserID(); } $userItem = $userList->getNext(); } } $roomListItem = $roomList->getNext(); } $authSourceTranslationArray = array(); $authSourceFindArray = array(); $authSourceItemArray = array(); $newPortal = $portalManager->getItem($newPortalId); $authSourceListNew = $newPortal->getAuthSourceList(); foreach ($authSourceArray as $authSourceId) { $authSourceManager = $environment->getAuthSourceManager(); $authSourceItemOld = $authSourceManager->getItem($authSourceId); $authSourceItemArray[$authSourceItemOld->getItemID()] = $authSourceItemOld; if (!$authSourceListNew->isEmpty()) { $authSourceItemNew = $authSourceListNew->getFirst(); while ($authSourceItemNew) { $authSourceItemArray[$authSourceItemNew->getItemID()] = $authSourceItemNew; if ($authSourceItemOld->isCommSyDefault() && $authSourceItemNew->isCommSyDefault()) { $authSourceTranslationArray[$authSourceItemOld->getItemID()] = $authSourceItemNew->getItemID(); } $authSourceItemNew = $authSourceListNew->getNext(); } } } $authSourceNotTranslationArray = array(); foreach ($authSourceArray as $authSourceId) { if (!array_key_exists($authSourceId, $authSourceTranslationArray)) { $authSourceNotTranslationArray[] = $authSourceId; } } $authSourceManager = $environment->getAuthSourceManager(); foreach ($authSourceNotTranslationArray as $authSourceId) { $authSourceItemOld = $authSourceManager->getItem($authSourceId); $authSourceItemNew = clone $authSourceItemOld; $authSourceItemNew->setItemID(''); $authSourceItemNew->setContextID($newPortalId); $authSourceItemNew->save(); $authSourceTranslationArray[$authSourceItemOld->getItemID()] = $authSourceItemNew->getItemID(); $authSourceItemArray[$authSourceItemNew->getItemID()] = $authSourceItemNew; } $userArrayAll = $userArray; $userArrayNew = array(); $failure = false; $userChangeArray = array(); foreach ($userArrayAll as $key => $userItem) { // does the user exist on current portal? $authentication = $environment->getAuthenticationObject(); $userId = $userItem->getUserID(); $authSource = $userItem->getAuthSource(); $first = true; $go = true; while ($go) { $userManager->resetLimits(); $userManager->setContextLimit($newPortalId); $userManager->setAuthSourceLimit($authSourceTranslationArray[$authSource]); $userManager->setUserIDLimit($userId); $userManager->select(); $userList = $userManager->get(); // commsy auth source, user id already exists if ($userList->isNotEmpty() && $userList->getCount() == 1) { $userItem2 = $userList->getFirst(); // email is equal if ($userItem2->getEmail() == $userItem->getEmail()) { unset($userArray[$userItem->getUserID() . "__CS__" . $userItem->getAuthSource()]); if ($userItem->getUserID() != $userId) { $userChangeArray[$userItem->getUserID() . "__CS__" . $authSourceTranslationArray[$authSource]] = $userId; } else { $userArrayNoChange[$userItem->getUserID() . "__CS__" . $authSourceTranslationArray[$authSource]] = $userItem; } $go = false; } else { // generate new user id if ($first) { $first = false; $userId .= '1'; } else { $count = $userId{mb_strlen($userId) - 1}; $count = (int) $count; $count++; $userId = mb_substr($userId, 0, mb_strlen($userId) - 1); $userId .= $count; } } } elseif ($userList->isNotEmpty() && $userList->getCount() > 1) { include_once('functions/error_functions.php'); trigger_error('ERROR: multiple user id ' . $userId . ' for one portal',E_USER_WARNING); $go = false; $failure = true; } else { // find free user id if ($userItem->getUserID() != $userId) { $userChangeArray[$userItem->getUserID() . "__CS__" . $authSourceTranslationArray[$authSource]] = $userId; } else { $userArrayNoChange[$userItem->getUserID() . "__CS__" . $authSourceTranslationArray[$authSource]] = $userItem; } $go = false; } } } if ($failure) { die("ERROR"); } // commsy auth source // copy auth (user_id and password) and user (normal information) items foreach ($userArray as $key => $userItem) { $keyArray = explode("__CS__", $key); $userIdKey = $keyArray[0]; $authSourceKey = $keyArray[1]; // old auth source $authManager = $authentication->getAuthManager($userItem->getAuthSource()); $authManager->setContextLimit($oldPortalId); $authItemOld = $authManager->getItem($userItem->getUserID()); if (!empty($authItemOld)) { $authItemNew = clone $authItemOld; $authItemNew->setPortalID($newPortalId); $authItemNew->setAuthSourceID($authSourceTranslationArray[$authSourceKey]); if (!empty($userChangeArray[$userIdKey . "__CS__" . $authSourceTranslationArray[$authSourceKey]])) { $authItemNew->setUserID($userChangeArray[$userIdKey . "__CS__" . $authSourceTranslationArray[$authSourceKey]]); } $authManager = $authentication->getAuthManager($authSourceTranslationArray[$authSourceKey]); $authManager->setContextLimit($newPortalId); $userIdAuthNew = $authItemNew->getUserID(); if (!empty($userIdAuthNew)) { $authManager->save($authItemNew); } } unset ($userIdAuthNew); $userItemNew = $userItem->cloneData(); $userItemNew->setContextID($newPortalId); $tempUser = $userManager->getItem($userItem->getCreatorID()); $userItemNew->setCreatorItem($tempUser); if (!empty($userChangeArray[$userIdKey . "__CS__" . $authSourceTranslationArray[$authSourceKey]])) { $userItemNew->setUserID($userChangeArray[$userIdKey . "__CS__" . $authSourceTranslationArray[$authSourceKey]]); } $userIdUserNew = $userItemNew->getUserID(); $userItemNew->setAuthSource($authSourceTranslationArray[$authSourceKey]); if (!empty($userIdUserNew)) { $userItemNew->save(); $userItemNew->setCreatorID2ItemID(); } } // external auth sources foreach ($userArrayNew as $key => $userItem) { $keyArray = explode("__CS__", $key); $userIdKey = $keyArray[0]; $authSourceKey = $keyArray[1]; $userItemnew = $userItem->cloneData(); $userItemNew->setContextID($newPortalId); $tempUser = $userManager->getItem($userItem->getCreatorID()); $userItemNew->setCreatorItem($tempUser); $userIdUserNew = $userItemNew->getUserID(); $userItemNew->setAuthSource($authSourceKey); if (!empty($userIdUserNew)) { $userItemNew->save(); $userItemNew->setCreatorID2ItemID(); } } // change user ids of user in rooms to move // and cahnge auth source of user in rooms to move $roomListItem = $roomList->getFirst(); while ($roomListItem) { $userManager = $environment->getUserManager(); $userManager->resetLimits(); $userManager->setContextLimit($roomListItem->getItemID()); $userManager->select(); $userList = $userManager->get(); if ($userList->isNotEmpty()) { $userItem = $userList->getFirst(); while ($userItem) { $userIdTest = $userItem->getUserID(); if (!empty($userIdTest) && !empty($userChangeArray[$userIdTest . "__CS__" . $authSourceTranslationArray[$userItem->getAuthSource()]])) { $userItem->setUserID($userChangeArray[$userIdTest . "__CS__" . $authSourceTranslationArray[$userItem->getAuthSource()]]); } $newAuthSourceForUser = $authSourceTranslationArray[$userItem->getAuthSource()]; $userItem->setAuthSource($newAuthSourceForUser); $userItem->setChangeModificationOnSave(false); $userItem->setSaveWithoutLinkModifier(); $userItem->save(); $userItem = $userList->getNext(); } } // delete old links from community room to project rooms // before saving on new potal if ($linkedProjectedRoomItems->isEmpty() && $roomListItem->isCommunityRoom()) { $roomListItem->setProjectListByID(array()); $roomListItem->save(); } // move files from old portal folder to new portal folder $oldContext = $roomListItem->getContextID(); $newContext = $newPortalId; if ($oldContext != $newContext) { $discManager = $environment->getDiscManager(); $discManager->moveFiles($roomListItem->getItemID(), $oldContext, $newContext); } $roomListItem->setContextID($newPortalId); // set link between project and community room if ($linkedProjectedRoomItems->isNotEmpty() && $roomListItem->isProjectRoom()) { $tempArray = array(); $tempArray[] = $roomItem->getItemID(); $roomListItem->setCommunityListByID($tempArray); } // save room with new context id $roomListItem->save(); echo ProgressBar::next(); $roomListItem = $roomList->getNext(); } } } else { usleep(1000); echo ProgressBar::next(); } return $linkedProjectedRoomItems; }
public function actionQuery() { $return = array("items" => array()); $start = $this->_data["options"]["start"]; $numEntries = $this->_data["options"]["numEntries"]; $itemManager = $this->_environment->getItemManager(); $currentUser = $this->_environment->getCurrentUserItem(); // collection room ids $room_id_array = array(); $grouproom_list = $currentUser->getUserRelatedGroupList(); if (isset($grouproom_list) and $grouproom_list->isNotEmpty()) { $grouproom_list->reverse(); $grouproom_item = $grouproom_list->getFirst(); while ($grouproom_item) { $project_room_id = $grouproom_item->getLinkedProjectItemID(); if (in_array($project_room_id, $room_id_array)) { $room_id_array_temp = array(); foreach ($room_id_array as $value) { $room_id_array_temp[] = $value; if ($value == $project_room_id) { $room_id_array_temp[] = $grouproom_item->getItemID(); } } $room_id_array = $room_id_array_temp; } $grouproom_item = $grouproom_list->getNext(); } } $project_list = $currentUser->getUserRelatedProjectList(); if (isset($project_list) and $project_list->isNotEmpty()) { $project_item = $project_list->getFirst(); while ($project_item) { $room_id_array[] = $project_item->getItemID(); $project_item = $project_list->getNext(); } } $community_list = $currentUser->getUserRelatedCommunityList(); if (isset($community_list) and $community_list->isNotEmpty()) { $community_item = $community_list->getFirst(); while ($community_item) { $room_id_array[] = $community_item->getItemID(); $community_item = $community_list->getNext(); } } $room_id_array_without_privateroom = $room_id_array; $itemManager->setOrderLimit(true); if (isset($room_id_array_without_privateroom) && !empty($room_id_array_without_privateroom)) { $new_entry_array = $itemManager->getAllNewPrivateRoomEntriesOfRoomList($room_id_array_without_privateroom); $new_entry_list = $itemManager->getPrivateRoomHomeItemList($new_entry_array); } else { $new_entry_list = new cs_list(); } // sort list $new_entry_list->sortby("modification_date"); $new_entry_list->reverse(); // prepare return $entry = $new_entry_list->getFirst(); $count = 0; while ($entry) { if ($count >= $start && $count < $start + $numEntries) { $type = $entry->getItemType(); if ($type == CS_LABEL_TYPE) { $labelManager = $this->_environment->getLabelManager(); $entry = $labelManager->getItem($entry->getItemID()); $type = $entry->getLabelType(); } else { $manager = $this->_environment->getManager($type); $entry = $manager->getItem($entry->getItemID()); } if (isset($entry) and !empty($entry)) { // skip portfolio if ($entry->getType() !== CS_PORTFOLIO_TYPE) { $moddate = $entry->getModificationDate(); if (mb_strstr($moddate, '9999-00-00')) { $mod_date = "'"; } else { if ($entry->getCreationDate() != $entry->getModificationDate()) { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($entry->getModificationDate()); } else { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($entry->getCreationDate()); } } if ($type === CS_MATERIAL_TYPE) { $versionId = $entry->getVersionID(); } else { $versionId = null; } $return["items"][] = array("itemId" => $entry->getItemID(), "contextId" => $entry->getContextID(), "module" => Type2Module($type), "title" => $entry->getTitle(), "image" => $this->getUtils()->getLogoInformationForType($type), "fileCount" => $entry->getFileList()->getCount(), "modificationDate" => $mod_date, "creator" => $entry->getCreatorItem()->getFullName(), "versionId" => $versionId); } } } if (isset($entry) && !empty($entry) && $entry->getType() !== CS_PORTFOLIO_TYPE) { $count++; } $entry = $new_entry_list->getNext(); } $return["total"] = $count; $this->setSuccessfullDataReturn($return); echo $this->_return; }
############################################### # connection to other commsys ############################################### if ($context_item->isServer()) { $link_item = new cs_link(); $link_item->setTitle($translator->getMessage('CONFIGURATION_CONNECTION')); $link_item->setIconPath('images/cs_config/PORTAL_ENTER_NEW.gif'); $link_item->setDescription($translator->getMessage('CONFIGURATION_CONNECTION_DESC')); $link_item->setContextID($environment->getCurrentContextID()); $link_item->setModule('configuration'); $link_item->setFunction('connection'); $addon_link_list->add($link_item); } ############################################# # export import ############################################# $context_item = $environment->getCurrentContextItem(); if ($context_item->isPortal()) { $link_item = new cs_link(); $link_item->setTitle($translator->getMessage('CONFIGURATION_EXPORT_IMPORT_LINK')); $link_item->setIconPath('images/cs_config/CONFIGURATION_EXTRA_FORM.gif'); $link_item->setDescription($translator->getMessage('CONFIGURATION_EXPORT_IMPORT_DESC')); $link_item->setContextID($environment->getCurrentContextID()); $link_item->setModule('configuration'); $link_item->setFunction('export_import'); $link_item->setParameter(array('iid' => $environment->getCurrentContextID())); $addon_link_list->add($link_item); } if ($addon_link_list->getFirst()) { $addon_link_list->sortby('title'); }
$date_item = $date_manager->getItem($date_item->getItemId()); $new_date_list->add($date_item); $current_context = $environment->getCurrentContextID(); if ($date_item->getContextID() != $current_context){ $checkedDateIds[] = $date_item->getItemID(); } break; } else { $date_item = $date_list->getNext(); } } } } // Termine anderer Räume $room_sort = $rooms->getFirst(); while ($room_sort) { if (!empty($date_id_array)) { foreach($date_id_array as $date_id) { $date_item = $date_list->getFirst(); while($date_item) { if($date_item->getItemID() == $date_id and $date_item->getContextID() == $room_sort->getItemId()) { $date_item = $date_manager->getItem($date_item->getItemId()); $new_date_list->add($date_item); $current_context = $environment->getCurrentContextID(); if ($date_item->getContextID() != $current_context){ $checkedDateIds[] = $date_item->getItemID(); } break; } else { $date_item = $date_list->getNext();
public function getRoomList($session_id) { $retour = ''; $session_id = $this->_encode_input($session_id); if ($this->_isSessionValid($session_id)) { $this->_environment->setSessionID($session_id); $session = $this->_environment->getSessionItem(); $user_id = $session->getValue('user_id'); $auth_source_id = $session->getValue('auth_source'); $context_id = $session->getValue('commsy_id'); $this->_environment->setCurrentContextID($context_id); $hash_manager = $this->_environment->getHashManager(); $user_manager = $this->_environment->getUserManager(); $user_manager->setContextLimit($context_id); $user_manager->setUserIDLimit($user_id); $user_manager->setAuthSourceLimit($auth_source_id); $user_manager->select(); $user_list = $user_manager->get(); if ($user_list->getCount() == 1) { $user_item = $user_list->getFirst(); if (!empty($user_item)) { $this->_environment->setCurrentUserItem($user_item); } $own_room = $user_item->getOwnRoom(); $list = $own_room->getCustomizedRoomList(); if (!(isset($list) and $list->isNotEmpty())) { $community_list = $user_item->getRelatedCommunityList(); $project_list = $user_item->getRelatedProjectListForMyArea(); $group_list = $user_item->getRelatedGroupList(); $class_factory = $this->_environment->getClassFactory(); include_once 'classes/cs_list.php'; $list = new cs_list(); if (!empty($community_list) and $community_list->isNotEmpty()) { $list->addList($community_list); } if (!empty($project_list) and $project_list->isNotEmpty()) { $list->addList($project_list); } if (!empty($group_list) and $group_list->isNotEmpty()) { $list->addList($group_list); } } unset($user_item); if (isset($list) and $list->isNotEmpty()) { $retour = '<?xml version="1.0" encoding="utf-8"?>' . LF; $retour .= ' <list>' . LF; // portal $item = $this->_environment->getCurrentPortalItem(); $retour .= ' <item>' . LF; $retour .= ' <title><![CDATA[' . $item->getTitle() . ']]></title>' . LF; if ($item->getItemID() > 99) { $retour .= ' <id><![CDATA[' . $item->getItemID() . ']]></id>' . LF; global $c_commsy_domain, $c_commsy_url_path; include_once 'functions/curl_functions.php'; $retour .= ' <url><![CDATA[' . $c_commsy_domain . $c_commsy_url_path . '/' . _curl(false, $item->getItemID(), 'home', 'index', array()) . ']]></url>' . LF; } $retour .= ' </item>' . LF; $retour .= ' <item>' . LF; $retour .= ' <title>-------------------------------</title>' . LF; $retour .= ' <id></id>' . LF; $retour .= ' </item>' . LF; // own room $item = $own_room; $retour .= ' <item>' . LF; $translator = $this->_environment->getTranslationObject(); $retour .= ' <title><![CDATA[' . $translator->getMessage($item->getTitle()) . ']]></title>' . LF; if ($item->getItemID() > 99) { $retour .= ' <id><![CDATA[' . $item->getItemID() . ']]></id>' . LF; global $c_commsy_domain, $c_commsy_url_path; include_once 'functions/curl_functions.php'; $retour .= ' <url><![CDATA[' . $c_commsy_domain . $c_commsy_url_path . '/' . _curl(false, $item->getItemID(), 'home', 'index', array()) . ']]></url>' . LF; // rss if ($item->isRSSOn()) { $own_room_user_item = $item->getOwnerUserItem(); if (!empty($own_room_user_item)) { $rss_hash = $hash_manager->getRSSHashForUser($own_room_user_item->getItemID()); if (!empty($rss_hash)) { global $c_commsy_domain, $c_commsy_url_path; $rss_url = $c_commsy_domain . $c_commsy_url_path . '/rss.php?cid=' . $item->getItemID() . '&hid=' . $rss_hash; $retour .= ' <rss><![CDATA[' . $rss_url . ']]></rss>' . LF; } unset($rss_hash); unset($rss_url); } } } $retour .= ' </item>' . LF; $retour .= ' <item>' . LF; $retour .= ' <title>-------------------------------</title>' . LF; $retour .= ' <id></id>' . LF; $retour .= ' </item>' . LF; $item = $list->getFirst(); while ($item) { $retour .= ' <item>' . LF; $retour .= ' <title><![CDATA[' . $item->getTitle() . ']]></title>' . LF; if ($item->getItemID() > 99) { $retour .= ' <id><![CDATA[' . $item->getItemID() . ']]></id>' . LF; global $c_commsy_domain, $c_commsy_url_path; include_once 'functions/curl_functions.php'; $retour .= ' <url><![CDATA[' . $c_commsy_domain . $c_commsy_url_path . '/' . _curl(false, $item->getItemID(), 'home', 'index', array()) . ']]></url>' . LF; // rss if ($item->isRSSOn()) { $user_room_item = $item->getUserByUserID($user_id, $auth_source_id); if (!empty($user_room_item) and !empty($hash_manager)) { $rss_hash = $hash_manager->getRSSHashForUser($user_room_item->getItemID()); if (!empty($rss_hash)) { global $c_commsy_domain, $c_commsy_url_path; $rss_url = $c_commsy_domain . $c_commsy_url_path . '/rss.php?cid=' . $item->getItemID() . '&hid=' . $rss_hash; $retour .= ' <rss><![CDATA[' . $rss_url . ']]></rss>' . LF; } unset($rss_hash); unset($rss_url); } } } $retour .= ' </item>' . LF; $item = $list->getNext(); } unset($hash_manager); $retour .= ' </list>' . LF; unset($list); $result = $this->_encode_output($retour); } if (!empty($retour)) { $result = $this->_encode_output($retour); } unset($own_room); unset($user_item); } else { $info = 'ERROR: GET ROOM LIST'; $info_text = 'database error: user (' . $user_id . ',' . $auth_source_id . ',' . $context_id . ') not equal'; $result = new SoapFault($info, $info_text); } unset($user_list); unset($user_manager); unset($session); } else { $info = 'ERROR: GET ROOM LIST'; $info_text = 'session id (' . $session_id . ') is not valid'; $result = new SoapFault($info, $info_text); } return $result; }
$group_item = $group_list->getNext(); } } } ############################################ # FLAG: group rooms ############################################ // select user (portal) array // and init room array with room titles // and init user_link_room_array $room_name_array = array(); $user_array = array(); $auth_source_array = array(); $room_item = $room_list->getFirst(); while ($room_item) { $room_name_array[$room_item->getItemID()] = $room_item->getTitle(); $user_manager->resetLimits(); $user_manager->setContextLimit($room_item->getItemID()); $user_manager->select(); $user_list = $user_manager->get(); if ($user_list->isNotEmpty()) { $user_item = $user_list->getFirst(); while ($user_item) { $auth_source_array[$user_item->getAuthSource()] = $user_item->getAuthSource(); $user_id_test = $user_item->getUserID(); if (!empty($user_id_test)) { $user_room_array[strtoupper($user_item->getUserID()).'__CS__'.$user_item->getAuthSource()][] = $room_item->getItemID(); if (empty($user_array[strtoupper($user_item->getUserID())])) { $portal_user_item = $user_item->getRelatedCommSyUserItem();
public function actionQuery() { $return = array("items" => array()); $start = $this->_data["options"]["start"]; $numEntries = $this->_data["options"]["numEntries"]; $query = $this->_data["query"]; if (isset($this->_data["options"]["filter"])) { $filter = $this->_data["options"]["filter"]; } else { $filter = array(); } $currentUserItem = $this->_environment->getCurrentUserItem(); $privateRoomItem = $currentUserItem->getOwnRoom(); // collect data of interest $roomIdArray = array(); $roomNameArray = array(); $rubricArray = array(); if (!empty($filter)) { foreach ($filter["rooms"] as $filterRoom) { if ($filterRoom["active"]) { $roomIdArray[] = $filterRoom["id"]; $roomNameArray[$filterRoom["id"]] = $filterRoom["title"]; } } } else { // project and group rooms $projectRoomList = $currentUserItem->getUserRelatedProjectList(); $projectRoomItem = $projectRoomList->getFirst(); while ($projectRoomItem) { $roomIdArray[] = $projectRoomItem->getItemID(); $roomNameArray[$projectRoomItem->getItemID()] = $projectRoomItem->getTitle(); $projectRoomItem = $projectRoomList->getNext(); } // community rooms $communityRoomList = $currentUserItem->getUserRelatedCommunityList(); $communityRoomItem = $communityRoomList->getFirst(); while ($communityRoomItem) { $roomIdArray[] = $communityRoomItem->getItemID(); $roomNameArray[$communityRoomItem->getItemID()] = $communityRoomItem->getTitle(); $communityRoomItem = $communityRoomList->getNext(); } // private room //$roomIdArray[] = $privateRoomItem->getItemID(); //$roomNameArray[$privateRoomItem->getItemID()] = $privateRoomItem->getTitle(); } // determe the rubrics to search in if (!empty($filter)) { foreach ($filter["rubrics"] as $filterRubric) { if ($filterRubric["active"] && in_array($filterRubric["type"], array(CS_DISCUSSION_TYPE, CS_DATE_TYPE, CS_TODO_TYPE))) { $rubricArray[] = $filterRubric["type"]; } } } else { $rubricArray[] = CS_DISCUSSION_TYPE; $rubricArray[] = CS_DATE_TYPE; $rubricArray[] = CS_TODO_TYPE; } /* * only three rubrics are handled in the following foreach loop * maybe these are the only managers that are able to handle context arrays??? * however, setting context array limits in other managers seems not to work */ // get search results from all relevant managers $searchResults = new cs_list(); foreach ($rubricArray as $rubric) { $manager = $this->_environment->getManager($rubric); $manager->setContextArrayLimit($roomIdArray); if ($rubric == CS_DATE_TYPE) { $manager->setWithoutDateModeLimit(); } if (!empty($query)) { $manager->setSearchLimit($query); } $manager->showNoNotActivatedEntries(); $manager->select(); $searchResults->addList($manager->get()); } // redefine rubric array if (!empty($filter)) { $rubricArray = array(); foreach ($filter["rubrics"] as $filterRubric) { if ($filterRubric["active"] && in_array($filterRubric["type"], array(CS_MATERIAL_TYPE, CS_ANNOUNCEMENT_TYPE, CS_TOPIC_TYPE))) { $rubricArray[] = $filterRubric["type"]; } } } else { $rubricArray = array(CS_MATERIAL_TYPE, CS_ANNOUNCEMENT_TYPE, CS_TOPIC_TYPE); } // materials foreach ($roomIdArray as $roomId) { foreach ($rubricArray as $rubric) { $rubricManager = $this->_environment->getManager($rubric); $rubricManager->setContextLimit($roomId); if (!empty($query)) { $rubricManager->setSearchLimit($query); } $rubricManager->showNoNotActivatedEntries(); $rubricManager->select(); $searchResults->addList($rubricManager->get()); } } // announcements foreach ($roomIdArray as $roomId) { $annoucementManager = $this->_environment->getManager(CS_ANNOUNCEMENT_TYPE); $annoucementManager->setContextLimit($roomId); } // sort list $searchResults->sortby("modification_date"); $searchResults->reverse(); // prepare return $entry = $searchResults->getFirst(); $count = 0; while ($entry) { if ($count >= $start && $count < $start + $numEntries) { $type = $entry->getItemType(); if ($type == CS_LABEL_TYPE) { $labelManager = $this->_environment->getLabelManager(); $entry = $labelManager->getItem($entry->getItemID()); $type = $entry->getLabelType(); } else { $manager = $this->_environment->getManager($type); $entry = $manager->getItem($entry->getItemID()); } if (isset($entry) and !empty($entry)) { // skip portfolio if ($entry->getType() !== CS_PORTFOLIO_TYPE) { $moddate = $entry->getModificationDate(); if ($entry->getCreationDate() != $entry->getModificationDate() && !strstr($moddate, '9999-00-00')) { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($entry->getModificationDate()); } else { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($entry->getCreationDate()); } if ($type === CS_MATERIAL_TYPE) { $versionId = $entry->getVersionID(); } else { $versionId = null; } $return["items"][] = array("itemId" => $entry->getItemID(), "contextId" => $entry->getContextID(), "module" => Type2Module($type), "title" => $entry->getTitle(), "image" => $this->getUtils()->getLogoInformationForType($type), "fileCount" => $entry->getFileList()->getCount(), "modificationDate" => $mod_date, "creator" => $entry->getCreatorItem()->getFullName(), "versionId" => $versionId, "roomName" => $roomNameArray[$entry->getContextID()]); } } } if (isset($entry) && !empty($entry) && $entry->getType() !== CS_PORTFOLIO_TYPE) { $count++; } $entry = $searchResults->getNext(); } $return["total"] = $count; $this->setSuccessfullDataReturn($return); echo $this->_return; }
private function _actionPerformRequest($archive_toggle = false) { // archive if ($archive_toggle) { $this->_environment->toggleArchiveMode(); } // archive $return = array(); $current_context = $this->_environment->getCurrentContextItem(); $current_user = $this->_environment->getCurrentUser(); $session = $this->_environment->getSessionItem(); $project_manager = $this->_environment->getProjectManager(); $community_manager = $this->_environment->getCommunityManager(); $private_room_manager = $this->_environment->getPrivateRoomManager(); $group_room_manager = $this->_environment->getGroupRoomManager(); $link_manager = $this->_environment->getLinkManager(); $noticed_manager = $this->_environment->getNoticedManager(); $room_manager = $this->_environment->getProjectManager(); $current_context = $this->_environment->getCurrentContextItem(); $session = $this->_environment->getSession(); $translator = $this->_environment->getTranslationObject(); // get current room modules $current_room_modules = $current_context->getHomeConf(); $room_moduls = array(); if (!empty($current_room_modules)) { $room_modules = explode(",", $current_room_modules); } $modules = array(); foreach ($room_modules as $module) { list($name, $display) = explode("_", $module); if ($display !== "none") { $modules[] = $name; } } $rubric_copy_array = $this->getUtils()->getCopyRubrics(); $item_room_ids = array(); $tmp_id_array = array(); $item_list = new cs_list(); // collect room and item ids foreach ($rubric_copy_array as $rubric) { $item_manager = $this->_environment->getManager($rubric); $item_id_array = $session->getValue($rubric . "_clipboard"); $item_list->addList($item_manager->getItemList($item_id_array)); $item = $item_list->getFirst(); while ($item) { $item_room_ids[] = $item->getContextID(); $item = $item_list->getNext(); } if (is_array($item_id_array)) { $tmp_id_array = array_merge($tmp_id_array, $item_id_array); } } $item_id_array = $tmp_id_array; // create a list of rooms $rooms = new cs_list(); $rooms->addList($project_manager->getSortedItemList($item_room_ids, "title")); $rooms->addList($community_manager->getSortedItemList($item_room_ids, "title")); $rooms->addList($private_room_manager->getSortedItemList($item_room_ids, "title")); $rooms->addList($group_room_manager->getSortedItemList($item_room_ids, "title")); // get item information $new_item_list = new cs_list(); $checked_ids = array(); if (!empty($item_id_array)) { foreach ($item_id_array as $item_id) { $item = $item_list->getFirst(); while ($item) { if ($item->getItemID() == $item_id && $item->getContextID() === 0) { $item_manager = $this->_environment->getManager($item->getItemType()); $item = $item_manager->getItem($item->getItemId()); $new_item_list->add($item); if ($item->getContextID() !== $current_context->getItemID()) { $checked_ids[] = $item->getItemID(); } break; } else { $item = $item_list->getNext(); } } } } $room_sort = $rooms->getFirst(); while ($room_sort) { if (!empty($item_id_array)) { foreach ($item_id_array as $item_id) { $item = $item_list->getFirst(); while ($item) { if ($item->getItemID() == $item_id && $item->getContextID() == $room_sort->getItemId()) { $item_manager = $this->_environment->getManager($item->getItemType()); $item = $item_manager->getItem($item->getItemId()); $new_item_list->add($item); if (isset($item) && $item->getContextID() !== $current_context->getItemID()) { $checked_ids[] = $item->getItemID(); } break; } else { $item = $item_list->getNext(); } } } } $room_sort = $rooms->getNext(); } $item_list = $new_item_list; // prepare return $data = array(); $entry = $item_list->getFirst(); if ($entry) { $last_room_id = $entry->getContextID(); } $index = 0; while ($entry) { if ($entry->isDeleted()) { $entry = $item_list->getNext(); continue; } $room_id = $entry->getContextID(); if ($last_room_id != $room_id) { $index++; } $last_room_id = $room_id; // room data if (!isset($data[$index])) { $data[$index]["room_id"] = $last_room_id; $room = $room_manager->getItem($last_room_id); // if $room is null, try to get a private room if ($room === null) { $room = $private_room_manager->getItem($last_room_id); } $headline = ""; if (empty($room)) { $community_manager->getItem($room_id); $room = $community_manager->getItem($room_id); $headline = $translator->getMessage("COPY_FROM") . " " . $translator->getMessage("COMMON_COMMUNITY_ROOM_TITLE") . " \"" . $room->getTitle() . "\""; } elseif ($room->isPrivateRoom()) { $headline = $translator->getMessage("COPY_FROM_PRIVATEROOM") . " \"" . $current_user->getFullname() . "\""; } elseif ($room->isGroupRoom()) { $headline = $translator->getMessage("COPY_FROM_GROUPROOM") . " \"" . $room->getTitle() . "\""; } else { $headline = $translator->getMessage("COPY_FROM_PROJECTROOM") . " \"" . $room->getTitle() . "\""; } $data[$index]["headline"] = $headline; } // process title $title = $entry->getTitle(); if ($entry->isNotActivated()) { $activating_date = $entry->getActivatingDate(); if (mb_strstr($activating_date, "9999-00-00")) { $title .= BR . $translator->getMessage('COMMON_NOT_ACTIVATED'); } else { $title .= BR . $translator->getMessage('COMMON_NOT_ACTIVATED') . " " . getDateInLang($entry->getActivatingDate()); } } $disabled = false; if ($entry->isNotActivated() && !($entry->getCreatorID() == $current_user->getItemID() || $current_user->isModerator())) { $disabled = true; } // item data $data[$index]["items"][] = array("disabled" => $disabled, "item_id" => $entry->getItemID(), "title" => $title, "rubric" => $this->getUtils()->getLogoInformationForType($entry->getItemType()), "modifier" => $entry->getModificatorItem()->getFullName(), "modification_date" => getDateInLang($entry->getModificationDate())); $entry = $item_list->getNext(); } // archive if ($archive_toggle) { $this->_environment->toggleArchiveMode(); } // archive return $data; }
$session->setValue('cid' . $environment->getCurrentContextID() . '_' . $environment->getCurrentModule() . '_buzzword_ids', $buzzword_array); $session_post_vars = $session->getValue('buzzword_post_vars'); } } elseif (!empty($command) and isOption($command, $translator->getMessage('COMMON_BUZZWORD_ADD'))) { if (!empty($_POST['attach_new_buzzword'])) { // set session item $session_item = $environment->getSessionItem(); $buzzword_attach_list = $session_item->getValue('buzzword_add'); $exist = false; if (!$session_item->issetValue('buzzword_add')) { $buzzword_attach_list = new cs_list(); } else { // check for duplicated entries in new buzzword list $buzzword_manager = $environment->getLabelManager(); if (!empty($buzzword_attach_list)) { $buzzword = $buzzword_attach_list->getFirst(); while ($buzzword) { if (strcmp($buzzword, ltrim($_POST['attach_new_buzzword'])) == 0) { $exist = true; break; } $buzzword = $buzzword_attach_list->getNext(); } } } // check for duplicated entries in existing buzzword list $buzzword_manager = $environment->getLabelManager(); $buzzword_manager->reset(); $buzzword_manager->setContextLimit($environment->getCurrentContextID()); $buzzword_manager->setTypeLimit('buzzword'); $buzzword_manager->select();
public function actionGetListContent() { $return = array("items" => array()); $search = $this->_data["search"]; $start = $this->_data["start"]; $numEntries = $this->_data["numEntries"]; $buzzwordIds = $this->_data["buzzwordRestrictions"]; $tagIds = $this->_data["tagRestrictions"]; $currentUser = $this->_environment->getCurrentUserItem()->getRelatedPrivateRoomUserItem(); $itemManager = $this->_environment->getItemManager(); $privateRoomItem = $currentUser->getOwnRoom(); $userIdArray = array($currentUser->getItemID()); $privateRoomIdArray = array($privateRoomItem->getItemID()); $itemManager->setOrderLimit(true); if ($search) { $itemManager->setSearchLimit($search); } if ($buzzwordIds) { $itemManager->setBuzzwordLimit($buzzwordIds[0]); } if ($tagIds) { $itemManager->setTagLimit($tagIds[0]); } /* * finaly removed? * if (!empty($sellist) and $sellist != 'new'){ $item_manager->setListLimit($sellist); } if (!empty($selmatrix)){ $item_manager->setMatrixLimit($selmatrix); } */ $entryList = $itemManager->getAllPrivateRoomEntriesOfUserList($privateRoomIdArray, $userIdArray); #pr($entryList); // ToDo: Nur Einträge in der Liste belassen, die auch angezeigt werden -> sonst gibt es leere Seiten über die geblättert wird! $rubricArray = array(CS_ANNOUNCEMENT_TYPE, CS_DISCUSSION_TYPE, CS_DATE_TYPE, CS_MATERIAL_TYPE, CS_TODO_TYPE); $filteredList = new cs_list(); $entry = $entryList->getFirst(); while ($entry) { if (in_array($entry->getItemType(), $rubricArray)) { $filteredList->add($entry); } $entry = $entryList->getNext(); } // prepare return $entry = $filteredList->getFirst(); $count = 0; while ($entry) { if ($count >= $start && $count < $start + $numEntries) { $type = $entry->getItemType(); if ($type == CS_LABEL_TYPE) { $labelManager = $this->_environment->getLabelManager(); $entry = $labelManager->getItem($entry->getItemID()); $type = $entry->getLabelType(); } else { $manager = $this->_environment->getManager($type); $entry = $manager->getItem($entry->getItemID()); } if ($entry != null) { $moddate = $entry->getModificationDate(); if ($entry->getCreationDate() != $entry->getModificationDate() and !strstr($moddate, '9999-00-00')) { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($entry->getModificationDate()); } else { $mod_date = $this->_environment->getTranslationObject()->getDateInLang($entry->getCreationDate()); } if ($type === CS_MATERIAL_TYPE) { $versionId = $entry->getVersionID(); } else { $versionId = null; } $return["items"][] = array("itemId" => $entry->getItemID(), "contextId" => $entry->getContextID(), "module" => Type2Module($type), "title" => $entry->getTitle(), "image" => $this->getUtils()->getLogoInformationForType($type), "fileCount" => $entry->getFileList()->getCount(), "modificationDate" => $mod_date, "versionId" => $versionId); } } $count++; $entry = $filteredList->getNext(); } $return["total"] = $count; $this->setSuccessfullDataReturn($return); echo $this->_return; }
function _sendPrivateRoomNewsletter() { if (!$this->_send_newsletter) { include_once 'functions/misc_functions.php'; $time_start = getmicrotime(); $retour = array(); $retour['title'] = 'privateroom newsletter'; $retour['description'] = 'send activity newsletter to private room user'; $retour['success'] = false; $retour['success_text'] = 'cron failed'; // get user in room $user = $this->getOwnerUserItem(); if (isset($user) and $this->isPrivateRoomNewsletterActive() and $this->isPrivateroom()) { $url_to_portal = ''; $portal_item = $this->getContextItem(); if (!empty($portal_item)) { $url_to_portal = $portal_item->getURL(); } global $c_commsy_cron_path; if (isset($c_commsy_cron_path)) { $curl_text = $c_commsy_cron_path . 'commsy.php?cid='; } elseif (!empty($url_to_portal)) { $c_commsy_domain = $this->_environment->getConfiguration('c_commsy_domain'); if (stristr($c_commsy_domain, 'https://')) { $curl_text = 'https://'; } else { $curl_text = 'http://'; } $curl_text .= $url_to_portal; $file = 'commsy.php'; $c_single_entry_point = $this->_environment->getConfiguration('c_single_entry_point'); if (!empty($c_single_entry_point)) { $file = $c_single_entry_point; } $curl_text .= '/' . $file . '?cid='; } else { $file = $_SERVER['PHP_SELF']; $file = str_replace('cron_new', 'commsy', $file); $file = str_replace('cron', 'commsy', $file); $curl_text = 'http://' . $_SERVER['HTTP_HOST'] . $file . '?cid='; } $mail_array = array(); $mail_array[] = $user->getEmail(); // get activity informations for room and send mail if (!empty($mail_array)) { // email $id = $user->getItemID(); $portal = $this->getContextItem(); $room_manager = $this->_environment->getRoomManager(); $list = $this->getCustomizedRoomList(); if (!isset($list)) { $list = $room_manager->_getRelatedContextListForUser($user->getUserID(), $user->getAuthSource(), $portal->getItemID(), true, true); } $list2 = new cs_list(); if (!$list->isEmpty()) { $item = $list->getFirst(); while ($item) { if ($item->isPrivateRoom() or !$item->isShownInPrivateRoomHomeByItemID($id) or !$item->isOpen() or $item->getItemID() < 0) { // do nothing } else { $list2->add($item); } unset($item); $item = $list->getNext(); } unset($item); unset($list); } $translator = $this->_environment->getTranslationObject(); $translator->setRubricTranslationArray($this->getRubricTranslationArray()); $mail_sequence = $this->getPrivateRoomNewsletterActivity(); $body = ''; $item = $list2->getFirst(); while ($item) { $conf = $item->getHomeConf(); if (!empty($conf)) { $rubrics = explode(',', $conf); } else { $rubrics = array(); } $count = count($rubrics); $check_managers = array(); $check_rubrics = array(); foreach ($rubrics as $rubric) { list($rubric_name, $rubric_status) = explode('_', $rubric); if ($rubric_status != 'none') { $check_managers[] = $rubric_name; if ($rubric_name == 'discussion') { $check_managers[] = 'discarticle'; } if ($rubric_name == 'material') { $check_managers[] = 'section'; } } } $title = '<a href="' . $curl_text . $item->getItemID() . '&mod=home&fct=index">' . $item->getTitle() . '</a>'; $body_title = BR . BR . $title . '' . LF; $total_count = 0; if ($mail_sequence == 'daily') { $count_total = $item->getPageImpressionsForNewsletter(1); $active = $item->getActiveMembersForNewsletter(1); } else { $count_total = $item->getPageImpressionsForNewsletter(7); $active = $item->getActiveMembersForNewsletter(7); } if ($count_total == 1) { $body_title .= '(' . $count_total . ' ' . $translator->getMessage('ACTIVITY_PAGE_IMPRESSIONS_SINGULAR') . '; '; } else { $body_title .= '(' . $count_total . ' ' . $translator->getMessage('ACTIVITY_PAGE_IMPRESSIONS') . '; '; } $body_title .= $translator->getMessage('ACTIVITY_ACTIVE_MEMBERS') . ': '; $body_title .= $active . '):' . BRLF; $body2 = ''; $annotation_manager = $this->_environment->getManager('annotation'); $annotation_manager->setContextLimit($item->getItemID()); if ($mail_sequence == 'daily') { $annotation_manager->setAgeLimit(1); } else { $annotation_manager->setAgeLimit(7); } $annotation_manager->showNoNotActivatedEntries(); $annotation_manager->select(); $annotation_list = $annotation_manager->get(); for ($i = 0; $i < $count; $i++) { $rubric_array = explode('_', $rubrics[$i]); if ($rubric_array[1] != 'none') { $rubric_manager = $this->_environment->getManager($rubric_array[0]); $rubric_manager->reset(); $rubric_manager->setContextLimit($item->getItemID()); if ($mail_sequence == 'daily') { $rubric_manager->setAgeLimit(1); } else { $rubric_manager->setAgeLimit(7); } if ($rubric_manager instanceof cs_dates_manager) { $rubric_manager->setDateModeLimit(2); } if ($rubric_manager instanceof cs_user_manager) { $rubric_manager->setUserLimit(); } $rubric_manager->showNoNotActivatedEntries(); $rubric_manager->select(); $rubric_list = $rubric_manager->get(); // returns a cs_list of announcement_items $ids = $rubric_manager->getIDs(); $rubric_item = $rubric_list->getFirst(); $user_manager = $this->_environment->getUserManager(); $user_manager->resetLimits(); $user_manager->setUserIDLimit($user->getUserID()); $user_manager->setAuthSourceLimit($user->getAuthSource()); $user_manager->setContextLimit($item->getItemID()); $user_manager->select(); $user_list = $user_manager->get(); if (isset($user_list) and $user_list->isNotEmpty() and $user_list->getCount() == 1) { $ref_user = $user_list->getFirst(); if (isset($ref_user) and $ref_user->getItemID() > 0) { $temp_body = ''; $count_entries = 0; while ($rubric_item) { $noticed_manager = $this->_environment->getNoticedManager(); $noticed = $noticed_manager->getLatestNoticedForUserByID($rubric_item->getItemID(), $ref_user->getItemID()); if (empty($noticed)) { $info_text = ' <span class="changed">[' . $translator->getMessage('COMMON_NEW') . ']</span>'; } elseif ($noticed['read_date'] < $rubric_item->getModificationDate()) { $info_text = ' <span class="changed">[' . $translator->getMessage('COMMON_CHANGED') . ']</span>'; } else { $info_text = ''; } $annotation_item = $annotation_list->getFirst(); $annotation_count = 0; while ($annotation_item) { $annotation_noticed = $noticed_manager->getLatestNoticedForUserByID($annotation_item->getItemID(), $ref_user->getItemID()); if (empty($annotation_noticed)) { $linked_item = $annotation_item->getLinkedItem(); if ($linked_item->getItemID() == $rubric_item->getItemID()) { $annotation_count++; } } $annotation_item = $annotation_list->getNext(); } if ($annotation_count == 1) { $info_text .= ' <span class="changed">[' . $translator->getMessage('COMMON_NEW_ANNOTATION') . ']</span>'; } else { if ($annotation_count > 1) { $info_text .= ' <span class="changed">[' . $translator->getMessage('COMMON_NEW_ANNOTATIONS') . ']</span>'; } } if (!empty($info_text)) { $count_entries++; $params = array(); $params['iid'] = $rubric_item->getItemID(); $title = ''; if ($rubric_item->isA(CS_USER_TYPE)) { $title .= $this->_environment->getTextConverter()->text_as_html_short($rubric_item->getFullname()); } else { $title .= $this->_environment->getTextConverter()->text_as_html_short($rubric_item->getTitle()); } if ($rubric_item->isA(CS_LABEL_TYPE)) { $mod = $rubric_item->getLabelType(); } else { $mod = $rubric_item->getType(); } $title .= $info_text; $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&mod=' . $mod . '&fct=detail&iid=' . $params['iid'] . '">' . $title . '</a>'; $temp_body .= BR . ' - ' . $ahref_curl; } $rubric_item = $rubric_list->getNext(); } } } $tempMessage = ''; switch (mb_strtoupper($rubric_array[0], 'UTF-8')) { case 'ANNOUNCEMENT': $tempMessage = $translator->getMessage('ANNOUNCEMENT_INDEX'); break; case 'DATE': $tempMessage = $translator->getMessage('DATES_INDEX'); break; case 'DISCUSSION': $tempMessage = $translator->getMessage('DISCUSSION_INDEX'); break; case 'GROUP': $tempMessage = $translator->getMessage('GROUP_INDEX'); break; case 'INSTITUTION': $tempMessage = $translator->getMessage('INSTITUTION_INDEX'); break; case 'MATERIAL': $tempMessage = $translator->getMessage('MATERIAL_INDEX'); break; case 'MYROOM': $tempMessage = $translator->getMessage('MYROOM_INDEX'); break; case 'PROJECT': $tempMessage = $translator->getMessage('PROJECT_INDEX'); break; case 'TODO': $tempMessage = $translator->getMessage('TODO_INDEX'); break; case 'TOPIC': $tempMessage = $translator->getMessage('TOPIC_INDEX'); break; case 'USER': $tempMessage = $translator->getMessage('USER_INDEX'); break; case 'ENTRY': $tempMessage = $translator->getMessage('ENTRY_INDEX'); break; default: $tempMessage = $translator->getMessage('COMMON_MESSAGETAG_ERROR' . ' cs_privateroom_item(456) '); break; } if ($count_entries == 1) { $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&mod=' . $rubric_array[0] . '&fct=index">' . $tempMessage . '</a>'; $body2 .= ' ' . $ahref_curl; $body2 .= ' <span style="font-size:8pt;">(' . $count_entries . ' ' . $translator->getMessage('NEWSLETTER_NEW_SINGLE_ENTRY') . ')</span>'; } elseif ($count_entries > 1) { $ahref_curl = '<a href="' . $curl_text . $item->getItemID() . '&mod=' . $rubric_array[0] . '&fct=index">' . $tempMessage . '</a>'; $body2 .= ' ' . $ahref_curl; $body2 .= ' <span style="font-size:8pt;">(' . $count_entries . ' ' . $translator->getMessage('NEWSLETTER_NEW_ENTRIES') . ')</span>'; } if (!empty($body2) and !empty($temp_body)) { $body2 .= $temp_body . BRLF . LF; } } $j = $i + 1; } $item = $list2->getNext(); if (!empty($body2)) { $body .= $body_title; $body2 .= BRLF; $body .= $body2; } else { $body .= $body_title; $body2 .= ' ' . $translator->getMessage('COMMON_NO_NEW_ENTRIES') . BRLF; $body .= $body2; } } if (empty($body)) { $translator->getMessage('COMMON_NO_NEW_ENTRIES') . LF; } $body .= LF; $portal = $this->getContextItem(); $portal_title = ''; if (isset($portal)) { $portal_title = $portal->getTitle(); } if ($mail_sequence == 'daily') { $body = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_HEADER_DAILY', $portal_title) . LF . LF . $body; } else { $body = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_HEADER_WEEKLY', $portal_title) . LF . LF . $body; } $body .= BRLF . BR . '-----------------------------' . BRLF . LF . $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_FOOTER'); $from = $translator->getMessage('SYSTEM_MAIL_MESSAGE', $portal_title); $to = implode($mail_array, ','); if ($mail_sequence == 'daily') { $subject = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_DAILY') . ': ' . $portal_title; } else { $subject = $translator->getMessage('PRIVATEROOM_MAIL_SUBJECT_WEEKLY') . ': ' . $portal_title; } // send email include_once 'classes/cs_mail.php'; $mail = new cs_mail(); $mail->set_to($to); $mail->set_from_name($from); $server_item = $this->_environment->getServerItem(); $default_sender_address = $server_item->getDefaultSenderAddress(); if (!empty($default_sender_address)) { $mail->set_from_email($default_sender_address); } else { $mail->set_from_email('@'); } $mail->set_subject($subject); $mail->set_message($body); $mail->setSendAsHTML(); if ($mail->send()) { $retour['success'] = true; $retour['success_text'] = 'send newsletter to ' . $to; $this->_send_newsletter = true; } unset($mail); unset($body); unset($subject); unset($default_sender_address); unset($from); unset($to); unset($user_list); unset($ref_user); unset($translator); unset($room_manager); unset($list); unset($list2); unset($portal); unset($user_manager); unset($file); unset($curl_text); unset($mail_array); unset($rubric_manager); unset($noticed_manager); unset($rubric_list); unset($rubric_item); } else { $retour['success'] = true; $retour['success_text'] = 'no user in room want the newsletter'; } } $time_end = getmicrotime(); $time = round($time_end - $time_start, 0); $retour['time'] = $time; return $retour; } }
public function search ($search_word, $parts_array) { $retour = array(); if ( !empty($search_word) and !empty($parts_array) ) { $current_user_item = $this->_environment->getCurrentUserItem(); $context_id_array = $current_user_item->getContextIDArray(); if ( !empty($context_id_array) ) { include_once('classes/cs_list.php'); $search_list = new cs_list(); foreach ($parts_array as $part) { $manager = $this->_getPartManager($part); if ( isset($manager) ) { $manager->setContextArrayLimit($context_id_array); $manager->setSearchLimit($search_word); $manager->select(); $list = $manager->get(); if ( isset($list) and $list->isNotEmpty() ) { $search_list->addList($list); } unset($list); } } } } $item = $search_list->getFirst(); while ($item) { $item_object = (object) null; $item_object->id = $item->getItemID(); $item_object->type = $item->getItemType(); if ( $item->isA(CS_USER_TYPE) ) { $item_object->title = $item->getFullname(); } else { $item_object->title = $item->getTitle(); } $item_object->url = $item->getItemURL(); $item_object->context_id = $item->getContextID(); $item_object->context_title = $item->getContextItem()->getTitle(); $item_object->user_id = $item->getCreatorID(); $item_object->user_id_mb = $this->_getMBUserID($item->getCreatorID()); if ( empty($item_object->user_id_mb)) { $creator_item = $item->getCreatorItem(); $item_object->user_title = $creator_item->getFullname(); unset($creator_item); } $item_object->item_id = $item->getItemID(); if ( $item->isA(CS_USER_TYPE) ) { $item_object->item_title = $item->getFullname(); } else { $item_object->item_title = $item->getTitle(); } # TBD: Warum gefunden? array_push($retour,$item_object); $item = $search_list->getNext(); } return $retour; }
private function _performIndexedSearch($rubric_array) { $db = $this->_environment->getDBConnector(); $session = $this->_environment->getSessionItem(); $params = $this->_environment->getCurrentParameterArray(); /************************************************************************************ * We can look up all search words in the database to get their ids... ************************************************************************************/ $query = ' SELECT sw_id FROM search_word WHERE 1=1 '; $size = sizeof($this->_search_words); if ($size != 0) { $query .= 'AND ('; for ($i = 0; $i < $size; $i++) { $query .= ' sw_word LIKE "' . encode(AS_DB, $this->_search_words[$i]) . '%" '; if ($i < $size - 1) { $query .= ' OR '; } } $query .= ') '; } $word_ids = $db->performQuery($query); /************************************************************************************ * ...and find items matching these ids * * fortunately, it is possible to limit this selection by rubrics, because all indexed entries are * associated to their proper main item * f.e. - discussionarticles are listed as discussions * - annotations are listed as the item they belong to * - ... ************************************************************************************/ $search_rubrics = $rubric_array; if (!empty($this->_params['selrubric'])) { $search_rubrics = array($this->_params['selrubric']); } $search_rubrics[] = 'file'; $query = ' SELECT si_item_id, si_item_type, si_count FROM search_index WHERE ( '; $size = sizeof($search_rubrics); for ($i = 0; $i < $size; $i++) { $query .= ' si_item_type = "' . mysql_real_escape_string($search_rubrics[$i]) . '"'; if ($i < $size - 1) { $query .= ' OR '; } } $query .= ') AND ('; if (!empty($word_ids)) { $size = sizeof($word_ids); for ($i = 0; $i < $size; $i++) { $query .= ' si_sw_id = ' . $word_ids[$i]['sw_id']; if ($i < $size - 1) { $query .= ' OR '; } } } else { $query .= 'FALSE'; } $query .= ')'; $query .= ' ORDER BY si_count DESC '; $results = $db->performQuery($query); /************************************************************************************ * the result is catched in a way, creating a rubric ordered array * * ...maybe this could be done directly in query ************************************************************************************/ foreach ($results as $result) { $type = $this->rubric2ItemType($result['si_item_type']); if ($type == "file") { // get type of their main item $item_manager = $this->_environment->getItemManager(); $item = $item_manager->getItem($result['si_item_id']); $type = $item->getItemType(); unset($item_manager); } // inline types need to be remapped $map = array("discarticle" => "discussion", "section" => "material", "step" => "todo"); if (isset($map[$type])) { $type = $map[$type]; } $this->_items[$type][$result['si_item_id']] = $result['si_count']; } /************************************************************************************ * if file indexing is on, we merge items here ************************************************************************************/ /* global $ftsearch_enabled; if (isset($ftsearch_enabled) && $ftsearch_enabled === true) { $ftsearch_manager = $this->_environment->getFTSearchManager(); $ftsearch_manager->setSearchStatus(true); $ftsearch_manager->setWords($this->_search_words); $ftItemIdArray = $ftsearch_manager->performFTSearch(); $itemManager = $this->_environment->getItemManager(); $itemList = $itemManager->getItemList($ftItemIdArray); $item = $itemList->getFirst(); while ($item) { $type = $item->getType(); $map = array( "discarticle" => "discussion", "section" => "material", "step" => "todo" ); if (isset($map[$type])) $type = $map[$type]; $this->_items[$type][$item->getItemID()] = 3; // <- this is just a fake value $item = $itemList->getNext(); } }*/ /************************************************************************************ * now we can get all needed information for the matched items ************************************************************************************/ $count_all = 0; $campus_search_ids = array(); $result_list = new cs_list(); /* foreach ($this->items as $type => $detail) { $manager = $this->_environment->getManager($type); $idArray = array_keys($detail); }*/ global $c_plugin_array; foreach ($rubric_array as $rubric) { if (!isset($c_plugin_array) || !in_array(strtolower($rubric), $c_plugin_array)) { $rubric_ids = array(); $rubric_list = new cs_list(); $rubric_manager = $this->_environment->getManager($rubric); /* * TODO: the main idea is to limit requests by the previous detected item ids and only get detailed information for those, * but db managers do not act as expected * * for now, items are filtered afterwards */ // set id array limit //$rubric_manager->setIDArrayLimit(array_keys($items[$rubric])); if ($rubric === CS_PROJECT_TYPE) { $rubric_manager->setQueryWithoutExtra(); } // context limit if ($rubric !== CS_PROJECT_TYPE && $rubric !== CS_MYROOM_TYPE) { $rubric_manager->setContextLimit($this->_environment->getCurrentContextID()); } elseif ($rubric === CS_PROJECT_TYPE && $this->_environment->inCommunityRoom()) { $rubric_manager->setContextLimit($this->_environment->getCurrentPortalID()); $current_community_item = $this->_environment->getCurrentContextItem(); $rubric_manager->setIDArrayLimit($current_community_item->getInternalProjectIDArray()); unset($current_community_item); } // date if ($rubric === CS_DATE_TYPE && $this->_params['selstatus'] === 2) { $rubric_manager->setWithoutDateModeLimit(); } elseif ($rubric === CS_DATE_TYPE && $this->_params['selstatus'] !== 2) { $rubric_manager->setDateModeLimit($this->_params['selstatus']); } if ($this->_params['selgroup']) { $rubric_manager->setGroupLimit($this->_params['selgroup']); } // user if ($rubric === CS_USER_TYPE) { $rubric_manager->setUserLimit(); $current_user = $this->_environment->getCurrentUser(); if ($current_user->isUser()) { $rubric_manager->setVisibleToAllAndCommsy(); } else { $rubric_manager->setVisibleToAll(); } } $count_all = $count_all + $rubric_manager->getCountAll(); foreach ($sel_array as $rubric => $value) { if (!empty($value)) { $rubric_manager->setRubricLimit($rubric, $value); } } // activating status if ($this->_params['sel_activating_status'] !== '1') { $rubric_manager->showNoNotActivatedEntries(); } $rubric_manager->setAttributeLimit($this->_params['selrestriction']); // apply filters if (!empty($this->_params['selbuzzword'])) { $rubric_manager->setBuzzwordLimit($this->_params['selbuzzword']); } // if(!empty($this->_params['seltag'])) { // $rubric_manager->setTagLimit($this->_params['seltag']); // } // get selected seltags $seltag_array = array(); foreach ($params as $key => $value) { if (substr($key, 0, 6) == 'seltag') { // set seltag array $seltag_array[$key] = $value; } } if (!empty($seltag_array)) { $rubric_manager->setTagArrayLimit($seltag_array); } /* * if ( !empty($selcolor) and $selcolor != '2' and $selrubric == "date") { $rubric_manager->setColorLimit('#'.$selcolor); } if ( ($selrubric == "todo") and !empty($selstatus)) { $rubric_manager->setStatusLimit($selstatus); } if (!empty($seluser)) { $rubric_manager->setUserLimit($seluser); } if ( !empty($selfiles) ) { $rubric_manager->setOnlyFilesLimit(); } */ if ($rubric != CS_MYROOM_TYPE) { $rubric_manager->selectDistinct(); $rubric_list = $rubric_manager->get(); $temp_rubric_ids = $rubric_manager->getIDArray(); } else { //$rubric_list = $rubric_manager->getRelatedContextListForUser($current_user->getUserID(),$current_user->getAuthSource(),$environment->getCurrentPortalID());; //$temp_rubric_ids = $rubric_list->getIDArray(); } /* if (isset($_GET['select']) and $_GET['select']=='all'){ if(get_class($rubric_manager) == 'cs_user_manager'){ $selected_ids = $temp_rubric_ids; } } */ $result_list->addList($rubric_list); if (!empty($temp_rubric_ids)) { $rubric_ids = $temp_rubric_ids; } $session->setValue('cid' . $this->_environment->getCurrentContextID() . '_' . $rubric . '_index_ids', $rubric_ids); $campus_search_ids = array_merge($campus_search_ids, $rubric_ids); /* $search_list->addList($rubric_list); if (!empty($temp_rubric_ids)){ $rubric_ids = $temp_rubric_ids; } $session->setValue('cid'.$environment->getCurrentContextID().'_'.$rubric.'_index_ids', $rubric_ids); $campus_search_ids = array_merge($campus_search_ids, $rubric_ids); */ } #$session->setValue('cid'.$environment->getCurrentContextID().'_campus_search_parameter_array', $campus_search_parameter_array); # $session = $this->_environment->getSessionItem(); } // search in indexed files $ftsearch_manager = $this->_environment->getFTSearchManager(); $ftsearch_manager->setSearchStatus(true); $ftsearch_manager->setWords($this->_search_words); $ftItemIdArray = $ftsearch_manager->performFTSearch(); /************************************************************************************ * as said in the todo note, some filtering is applied afterwards ************************************************************************************/ $entry = $result_list->getFirst(); while ($entry) { /* if($entry instanceof cs_group_item) { $entry->setType(CS_GROUP_TYPE); $this->_list->add($entry); }*/ if (isset($this->_items[$entry->getType()][$entry->getItemID()]) || in_array($entry->getItemID(), $ftItemIdArray)) { $this->_list->add($entry); } $entry = $result_list->getNext(); } return $ftItemIdArray; }