Пример #1
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionAddcomment()
 {
     $this->layout = " ";
     $model = new BlogComment();
     $model->datetime = date('Y-m-d H:i:s');
     $model->name = $_REQUEST['name'];
     $model->comment = $_REQUEST['comment'];
     $model->blog_id = $_REQUEST['blog_id'];
     if ($model->save()) {
         $this->redirect(array('blog/view', 'id' => $_REQUEST['blog_id']));
     } else {
         print_r($model->getErrors());
     }
 }
Пример #2
0
 public function delete()
 {
     Context::get('db')->start_transaction();
     // delete blog comment
     BlogComment::neo()->where('blog_id = ?', $this->id)->delete();
     // delete blog
     parent::delete();
     Context::get('db')->commit();
 }
	public function testNotSpam()
	{
		$this->login('uberadmin');
		
		$this->request('admin/blog/comment/notspam', array('commentID' => '666',
		                                           'from' => 'blog/admin/comment/index/3'));

		$comment = BlogComment::get(666);
		$this->assertEquals(PropertySpamStatus::OK, $comment->spamStatus);
		$this->assertFlashNotice('Comment unmarked as spam');
		$this->assertRedirected('blog/admin/comment/index/3');
	}
Пример #4
0
 public function leave()
 {
     // get nickname to say good bye.
     $user = User::neo()->where(User::get_login_id())->find();
     // get all blog ids to delete comments
     $blogs = Blog::neo()->select('id')->where('user_id = ?', User::get_login_id())->find('all');
     $blog_ids = extract_property($blogs, 'id');
     // delete blog_comment, blog, and user
     Context::get('db')->start_transaction();
     BlogComment::neo()->where('blog_id ' . Query::id_condition($blog_ids))->delete();
     Blog::neo()->where('user_id = ?', User::get_login_id())->delete();
     User::neo()->where(User::get_login_id())->delete();
     Context::get('db')->commit();
     $user->logout();
     $this->redirect_to('/user/leave_success/' . $user->nickname);
 }
Пример #5
0

    case 'entries_set_online':
    case 'entries_set_offline':
    case 'entries_set_pending':
        $f_entries = Input::Get('f_entries', 'array');
        $status = substr($f_action, 12);

        foreach ($f_entries as $entry_id) {
            $BlogEntry = new BlogEntry($entry_id);
            $BlogEntry->setProperty('admin_status', $status);
        }
    break;

    case 'comments_set_online':
    case 'comments_set_offline':
    case 'comments_set_pending':
        $f_comments = Input::Get('f_comments', 'array');
        $status = substr($f_action, 13);

        foreach ($f_comments as $comment_id) {
            $BlogComment = new BlogComment($comment_id);
            $BlogComment->setProperty('admin_status', $status);
        }
    break;
}

// Need to exit to avoid output of the menue.
exit;
?>
Пример #6
0
    function delete()
    {
        $entry_id = $this->getProperty('entry_id');
        $blog_id = $this->getProperty('fk_blog_id');

        foreach (BlogComment::getComments(array('entry_id' => $this->getProperty('entry_id'))) as $Comment) {
            $Comment->delete();
        }

        parent::delete();
        BlogImageHelper::RemoveImageDerivates('entry', $entry_id);
        BlogentryTopic::OnBlogentryDelete($entry_id);
        Blog::TriggerCounters($blog_id);
        $CampCache = CampCache::singleton();
        $CampCache->clear('user');
    }
Пример #7
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      BlogComment $value A BlogComment object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(BlogComment $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #8
0
}

// Check permissions
if (!$g_user->hasPermission('plugin_blog_admin')) {
    camp_html_display_error(getGS('You do not have the right to manage blogs.'));
    exit;
}

$f_entry_id = Input::Get('f_entry_id', 'int');
$f_comment_id = Input::Get('f_comment_id', 'int');

if (!$f_comment_id) {
    $user_id = $g_user->getUserId();   
}

$BlogComment = new BlogComment($f_comment_id, $f_entry_id);

if ($BlogComment->store($is_admin, $user_id)) {
    camp_html_add_msg(getGS('Blog comment saved.'), 'ok');
    ?>
    <script language="javascript">
        window.opener.location.reload();
        window.close();
    </script>
    <?php
    exit();
}

?>
<head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
Пример #9
0
	/**
	 * Creates the list of objects. Sets the parameter $p_hasNextElements to
	 * true if this list is limited and elements still exist in the original
	 * list (from which this was truncated) after the last element of this
	 * list.
	 *
	 * @param int $p_start
	 * @param int $p_limit
	 * @param bool $p_hasNextElements
	 * @return array
	 */
	protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count)
	{
	    if (!defined('PLUGIN_BLOG_ADMIN_MODE')) {
    	    $operator = new Operator('is', 'integer');
    	    $context = CampTemplate::singleton()->context();
    	    
    	    if (!$p_parameters['ignore_status']) {
    	        $comparisonOperation = new ComparisonOperation('status', $operator, 'online');
    	        $this->m_constraints[] = $comparisonOperation; 
    	    }
    	    if (!$p_parameters['ignore_admin_status']) {
    	        $comparisonOperation = new ComparisonOperation('admin_status', $operator, 'online');
    	        $this->m_constraints[] = $comparisonOperation; 
    	    }
    	    if ($context->blogentry->defined && !$p_parameters['ignore_blogentry']) {
        	    $comparisonOperation = new ComparisonOperation('entry_id', $operator, $context->blogentry->identifier);
                $this->m_constraints[] = $comparisonOperation;
    	    } elseif ($context->blog->defined && !$p_parameters['ignore_blog']) {
        	    $comparisonOperation = new ComparisonOperation('blog_id', $operator, $context->blog->identifier);
                $this->m_constraints[] = $comparisonOperation;
    	    }
    	    if ($context->language->defined && $p_parameters['ignore_language']) {
        	    $comparisonOperation = new ComparisonOperation('language_id', $operator, $context->language->number);
                $this->m_constraints[] = $comparisonOperation;
    	    }
	    }
	    
	    $BlogCommentsList = BlogComment::GetList($this->m_constraints, $this->m_order, $p_start, $p_limit, $p_count);
        $metaBlogCommentsList = array();
	    foreach ($BlogCommentsList as $blogComment) {
	        $metaBlogCommentsList[] = new MetaBlogComment($blogComment->getId());
	    }
	    return $metaBlogCommentsList;
	}
Пример #10
0
					<?php 
echo $blog->content;
?>
					<br>
					<div id="wrapper-tags">
					Tags : <?php 
echo str_replace(",", ", ", $blog->tags);
?>

					</div>
				</div>
				<div id="wrapper-right-side"></div>
				<div id="komentar">
					<div id="list-komentar">
						<?php 
foreach (BlogComment::model()->findAll("blog_id = {$_REQUEST['id']}") as $key) {
    ?>
						
						<div class="user-comment">
							<!-- <div style="height:100%"> -->
								<div class="wrap-user-name">
									<?php 
    $id = $key->name;
    $img = User::model()->find("username='******'")->id . ".jpg";
    $filename = Yii::app()->basePath . "/../img/blog/" . $img;
    if (!file_exists($filename)) {
        $img = "notfound.jpg";
    }
    ?>
									<img  src="<?php 
    echo Yii::app()->request->baseUrl;
Пример #11
0
 public function createPostsWithComments($postsCount, $commentsCount)
 {
     $userId = 2;
     for ($i = 1; $i <= $postsCount; $i++) {
         $post = BlogPost::create(['userId' => $userId, 'title' => "Post {$i}", 'message' => "This is a message {$i}!", 'createdAt' => time() + $i]);
         for ($j = 1; $j <= $commentsCount; $j++) {
             $comment = BlogComment::create(['userId' => $userId, 'blogPostId' => $post->id, 'title' => "Comment {$j} to post {$i}", 'message' => "This is a comment message {$i}:{$j}!", 'createdAt' => time() + $j]);
         }
     }
 }
Пример #12
0
 public function createUsersWithAsocs($count)
 {
     for ($i = 1; $i <= $count; $i++) {
         $user = User::create(['login' => 'login_' . $i, 'password' => 'password_' . $i, 'email' => 'email_' . $i . '@example.com']);
         $profile = Profile::create(['userId' => $user->id, 'sign' => 'signature of user ' . $user->id]);
         for ($j = 1; $j <= $count; $j++) {
             $relation = UserAndGroupRelation::create(['userId' => $user->id, 'groupId' => $j]);
             $post = BlogPost::create(['userId' => $user->id, 'title' => "Post {$i}", 'message' => "This is a message {$i}!", 'createdAt' => time() + $i]);
             for ($k = 1; $k <= $count; $k++) {
                 $comment = BlogComment::create(['userId' => $user->id, 'blogPostId' => $post->id, 'title' => "Comment {$j} to post {$i}", 'message' => "This is a comment message {$i}:{$j}!", 'createdAt' => time() + $j]);
             }
         }
     }
 }
Пример #13
0
 public function displayPost()
 {
     $id_lang = $this->context->language->id;
     $id_shop = $this->context->shop->id;
     if (is_null($this->id_post) || !is_numeric($this->id_post)) {
         return $this->displayList();
     }
     $post = new BlogPost($this->id_post);
     if ($post->status == 'published' && $post->isAssociatedToShop($id_shop)) {
         //comment submit
         if (Tools::isSubmit('submitMessage') && $this->conf['comment_active'] && $post->allow_comments) {
             $comment = new BlogComment();
             try {
                 $message = trim(strip_tags(Tools::getValue('blog_comment')));
                 $comment->id_blog_post = $this->id_post;
                 $comment->customer_name = pSQL(Tools::getValue('customer_name'));
                 if ($message == '' || strlen($comment->customer_name) < (int) $this->conf['comment_name_min_length']) {
                     throw new Exception('error_input');
                 }
                 if (!Validate::isMessage($message) || !Validate::isGenericName($comment->customer_name)) {
                     throw new Exception('error_input_invalid');
                 }
                 $comment->content = $message;
                 $id_customer = (int) $this->context->customer->id;
                 $id_guest = (int) $this->context->cookie->id_guest;
                 if (!$this->conf['comment_guest'] && empty($id_customer)) {
                     throw new Exception('error_guest');
                 }
                 //get last comment from customer
                 $customerComment = BlogComment::getByCustomer($this->id_post, $id_customer, true, $id_guest);
                 $comment->id_customer = $id_customer;
                 $comment->id_guest = $id_guest;
                 $comment->id_lang = $id_lang;
                 $comment->id_shop = $id_shop;
                 if ($customerComment['content'] == $comment->content) {
                     throw new Exception('error_already');
                 }
                 if ($customerComment && strtotime($customerComment['date_add']) + (int) $this->conf['comment_min_time'] > time()) {
                     throw new Exception('error_delay');
                 }
                 $comment->active = $this->conf['comment_moderate'] ? 0 : 1;
                 $comment->save();
                 $this->context->smarty->assign('psblog_confirmation', true);
             } catch (Exception $e) {
                 $comment->content = Tools::getValue('blog_comment');
                 $comment->customer_name = Tools::getValue('customer_name');
                 $this->context->smarty->assign('psblog_error', $e->getMessage());
                 $this->context->smarty->assign('comment', $comment);
             }
         }
         /*             * * view article ** */
         $images = $post->getImages(false);
         $categories = $post->listCategories(true);
         $products = $post->getProducts(true);
         $related = $post->listRelated(true, true);
         if (is_array($related) && count($related) > 0) {
             $i = 0;
             foreach ($related as $val) {
                 $related[$i]['link'] = BlogPost::linkPost($val['id_blog_post'], $val['link_rewrite'], $val['id_lang']);
                 $i++;
             }
         }
         if (is_array($products) && count($products) > 0) {
             $i = 0;
             foreach ($products as $p) {
                 $product = new Product($p['id_product'], false, $id_lang);
                 $products[$i]['link'] = $this->context->link->getProductLink($product);
                 $products[$i]['imageLink'] = $this->context->link->getImageLink($p['link_rewrite'], $p['id_product'] . '-' . $p['id_image'], $this->conf['product_img_format']);
                 $i++;
             }
         }
         /* SEO metas */
         $curr_meta_title = $this->context->smarty->getTemplateVars('meta_title');
         $this->context->smarty->assign(array('meta_title' => $curr_meta_title . ' - ' . $post->title, 'meta_description' => $post->meta_description, 'meta_keywords' => $post->meta_keywords));
         if ($this->conf['view_display_popin'] == 1) {
             $this->addjqueryPlugin('fancybox');
             $this->addJS($this->module->getPathUri() . 'js/popin.js');
         }
         if ($categories) {
             $i = 0;
             foreach ($categories as $cat) {
                 $categories[$i]['link'] = BlogCategory::linkCategory($cat['id_blog_category'], $cat['link_rewrite'], $cat['id_lang']);
                 $i++;
             }
         }
         $comments = $post->getComments();
         $this->context->smarty->assign(array('post_images' => $images, 'post_products' => $products, 'post_related' => $related, 'post_categories' => $categories, 'post_comments' => $comments));
     } else {
         $post->status = 'suspended';
     }
     $this->context->smarty->assign('post', $post);
     $this->setTemplate('view.tpl');
 }
Пример #14
0
 /**
  * Exclude object from result
  *
  * @param     BlogComment $blogComment Object to remove from the list of results
  *
  * @return    BlogCommentQuery The current query, for fluid interface
  */
 public function prune($blogComment = null)
 {
     if ($blogComment) {
         $this->addUsingAlias(BlogCommentPeer::COMMENT_ID, $blogComment->getCommentId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
	protected function findComment($ID)
	{	
		$this->_comment = BlogComment::get($ID);
		return $this->_comment;
	}
Пример #16
0
 public function delete_comment($id)
 {
     $comment = BlogComment::neo()->where($id)->find();
     // validation
     if (!$comment->validate_delete()) {
         $this->flash->add('message_error', $comment->errors->get_messages());
         $this->back();
     }
     $comment->delete();
     $this->back();
 }
Пример #17
0
    /**
     * Gets an blog list based on the given parameters.
     *
     * @param array $p_parameters
     *    An array of ComparisonOperation objects
     * @param string $p_order
     *    An array of columns and directions to order by
     * @param integer $p_start
     *    The record number to start the list
     * @param integer $p_limit
     *    The offset. How many records from $p_start will be retrieved.
     *
     * @return array $issuesList
     *    An array of Issue objects
     */
    public static function GetList($p_parameters, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count)
    {
        global $g_ado_db;

        if (!is_array($p_parameters)) {
            return null;
        }

        // adodb::selectLimit() interpretes -1 as unlimited
        if ($p_limit == 0) {
            $p_limit = -1;
        }


        $selectClauseObj = new SQLSelectClause();

        // sets the where conditions
        foreach ($p_parameters as $param) {
            $comparisonOperation = self::ProcessListParameters($param);
            if (empty($comparisonOperation)) {
                continue;
            }

            $whereCondition = $comparisonOperation['left'] . ' '
            . $comparisonOperation['symbol'] . " '"
            . $g_ado_db->escape($comparisonOperation['right']) . "' ";
            $selectClauseObj->addWhere($whereCondition);
        }

        // sets the columns to be fetched
        $tmpBlogComment = new BlogComment();
		$columnNames = $tmpBlogComment->getColumnNames(true);
        foreach ($columnNames as $columnName) {
            $selectClauseObj->addColumn($columnName);
        }

        // sets the main table for the query
        $mainTblName = $tmpBlogComment->getDbTableName();
        $selectClauseObj->setTable($mainTblName);
        unset($tmpBlogComment);

        if (is_array($p_order)) {
            $order = self::ProcessListOrder($p_order);
            // sets the order condition if any
            foreach ($order as $orderField=>$orderDirection) {
                $selectClauseObj->addOrderBy($orderField . ' ' . $orderDirection);
            }
        }

        $sqlQuery = $selectClauseObj->buildQuery();

        // count all available results
        $countRes = $g_ado_db->Execute($sqlQuery);
        $p_count = $countRes->recordCount();

        //get tlimited rows
        $blogCommentRes = $g_ado_db->SelectLimit($sqlQuery, $p_limit, $p_start);

        // builds the array of blogComment objects
        $blogCommentsList = array();
        while ($blogComment = $blogCommentRes->FetchRow()) {
            $blogCommentObj = new BlogComment($blogComment['comment_id']);
            if ($blogCommentObj->exists()) {
                $blogCommentsList[] = $blogCommentObj;
            }
        }

        return $blogCommentsList;
    } // fn GetList
Пример #18
0
	protected function findComment($ID)
	{
		$this->_comment = BlogComment::get($ID);
		if ($this->_comment)
		{
			$year = date('Y', $this->_comment->blogDatePosted);
			$month = date('m', $this->_comment->blogDatePosted);
			$day = date('d', $this->_comment->blogDatePosted);
			$this->_blog = Blog::getBlog($year, $month, $day,
			                             $this->_comment->blogID,
			                             $this->_comment->blogLanguage);
			return true;
		}
		else
		{
			return false;
		}
	}
Пример #19
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = BlogComment::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }