コード例 #1
0
ファイル: pump_blogs_inc.php プロジェクト: bitweaver/blogs
 */
// keep in mind that most recent blog posts are show at the top of the blog
/**
 * required setup
 */
include_once BLOGS_PKG_PATH . 'BitBlog.php';
$pageHash = array('fSavePage' => TRUE, 'format_guid' => 'tikiwiki', 'title' => 'bitweaver Blog', 'edit' => 'Sample Blog added during the installation process', 'use_title' => 'y', 'max_posts' => '10', 'use_title' => 'on', 'use_find' => 'on', 'allow_comments' => 'on');
$gBlog = new BitBlog();
if ($gBlog->store($pageHash)) {
    $blogPostHash = array(array('fSavePage' => TRUE, 'format_guid' => 'tikiwiki', 'blog_content_id' => array($gBlog->mContentId), 'trackback' => NULL, 'title' => 'Lorem Ipsum', 'edit' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum molestie lectus quis elit. Suspendisse scelerisque augue vitae ipsum. Maecenas quis enim. Suspendisse at turpis sed sem ullamcorper aliquam. Aliquam pede ligula, auctor vitae, interdum eget, aliquam vitae, magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam varius feugiat neque. Pellentesque varius. Fusce a mi in nulla porta aliquam. Morbi scelerisque, turpis quis sodales blandit, libero lorem faucibus dui, sit amet lacinia sem pede in quam. Pellentesque tempor suscipit sem. Nam sed augue. 

	Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam. 

	Donec nec velit. Mauris scelerisque vestibulum ante. Nulla congue commodo lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aenean posuere, magna sit amet pharetra consectetuer, erat sapien ultricies elit, sit amet sollicitudin sem nibh vitae erat. Proin commodo feugiat nunc. Proin in eros. Fusce nec ante. Nulla convallis mi quis arcu. Duis quam. Cras arcu sem, posuere ut, sodales sit amet, blandit eu, orci. Sed tincidunt egestas est. Curabitur tempus, ipsum ut blandit accumsan, odio tellus egestas ipsum, sit amet cursus lacus velit et est. Nulla at sem. Aliquam quam purus, bibendum ut, tristique sollicitudin, interdum eget, ante. Nulla a ligula. Mauris scelerisque sem a odio. Quisque a nunc sed risus eleifend rutrum. Maecenas vitae lacus.
	'), array('fSavePage' => TRUE, 'format_guid' => 'tikiwiki', 'blog_content_id' => array($gBlog->mContentId), 'trackback' => NULL, 'title' => 'Another Blog', 'edit' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum molestie lectus quis elit. Suspendisse scelerisque augue vitae ipsum. Maecenas quis enim. Suspendisse at turpis sed sem ullamcorper aliquam. Aliquam pede ligula, auctor vitae, interdum eget, aliquam vitae, magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam varius feugiat neque. Pellentesque varius. Fusce a mi in nulla porta aliquam. Morbi scelerisque, turpis quis sodales blandit, libero lorem faucibus dui, sit amet lacinia sem pede in quam. Pellentesque tempor suscipit sem. Nam sed augue. 

	Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam. 
	'), array('fSavePage' => TRUE, 'format_guid' => 'tikiwiki', 'blog_content_id' => array($gBlog->mContentId), 'trackback' => NULL, 'title' => 'Welcome', 'edit' => 'This is the blogs package of bitweaver. A blog is short for __web log__ and is basically a journal that is available on the web. The activity of updating a blog is "blogging" and someone who keeps a blog is a "blogger." Blogs are typically updated daily using software that allows people with little or no technical background to update and maintain the blog. Postings on a blog are almost always arranged in cronological order with the most recent additions featured most prominantly.

	If you have added the __Package Wiki__ to your isntallation and added the wiki sample data, you will notice that it is possible to link to those pages using simple wiki words such as bitweaverGlossary.
	'));
    foreach ($blogPostHash as $blogPost) {
        $newPost = new BitBlogPost(NULL);
        if ($newPost->store($blogPost)) {
            $pumpedData['Blog'][] = $blogPost['title'];
        } else {
            $error = $newPost->mErrors;
            $gBitSmarty->assign('error', $error);
        }
    }
}
コード例 #2
0
ファイル: data.blog.php プロジェクト: bitweaver/blogs
function data_blog($data, $params)
{
    // No change in the parameters with Clyde
    global $gLibertySystem, $gBitSmarty, $gBitSystem, $gBitUser;
    $display_result = "";
    if ($gBitSystem->isPackageActive('blogs') && $gBitUser->hasPermission('p_blogs_view')) {
        // The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
        $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATABLOG];
        require_once BLOGS_PKG_PATH . 'BitBlog.php';
        require_once LIBERTY_PKG_PATH . 'lookup_content_inc.php';
        $module_params = $params;
        if (isset($module_params['id'])) {
            $gBitSmarty->assign('blog_id', $module_params['id']);
        }
        $blogPost = new BitBlogPost();
        $sortOptions = array("publish_date_desc", "publish_date_asc", "last_modified_asc", "last_modified_desc", "created_asc", "created_desc", "random");
        if (!empty($module_params['sort_mode']) && in_array($module_params['sort_mode'], $sortOptions)) {
            $sort_mode = $module_params['sort_mode'];
        } else {
            $sort_mode = 'publish_date_desc';
        }
        $getHash = array();
        if (isset($module_params['user'])) {
            $getHash['user'] = $module_params['user'];
        }
        if (isset($module_params['id'])) {
            $getHash['blog_id'] = $module_params['id'];
        }
        if (isset($module_params['group_id'])) {
            $getHash['group_id'] = $module_params['group_id'];
        }
        if (isset($module_params['role_id'])) {
            $getHash['role_id'] = $module_params['role_id'];
        }
        // handle draft posts
        $getHash['enforce_status'] = TRUE;
        // @TODO enable lists that include draft posts
        // the current tpl configuration doesnt allow us to support draft lists right now
        // there is an object reference problem in liberty::service_content_body_inc.tpl
        // if the object reference problem in the above mentions tpl is patched then use this if to enable drafts
        // if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){
        if (FALSE) {
            // if we are getting drafts then get future posts too
            $getHash['show_future'] = TRUE;
            $getHash['min_status_id'] = -6;
            $getHash['max_status_id'] = -4;
            $getHash['min_owner_status_id'] = -6;
            // limit by user
            $getHash['user_id'] = $gBitUser->mUserId;
        } else {
            $getHash['min_owner_status_id'] = 0;
        }
        $getHash['sort_mode'] = $sort_mode;
        $getHash['parse_data'] = TRUE;
        $getHash['max_records'] = empty($module_params['max']) ? 1 : $module_params['max'];
        $getHash['load_num_comments'] = TRUE;
        $getHash['page'] = !empty($module_params['page']) ? $module_params['page'] : 1;
        $getHash['offset'] = !empty($module_params['offset']) ? $module_params['offset'] : 0;
        $blogPosts = $blogPost->getList($getHash);
        $display_format = empty($module_params['format']) ? 'simple_title_list' : $module_params['format'];
        switch ($display_format) {
            case 'full':
                $display_result = '<div class="blogs">';
                if ($gBitSystem->isPackageActive('rss')) {
                    if (isset($module_params['user'])) {
                        $rssUser = new BitUser();
                        $rssUser->load(false, $module_params['user']);
                        $rssUserId = $rssUser->getField('user_id');
                    }
                    $rssPath = BLOGS_PKG_URL . 'blogs_rss.php?' . (isset($module_params['id']) ? 'blog_id=' . $module_params['id'] : "") . (isset($module_params['id']) && isset($rssUserId) ? "&" : "") . (isset($rssUserId) ? 'user_id=' . $rssUserId : "") . (isset($rssUserId) && isset($module_params['group_id']) ? "&" : "") . (isset($module_params['group_id']) ? 'group_id=' . $module_params['group_id'] : "") . (isset($rssUserId) && isset($module_params['role_id']) ? "&" : "") . (isset($module_params['role_id']) ? 'role_id=' . $module_params['role_id'] : "");
                    // something like this would be better, calling smarty directly so translation can also be called -wjames5
                    // $rssIcon = smarty_function_biticon( array('ipackage'=>"rss", 'iname'="rss-16x16", 'iexplain'=>"RSS feed"), &$gBitSmarty );
                    $display_result .= '<div class="floaticon"><a title="RSS feed" href="' . $rssPath . '"><img src="' . BIT_ROOT_URL . 'rss/icons/rss-16x16.png" alt="RSS feed" title="RSS feed" class="icon" /></a></div>';
                }
                $gBitSmarty->assign('showDescriptionsOnly', TRUE);
                foreach ($blogPosts['data'] as $aPost) {
                    $gBitSmarty->assign('aPost', $aPost);
                    $display_result .= $gBitSmarty->fetch('bitpackage:blogs/blog_list_post.tpl');
                }
                $display_result .= '</div>';
                $display_result = eregi_replace("\n", "", $display_result);
                break;
            case 'list':
            default:
                $display_result = "<ul>";
                foreach ($blogPosts['data'] as $post) {
                    $link = $blogPost->getDisplayLink($post['title'], $post);
                    $display_result .= "<li>{$link}</li>\n";
                }
                $display_result .= "</ul>\n";
                break;
        }
    } else {
        $display_result = '<div class=error>' . tra('Blogs Package Deactivated.') . '</div>';
    }
    return $display_result;
}
コード例 #3
0
ファイル: BitBlogPost.php プロジェクト: bitweaver/blogs
 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;
 }
コード例 #4
0
ファイル: blogs_rss.php プロジェクト: bitweaver/blogs
$gBitSystem->verifyPackage('rss');
$gBitSystem->verifyPackage('blogs');
$gBitSystem->verifyFeature('blogs_rss');
require_once BLOGS_PKG_PATH . 'BitBlogPost.php';
require_once RSS_PKG_PATH . "rss_inc.php";
// default feed info
$rss->title = $gBitSystem->getConfig('blogs_rss_title', $gBitSystem->getConfig('site_title') . ' - ' . tra('Blog Posts'));
$rss->description = $gBitSystem->getConfig('blogs_rss_description', $gBitSystem->getConfig('site_title') . ' - ' . tra('RSS Feed'));
// check permission to view wiki pages
if (!$gBitUser->hasPermission('p_blogs_view')) {
    require_once RSS_PKG_PATH . "rss_error.php";
} else {
    // check if we want to use the cache file
    $cacheFile = TEMP_PKG_PATH . RSS_PKG_NAME . '/' . BLOGS_PKG_NAME . (!empty($_REQUEST['user_id']) ? "_" . $_REQUEST['user_id'] : "") . (!empty($_REQUEST['group_id']) ? "_" . $_REQUEST['group_id'] : "") . (!empty($_REQUEST['role_id']) ? "_" . $_REQUEST['role_id'] : "") . (!empty($_REQUEST['blog_id']) ? "_" . $_REQUEST['blog_id'] : "") . '_' . $cacheFileTail;
    $rss->useCached($rss_version_name, $cacheFile, $gBitSystem->getConfig('rssfeed_cache_time'));
    $blogPost = new BitBlogPost();
    $listHash['sort_mode'] = 'last_modified_desc';
    $listHash['max_records'] = $gBitSystem->getConfig('blogs_rss_max_records', 10);
    $listHash['parse_data'] = TRUE;
    $listHash['full_data'] = TRUE;
    if (!empty($_REQUEST['user_id'])) {
        if ($gBitSystem->getConfig('user_class', 'BitPermUser') == 'RolePermUser') {
            require_once USERS_PKG_PATH . 'RoleUser.php';
        } else {
            require_once USERS_PKG_PATH . 'BitUser.php';
        }
        $blogUser = new BitUser();
        $userData = $blogUser->getUserInfo(array('user_id' => $_REQUEST['user_id']));
        // dont try and fool me
        if (!empty($userData)) {
            $userName = $userData['real_name'] ? $userData['real_name'] : $userData['login'];
コード例 #5
0
ファイル: categ_lib.php プロジェクト: bitweaver/categories
 function categorize_blog_post($post_id, $category_id, $purge = false)
 {
     global $gBlog;
     // Check if we already have this object in the categories_objects page
     $cat_object_id = $this->is_categorized('blogpost', $post_id);
     if (!$cat_object_id) {
         // The page is not cateorized
         $blogPost = new BitBlogPost($post_id);
         if ($blogPost->load()) {
             $href = BLOGS_PKG_URL . 'view_post.php?post_id=' . $post_id;
             $cat_object_id = $this->add_categorized_object('blogpost', $post_id, $blogPost->mInfo["user"], $blogPost->mInfo["title"], $href);
         }
     } elseif ($purge) {
         $query = "delete from `" . BIT_DB_PREFIX . "categories_objects_map` where `cat_object_id`=? and `category_id`=?";
         $this->mDb->query($query, array($cat_object_id, $category_id));
     }
     $this->categorize($cat_object_id, $category_id);
 }
コード例 #6
0
$listHash['blog_id'] = $gContent->getField('blog_id');
$listHash['parse_data'] = TRUE;
$listHash['max_records'] = $gContent->getField('max_posts');
$listHash['load_num_comments'] = TRUE;
$blogPosts = $blogPost->getList($listHash);
if (count($blogPosts)) {
    // If there're more records then assign next_offset
    $gBitSmarty->assignByRef('blogPosts', $blogPosts);
    $gBitSmarty->assign('listInfo', $listHash);
} elseif ($gContent->hasPostPermission()) {
    bit_redirect(BLOGS_PKG_URL . 'post.php?blog_id=' . $gContent->getField('blog_id'));
}
if ($gBitSystem->isFeatureActive('users_watches')) {
    if ($gBitUser->isValid() && isset($_REQUEST['watch_event'])) {
        if ($_REQUEST['watch_action'] == 'add') {
            $blogPost = new BitBlogPost($_REQUEST['watch_object']);
            if ($blogPost->load()) {
                $gBitUser->storeWatch($_REQUEST['watch_event'], $_REQUEST['watch_object'], tra('blog'), $blogPost->getTitle(), $blogPost->getDisplayUrl());
            }
        } else {
            $gBitUser->expungeWatch($_REQUEST['watch_event'], $_REQUEST['watch_object']);
        }
    }
    $gBitSmarty->assign('user_watching_blog', 'n');
    if ($watch = $gBitUser->getEventWatches('blog_post', $listHash['blog_id'])) {
        $gBitSmarty->assign('user_watching_blog', 'y');
    }
}
$gBitSmarty->assign('descriptionLength', $gBitSystem->getConfig('blog_posts_description_length', 500));
$gBitSmarty->assign('showDescriptionsOnly', TRUE);
if ($gBitSystem->isFeatureActive('blog_ajax_more') && $gBitThemes->isJavascriptEnabled()) {
コード例 #7
0
ファイル: BitBlog.php プロジェクト: bitweaver/blogs
 function getPostsCount($pBlogContentId)
 {
     global $gBitSystem;
     $ret = NULL;
     if (@$this->verifyId($pBlogContentId)) {
         $whereSql = 'bpm.`blog_content_id` = ?';
         $bindVars = array((int) $pBlogContentId);
         BitBlogPost::getDateRestrictions(array(), $whereSql, $bindVars);
         $query = "SELECT COUNT(*)\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "blogs_posts_map` bpm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "blog_posts` bp ON (bpm.`post_content_id`=bp.`content_id`)\n\t\t\t\tWHERE {$whereSql}";
         $ret = $this->mDb->getOne($query, $bindVars);
     } else {
         $this->mErrors['content_id'] = "Invalid blog content id.";
     }
     return $ret;
 }
コード例 #8
0
ファイル: xmlrpc.php プロジェクト: bitweaver/xmlrpc
function getPost($params)
{
    global $gBitSystem, $userlib, $gBlog;
    $appkeyp = $params->getParam(0);
    $appkey = $appkeyp->scalarval();
    $blogidp = $params->getParam(1);
    $postid = $blogidp->scalarval();
    $usernamep = $params->getParam(2);
    $username = $usernamep->scalarval();
    $passwordp = $params->getParam(3);
    $password = $passwordp->scalarval();
    // Now check if the user is valid and if the user can post a submission
    if (!$gBitUser->validate($username, $password, '', '')) {
        return new xmlrpcresp(0, 101, "Invalid username or password");
    }
    if (!check_individual($username, $blogid, 'p_blogs_post')) {
        return new xmlrpcresp(0, 101, "User is not allowed to post to this weblog due to individual restrictions for this weblog");
    }
    if (!$gBitUser->user_has_permission($username, 'p_blogs_post')) {
        return new xmlrpcresp(0, 101, "User is not allowed to post");
    }
    if (!$gBitUser->user_has_permission($username, 'p_blogs_view')) {
        return new xmlrpcresp(0, 101, "Permission denied to read this blog");
    }
    // Now get the post information
    $blogPost = new BitBlogPost($postid);
    if ($blogPost->load()) {
        #  $dateCreated=date("Ymd",$post_data["created"])."T".date("h:i:s",$post_data["created"]);
        $dateCreated = $gBitSystem->get_iso8601_datetime($blogPost->mInfo["created"]);
        // added dateTime type for blogger compliant xml tag Joerg Knobloch <*****@*****.**>
        $myStruct = new xmlrpcval(array("userid" => new xmlrpcval($username), "dateCreated" => new xmlrpcval($dateCreated, "dateTime.iso8601"), "content" => new xmlrpcval("<title>" . $blogPost->mInfo["title"] . "</title>" . $blogPost->mInfo["data"]), "postid" => new xmlrpcval($blogPost->mInfo["post_id"])), "struct");
        // User ok and can submit then submit an article
    } else {
        return new xmlrpcresp(0, 101, "Post not found");
    }
    return new xmlrpcresp($myStruct);
}
コード例 #9
0
ファイル: lookup_post_inc.php プロジェクト: bitweaver/blogs
<?php

/**
 * @package blogs
 * @subpackage functions
 */
/**
 * Initial Setup
 */
global $gContent;
require_once BLOGS_PKG_PATH . 'BitBlogPost.php';
require_once LIBERTY_PKG_PATH . 'lookup_content_inc.php';
if (empty($gContent) || !is_object($gContent) || !$gContent->isValid()) {
    // if blog_id supplied, use that
    if (@BitBase::verifyId($_REQUEST['post_id'])) {
        $gContent = new BitBlogPost($_REQUEST['post_id']);
        $gContent->load();
    } elseif (@BitBase::verifyId($_REQUEST['content_id'])) {
        $gContent = new BitBlogPost(NULL, $_REQUEST['content_id']);
        $gContent->load();
    } else {
        $gContent = new BitBlogPost();
    }
    $gBitSmarty->assignByRef('gContent', $gContent);
}
コード例 #10
0
ファイル: BitReBlog.php プロジェクト: bitweaver/reblog
 /**
  * This function stores a RSS feed item as a blog post
  **/
 function reblogItem(&$pParamHash)
 {
     require_once BLOGS_PKG_PATH . 'BitBlogPost.php';
     $blogPost = new BitBlogPost();
     $postHash = array();
     $postHash['data'] = $pParamHash['item']->get_content();
     $postHash['title'] = $pParamHash['item']->get_title();
     $postHash['user_id'] = $pParamHash['user_id'];
     $postHash['format_guid'] = $pParamHash['format_guid'];
     $postHash['publish_date'] = $postHash['expire_date'] = $pParamHash['publish_date'];
     if ($blogPost->store($postHash)) {
         $itemHash;
         $itemHash['item_id'] = $pParamHash['item']->get_id($pParamHash['use_hash']);
         $itemHash['item_link'] = $pParamHash['item']->get_link();
         $author = $pParamHash['item']->get_author();
         $itemHash['item_author'] = !empty($author) ? $author->get_name() : NULL;
         $itemHash['content_id'] = $blogPost->mInfo['content_id'];
         $itemHash['feed_id'] = $this->mFeedId;
         //store a reference to the blog post item in the reblog item map
         $this->mDb->StartTrans();
         $table = BIT_DB_PREFIX . "reblog_items_map";
         $result = $this->mDb->associateInsert($table, $itemHash);
         $this->mDb->CompleteTrans();
     }
     return $blogPost->mErrors;
 }
コード例 #11
0
ファイル: wp-migrate.php プロジェクト: bitweaver/blogs
function migrate_wp_post_map()
{
    global $wpdb, $gBitSystem, $gBitSmarty, $gUserMap, $gErrorMap, $gBlogMap, $gPostMap;
    $query = "select * from " . $wpdb->table_prefix . "wp_post2cat";
    $post2cat = $wpdb->get_results($query);
    if (!empty($post2cat)) {
        foreach ($post2cat as $map) {
            $post = new BitBlogPost();
            if (!empty($gPostMap[$map->post_id])) {
                if (!empty($gBlogMap[$map->category_id])) {
                    $post->storePostMap($gPostMap[$map->post_id], $gBlogMap[$map->category_id]);
                } else {
                    $gErrorMap[]['error'] = "Post2Category: " . $map->post_id . " Unable to map category: " . $map->category_id;
                }
            } else {
                $gErrorMap[]['error'] = "Post2Category: Unable to map post_id: " . $map->post_id . " category: " . $map->category_id;
            }
        }
    }
}