diff options
53 files changed, 3836 insertions, 0 deletions
diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..2062d9d --- /dev/null +++ b/.htaccess @@ -0,0 +1,6 @@ +<IfModule mod_rewrite.c> + RewriteEngine on + RewriteBase /blogs/ + RewriteRule ^([0-9]+)$ view.php?blog_id=$1 [L] + RewriteRule ^post/([0-9]+)$ view_post.php?post_id=$1 [L] +</IfModule> diff --git a/BitBlog.php b/BitBlog.php new file mode 100644 index 0000000..8efa03b --- /dev/null +++ b/BitBlog.php @@ -0,0 +1,324 @@ +<?php +require_once( BLOGS_PKG_PATH.'BitBlogPost.php'); +require_once( LIBERTY_PKG_PATH.'LibertyComment.php'); + +define( 'BITBLOG_CONTENT_TYPE_GUID', 'bitblog' ); + +class BitBlog extends BitBase { + function BitBlog() { + BitBase::BitBase(); + } + + // BLOG METHODS //// + /*shared*/ + function list_blogs($offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '', $user_id = NULL, $add_sql = NULL) { + global $gBitSystem; + + if ($find) { + $findesc = '%' . strtoupper( $find ) . '%'; + $mid = " WHERE (UPPER(tb.`title`) like ? or UPPER(tb.`description`) like ?) "; + $bindvars=array($findesc,$findesc); + if ($user_id) { + $mid .= " AND tb.`user_id` = ?"; + $bindvars[] = $user_id; + } + } elseif( $user_id ) { // or a string + $mid = " WHERE tb.`user_id` = ? "; + $bindvars=array( $user_id ); + } else { + $mid = ''; + $bindvars=array(); + } + + if ($add_sql) { + if (strlen($mid) > 1) { + $mid .= ' AND '.$add_sql.' '; + } else { + $mid = "WHERE $add_sql "; + } + } + + $query = "SELECT tb.*, uu.`login` as `user`, uu.`real_name` + FROM `".BIT_DB_PREFIX."tiki_blogs` tb INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = tb.`user_id`) + $mid order by ".$this->convert_sortmode($sort_mode); + + $result = $this->query($query,$bindvars,$maxRecords,$offset); + + $ret = array(); + + while ($res = $result->fetchRow()) { + if ( $gBitSystem->isPackageActive( 'categories' ) ) { + global $categlib; + $res['categs'] = $categlib->get_object_categories( BITBLOG_CONTENT_TYPE_GUID, $res['blog_id'] ); + } + $res['blog_url'] = $this->getBlogUrl( $res['blog_id'] ); + $ret[] = $res; + } + $retval = array(); + $retval["data"] = $ret; + $query_cant = "SELECT COUNT(tb.`blog_id`) FROM `".BIT_DB_PREFIX."tiki_blogs` tb $mid"; + + $cant = $this->getOne($query_cant, $bindvars); + $retval["cant"] = $cant; + return $retval; + } + + function get_user_blogs($user_id, $maxRecords = NULL) { + $ret = NULL; + + if ($user_id) { + + $sql = "SELECT tb.*, uu.`user_id`, uu.`login` as `user`, uu.`email`, uu.`real_name` + FROM `".BIT_DB_PREFIX."tiki_blogs` tb INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = tb.`user_id`) + WHERE tb.`user_id` = ? $mid"; + + if ($maxRecords && is_numeric($maxRecords) && $maxRecords >= 0) { + $blogsRes = $this->query($sql, array($user_id), $maxRecord); + } else { + $blogsRes = $this->query($sql, array($user_id)); + } + $ret = $blogsRes->getRows(); + } + return $ret; + } + + function get_num_user_blogs($user_id) { + $ret = NULL; + if ($user_id) { + $sql = "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."tiki_blogs` WHERE `user_id` = ?"; + $ret = $this->getOne($sql, array( $user_id )); + } + return $ret; + } + + function getContentType() { + return 'bitblog'; + } + + function getBlogUrl( $pBlogId ) { + global $gBitSystem; + if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) { + $ret = BLOGS_PKG_URL.$pBlogId; + } else { + $ret = BLOGS_PKG_URL.'view.php?blog_id='.$pBlogId; + } + return $ret; + } + + + /*shared*/ + function get_blog($blog_id) { + global $gBitSystem; + $ret = NULL; + if ($blog_id && is_numeric($blog_id)) { + + $query = "SELECT tb.*, uu.`login` as `user`, uu.`user_id`, uu.`real_name`, tup.`value` AS `blog_style`, tf.`storage_path` as avatar + FROM `".BIT_DB_PREFIX."tiki_blogs` tb INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = tb.`user_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_attachments` ta ON (uu.`user_id` = ta.`user_id` AND uu.`avatar_attachment_id`=ta.`attachment_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON (tf.`file_id` = ta.`foreign_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_user_preferences` tup ON ( uu.`user_id`=tup.`user_id` AND tup.`pref_name`='theme' ) + WHERE tb.`blog_id`= ?"; + + $result = $this->query($query,array((int)$blog_id)); + $ret = $result->fetchRow(); + if ($ret) { + $ret['avatar'] = (!empty($res['avatar']) ? BIT_ROOT_URL.$res['avatar'] : NULL); + if ( $gBitSystem->isPackageActive( 'categories' ) ) { + global $categlib; + $ret['categs'] = $categlib->get_object_categories( BITBLOG_CONTENT_TYPE_GUID, $blog_id ); + } + + if( empty( $ret['max_posts'] ) || !is_numeric( $ret['max_posts'] ) ) { + $ret['max_posts'] = 10; // spiderr hack to hardcode fail safe + } + } + } + return $ret; + } + + /*shared*/ + function list_user_blogs($user_id = NULL, $include_public = false) { + $ret = NULL; + if ($user_id && is_numeric($user_id)) { + $bindvars=array(); + $bindvars[] = (int)$user_id; + $mid = ''; + if ($include_public) { + $mid .= "OR `public`=?"; + $bindvars[]='y'; + } + $query = "SELECT tb.*, uu.`login` as `user`, uu.`real_name` + FROM `".BIT_DB_PREFIX."tiki_blogs` tb INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = tb.`user_id`) + WHERE tb.`user_id` = ? $mid "; + $result = $this->query($query,$bindvars); + $ret = array(); + + while ($res = $result->fetchRow()) { + $ret[] = $res; + } + } + return $ret; + } + + + function add_blog_hit($blog_id) { + global $count_admin_pvs; + global $gBitUser; + + if ($count_admin_pvs == 'y' || !$gBitUser->isAdmin()) { + $bindvars = array( $blog_id ); + $ownerSql = ''; + if( $gBitUser->isValid() ) { + // this is a super cheap way to keep us from 'hitting' our own blog + $ownerSql = ' AND `user_id` != ?'; + array_push( $bindvars, $gBitUser->mUserId ); + } + $query = "update `".BIT_DB_PREFIX."tiki_blogs` set `hits` = `hits`+1 where `blog_id`=? $ownerSql"; + $result = $this->query($query,$bindvars); + } + + return true; + } + + function replace_blog($title, $description, $user_id, $public, $max_posts, $blog_id, $heading, $use_title, $use_find, + $allow_comments, $creation_date = NULL) { + $now = date("U"); + if ($creation_date == NULL) + $creation_date = (int)$now; + + if ( !empty( $blog_id ) ) { + $query = "update `".BIT_DB_PREFIX."tiki_blogs` set `title`=? ,`description`=?,`user_id`=?,`public`=?,`last_modified`=?,`max_posts`=?,`heading`=?,`use_title`=?,`use_find`=?,`allow_comments`=? where `blog_id`=?"; + + $result = $this->query($query,array($title,$description,$user_id,$public,$now,$max_posts,$heading,$use_title,$use_find,$allow_comments,$blog_id)); + } else { + $query = "insert into `".BIT_DB_PREFIX."tiki_blogs`(`created`,`last_modified`,`title`,`description`,`user_id`,`public`,`posts`,`max_posts`,`hits`,`heading`,`use_title`,`use_find`,`allow_comments`) + values(?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + $result = $this->query($query,array($creation_date,(int) $now,$title,$description,$user_id,$public,0,(int) $max_posts,0,$heading,$use_title,$use_find,$allow_comments)); + $query2 = "select max(`blog_id`) from `".BIT_DB_PREFIX."tiki_blogs` where `last_modified`=?"; + $blog_id = $this->getOne($query2,array((int) $now)); + } + + return $blog_id; + } + + function expunge($blog_id) { + $this->mDb->StartTrans(); + $query = "delete from `".BIT_DB_PREFIX."tiki_blogs` where `blog_id`=?"; + + $result = $this->query($query,array((int) $blog_id)); + $query = "delete from `".BIT_DB_PREFIX."tiki_blog_posts` where `blog_id`=?"; + $result = $this->query($query,array((int) $blog_id)); + $this->remove_object( BITBLOG_CONTENT_TYPE_GUID, $blog_id ); + $this->mDb->CompleteTrans(); + return true; + } + + // ported from gBitSystem - one day BitBlog will inherit from LibertyContent, until then, dupe this func... + function remove_object($type, $id) { + global $categlib; + if( is_object( $categlib ) ) { + $categlib->uncategorize_object($type, $id); + } + // Now remove comments + $object = $type . $id; +// $query = "delete from `".BIT_DB_PREFIX."tiki_comments` where `object`=? and `object_type`=?"; +// $result = $this->query($query, array( $id, $type )); + // Remove individual permissions for this object if they exist + $query = "delete from `".BIT_DB_PREFIX."users_objectpermissions` where `object_id`=? and `object_type`=?"; + $result = $this->query($query,array((int)$object,$type)); + return true; + } + + function get_random_blog_post($blog_id = NULL, $load_comments = FALSE) { + $ret = NULL; + $bindvars = array(); + + if ($blog_id && is_numeric($blog_id)) { + $sql = "SELECT `post_id` FROM `".BIT_DB_PREFIX."tiki_blog_posts` WHERE `blog_id` = ?"; + $rs = $this->query($sql, array($blog_id)); + $rows = $rs->getRows(); + $numPosts = count($rows); + if ($numPosts > 0) { + $post_id = $rows[rand(0, $numPosts-1)]['post_id']; // Get a random post_id array index + $blogPost = new BitBlogPost( $post_id ); + $blogPost->load($load_comments); + $ret = $blogPost; + } + } + return $ret; + } + + + function add_blog_activity($blog_id) { + + //Caclulate activity, update tiki_blogs and purge activity table + $today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); + + $day0 = $today - (24 * 60 * 60); + $day1 = $today - (2 * 24 * 60 * 60); + $day2 = $today - (3 * 24 * 60 * 60); + // Purge old activity + $query = "delete from `".BIT_DB_PREFIX."tiki_blog_activity` where `day`<?"; + $result = $this->query($query,array((int) $day2)); + // Register new activity + $query = "select count(*) from `".BIT_DB_PREFIX."tiki_blog_activity` where `blog_id`=? and `day`=?"; + $result = $this->getOne($query,array((int) $blog_id,(int)$today)); + + if ($result) { + $query = "update `".BIT_DB_PREFIX."tiki_blog_activity` set `posts`=`posts`+1 where `blog_id`=? and `day`=?"; + } else { + $query = "insert into `".BIT_DB_PREFIX."tiki_blog_activity`(`blog_id`,`day`,`posts`) values(?,?,1)"; + } + + $result = $this->query($query,array((int) $blog_id,(int) $today)); + // Calculate activity + $query = "select `posts` from `".BIT_DB_PREFIX."tiki_blog_activity` where `blog_id`=? and `day`=?"; + $vtoday = $this->getOne($query,array((int) $blog_id,(int) $today)); + $day0 = $this->getOne($query,array((int) $blog_id,(int) $day0)); + $day1 = $this->getOne($query,array((int) $blog_id,(int) $day1)); + $day2 = $this->getOne($query,array((int) $blog_id,(int) $day2)); + $activity = (2 * $vtoday) + ($day0)+(0.5 * $day1) + (0.25 * $day2); + // Update tiki_blogs with activity information + $query = "update `".BIT_DB_PREFIX."tiki_blogs` set `activity`=? where `blog_id`=?"; + $result = $this->query($query,array($activity,(int) $blog_id)); + } + + function get_blog_owner($blog_id) { + $user_id = NULL; + if ($blog_id && is_numeric($blog_id)) { + $sql = "SELECT `user_id` FROM `".BIT_DB_PREFIX."tiki_blogs` WHERE `blog_id` = ?"; + $user_id = $this->getOne($sql, array($blog_id)); + } + return $user_id; + } + + function get_post_owner($post_id) { + $user_id = NULL; + if ($post_id && is_numeric($post_id)){ + $sql = "SELECT tc.`user_id` FROM `".BIT_DB_PREFIX."tiki_blog_posts` tbp, `".BIT_DB_PREFIX."tiki_content` tc + WHERE tbp.`post_id`= ? AND tbp.`content_id` = tc.`content_id`"; + $user_id = $this->getOne($sql, array($post_id)); + } + return $user_id; + } + + function viewerCanPostIntoBlog() { + global $gBitUser; + return ($this->mInfo['user_id'] == $gBitUser->mUserId || $gBitUser->isAdmin() || $this->mInfo['public'] == 'y' || $this->viewerHasPermission('bit_p_blog_post')); + } + + function viewerHasPermission($pPermName = NULL) { + global $gBitUser; + $ret = FALSE; + if ($gBitUser->mUserId && $pPermName) { + $ret = $gBitUser->object_has_permission( $gBitUser->mUserId, $this->mInfo['blog_id'], $this->getContentType(), $pPermName ); + } + return $ret; + } +} + +global $gBlog; +$gBlog = new BitBlog(); + +?> diff --git a/BitBlogPost.php b/BitBlogPost.php new file mode 100644 index 0000000..e1289cb --- /dev/null +++ b/BitBlogPost.php @@ -0,0 +1,475 @@ +<?php +/** +* $Header: /cvsroot/bitweaver/_bit_blogs/BitBlogPost.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +* +* Copyright (c) 2004 bitweaver.org +* All Rights Reserved. See copyright.txt for details and a complete list of authors. +* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details +* +* $Id: BitBlogPost.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +*/ +/** +* Virtual base class (as much as one can have such things in PHP) for all +* derived tikiwiki classes that require database access. +* +* @date created 2004/10/20 +* +* @author drewslater <andrew@andrewslater.com>, spiderr <spider@steelsun.com> +* +* @version $Revision: 1.1 $ $Date: 2005/06/19 03:57:42 $ $Author: bitweaver $ +* +* @class BitBase +*/ + +require_once( LIBERTY_PKG_PATH.'LibertyComment.php'); +require_once( LIBERTY_PKG_PATH.'LibertyAttachable.php'); +require_once( BLOGS_PKG_PATH.'BitBlog.php'); + +define( 'BITBLOGPOST_CONTENT_TYPE_GUID', 'bitblogpost' ); + +class BitBlogPost extends LibertyAttachable { + var $mPostId; + function BitBlogPost( $pPostId=NULL, $pContentId=NULL ) { + LibertyAttachable::LibertyAttachable(); + $this->registerContentType( BITBLOGPOST_CONTENT_TYPE_GUID, array( + 'content_type_guid' => BITBLOGPOST_CONTENT_TYPE_GUID, + 'content_description' => 'Blog Post', + 'handler_class' => 'BitBlogPost', + 'handler_package' => 'blogs', + 'handler_file' => 'BitBlogPost.php', + 'maintainer_url' => 'http://www.bitweaver.org' + ) ); + $this->mPostId = $pPostId; + $this->mContentId = $pContentId; + } + + function load( $pLoadComments = TRUE ) { + if( !empty( $this->mPostId ) || !empty( $this->mContentId ) ) { + global $gBitSystem; + $lookupColumn = !empty( $this->mPostId )? 'post_id' : 'content_id'; + $lookupId = !empty( $this->mPostId )? $this->mPostId : $this->mContentId; + $query = "SELECT tbp.*, tc.*, tb.`title` as `blogtitle`, tb.`allow_comments`,tb.`allow_comments`, tb.`use_title`, tb.`user_id` AS `blog_user_id`, uu.`login` as `user`, uu.`real_name`, tf.`storage_path` as avatar, tup.`value` AS `blog_style` + FROM `".BIT_DB_PREFIX."tiki_blog_posts` tbp + INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON (tc.`content_id` = tbp.`content_id`) + INNER JOIN `".BIT_DB_PREFIX."tiki_blogs` tb ON (tb.`blog_id` = tbp.`blog_id`) + INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON( uu.`user_id` = tc.`user_id` ) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_attachments` ta ON (uu.`user_id` = ta.`user_id` AND uu.`avatar_attachment_id`=ta.`attachment_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON (tf.`file_id` = ta.`foreign_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_user_preferences` tup ON ( uu.`user_id`=tup.`user_id` AND tup.`pref_name`='theme' ) + WHERE tbp.`$lookupColumn`=? "; + + $result = $this->query($query,array((int) $lookupId)); + + if ($result->numRows()) { + $this->mInfo = $result->fetchRow(); + $this->mPostId = $this->mInfo['post_id']; + $this->mContentId = $this->mInfo['content_id']; + $this->mInfo['blog_url'] = BitBlog::getBlogUrl( $this->mInfo['blog_id'] ); + + if ($pLoadComments) { + $comment = new LibertyComment(); + $this->mInfo['num_comments'] = $comment->getNumComments($this->mInfo['content_id']); + // Get the comments associated with this post + $this->mInfo['comments'] = $comment->getComments($this->mInfo['content_id'], $gBitSystem->getPreference( 'blog_comments_per_page', 10 ) ); + } + + if (!$this->mInfo['trackbacks_from'] || $this->mInfo['trackbacks_from']===null) + $this->mInfo['trackbacks_from'] = serialize(array()); + + if (!$this->mInfo['trackbacks_to'] || $this->mInfo['trackbacks_to']===null) + $this->mInfo['trackbacks_to'] = serialize(array()); + + $this->mInfo['trackbacks_from_count'] = count(array_keys(unserialize($this->mInfo['trackbacks_from']))); + $this->mInfo['trackbacks_from'] = unserialize($this->mInfo['trackbacks_from']); + $this->mInfo['trackbacks_to'] = unserialize($this->mInfo['trackbacks_to']); + if ( $gBitSystem->isPackageActive( 'categories' ) ) { + global $categlib; + $this->mInfo['categs'] = $categlib->get_object_categories( BITBLOGPOST_CONTENT_TYPE_GUID, $this->mContentId ); + } + $this->mInfo['trackbacks_to_count'] = count($this->mInfo['trackbacks_to']); + LibertyAttachable::load(); + if( $this->mStorage ) { + foreach( array_keys( $this->mStorage ) as $key ) { + $this->mStorage[$key]['wiki_plugin_link'] = '{ATTACHMENT(id=>'.$key.')}{ATTACHMENT}'; + } + } + } + } + return( count( $this->mInfo ) ); + } + + function verify( &$pParamHash ) { + global $gBitUser; + if( !empty( $pParamHash['post_id'] ) && empty( $this->mContentId ) && empty( $pParamHash['content_id'] ) ) { + $this->mPostId = $pParamHash['post_id']; + $this->load(); + } + if (empty($pParamHash['user_id'])) { + $pParamHash['user_id'] = $gBitUser->mUserId; + } + $pParamHash['content_type_guid'] = BITBLOGPOST_CONTENT_TYPE_GUID; + return( count( $this->mErrors ) == 0 ); + } + + function isValid() { + return( !empty( $this->mPostId ) && is_numeric( $this->mPostId ) && $this->mPostId > 0 ); + } + + function isBlogOwner( $pUserId=NULL ) { + $ret = FALSE; + global $gBitUser; + if( empty( $pUserId ) && $gBitUser->isValid() ) { + $pUserId = $gBitUser->mUserId; + } + if( $this->isValid() && ($pUserId == $this->mInfo["blog_user_id"]) ) { + $ret = 'y'; + } + return $ret; + } + + function store( &$pParamHash ) { + global $gBlog, $gBitSystem; + $pParamHash['upload']['thumbnail'] = TRUE; + + $this->mDb->StartTrans(); + if( $this->verify( $pParamHash ) && LibertyAttachable::store( $pParamHash ) ) { + if( !empty( $pParamHash['attachment_id'] ) ) { + // we just shoved an attachment onto the blog so we will concat the new link for usability. + // THis is a bit hackish to do here. I imagine we will allow for this down in Liberty eventually, + // but right now there is a chicken-n-egg situation storing 'data' before the attachments. - spiderr + $pParamHash['edit'] .= '{ATTACHMENT(id=>'.$pParamHash['attachment_id'].')}{ATTACHMENT}'; + LibertyContent::store( $pParamHash ); + } + if (empty($pParamHash['post_id'])) { + global $smarty; + global $feature_user_watches; + $tracks = serialize(explode(',', $pParamHash['trackback'])); + $pParamHash['edit'] = strip_tags($pParamHash['edit'], '<a><b><i><h1><h2><h3><h4><h5><h6><ul><li><ol><br><p><table><tr><td><img><pre>'); + $now = date("U"); + if (empty($pParamHash['post_date'])) + $pParamHash['post_date'] = (int)$now; + $pParamHash['post_id'] = $this->GenID('tiki_blog_posts_post_id_seq'); + + $query = "insert into `".BIT_DB_PREFIX."tiki_blog_posts`(`blog_id`, `post_id`, `content_id`, `trackbacks_from`,`trackbacks_to`) values(?,?,?,?,?)"; + $result = $this->query($query,array($pParamHash['blog_id'],$pParamHash['post_id'],$pParamHash['content_store']['content_id'],serialize(array()),serialize(array()))); + $this->mPostId = $pParamHash['post_id']; + + // Send trackbacks recovering only successful trackbacks + $trackbacks = serialize( $this->sendTrackbacks( $pParamHash['trackback'] ) ); + // Update post with trackbacks successfully sent + $query = "update `".BIT_DB_PREFIX."tiki_blog_posts` set `trackbacks_from`=?, `trackbacks_to` = ? where `post_id`=?"; + $this->query($query,array(serialize(array()),$trackbacks,(int) $pParamHash['post_id'])); + $query = "update `".BIT_DB_PREFIX."tiki_blogs` set `last_modified`=?,`posts`=`posts`+1 where `blog_id`=?"; + $result = $this->query($query,array((int)$now,(int) $pParamHash['blog_id'])); + $gBlog->add_blog_activity($pParamHash['blog_id']); + + // let's reload to get a full mInfo hash which is needed below + $this->load(); + + if( $gBitSystem->isFeatureActive( 'feature_user_watches' ) ) { + global $gBitUser; + if( $nots = $gBitUser->getEventWatches( 'blog_post', $this->mInfo['blog_id'] ) ) { + foreach ($nots as $not) { + $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]); + + $smarty->assign('mail_title', $this->mInfo['title']); + $smarty->assign('mail_blogid', $this->mInfo['blog_id']); + $smarty->assign('mail_postid', $this->mPostId); + $smarty->assign('mail_date', date("U")); + $smarty->assign('mail_user', $this->mInfo['user']); + $smarty->assign('mail_data', $this->mInfo['data']); + $smarty->assign('mail_hash', $not['hash']); + $foo = parse_url($_SERVER["REQUEST_URI"]); + $machine = httpPrefix(). $foo["path"]; + $smarty->assign('mail_machine', $machine); + $parts = explode('/', $foo['path']); + + if (count($parts) > 1) + unset ($parts[count($parts) - 1]); + + $smarty->assign('mail_machine_raw', httpPrefix(). implode('/', $parts)); + $mail_data = $smarty->fetch('bitpackage:blogs/user_watch_blog_post.tpl'); + @mail($not['email'], tra('Blog post'). ' ' . $title, $mail_data, "From: ".$gBitSystem->getPrefence( 'sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n"); + } + } + } + } + + if( !empty( $pParamHash['trackbacks'] ) ) { + $trackbacks = serialize($gBlog->send_trackbacks($post_id, $trackbacks)); + $query = "update `".BIT_DB_PREFIX."tiki_blog_posts` set `trackbacks_to`=? where `post_id`=?"; + $result = $this->query($query,array($trackbacks,$user_id,$post_id)); + } + } + $this->mDb->CompleteTrans(); + return( count( $this->mErrors ) == 0 ); + } + + + function expunge() { + $this->mDb->StartTrans(); + // let's force a full load to make sure everything is loaded. + $this->load(); + if( $this->isValid() ) { + // First kill any comments which belong to this post + foreach($this->mInfo['comments'] as $comment) { + $tmpComment = new LibertyComment($comment['comment_id']); + $tmpComment->deleteComment(); + } + + $query = "delete from `".BIT_DB_PREFIX."tiki_blog_posts` where `post_id`=?"; + $result = $this->query( $query, array( (int) $this->mPostId ) ); + + $query = "update `".BIT_DB_PREFIX."tiki_blogs` set `posts`=`posts`-1 where `blog_id`=?"; + $result = $this->query( $query, array( (int)$this->mInfo['blog_id'] ) ); + // Do this last so foreign keys won't complain (not the we have them... yet ;-) + LibertyAttachable::expunge(); + } + $this->mDb->CompleteTrans(); + + return true; + } + + function getDisplayUrl( $pPostId=NULL ) { + if( empty( $pPostId ) ) { + $pPostId = $this->mPostId; + } + global $gBitSystem; + $ret = NULL; + if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) { + $ret = BLOGS_PKG_URL."post/$pPostId"; + } else { + $ret = BLOGS_PKG_URL.'view_post.php?post_id='.$pPostId; + } + return $ret; + } + + + function getDisplayLink( $pPostId=NULL, $pMixed=NULL ) { + $ret = NULL; + if( empty( $pPostId ) ) { + $pPostId = $this->mPostId; + } + global $gBitSystem; + if( is_numeric( $pPostId ) ) { + if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) { + $ret = BLOGS_PKG_URL.'post/'.$pPostId; + } else { + $ret = BLOGS_PKG_URL.'view_post.php?post_id='.$pPostId; + } + } + return $ret; + } + + /** + * Returns include file that will + * @return the fully specified path to file to be included + */ + function getRenderFile() { + return( BLOGS_PKG_PATH.'display_bitblogpost_inc.php' ); + } + + function sendTrackbacks( $pTrackbacks ) { + $ret = array(); + if( $this->isValid() && !empty( $pTrackbacks ) ) { + // Split to get each URI + $tracks = explode(',', $pTrackbacks); + + //Build uri for post + $parts = parse_url($_SERVER['REQUEST_URI']); + $uri = httpPrefix(). str_replace('post', + 'view_post', $parts['path']). '?post_id=' . $this->mPostId . '&blog_id=' . $this->mInfo['blog_id']; + include_once ( UTIL_PKG_PATH.'Snoopy.class.inc' ); + $snoopy = new Snoopy; + + foreach ($tracks as $track) { + @$fp = fopen($track, 'r'); + + if ($fp) { + $data = ''; + + while (!feof($fp)) { + $data .= fread($fp, 32767); + } + + fclose ($fp); + preg_match("/trackback:ping=(\"|\'|\s*)(.+)(\"|\'\s)/", $data, $reqs); + + if (!isset($reqs[2])) + return $ret; + + @$fp = fopen($reqs[2], 'r'); + + if ($fp) { + fclose ($fp); + + $submit_url = $reqs[2]; + $submit_vars["url"] = $uri; + $submit_vars["blog_name"] = $this->mInfo['blogtitle']; + $submit_vars["title"] = $this->mInfo['title'] ? $this->mInfo['title'] : date("d/m/Y [h:i]", $this->mInfo['created']); + $submit_vars["title"] .= ' ' . tra('by'). ' ' . BitUser::getDisplayName( FALSE, $this->mInfo ); + $submit_vars["excerpt"] = substr($post_info['data'], 0, 200); + $snoopy->submit($submit_url, $submit_vars); + $back = $snoopy->results; + + if (!strstr('<error>1</error>', $back)) { + $ret[] = $track; + } + } + } + } + } + return $ret; + } + + function getList( &$pListHash ) { + global $gBitUser, $gBitSystem; + + if( empty( $pListHash['sort_mode'] ) ) { + $pListHash['sort_mode'] = 'created_desc'; + } + + $this->prepGetList( $pListHash ); + + $whereSql = ''; + $bindvars = array(); + if( !empty( $pListHash['blog_id'] ) ) { + array_push( $bindvars, (int)$pListHash['blog_id'] ); + $whereSql = ' AND tbp.`blog_id` = ? '; + } + + if( !empty( $pListHash['user_id'] ) ) { + array_push( $bindvars, (int)$pListHash['user_id'] ); + $whereSql = ' AND tc.`user_id` = ? '; + } + + + if( $pListHash['find'] ) { + $findesc = '%' . strtoupper( $pListHash['find'] ) . '%'; + $mid = "AND (UPPER(`data`) like ?) "; + $bindvars[] =$findesc; + } else { + $mid = ""; + } + + if( is_numeric( $pListHash['date'] ) ) { + $mid .= " AND tc.`created`<=? "; + $bindvars[]=(int) $pListHash['date']; + } + + $query = "SELECT tbp.*, tc.*, tb.`title` AS `blogtitle`, tb.`allow_comments`, uu.`email`, uu.`login` as `user`, uu.`real_name`, tf.`storage_path` as avatar + FROM `".BIT_DB_PREFIX."tiki_blogs` tb, `".BIT_DB_PREFIX."tiki_blog_posts` tbp + INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON (tc.`content_id` = tbp.`content_id`) + INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = tc.`user_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_attachments` ta ON (uu.`user_id` = ta.`user_id` AND ta.`attachment_id` = uu.`avatar_attachment_id`) + LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON (tf.`file_id` = ta.`foreign_id`) + WHERE tb.`blog_id` = tbp.`blog_id` $whereSql $mid order by tc.".$this->convert_sortmode( $pListHash['sort_mode'] ); + $query_cant = "SELECT COUNT(tbp.`post_id`) FROM `".BIT_DB_PREFIX."tiki_blog_posts` tbp, `".BIT_DB_PREFIX."tiki_content` tc WHERE tc.`content_id` = tbp.`content_id` $whereSql $mid"; + $result = $this->query($query,$bindvars,$pListHash['max_records'],$pListHash['offset']); + $cant = $this->getOne($query_cant,$bindvars); + $ret = array(); + + while ($res = $result->fetchRow()) { + $res['avatar'] = (!empty($res['avatar']) ? BIT_ROOT_URL.$res['avatar'] : NULL); + if ( $pListHash['load_num_comments'] || $pListHash['load_comments'] ) { + $comment = new LibertyComment(); + $res['num_comments'] = $comment->getNumComments($res['content_id']); + if( $pListHash['load_comments'] ) { + // Get the comments associated with this post + $res['comments'] = $comment->getComments($res['content_id'], $gBitSystem->getPreference( 'blog_comments_per_page', 10 ) ); + } + } else { + $res['comments'] = NULL; + } + + $res['post_url'] = BitBlogPost::getDisplayLink( $res['post_id'] ); + $res['display_url'] = $res['post_url']; + $res['blog_url'] = BitBlog::getBlogUrl( $res['blog_id'] ); + + 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'] ); + + if ( $gBitSystem->isPackageActive( 'categories' ) ) { + global $categlib; + require_once( CATEGORIES_PKG_PATH.'categ_lib.php' ); + $res['categs'] = $categlib->get_object_categories( BITBLOGPOST_CONTENT_TYPE_GUID, $res["content_id"] ); + } + + if( $pListHash['parse_data'] ) { + $res["parsed_data"] = $this->parseData($res["data"], $res['format_guid']); + } + + $ret[] = $res; + } + + $retval = array(); + $retval["data"] = $ret; + $retval["cant"] = $cant; + return $retval; + } + + + function addTrackbackFrom( $url, $title = '', $excerpt = '', $blog_name = '') { + if( $this->isValid() ) { + $tbs = $this->getTrackbacksFrom( $this->mPostId ); + $aux = array( + 'title' => $title, + 'excerpt' => $excerpt, + 'blog_name' => $blog_name + ); + + $tbs[$url] = $aux; + $st = serialize($tbs); + $query = "update `".BIT_DB_PREFIX."tiki_blog_posts` set `trackbacks_from`=? where `post_id`=?"; + $this->query( $query, array( $st, $this->mPostId ) ); + return true; + } + } + + function getTrackbacksFrom() { + if( $this->isValid() ) { + $st = $this->mDb->getOne("select `trackbacks_from` from `".BIT_DB_PREFIX."tiki_blog_posts` where `post_id`=?",array( $this->mPostId ) ); + return unserialize($st); + } + } + + function getTrackbacksTo() { + if( $this->isValid() ) { + $st = $this->mDb->getOne("select `trackbacks_to` from `".BIT_DB_PREFIX."tiki_blog_posts` where `post_id`=?", array( $this->mPostId ) ); + return unserialize($st); + } + } + + function clearTrackbacksFrom() { + if( $this->isValid() ) { + $empty = serialize(array()); + $query = "update `".BIT_DB_PREFIX."tiki_blog_posts` set `trackbacks_from` = ? where `post_id`=?"; + $this->query( $query, array( $empty, $this->mPostId ) ); + } + } + + function clearTrackbacksTo() { + if( $this->isValid() ) { + $empty = serialize(array()); + $query = "update `".BIT_DB_PREFIX."tiki_blog_posts` set `trackbacks_to` = ? where `post_id`=?"; + $this->query( $query, array( $empty, $this->mPostId ) ); + } + } + + + +} diff --git a/admin/admin_blogs_inc.php b/admin/admin_blogs_inc.php new file mode 100644 index 0000000..9bcfff1 --- /dev/null +++ b/admin/admin_blogs_inc.php @@ -0,0 +1,102 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/admin/admin_blogs_inc.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. +if (isset($_REQUEST["blogset"]) && isset($_REQUEST["homeBlog"])) { + + $gBitSystem->storePreference("home_blog", $_REQUEST["homeBlog"]); + $smarty->assign('home_blog', $_REQUEST["homeBlog"]); +} + +require_once( BLOGS_PKG_PATH.'BitBlog.php' ); +if (defined("CATEGORIES_PKG_PATH") and $gBitSystem->isPackageActive( 'categories' )) { + include_once( CATEGORIES_PKG_PATH.'categ_lib.php'); + $categs = $categlib->get_all_categories(); + $smarty->assign('categs',$categs); +} + +$formBlogLists = array( + "blog_list_title" => array( + 'label' => 'Title', + 'note' => '', + 'page' => '', + ), + "blog_list_description" => array( + 'label' => 'Description', + ), + "blog_list_created" => array( + 'label' => 'Creation date', + ), + "blog_list_lastmodif" => array( + 'label' => 'Last modification time', + ), + "blog_list_user" => array( + 'label' => 'User', + ), + "blog_list_posts" => array( + 'label' => 'Posts', + ), + "blog_list_visits" => array( + 'label' => 'Visits', + ), + "blog_list_activity" => array( + 'label' => 'Activity', + ), +); +$smarty->assign( 'formBlogLists',$formBlogLists ); + +$formBlogFeatures = array( + "feature_blog_rankings" => array( + 'label' => 'Rankings', + ), + "blog_spellcheck" => array( + 'label' => 'Spellchecking', + ), +); +$smarty->assign( 'formBlogFeatures',$formBlogFeatures ); + +$processForm = set_tab(); + +if( $processForm ) { + + $blogToggles = array_merge( $formBlogLists,$formBlogFeatures ); + foreach( $blogToggles as $item => $data ) { + simple_set_toggle( $item ); + } + + $gBitSystem->storePreference("feature_blogposts_comments", isset( $_REQUEST["feature_blogposts_comments"] ) ? 'y' : 'n'); + $gBitSystem->storePreference("blog_list_order", $_REQUEST["blog_list_order"]); + $gBitSystem->storePreference("blog_list_user", $_REQUEST["blog_list_user"]); + $smarty->assign('blog_list_order', $_REQUEST["blog_list_order"]); + $smarty->assign('blog_list_user', $_REQUEST['blog_list_user']); + + if ($gBitSystem->isPackageActive( 'categories' )) { + if (isset($_REQUEST["blog_categ"]) && $_REQUEST["blog_categ"] == "on") { + $gBitSystem->storePreference("blog_categ", 'y'); + $smarty->assign("blog_categ", 'y'); + } else { + $gBitSystem->storePreference("blog_categ", 'n'); + $smarty->assign("blog_categ", 'n'); + } + $gBitSystem->storePreference("blog_parent_categ", $_REQUEST["blog_parent_categ"]); + $smarty->assign('blog_parent_categ', $_REQUEST['blog_parent_categ']); + } + + if (isset($_REQUEST["blog_comments_per_page"])) { + $gBitSystem->storePreference("blog_comments_per_page", $_REQUEST["blog_comments_per_page"]); + + $smarty->assign('blog_comments_per_page', $_REQUEST["blog_comments_per_page"]); + } + + if (isset($_REQUEST["blog_comments_default_ordering"])) { + $gBitSystem->storePreference("blog_comments_default_ordering", $_REQUEST["blog_comments_default_ordering"]); + + $smarty->assign('blog_comments_default_ordering', $_REQUEST["blog_comments_default_ordering"]); + } +} + + +$blogs = $gBlog->list_blogs(0, -1, 'created_desc', ''); +$smarty->assign_by_ref('blogs', $blogs["data"]); +?> diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..3e305fe --- /dev/null +++ b/admin/index.php @@ -0,0 +1,6 @@ +<?php + + // This is not a package. + header ("location: ../index.php"); + +?>
\ No newline at end of file diff --git a/admin/schema_inc.php b/admin/schema_inc.php new file mode 100644 index 0000000..f003714 --- /dev/null +++ b/admin/schema_inc.php @@ -0,0 +1,114 @@ +<?php + +$tables = array( + +'tiki_blog_activity' => " + blog_id I4 NOTNULL PRIMARY, + day I8 NOTNULL PRIMARY, + posts I4 +", + +'tiki_blog_posts' => " + post_id I4 PRIMARY, + content_id I4 NOTNULL, + blog_id I4 NOTNULL, + trackbacks_to X, + trackbacks_from X +", + +'tiki_blogs' => " + blog_id I4 AUTO PRIMARY, + user_id I4 NOTNULL, + created I8 NOTNULL, + last_modified I8 NOTNULL, + title C(200), + description X, + public C(1), + posts I4, + max_posts I4, + hits I4, + activity decimal(4,2), + heading X, + use_find C(1), + use_title C(1), + add_date C(1), + add_poster C(1), + allow_comments C(1) +" + +); + +global $gBitInstaller; + +$gBitInstaller->makePackageHomeable(BLOGS_PKG_NAME); + +foreach( array_keys( $tables ) AS $tableName ) { + $gBitInstaller->registerSchemaTable( BLOGS_PKG_DIR, $tableName, $tables[$tableName] ); +} + +$gBitInstaller->registerPackageInfo( BLOGS_PKG_NAME, array( + 'description' => "A Blog is a web based journal or diary.", + 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', + 'version' => '0.1', + 'state' => 'beta', + 'dependencies' => '', +) ); + +// ### Indexes +$indices = array ( + 'tiki_blog_posts_blog_id_idx' => array( 'table' => 'tiki_blog_posts', 'cols' => 'blog_id', 'opts' => NULL ), + 'tiki_blogs_title_idx' => array( 'table' => 'tiki_blogs', 'cols' => 'title', 'opts' => NULL ), + 'tiki_blogs_hits_idx' => array( 'table' => 'tiki_blogs', 'cols' => 'hits', 'opts' => NULL ), + 'tiki_blogs_user_id_idx' => array( 'table' => 'tiki_blogs', 'cols' => 'user_id', 'opts' => NULL ) +); +// TODO - SPIDERR - following seems to cause time _decrease_ cause bigint on postgres. need more investigation +// 'tiki_blog_posts_created_idx' => array( 'table' => 'tiki_blog_posts', 'cols' => 'created', 'opts' => NULL ), +$gBitInstaller->registerSchemaIndexes( BLOGS_PKG_DIR, $indices ); + +// ### Sequences +$sequences = array ( + 'tiki_blog_posts_post_id_seq' => array( 'start' => 1 ) +); +$gBitInstaller->registerSchemaSequences( BLOGS_PKG_DIR, $sequences ); + +// ### Default MenuOptions +$gBitInstaller->registerMenuOptions( BLOGS_PKG_NAME, array ( + array(42,'s','Blogs','list_blogs.php',450,'feature_blogs','bit_p_read_blog',''), + array(42,'o','List blogs','list_blogs.php',455,'feature_blogs','bit_p_read_blog',''), + array(42,'o','Rankings','rankings.php',460,'feature_blogs,feature_blog_rankings','bit_p_read_blog',''), + array(42,'o','Create/Edit blog','edit.php',465,'feature_blogs','bit_p_read_blog,bit_p_create_blogs',''), + array(42,'o','Post','post.php',470,'feature_blogs','bit_p_read_blog,bit_p_blog_post',''), + array(42,'o','Admin posts','index.php',475,'feature_blogs','bit_p_read_blog,bit_p_blog_admin','') +) ); + + +// ### Default UserPermissions +$gBitInstaller->registerUserPermissions( BLOGS_PKG_NAME, array( + array('bit_p_create_blogs', 'Can create a blog', 'registered', BLOGS_PKG_NAME), + array('bit_p_blog_post', 'Can post to a blog', 'registered', BLOGS_PKG_NAME), + array('bit_p_blog_admin', 'Can admin blogs', 'editors', BLOGS_PKG_NAME), + array('bit_p_read_blog', 'Can read blogs', 'basic', BLOGS_PKG_NAME) +) ); + +// ### Default Preferences +$gBitInstaller->registerPreferences( BLOGS_PKG_NAME, array( + array( BLOGS_PKG_NAME, 'blog_comments_default_ordering','points_desc'), + array( BLOGS_PKG_NAME, 'blog_comments_per_page','10'), + array( BLOGS_PKG_NAME, 'blog_list_activity','y'), + array( BLOGS_PKG_NAME, 'blog_list_created','y'), + array( BLOGS_PKG_NAME, 'blog_list_description','y'), + array( BLOGS_PKG_NAME, 'blog_list_lastmodif','y'), + array( BLOGS_PKG_NAME, 'blog_list_order','created_desc'), + array( BLOGS_PKG_NAME, 'blog_list_posts','y'), + array( BLOGS_PKG_NAME, 'blog_list_title','y'), + array( BLOGS_PKG_NAME, 'blog_list_user','n'), + array( BLOGS_PKG_NAME, 'blog_list_visits','y'), + array( BLOGS_PKG_NAME, 'blog_spellcheck','n'), + array( BLOGS_PKG_NAME, 'blog_categ','n'), + array( BLOGS_PKG_NAME, 'blog_parent_categ',0), + array( BLOGS_PKG_NAME, 'feature_blogposts_comments','n'), + array( BLOGS_PKG_NAME, 'feature_blog_rankings','y'), + array( BLOGS_PKG_NAME, 'feature_blogs','y'), +) ); + +?> diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php new file mode 100644 index 0000000..769c4b5 --- /dev/null +++ b/admin/upgrade_inc.php @@ -0,0 +1,104 @@ +<?php + +global $gBitSystem, $gUpgradeFrom, $gUpgradeTo; + +require_once( BLOGS_PKG_PATH.'BitBlogPost.php' ); + +$upgrades = array( + +'BONNIE' => array( + 'CLYDE' => array( + +// STEP 1 +array( 'DATADICT' => array( +array( 'RENAMECOLUMN' => array( + 'tiki_blog_activity' => array( '`blogId`' => '`blog_id` I4' ), + 'tiki_blog_posts' => array( '`postId`' => '`post_id` I4 AUTO' , + '`blogId`' => '`blog_id` I4' ), + 'tiki_blogs' => array( '`blogId`' => '`blog_id` I4 AUTO', + '`lastModif`' => '`last_modified` I8', + '`maxPosts`' => '`max_posts` I4' ), +)), + + +array( 'ALTER' => array( + 'tiki_blog_posts' => array( + 'user_id' => array( '`user_id`', 'I4' ), // , 'NOTNULL' ), + 'content_id' => array( '`content_id`', 'I4' ), // , 'NOTNULL' ), + ), + 'tiki_blogs' => array( + 'user_id' => array( '`user_id`', 'I4' ), // , 'NOTNULL' ), + ), +)), +/* +blog_posts` SET user_id=(SELECT uu.user_id FROM users_users uu WHERE tiki_blog_posts.`user`=uu.login)", +"UPDATE `".BIT_DB_PREFIX."tiki_blogs` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `user`=login)", +"ALTER TABLE `".BIT_DB_PREFIX."tiki_blogs` DROP `user`" + ) +*/ +)), + +// STEP 2 +array( 'QUERY' => + array( 'SQL92' => array( + "UPDATE `".BIT_DB_PREFIX."tiki_blogs` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_blogs`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_blog_posts` SET `user_id`=(SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE `".BIT_DB_PREFIX."users_users`.`login`=`".BIT_DB_PREFIX."tiki_blog_posts`.`user`)", + "UPDATE `".BIT_DB_PREFIX."tiki_preferences` set `value`='last_modified_desc' where `name`='blog_list_order'", + "UPDATE `".BIT_DB_PREFIX."tiki_categorized_objects` SET `object_type`='".BITBLOGPOST_CONTENT_TYPE_GUID."' WHERE `object_type`='blogpost'", + ), +)), + + +// STEP 3 +array( 'PHP' => ' + global $gBitSystem; + $startPost = $gBitSystem->getOne( "SELECT MAX(`post_id`) FROM `'.BIT_DB_PREFIX.'tiki_blog_posts`" ); + $gBitSystem->mDb->mDb->CreateSequence( "tiki_blog_posts_post_id_seq", $startPost + 1 ); + $query = "SELECT tbp.`post_id`, uu.`user_id`, uu.`user_id` AS modifier_user_id, tbp.`created`, tbp.`created` AS last_modified, tbp.`data`, tbp.`title` + FROM `'.BIT_DB_PREFIX.'tiki_blog_posts` tbp INNER JOIN `'.BIT_DB_PREFIX.'users_users` uu ON( tbp.`user`=uu.`login` )"; + if( $rs = $gBitSystem->query( $query ) ) { + while( !$rs->EOF ) { + $postId = $rs->fields["post_id"]; + unset( $rs->fields["post_id"] ); + $conId = $gBitSystem->mDb->mDb->GenID( "tiki_content_id_seq" ); + $rs->fields["content_id"] = $conId; + $rs->fields["content_type_guid"] = BITBLOGPOST_CONTENT_TYPE_GUID; + $rs->fields["format_guid"] = PLUGIN_GUID_TIKIWIKI; + $gBitSystem->mDb->associateInsert( "tiki_content", $rs->fields ); + $gBitSystem->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_blog_posts` SET `content_id`=? WHERE `post_id`=? ", array( $conId, $postId ) ); + $rs->MoveNext(); + } + } +' ), + + +// STEP 4 +array( 'QUERY' => + array( 'SQL92' => array( + // Update Blog Post comments - we have no Blog level comments in CLYDE + "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `objectType`='".BITBLOGPOST_CONTENT_TYPE_GUID."' WHERE `objectType`='post'", + "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `parent_id`=(SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_blog_posts` WHERE `post_id`=`".BIT_DB_PREFIX."tiki_comments`.`object`) WHERE `parent_id`=0 AND `objectType`='".BITBLOGPOST_CONTENT_TYPE_GUID."'", + ), +)), + + +// STEP 5 +array( 'DATADICT' => array( + array( 'DROPCOLUMN' => array( + 'tiki_blog_posts' => array( '`user`', '`created`', '`data`', '`title`' ), + 'tiki_blogs' => array( '`user`' ), + )), +)), + + + ) +) + +); + +if( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) { + $gBitSystem->registerUpgrade( BLOGS_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] ); +} + + +?> diff --git a/bit_setup_inc.php b/bit_setup_inc.php new file mode 100644 index 0000000..2eb0d01 --- /dev/null +++ b/bit_setup_inc.php @@ -0,0 +1,28 @@ +<?php +global $gBitSystem, $smarty, $bit_p_blog_admin; +$gBitSystem->registerPackage( 'blogs', dirname( __FILE__).'/' ); + +if( $gBitSystem->isPackageActive( 'blogs' ) ) { + + $gBitSystem->registerAppMenu( 'blogs', 'Blogs', BLOGS_PKG_URL.'index.php', 'bitpackage:blogs/menu_blogs.tpl', 'blogs'); + + $gBitSystem->registerNotifyEvent( array( "blog_post" => tra("An entry is posted to a blog") ) ); + + $smarty->assign('home_blog', 0); + $smarty->assign('blog_comments_default_ordering', 'points_desc'); + $smarty->assign('blog_comments_per_page', 10); + $smarty->assign('blog_spellcheck', 'n'); + $smarty->assign('blog_list_order', 'created_desc'); + $smarty->assign('blog_list_title', 'y'); + $smarty->assign('blog_list_description', 'y'); + $smarty->assign('blog_list_created', 'y'); + $smarty->assign('blog_list_lastmodif', 'y'); + $smarty->assign('blog_list_user', 'y'); + $smarty->assign('blog_list_posts', 'y'); + $smarty->assign('blog_list_visits', 'y'); + $smarty->assign('blog_list_activity', 'y'); + $smarty->assign('blog_list_user', 'text'); + +} + +?> diff --git a/blogs_rss.php b/blogs_rss.php new file mode 100644 index 0000000..48e6dbb --- /dev/null +++ b/blogs_rss.php @@ -0,0 +1,57 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/blogs_rss.php,v 1.1 2005/06/19 03:57:41 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +require_once( '../bit_setup_inc.php' ); +require_once( KERNEL_PKG_PATH.'BitBase.php' ); +include_once( BLOGS_PKG_PATH.'BitBlogPost.php' ); +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +global $gBitSystem; + +if ($rss_blogs != 'y') { + $errmsg=tra("rss feed disabled"); + require_once( RSS_PKG_PATH.'rss_error.php' ); +} + +if (!$gBitUser->hasPermission( 'bit_p_read_blog' )) { + $errmsg=tra("Permission denied you cannot view this section"); + require_once( RSS_PKG_PATH.'rss_error.php' ); +} + + +if (!empty($_REQUEST['blog_id'])) { + $blogInfo = $gBlog->get_blog($_REQUEST['blog_id']); + $title = $gBitSystem->getPreference( 'title_rss_blog', "Tiki RSS feed for " ).$blogInfo['title']; + $desc = $gBitSystem->getPreference( 'desc_rss_blog', "Last modifications to the Blog: " ).$blogInfo['description']; +} else { + $title = "Blogs RSS feed for ".$gBitSystem->getPreference("siteTitle","Tiki"); + $desc = $gBitSystem->getPreference( 'desc_rss_blog', "Last modifications to the Blogs" ); +} +$now = date("U"); +$id = "blog_id"; +$desc_id = "parsed_data"; +$dateId = "created"; +$readrepl = "view_post.php?$id="; + +require( RSS_PKG_PATH.'rss_read_cache.php' ); + +if ($output == "EMPTY") { + $blogPost = new BitBlogPost(); + $listHash['sort_mode'] = $dateId.'_desc'; + $listHash['max_records'] = $gBitSystem->getPreference( 'max_rss_blogs', 10 ); + $listHash['parse_data'] = TRUE; + if (!empty($_REQUEST['blog_id'])) { + $listHash['blog_id'] = $_REQUEST['blog_id']; + } + + $changes = $blogPost->getList( $listHash ); + $output=""; +} + +require( RSS_PKG_PATH.'rss.php' ); + +?> diff --git a/display_bitblogpost_inc.php b/display_bitblogpost_inc.php new file mode 100644 index 0000000..ddd3477 --- /dev/null +++ b/display_bitblogpost_inc.php @@ -0,0 +1,193 @@ +<?php + +if (defined("CATEGORIES_PKG_PATH")) { + include_once( CATEGORIES_PKG_PATH.'categ_lib.php'); +} + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +global $PHP_SELF; + +if (!isset($gContent->mPostId) && !isset($gContent->mPostId)) { + $parts = parse_url($_SERVER['REQUEST_URI']); + + $paths = explode('/', $parts['path']); + $blog_id = $paths[count($paths) - 2]; + $post_id = $paths[count($paths) - 1]; + // So this is to process a trackback ping + if (isset($_REQUEST['__mode'])) { + // Build RSS listing trackback_from + $pings = $gContent->getTrackbacksFrom(); + } + + if (isset($_REQUEST['url'])) { + // Add a trackback ping to the list of trackback_from + $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : ''; + + $excerpt = isset($_REQUEST['excerpt']) ? $_REQUEST['excerpt'] : ''; + $blog_name = isset($_REQUEST['blog_name']) ? $_REQUEST['blog_name'] : ''; + + if ($gContent->addTrackbackFrom( $_REQUEST['url'], $title, $excerpt, $blog_name ) ) { + print ('<?xml version="1.0" encoding="iso-8859-1"?>'); + + print ('<response>'); + print ('<error>0</error>'); + print ('</response>'); + } else { + print ('<?xml version="1.0" encoding="iso-8859-1"?>'); + + print ('<response>'); + print ('<error>1</error>'); + print ('<message>Error trying to add ping for post</message>'); + print ('</response>'); + } + + die; + } +} + +$gBitSystem->verifyPackage( 'blogs' ); + +if (!isset($gContent->mPostId) && $post_id) { + $gContent->mPostId = $gContent->mInfo['blog_id']; +} +$smarty->assign('post_info', $gContent->mInfo ); +$smarty->assign('post_id', $gContent->mPostId); +$_REQUEST["blog_id"] = $gContent->mInfo["blog_id"]; + +$smarty->assign('blog_id', $_REQUEST["blog_id"]); + +if( !empty( $gContent->mInfo['blog_style'] ) && $gBitSystem->getPreference('feature_user_theme') == 'h' ) { + $gBitSystem->setStyle( $gContent->mInfo['blog_style'] ); + $gBitLoc['styleSheet'] = $gBitSystem->getStyleCss( $gContent->mInfo['blog_style'], $gContent->mInfo['user_id'] ); + $smarty->assign( 'userStyle', $gContent->mInfo['blog_style'] ); +} + +//Build absolute URI for this +$parts = parse_url($_SERVER['REQUEST_URI']); +$uri = httpPrefix(). $parts['path'] . '?blog_id=' . $gContent->mInfo['blog_id'] . '&post_id=' . $gContent->mPostId; +$uri2 = httpPrefix(). $parts['path'] . '/' . $gContent->mInfo['blog_id'] . '/' . $gContent->mPostId; +$smarty->assign('uri', $uri); +$smarty->assign('uri2', $uri2); + +if (!isset($_REQUEST['offset'])) + $_REQUEST['offset'] = 0; + +if (!isset($_REQUEST['sort_mode'])) + $_REQUEST['sort_mode'] = 'created_desc'; + +if (!isset($_REQUEST['find'])) + $_REQUEST['find'] = ''; + +$smarty->assign('offset', $_REQUEST["offset"]); +$smarty->assign('sort_mode', $_REQUEST["sort_mode"]); +$smarty->assign('find', $_REQUEST["find"]); +$offset = $_REQUEST["offset"]; +$sort_mode = $_REQUEST["sort_mode"]; +$find = $_REQUEST["find"]; + +$parsed_data = $gContent->parseData(); + +if (!isset($_REQUEST['page'])) + $_REQUEST['page'] = 1; + +$pages = $gContent->getNumberOfPages($parsed_data); +$parsed_data = $gContent->getPage($parsed_data, $_REQUEST['page']); +$smarty->assign('pages', $pages); + +if ($pages > $_REQUEST['page']) { + $smarty->assign('next_page', $_REQUEST['page'] + 1); +} else { + $smarty->assign('next_page', $_REQUEST['page']); +} + +if ($_REQUEST['page'] > 1) { + $smarty->assign('prev_page', $_REQUEST['page'] - 1); +} else { + $smarty->assign('prev_page', 1); +} + +$smarty->assign('first_page', 1); +$smarty->assign('last_page', $pages); +$smarty->assign('page', $_REQUEST['page']); + +$smarty->assign('parsed_data', $parsed_data); + +$smarty->assign('individual', 'n'); + +if ($gBitUser->object_has_one_permission($_REQUEST["blog_id"], 'blog')) { + $smarty->assign('individual', 'y'); + + if (!$gBitUser->isAdmin()) { + // Now get all the permissions that are set for this type of permissions 'image gallery' + $perms = $gBitUser->getPermissions('', 'blogs'); + + foreach ($perms["data"] as $perm) { + $perm_name = $perm["perm_name"]; + + if ($gBitUser->object_has_permission($user, $_REQUEST["blog_id"], 'blog', $perm_name)) { + $$perm_name = 'y'; + + $smarty->assign("$perm_name", 'y'); + } else { + $$perm_name = 'n'; + + $smarty->assign("$perm_name", 'n'); + } + } + } +} + +if ($gBitUser->hasPermission( 'bit_p_blog_admin' )) { + $bit_p_create_blogs = 'y'; + + $smarty->assign('bit_p_create_blogs', 'y'); + $bit_p_blog_post = 'y'; + $smarty->assign('bit_p_blog_post', 'y'); + $bit_p_read_blog = 'y'; + $smarty->assign('bit_p_read_blog', 'y'); +} + +$gBitSystem->verifyPermission( 'bit_p_read_blog' ); +/*if (!$gBitUser->hasPermission( 'bit_p_read_blog' )) { + $smarty->assign('msg', tra("Permission denied you can not view this section")); + + $gBitSystem->display( 'error.tpl' ); + die; +}*/ + +$smarty->assign('ownsblog', ( $gBitUser->isValid() && $gBitUser->mUserId == $gContent->mInfo["user_id"] ) ? 'y' : 'n' ); + +if ($gBitSystem->isFeatureActive( 'feature_blogposts_comments' ) ) { + $maxComments = $gBitSystem->getPreference( 'blog_comments_per_page' ); + $comments_return_url = $PHP_SELF."?post_id=".$gContent->mPostId; + $commentsParentId = $gContent->mInfo['content_id']; + include_once ( LIBERTY_PKG_PATH.'comments_inc.php' ); +} + +$section = 'blogs'; + +if( $gBitSystem->isFeatureActive( 'feature_theme_control' ) ) { + $cat_type = 'blog'; + + $cat_objid = $gContent->mContentId; + include( THEMES_PKG_PATH.'tc_inc.php' ); +} + +if( $gBitSystem->isPackageActive( 'categories' ) ) { + $cat_obj_type = BITBLOGPOST_CONTENT_TYPE_GUID; + $cat_objid = $gContent->mContentId; + include_once( CATEGORIES_PKG_PATH.'categories_display_inc.php' ); +} + +if ( $gBitSystem->isPackageActive( 'notepad' ) && $gBitUser->isValid() && isset($_REQUEST['savenotepad'])) { + + $gBitSystem->replace_note($user, 0, $gContent->mInfo['title'] ? $gContent->mInfo['title'] : date("d/m/Y [h:i]", $gContent->mInfo['created']), $gContent->mInfo['data']); +} + + +$gBitSystem->setBrowserTitle($gContent->mInfo['title'].' - '.$gContent->mInfo['blogtitle']); +// Display the template +$gBitSystem->display( 'bitpackage:blogs/view_blog_post.tpl'); + +?> diff --git a/edit.php b/edit.php new file mode 100644 index 0000000..48709f5 --- /dev/null +++ b/edit.php @@ -0,0 +1,155 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/edit.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); + +$gBitSystem->verifyPackage( 'blogs' ); + +if (isset($_REQUEST["blog_id"])) { + $blog_id = $_REQUEST["blog_id"]; +} else { + $blog_id = 0; +} + +$smarty->assign('individual', 'n'); + +if ($gBitUser->object_has_one_permission($blog_id, 'blog')) { + $smarty->assign('individual', 'y'); + + if (!$gBitUser->isAdmin()) { + // Now get all the permissions that are set for this content type + $perms = $gBitUser->getPermissions('', 'blogs'); + foreach( array_keys( $perms ) as $permName ) { + if ($gBitUser->object_has_permission( $user, $_REQUEST["blog_id"], 'blog', $permName ) ) { + $$permName = 'y'; + $smarty->assign( $permName, 'y'); + } else { + $$permName = 'n'; + $smarty->assign( $permName, 'n'); + } + } + } +} + +$smarty->assign('blog_id', $blog_id); +$smarty->assign('title', ''); +$smarty->assign('description', ''); +$smarty->assign('public', 'n'); +$smarty->assign('use_find', 'y'); +$smarty->assign('use_title', 'y'); +$smarty->assign('allow_comments', 'y'); +$smarty->assign('max_posts', 10); + + +if (!isset($created)) { + $created=time(); + $smarty->assign('created', $created); +} + +if (!isset($last_modified)) { + $last_modified=time(); + $smarty->assign('last_modified', $last_modified); +} + +if (isset($_REQUEST["heading"])and $bit_p_edit_templates) { + $heading = $_REQUEST["heading"]; +} else { + $heading = ''; +} + +$smarty->assign_by_ref('heading', $heading); + +if (isset($_REQUEST["blog_id"]) && $_REQUEST["blog_id"] > 0) { + // Check permission + $data = $gBlog->get_blog($_REQUEST["blog_id"]); + + if ($data["user_id"] != $gBitUser->mUserId || !$gBitUser->mUserId) { + $gBitSystem->verifyPermission( 'bit_p_blog_admin', "Permission denied you cannot edit this blog" ); + } + + $smarty->assign('title', $data["title"]); + $smarty->assign('description', $data["description"]); + $smarty->assign('public', $data["public"]); + $smarty->assign('use_title', $data["use_title"]); + $smarty->assign('allow_comments', $data["allow_comments"]); + $smarty->assign('use_find', $data["use_find"]); + $smarty->assign('max_posts', $data["max_posts"]); + $smarty->assign('heading', $data["heading"]); +} else { + $data = NULL; +} + +// Now check permissions to access this page +if (!$gBitUser->hasPermission( 'bit_p_create_blogs' ) && ($gBitUser->mUserId != $data['user_id'] || !$gBitUser->mUserId) ) { + $smarty->assign('msg', tra("Permission denied you cannot create or edit blogs")); + + $gBitSystem->display( 'error.tpl' ); + die; +} + +if (isset($_REQUEST['preview'])) { + $smarty->assign('title', $_REQUEST["title"]); + + $smarty->assign('description', $_REQUEST["description"]); + $smarty->assign('public', isset($_REQUEST["public"]) ? 'y' : 'n'); + $smarty->assign('use_find', isset($_REQUEST["use_find"]) ? 'y' : 'n'); + $smarty->assign('use_title', isset($_REQUEST["use_title"]) ? 'y' : 'n'); + $smarty->assign('allow_comments', isset($_REQUEST["allow_comments"]) ? 'y' : 'n'); + $smarty->assign('max_posts', $_REQUEST["max_posts"]); + $smarty->assign('heading', $heading); +} + +if (isset($_REQUEST['save_blog'])) { + + if (isset($_REQUEST["public"]) && $_REQUEST["public"] == 'on') { + $public = 'y'; + } else { + $public = 'n'; + } + + $use_title = isset($_REQUEST['use_title']) ? 'y' : 'n'; + $allow_comments = isset($_REQUEST['allow_comments']) ? 'y' : 'n'; + $use_find = isset($_REQUEST['use_find']) ? 'y' : 'n'; + $heading = isset($_REQUEST['heading']) ? $_REQUEST['heading'] : ''; + + $bid = $gBlog->replace_blog($_REQUEST["title"], + $_REQUEST["description"], $gBitUser->mUserId, $public, + $_REQUEST["max_posts"], $_REQUEST["blog_id"], + $heading, $use_title, $use_find, + $allow_comments); + + $cat_type = 'blog'; + $cat_objid = $bid; + $cat_desc = substr($_REQUEST["description"], 0, 200); + $cat_name = $_REQUEST["title"]; + $cat_href = BitBlog::getBlogUrl( $cat_objid ); + if ($gBitSystem->isPackageActive( 'categories' )) { + include_once( CATEGORIES_PKG_PATH.'categorize_inc.php' ); + } + + header ("location: ".BLOGS_PKG_URL.'post.php?blog_id='.$bid ); + die; +} + +$cat_type = 'blog'; +$cat_objid = $blog_id; +if ($gBitSystem->isPackageActive( 'categories' )) { + include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' ); +} + + +$gBitSystem->setBrowserTitle("Edit Blog Post - ".$data['title']); +// Display the Index Template +$smarty->assign('show_page_bar', 'n'); +$gBitSystem->display( 'bitpackage:blogs/edit_blog.tpl'); + +?> diff --git a/icons/pkg_blogs.png b/icons/pkg_blogs.png Binary files differnew file mode 100644 index 0000000..e97db6d --- /dev/null +++ b/icons/pkg_blogs.png diff --git a/index.php b/index.php new file mode 100644 index 0000000..f74f703 --- /dev/null +++ b/index.php @@ -0,0 +1,39 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/index.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +if (defined("CATEGORIES_PKG_PATH")) { + include_once( CATEGORIES_PKG_PATH.'categ_lib.php'); +} + +$gBitSystem->verifyPackage( 'blogs' ); + +if ($gBitSystem->isPackageActive( 'categories' )) { + if (isset($_REQUEST['addcateg']) and $_REQUEST['addcateg'] and isset($_REQUEST['post_id']) and $_REQUEST['post_id']) { + $categlib->categorize_blog_post($_REQUEST['post_id'],$_REQUEST['addcateg'],true); + } elseif (isset($_REQUEST['delcategs']) and isset($_REQUEST['post_id']) and $_REQUEST['post_id']) { + $categlib->uncategorize('blogpost',$_REQUEST['post_id']); + } + + $categs = $categlib->list_all_categories(0, -1, 'name_asc', '', '', 0); + $smarty->assign('categs',$categs['data']); + $smarty->assign('page','index.php'); + $choosecateg = str_replace('"',"'",$smarty->fetch('bitpackage:blogs/popup_categs.tpl')); + $smarty->assign('choosecateg',$choosecateg); +} + +$smarty->assign( 'showEmpty', TRUE ); +$gDefaultCenter = 'bitpackage:blogs/center_list_blog_posts.tpl'; +$smarty->assign_by_ref( 'gDefaultCenter', $gDefaultCenter ); + +// Display the template +$gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', 'List Blog Posts' ); + +?> diff --git a/list_blogs.php b/list_blogs.php new file mode 100644 index 0000000..d0a06f5 --- /dev/null +++ b/list_blogs.php @@ -0,0 +1,161 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/list_blogs.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +$gBitSystem->verifyPackage( 'blogs' ); + +$gBitSystem->verifyPermission( 'bit_p_read_blog' ); + +/* +if($feature_listPages != 'y') { + $smarty->assign('msg',tra("This feature is disabled")); + $gBitSystem->display( 'error.tpl' ); + die; +} +*/ + +/* +// Now check permissions to access this page +if(!$gBitUser->hasPermission( 'bit_p_view' )) { + $smarty->assign('msg',tra("Permission denied you cannot view pages")); + $gBitSystem->display( 'error.tpl' ); + die; +} +*/ +if (isset($_REQUEST["remove"])) { + + + // Check if it is the owner + if( $data = $gBlog->get_blog($_REQUEST["remove"]) ) { + if( !empty( $_REQUEST['cancel'] ) ) { + // user cancelled - just continue on, doing nothing + } elseif( empty( $_REQUEST['confirm'] ) ) { + $formHash['remove'] = $_REQUEST["remove"]; + $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete the blog '.$data['title'].'?', 'error' => 'This cannot be undone!' ) ); + } else { + + if ($data["user_id"] != $gBitUser->mUserId) { + $gBitSystem->verifyPermission( 'bit_p_blog_admin', "Permission denied you cannot remove this blog" ); + } + + $gBlog->expunge($_REQUEST["remove"]); + } + } +} + +// This script can receive the thresold +// for the information as the number of +// days to get in the log 1,3,4,etc +// it will default to 1 recovering information for today +if( empty( $_REQUEST["sort_mode"] ) ) { + $sort_mode = $gBitSystem->getPreference( 'blog_list_order', 'created_desc' ); +} else { + $sort_mode = $_REQUEST["sort_mode"]; +} + +$smarty->assign_by_ref('sort_mode', $sort_mode); + +// If offset is set use it if not then use offset =0 +// use the maxRecords php variable to set the limit +// if sortMode is not set then use last_modified_desc +if (!isset($_REQUEST["offset"])) { + $offset = 0; +} else { + $offset = $_REQUEST["offset"]; +} + +if (isset($_REQUEST['page'])) { + $page = &$_REQUEST['page']; + $offset = ($page - 1) * $maxRecords; +} + +$smarty->assign_by_ref('offset', $offset); + +if (isset($_REQUEST["find"])) { + $find = $_REQUEST["find"]; +} else { + $find = ''; +} + +$smarty->assign('find', $find); + +// Get a list of last changes to the Wiki database +$listpages = $gBlog->list_blogs($offset, $maxRecords, $sort_mode, $find); + +for ($i = 0; $i < count($listpages["data"]); $i++) { + if ($gBitUser->object_has_one_permission($listpages["data"][$i]["blog_id"], 'blog')) { + $listpages["data"][$i]["individual"] = 'y'; + + if ($gBitUser->object_has_permission($user, $listpages["data"][$i]["blog_id"], 'blog', 'bit_p_read_blog')) { + $listpages["data"][$i]["individual_bit_p_read_blog"] = 'y'; + } else { + $listpages["data"][$i]["individual_bit_p_read_blog"] = 'n'; + } + + if ($gBitUser->object_has_permission($user, $listpages["data"][$i]["blog_id"], 'blog', 'bit_p_blog_post')) { + $listpages["data"][$i]["individual_bit_p_blog_post"] = 'y'; + } else { + $listpages["data"][$i]["individual_bit_p_blog_post"] = 'n'; + } + + if ($gBitUser->object_has_permission($user, $listpages["data"][$i]["blog_id"], 'blog', 'bit_p_create_blogs')) { + $listpages["data"][$i]["individual_bit_p_create_blogs"] = 'y'; + } else { + $listpages["data"][$i]["individual_bit_p_create_blogs"] = 'n'; + } + + if ($gBitUser->isAdmin() || $gBitUser->object_has_permission($user, $listpages["data"][$i]["blog_id"], 'blog', 'bit_p_blog_admin')) + { + $listpages["data"][$i]["individual_bit_p_create_blogs"] = 'y'; + + $listpages["data"][$i]["individual_bit_p_blog_post"] = 'y'; + $listpages["data"][$i]["individual_bit_p_read_blog"] = 'y'; + } + } else { + $listpages["data"][$i]["individual"] = 'n'; + } +} + +// If there're more records then assign next_offset +$cant_pages = ceil($listpages["cant"] / $maxRecords); +$smarty->assign_by_ref('cant_pages', $cant_pages); +$smarty->assign('actual_page', 1 + ($offset / $maxRecords)); + +if ($listpages["cant"] > ($offset + $maxRecords)) { + $smarty->assign('next_offset', $offset + $maxRecords); +} else { + $smarty->assign('next_offset', -1); +} + +// If offset is > 0 then prev_offset +if ($offset > 0) { + $smarty->assign('prev_offset', $offset - $maxRecords); +} else { + $smarty->assign('prev_offset', -1); +} + +$smarty->assign_by_ref('listpages', $listpages["data"]); +//print_r($listpages["data"]); +$section = 'blogs'; + +if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') { + include_once( HAWHAW_PKG_PATH.'hawtiki_lib.php' ); + + HAWBIT_list_blogs($listpages, $bit_p_read_blog); +} + + +$gBitSystem->setBrowserTitle("View All Blogs"); +// Display the template +$gBitSystem->display( 'bitpackage:blogs/list_blogs.tpl'); + +?> diff --git a/lookup_post_inc.php b/lookup_post_inc.php new file mode 100644 index 0000000..2db4d96 --- /dev/null +++ b/lookup_post_inc.php @@ -0,0 +1,11 @@ +<?php + global $gContent, $smarty; + + if( empty( $gContent ) || !is_object( $gContent ) || !$gContent->isValid() ) { + $postId = isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : NULL; + $gContent = new BitBlogPost( $postId ); + $gContent->load(); + $comments_return_url = $_SERVER['PHP_SELF']."?post_id=$postId"; + $smarty->assign_by_ref( 'gContent', $gContent ); + } +?> diff --git a/modules/index.php b/modules/index.php new file mode 100644 index 0000000..3e305fe --- /dev/null +++ b/modules/index.php @@ -0,0 +1,6 @@ +<?php + + // This is not a package. + header ("location: ../index.php"); + +?>
\ No newline at end of file diff --git a/modules/mod_last_blog_posts.php b/modules/mod_last_blog_posts.php new file mode 100644 index 0000000..1647517 --- /dev/null +++ b/modules/mod_last_blog_posts.php @@ -0,0 +1,35 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_last_blog_posts.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +/** +* Params: +* - title : if is "title", show the title of the post, else show the date of creation +*/ +if( !defined( 'MAX_BLOG_PREVIEW_LENGTH' ) ) { + define ('MAX_BLOG_PREVIEW_LENGTH', 100); +} + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +include_once( BLOGS_PKG_PATH.'BitBlogPost.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); +require_once( KERNEL_PKG_PATH.'mod_lib.php' ); + +global $smarty, $gBlog, $modlib, $gQueryUserId, $module_rows, $module_params, $gBitSystem; + +$listHash = array( 'user_id' => $gQueryUserId, 'sort_mode' => 'created_desc', 'max_records' => $module_rows, 'parse_data' => TRUE ); +$blogPost = new BitBlogPost(); +$ranking = $blogPost->getList( $listHash ); + +$modParams = $modlib->get_module_params('bitpackage:blogs/mod_last_blog_posts.tpl', $gQueryUserId); + +$maxPreviewLength = (!empty($modParams['max_preview_length']) ? $modParams['max_preview_length'] : MAX_BLOG_PREVIEW_LENGTH); +$user_blog_id = NULL; +if( count( $ranking['data'] ) ) { + $user_blog_id = $ranking['data'][0]['blog_id']; +} +$smarty->assign('user_blog_id', $user_blog_id); + +$smarty->assign('maxPreviewLength', $maxPreviewLength); +$smarty->assign('modLastBlogPosts', $ranking["data"]); +$smarty->assign('modLastBlogPostsTitle',(isset($module_params["title"])?$module_params["title"]:"")); +$smarty->assign('blogsPackageActive', $gBitSystem->isPackageActive('blogs')); +?> diff --git a/modules/mod_last_blog_posts.tpl b/modules/mod_last_blog_posts.tpl new file mode 100644 index 0000000..51d4ad2 --- /dev/null +++ b/modules/mod_last_blog_posts.tpl @@ -0,0 +1,24 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_last_blog_posts.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{strip} +{if $blogsPackageActive} + {bitmodule title="$moduleTitle" name="last_blog_posts"} + <ul class="blogs"> + {section name=ix loop=$modLastBlogPosts} + <li class="{cycle values="odd,even"}"> + <div class="date">{$modLastBlogPosts[ix].created|bit_long_date} + <br /> + by {displayname hash=$modLastBlogPosts[ix]}</div> + {$modLastBlogPosts[ix].parsed_data|truncate:$maxPreviewLength} + <br /> + <a href="{$modLastBlogPosts[ix].post_url}">Read more</a> + </li> + {sectionelse} + <li></li> + {/section} + </ul> + {if $user_blog_id} + <div style="text-align:center;"><a href="{$gBitLoc.BIT_ROOT_URL}blogs/view.php?blog_id={$user_blog_id}">Visit my blog</a></div> + {/if} + {/bitmodule} +{/if} +{/strip} diff --git a/modules/mod_last_created_blogs.php b/modules/mod_last_created_blogs.php new file mode 100644 index 0000000..1d70be0 --- /dev/null +++ b/modules/mod_last_created_blogs.php @@ -0,0 +1,10 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_last_created_blogs.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); + +global $gBlog, $gQueryUserId, $module_rows; +$ranking = $gBlog->list_blogs(0, $module_rows, 'created_desc', '', $gQueryUserId); + +$smarty->assign('modLastCreatedBlogs', $ranking["data"]); +?> diff --git a/modules/mod_last_created_blogs.tpl b/modules/mod_last_created_blogs.tpl new file mode 100644 index 0000000..682ba74 --- /dev/null +++ b/modules/mod_last_created_blogs.tpl @@ -0,0 +1,19 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_last_created_blogs.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{strip} +{if $gBitSystemPrefs.feature_blogs eq 'y'} + {if $nonums eq 'y'} + {eval var="{tr}Last `$module_rows` Created blogs{/tr}" assign="tpl_module_title"} + {else} + {eval var="{tr}Last Created blogs{/tr}" assign="tpl_module_title"} + {/if} + {bitmodule title="$moduleTitle" name="last_created_blogs"} + <ol class="blogs"> + {section name=ix loop=$modLastCreatedBlogs} + <li><a href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$modLastCreatedBlogs[ix].blog_id}">{$modLastCreatedBlogs[ix].title}</a></li> + {sectionelse} + <li></li> + {/section} + </ol> + {/bitmodule} +{/if} +{/strip} diff --git a/modules/mod_last_modified_blogs.php b/modules/mod_last_modified_blogs.php new file mode 100644 index 0000000..6309414 --- /dev/null +++ b/modules/mod_last_modified_blogs.php @@ -0,0 +1,11 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_last_modified_blogs.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); + +global $gBlog, $gQueryUserId, $module_rows; + +$ranking = $gBlog->list_blogs(0, $module_rows, 'last_modified_desc', '', $gQueryUserId ); + +$smarty->assign('modLastModifiedBlogs', $ranking["data"]); +?> diff --git a/modules/mod_last_modified_blogs.tpl b/modules/mod_last_modified_blogs.tpl new file mode 100644 index 0000000..ff3884b --- /dev/null +++ b/modules/mod_last_modified_blogs.tpl @@ -0,0 +1,19 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_last_modified_blogs.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{strip} +{if $gBitSystemPrefs.feature_blogs eq 'y'} + {if $nonums eq 'y'} + {eval var="{tr}Last `$module_rows` Modified blogs{/tr}" assign="tpl_module_title"} + {else} + {eval var="{tr}Last Modified blogs{/tr}" assign="tpl_module_title"} + {/if} + {bitmodule title="$moduleTitle" name="last_modified_blogs"} + <ol class="blogs"> + {section name=ix loop=$modLastModifiedBlogs} + <li><a href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$modLastModifiedBlogs[ix].blog_id}">{$modLastModifiedBlogs[ix].title}</a></li> + {sectionelse} + <li></li> + {/section} + </ol> + {/bitmodule} +{/if} +{/strip} diff --git a/modules/mod_top_active_blogs.php b/modules/mod_top_active_blogs.php new file mode 100644 index 0000000..bddb443 --- /dev/null +++ b/modules/mod_top_active_blogs.php @@ -0,0 +1,12 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_top_active_blogs.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); + +global $gBlog, $gQueryUserId, $modlib; + +$params = $modlib->get_module_params('bitpackage:blogs/mod_top_active_blogs.tpl', $gQueryUserId); + +$ranking = $gBlog->list_blogs(0, $params['rows'], 'activity_desc', '', $gQueryUserId, 'tb.`activity` IS NOT NULL'); +$smarty->assign('modTopActiveBlogs', $ranking["data"]); +?> diff --git a/modules/mod_top_active_blogs.tpl b/modules/mod_top_active_blogs.tpl new file mode 100644 index 0000000..0ed0f64 --- /dev/null +++ b/modules/mod_top_active_blogs.tpl @@ -0,0 +1,19 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_top_active_blogs.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{strip} +{if $gBitSystemPrefs.package_blogs eq 'y' && $gBitUser->hasPermission( 'bit_p_read_blog' )} + {if $nonums eq 'y'} + {eval var="`$module_rows` {tr}Most Active blogs{/tr}" assign="tpl_module_title"} + {else} + {eval var="{tr}Most Active blogs{/tr}" assign="tpl_module_title"} + {/if} + {bitmodule title="$moduleTitle" name="top_active_blogs"} + <ol class="blogs"> + {section name=ix loop=$modTopActiveBlogs} + <li><a href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$modTopActiveBlogs[ix].blog_id}">{$modTopActiveBlogs[ix].title}</a></li> + {sectionelse} + <li></li> + {/section} + </ol> + {/bitmodule} +{/if} +{/strip} diff --git a/modules/mod_top_visited_blogs.php b/modules/mod_top_visited_blogs.php new file mode 100644 index 0000000..13c1664 --- /dev/null +++ b/modules/mod_top_visited_blogs.php @@ -0,0 +1,13 @@ +<?php +// $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_top_visited_blogs.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); + +global $gBlog, $gQueryUserId, $modlib; + +$params = $modlib->get_module_params('bitpackage:blogs/mod_top_visited_blogs.tpl', $gQueryUserId); +$ranking = $gBlog->list_blogs(0, $params['rows'], 'hits_desc', '',$gQueryUserId,' `hits` IS NOT NULL '); + +$smarty->assign('modTopVisitedBlogs', $ranking["data"]); +$smarty->assign('bulletSrc', isset($params["bullet"]) ? $params['bullet'] : NULL); +?> diff --git a/modules/mod_top_visited_blogs.tpl b/modules/mod_top_visited_blogs.tpl new file mode 100644 index 0000000..f3379ff --- /dev/null +++ b/modules/mod_top_visited_blogs.tpl @@ -0,0 +1,20 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/modules/mod_top_visited_blogs.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{strip} +{if $gBitSystemPrefs.package_blogs eq 'y'} + {if $nonums eq 'y'} + {eval var="{tr}Most `$module_rows` visited blogs{/tr}" assign="tpl_module_title"} + {else} + {eval var="{tr}Most visited blogs{/tr}" assign="tpl_module_title"} + {/if} + + {bitmodule title="$moduleTitle" name="top_visited_blogs"} + <ol class="blogs"> + {section name=ix loop=$modTopVisitedBlogs} + <li><a href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$modTopVisitedBlogs[ix].blog_id}">{$modTopVisitedBlogs[ix].title}</a></li> + {sectionelse} + <li></li> + {/section} + </ol> + {/bitmodule} +{/if} +{/strip} diff --git a/post.php b/post.php new file mode 100644 index 0000000..8065d89 --- /dev/null +++ b/post.php @@ -0,0 +1,248 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/post.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +$gBitSystem->verifyPackage( 'blogs' ); + +// Now check permissions to access this page +$gBitSystem->verifyPermission( 'bit_p_blog_post' ); + +$smarty->assign('wysiwyg', 'n'); + +if (isset($_REQUEST['wysiwyg']) && $_REQUEST['wysiwyg'] == 'y') { + $smarty->assign('wysiwyg', 'y'); +} + +if (isset($_REQUEST["blog_id"])) { + $blog_id = $_REQUEST["blog_id"]; + $blog_data = $gBlog->get_blog($blog_id); +} else { + $blog_id = NULL; +} + +// $blogs holds a list of blogs which the user can post into +// If a specific blog_id is passed in, we will use that and not load up all the blogs +if ($gBitUser->hasPermission( 'bit_p_blog_admin' )) { + if ($blog_id) { + $blogs = array($gBlog->get_blog($blog_id)); + } else { + $blogs_temp = $gBlog->list_blogs(0, -1, 'created_desc', ''); + $blogs = $blogs_temp['data']; + // Get blogs the admin owns + $adminBlogs = $gBlog->list_user_blogs($gBitUser->mUserId); + if (count($adminBlogs) > 0) { + // Use one of these as the default blog to post into + $blog_id = $adminBlogs[0]['blog_id']; + } + } +} else { + if ($blog_id) { + $blogInfo = $gBlog->get_blog($blog_id); + if ($blogInfo) { + //if (($blogInfo['user_id'] != $gBitUser->mUserId && $blogInfo['public'] != 'y') && !$gBlog->viewerCanPostIntoBlog()) { + if ($gBlog->viewerCanPostIntoBlog()) { + $smarty->assign('msg', tra("You cannot post into this blog")); + $gBitSystem->display('error.tpl'); + die(); + } + $blogs = array($blogInfo); + } else { + $smarty->assign('msg',tra("The given blog does not exist")); + $gBitSystem->display('error.tpl'); + die(); + } + } else { + $blogs = $gBlog->list_user_blogs($gBitUser->mUserId, 1); + } +} + +if (!$blog_id && count($blogs) > 0) { + $blog_id = $blogs[0]['blog_id']; // Default to the first blog returned that this user owns +} +if (count($blogs) == 0) { + if( $gBitUser->hasPermission( 'bit_p_create_blogs' )) { + $mid = 'bitpackage:blogs/edit_blog.tpl'; + $smarty->assign('warning', tra("Before you can post, you first need to create a blog that will hold your posts.")); + } else { + $smarty->assign('msg', tra("You can't post in any blog maybe you have to create a blog first")); + $mid = 'error.tpl'; + } + +} else { + if ($gBitSystem->getPreference('package_quicktags','n') == 'y') { + include_once( QUICKTAGS_PKG_PATH.'quicktags_inc.php' ); + } + $mid = 'bitpackage:blogs/blog_post.tpl'; +} + +$smarty->assign('data', ''); +$smarty->assign('created', date("U")); + +$blog_data = $gBlog->get_blog($blog_id); +$smarty->assign_by_ref('blog_data', $blog_data); + +require_once( BLOGS_PKG_PATH.'lookup_post_inc.php' ); +if ( $gBitSystem->isPackageActive('categories') ) { + $cat_type = BITBLOGPOST_CONTENT_TYPE_GUID; + $cat_objid = $gContent->mPostId; + include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' ); +} + + +if (isset($_REQUEST['remove_image'])) { + + $gContent->expungeAttachment( $_REQUEST['remove_image'] ); +} + +// If the post_id is passed then get the article data +if( isset($_REQUEST["post_id"]) && $_REQUEST["post_id"] > 0 ) { + $gContent->load(); + + if( $gContent->mInfo["user_id"] != $gBitUser->mUserId || !$gBitUser->isValid() ) { + $gBitSystem->verifyPermission( 'bit_p_blog_admin', "Permission denied you cannot edit this blog" ); + } + + $smarty->assign('data', $gContent->mInfo["data"]); + $smarty->assign('title', $gContent->mInfo["title"]); + $smarty->assign('trackbacks_to', $gContent->mInfo["trackbacks_to"]); + $smarty->assign('created', $gContent->mInfo["created"]); + $smarty->assign('parsed_data', $gContent->parseData() ); +} else { + // Avoid undefined trackbacks_to smarty var in the case of 'preview' + $smarty->assign('trackbacks_to', NULL); +} + +$smarty->assign('preview', 'n'); + +if (isset($_REQUEST["preview"])) { + $data = $_REQUEST['edit']; + $parsed_data = $gContent->parseData( $_REQUEST['edit'], (!empty($_REQUEST['format_guid']) ? $_REQUEST['format_guid'] : 'tikiwiki' )); + + if ($blog_spellcheck == 'y') { + if (isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on') { + $parsed_data = $gBitSystem->spellcheckreplace($data, $parsed_data, $language, 'blogedit'); + + $smarty->assign('spellcheck', 'y'); + } else { + $smarty->assign('spellcheck', 'n'); + } + } + + if (empty($data)) + $data = ''; + + $smarty->assign('data', $data); + $smarty->assign('title', isset($_REQUEST["title"]) ? $_REQUEST['title'] : ''); + $smarty->assign('parsed_data', $parsed_data); + $smarty->assign('preview', 'y'); + +} elseif (isset($_REQUEST['save_post']) || isset($_REQUEST['save_post_exit'])) { + $smarty->assign('individual', 'n'); + + if ($gBitUser->object_has_one_permission($_REQUEST["blog_id"], 'blog')) { + $smarty->assign('individual', 'y'); + + if (!$gBitUser->isAdmin()) { + // Now get all the permissions that are set for this content type + $perms = $gBitUser->getPermissions('', 'blogs'); + foreach( array_keys( $perms ) as $permName ) { + if ($gBitUser->object_has_permission( $user, $_REQUEST["blog_id"], 'blog', $permName ) ) { + $$permName = 'y'; + $smarty->assign( $permName, 'y'); + } else { + $$permName = 'n'; + $smarty->assign( $permName, 'n'); + } + } + } + } + + if ($gBitUser->hasPermission( 'bit_p_blog_admin' )) { + $bit_p_create_blogs = 'y'; + + $smarty->assign('bit_p_create_blogs', 'y'); + $bit_p_blog_post = 'y'; + $smarty->assign('bit_p_blog_post', 'y'); + $bit_p_read_blog = 'y'; + $smarty->assign('bit_p_read_blog', 'y'); + } + + $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : ''; + + if( !isset( $_REQUEST['trackback'] ) ) { $_REQUEST['trackback'] = ''; } + + if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) { + $_REQUEST['upload'] = &$_FILES['userfile1']; + $_REQUEST['upload']['process_storage'] = STORAGE_IMAGE; + } + + if( $gContent->store( $_REQUEST ) ) { + if ( $gBitSystem->isPackageActive('categories') ) { + $cat_desc = $gLibertySystem->mContentTypes[BITBLOGPOST_CONTENT_TYPE_GUID]['content_description'].' by '.$gBitUser->getDisplayName( FALSE, array( 'real_name' => $gContent->mInfo['real_name'], 'user' => $gContent->mInfo['user'], 'user_id'=>$gContent->mInfo['user_id'] ) ); + $cat_name = $gContent->getTitle(); + $cat_href = $gContent->getDisplayUrl(); + $cat_objid = $gContent->mContentId; + include_once( CATEGORIES_PKG_PATH.'categorize_inc.php' ); + } + $postid = $_REQUEST['post_id']; + $smarty->assign('post_id', $gContent->mPostId); + + if (isset($_REQUEST['save_post_exit'])) { + header ("location: ".BLOGS_PKG_URL."view_post.php?post_id=$postid"); + die; + } + + $data = $_REQUEST['edit']; + $parsed_data = $gContent->parseData($_REQUEST['edit']); + + if (empty($data)) + $data = ''; + + $smarty->assign('data', $data); + $smarty->assign('title', isset($_REQUEST["title"]) ? $_REQUEST['title'] : ''); + $smarty->assign('trackbacks_to', explode(',', $_REQUEST['trackback'])); + $smarty->assign('parsed_data', $parsed_data); + } +} + +// WYSIWYG and Quicktag variable +$smarty->assign( 'textarea_id', 'editblog' ); + +if (isset($_REQUEST["post_id"])) { + $post_id = $_REQUEST["post_id"]; +} else { + $post_id = NULL; +} +$smarty->assign_by_ref('post_id', $post_id); + +$smarty->assign_by_ref('post_images', $gContent->mStorage); + +$sameurl_elements = array( + 'offset', + 'sort_mode', + 'where', + 'find', + 'blog_id', + 'post_id' +); + +$smarty->assign_by_ref('blogs', $blogs); +$smarty->assign('blog_id', $blog_id); +$section = 'blogs'; + + +$gBitSystem->setBrowserTitle("Create Blog Post"); +// Display the Index Template +$gBitSystem->display( $mid ); +$smarty->assign('show_page_bar', 'n'); + +?> diff --git a/print_blog_post.php b/print_blog_post.php new file mode 100644 index 0000000..dfdd4f4 --- /dev/null +++ b/print_blog_post.php @@ -0,0 +1,107 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/print_blog_post.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +$gBitSystem->verifyPackage( 'blogs' ); + +if (!isset($_REQUEST["post_id"])) { + $gBitSystem->fatalError( 'No post indicated' ); +} + +include_once( BLOGS_PKG_PATH.'lookup_post_inc.php' ); + +$smarty->assign('post_info', $gContent->mInfo ); + +//Build absolute URI for this +$parts = parse_url($_SERVER['REQUEST_URI']); +$uri = httpPrefix(). $parts['path'] . '?blog_id=' . $gContent->mInfo['blog_id'] . '&post_id=' . $gContent->mInfo['post_id']; +$uri2 = httpPrefix(). $parts['path'] . '/' . $gContent->mInfo['blog_id'] . '/' . $gContent->mInfo['post_id']; +$smarty->assign('uri', $uri); +$smarty->assign('uri2', $uri2); + +if (!isset($_REQUEST['offset'])) + $_REQUEST['offset'] = 0; + +if (!isset($_REQUEST['sort_mode'])) + $_REQUEST['sort_mode'] = 'created_desc'; + +if (!isset($_REQUEST['find'])) + $_REQUEST['find'] = ''; + +$smarty->assign('offset', $_REQUEST["offset"]); +$smarty->assign('sort_mode', $_REQUEST["sort_mode"]); +$smarty->assign('find', $_REQUEST["find"]); +$offset = $_REQUEST["offset"]; +$sort_mode = $_REQUEST["sort_mode"]; +$find = $_REQUEST["find"]; + +$smarty->assign( 'parsed_data', $gContent->parseData() ); + +$smarty->assign('individual', 'n'); + +if ($gBitUser->object_has_one_permission($gContent->mInfo['blog_id'], 'blog')) { + $smarty->assign('individual', 'y'); + + if (!$gBitUser->isAdmin()) { + // Now get all the permissions that are set for this content type + $perms = $gBitUser->getPermissions('', 'blogs'); + foreach( array_keys( $perms ) as $permName ) { + if ($gBitUser->object_has_permission( $user, $_REQUEST["blog_id"], 'blog', $permName ) ) { + $$permName = 'y'; + $smarty->assign( $permName, 'y'); + } else { + $$permName = 'n'; + $smarty->assign( $permName, 'n'); + } + } + } +} + +if ($gBitUser->hasPermission( 'bit_p_blog_admin' )) { + $bit_p_create_blogs = 'y'; + + $smarty->assign('bit_p_create_blogs', 'y'); + $bit_p_blog_post = 'y'; + $smarty->assign('bit_p_blog_post', 'y'); + $bit_p_read_blog = 'y'; + $smarty->assign('bit_p_read_blog', 'y'); +} + +$gBitSystem->verifyPermission( 'bit_p_read_blog' ); + +$ownsblog = 'n'; + +if ($gBitUser->mUserId && $gBitUser->mUserId == $gContent->mInfo['blog_user_id'] ) { + $ownsblog = 'y'; +} + +$smarty->assign('ownsblog', $ownsblog); + +if ($feature_theme_control == 'y') { + $cat_type = 'blog'; + $cat_objid = $gContent->mInfo['blog_id']; + include( THEMES_PKG_PATH.'tc_inc.php' ); +} + +if ($feature_blogposts_comments == 'y') { + $maxComments = $gBitSystem->getPreference( 'blog_comments_per_page' ); + $comments_return_url = $PHP_SELF."?post_id=$post_id"; + $commentsParentId = $gContent->mContentId; + include_once ( LIBERTY_PKG_PATH.'comments_inc.php' ); +} + + +$gBitSystem->setBrowserTitle( $gContent->mInfo['title'] ); +// Display the template +$smarty->display("bitpackage:blogs/print_blog_post.tpl"); + +?> diff --git a/rankings.php b/rankings.php new file mode 100644 index 0000000..c2e686c --- /dev/null +++ b/rankings.php @@ -0,0 +1,78 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/rankings.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( KERNEL_PKG_PATH.'rank_lib.php' ); + +$gBitSystem->verifyPackage( 'blogs' ); + +if ($feature_blog_rankings != 'y') { + $smarty->assign('msg', tra("This feature is disabled").": feature_blog_rankings"); + + $gBitSystem->display( 'error.tpl' ); + die; +} + +$gBitSystem->verifyPermission( 'bit_p_read_blog' ); + +$allrankings = array( + array( + 'name' => tra('Top visited blogs'), + 'value' => 'blog_ranking_top_blogs' +), + array( + 'name' => tra('Last posts'), + 'value' => 'blog_ranking_last_posts' +), + array( + 'name' => tra('Top active blogs'), + 'value' => 'blog_ranking_top_active_blogs' +) +); + +$smarty->assign('allrankings', $allrankings); + +if (!isset($_REQUEST["which"])) { + $which = 'blog_ranking_top_blogs'; +} else { + $which = $_REQUEST["which"]; +} + +$smarty->assign('which', $which); + +// Get the page from the request var or default it to HomePage +if (!isset($_REQUEST["limit"])) { + $limit = 10; +} else { + $limit = $_REQUEST["limit"]; +} + +$smarty->assign_by_ref('limit', $limit); + +// Rankings: +// Top Pages +// Last pages +// Top Authors +$rankings = array(); + +$rk = $ranklib->$which($limit); +$rank["data"] = $rk["data"]; +$rank["title"] = $rk["title"]; +$rank["y"] = $rk["y"]; +$rankings[] = $rank; + +$smarty->assign_by_ref('rankings', $rankings); +$smarty->assign('rpage', 'rankings.php'); + + +// Display the template +$gBitSystem->display( 'bitpackage:kernel/ranking.tpl'); + +?> diff --git a/send_post.php b/send_post.php new file mode 100644 index 0000000..3abe52e --- /dev/null +++ b/send_post.php @@ -0,0 +1,120 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/send_post.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +$gBitSystem->verifyPermission( 'bit_p_read_blog' ); + +if (!isset($_REQUEST["post_id"])) { + $gBitSystem->fatalError( 'No post indicated' ); +} + +include_once( BLOGS_PKG_PATH.'lookup_post_inc.php' ); +$smarty->assign('post_info', $gContent->mInfo ); + +//Build absolute URI for this +$parts = parse_url($_SERVER['REQUEST_URI']); +$uri = httpPrefix(). $parts['path'] . '?blog_id=' . $gContent->mInfo['blog_id'] . '&post_id=' . $gContent->mInfo['post_id']; +$uri2 = httpPrefix(). $parts['path'] . '/' . $gContent->mInfo['blog_id'] . '/' . $gContent->mInfo['post_id']; +$smarty->assign('uri', $uri); +$smarty->assign('uri2', $uri2); + +$smarty->assign( 'parsed_data', $gContent->parseData() ); + +$smarty->assign('individual', 'n'); + +if ($gBitUser->object_has_one_permission($gContent->mInfo["blog_id"], 'blog')) { + $smarty->assign('individual', 'y'); + + if (!$gBitUser->isAdmin()) { + // Now get all the permissions that are set for this content type + $perms = $gBitUser->getPermissions('', 'blogs'); + foreach( array_keys( $perms ) as $permName ) { + if ($gBitUser->object_has_permission( $user, $_REQUEST["blog_id"], 'blog', $permName ) ) { + $$permName = 'y'; + $smarty->assign( $permName, 'y'); + } else { + $$permName = 'n'; + $smarty->assign( $permName, 'n'); + } + } + } +} + +if ($gBitUser->hasPermission( 'bit_p_blog_admin' )) { + $bit_p_create_blogs = 'y'; + + $smarty->assign('bit_p_create_blogs', 'y'); + $bit_p_blog_post = 'y'; + $smarty->assign('bit_p_blog_post', 'y'); + $bit_p_read_blog = 'y'; + $smarty->assign('bit_p_read_blog', 'y'); +} + +$smarty->assign('ownsblog', $gContent->isBlogOwner() ); + +if ($feature_blogposts_comments == 'y') { + $maxComments = $gBitSystem->getPreference( 'blog_comments_per_page' ); + $comments_default_ordering = $blog_comments_default_ordering; + $comments_vars = array( + 'post_id', + 'offset', + 'find', + 'sort_mode' + ); + + $comments_prefix_var = 'post:'; + $comments_object_var = 'post_id'; + include_once ( LIBERTY_PKG_PATH.'comments_inc.php' ); +} + +$section = 'blogs'; + +if ($feature_theme_control == 'y') { + $cat_type = 'blog'; + + $cat_objid = $_REQUEST['blog_id']; + include( THEMES_PKG_PATH.'tc_inc.php' ); +} + +if (!isset($_REQUEST['addresses'])) { + $_REQUEST['addresses'] = ''; +} + +$smarty->assign('addresses', $_REQUEST['addresses']); +$smarty->assign('sent', 'n'); + +if (isset($_REQUEST['send'])) { + + $emails = explode(',', $_REQUEST['addresses']); + + $foo = parse_url($_SERVER["REQUEST_URI"]); + $machine = httpPrefix(). $gContent->getDisplayLink(); + + foreach ($emails as $email) { + $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]); + + $smarty->assign('mail_user', $gBitUser->getDisplayName() ); + $smarty->assign('mail_title', $gContent->mInfo['title'] ? $gContent->mInfo['title'] : date("d/m/Y [h:i]", $gContent->mInfo['created'])); + $smarty->assign('mail_machine', $machine); + $mail_data = $smarty->fetch('bitpackage:blogs/blogs_send_link.tpl'); + @mail($email, tra('Post recommendation at'). ' ' . $_SERVER["SERVER_NAME"], $mail_data, + "From: ".$gBitSystem->getPreference( 'sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n"); + } + + $smarty->assign('sent', 'y'); +} +$gBitSystem->setBrowserTitle("Send Blog Post: ".$gContent->mInfo['title']); + +// Display the template +$gBitSystem->display( 'bitpackage:blogs/send_blog_post.tpl'); + +?> diff --git a/templates/admin_blogs.tpl b/templates/admin_blogs.tpl new file mode 100644 index 0000000..9c9c460 --- /dev/null +++ b/templates/admin_blogs.tpl @@ -0,0 +1,148 @@ +{strip} +{form} + {jstabs} + {jstab title="Home Blog"} + {legend legend="Home Blog"} + <input type="hidden" name="page" value="{$page}" /> + <div class="row"> + {formlabel label="Home Blog (main blog)" for="homeBlog"} + {forminput} + <select name="homeBlog" id="homeBlog"> + {section name=ix loop=$blogs} + <option value="{$blogs[ix].blog_id|escape}" {if $blogs[ix].blog_id eq $home_blog}selected="selected"{/if}>{$blogs[ix].title|truncate:20:"...":true}</option> + {sectionelse} + <option>{tr}No records found{/tr}</option> + {/section} + </select> + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="homeTabSubmit" value="{tr}Change preferences{/tr}" /> + </div> + {/legend} + {/jstab} + + {jstab title="Blog Features"} + {legend legend="Blog Features"} + <input type="hidden" name="page" value="{$page}" /> + + {foreach from=$formBlogFeatures key=item item=output} + <div class="row"> + {formlabel label=`$output.label` for=$item} + {forminput} + {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item} + {formhelp note=`$output.help` page=`$output.page`} + {/forminput} + </div> + {/foreach} + + <div class="row"> + {formlabel label="Default ordering for blog listing" for="blog_list_order"} + {forminput} + <select name="blog_list_order" id="blog_list_order"> + <option value="created_desc" {if $blog_list_order eq 'created_desc'}selected="selected"{/if}>{tr}Creation date{/tr} ({tr}desc{/tr})</option> + <option value="last_modified_desc" {if $blog_list_order eq 'last_modified_desc'}selected="selected"{/if}>{tr}Last modification date{/tr} ({tr}desc{/tr})</option> + <option value="title_asc" {if $blog_list_order eq 'title_asc'}selected="selected"{/if}>{tr}Blog title{/tr} ({tr}asc{/tr})</option> + <option value="posts_desc" {if $blog_list_order eq 'posts_desc'}selected="selected"{/if}>{tr}Number of posts{/tr} ({tr}desc{/tr})</option> + <option value="hits_desc" {if $blog_list_order eq 'hits_desc'}selected="selected"{/if}>{tr}Visits{/tr} ({tr}desc{/tr})</option> + <option value="activity_desc" {if $blog_list_order eq 'activity_desc'}selected="selected"{/if}>{tr}Activity{/tr} ({tr}desc{/tr})</option> + </select> + {/forminput} + </div> + + <div class="row"> + {formlabel label="In blog listing show user as" for="blog_list_user_as"} + {forminput} + <select name="blog_list_user" id="blog_list_user_as"> + <option value="text" {if $blog_list_user eq 'text'}selected="selected"{/if}>{tr}Plain text{/tr}</option> + <option value="link" {if $blog_list_user eq 'link'}selected="selected"{/if}>{tr}Link to user information{/tr}</option> + <option value="avatar" {if $blog_list_user eq 'avatar'}selected="selected"{/if}>{tr}User avatar{/tr}</option> + </select> + {/forminput} + </div> + + {if $gBitSystemPrefs.package_categories eq 'y'} + <div class="row"> + {formlabel label="Use a category for posts" for="blog_categ"} + {forminput} + <input type="checkbox" name="blog_categ" id="blog_categ" + {if $blog_categ eq 'y'}checked="checked"{/if} /> + {/forminput} + </div> + + <div class="row"> + {formlabel label="Choose a parent category for blogs" for="blog_parent_categ"} + {forminput} + <select name="blog_parent_categ" id="blog_parent_categ"> + <option value="0" {if $blog_parent_categ eq '0'}selected="selected"{/if}>{tr}Top{/tr}</option> + {section name=i loop=$categs} + <option value="{$categs[i].category_id}"{if $blog_parent_categ eq $categs[i].category_id} selected="selected"{/if}>{$categs[i].name}</option> + {/section} + </select> + {/forminput} + </div> + {/if} + + <div class="row submit"> + <input type="submit" name="featuresTabSubmit" value="{tr}Change preferences{/tr}" /> + </div> + {/legend} + {/jstab} + + {jstab title="List Settings"} + {legend legend="List Settings"} + <input type="hidden" name="page" value="{$page}" /> + + {foreach from=$formBlogLists key=item item=output} + <div class="row"> + {formlabel label=`$output.label` for=$item} + {forminput} + {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item} + {formhelp note=`$output.help` page=`$output.page`} + {/forminput} + </div> + {/foreach} + + <div class="row submit"> + <input type="submit" name="listTabSubmit" value="{tr}Change preferences{/tr}" /> + </div> + {/legend} + {/jstab} + + {jstab title="Blog Comments Settings"} + {legend legend="Blog Comments Settings"} + <div class="row"> + {formlabel label="Post level comments" for="feature_blogposts_comments"} + {forminput} + <input type="checkbox" name="feature_blogposts_comments" id="feature_blogposts_comments" {if $gBitSystemPrefs.feature_blogposts_comments eq 'y'}checked="checked"{/if} /> + {/forminput} + </div> + + <div class="row"> + {formlabel label="Default number of comments per page" for="blog_comments_per_page"} + {forminput} + <input size="5" type="text" name="blog_comments_per_page" id="blog_comments_per_page" value="{$blog_comments_per_page|escape}" /> + {/forminput} + </div> + + <div class="row"> + {formlabel label="Comments default ordering" for="blog_comments_default_ordering"} + {forminput} + <select name="blog_comments_default_ordering" id="blog_comments_default_ordering"> + <option value="comment_date_desc" {if $blog_comments_default_ordering eq 'comment_date_desc'}selected="selected"{/if}>{tr}Newest first{/tr}</option> + <option value="comment_date_asc" {if $blog_comments_default_ordering eq 'comment_date_asc'}selected="selected"{/if}>{tr}Oldest first{/tr}</option> + <option value="points_desc" {if $blog_comments_default_ordering eq 'points_desc'}selected="selected"{/if}>{tr}Points{/tr}</option> + </select> + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="commentTabSubmit" value="{tr}Change preferences{/tr}" /> + </div> + {/legend} + {/jstab} + {/jstabs} +{/form} + +{/strip} diff --git a/templates/blog_header.tpl b/templates/blog_header.tpl new file mode 100644 index 0000000..92df1f3 --- /dev/null +++ b/templates/blog_header.tpl @@ -0,0 +1,31 @@ +<span class="blogtitle">{tr}Blog{/tr}: {$title}</span> +<div class="bloginfo"> +{tr}Created by{/tr} {displayname hash=$creator}{tr} on {/tr}{$created|bit_short_datetime}<br /> +{tr}Last modified{/tr} {$last_modified|bit_short_datetime}<br /><br /> +<table> +<tr> + <td> ({$posts} {tr}posts{/tr} | {$hits} {tr}visits{/tr} | {tr}Activity{/tr} {$activity|string_format:"%.2f"})</td> + <td> +{if $gBitUser->hasPermission( 'bit_p_blog_post' )} + {if ($gBitUser->mUserId and $creator eq $gBitUser->mUserId) or $gBitUser->hasPermission( 'bit_p_blog_admin' ) or $public eq 'y'} + <a title="{tr}post{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$blog_id}">{biticon ipackage=liberty iname="post" iexplain="post"}</a> + {/if} +{/if} +{if $gBitSystemPrefs.package_rss eq 'y' && $rss_blog eq 'y'} + <a title="{tr}RSS feed{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}rss.php?blog_id={$blog_id}">{biticon ipackage="rss" iname="rss" iexplain="RSS feed"}</a> +{/if} +{if ($gBitUser->isRegistered() and $creator eq $gBitUser->mUserId) or $gBitUser->hasPermission( 'bit_p_blog_admin' )} + <a title="{tr}Edit blog{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}edit.php?blog_id={$blog_id}">{biticon ipackage=liberty iname="edit" iexplain="edit"}</a> +{/if} +{if $gBitUser->isRegistered() and $gBitSystemPrefs.feature_user_watches eq 'y'} + {if $user_watching_blog eq "n"} + <a title="{tr}monitor this blog{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$blog_id}&watch_event=blog_post&watch_object={$blog_id}&watch_action=add">{biticon ipackage="users" iname="watch" iexplain="monitor this blog"}</a> + {else}<a title="{tr}stop monitoring this blog{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$blog_id}&watch_event=blog_post&watch_object={$blog_id}&watch_action=remove">{biticon ipackage="users" iname="unwatch" iexplain="stop monitoring this blog"}</a> + {/if} +{/if} + </td> +</tr> +</table> +</div> + +<div class="blogdesc">{tr}Description:{/tr} {$description}</div> diff --git a/templates/blog_list_post.tpl b/templates/blog_list_post.tpl new file mode 100644 index 0000000..6dc9613 --- /dev/null +++ b/templates/blog_list_post.tpl @@ -0,0 +1,73 @@ +{strip} + +<div class="post" + {if $user_dbl eq 'y' and (($blogPosts[ix].ownsblog eq 'y') or ($gBitUser->mUserId and $blogPosts[ix].user_id eq $gBitUser->mUserId) or $gBitUser->hasPermission( 'bit_p_blog_admin' ))} + ondblclick="location.href='{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$blogPosts[ix].blog_id}{$blog_id}&post_id={$blogPosts[ix].post_id}{$post_id}';" + {/if} +> + {if $gBitUser->hasPermission( 'bit_p_view_tabs_and_tools' )} + <div class="floaticon"> + {if $gBitSystemPrefs.package_rss eq 'y' && $gBitSystemPrefs.rss_blogs eq 'y'} + <a href="{$gBitLoc.BLOGS_PKG_URL}blogs_rss.php?blog_id={$blogPosts[ix].blog_id}">{biticon ipackage=rss iname=rss iexplain="rss feed"}</a> + {/if} + {if ($blogPosts[ix].ownsblog eq 'y') or ($gBitUser->mUserId and $blogPosts[ix].user_id eq $gBitUser->mUserId) or $gBitUser->hasPermission( 'bit_p_blog_admin' )} + <a title="{tr}Edit{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$blogPosts[ix].blog_id}&post_id={$blogPosts[ix].post_id}">{biticon ipackage=liberty iname="edit" iexplain="edit"}</a> + <a title="{tr}Remove{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$blogPosts[ix].blog_id}&remove={$blogPosts[ix].post_id}">{biticon ipackage=liberty iname="delete" iexplain="delete"}</a> + {/if} + + {**====== NOTEPAD PACKAGE CHECK IS BROKEN + {if $gBitUser->mUserId and $gBitSystemPrefs.package_notepad eq 'y' and $gBitUser->hasPermission( 'bit_p_notepad' )} + <a title="{tr}Save to notepad{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$blogPosts[ix].blog_id}&savenotepad={$blogPosts[ix].post_id}">{biticon ipackage=liberty iname="save" iexplain="save"}</a> + {/if} + ========= NOTEPAD PACKAGE CHECK IS BROKEN **} + + <a title="{tr}print{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}print_blog_post.php?post_id={$blogPosts[ix].post_id}">{biticon ipackage=liberty iname="print" iexplain="print"}</a> + <a title="{tr}email this post{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}send_post.php?post_id={$blogPosts[ix].post_id}">{biticon ipackage=liberty iname="mail_send" iexplain="email this post"}</a> + </div> + {/if} + + <div class="header"> + {if $blogPosts[ix].title} + <h1>{$blogPosts[ix].title}</h1> + {else} + <h1>{$blogPosts[ix].created|bit_long_date}</h1> + {/if} + + <div class="date"> + {if $gBitSystem->isPackageActive( 'categories' )} + {assign var=cats value=$blogPosts[ix].categs} + {include file="bitpackage:categories/categories_nav.tpl"} + {/if} + + {if $showBlogTitle}{displayname hash=$blogPosts[ix]} {tr}in{/tr} <a href="{$blogPosts[ix].blog_url}">{$blogPosts[ix].blogtitle}</a>{/if}<br /> + {$blogPosts[ix].created|bit_long_date} + </div> + </div> + + <div class="body"> + <div class="content"> + {if $blogPosts[ix].avatar}<img src="{$blogPosts[ix].avatar}" class="avatar" />{/if} + {$blogPosts[ix].parsed_data} + <p> + {tr}Posted on {$blogPosts[ix].created|bit_long_datetime}{/tr} + </p> + </div> <!-- end .content --> + + {if $blogPosts[ix].pages > 1} + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$blogPosts[ix].blog_id}&post_id={$blogPosts[ix].post_id}">{tr}read more{/tr} ({$blogPosts[ix].pages} {tr}pages{/tr})</a> + {/if} + </div> <!-- end .body --> + + <div class="footer"> + <a href="{$blogPosts[ix].post_url}">{tr}Permalink{/tr}</a> + + {if $blogPosts[ix].trackbacks_from_count}({tr}referenced by{/tr}: {$blogPosts[ix].trackbacks_from_count} {tr}posts{/tr} / {tr}references{/tr}: {$blogPosts[ix].trackbacks_to_count} {tr}posts{/tr}){/if} + + {if $blogPosts[ix].allow_comments eq 'y' and $gBitSystemPrefs.feature_blogposts_comments eq 'y'} + {$blogPosts[ix].num_comments} {if $blogPosts[ix].num_comments == 1} {tr}comment{/tr} {else} {tr}comments{/tr}{/if} | + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?find={$find}&blog_id={$blogPosts[ix].blog_id}&offset={$offset}&sort_mode={$sort_mode}&post_id={$blogPosts[ix].post_id}&post_comment_request=1">{if $blogPosts[ix].num_comments > 0}{tr}view comments{/tr}{else}{tr}add comment{/tr}{/if}</a> + {/if} + </div> <!-- end .footer --> +</div> <!-- end .blog --> + +{/strip} diff --git a/templates/blog_post.tpl b/templates/blog_post.tpl new file mode 100644 index 0000000..a7e7ac2 --- /dev/null +++ b/templates/blog_post.tpl @@ -0,0 +1,127 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/templates/blog_post.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{literal} +<script type="text/javascript"> +function confirmDelete(fileName, location) { + if (confirm("Are you sure you want to delete" + fileName + "?")) { + document.location = location; + } +} +</script> +{/literal} + +{strip} +<div class="edit blogs"> + <div class="header"> + <h1>{tr}Edit Post{/tr}</h1> + </div> + + <div class="body"> + {if $preview eq 'y'} + {include file="bitpackage:blogs/preview_post.tpl"} + {/if} + + {form enctype="multipart/form-data" name="blogpost" id="editpageform"} + <input type="hidden" name="post_id" value="{$post_id|escape}" /> + <input type="hidden" name="blog_id" value="{$blog_id|escape}" /> + <input type="hidden" name="rows" value="{$rows}"/> + <input type="hidden" name="cols" value="{$cols}"/> + <input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /> + + {jstabs} + {jstab title="Create Blog Post"} + {legend legend="Post to a Blog"} + {if $blogs} + <div class="row"> + {formlabel label="Blog" for="blog_id"} + {forminput} + <select name="blog_id" id="blog_id"> + {section name=ix loop=$blogs} + <option value="{$blogs[ix].blog_id|escape}" {if $blogs[ix].blog_id eq $blog_id}selected="selected"{/if}>{$blogs[ix].title}</option> + {/section} + </select> + {/forminput} + </div> + {/if} + + {if !$blog_data.use_title OR $blog_data.use_title eq 'y'} + <div class="row"> + {formlabel label="Title" for="title"} + {forminput} + <input type="text" size="60" name="title" id="title" value="{$title|escape}" /> + {/forminput} + </div> + {/if} + + {if $gBitSystem->isPackageActive( 'smileys' )} + {include file="bitpackage:smileys/smileys_full.tpl"} + {/if} + + {if $gBitSystem->isPackageActive( 'quicktags' ) eq 'y'} + {include file="bitpackage:quicktags/quicktags_full.tpl"} + {/if} + + <div class="row"> + {forminput} + <textarea id="{$textarea_id}" name="edit" rows="{$rows|default:20}" cols="{$cols|default:80}">{$data}</textarea> + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="preview" value="{tr}Preview{/tr}" /> + <input type="submit" name="save_post_exit" value="{tr}Save{/tr}" /> + </div> + {/legend} + {/jstab} + + {if $gBitSystem->isPackageActive( 'categories' )} + {jstab title="Categorize"} + {legend legend="Categorize"} + {include file="bitpackage:categories/categorize.tpl"} + {/legend} + {/jstab} + {/if} + + {jstab title="Attachments"} + {legend legend="Attachments"} + {include file="bitpackage:liberty/edit_storage.tpl"} + {/legend} + {/jstab} + + {jstab title="Advanced Options"} + {legend legend="Advanced Options"} + {include file="bitpackage:liberty/edit_format.tpl"} + + <div class="row"> + {formlabel label="Send trackback pings" for="trackback"} + {forminput} + <textarea name="trackback" id="trackback" rows="3" cols="60">{section name=ix loop=$trackbacks_to}{if not $smarty.section.ix.first},{/if}{$trackbacks_to[ix]}{/section}</textarea> + {formhelp note="Insert a comma separated list of URIs to send blogs."} + {/forminput} + </div> + {/legend} + {/jstab} + {/jstabs} + {/form} + + {if count($post_images) > 0} + <table class="data"> + <tr> + <th>Filename</th><th>Link</th><th>Actions</th> + </tr> + {foreach key=attachmentId from=$post_images item=storage} + <tr class="{cycle values="odd,even"}"> + <td align="center">{if $storage.thumbnail_url.small}<img src="{$storage.thumbnail_url.small}" /><br/>{/if}{$storage.filename}</td> + <td>{$storage.wiki_plugin_link|escape}</td> + <td align="right"><a href="javascript:confirmDelete('Delete {$storage.filename}?','{$gBitLoc.BLOGS_PKG_URL}post.php?post_id={$post_id}&remove_image={$attachmentId}')">{biticon ipackage=liberty iname=delete iexplain="remove"}</a></td> + </tr> + {/foreach} + <tr> + <td colspan="3">Copy the links listed above into the text field to display the images in your blog post</td> + </tr> + </table> + {/if} + </div><!-- end .body --> +</div><!-- end .blogs --> +{/strip} + +{include file="bitpackage:liberty/edit_help.tpl"} diff --git a/templates/blogs_send_link.tpl b/templates/blogs_send_link.tpl new file mode 100644 index 0000000..5f30d25 --- /dev/null +++ b/templates/blogs_send_link.tpl @@ -0,0 +1,6 @@ +{tr}Hi, + +{$mail_user} has sent you this link:{/tr} + +{tr}Blog post:{/tr} {$post_info.title} +{tr}at:{/tr} {$mail_machine} diff --git a/templates/center_list_blog_posts.php b/templates/center_list_blog_posts.php new file mode 100644 index 0000000..c76109f --- /dev/null +++ b/templates/center_list_blog_posts.php @@ -0,0 +1,93 @@ +<?php + +global $smarty, $gBlog, $gBitSystem, $categlib, $_REQUEST, $maxRecords, $gQueryUserId, $package_categories; +$postRecords = ( $module_rows ? $module_rows : $maxRecords ); + +if (defined("CATEGORIES_PKG_PATH")) { + include_once( CATEGORIES_PKG_PATH.'categ_lib.php'); +} +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); +require_once( USERS_PKG_PATH.'BitUser.php' ); + +if ($gBitSystem->isPackageActive( 'categories' )) { + if (isset($_REQUEST['addcateg']) and $_REQUEST['addcateg'] and isset($_REQUEST['post_id']) and $_REQUEST['post_id']) { + $categlib->categorize_blog_post($_REQUEST['post_id'],$_REQUEST['addcateg'],true); + } elseif (isset($_REQUEST['delcategs']) and isset($_REQUEST['post_id']) and $_REQUEST['post_id']) { + $categlib->uncategorize('blogpost',$_REQUEST['post_id']); + } + $categs = $categlib->list_all_categories(0, -1, 'name_asc', '', '', 0); + $smarty->assign('categs',$categs['data']); + $smarty->assign('page','view.php'); + $choosecateg = str_replace('"',"'",$smarty->fetch('bitpackage:blogs/popup_categs.tpl')); + $smarty->assign('choosecateg',$choosecateg); +} + +if ( empty( $_REQUEST["sort_mode"] ) ) { + $sort_mode = 'created_desc'; +} else { + $sort_mode = $_REQUEST["sort_mode"]; +} + +$smarty->assign_by_ref('sort_mode', $sort_mode); + +// If offset is set use it if not then use offset =0 +// use the maxRecords php variable to set the limit +// if sortMode is not set then use last_modified_desc +if (!isset($_REQUEST["offset"])) { + $offset = 0; +} else { + $offset = $_REQUEST["offset"]; +} + +if (isset($_REQUEST['page'])) { + $page = $_REQUEST['page']; + $offset = ($page - 1) * $postRecords; +} + +$smarty->assign_by_ref('offset', $offset); + +if (isset($_REQUEST["find"])) { + $find = $_REQUEST["find"]; +} else { + $find = ''; +} +$smarty->assign('find', $find); + +$smarty->assign('showBlogTitle', 'y'); + +$listHash['max_records'] = $postRecords; +$listHash['parse_data'] = TRUE; +$listHash['load_comments'] = TRUE; +// Get a list of last changes to the Wiki database +if ($gQueryUserId) { + $listHash['user_id'] = $gQueryUserId; +} elseif( $_REQUEST['user_id'] ) { + $listHash['user_id'] = $_REQUEST['user_id']; +} + +$blogPost = new BitBlogPost(); +$blogPosts = $blogPost->getList( $listHash ); + +// If there're more records then assign next_offset +$cant_pages = ceil($blogPosts["cant"] / $postRecords); +$smarty->assign_by_ref('cant_pages', $cant_pages); +$smarty->assign('actual_page', 1 + ($offset / $postRecords)); + +if ($blogPosts["cant"] > ($offset + $postRecords)) { + $smarty->assign('next_offset', $offset + $postRecords); +} else { + $smarty->assign('next_offset', -1); +} + +// If offset is > 0 then prev_offset +if ($offset > 0) { + $smarty->assign('prev_offset', $offset - $postRecords); +} else { + $smarty->assign('prev_offset', -1); +} + +$smarty->assign_by_ref('blogPosts', $blogPosts["data"]); +//print_r($blogPosts["data"]); + + +?> diff --git a/templates/center_list_blog_posts.tpl b/templates/center_list_blog_posts.tpl new file mode 100644 index 0000000..2764fb6 --- /dev/null +++ b/templates/center_list_blog_posts.tpl @@ -0,0 +1,24 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/templates/center_list_blog_posts.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{if $blogPosts || $showEmpty} +<div class="floaticon">{bithelp}</div> + +<div class="display blogs"> + <div class="header"> + <h1>{tr}Recent Blog Posts{/tr}</h1> + </div> + + <div class="body"> + {section name=ix loop=$blogPosts} + {include file="bitpackage:blogs/blog_list_post.tpl"} + {sectionelse} + <div class="body"> + <div class="norecords">{tr}No records found{/tr}</div> + </div> + {/section} + </div> + + {pagination url="`$gBitLoc.BLOGS_PKG_URL`index.php" user_id="`$gQueryUserId`"} + + {*minifind sort_mode=$sort_mode*} +</div> +{/if}
\ No newline at end of file diff --git a/templates/edit_blog.tpl b/templates/edit_blog.tpl new file mode 100644 index 0000000..93680ac --- /dev/null +++ b/templates/edit_blog.tpl @@ -0,0 +1,108 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/templates/edit_blog.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +{strip} + +<div class="floaticon">{bithelp}</div> + +<div class="edit blogs"> + <div class="header"> + <h1>{tr}Create or Edit Blog{/tr}</h1> + </div> + + <div class="body"> + {if strlen($heading) > 0} + <div class="preview"> + <div class="heading"> + <h2>{$description}</h2> + </div> + <div class="introduction"> + {eval var=$heading} + </div> + </div> + {/if} + + {if $individual eq 'y'} + {formfeedback warning="<a href='`$gBitLoc.KERNEL_PKG_URL`object_permissions.php?objectName=blog%20`$title`&object_type=blog&permType=blogs&object_id=`$blog_id`'>There are individual permissions set for this blog</a>" position="top"} + {/if} + + {form ipackage="blogs" ifile="edit.php"} + {jstabs} + {jstab title="Edit/Create Blog"} + {legend legend="Edit Blog"} + <input type="hidden" name="blog_id" value="{$blog_id|escape}" /> + <div class="row"> + {formfeedback warning=$warning} + {formlabel label="Title" for="title"} + {forminput} + <input type="text" name="title" id="title" value="{if $title}{$title|escape}{else}{displayname hash=$gBitUser->mInfo nolink=FALSE}'s Blog{/if}" /> + {/forminput} + </div> + + <div class="row"> + {formlabel label="Description" for="description"} + {forminput} + <textarea name="description" id="description" rows="2" cols="40">{$description|escape}</textarea> + {formhelp note=''} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Number of posts to show" for="max_posts"} + {forminput} + <input type="text" name="max_posts" id="max_posts" value="{$max_posts|escape|default:10}" /> + {formhelp note='Enter the number of blog posts you wish to display when viewing this blog.'} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Allow other user to post in this blog" for="public"} + {forminput} + <input type="checkbox" name="public" id="public" {if $public eq 'y'}checked="checked"{/if} /> + {formhelp note=''} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Use titles in blog posts" for="use_title"} + {forminput} + <input type="checkbox" name="use_title" id="use_title" {if !$use_title || $use_title eq 'y'}checked="checked"{/if} /> + {formhelp note='If this is not seelcted, the time and date of when the post was created will be displayed instead of the post title.'} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Allow search" for="use_find"} + {forminput} + <input type="checkbox" name="use_find" id="use_find" {if !$use_find || $use_find eq 'y'}checked="checked"{/if} /> + {formhelp note='Allow userers to search this blog for occurances of words.'} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Allow comments" for="allow_comments"} + {forminput} + <input type="checkbox" name="allow_comments" id="allow_comments" {if !$allow_comments || $allow_comments eq 'y'}checked="checked"{/if} /> + {formhelp note='Are other users allowed to add comments to posts made in this blog?'} + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="preview" value="{tr}preview{/tr}" /> + <input type="submit" name="save_blog" value="{tr}save{/tr}" /> + </div> + {/legend} + {/jstab} + + {if $gBitSystemPrefs.package_categories eq 'y'} + {jstab title="Categorize"} + {legend legend="Categorize"} + {include file="bitpackage:categories/categorize.tpl"} + {/legend} + {/jstab} + {/if} + {/jstabs} + {/form} + + </div><!-- end .body --> +</div><!-- end .blog --> + +{/strip} diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 0000000..3e305fe --- /dev/null +++ b/templates/index.php @@ -0,0 +1,6 @@ +<?php + + // This is not a package. + header ("location: ../index.php"); + +?>
\ No newline at end of file diff --git a/templates/list_blogs.tpl b/templates/list_blogs.tpl new file mode 100644 index 0000000..ad58fc1 --- /dev/null +++ b/templates/list_blogs.tpl @@ -0,0 +1,124 @@ +{strip} + +<div class="floaticon">{bithelp}</div> + +<div class="listing blogs"> + <div class="header"> + <h1>{tr}Blogs{/tr}</h1> + </div> + + <div class="body"> + <div class="navbar"> + <ul> + <li>{biticon ipackage=liberty iname=sort iexplain="sort by"}</li> + {if $blog_list_title eq 'y'} + <li>{smartlink ititle="Title" isort="title" offset=$offset}</li> + {/if} + {if $blog_list_created eq 'y'} + <li>{smartlink ititle="Created" isort="created" iorder=desc offset=$offset}</li> + {/if} + {if $blog_list_lastmodif eq 'y'} + <li>{smartlink ititle="Last Modified" isort="last_modified" iorder=desc idefault=1 offset=$offset}</li> + {/if} + {if $blog_list_user eq 'y'} + <li>{smartlink ititle="Creator" isort="user" offset=$offset}</li> + {/if} + {if $blog_list_posts eq 'y'} + <li>{smartlink ititle="Posts" isort="posts" iorder=desc offset=$offset}</li> + {/if} + {if $blog_list_visits eq 'y'} + <li>{smartlink ititle="Visits" isort="hits" iorder=desc offset=$offset}</li> + {/if} + {if $blog_list_activity eq 'y'} + <li>{smartlink ititle="Activity" isort="activity" iorder=desc offset=$offset}</li> + {/if} + </ul> + </div> + + <div class="clear"></div> + + <ul class="data"> + {section name=changes loop=$listpages} + <li class="item {cycle values='odd,even'}"> + <div class="floaticon"> + {if $gBitUser->hasPermission( 'bit_p_blog_post' )} + {if ($gBitUser->isAdmin()) or ($listpages[changes].individual eq 'n') or ($listpages[changes].individual_gBitUser->hasPermission( 'bit_p_blog_post' ))} + {if ($gBitUser->mUserId and $listpages[changes].user_id eq $gBitUser->mUserId) or ($gBitUser->hasPermission( 'bit_p_blog_admin' )) or ($listpages[changes].public eq 'y')} + <a title="{tr}post{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$listpages[changes].blog_id}">{biticon ipackage=liberty iname="edit" iexplain="post"}</a> + {/if} + {/if} + {/if} + {if ($gBitUser->mUserId and $listpages[changes].user_id eq $gBitUser->mUserId) or ($gBitUser->hasPermission( 'bit_p_blog_admin' ))} + {if ($gBitUser->isAdmin()) or ($listpages[changes].individual eq 'n') or ($listpages[changes].individual_gBitUser->hasPermission( 'bit_p_blog_create_blog' ))} + <a title="{tr}edit{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}edit.php?blog_id={$listpages[changes].blog_id}">{biticon ipackage=liberty iname="config" iexplain="configure"}</a> + {/if} + {/if} + {if ($gBitUser->mUserId and $listpages[changes].user_id eq $gBitUser->mUserId) or ($gBitUser->hasPermission( 'bit_p_blog_admin' ))} + {if ($gBitUser->isAdmin()) or ($listpages[changes].individual eq 'n') or ($listpages[changes].individual_gBitUser->hasPermission( 'bit_p_blog_create_blog' ))} + <a title="{tr}remove{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}list_blogs.php?offset={$offset}&sort_mode={$sort_mode}&remove={$listpages[changes].blog_id}">{biticon ipackage=liberty iname="delete" iexplain="delete"}</a> + {/if} + {/if} + {if $gBitUser->isAdmin()} + <a title="{tr}perms{/tr}" href="{$gBitLoc.KERNEL_PKG_URL}object_permissions.php?objectName=blog%20{$listpages[changes].title}&objectType=blog&permType=blogs&object_id={$listpages[changes].blog_id}">{if $listpages[changes].individual eq 'y'}{biticon ipackage=liberty iname="permissionsi_set" iexplain="set permissions"}{else}{biticon ipackage=liberty iname="permissions" iexplain="set permissions"}{/if}</a> + {/if} + </div> + + {if $blog_list_title eq 'y'} + <h2>{if ($gBitUser->isAdmin()) or ($listpages[changes].individual eq 'n') or ($listpages[changes].individual_gBitUser->hasPermission( 'bit_p_read_blog' ))}<a title="{$listpages[changes].title}" href="{$listpages[changes].blog_url}">{/if} + {$listpages[changes].title}{if ($gBitUser->isAdmin()) or ($listpages[changes].individual eq 'n') or ($listpages[changes].individual_gBitUser->hasPermission( 'bit_p_read_blog' ))}</a>{/if}</h2> + {/if} + + {if $blog_list_description eq 'y'} + <p>{$listpages[changes].description}</p> + {/if} + + <div class="date"> + {if $blog_list_user eq 'y'} + {if $blog_list_user eq 'link'} + {tr}Created by{/tr} {$listpages[changes].user|userlink} + {elseif $blog_list_user eq 'avatar'} + {$listpages[changes].user|avatarize} + {else} + {tr}Created by{/tr} {$listpages[changes].user} + {/if} + {/if} + + {if $blog_list_created eq 'y'} + <br />{tr}Created on{/tr} {$listpages[changes].created|bit_short_date} + {/if} + + {if $blog_list_lastmodif eq 'y'} + <br />{tr}Last Modified{/tr} {$listpages[changes].last_modified|bit_short_datetime} + {/if} + </div> + + <div class="footer"> + {if $blog_list_posts eq 'y'} + {tr}Posts{/tr}: {$listpages[changes].posts} • + {/if} + + {if $blog_list_visits eq 'y'} + {tr}Visits{/tr}: {$listpages[changes].hits} • + {/if} + + {if $blog_list_activity eq 'y'} + {tr}Activity{/tr}: {$listpages[changes].activity|default:0} + {/if} + </div> + + <div class="clear"></div> + <li> + {sectionelse} + <li class="item norecords"> + {tr}No records found{/tr} + </li> + {/section} + </ul> + </div><!-- end .body --> + + {pagination} + + {minifind sort_mode=$sort_mode} +</div><!-- end .blog --> + +{/strip} diff --git a/templates/list_posts.tpl b/templates/list_posts.tpl new file mode 100644 index 0000000..81b4176 --- /dev/null +++ b/templates/list_posts.tpl @@ -0,0 +1,17 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/templates/list_posts.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +<div class="floaticon">{bithelp}</div> + +<div class="listing blogs"> + <div class="header"><h1>{tr}Recent Blog Posts{/tr}</h1></div> + + <div class="body"> + {section name=ix loop=$blogPosts} + {include file="bitpackage:blogs/blog_list_post.tpl"} + <a href="{$blogPosts[ix].post_url}">{tr}read post{/tr}</a> + {sectionelse} + <div class="norecords">{tr}No records found{/tr}</div> + {/section} + </div> + + {pagination} +</div> diff --git a/templates/menu_blogs.tpl b/templates/menu_blogs.tpl new file mode 100644 index 0000000..a2b7556 --- /dev/null +++ b/templates/menu_blogs.tpl @@ -0,0 +1,14 @@ +{strip} +<ul> + {if $gBitUser->hasPermission( 'bit_p_read_blog' )} + <li><a class="item" href="{$gBitLoc.BLOGS_PKG_URL}index.php">{tr}Recent Posts{/tr}</a></li> + <li><a class="item" href="{$gBitLoc.BLOGS_PKG_URL}list_blogs.php">{tr}List Blogs{/tr}</a></li> + {/if}{if $gBitUser->hasPermission( 'bit_p_create_blogs' )} + <li><a class="item" href="{$gBitLoc.BLOGS_PKG_URL}edit.php">{tr}Create a Blog{/tr}</a></li> + {/if}{if $gBitUser->hasPermission( 'bit_p_blog_post' )} + <li><a class="item" href="{$gBitLoc.BLOGS_PKG_URL}post.php">{tr}Post to a Blog{/tr}</a></li> + {/if}{if $gBitSystemPrefs.feature_blog_rankings eq 'y' and $gBitUser->hasPermission( 'bit_p_read_blog' )} + <li><a class="item" href="{$gBitLoc.BLOGS_PKG_URL}rankings.php">{tr}Blog Rankings{/tr}</a></li> + {/if} +</ul> +{/strip} diff --git a/templates/menu_blogs_admin.tpl b/templates/menu_blogs_admin.tpl new file mode 100644 index 0000000..f3ccd02 --- /dev/null +++ b/templates/menu_blogs_admin.tpl @@ -0,0 +1 @@ +<ul><li><a class="item" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=blogs">{tr}Blogs Settings{/tr}</a></li></ul>
\ No newline at end of file diff --git a/templates/popup_categs.tpl b/templates/popup_categs.tpl new file mode 100644 index 0000000..e23afda --- /dev/null +++ b/templates/popup_categs.tpl @@ -0,0 +1,2 @@ +{section name=i loop=$categs}<div><a href="{$gBitLoc.BLOGS_PKG_URL}{$page}?blog_id=:::blogid:::&post_id=:::postid:::&addcateg={$categs[i].category_id}">{biticon ipackage=categories +iname=$categs[i].name|cat:'.png'}</a></div>{/section}<div><a href="{$gBitLoc.BLOGS_PKG_URL}{$page}?blog_id=:::blogid:::&post_id=:::postid:::&delcategs=1">{tr}Clear{/tr}</a></div> diff --git a/templates/preview_post.tpl b/templates/preview_post.tpl new file mode 100644 index 0000000..a6e4dd5 --- /dev/null +++ b/templates/preview_post.tpl @@ -0,0 +1,12 @@ +<h2>{tr}Preview{/tr}: {$page}</h2> +<div class="posthead"> +{if $blog_data.use_title eq 'y'} + {$title}<br /> + <small>{tr}posted by{/tr} {displayname hash=$gBitUser->mInfo} on {$created|bit_short_datetime}</small> +{else} + {$created|bit_short_datetime}<small>{tr}posted by{/tr} {displayname hash=$gBitUser}</small> +{/if} +</div> +<div class="postbody"> +{$parsed_data} +</div> diff --git a/templates/print_blog_post.tpl b/templates/print_blog_post.tpl new file mode 100644 index 0000000..0bc200f --- /dev/null +++ b/templates/print_blog_post.tpl @@ -0,0 +1,69 @@ +<html> +<head> +<title> +{if $post_info.use_title eq 'y'}{$post_info.title} {tr}posted by{/tr} {displayname hash=$post_info nolink=TRUE} on {$post_info.created|bit_short_datetime}{else}{$post_info.created|bit_short_datetime} {tr}posted by{/tr} {displayname hash=$post_info}{/if} +</title> +</head> +<style type="text/css"> +<!-- + +{literal} +body { margin : 5ex; } +a { color : black; text-decoration : none; } +a:hover { background-color : #deceae; } + +.head { border-bottom: 1px solid black; } +.title { font-size : larger; margin : 1ex 0; } +.postedby {font-size : smaller; font-style : italic; } + +.body { margin : 2ex;} + +.foot { border-top : 1px solid black; } +.permalink { } +.icon { border: 0px; } +{/literal} +--> +</style> + +<body> +<!-- +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> +<rdf:Description + rdf:about="{$uri}" + dc:identifer="{$uri}" + dc:title="{if $post_info.use_title eq 'y'}{$post_info.title} {tr}posted by{/tr} {$post_info.user} on {$post_info.created|bit_short_datetime}{else}{$post_info.created|bit_short_datetime} {tr}posted by{/tr} {$post_info.user}{/if}" + trackback:ping="{$uri2}" /> +</rdf:RDF> +--> + +<br /> + +<div class="head"> +{if $post_info.use_title eq 'y'} +<div>{$post_info.title}</div> +<div class="postedby">{tr}posted by{/tr} {displayname hash=$post_info} on {$post_info.created|bit_short_datetime}</div> +{else} +<div class="postedby">{$post_info.created|bit_short_datetime} {tr}posted by{/tr} {displayname hash=$post_info}</div> +{/if} +</div> +<div class="postbody"> +{$parsed_data} +<hr /> +<table> +<tr><td> +<a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$post_info.blog_id}&post_id={$post_info.post_id}">{tr}Permalink{/tr}</a> +({tr}referenced by{/tr}: {$post_info.trackbacks_from_count} {tr}posts{/tr} {tr}references{/tr}: {$post_info.trackbacks_to_count} {tr}posts{/tr}) +{if $post_info.allow_comments eq 'y' and $gBitSystemPrefs.feature_blogposts_comments eq 'y'} +{$post_info.num_comments} {tr}comments{/tr} + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?find={$find}&blog_id={$post_info.blog_id}&offset={$offset}&sort_mode={$sort_mode}&post_id={$post_info.post_id}">{tr}view comments{/tr}</a> +{/if} +</td><td> +<a title="{tr}print{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}print_blog_post.php?post_id={$post_info.post_id}">{biticon ipackage=liberty iname="print" iexplain="Print"}</a> +<a title="{tr}email this post{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}send_post.php?post_id={$post_info.post_id}">{biticon ipackage=liberty iname="mail_send" iexplain="Email"}</a> +</td></tr></table> +</div> + +</body> +</html> diff --git a/templates/send_blog_post.tpl b/templates/send_blog_post.tpl new file mode 100644 index 0000000..3c74003 --- /dev/null +++ b/templates/send_blog_post.tpl @@ -0,0 +1,34 @@ +<!-- +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> +<rdf:Description + rdf:about="{$uri}" + dc:identifer="{$uri}" + dc:title="{if $blog_data.use_title eq 'y'}{$post_info.title} {tr}posted by{/tr} {$post_info.user} on {$post_info.created|bit_short_datetime}{else}{$post_info.created|bit_short_datetime}{tr}posted by{/tr} {$post_info.user}{/if}" + trackback:ping="{$uri2}" /> +</rdf:RDF> +--> +<h2>{tr}Send blog post{/tr}</h2> +{if $sent eq 'y'} +<h3>{tr}A link to this post was sent to the following addresses:{/tr}</h3> +<div class="wikibody"> +{$addresses} +</div> +{else} + <h3>{tr}Send post to these addresses{/tr}</h3> + <form method="post" action="{$gBitLoc.BLOGS_PKG_URL}send_post.php"> + <input type="hidden" name="post_id" value="{$post_info.post_id}" /> + <table class="panel"> + <tr> + <td>{tr}List of email addresses separated by commas{/tr}</td> + <td><textarea cols="60" rows="5" name="addresses">{$addresses|escape}</textarea></td> + </tr> + <tr class="panelsubmitrow"> + <td colspan="2"><input type="submit" name="send" value="{tr}send{/tr}" /></td> + </tr> + </table> + </form> +{/if} + +{include file="bitpackage:blogs/view_blog_post.tpl"} diff --git a/templates/user_watch_blog_post.tpl b/templates/user_watch_blog_post.tpl new file mode 100644 index 0000000..96a6714 --- /dev/null +++ b/templates/user_watch_blog_post.tpl @@ -0,0 +1,8 @@ +{tr}New blog post: {$mail_title} by {$mail_user} at {$mail_date|bit_short_datetime}{/tr} + +{tr}View the blog at:{/tr} +{$mail_machine_raw}/{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$mail_blogid}&post_id={$mail_postid} + +{tr}If you don't want to receive these notifications follow this link:{/tr} +{$mail_machine_raw}/{$gBitLoc.USERS_PKG_URL}user_watches.php?hash={$mail_hash} + diff --git a/templates/view_blog.tpl b/templates/view_blog.tpl new file mode 100644 index 0000000..7cb165b --- /dev/null +++ b/templates/view_blog.tpl @@ -0,0 +1,55 @@ +{* $Header: /cvsroot/bitweaver/_bit_blogs/templates/view_blog.tpl,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ *} +<div class="display blogs"> +<div class="floaticon"> + {if $gBitUser->hasPermission( 'bit_p_blog_post' )} + {if ($gBitUser->mUserId and $creator eq $gBitUser->mUserId) or $gBitUser->hasPermission( 'bit_p_blog_admin' ) or $public eq 'y' or $bit_p_blog_post eq 'y'} + <a title="{tr}post{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$blog_id}">{biticon ipackage=liberty iname="post" iexplain="post"}</a> + {/if} + {/if} + + {if $gBitSystemPrefs.package_rss eq 'y' && $rss_blog eq 'y'} + <a title="{tr}RSS feed{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}blog_rss.php?blog_id={$blog_id}">{biticon ipackage="rss" iname="rss" iexplain="RSS feed"}</a> + {/if} + + {if ($gBitUser->mUserId and $creator eq $gBitUser->mUserId) or $gBitUser->hasPermission( 'bit_p_blog_admin' )} + <a title="{tr}Edit blog{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}edit.php?blog_id={$blog_id}">{biticon ipackage=liberty iname="config" iexplain="edit"}</a> + {/if} + + {if $gBitUser->isRegistered() and $gBitSystemPrefs.feature_user_watches eq 'y'} + {if $user_watching_blog eq 'n'} + <a title="{tr}monitor this blog{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$blog_id}&watch_event=blog_post&watch_object={$blog_id}&watch_action=add">{biticon ipackage="users" iname="watch" iexplain="monitor this blog"}</a> + {else} + <a title="{tr}stop monitoring this blog{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$blog_id}&watch_event=blog_post&watch_object={$blog_id}&watch_action=remove">{biticon ipackage="users" iname="unwatch" iexplain="stop monitoring this blog"}</a> + {/if} + {/if} +</div> + +<div class="header"> + <h1>{tr}Blog{/tr}: {$title}</h1> + {if $description}<h2>{tr}Description:{/tr} {$description}</h2>{/if} +{if strlen($heading) > 0} + <div class="introduction">{eval var=$heading}</div> +{else} + <div class="date"> + {tr}Created by{/tr} {displayname hash=$blog_data}{tr} on {/tr}{$created|bit_short_datetime}<br /> + {tr}Last modified{/tr} {$last_modified|bit_short_datetime} + </div> +{/if} +</div> + +<div class="footer"> + {$posts} {tr}posts{/tr} | {$hits} {tr}visits{/tr} | {tr}Activity{/tr} {$activity|string_format:"%.2f"} +</div> + + +{section name=ix loop=$blogPosts} + {include file="bitpackage:blogs/blog_list_post.tpl"} +{/section} + +{pagination blog_id=$blog_id} + +{if $use_find eq 'y'} + {minifind blog_id=$blog_id sort_mode=$sort_mode} +{/if} + +</div> {* end .blog *} diff --git a/templates/view_blog_post.tpl b/templates/view_blog_post.tpl new file mode 100644 index 0000000..e73a337 --- /dev/null +++ b/templates/view_blog_post.tpl @@ -0,0 +1,108 @@ +<!-- +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> +<rdf:Description + rdf:about="{$uri}" + dc:identifer="{$uri}" + dc:title="{if $post_info.use_title eq 'y'}{$post_info.title} {tr}posted by{/tr} {$post_info.user} on {$post_info.created|bit_short_datetime}{else}{$post_info.created|bit_short_datetime} {tr}posted by{/tr} {$post_info.user}{/if}" + trackback:ping="{$uri2}" /> +</rdf:RDF> +--> +<div class="display blogs"> + <div class="floaticon"> + {if ($ownsblog eq 'y') or $gBitUser->hasPermission( 'bit_p_blog_admin' )} + <a href="{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$post_info.blog_id}&post_id={$post_info.post_id}">{biticon ipackage=liberty iname="edit" iexplain="edit"}</a> + <a href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$post_info.blog_id}&remove={$post_info.post_id}">{biticon ipackage=liberty iname="delete" iexplain="delete"}</a> + {/if} + + {if $gBitSystem->isPackageActive( 'notepad' ) and $gBitUser->hasPermission( 'bit_p_notepad' )} + <a title="{tr}Save to notepad{/tr}" href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$smarty.request.blog_id}&post_id={$smarty.request.post_id}&savenotepad=1">{biticon ipackage=liberty iname="save" iexplain="save"}</a> + {/if} + {if $gBitUser->hasPermission( 'bit_p_print' )} + <a href="{$gBitLoc.BLOGS_PKG_URL}print_blog_post.php?post_id={$post_id}">{biticon ipackage=liberty iname="print" iexplain="print"}</a> + {/if} + <a href="{$gBitLoc.BLOGS_PKG_URL}send_post.php?post_id={$post_id}">{biticon ipackage=liberty iname="mail_send" iexplain="email this post"}</a> + </div> + + <div class="header"> + <h1> + {if $post_info.use_title eq 'y' && $post_info.title} + {$post_info.title} + {else} + {$post_info.created|bit_long_date} + {/if} + </h1> + {if $gBitSystem->isPackageActive( 'categories' )} + {include file="bitpackage:categories/categories_nav.tpl"} + {/if} + <div class="date"> + {$post_info.created|bit_long_date} + </div> + </div> + + <div class="body" + {if $user_dbl eq 'y' and (($ownsblog eq 'y') or $gBitUser->hasPermission( 'bit_p_blog_admin' ))} + ondblclick="location.href='{$gBitLoc.BLOGS_PKG_URL}post.php?blog_id={$post_info.blog_id}&post_id={$post_info.post_id}';" + {/if} + > + <div class="content"> + {$parsed_data} + <p> + {displayname hash=$post_info}<br /> + {tr}in{/tr} <a href="{$gBitLoc.BLOGS_PKG_URL}view.php?blog_id={$post_info.blog_id}">{$post_info.blogtitle}</a><br /> + {tr}Posted at{/tr} {$post_info.created|bit_long_time} + </p> + </div> <!-- end .content --> + </div> <!-- end .body --> + + <div class="footer"> + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?post_id={$post_id}">{tr}Permalink{/tr}</a> + {tr}referenced by{/tr} {$post_info.trackbacks_from_count} {tr}posts{/tr} | {tr}references{/tr} {$post_info.trackbacks_to_count} {tr}posts{/tr} + {if $post_info.allow_comments eq 'y' and $gBitSystemPrefs.feature_blogposts_comments eq 'y'} + | {$post_info.num_comments} {tr}comments{/tr} + + {/if} + </div> {* end .footer *} + + {if $pages > 1} + <div class="pagination"> + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$smarty.request.blog_id}&post_id={$smarty.request.post_id}&page={$first_page}">{biticon ipackage=liberty iname="nav_first" iexplain="first page"}</a> + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$smarty.request.blog_id}&post_id={$smarty.request.post_id}&page={$prev_page}">{biticon ipackage=liberty iname="nav_prev" iexplain="previous page"}</a> + {tr}page{/tr}:{$page}/{$pages} + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$smarty.request.blog_id}&post_id={$smarty.request.post_id}&page={$next_page}">{biticon ipackage=liberty iname="nav_next" iexplain="next page"}</a> + <a href="{$gBitLoc.BLOGS_PKG_URL}view_post.php?blog_id={$smarty.request.blog_id}&post_id={$smarty.request.post_id}&page={$last_page}">{biticon ipackage=liberty iname="nav_last" iexplain="last page"}</a> + </div> + {/if} + + {if $post_info.trackbacks_from_count > 0} + <h2>{tr}Trackback pings{/tr}:</h2> + <table> + <tr> + <th>{tr}Title{/tr}</th> + <th>{tr}URI{/tr}</th> + <th>{tr}Blog name{/tr}</th> + </tr> + {cycle values="even,odd" print=false} + {foreach from=$post_info.trackbacks_from key=key item=item} + <tr class="{cycle}"> + <td>{$item.title}</td> + <td><a href="{$key}" title="{$key}" class="external">{$key|truncate:"40"}</a></td> + <td>{$item.blog_name}</td> + </tr> + {/foreach} + </table> + {/if} + + {if $gBitSystem->isPackageActive( 'categories' )} + {include file="bitpackage:categories/categories_objects.tpl"} + {/if} +</div> {* end .blog *} + +{if $post_info.allow_comments eq 'y' and $gBitSystemPrefs.feature_blogposts_comments eq 'y'} +{if $gBitUser->hasPermission( 'bit_p_read_comments' )} + +{include file="bitpackage:liberty/comments.tpl"} + +{/if} +{/if} diff --git a/view.php b/view.php new file mode 100644 index 0000000..936d816 --- /dev/null +++ b/view.php @@ -0,0 +1,209 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/view.php,v 1.1 2005/06/19 03:57:41 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +$iPageTitle = 'test'; +// Initialization +require_once( '../bit_setup_inc.php' ); + +if (defined("CATEGORIES_PKG_PATH")) { + include_once( CATEGORIES_PKG_PATH.'categ_lib.php'); +} +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +$gBitSystem->verifyPackage( 'blogs' ); +$smarty->assign('showBlogTitle', 'y'); + +if (isset($_REQUEST['user_id']) && !isset($_REQUEST['blog_id'])) { + // We will try and grab the first blog owned by the user id given + $blogsList = $gBlog->list_user_blogs($_REQUEST['user_id']); + if (!empty($blogsList[0]['blog_id'])) { + $_REQUEST['blog_id'] = $blogsList[0]['blog_id']; + } +} + +if (!isset($_REQUEST["blog_id"])) { + $gBitSystem->fatalError( 'No blog indicated' ); +} + +$smarty->assign('individual', 'n'); + +if ($gBitUser->object_has_one_permission( $_REQUEST["blog_id"], $gBlog->getContentType() )) { + $smarty->assign('individual', 'y'); + + if (!$gBitUser->isAdmin()) { + // Now get all the permissions that are set for this type of permissions 'image gallery' + //$perms = $gBitUser->getPermissions('', BLOGS_PKG_NAME ); + $perms = $gBitSystem->getPermissionInfo(NULL, BLOGS_PKG_NAME); + + foreach ($perms as $perm_name => $permInfo) { + //$perm_name = $perm["perm_name"]; + + if ($gBitUser->object_has_permission( $gBitUser->mUserId, $_REQUEST["blog_id"], $gBlog->getContentType(), $perm_name ) ) { + $$perm_name = 'y'; + + $smarty->assign("$perm_name", 'y'); + } else { + $$perm_name = 'n'; + + $smarty->assign("$perm_name", 'n'); + } + } + } +} + +$gBitSystem->verifyPermission( 'bit_p_read_blog' ); + +if ($gBitSystem->isPackageActive( 'categories' )) { + if (isset($_REQUEST['addcateg']) and $_REQUEST['addcateg'] and isset($_REQUEST['post_id']) and $_REQUEST['post_id']) { + $categlib->categorize_blog_post($_REQUEST['post_id'],$_REQUEST['addcateg'],true); + } elseif (isset($_REQUEST['delcategs']) and isset($_REQUEST['post_id']) and $_REQUEST['post_id']) { + $categlib->uncategorize('blogpost',$_REQUEST['post_id']); + } + $categs = $categlib->list_all_categories(0, -1, 'name_asc', '', '', 0); + $smarty->assign('categs',$categs['data']); + $smarty->assign('page','view.php'); + $choosecateg = str_replace('"',"'",$smarty->fetch('bitpackage:blogs/popup_categs.tpl')); + $smarty->assign('choosecateg',$choosecateg); +} +$blog_data = $gBlog->get_blog($_REQUEST["blog_id"]); + +if( !empty( $blog_data['blog_style'] ) && $gBitSystem->getPreference('feature_user_theme') == 'h' ) { + $gBitSystem->setStyle( $blog_data['blog_style'] ); + $gBitLoc['styleSheet'] = $gBitSystem->getStyleCss( $blog_data['blog_style'], $blog_data['user_id'] ); + $smarty->assign( 'userStyle', $blog_data['blog_style'] ); +} + +$ownsblog = ($gBitUser->mUserId == $blog_data["user_id"] ) ? 'y' : 'n'; +$smarty->assign('ownsblog', $ownsblog); + +if (!$blog_data) { + $gBitSystem->fatalError( 'Blog not found' ); +} + +$gBlog->add_blog_hit($_REQUEST["blog_id"]); +$smarty->assign('blog_id', $_REQUEST["blog_id"]); +$smarty->assign('title', $blog_data["title"]); +$smarty->assign('heading', $blog_data["heading"]); +$smarty->assign('use_title', $blog_data["use_title"]); +$smarty->assign('use_find', $blog_data["use_find"]); +$smarty->assign('allow_comments', $blog_data["allow_comments"]); +$smarty->assign('description', $blog_data["description"]); +$smarty->assign('created', $blog_data["created"]); +$smarty->assign('last_modified', $blog_data["last_modified"]); +$smarty->assign('posts', $blog_data["posts"]); +$smarty->assign('public', $blog_data["public"]); +$smarty->assign('hits', $blog_data["hits"]); +$smarty->assign('creator', $blog_data["user_id"]); +$smarty->assign('activity', $blog_data["activity"]); +$smarty->assign('avatar', $blog_data["avatar"]); +$smarty->assign_by_ref('blog_data', $blog_data); + +if (isset($_REQUEST["remove"])) { + + $blogPost = new BitBlogPost( $_REQUEST["remove"] ); + if( $blogPost->load() ) { + if( !$ownsblog && !$gBitUser->mUserId || $blogPost->mInfo["user_id"] != $gBitUser->mUserId) { + $gBitSystem->verifyPermission( 'bit_p_blog_admin', "Permission denied you cannot remove this post" ); + } + + if( !empty( $_REQUEST['cancel'] ) ) { + // user cancelled - just continue on, doing nothing + } elseif( empty( $_REQUEST['confirm'] ) ) { + $formHash['remove'] = $_REQUEST['remove']; + $formHash['blog_id'] = $_REQUEST['blog_id']; + $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to remove post '.$_REQUEST['remove'].'?' ) ); + } else { + $blogPost->expunge(); + } + } +} + + +$now = date("U"); + +$blogPost = new BitBlogPost(); +$listHash['blog_id'] = $_REQUEST['blog_id']; +$listHash['parse_data'] = TRUE; +$listHash['max_records'] = $blog_data['max_posts']; +$listHash['load_num_comments'] = TRUE; +$blogPosts = $blogPost->getList( $listHash ); +//$blogPosts = $blogPost->getList($_REQUEST["blog_id"], $offset, $blog_data["max_posts"], $sort_mode, $find ); +if (!empty($_REQUEST['offset'])) { + $offset = $_REQUEST['offset']; +} else { + $offset = 0; +} +$cant_pages = ceil($blogPosts["cant"] / $blog_data["max_posts"]); +$smarty->assign_by_ref('cant_pages', $cant_pages); +$smarty->assign('actual_page', 1 + ($listHash['offset'] / $blog_data["max_posts"])); +$smarty->assign_by_ref('offset', $listHash['offset']); +$smarty->assign_by_ref('sort_mode', $listHash['sort_mode']); + +if ($blogPosts["cant"] > ($listHash['offset'] + $blog_data["max_posts"])) { + $smarty->assign('next_offset', $offset + $blog_data["max_posts"]); +} else { + $smarty->assign('next_offset', -1); +} + +// If offset is > 0 then prev_offset +if ($listHash['offset'] > 0) { + $smarty->assign('prev_offset', $offset - $blog_data["max_posts"]); +} else { + $smarty->assign('prev_offset', -1); +} + +// If there're more records then assign next_offset +$smarty->assign_by_ref('blogPosts', $blogPosts["data"]); +//print_r($blogPosts["data"]); + +if( $gBitSystem->isFeatureActive( 'feature_theme_control' ) ) { + $cat_type = 'blog'; + $cat_objid = $_REQUEST['blog_id']; + include( THEMES_PKG_PATH.'tc_inc.php' ); +} + +if( $gBitSystem->isPackageActive( 'notepad' ) && $gBitUser->hasPermission( 'bit_p_notepad' ) && isset($_REQUEST['savenotepad']) ) { + + $blogPost = new BitBlogPost( $_REQUEST['savenotepad'] ); + if( $blogPost->load() ) { + $gBitSystem->replace_note( $gBitUser->mUserId, 0, $blogPost->mInfo['title'] ? $blogPost->mInfo['title'] : date("d/m/Y [h:i]", $blogPost->mInfo['created']), $blogPost->mInfo['data']); + } +} + +if( $gBitSystem->isFeatureActive( 'feature_user_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->mInfo['title'], $blogPost->getDisplayLink() ); + } + } else { + $gBitUser->expungeWatch( $_REQUEST['watch_event'], $_REQUEST['watch_object'] ); + } + } + + $smarty->assign('user_watching_blog', 'n'); + + if ( $watch = $gBitUser->getEventWatches( $gBitUser->mUserId, 'blog_post', $_REQUEST['blog_id'])) { + $smarty->assign('user_watching_blog', 'y'); + } +} + +if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') { + include_once( HAWHAW_PKG_PATH.'hawtiki_lib.php' ); + + HAWBIT_view_blog($blogPosts, $blog_data); +} + + + +$gBitSystem->setBrowserTitle($blog_data['title']); +// Display the template +$gBitSystem->display( 'bitpackage:blogs/view_blog.tpl'); +?> diff --git a/view_post.php b/view_post.php new file mode 100644 index 0000000..12b127d --- /dev/null +++ b/view_post.php @@ -0,0 +1,28 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/view_post.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); +require_once( BLOGS_PKG_PATH.'BitBlogPost.php' ); + +if ( empty( $_REQUEST["post_id"] ) && empty( $_REQUEST["content_id"] ) ) { + $gBitSystem->fatalError( 'No post indicated' ); +} + +global $gContent; +$postId = !empty( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : NULL; +$conId = !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL; + +$gContent = new BitBlogPost( $postId, $conId ); +if( $gContent->load() ) { + include_once( BLOGS_PKG_PATH.'display_bitblogpost_inc.php' ); +} else { + $gBitSystem->fatalError( 'Post could not be found.' ); +} + +?> diff --git a/view_post_image.php b/view_post_image.php new file mode 100644 index 0000000..6f913e3 --- /dev/null +++ b/view_post_image.php @@ -0,0 +1,23 @@ +<?php + +// $Header: /cvsroot/bitweaver/_bit_blogs/view_post_image.php,v 1.1 2005/06/19 03:57:42 bitweaver Exp $ + +// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. +// All Rights Reserved. See copyright.txt for details and a complete list of authors. +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. + +// Initialization +require_once( '../bit_setup_inc.php' ); + +include_once( BLOGS_PKG_PATH.'BitBlog.php' ); + +if (!isset($_REQUEST["image_id"])) { + $smarty->assign('msg', tra("No image id given")); + $gBitSystem->display( 'error.tpl' ); + die; +} + +$imageInfo = $gBlog->getStorageFileInfo($_REQUEST["image_id"]); +$smarty->assign( 'imageInfo' , $imageInfo ); +$gBitSystem->display( 'bitpackage:blogs/view_post_image.tpl' ); +?> |
