Beispiel #1
0
 /**
  * Retrieve a list of objects as arrays - DON'T USE WITH JOINT KEYS
  *
  * @param object $criteria {@link CriteriaElement} conditions to be met
  * @param int   $limit      Max number of objects to fetch
  * @param int   $start      Which record to start at
  *
  * @return array
  */
 function getList($criteria = null, $limit = 0, $start = 0)
 {
     $ret = array();
     if ($criteria == null) {
         $criteria = new CriteriaCompo();
     }
     if ($criteria->getSort() == '') {
         $criteria->setSort($this->identifierName);
     }
     $sql = 'SELECT ' . $this->keyName;
     if (!empty($this->identifierName)) {
         $sql .= ', ' . $this->identifierName;
     }
     $sql .= ' FROM ' . $this->table;
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         if ($criteria->getSort() != '') {
             $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
         }
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     $myts =& MyTextSanitizer::getInstance();
     while ($myrow = $this->db->fetchArray($result)) {
         //identifiers should be textboxes, so sanitize them like that
         $ret[$myrow[$this->keyName]] = empty($this->identifierName) ? 1 : $myts->htmlSpecialChars($myrow[$this->identifierName]);
     }
     return $ret;
 }
 function getActiveModules()
 {
     //
     // At first, get active module IDs.
     //
     static $ret;
     if (isset($ret)) {
         return $ret;
     }
     $handler =& xoops_gethandler('module');
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('isactive', 1));
     $criteria->add(new Criteria('hassearch', 1));
     // shortcut for speedup
     $db = $handler->db;
     $sort = $criteria->getSort();
     $sql = 'SELECT mid,name FROM ' . $db->prefix('modules') . ' ' . $criteria->renderWhere() . ($sort ? ' ORDER BY ' . $sort . ' ' . $criteria->getOrder() : ' ORDER BY weight ' . $criteria->getOrder() . ', mid ASC');
     $result = $db->query($sql);
     $handler =& xoops_gethandler('groupperm');
     $groupArr = Legacy_SearchUtils::getUserGroups();
     $ret = array();
     while (list($mid, $name) = $db->fetchRow($result)) {
         if ($handler->checkRight('module_read', $mid, $groupArr)) {
             $ret[] = array('mid' => $mid, 'name' => $name);
         }
     }
     return $ret;
 }
 /**
  * Get configs from the database
  * 
  * @param	object  $criteria   {@link CriteriaElement}
  * @param	bool    $id_as_key  return the config's id as key?
  *
  * @return	array   Array of {@link XoopsConfigItem} objects
  */
 function getObjects($criteria = null, $id_as_key = false)
 {
     if ($criteria == null) {
         $criteria = new CriteriaCompo();
     }
     if ($criteria->getSort() == "") {
         $criteria->setSort('conf_order');
     }
     return parent::getObjects($criteria, $id_as_key);
 }
Beispiel #4
0
 /**
  * Get a list of {@link SmartmediaFolder} objects for the search feature
  *
  * @param array $queryarray list of keywords to look for
  * @param string $andor specify which type of search we are performing : AND or OR
  * @param int $limit maximum number of results to return
  * @param int $offset at which folder shall we start
  * @param int $userid userid related to the creator of the folder
  *
  * @return array array containing information about the folders mathing the search criterias
  */
 function &getObjectsForSearch($queryarray = array(), $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
 {
     global $xoopsConfig;
     $ret = array();
     $sql = "SELECT item." . $this->_key_field . ", itemtext." . $this->_caption_field . ", itemtext.description, parent.categoryid FROM\r\n                   (\r\n        \t\t\t (" . $this->_db->prefix($this->_dbtable) . " AS item\r\n\t\t\t\t\t   INNER JOIN " . $this->_db->prefix($this->_dbtable) . "_text AS itemtext \r\n        \t\t       ON item." . $this->_key_field . " = itemtext." . $this->_key_field . "\r\n        \t\t     )\r\n        \t\t     INNER JOIN " . $this->_db->prefix($this->_dbtable_parent) . " AS parent\r\n         \t\t     ON parent." . $this->_key_field . " = item." . $this->_key_field . "\r\n                   )";
     if ($queryarray) {
         $criteriaKeywords = new CriteriaCompo();
         for ($i = 0; $i < count($queryarray); $i++) {
             $criteriaKeyword = new CriteriaCompo();
             $criteriaKeyword->add(new Criteria('itemtext.title', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             $criteriaKeyword->add(new Criteria('itemtext.description', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR');
             $criteriaKeywords->add($criteriaKeyword, $andor);
         }
     }
     if ($userid != 0) {
         $criteriaUser = new CriteriaCompo();
         $criteriaUser->add(new Criteria('item.uid', $userid), 'OR');
     }
     $criteria = new CriteriaCompo();
     // Languageid
     $criteriaLanguage = new CriteriaCompo();
     $criteriaLanguage->add(new Criteria('itemtext.languageid', $xoopsConfig['language']));
     $criteria->add($criteriaLanguage);
     if (!empty($criteriaUser)) {
         $criteria->add($criteriaUser, 'AND');
     }
     if (!empty($criteriaKeywords)) {
         $criteria->add($criteriaKeywords, 'AND');
     }
     $criteria->setSort('item.weight');
     $criteria->setOrder('ASC');
     $sql .= ' ' . $criteria->renderWhere();
     //$sql .= "GROUP BY parent." . $this->_key_field . "";
     if ($criteria->getSort() != '') {
         $sql .= ' ORDER BY ' . $criteria->getSort() . '
             ' . $criteria->getOrder();
     }
     //echo "<br />$sql<br />";
     $result = $this->_db->query($sql, $limit, $offset);
     // If no records from db, return empty array
     if (!$result) {
         return $ret;
     }
     // Add each returned record to the result array
     while ($myrow = $this->_db->fetchArray($result)) {
         $item['id'] = $myrow[$this->_key_field];
         $item['title'] = $myrow[$this->_caption_field];
         $item['categoryid'] = $myrow[$this->_parent_field];
         $ret[] = $item;
         unset($item);
     }
     return $ret;
 }