/** * @param string $title */ public function setTitle($title) { $this->_title = $this->html2text($title); $this->_original_title = $this->_title; $titleTag = array(); $titleTag['module'] = $this->publisher->getModule()->getVar('name'); if (isset($this->_title) && $this->_title != '' && strtoupper($this->_title) != strtoupper($titleTag['module'])) { $titleTag['title'] = $this->_title; } if (isset($this->_categoryPath) && $this->_categoryPath != '') { $titleTag['category'] = $this->_categoryPath; } $ret = isset($titleTag['title']) ? $titleTag['title'] : ''; if (isset($titleTag['category']) && $titleTag['category'] != '') { if ($ret != '') { $ret .= ' - '; } $ret .= $titleTag['category']; } if (isset($titleTag['module']) && $titleTag['module'] != '') { if ($ret != '') { $ret .= ' - '; } $ret .= $titleTag['module']; } $this->_title = $ret; }
/** * Delete all permission for a specific item * deletePermissions() * * @param integer $itemid id of the item for which to delete the permissions * @param string $gperm_name permission name * * @return boolean : TRUE if the no errors occured */ public function deletePermissions($itemid, $gperm_name) { $xoops = Xoops::getInstance(); $result = true; $gperm_handler = $xoops->getHandlerGroupperm(); $gperm_handler->deleteByModule($this->publisher->getModule()->getVar('mid'), $gperm_name, $itemid); return $result; }
/** * delete a category from the database * * @param XoopsObject $category reference to the category to delete * @param bool $force * * @return bool FALSE if failed. */ public function delete(XoopsObject $category, $force = false) { $xoops = Xoops::getInstance(); // Deleting this category ITEMs $criteria = new Criteria('categoryid', $category->getVar('categoryid')); $this->publisher->getItemHandler()->deleteAll($criteria, true, true); unset($criteria); // Deleting the sub categories $subcats = $this->getCategories(0, 0, $category->getVar('categoryid')); foreach ($subcats as $subcat) { $this->delete($subcat); } if (!parent::delete($category, $force)) { $category->setErrors('An error while deleting.'); return false; } $module_id = $this->publisher->getModule()->getVar('mid'); $xoops->getHandlerGroupPermission()->deleteByModule($module_id, "category_read", $category->getVar('categoryid')); $xoops->getHandlerGroupPermission()->deleteByModule($module_id, "item_submit", $category->getVar('categoryid')); $xoops->getHandlerGroupPermission()->deleteByModule($module_id, "category_moderation", $category->getVar('categoryid')); return true; }
/** * @param array $queryarray * @param string $andor * @param int $limit * @param int $offset * @param int $userid * @param array $categories * @param int $sortby * @param string $searchin * @param string $extra * * @return array */ public function getItemsFromSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = array(), $sortby = 0, $searchin = "", $extra = "") { $xoops = Xoops::getInstance(); $ret = array(); $gperm_handler = $xoops->getHandlerGroupPermission(); $groups = $xoops->getUserGroups(); $searchin = empty($searchin) ? array("title", "body", "summary") : (is_array($searchin) ? $searchin : array($searchin)); if (in_array("all", $searchin) || count($searchin) == 0) { $searchin = array("title", "subtitle", "body", "summary", "meta_keywords"); } if (is_array($userid) && count($userid) > 0) { $userid = array_map("intval", $userid); $criteriaUser = new CriteriaCompo(); $criteriaUser->add(new Criteria('uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR'); } elseif (is_numeric($userid) && $userid > 0) { $criteriaUser = new CriteriaCompo(); $criteriaUser->add(new Criteria('uid', $userid), 'OR'); } $count = count($queryarray); if (is_array($queryarray) && $count > 0) { $criteriaKeywords = new CriteriaCompo(); for ($i = 0; $i < count($queryarray); ++$i) { $criteriaKeyword = new CriteriaCompo(); if (in_array('title', $searchin)) { $criteriaKeyword->add(new Criteria('title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); } if (in_array('subtitle', $searchin)) { $criteriaKeyword->add(new Criteria('subtitle', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); } if (in_array('body', $searchin)) { $criteriaKeyword->add(new Criteria('body', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); } if (in_array('summary', $searchin)) { $criteriaKeyword->add(new Criteria('summary', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); } if (in_array('meta_keywords', $searchin)) { $criteriaKeyword->add(new Criteria('meta_keywords', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); } $criteriaKeywords->add($criteriaKeyword, $andor); unset($criteriaKeyword); } } if (!PublisherUtils::IsUserAdmin() && count($categories) > 0) { $criteriaPermissions = new CriteriaCompo(); // Categories for which user has access $categoriesGranted = $gperm_handler->getItemIds('category_read', $groups, $this->publisher->getModule()->getVar('mid')); if (count($categories) > 0) { $categoriesGranted = array_intersect($categoriesGranted, $categories); } if (count($categoriesGranted) == 0) { return $ret; } $grantedCategories = new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN'); $criteriaPermissions->add($grantedCategories, 'AND'); } elseif (count($categories) > 0) { $criteriaPermissions = new CriteriaCompo(); $grantedCategories = new Criteria('categoryid', "(" . implode(',', $categories) . ")", 'IN'); $criteriaPermissions->add($grantedCategories, 'AND'); } $criteriaItemsStatus = new CriteriaCompo(); $criteriaItemsStatus->add(new Criteria('status', _PUBLISHER_STATUS_PUBLISHED)); $criteria = new CriteriaCompo(); if (!empty($criteriaUser)) { $criteria->add($criteriaUser, 'AND'); } if (!empty($criteriaKeywords)) { $criteria->add($criteriaKeywords, 'AND'); } if (!empty($criteriaPermissions)) { $criteria->add($criteriaPermissions); } if (!empty($criteriaItemsStatus)) { $criteria->add($criteriaItemsStatus, 'AND'); } $criteria->setLimit($limit); $criteria->setStart($offset); if (empty($sortby)) { $sortby = "datesub"; } $criteria->setSort($sortby); $order = 'ASC'; if ($sortby === "datesub") { $order = 'DESC'; } $criteria->setOrder($order); $ret = $this->getItemObjects($criteria); return $ret; }