$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()) { $gBitSmarty->assign('ajax_more', TRUE);
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); }
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); }
function getPost($pListHash = array()) { $ret = NULL; $bindVars = array(); $blogId = !empty($pListHash['blog_id']) ? $pListHash['blog_id'] : $this->mBlogId; if (BitBase::verifyId($blogId)) { $this->prepGetList($pListHash); $sql = "SELECT bp.`post_id`\n\t\t\t\t\tFROM `" . BIT_DB_PREFIX . "blog_posts` bp\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id`=bp.`content_id`)\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "blogs_posts_map` bpm ON (bp.`content_id`=bpm.`post_content_id`)\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "blogs` b on (bpm.`blog_content_id`=b.`content_id`)\n\t\t\t\t\tWHERE b.`blog_id` = ? ORDER BY " . $this->mDb->convertSortMode($pListHash['sort_mode']); if ($postId = $this->mDb->getOne($sql, array($blogId))) { $blogPost = new BitBlogPost($postId); $blogPost->load(NULL, $pListHash); $ret = $blogPost; } } return $ret; }
<?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); }