示例#1
0
 /**
  * Override parent's implementation of store
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     if (!$this->created) {
         $this->created = EB::date()->toSql();
     }
     // Generate an alias if alias is empty
     if (!$this->alias) {
         $this->alias = EBR::normalizePermalink($this->title);
     }
     $my = JFactory::getUser();
     // Add point integrations for new categories
     if ($this->id == 0 && $my->id > 0) {
         EB::loadLanguages();
         // Integrations with EasyDiscuss
         EB::easydiscuss()->log('easyblog.new.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_CATEGORY', $this->title));
         EB::easydiscuss()->addPoint('easyblog.new.category', $my->id);
         EB::easydiscuss()->addBadge('easyblog.new.category', $my->id);
         // AlphaUserPoints
         EB::aup()->assign('plgaup_easyblog_add_category', '', 'easyblog_add_category_' . $this->id, JText::sprintf('COM_EASYBLOG_AUP_NEW_CATEGORY_CREATED', $this->title));
         // JomSocial integrations
         EB::jomsocial()->assignPoints('com_easyblog.category.add', $my->id);
         // Assign EasySocial points
         EB::easysocial()->assignPoints('category.create', $my->id);
     }
     // Figure out the proper nested set model
     if ($this->id == 0 && $this->lft == 0) {
         // No parent id, we use the current lft,rgt
         if ($this->parent_id) {
             $left = $this->getLeft($this->parent_id);
             $this->lft = $left;
             $this->rgt = $this->lft + 1;
             // Update parent's right
             $this->updateRight($left);
             $this->updateLeft($left);
         } else {
             $this->lft = $this->getLeft() + 1;
             $this->rgt = $this->lft + 1;
         }
     }
     if ($this->id == 0) {
         // new cats. we need to store the ordering.
         $this->ordering = $this->getOrdering($this->parent_id) + 1;
     }
     $isNew = !$this->id ? true : false;
     $state = parent::store();
     return $state;
 }
示例#2
0
 /**
  * Converts a string into a valid permalink
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function normalizePermalink($string, $postId = null)
 {
     $permalink = EBR::normalizePermalink($string);
     $i = 1;
     while ($this->permalinkExists($permalink, $postId)) {
         $permalink = $string . '-' . $i;
         $i++;
     }
     $permalink = EBR::normalizePermalink($permalink);
     return $permalink;
 }
示例#3
0
 /**
  * Creates a new category on the site.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public static function newCategory($blogId, $username, $password, $data)
 {
     global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;
     // Login the user
     $state = self::login($username, $password);
     if ($state !== true) {
         return $state;
     }
     $category = EB::table('Category');
     if (isset($data['name'])) {
         $category->title = $data['name'];
     }
     if (isset($data['slug'])) {
         $category->alias = EBR::normalizePermalink($data['slug']);
     }
     if (isset($data['parent_id'])) {
         $category->parent_id = $data['parent_id'];
     }
     // Set the state to published
     $category->published = true;
     $category->created_by = JFactory::getUser()->id;
     // Save the category.
     $state = $category->store();
     if (!$state) {
         return new xmlrpcresp(0, $xmlrpcerruser + 1, $category->getError());
     }
     return new xmlrpcresp(new xmlrpcval($category->id, $xmlrpcInt));
 }
示例#4
0
 /**
  * Retrieves the alias of a post
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAlias()
 {
     static $permalinks = array();
     if (!isset($permalinks[$this->id])) {
         $date = EB::date($this->created);
         // Default permalink
         $permalink = $this->permalink;
         // Ensure that the permalink is valid.
         $permalink = EBR::normalizePermalink($permalink);
         if ($this->config->get('main_sef_unicode') || !EBR::isSefEnabled()) {
             $permalink = $this->id . '-' . $permalink;
         }
         // Date based permalink
         $datePermalink = $date->format('Y') . '/' . $date->format('m') . '/' . $date->format('d');
         // Date based SEF settings
         if ($this->config->get('main_sef') == 'date') {
             $permalink = $datePermalink . '/' . $permalink;
         }
         // Category based permalink type
         if ($this->config->get('main_sef') == 'datecategory' || $this->config->get('main_sef') == 'category') {
             // Get the current primary category
             $category = $this->getPrimaryCategory();
             $categoryPermalink = $category->getAlias();
             // Date and category based permalink type
             if ($this->config->get('main_sef') == 'datecategory') {
                 $permalink = $categoryPermalink . '/' . $datePermalink . '/' . $permalink;
             } else {
                 $permalink = $categoryPermalink . '/' . $permalink;
             }
         }
         // Custom based permalink type
         if ($this->config->get('main_sef') == 'custom') {
             $permalink = EBR::getCustomPermalink($this);
         }
         $permalinks[$this->id] = $permalink;
     }
     return $permalinks[$this->id];
 }
示例#5
0
 /**
  * Retrieves the alias for this author
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAlias()
 {
     static $permalinks = array();
     if (!isset($permalinks[$this->id])) {
         $config = EB::config();
         if (!$this->user && $this->id) {
             $this->user = JFactory::getuser($this->id);
         }
         // If the username is invalid
         if (!$this->user->username) {
             return JText::_('COM_EASYBLOG_INVALID_PERMALINK_BLOGGER');
         }
         // If user doesn't have a permalink, generate it for them
         if (!$this->permalink) {
             $this->permalink = EBR::normalizePermalink($this->user->username);
             $this->store();
         }
         $permalink = $this->permalink;
         if ($config->get('main_sef_unicode') || !EBR::isSefEnabled()) {
             $permalink = $this->id . '-' . $this->permalink;
         }
         $permalinks[$this->id] = $permalink;
     }
     return $permalinks[$this->id];
 }
示例#6
0
 /**
  * Binds the posted data with the object
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function bind($data, $ignore = array())
 {
     parent::bind($data, $ignore);
     if (empty($this->created)) {
         $date = EB::date();
         $this->created = $date->toMySQL();
     }
     // we check the alias only when this teamblog is a new teamblog or the alias is empty
     if (empty($this->id) || empty($this->alias)) {
         jimport('joomla.filesystem.filter.filteroutput');
         $i = 1;
         while ($this->aliasExists() || empty($this->alias)) {
             $this->alias = empty($this->alias) ? $this->title : $this->alias . '-' . $i;
             $i++;
         }
         $this->alias = EBR::normalizePermalink($this->alias);
     }
 }