b2evolution PHP Cross Reference Blogging Systems

Source: /inc/links/model/_linkcomment.class.php - 186 lines - 4855 bytes - Summary - Text - Print

Description: This file implements the LinkComment class, which is a wrapper class for Comment class to handle linked files. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file implements the LinkComment class, which is a wrapper class for Comment class to handle linked files.

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   9   *

  10   * @package evocore

  11   *

  12   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  13   * @author efy-asimo: Attila Simo.

  14   *

  15   * @version $Id: $

  16   */
  17  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  18  
  19  /**

  20   * LinkComment Class

  21   *

  22   * @package evocore

  23   */
  24  class LinkComment extends LinkOwner
  25  {
  26      /**

  27       * @var Comment

  28       */
  29      var $Comment;
  30  
  31      /**

  32       * Constructor

  33       */
  34  	function LinkComment( $edited_Comment )
  35      {
  36          parent::LinkOwner( $edited_Comment, 'comment' );
  37          $this->Comment = & $this->link_Object;
  38  
  39          $this->_trans = array(
  40              'Link this image to your owner' => NT_( 'Link this image to your comment' ),
  41              'Link this file to your owner' => NT_( 'Link this file to your comment'),
  42              'The file will be linked for download at the end of the owner' => NT_( 'The file will be linked for download at the end of the comment.' ),
  43              'Insert the following code snippet into your owner' => NT_( 'Insert the following code snippet into your comment.' ),
  44              'View this owner...' => NT_( 'View this comment...' ),
  45              'Edit this owner...' => NT_( 'Edit this comment...' ),
  46              'Click on link %s icons below to link additional files to $ownerTitle$.' => NT_( 'Click on link %s icons below to link additional files to <strong>Comment</strong>.' ),
  47              'Link files to current owner' => NT_( 'Link files to current comment' ),
  48              'Selected files have been linked to owner.' => NT_( 'Selected files have been linked to comment.' ),
  49              'Link has been deleted from $ownerTitle$.' => NT_( 'Link has been deleted from the &laquo;Comment&raquo;.' ),
  50          );
  51      }
  52  
  53      /**

  54       * Check current User Comment permissions

  55       *

  56       * @param string permission level

  57       * @param boolean true to assert if user dosn't have the required permission

  58       */
  59  	function check_perm( $permlevel, $assert = false )
  60      {
  61          global $current_User;
  62  
  63          $this->load_Blog();
  64          return $current_User->check_perm( 'blog_comments', $permlevel, $assert, $this->Blog->ID );
  65      }
  66  
  67      /**

  68       * Get all positions ( key, display name ) pairs where link can be displayed

  69       *

  70       * @return array

  71       */
  72  	function get_positions()
  73      {
  74          // Should be ordered like the ENUM.

  75          return array(
  76              'teaser' => T_( 'Above comment' ),
  77              'aftermore' => T_( 'Below comment' ),
  78              );
  79      }
  80  
  81      /**

  82       * Load all links of owner Comment if it was not loaded yet

  83       */
  84  	function load_Links()
  85      {
  86          if( is_null( $this->Links ) )
  87          { // Links have not been loaded yet:
  88              $LinkCache = & get_LinkCache();
  89              $this->Links = $LinkCache->get_by_comment_ID( $this->Comment->ID );
  90          }
  91      }
  92  
  93      /**

  94       * Add new link to owner Comment

  95       *

  96       * @param integer file ID

  97       * @param integer link position ( 'teaser', 'aftermore' )

  98       * @param int order of the link

  99       */
 100  	function add_link( $file_ID, $position, $order )
 101      {
 102          $edited_Link = new Link();
 103          $edited_Link->set( 'cmt_ID', $this->Comment->ID );
 104          $edited_Link->set( 'file_ID', $file_ID );
 105          $edited_Link->set( 'position', $position );
 106          $edited_Link->set( 'order', $order );
 107          $edited_Link->dbinsert();
 108  
 109          // Update last touched date of the Item

 110          $this->item_update_last_touched_date();
 111      }
 112  
 113      /**

 114       * Set Blog

 115       */
 116  	function load_Blog()
 117      {
 118          if( is_null( $this->Blog ) )
 119          {
 120              $comment_Item = $this->Comment->get_Item();
 121              $this->Blog = & $comment_Item->get_Blog();
 122          }
 123      }
 124  
 125      /**

 126       * Get where condition for select query to get Comment links

 127       */
 128  	function get_where_condition() {
 129          return 'link_cmt_ID = '.$this->Comment->ID;
 130      }
 131  
 132      /**

 133       * Get Comment parameter

 134       *

 135       * @param string parameter name to get

 136       */
 137  	function get( $parname )
 138      {
 139          switch( $parname )
 140          {
 141              case 'name':
 142                  return 'comment';
 143              case 'title':
 144                  return T_( 'Comment' );
 145          }
 146          return parent::get( $parname );
 147      }
 148  
 149      /**

 150       * Get Comment edit url

 151       */
 152  	function get_edit_url()
 153      {
 154          $this->load_Blog();
 155          return '?ctrl=comments&amp;blog='.$this->Blog->ID.'&amp;action=edit&amp;comment_ID='.$this->Comment->ID;
 156      }
 157  
 158      /**

 159       * Get Comment view url

 160       */
 161  	function get_view_url()
 162      {
 163          return $this->Comment->get_permanent_url();
 164      }
 165  
 166  
 167      /**

 168       * Update field last_touched_ts of Item

 169       */
 170  	function item_update_last_touched_date()
 171      {
 172          $updated_Item = NULL;
 173  
 174          if( !empty( $this->Comment ) )
 175          {
 176              $updated_Item = & $this->Comment->get_Item();
 177          }
 178  
 179          if( !empty( $updated_Item ) )
 180          {    // Update Item if it exists
 181              $updated_Item->update_last_touched_date();
 182          }
 183      }
 184  }
 185  
 186  ?>

title

Description

title

Description

title

Description

title

title

Body