Beispiel #1
0
 *
 * @package wiki
 * @subpackage functions
 */
/**
 * required setup
 */
require_once '../kernel/setup_inc.php';
include_once WIKI_PKG_PATH . 'BitPage.php';
$gBitSystem->verifyPackage('wiki');
$gBitSystem->verifyFeature('users_watches');
$gBitSystem->verifyPermission('p_admin_users', tra("Permission denied you cannot browse these page watches"));
// Get the page from the request var or default it to HomePage
include WIKI_PKG_PATH . 'lookup_page_inc.php';
// make comment count for this page available for templates
$gComment = new LibertyComment();
$numComments = $gComment->getNumComments($gContent->mContentId);
$gBitSmarty->assign('comments_count', $numComments);
//vd($gContent->mPageId);vd($gContent->mInfo);
if (!$gContent->isValid() || empty($gContent->mInfo)) {
    $gBitSystem->fatalError(tra("Unknown page"));
}
$watches = NULL;
if (!empty($gContent->mPageId)) {
    $event = 'wiki_page_changed';
    $watches = $gBitUser->get_event_watches($event, $gContent->mPageId);
    $gBitSmarty->assignByRef('watches', $watches);
    $gBitSmarty->assignByRef('pageInfo', $gContent->mInfo);
}
// Display the template
$gBitSystem->display('bitpackage:wiki/page_watches.tpl', NULL, array('display_mode' => 'display'));
Beispiel #2
0
 /**
  * This function generates a list of records from the liberty_content database for use in a list page
  **/
 function getList(&$pParamHash)
 {
     global $commentsLib;
     LibertyContent::prepGetList($pParamHash);
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash);
     // this will set $find, $sort_mode, $max_records and $offset
     extract($pParamHash);
     // quick search support from find field
     if (is_array($find)) {
         // you can use an array of pages
         $whereSql .= " AND lc.`title` IN( " . implode(',', array_fill(0, count($find), '?')) . " )";
         $bindVars = array_merge($bindVars, $find);
     } elseif (is_string($find)) {
         // or a string
         $whereSql .= " AND UPPER( lc.`title` )like ? ";
         $bindVars[] = '%' . strtoupper($find) . '%';
     }
     $sortModePrefix = 'lc.';
     $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pParamHash['sort_mode']);
     $query = "SELECT bm.*, lc.`content_id`, lc.`title`, lc.`data`, lcds.`data` AS `summary`,\n\t\t\t\t\t\tlc.`format_guid`, lc.`last_modified`, lc.`created`, lc.`version` \n\t\t\t\t\t\t{$selectSql}\n\t\t\t\t  FROM `" . BIT_DB_PREFIX . "gmaps` bm \n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = bm.`content_id` )\n\t\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON (lc.`content_id` = lcds.`content_id` AND lcds.`data_type`='summary')\n\t\t\t\t\t\t{$joinSql}\n\t\t\t\t  WHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\t\t  ORDER BY {$sort_mode}";
     $query_cant = "SELECT COUNT( * )\n\t\t\t\t\t\tFROM\t`" . BIT_DB_PREFIX . "gmaps` bm \n\t\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = bm.`content_id` ) {$joinSql}\n\t\t\t\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}";
     $result = $this->mDb->query($query, $bindVars, $max_records, $offset);
     $ret = array();
     $comment = new LibertyComment();
     while ($res = $result->fetchRow()) {
         if ($this->getPreference('allow_comments', null, $res['content_id']) == 'y') {
             $res['num_comments'] = $comment->getNumComments($res['content_id']);
         }
         $res['display_url'] = $this->getDisplayUrl(NULL, $res);
         $ret[] = $res;
     }
     $pParamHash["data"] = $ret;
     $pParamHash["cant"] = $this->mDb->getOne($query_cant, $bindVars);
     LibertyContent::postGetList($pParamHash);
     return $pParamHash;
 }
Beispiel #3
0
 }
 // $commentsParentId is the content_id which the comment tree is attached to
 if (!@BitBase::verifyId($commentsParentId)) {
     $comments = array();
     $numComments = 0;
 } else {
     if (@BitBase::verifyId($commentsParentIds)) {
         $parents = $commentsParentIds;
     } else {
         $parents = $commentsParentId;
     }
     // pass in a reference to the root object so that we can do proper permissions checks
     if (is_object($gContent)) {
         $gComment->mRootObj = $gContent;
     }
     $numComments = $gComment->getNumComments($commentsParentId);
     if ($commentOffset > $numComments) {
         $commentOffset = $numComments / $maxComments;
         $currentPage = ceil($commentOffset + 1 / $maxComments);
     }
     $comments = $gComment->getComments($parents, $maxComments, $commentOffset, $comments_sort_mode, $comments_display_style);
 }
 if ($comments_display_style == 'flat') {
     $commentsTree = $comments;
 } else {
     $commentsTree = array();
     foreach ($comments as $id => $node) {
         if (!empty($comments[$node['parent_id']])) {
             $comments[$node['parent_id']]['children'][$id] =& $comments[$id];
         }
         if ($node['parent_id'] == $node['root_id'] || empty($comments[$node['parent_id']])) {
Beispiel #4
0
 function getList(&$pListHash)
 {
     global $gBitUser, $gBitSystem;
     $this->prepGetList($pListHash);
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash);
     if (@$this->verifyId($pListHash['blog_id'])) {
         $selectSql .= ', bpm.crosspost_note';
         array_push($bindVars, (int) $pListHash['blog_id']);
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "blogs_posts_map` bpm ON ( bpm.`post_content_id` = bp.`content_id` ) ";
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "blogs` b ON ( bpm.`blog_content_id`=b.`content_id` ) ";
         //	" ON ( b.`content_id` = bpm.`blog_content_id` AND bp.`content_id` = bpm.`post_content_id` )";
         $whereSql .= ' AND b.`blog_id` = ? ';
         $pListHash['sort_mode'] = 'publish_date_desc';
     }
     if (@$this->verifyId($pListHash['post_id_gt'])) {
         array_push($bindVars, (int) $pListHash['post_id_gt']);
         $whereSql .= ' AND bp.`post_id` > ? ';
     }
     if (@$this->verifyId($pListHash['post_id_lt'])) {
         array_push($bindVars, (int) $pListHash['post_id_lt']);
         $whereSql .= ' AND bp.`post_id` < ? ';
     }
     if (@$this->verifyId($pListHash['user_id'])) {
         array_push($bindVars, (int) $pListHash['user_id']);
         $whereSql .= ' AND lc.`user_id` = ? ';
     }
     $this->getServicesSql('content_user_collection_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pListHash);
     // map user to login in case we used one instead of the other
     if (!empty($pListHash['user'])) {
         $pListHash['login'] = $pListHash['user'];
     }
     if (!empty($pListHash['login'])) {
         array_push($bindVars, $pListHash['login']);
         $whereSql .= ' AND uu.`login` = ? ';
     }
     if ($pListHash['find']) {
         $findesc = '%' . strtoupper($pListHash['find']) . '%';
         $whereSql .= "AND (UPPER(lc.`data`) like ?) ";
         $bindVars[] = $findesc;
     }
     if (!empty($pListHash['date']) && is_numeric($pListHash['date'])) {
         $whereSql .= " AND  lc.`created`<=? ";
         $bindVars[] = $pListHash['date'];
     }
     if (!empty($pListHash['date_start']) && is_numeric($pListHash['date_start'])) {
         $whereSql .= " AND  lc.`created`>=? ";
         $bindVars[] = $pListHash['date_start'];
     }
     if (!empty($pListHash['date_end']) && is_numeric($pListHash['date_end'])) {
         $whereSql .= " AND  lc.`created`<=? ";
         $bindVars[] = $pListHash['date_end'];
     }
     if (!empty($pListHash['content_perm_name'])) {
         $this->getContentListPermissionsSql($pListHash['content_perm_name'], $selectSql, $joinSql, $whereSql, $bindVars);
     }
     /* Check if the post wants to be viewed before / after respective dates
      * Note: expiring posts are determined by the expired date being greater than the publish date
      */
     static::getDateRestrictions($pListHash, $whereSql, $bindVars);
     /* sort_mode is never empty due to call to prepGetList above
      * I think this will have to be perminently removed and default
      * set before passing the list hash in if a different default is
      * desired from that in prepGetList. -wjames5
      */
     /*
     if( empty( $pListHash['sort_mode'] ) ) {
     	$pListHash['sort_mode'] = 'publish_date_desc';
     	$sortModePrefix = 'bp';
     	//$pListHash['sort_mode'] = 'created_desc';
     } else {
     */
     $sortModePrefix = '';
     if (!empty($pListHash['sort_mode']) && !strpos($pListHash['sort_mode'], '.')) {
         switch ($pListHash['sort_mode']) {
             case 'publish_date_asc':
             case 'publish_date_desc':
             case 'post_id_desc':
             case 'post_id_asc':
                 $sortModePrefix = 'bp.';
                 break;
             case 'date_added_desc':
                 $sortModePrefix = 'bpm.';
                 break;
             case 'hits_asc':
             case 'hits_desc':
                 $sortModePrefix = 'lch.';
                 break;
             case 'sort_date_asc':
             case 'sort_date_desc':
                 break;
             case 'real_name_asc':
             case 'real_name_desc':
                 $sortModePrefix = 'uu.';
                 break;
                 // these technicall are not correct, however, we do not double join on users_users, so we sort by creator real_name
             // these technicall are not correct, however, we do not double join on users_users, so we sort by creator real_name
             case 'creator_real_name_asc':
             case 'modifier_real_name_asc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'real_name_asc';
                 break;
             case 'registration_date_desc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'registration_date_desc';
                 break;
             case 'creator_real_name_desc':
             case 'modifier_real_name_desc':
                 $sortModePrefix = 'uu.';
                 $pListHash['sort_mode'] = 'real_name_desc';
                 break;
             default:
                 $sortModePrefix = 'lc.';
                 break;
         }
     }
     $secondarySortMode = $pListHash['sort_mode'] != 'last_modified_desc' ? ', last_modified DESC' : '';
     $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pListHash['sort_mode']) . $secondarySortMode;
     $query = "\n\t\t\tSELECT\n\t\t\t\tbp.`post_id`, bp.`publish_date`, bp.`expire_date`, bp.`trackbacks_to`, bp.`trackbacks_from`,\n\t\t\t\tlc.*, lch.`hits`, lcds.`data` AS `summary`, COALESCE( bp.`publish_date`, lc.`last_modified` ) AS sort_date,\n\t\t\t\tuu.`email`, uu.`login`, uu.`real_name`,\n\t\t\t\t\tlfa.`file_name` as `avatar_file_name`, lfa.`mime_type` AS `avatar_mime_type`, laa.`attachment_id` AS `avatar_attachment_id`,\n\t\t\t\t\tlfp.`file_name` AS `image_file_name`, lfp.`mime_type` AS `image_mime_type`, lap.`attachment_id` AS `image_attachment_id`\n\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id`         = bp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON lc.`content_id`         = lch.`content_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_data` lcds ON (lc.`content_id` = lcds.`content_id` AND lcds.`data_type`='summary')\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`\tlaa ON (uu.`user_id` = laa.`user_id` AND laa.`attachment_id` = uu.`avatar_attachment_id`)\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`\t    lfa ON lfa.`file_id`\t\t   = laa.`foreign_id`\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`  lap ON lap.`content_id`        = lc.`content_id` AND lap.`is_primary` = 'y'\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`        lfp ON lfp.`file_id`           = lap.`foreign_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY {$sort_mode}";
     # Get count of total number of items available
     $query_cant = "\n\t\t\tSELECT COUNT( * )\n\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id` = bp.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ";
     $cant = $this->mDb->getOne($query_cant, $bindVars);
     $pListHash["cant"] = $cant;
     # Check for offset out of range
     if ($pListHash['offset'] < 0) {
         $pListHash['offset'] = 0;
     } elseif ($pListHash['offset'] > $pListHash["cant"]) {
         $lastPageNumber = ceil($pListHash["cant"] / $pListHash['max_records']) - 1;
         $pListHash['offset'] = $pListHash['max_records'] * $lastPageNumber;
     }
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     $ret = array();
     $comment = new LibertyComment();
     while ($res = $result->fetchRow()) {
         $res['no_fatal'] = TRUE;
         $accessError = $this->invokeServices('content_verify_access', $res, FALSE);
         if (empty($accessError)) {
             foreach (array('avatar', 'image') as $img) {
                 $res[$img] = liberty_fetch_thumbnails(array('source_file' => liberty_mime_get_source_file(array('user_id' => $res['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name(array('mime_type' => $res[$img . '_mime_type'], 'name' => $res[$img . '_file_name'])), 'file_name' => basename($res[$img . '_file_name']), 'sub_dir' => $res[$img . '_attachment_id']))));
             }
             $res['thumbnail_url'] = BitBlogPost::getImageThumbnails($res);
             $res['num_comments'] = $comment->getNumComments($res['content_id']);
             $res['post_url'] = BitBlogPost::getDisplayUrlFromHash($res);
             $res['display_url'] = $res['post_url'];
             $res['display_link'] = $this->getDisplayLink($res['title'], $res);
             $res['blogs'] = $this->getBlogMemberships($res['content_id']);
             // trackbacks
             if ($res['trackbacks_from'] != null) {
                 $res['trackbacks_from'] = unserialize($res['trackbacks_from']);
             }
             if (!is_array($res['trackbacks_from'])) {
                 $res['trackbacks_from'] = array();
             }
             $res['trackbacks_from_count'] = count(array_keys($res['trackbacks_from']));
             if ($res['trackbacks_to'] != null) {
                 $res['trackbacks_to'] = unserialize($res['trackbacks_to']);
             }
             if ($res['user_id'] == $gBitUser->mUserId) {
                 $res['ownsblog'] = 'y';
             } else {
                 $res['ownsblog'] = 'n';
             }
             $res['trackbacks_to_count'] = count($res['trackbacks_to']);
             $res['pages'] = $this->getNumberOfPages($res['data']);
             // deal with the parsing
             $parseHash['format_guid'] = $res['format_guid'];
             $parseHash['content_id'] = $res['content_id'];
             $parseHash['user_id'] = $res['user_id'];
             // support for ...split... and auto split
             if (!empty($pListHash['full_data'])) {
                 $parseHash['data'] = $res['data'];
                 $res['parsed'] = $this->parseData($parseHash);
             } else {
                 $parseHash['data'] = $res['data'];
                 $parseHash['no_cache'] = TRUE;
                 $splitArray = $this->parseSplit($parseHash, $gBitSystem->getConfig('blog_posts_description_length', 500));
                 $res = array_merge($res, $splitArray);
             }
             if (!empty($this->mInfo['summary'])) {
                 $res['summary'] = $parseHash['data'] = $this->mInfo['summary'];
                 $parseHash['no_cache'] = TRUE;
                 $res['parsed_summary'] = $this->parsedData($parseHash);
             }
             if (!empty($res['crosspost_note'])) {
                 $res['crosspost_note_raw'] = $parseHash['data'] = $res['crosspost_note'];
                 $parseHash['no_cache'] = TRUE;
                 $res['crosspost_note'] = $this->parseData($parseHash);
             }
             $ret[] = $res;
         } elseif (!empty($accessError)) {
             if (!empty($accessError['access_control'])) {
                 $res['post_url'] = BitBlogPost::getDisplayUrlFromHash($res['content_id'], $res);
                 $res['display_url'] = $res['post_url'];
                 /* this needs to be part of loop that gets all blogs post is in
                 			$res['blog_url'] = BitBlog::getDisplayUrlFromHash( $res['blog_content_id'] );
                 			*/
                 $res["parsed_data"] = $accessError['access_control'];
                 $ret[] = $res;
             }
         } else {
         }
     }
     LibertyContent::postGetList($pListHash);
     return $ret;
 }
Beispiel #5
0
 /**
  * This function generates a list of records from the liberty_content database for use in a list page
  * @param $pParamHash contains an array of conditions to sort by
  * @return array of articles
  * @access public
  **/
 public function getList(&$pParamHash)
 {
     global $gBitSystem, $gBitUser, $gLibertySystem;
     if (empty($pParamHash['sort_mode'])) {
         // no idea what this is supposed to do
         //$pParamHash['sort_mode'] = $gBitSystem->isFeatureActive('articles_auto_approve') ? 'order_key_desc' : 'publish_date_desc';
         $pParamHash['sort_mode'] = 'publish_date_desc';
     }
     LibertyContent::prepGetList($pParamHash);
     $joinSql = '';
     $selectSql = '';
     $bindVars = array();
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash);
     $find = $pParamHash['find'];
     if (is_array($find)) {
         // you can use an array of articles
         $whereSql .= " AND lc.`title` IN( " . implode(',', array_fill(0, count($find), '?')) . " )";
         $bindVars = array_merge($bindVars, $find);
     } elseif (is_string($find)) {
         // or a string
         $whereSql .= " AND UPPER( lc.`title` ) LIKE ? ";
         $bindVars[] = '%' . strtoupper($find) . '%';
     } elseif (@$this->verifyId($pParamHash['user_id'])) {
         // or gate on a user
         $whereSql .= " AND lc.`user_id` = ? ";
         $bindVars[] = (int) $pParamHash['user_id'];
     }
     if (@$this->verifyId($pParamHash['status_id'])) {
         $whereSql .= " AND a.`status_id` = ? ";
         $bindVars[] = $pParamHash['status_id'];
     }
     if (@$this->verifyId($pParamHash['type_id'])) {
         $whereSql .= " AND a.`article_type_id` = ? ";
         $bindVars[] = (int) $pParamHash['type_id'];
     }
     // TODO: we need to check if the article wants to be viewed before / after respective dates
     // someone better at SQL please get this working without an additional db call - xing
     $now = $gBitSystem->getUTCTime();
     if (!empty($pParamHash['show_future']) && !empty($pParamHash['show_expired']) && $gBitUser->hasPermission('p_articles_admin')) {
         // this will show all articles at once - future, current and expired
     } elseif (!empty($pParamHash['show_future']) && $gBitUser->hasPermission('p_articles_admin')) {
         // hide expired articles
         $whereSql .= " AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ) ";
         $bindVars[] = (int) $now;
         $bindVars[] = 'y';
     } elseif (!empty($pParamHash['show_expired']) && $gBitUser->hasPermission('p_articles_admin')) {
         // hide future articles
         $whereSql .= " AND ( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) ";
         $bindVars[] = (int) $now;
         $bindVars[] = 'y';
     } elseif (!empty($pParamHash['get_future'])) {
         // show only future
         // if we're trying to view these articles, we better have the perms to do so
         if (!$gBitUser->hasPermission('p_articles_admin')) {
             return array();
         }
         $whereSql .= " AND a.`publish_date` > ?";
         $bindVars[] = (int) $now;
     } elseif (!empty($pParamHash['get_expired'])) {
         // show only expired articles
         // if we're trying to view these articles, we better have the perms to do so
         if (!$gBitUser->hasPermission('p_articles_admin')) {
             return array();
         }
         $whereSql .= " AND a.`expire_date` < ? ";
         $bindVars[] = (int) $now;
     } else {
         // hide future and expired articles - this is the default behaviour
         // we need all these AND and ORs to ensure that other conditions such as status_id are respected as well
         $whereSql .= " AND (( a.`publish_date` > a.`expire_date` ) OR (( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ))) ";
         $bindVars[] = (int) $now;
         $bindVars[] = 'y';
         $bindVars[] = (int) $now;
         $bindVars[] = 'y';
     }
     if (@$this->verifyId($pParamHash['topic_id'])) {
         $whereSql .= " AND a.`topic_id` = ? ";
         $bindVars[] = (int) $pParamHash['topic_id'];
     } elseif (!empty($pParamHash['topic'])) {
         $whereSql .= " AND UPPER( atopic.`topic_name` ) = ? ";
         $bindVars[] = strtoupper($pParamHash['topic']);
     } else {
         $whereSql .= " AND ( atopic.`active_topic` != 'n' OR atopic.`active_topic` IS NULL ) ";
         //$whereSql .= " AND atopic.`active_topic` != 'n' ";
     }
     // Oracle is very particular about naming multiple columns, so need to explicity name them ORA-00918: column ambiguously defined
     $query = "SELECT\n\t\t\t\ta.`article_id`, a.`description`, a.`author_name`, a.`publish_date`, a.`expire_date`, a.`rating`,\n\t\t\t\tatopic.`topic_id`, atopic.`topic_name`, atopic.`has_topic_image`, atopic.`active_topic`,\n\t\t\t\tastatus.`status_id`, astatus.`status_name`,\n\t\t\t\tlch.`hits`,\n\t\t\t\tatype.*, lc.*, la.`attachment_id` AS `primary_attachment_id`, lf.`file_name` AS `image_attachment_path` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "articles` a\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON( lc.`content_id`         = a.`content_id` )\n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "article_status`   astatus ON( astatus.`status_id`     = a.`status_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON( lc.`content_id`         = lch.`content_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "article_topics`    atopic ON( atopic.`topic_id`       = a.`topic_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "article_types`      atype ON( atype.`article_type_id` = a.`article_type_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`   la ON( la.`content_id`         = lc.`content_id` AND la.`is_primary` = 'y' )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`         lf ON( lf.`file_id`            = la.`foreign_id` )\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pParamHash['sort_mode']);
     $query_cant = "SELECT COUNT( * )FROM `" . BIT_DB_PREFIX . "articles` a\n\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`    lc ON lc.`content_id`   = a.`content_id`\n\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "article_topics` atopic ON atopic.`topic_id` = a.`topic_id` {$joinSql}\n\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "article_types`   atype ON atype.`article_type_id` = a.`article_type_id`\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}";
     $result = $this->mDb->query($query, $bindVars, $pParamHash['max_records'], $pParamHash['offset']);
     $ret = array();
     $comment = new LibertyComment();
     while ($res = $result->fetchRow()) {
         // get this stuff parsed
         $res = array_merge($this->parseSplit($res, $gBitSystem->getConfig('articles_description_length', 500)), $res);
         $res['thumbnail_url'] = static::getImageThumbnails($res);
         $res['num_comments'] = $comment->getNumComments($res['content_id']);
         $res['display_url'] = self::getDisplayUrlFromHash($res);
         $res['display_link'] = $this->getDisplayLink($res['title'], $res);
         // fetch the primary attachment that we can display the file on the front page if needed
         $res['primary_attachment'] = LibertyMime::loadAttachment($res['primary_attachment_id']);
         $ret[] = $res;
     }
     $pParamHash["cant"] = $this->mDb->getOne($query_cant, $bindVars);
     LibertyContent::postGetList($pParamHash);
     return $ret;
 }
Beispiel #6
0
 function getList(&$pListHash)
 {
     global $gBitUser, $gBitSystem;
     $this->prepGetList($pListHash);
     $ret = NULL;
     $bindVars = array();
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     array_push($bindVars, $this->mContentTypeGuid);
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     if (@$this->verifyId($pListHash['gmap_id']) || isset($pListHash['set_id'])) {
         $selectSql .= ", gmk.*, gms.`set_id`, gms.`style_id`, gms.`icon_id` ";
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "gmaps_marker_keychain` gmk ON (gm.`marker_id` = gmk.`marker_id`) ";
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "gmaps_marker_sets` gms ON (gmk.`set_id` = gms.`set_id`) ";
     }
     if (@$this->verifyId($pListHash['user_id'])) {
         array_push($bindVars, (int) $pListHash['user_id']);
         $whereSql .= ' AND lc.`user_id` = ? ';
     }
     // map user to login in case we used one instead of the other
     if (!empty($pListHash['user'])) {
         $pListHash['login'] = $pListHash['user'];
     }
     if (!empty($pListHash['login'])) {
         array_push($bindVars, $pListHash['login']);
         $whereSql .= ' AND uu.`login` = ? ';
     }
     if (isset($pListHash['set_id'])) {
         if (!is_array($pListHash['set_id']) && is_numeric($pListHash['set_id'])) {
             $sets = array($pListHash['set_id']);
         } elseif (is_array($pListHash['set_id'])) {
             $sets = $pListHash['set_id'];
         }
         $hasOne = FALSE;
         foreach ($sets as $value) {
             if (@$this->verifyId($value)) {
                 if ($hasOne != TRUE) {
                     $whereSql .= " AND ( gmk.`set_id` = ? ";
                     $hasOne = TRUE;
                 } else {
                     $whereSql .= " OR gmk.`set_id` = ? ";
                 }
                 array_push($bindVars, (int) $value);
             }
         }
         if ($hasOne == TRUE) {
             $whereSql .= " ) ";
         }
     }
     if (@$this->verifyId($pListHash['gmap_id'])) {
         $selectSql .= ", gsk.* ";
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "gmaps_sets_keychain` gsk ON( gms.`set_id` = gsk.`set_id`) ";
         $whereSql .= " AND gsk.`set_type` = 'markers' AND gsk.`gmap_id` = ? ";
         array_push($bindVars, (int) $pListHash['gmap_id']);
     }
     if (isset($pListHash['favorites'])) {
         $selectSql .= ", ufm.* ";
         $joinSql .= " LEFT JOIN `" . BIT_DB_PREFIX . "users_favorites_map` ufm ON ( lc.`content_id`=ufm.`favorite_content_id` ) ";
         $whereSql .= " AND ufm.`favorite_content_id` IS NOT NULL ";
     }
     switch ($pListHash['sort_mode']) {
         case 'pos_desc':
         case 'pos_asc':
             $sortModePrefix = 'gmk.';
             break;
         default:
             $sortModePrefix = 'lc.';
             break;
     }
     $secondarySortMode = $pListHash['sort_mode'] != 'title_asc' ? ', lc.title ASC' : '';
     $sort_mode = $sortModePrefix . $this->mDb->convertSortmode($pListHash['sort_mode']) . $secondarySortMode;
     $query = "SELECT lc.*, gm.*, \n\t\t\t\t  uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t  uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,\n\t\t\t\t  lf.storage_path AS `image_attachment_path` {$selectSql}\n\t\t\t\t  FROM `" . BIT_DB_PREFIX . "gmaps_markers` gm \n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( gm.`content_id`=lc.`content_id` ) {$joinSql}\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (uuc.`user_id` = lc.`user_id`)\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments`   la ON( la.`content_id`         = lc.`content_id` AND la.`is_primary` = 'y' )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`         lf ON( lf.`file_id`            = la.`foreign_id` )\n\t\t\t\t  WHERE lc.`content_type_guid` = ? {$whereSql}\n\t\t\t\t  ORDER BY {$sort_mode}";
     $query_cant = "\n\t\t\tSELECT COUNT( * )\n\t\t    FROM `" . BIT_DB_PREFIX . "gmaps_markers` gm \n\t\t\t\tINNER JOIN      `" . BIT_DB_PREFIX . "liberty_content`       lc ON lc.`content_id` = gm.`content_id`\n\t\t\t\tINNER JOIN\t\t`" . BIT_DB_PREFIX . "users_users`\t\t\t uu ON uu.`user_id`\t\t\t   = lc.`user_id`\n\t\t\t\t{$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ";
     $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     $cant = $this->mDb->getOne($query_cant, $bindVars);
     $comment = new LibertyComment();
     while ($res = $result->fetchrow()) {
         $res['display_url'] = $this->getDisplayUrl(NULL, $res);
         //need something like this - but need to get the prefs in the query
         $res['allow_comments'] = "n";
         if ($this->getPreference('allow_comments', null, $res['content_id']) == 'y') {
             $res['allow_comments'] = "y";
             $res['num_comments'] = $comment->getNumComments($res['content_id']);
         }
         $res['thumbnail_url'] = liberty_fetch_thumbnails(array("storage_path" => $res['image_attachment_path']));
         /* not sure the best way to go about
          *  cleaning this kind of crap out -
          *  but since gmaps uses plenty of javascript
          *  we can't have this business in here
          *  if someone slipped it in somehow.
          *  there shouldnt be line breaks in titles anyway,
          *  but sometimes someone gets one in. -wjames5
          */
         $res['title'] = str_replace("\n", "", $res['title']);
         // to support html in labels
         $res['parsed_label_data'] = $this->parseData($res['label_data'], $res['format_guid']);
         $res['parsed_label_data'] = addslashes($res['parsed_label_data']);
         // this should escape line breaks for javascript
         $res['label_data'] = addslashes($res['label_data']);
         $res['label_data'] = str_replace("\n", "\\n", $res['label_data']);
         $ret[] = $res;
     }
     $pListHash["data"] = $ret;
     $pListHash["cant"] = $cant;
     LibertyContent::postGetList($pListHash);
     return $pListHash;
 }