Ejemplo n.º 1
0
 /**
  * Get tags for a list of IDs
  * 
  * @param   array    $ids    Bulletin ids
  * @param   integer  $admin  Admin flag
  * @return  array
  */
 public function getTagsForIds($ids = array(), $admin = 0)
 {
     $tt = new Tables\Tag($this->_db);
     $tj = new Tables\Object($this->_db);
     if (!is_array($ids) || empty($ids)) {
         return false;
     }
     $ids = array_map('intval', $ids);
     $sql = "SELECT t.tag, t.raw_tag, t.admin, rt.objectid\n\t\t\t\tFROM " . $tt->getTableName() . " AS t \n\t\t\t\tINNER JOIN " . $tj->getTableName() . " AS rt ON (rt.tagid = t.id) AND rt.tbl='" . $this->_scope . "' \n\t\t\t\tWHERE rt.objectid IN (" . implode(',', $ids) . ") ";
     switch ($admin) {
         case 1:
             $sql .= "";
             break;
         case 0:
         default:
             $sql .= "AND t.admin=0 ";
             break;
     }
     $sql .= "ORDER BY raw_tag ASC";
     $this->_db->setQuery($sql);
     $tags = array();
     if ($items = $this->_db->loadObjectList()) {
         foreach ($items as $item) {
             if (!isset($tags[$item->objectid])) {
                 $tags[$item->objectid] = array();
             }
             $tags[$item->objectid][] = $item;
         }
     }
     return $tags;
 }
Ejemplo n.º 2
0
 /**
  * Get recently used tags
  *
  * @param   integer  $limit  Number of tags to find
  * @param   string   $order  Sort results by
  * @return  array
  */
 public function getRecentTags($limit = 25, $order = 'taggedon DESC', $exclude_private = 1)
 {
     require_once __DIR__ . DS . 'object.php';
     $tj = new Object($this->_db);
     $sql = "SELECT t.tag, t.raw_tag, t.admin, tj.taggedon, COUNT(tj.tagid) AS tcount ";
     $sql .= "FROM {$this->_tbl} AS t  ";
     $sql .= "JOIN " . $tj->getTableName() . " AS tj ON t.id=tj.tagid ";
     //AND t.raw_tag NOT LIKE 'tool:%' AND t.raw_tag NOT LIKE 'resource:%' ";
     if ($exclude_private) {
         $sql .= "LEFT JOIN #__resources AS R ON R.id=tj.objectid AND tj.tbl='resources' ";
         $sql .= "LEFT JOIN #__wiki_page AS P ON P.id=tj.objectid AND tj.tbl='wiki' ";
         $sql .= "LEFT JOIN #__xprofiles AS XP ON XP.uidNumber=tj.objectid AND tj.tbl='xprofiles' ";
     }
     $sql .= "WHERE t.id=tj.tagid AND t.admin=0 ";
     if ($exclude_private) {
         $sql .= "AND (\n\t\t\t\t(tj.tbl='resources' AND R.access!=4) OR\n\t\t\t\t(tj.tbl='wiki' AND P.access=0) OR\n\t\t\t\t(tj.tbl='xprofiles' AND XP.public=0) OR\n\t\t\t\t(tj.tbl NOT IN ('xprofiles', 'wiki', 'resources', 'wishlist', 'support'))\n\t\t\t\t) ";
     }
     $sql .= "GROUP BY raw_tag\n\t\t\t\tORDER BY {$order} LIMIT " . (int) $limit;
     $this->_db->setQuery($sql);
     return $this->_db->loadObjectList();
 }