Exemplo n.º 1
0
 public function store($updateNulls = false)
 {
     if (!$this->created) {
         $this->created = FD::get('Date', 'now', false)->toMySQL();
     }
     return parent::store();
 }
Exemplo n.º 2
0
 public function store($updateNulls = false)
 {
     if (empty($this->ordering)) {
         $this->ordering = $this->getNextOrder('type = ' . FD::db()->quote($this->type) . ' AND parent_uid = ' . FD::db()->quote($this->parent_uid));
     }
     parent::store($updateNulls);
 }
Exemplo n.º 3
0
 /**
  * Overrides the delete function
  *
  * @since	1.0
  * @access	public
  * @return	bool
  */
 public function delete($pk = null)
 {
     $state = parent::delete();
     // Delete any items that are related to this stream
     $stream = FD::stream();
     $stream->delete($this->id, 'feeds');
     return $state;
 }
Exemplo n.º 4
0
 public function store($updateNulls = false)
 {
     if (empty($this->value) && !empty($this->title)) {
         $this->value = JString::strtolower(JString::str_ireplace(' ', '', $this->title));
     }
     if (empty($this->title) && !empty($this->value)) {
         $this->title = JString::ucfirst($this->value);
     }
     return parent::store($updateNulls);
 }
Exemplo n.º 5
0
 /**
  * Override parent's load implementation
  *
  * @since   1.0
  * @access  public
  * @param   int     The unique row id.
  * @param   bool    True to reset the default values before loading the new row.
  *
  * @author  Mark Lee <*****@*****.**>
  */
 public function load($key = null, $reset = true)
 {
     $state = parent::load($key, $reset);
     // @rule: We want to see which steps the user has already walked through.
     if (empty($this->step_access)) {
         $this->step_access = array();
     }
     if (!empty($this->step_access) && is_string($this->step_access)) {
         $this->step_access = explode(',', $this->step_access);
     }
     return $state;
 }
Exemplo n.º 6
0
 public function load($uid = null, $userId = null, $type = SOCIAL_STREAM_HIDE_TYPE_STREAM)
 {
     if (empty($uid) || empty($userId)) {
         return false;
     }
     $db = FD::db();
     $query = 'select `id` from `#__social_stream_hide`';
     $query .= ' where `user_id` = ' . $db->Quote($userId);
     $query .= ' and `uid` = ' . $db->Quote($uid);
     $query .= ' and `type` = ' . $db->Quote($type);
     $db->setQuery($query);
     $id = $db->loadResult();
     return parent::load($id);
 }
Exemplo n.º 7
0
 /**
  * Load a particular record given the user's id.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user's id.
  */
 public function loadByUser($userId)
 {
     $db = FD::db();
     $query = array();
     $query[] = 'SELECT * FROM ' . $db->nameQuote($this->_tbl);
     $query[] = 'WHERE ' . $db->nameQuote('user_id') . '=' . $db->Quote($userId);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result) {
         return false;
     }
     return parent::bind($result);
 }
Exemplo n.º 8
0
 public function loadByRelation($creator, $recipient, $type)
 {
     $db = FD::db();
     $query = 'SELECT COUNT(1) AS related,b.* FROM ' . $db->nameQuote('#__social_conversations_participants') . ' AS a ' . 'INNER JOIN ' . $db->nameQuote($this->_tbl) . ' AS b ' . 'ON b.' . $db->nameQuote('id') . ' = a.' . $db->nameQuote('conversation_id') . ' ' . 'WHERE ( ' . 'a.' . $db->nameQuote('user_id') . ' = ' . $db->Quote($creator) . ' ' . 'OR ' . 'a.' . $db->nameQuote('user_id') . ' = ' . $db->Quote($recipient) . ' ' . ') ' . 'AND b.' . $db->nameQuote('type') . ' = ' . $db->Quote($type) . ' ' . 'GROUP BY a.' . $db->nameQuote('conversation_id');
     // echo $query;exit;
     $db->setQuery($query);
     $data = $db->loadObject();
     if (!isset($data->related)) {
         return false;
     }
     if ($data->related >= 2) {
         return parent::bind($data);
     }
     return false;
 }
Exemplo n.º 9
0
 public function store($updateNulls = false)
 {
     if (empty($this->ordering)) {
         $this->ordering = $this->getNextOrder('type = ' . FD::db()->quote($this->type) . ' AND parent_uid = ' . FD::db()->quote($this->parent_uid));
     }
     if (empty($this->uid)) {
         $db = FD::db();
         $sql = $db->sql();
         $sql->raw("SELECT MAX(`uid`) FROM `#__social_regions` WHERE `type` = " . $db->q($this->type));
         $db->setQuery($sql);
         $result = (int) $db->loadResult();
         $this->uid = $result + 1;
     }
     parent::store($updateNulls);
 }
Exemplo n.º 10
0
 /**
  * Override parent's store function
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     // Generate an alias for this filter if it is empty.
     if (empty($this->alias)) {
         $alias = $this->title;
         $alias = JFilterOutput::stringURLSafe($alias);
         $tmp = $alias;
         $i = 1;
         while ($this->aliasExists($alias)) {
             $alias = $tmp . '-' . $i;
             $i++;
         }
         $this->alias = $alias;
     }
     $state = parent::store($updateNulls);
 }
Exemplo n.º 11
0
 public function store($updateNulls = false)
 {
     $now = FD::date();
     // Set created to now by default
     if (empty($this->created)) {
         $this->created = $now->toSql();
     }
     // Set expired to 1 day later by default
     if (empty($this->expired)) {
         $this->expired = FD::date($now->toUnix() + 24 * 60 * 60)->toSql();
     }
     if (is_array($this->value) || is_object($this->value)) {
         $this->value = FD::json()->encode($this->value);
     }
     return parent::store($updateNulls);
 }
Exemplo n.º 12
0
 public function loadByAlertId($alert_id, $user_id = null)
 {
     if (is_null($user_id)) {
         $user_id = FD::user()->id;
     }
     $db = FD::db();
     $sql = $db->sql();
     $sql->select('#__social_alert_map');
     $sql->where('alert_id', $alert_id);
     $sql->where('user_id', $user_id);
     $db->setQuery($sql);
     $result = $db->loadObject();
     if (!$result) {
         return false;
     }
     return parent::bind($result);
 }
Exemplo n.º 13
0
 /**
  * Override parent's load implementation
  *
  * @since	1.0
  * @access	public
  * @param	int		The unique row id.
  * @param   bool	True to reset the default values before loading the new row.
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function load($key = null, $reset = true)
 {
     $state = parent::load($key, $reset);
     // If state is false, then we create the session here
     if (!$state) {
         $session = JFactory::getSession();
         $this->session_id = $session->getId();
         $this->created = FD::date()->toSql();
         $state = $this->store();
     }
     // @rule: We want to see which steps the user has already walked through.
     if (empty($this->step_access)) {
         $this->step_access = array();
     }
     if (!empty($this->step_access) && is_string($this->step_access)) {
         $this->step_access = explode(',', $this->step_access);
     }
     return $state;
 }
Exemplo n.º 14
0
 public function load($uid = null, $utype = '', $component = 'com_easysocial')
 {
     if (empty($uid)) {
         return false;
     }
     if ($utype) {
         $db = FD::db();
         $query = 'select * from ' . $db->nameQuote('#__social_indexer');
         $query .= ' where ' . $db->nameQuote('uid') . ' = ' . $db->Quote($uid);
         $query .= ' and ' . $db->nameQuote('utype') . ' = ' . $db->Quote($utype);
         $query .= ' and ' . $db->nameQuote('component') . ' = ' . $db->Quote($component);
         $db->setQuery($query);
         $result = $db->loadObject();
         if (!$result) {
             return false;
         }
         parent::bind($result);
     } else {
         parent::load($uid);
     }
     return true;
 }
Exemplo n.º 15
0
 public function __construct($db)
 {
     parent::__construct('#__social_subscriptions', 'id', $db);
 }
Exemplo n.º 16
0
 /**
  * Override's parent's behavior of store.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     $state = parent::store();
     return $state;
 }
Exemplo n.º 17
0
 /**
  * Class Constructor
  *
  * @since	1.0
  * @param	JDatabase
  */
 public function __construct($db)
 {
     parent::__construct('#__social_covers', 'id', $db);
 }
Exemplo n.º 18
0
 /**
  * Class Constructor.
  *
  * @since	1.0
  * @access	public
  */
 public function __construct(&$db)
 {
     parent::__construct('#__social_apps_calendar', 'id', $db);
 }
Exemplo n.º 19
0
 /**
  * Overrides parent's delete behavior
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     $state = parent::delete($pk);
     // Delete streams that are related to this note.
     $stream = FD::stream();
     $stream->delete($this->id, 'notes');
     return $state;
 }
Exemplo n.º 20
0
 /**
  * Override parent's delete behavior
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function delete($pk = null)
 {
     $state = parent::delete($pk);
     if (!$state) {
         return false;
     }
     // Delete all existing create access for this category first.
     FD::model('ClusterCategory')->deleteAccess($this->id);
     // Delete this categories fields.
     FD::model('Fields')->deleteFields($this->id, SOCIAL_TYPE_CLUSTERS);
     return $state;
 }
Exemplo n.º 21
0
 public function __construct(&$db)
 {
     parent::__construct('#__social_events_meta', 'id', $db);
 }
 /**
  * Override parent's store method so that we can
  * run our own maintenance here.
  */
 public function store($updateNulls = false)
 {
     $state = parent::store($updateNulls);
     if ($state) {
         // Add a new location item if address, latitude , longitude is provided.
         $latitude = JRequest::getVar('latitude');
         $longitude = JRequest::getVar('longitude');
         $address = JRequest::getVar('address');
         // Let's add the location now.
         if (!empty($latitude) && !empty($longitude) && !empty($address)) {
             $location = FD::table('Location');
             $location->latitude = $latitude;
             $location->longitude = $longitude;
             $location->address = $address;
             $location->uid = $this->id;
             $location->type = SOCIAL_TYPE_CONVERSATIONS;
             $location->user_id = $this->created_by;
             $location->store();
         }
     }
     return $state;
 }
Exemplo n.º 23
0
 /**
  * Override parent's behavior of deleting as we also need to delete physical files.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return	bool
  */
 public function delete($pk = null)
 {
     $state = parent::delete();
     if (!$state) {
         return false;
     }
     // Get config
     $config = FD::config();
     // Get the default avatars storage location.
     $avatarsPath = JPATH_ROOT . '/' . FD::cleanPath($config->get('avatars.storage.container'));
     // Test if the avatars path folder exists. If it doesn't we need to create it.
     if (!FD::makeFolder($avatarsPath)) {
         FD::logError(__FILE__, __LINE__, 'AVATARS: Unable to create the path ' . $avatarsPath);
         $this->setError(JText::_('Errors when creating default container for avatar'));
         return false;
     }
     // Get the default avatars storage location for this type.
     $typePath = $config->get('avatars.storage.' . $this->type);
     $storagePath = $avatarsPath . '/' . FD::cleanPath($typePath);
     // Set the absolute path based on the uid.
     $storagePath = $storagePath . '/' . $this->uid;
     $this->deleteFolder($storagePath);
     return $state;
 }
Exemplo n.º 24
0
 /**
  * Tries to find the oauth record given a username
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function loadByUsername($username)
 {
     $model = FD::model('OAuth');
     $row = $model->getRow(array('username' => $username));
     if (!$row) {
         return false;
     }
     $state = parent::bind($row);
     return $state;
 }
Exemplo n.º 25
0
 /**
  * Class construct
  *
  * @since	1.0
  * @param	JDatabase
  */
 public function __construct(&$db)
 {
     parent::__construct('#__social_points_maps', 'id', $db);
 }
Exemplo n.º 26
0
 public function __construct($db)
 {
     parent::__construct('#__social_links_images', 'id', $db);
 }
Exemplo n.º 27
0
 public function __construct(&$db)
 {
     parent::__construct('#__social_config', 'type', $db);
 }
Exemplo n.º 28
0
 /**
  * Override parent's behavior to delete this discussion
  *
  * @since	1.2
  * @access	public
  * @param	int
  * @return
  */
 public function delete($pk = null)
 {
     $state = parent::delete($pk);
     if ($state) {
         // Delete all the replies
         $model = FD::model('Discussions');
         $model->deleteReplies($this->id);
         // Delete all stream items related to this discussion.
         FD::stream()->delete($this->id, 'discussions');
         // Delete any files associated in #__social_discussions_files
         $model->deleteFiles($this->id);
     }
     return $state;
 }
Exemplo n.º 29
0
 /**
  * Deletes a profile off the system. Any related profiles stuffs should also be deleted here.
  *
  * @since	1.0
  * @access	public
  * @param   mixed	An optional primary key value to delete.  If not set the instance property value is used.
  */
 public function delete($pk = null)
 {
     // Try to delete this profile item.
     $state = parent::delete($pk);
     // Delete custom fields created for this profile type
     if ($state) {
         // Delete all field relations to this profile.
         $model = FD::model('Fields');
         $model->deleteFields($this->id, SOCIAL_TYPE_PROFILES);
         // Delete all stream related items.
         $stream = FD::stream();
         $stream->delete($this->id, SOCIAL_TYPE_PROFILES);
         // Delete profile avatar.
         $avatar = FD::table('Avatar');
         if ($avatar->load(array('uid' => $this->id, 'type' => SOCIAL_TYPE_PROFILES))) {
             $avatar->delete();
         }
         // Delete default avatars for this profile.
         $avatarModel = FD::model("Avatars");
         $avatarModel->deleteDefaultAvatars($this->id, SOCIAL_TYPE_PROFILES);
     }
     return $state;
 }
Exemplo n.º 30
0
 public function __construct($db)
 {
     parent::__construct('#__social_stream_tags', 'id', $db);
 }