Example #1
0
 public function loadByKey($key)
 {
     $db = EasyBlogHelper::db();
     $query = 'SELECT * FROM ' . $db->nameQuote($this->_tbl) . ' WHERE ' . $db->nameQuote('key') . '=' . $db->Quote($key);
     $db->setQuery($query);
     $data = $db->loadObject();
     return parent::bind($data);
 }
Example #2
0
 function loadBySource($postId, $key, $source)
 {
     $db = EasyBlogHelper::db();
     $query = 'SELECT * FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('uid') . '=' . $db->Quote($key) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('post_id') . '=' . $db->Quote($postId) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('source') . '=' . $db->Quote($source);
     $db->setQuery($query);
     $obj = $db->loadObject();
     return parent::bind($obj);
 }
Example #3
0
 public function loadByPostId($id)
 {
     $db = $this->getDBO();
     $query = 'select * FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl);
     $query .= ' where `post_id`= ' . $db->Quote($id);
     $db->setQuery($query);
     $result = $db->loadAssoc();
     return parent::bind($result);
 }
Example #4
0
 public function load($path = null, $type = true)
 {
     $db = EasyBlogHelper::db();
     $query = 'SELECT * FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl);
     $query .= ' WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('path') . '=' . $db->Quote($path);
     $query .= ' AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('type') . '=' . $db->Quote($type);
     $db->setQuery($query);
     $obj = $db->loadObject();
     return parent::bind($obj);
 }
Example #5
0
 public function load($id = null, $type = '')
 {
     $db = EasyBlogHelper::db();
     $query = 'SELECT * FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('content_id') . '=' . $db->Quote($id) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('type') . '=' . $db->Quote($type);
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result) {
         return false;
     }
     return parent::bind($result);
 }
Example #6
0
 function bindPost()
 {
     $data = array('nickname' => JRequest::getWord('nickname'), 'description' => JRequest::getVar('description'), 'url' => JRequest::getVar('url'), 'biography' => JRequest::getVar('biography'), 'title' => JRequest::getVar('title'));
     pr($data);
     exit;
     parent::bind($data);
     $avatar = JRequest::getVar('avatar', '', 'Files');
     if (!empty($avatar['tmp_name'])) {
         require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'image.php';
     }
 }
Example #7
0
 public function loadByUser($id, $type)
 {
     $db = EB::db();
     $query = 'SELECT * FROM ' . $db->quoteName($this->_tbl) . ' ' . 'WHERE ' . $db->nameQuote('user_id') . '=' . $db->Quote($id) . ' ' . 'AND ' . $db->nameQuote('type') . '=' . $db->Quote($type) . ' ' . 'LIMIT 1';
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result) {
         return false;
     }
     return parent::bind($result);
 }
Example #8
0
 function loadByUser($id, $type)
 {
     $db = $this->getDBO();
     $query = 'SELECT * FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('user_id') . '=' . $db->Quote($id) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('type') . '=' . $db->Quote($type) . ' ' . 'LIMIT 1';
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result) {
         return false;
     }
     return parent::bind($result);
 }
 /**
  * Loads a micro posting from twitter given the post id
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function loadByPostId($id)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->qn($this->_tbl);
     $query[] = 'WHERE ' . $db->qn('post_id') . '=' . $db->Quote($id);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObject();
     $state = parent::bind($result);
     return $state;
 }
Example #10
0
 function bind($data, $ignore = array())
 {
     parent::bind($data, $ignore);
     $this->url = $this->_appendHTTP($this->url);
     //default to username for blogger permalink if empty
     if (empty($this->permalink)) {
         $user = JFactory::getUser($this->id);
         $this->permalink = isset($user->username) ? $user->username : $this->id;
         $this->permalink = JFilterOutput::stringURLSafe($this->permalink);
     } else {
         $this->permalink = JFilterOutput::stringURLSafe($this->permalink);
     }
     return true;
 }
Example #11
0
 /**
  * Binds an array of data with the current profile object.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function bind($data, $ignore = array())
 {
     // Load the parent bind method
     $state = parent::bind($data, $ignore);
     // Normalize the url
     $this->url = EB::string()->normalizeUrl($this->url);
     // If user's permalink is empty, we need to generate one for them.
     if (empty($this->permalink)) {
         $user = JFactory::getUser($this->id);
         $this->permalink = $user->username;
     }
     // Ensure that the permalink is valid
     $this->permalink = JFilterOutput::stringURLSafe($this->permalink);
     return $state;
 }
Example #12
0
 /**
  * Loads a meta data by a specific type
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function loadByType($type, $id)
 {
     $db = EB::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->quoteName($this->_tbl);
     $query[] = 'WHERE ' . $db->quoteName('type') . '=' . $db->Quote($type);
     $query[] = 'AND ' . $db->quoteName('content_id') . '=' . $db->Quote($id);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $data = $db->loadObject();
     if (!$data) {
         return false;
     }
     return parent::bind($data);
 }
Example #13
0
 public function fill($userId, $postId, $type, $hash = '')
 {
     static $objects = array();
     if (!isset($objects[$type][$postId][$userId])) {
         $db = $this->getDBO();
         $query = 'SELECT * FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote($this->_tbl) . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . '=' . $db->Quote($userId) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('uid') . '=' . $db->Quote($postId) . ' ' . 'AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('type') . '=' . $db->Quote($type);
         if (!empty($hash)) {
             $query .= ' AND ' . EasyBlogHelper::getHelper('SQL')->nameQuote('sessionid') . '=' . $db->Quote($hash);
         }
         $db->setQuery($query);
         $result = $db->loadObject();
         if (is_null($result)) {
             return false;
         }
         $objects[$type][$postId][$userId] = $result;
     }
     return parent::bind($objects[$type][$postId][$userId]);
 }
Example #14
0
 /**
  * Overrides parent's bind method
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function bind($data, $ignore = array())
 {
     parent::bind($data, $ignore);
     if (!$this->created) {
         $this->created = EB::date()->toSql();
     }
     // we check the alias only when the category is a new category 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;
             $this->alias = EBR::normalizePermalink($this->alias);
             $i++;
         }
     }
 }
Example #15
0
 /**
  * Must only be bind when using POST data
  **/
 function bind($data, $post = false)
 {
     parent::bind($data);
     if ($post) {
         $acl = EasyBlogACLHelper::getRuleSet();
         $my = JFactory::getUser();
         // Some properties needs to be overriden.
         $content = JRequest::getVar('write_content_hidden', '', 'post', 'string', JREQUEST_ALLOWRAW);
         if ($this->id == 0) {
             // this is to check if superadmin assign blog author during blog creation.
             if (empty($this->created_by)) {
                 $this->created_by = $my->id;
             }
         }
         //remove unclean editor code.
         $pattern = array('/<p><br _mce_bogus="1"><\\/p>/i', '/<p><br mce_bogus="1"><\\/p>/i', '/<br _mce_bogus="1">/i', '/<br mce_bogus="1">/i', '/<p><br><\\/p>/i');
         $replace = array('', '', '', '', '');
         $content = preg_replace($pattern, $replace, $content);
         // Search for readmore tags using Joomla's mechanism
         $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
         $pos = preg_match($pattern, $content);
         if ($pos == 0) {
             $this->intro = $content;
             // @rule: Since someone might update this post, we need to clear out the content
             // if it doesn't contain anything.
             $this->content = '';
         } else {
             list($intro, $main) = preg_split($pattern, $content, 2);
             $this->intro = $intro;
             $this->content = $main;
         }
         $publish_up = '';
         $publish_down = '';
         $created_date = '';
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($this->created)) {
             $date = EasyBlogHelper::getDate($this->created, $tzoffset);
             $created_date = $date->toMySQL();
         }
         if ($this->publish_down == '0000-00-00 00:00:00') {
             $publish_down = $this->publish_down;
         } else {
             if (!empty($this->publish_down)) {
                 $date = EasyBlogHelper::getDate($this->publish_down, $tzoffset);
                 $publish_down = $date->toMySQL();
             }
         }
         if (!empty($this->publish_up)) {
             $date = EasyBlogHelper::getDate($this->publish_up, $tzoffset);
             $publish_up = $date->toMySQL();
         }
         //default joomla date obj
         $date = EasyBlogHelper::getDate();
         $this->created = !empty($created_date) ? $created_date : $date->toMySQL();
         $this->modified = $date->toMySQL();
         $this->publish_up = !empty($publish_up) ? $publish_up : $date->toMySQL();
         $this->publish_down = empty($publish_down) ? '0000-00-00 00:00:00' : $publish_down;
         $this->ispending = empty($acl->rules->publish_entry) ? 1 : 0;
         $this->title = trim($this->title);
         $this->permalink = trim($this->permalink);
     }
     return true;
 }
Example #16
0
 /**
  * Must only be bind when using POST data
  **/
 function bind($data, $post = false)
 {
     if (!$post) {
         return parent::bind($data);
     }
     parent::bind($data);
     $acl = EasyBlogACLHelper::getRuleSet();
     $my = JFactory::getUser();
     // Some properties needs to be overriden.
     $content = $this->content;
     //remove unclean editor code.
     $pattern = array('/<p><br _mce_bogus="1"><\\/p>/i', '/<p><br mce_bogus="1"><\\/p>/i', '/<br _mce_bogus="1">/i', '/<br mce_bogus="1">/i', '/<p><br><\\/p>/i');
     $replace = array('', '', '', '', '');
     $content = preg_replace($pattern, $replace, $content);
     // Search for readmore tags using Joomla's mechanism
     $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i';
     $pos = preg_match($pattern, $content);
     if ($pos == 0) {
         $this->intro = $content;
         $this->content = '';
     } else {
         list($intro, $main) = preg_split($pattern, $content, 2);
         $this->intro = $intro;
         $this->content = $main;
     }
     $intro = $this->intro;
     $content = $this->content;
     $publish_up = '';
     $publish_down = '';
     $created_date = '';
     $tzoffset = EasyBlogDateHelper::getOffSet();
     if (!empty($this->created)) {
         $date = EasyBlogHelper::getDate($this->created, $tzoffset);
         $created_date = $date->toMySQL();
     }
     if ($this->publish_down == '0000-00-00 00:00:00') {
         $publish_down = $this->publish_down;
     } else {
         if (!empty($this->publish_down)) {
             $date = EasyBlogHelper::getDate($this->publish_down, $tzoffset);
             $publish_down = $date->toMySQL();
         }
     }
     if (!empty($this->publish_up)) {
         $date = EasyBlogHelper::getDate($this->publish_up, $tzoffset);
         $publish_up = $date->toMySQL();
     }
     //default joomla date obj
     $date = EasyBlogHelper::getDate();
     $this->created = !empty($created_date) ? $created_date : $date->toMySQL();
     $this->intro = $intro;
     $this->content = $content;
     $this->modified = $date->toMySQL();
     $this->publish_up = !empty($publish_up) ? $publish_up : $date->toMySQL();
     $this->publish_down = empty($publish_down) ? '0000-00-00 00:00:00' : $publish_down;
     $this->ispending = empty($acl->rules->publish_entry) ? 1 : 0;
     $this->issitewide = empty($this->blog_contribute) ? 1 : 0;
     // Bind necessary stuffs for the next load
     if (isset($data['tags']) && !empty($data['tags']) && is_array($data['tags'])) {
         $this->set('tags', implode(',', $data['tags']));
     }
     if (isset($data['keywords']) && !empty($data['keywords'])) {
         $this->set('metakey', $data['keywords']);
     }
     if (isset($data['description']) && !empty($data['description'])) {
         $this->set('metadesc', $data['description']);
     }
     if (isset($data['trackback']) && !empty($data['trackback'])) {
         $this->set('trackbacks', $data['trackback']);
     }
     if (isset($data['blogpassword']) && !empty($data['blogpassword'])) {
         $this->set('blogpassword', $data['blogpassword']);
     }
     // @task: Try to detect autoposting for centralized sites
     if (isset($data['centralized']) && !empty($data['centralized'])) {
         $this->set('autopost_centralized', implode(',', $data['centralized']));
     }
     if (isset($data['socialshare']) && !empty($data['socialshare'])) {
         $this->set('autopost', implode(',', $data['socialshare']));
     }
     if (isset($data['blog_contribute_source']) && $data['blog_contribute_source'] != 'easyblog') {
         $this->set('external_source', $data['blog_contribute_source']);
         $this->set('external_group_id', $data['blog_contribute']);
     }
     if (isset($data['image']) && $data['image']) {
         $this->set('image', $data['image']);
     }
     return true;
 }
Example #17
0
 /**
  * Overrides parent's bind method to add our own logic.
  *
  * @param Array $data
  **/
 function bind($data, $ignore = array())
 {
     parent::bind($data, $ignore);
 }
Example #18
0
 /**
  * Overrides parent's bind method to add our own logic.
  *
  * @param Array $data
  **/
 function bind($data, $ignore = array())
 {
     parent::bind($data, $ignore);
     if (empty($this->created)) {
         $this->created = EasyBlogHelper::getDate()->toMySQL();
     }
     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 	= JFilterOutput::stringURLSafe( $this->alias );
     $this->alias = EasyBlogRouter::generatePermalink($this->alias);
 }