Ejemplo n.º 1
0
/**
 * mime_image_create_panorama
 *
 * @param array $pStoreRow
 * @access public
 * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
 */
function mime_image_create_panorama(&$pStoreRow)
{
    global $gBitSystem, $gThumbSizes;
    // we know the panorama image will be a jpeg, so we don't need the canThumbFunc check here
    if (($panoramaFunc = liberty_get_function('panorama')) && !empty($pStoreRow['source_file']) && is_file($pStoreRow['source_file'])) {
        // the panorama has to be a jpg
        $gBitSystem->setConfig('liberty_thumbnail_format', 'jpg');
        $width = $gBitSystem->getConfig('mime_image_panorama_width', 3000);
        $gThumbSizes['panorama'] = array($width, $width / 2);
        // for the panorama, we will force a quality lower than 75 to reduce image size
        if ($gBitSystem->getConfig('liberty_thumbnail_quality', 85) > 75) {
            $gBitSystem->setConfig('liberty_thumbnail_quality', 75);
        }
        $genHash = array('attachment_id' => $pStoreRow['attachment_id'], 'dest_branch' => liberty_mime_get_storage_branch(array('sub_dir' => $pStoreRow['attachment_id'], 'user_id' => $pStoreRow['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name($pStoreRow))), 'file_name' => dirname($pStoreRow['file_name']) . "/", 'source_file' => $pStoreRow['source_file'], 'type' => $pStoreRow['mime_type'], 'thumbnail_sizes' => array('panorama'));
        if (liberty_generate_thumbnails($genHash)) {
            // we want to modify the panorama
            $genHash['source_file'] = $genHash['icon_thumb_path'];
            if (!$panoramaFunc($genHash)) {
                $pStoreRow['errors']['panorama'] = $genHash['error'];
            }
        }
        return empty($pStoreRow['errors']);
    }
}
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 function liberty_mime_get_source_file($pParamHash)
 {
     if (empty($pParamHash['package'])) {
         $pParamHash['package'] = liberty_mime_get_storage_sub_dir_name(array('type' => BitBase::getParameter($pParamHash, 'mime_type'), 'name' => BitBase::getParameter($pParamHash, 'file_name')));
     }
     if (empty($pParamHash['sub_dir'])) {
         $pParamHash['sub_dir'] = BitBase::getParameter($pParamHash, 'attachment_id');
     }
     return STORAGE_PKG_PATH . liberty_mime_get_storage_branch($pParamHash) . basename(BitBase::getParameter($pParamHash, 'file_name'));
 }
Ejemplo n.º 4
0
 function mime_default_load($pFileHash, &$pPrefs)
 {
     global $gBitSystem, $gLibertySystem;
     $ret = FALSE;
     if (@BitBase::verifyId($pFileHash['attachment_id'])) {
         $query = "\n\t\t\t\tSELECT la.`attachment_id`, la.`content_id`, la.`attachment_plugin_guid`, la.`foreign_id`, la.`user_id`, la.`is_primary`, la.`pos`, la.`error_code`, la.`caption`, la.`hits` AS `downloads`,\n\t\t\t\t\tlf.`file_id`, lf.`user_id`, lf.`file_name`, lf.`file_size`, lf.`mime_type`\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_attachments` la\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf ON( la.`foreign_id` = lf.`file_id` )\n\t\t\t\tWHERE la.`attachment_id`=?";
         if ($row = $gBitSystem->mDb->getRow($query, array($pFileHash['attachment_id']))) {
             $ret = array_merge($pFileHash, $row);
             $storageName = basename($row['file_name']);
             // compatibility with _FILES hash
             $row['name'] = $storageName;
             $defaultFileName = liberty_mime_get_default_file_name($row['file_name'], $row['mime_type']);
             $storageBranchPath = liberty_mime_get_storage_branch(array('sub_dir' => $row['attachment_id'], 'user_id' => $row['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name($row)));
             $storageBranch = $storageBranchPath . $defaultFileName;
             if (!file_exists(STORAGE_PKG_PATH . $storageBranch)) {
                 $storageBranch = liberty_mime_get_storage_branch(array('sub_dir' => $row['attachment_id'], 'user_id' => $row['user_id'], 'package' => liberty_mime_get_storage_sub_dir_name($row))) . $storageName;
             }
             // this will fetch the correct thumbnails
             $thumbHash['source_file'] = STORAGE_PKG_PATH . $storageBranch;
             $row['source_file'] = STORAGE_PKG_PATH . $storageBranch;
             $canThumbFunc = liberty_get_function('can_thumbnail');
             if ($canThumbFunc && $canThumbFunc($row['mime_type'])) {
                 $thumbHash['default_image'] = LIBERTY_PKG_URL . 'icons/generating_thumbnails.png';
             }
             $ret['thumbnail_url'] = liberty_fetch_thumbnails($thumbHash);
             // indicate that this is a mime thumbnail
             if (!empty($ret['thumbnail_url']['medium']) && strpos($ret['thumbnail_url']['medium'], '/mime/')) {
                 $ret['thumbnail_is_mime'] = TRUE;
             }
             // pretty URLs
             if ($gBitSystem->isFeatureActive("pretty_urls") || $gBitSystem->isFeatureActive("pretty_urls_extended")) {
                 $ret['display_url'] = LIBERTY_PKG_URL . "view/file/" . $row['attachment_id'];
             } else {
                 $ret['display_url'] = LIBERTY_PKG_URL . "view_file.php?attachment_id=" . $row['attachment_id'];
             }
             // legacy table data was named storage path and included a partial path. strip out any path just in case
             $ret['file_name'] = $storageName;
             $ret['preferences'] = $pPrefs;
             // some stuff is only available if we have a source file
             //    make sure to check for these when you use them. frequently the original might not be available
             //    e.g.: video files are large and the original might be deleted after conversion
             if (is_file(STORAGE_PKG_PATH . $storageBranch)) {
                 $ret['mime_type'] = $row['mime_type'];
                 $ret['source_file'] = STORAGE_PKG_PATH . $storageBranch;
                 $ret['source_url'] = STORAGE_PKG_URL . $storageBranch;
                 $ret['last_modified'] = filemtime($ret['source_file']);
                 $ret['download_url'] = LibertyMime::getAttachmentDownloadUrl($row['attachment_id']);
             }
             // add a description of how to insert this file into a wiki page
             if ($gLibertySystem->isPluginActive('dataattachment')) {
                 $ret['wiki_plugin_link'] = "{attachment id=" . $row['attachment_id'] . "}";
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 5
0
 function getBlog($pBlogId, $pContentId = NULL)
 {
     global $gBitSystem;
     $ret = NULL;
     $lookupId = !empty($pBlogId) ? $pBlogId : $pContentId;
     $lookupColumn = !empty($pBlogId) ? 'blog_id' : 'content_id';
     $bindVars = array((int) $lookupId);
     $selectSql = '';
     $joinSql = '';
     $whereSql = '';
     $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     if (BitBase::verifyId($lookupId)) {
         $query = "\n\t\t\t\tSELECT b.*, lc.*, lch.`hits`, uu.`login`, uu.`login`, uu.`user_id`, 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\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "blogs` b\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = b.`content_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON (uu.`user_id` = lc.`user_id`)\n\t\t\t\t\t{$joinSql}\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON (lc.`content_id` = lch.`content_id`)\n\t\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\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`\t    lfa ON lfa.`file_id`\t\t   = laa.`foreign_id`\n\t\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\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files`        lfp ON lfp.`file_id`           = lap.`foreign_id`\n\t\t\t\tWHERE b.`{$lookupColumn}`= ? {$whereSql}";
         if ($this->mInfo = $this->mDb->getRow($query, $bindVars)) {
             $this->mContentId = $this->getField('content_id');
             $this->mBlogId = $this->getField('blog_id');
             foreach (array('avatar', 'image') as $img) {
                 $this->mInfo[$img] = liberty_fetch_thumbnails(array('source_file' => $this->getSourceFile(array('user_id' => $this->getField('user_id'), 'package' => liberty_mime_get_storage_sub_dir_name(array('type' => $this->getField($img . '_mime_type'), 'name' => $this->getField($img . '_file_name'))), 'file_name' => basename($this->mInfo[$img . '_file_name']), 'sub_dir' => $this->getField($img . '_attachment_id')))));
             }
             parent::load();
             $this->mInfo['postscant'] = $this->getPostsCount($this->mContentId);
         }
     }
     return count($this->mInfo) != 0;
 }
Ejemplo n.º 6
0
 function liberty_mime_get_source_file($pParamHash)
 {
     $fileName = BitBase::getParameter($pParamHash, 'file_name');
     if (empty($pParamHash['package'])) {
         $pParamHash['package'] = liberty_mime_get_storage_sub_dir_name(array('mime_type' => BitBase::getParameter($pParamHash, 'mime_type'), 'name' => $fileName));
     }
     if (empty($pParamHash['sub_dir'])) {
         $pParamHash['sub_dir'] = BitBase::getParameter($pParamHash, 'attachment_id');
     }
     $defaultFileName = liberty_mime_get_default_file_name($fileName, $pParamHash['mime_type']);
     $ret = STORAGE_PKG_PATH . liberty_mime_get_storage_branch($pParamHash) . $defaultFileName;
     if (!file_exists($ret)) {
         $ret = STORAGE_PKG_PATH . liberty_mime_get_storage_branch($pParamHash) . basename(BitBase::getParameter($pParamHash, 'file_name'));
     }
     return $ret;
 }
Ejemplo n.º 7
0
 /**
  * getList get a list of users
  *
  * @param array $pParamHash
  * @access public
  * @return array of users
  */
 function getList(&$pParamHash)
 {
     global $gBitSystem, $gBitUser;
     if (empty($pParamHash['sort_mode'])) {
         $pParamHash['sort_mode'] = 'registration_date_desc';
     }
     LibertyContent::prepGetList($pParamHash);
     $selectSql = $joinSql = $whereSql = '';
     $bindVars = array();
     array_push($bindVars, 'bituser');
     $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash);
     // limit search to users with a specific language
     if (!empty($pParamHash['lang_code'])) {
         $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "liberty_content_prefs` lcp ON ( lcp.`content_id`=uu.`content_id` AND lcp.`pref_name`='bitlanguage' )";
         $whereSql .= " AND lcp.`pref_value`=? ";
         $bindVars[] = $pParamHash['lang_code'];
     }
     if (!$gBitUser->hasPermission('p_users_admin')) {
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_prefs` lcp2 ON ( lcp2.`content_id`=uu.`content_id` AND lcp2.`pref_name`='users_information' )";
         $whereSql .= " AND (lcp2.`pref_value` IS NULL OR lcp2.`pref_value`='public')";
     }
     // limit search to users with a specific IP
     if (!empty($pParamHash['ip'])) {
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_cnxn` uc ON ( uu.`user_id`=uc.`user_id`) ";
         $ips = explode(',', $pParamHash['ip']);
         $whereSql .= ' AND ( ';
         do {
             $ip = array_pop($ips);
             if (strpos($ip, '%')) {
                 $whereSql .= " uc.`ip` LIKE ? ";
             } else {
                 $whereSql .= " uc.`ip`=? ";
             }
             $bindVars[] = $ip;
             if (!empty($ips)) {
                 $whereSql .= ' OR ';
             }
         } while ($ips);
         $whereSql .= ' ) ';
     }
     // limit to registrations over a time period like 'YYYY-MM-DD' or 'Y \Week W' or anything convertible by SQLDate
     if (!empty($pParamHash['period'])) {
         $sqlPeriod = $this->mDb->SQLDate($this->mDb->getPeriodFormat($pParamHash['period']), $this->mDb->SQLIntToTimestamp('registration_date'));
         $whereSql .= ' AND ' . $sqlPeriod . '=?';
         $bindVars[] = $pParamHash['timeframe'];
     }
     // lets search for a user
     if ($pParamHash['find']) {
         $whereSql .= " AND ( UPPER( uu.`login` ) LIKE ? OR UPPER( uu.`real_name` ) LIKE ? OR UPPER( uu.`email` ) LIKE ? ) ";
         $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%';
         $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%';
         $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%';
     }
     if ($gBitSystem->isPackageActive('stats')) {
         $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "stats_referer_users_map` srum ON (srum.`user_id`=uu.`user_id`)\n\t\t\t\t\t\t  LEFT OUTER JOIN `" . BIT_DB_PREFIX . "stats_referer_urls` sru ON (srum.`referer_url_id`=sru.`referer_url_id`)";
         $selectSql .= ", sru.`referer_url`";
         if (!empty($pParamHash['referer'])) {
             if ($pParamHash['referer'] == 'none') {
                 $whereSql .= " AND `referer_url` IS NULL";
             } else {
                 $whereSql .= " AND `referer_url` LIKE ?";
                 $bindVars[] = '%' . strtolower($pParamHash['find']) . '%';
             }
         }
     }
     // Return an array of users indicating name, email, last changed pages, versions, last_login
     $query = "\n\t\t\tSELECT uu.*, lc.`content_status_id`, lf_ava.`file_name` AS `avatar_file_name`, lf_ava.`mime_type` AS `avatar_mime_type`, la_ava.`attachment_id` AS `avatar_attachment_id` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "users_users` uu\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (uu.`content_id`=lc.`content_id`)\n\t\t\t\t{$joinSql}\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_attachments` la_ava ON ( uu.`avatar_attachment_id`=la_ava.`attachment_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf_ava ON ( lf_ava.`file_id`=la_ava.`foreign_id` )\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ORDER BY " . $this->mDb->convertSortmode($pParamHash['sort_mode']);
     $result = $this->mDb->query($query, $bindVars, $pParamHash['max_records'], $pParamHash['offset']);
     $ret = array();
     while ($res = $result->fetchRow()) {
         // Used for pulling out dead/empty/spam accounts
         if (isset($pParamHash['max_content_count']) && is_numeric($pParamHash['max_content_count'])) {
             $contentCount = $this->mDb->getOne("SELECT COUNT(*) FROM  `" . BIT_DB_PREFIX . "liberty_content` lc INNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( lc.`user_id`=uu.`user_id` ) WHERE uu.`user_id`=? AND `content_type_guid` != 'bituser'", array($res['user_id']));
             if ($contentCount > $pParamHash['max_content_count']) {
                 continue;
             }
         }
         // Used for pulling out non-idle accounts or pigs
         if (isset($pParamHash['min_content_count']) && is_numeric($pParamHash['min_content_count'])) {
             $contentCount = $this->mDb->getOne("SELECT COUNT(*) FROM  `" . BIT_DB_PREFIX . "liberty_content` lc INNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( lc.`user_id`=uu.`user_id` ) WHERE uu.`user_id`=? AND `content_type_guid` != 'bituser'", array($res['user_id']));
             if ($contentCount < $pParamHash['min_content_count']) {
                 continue;
             }
         }
         if (!empty($res['referer_url'])) {
             if ($gBitSystem->isPackageActive('stats')) {
                 $res['short_referer_url'] = stats_referer_display_short($res['referer_url']);
             }
         }
         if (!empty($res['avatar_file_name'])) {
             $res['avatar_url'] = $this->getSourceUrl(array('attachment_id' => $res['avatar_attachment_id'], 'mime_type' => $res['avatar_mime_type'], 'file_name' => $res['avatar_file_name']));
             $res['thumbnail_url'] = liberty_fetch_thumbnail_url(array('source_file' => $this->getSourceFile(array('sub_dir' => $res['avatar_attachment_id'], 'user_id' => $res['user_id'], 'file_name' => $res['avatar_file_name'], 'mime_type' => $res['avatar_mime_type'], 'package' => liberty_mime_get_storage_sub_dir_name(array('mime_type' => $res['avatar_mime_type'], 'name' => $res['avatar_file_name'])))), 'file_name' => $res['avatar_url'], 'size' => 'avatar'));
         }
         $res["roles"] = $this->getRoles($res['user_id']);
         $ret[$res['user_id']] = $res;
     }
     $retval = array();
     $query = "\n\t\t\tSELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "users_users` uu\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (uu.`content_id`=lc.`content_id`) {$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}";
     $pParamHash["cant"] = $this->mDb->getOne($query, $bindVars);
     LibertyContent::postGetList($pParamHash);
     return $ret;
 }
Ejemplo n.º 8
0
 function getStoragePath($pParamHash, $pRootDir = NULL)
 {
     $pParamHash['sub_dir'] = liberty_mime_get_storage_sub_dir_name(array('type' => BitBase::getParameter($pParamHash, 'mime_type', $this->getField('mime_type')), 'name' => BitBase::getParameter($pParamHash, 'file_name', $this->getField('file_name'))));
     $pParamHash['user_id'] = $this->getParameter($pParamHash, 'user_id', $this->getField('user_id'));
     return parent::getStoragePath($pParamHash) . $this->getParameter($pParamHash, 'attachment_id', $this->getField('attachment_id')) . '/';
 }