/** * Allows caller to load a list map using a given id and type. * * Example: * <code> * <?php * $table = FD::table(); * $table->loadByType( 42 , SOCIAL_TYPE_USER ); * ?> * </code> * * @since 1.0 * @access public * @param int The list's id. * @param int The target id. * @param string The target type. * @return boolean */ public function loadByType($listId, $targetId, $targetType) { $db = FD::db(); $query = 'SELECT * FROM ' . $db->nameQuote($this->_tbl) . ' ' . 'WHERE ' . $db->nameQuote('target_id') . '=' . $db->Quote($targetId) . ' ' . 'AND ' . $db->nameQuote('target_type') . '=' . $db->Quote($targetType) . ' ' . 'AND ' . $db->nameQuote('list_id') . '=' . $db->Quote($listId); $db->setQuery($query); $result = $db->loadObject(); if (!$result) { return false; } return parent::bind($result); }
/** * 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); }
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; }
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); }
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; }
/** * Bind's the stream data * * Example: * <code> * <?php * // Load up the library. * $item = FD::table( 'StreamItem' ); * $item->bind( $data ); * * </code> * * @since 1.0 * @access public * @param mixed Accepts array, object or SocialStreamTemplate which represents the stream's data. * @return SocialTableStreamItem Returns the new stream id if success, false otherwise. */ public function bind($data, $ignore = array()) { // Request parent to bind the data. $state = parent::bind($data, $ignore); return $state; }
/** * 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; }
/** * Override parent's bind method implementation. * * @since 1.0 * @access public * @param Array An array of key / value pairs for the table columns * @param Array A list of ignored columns. (Optional) * @return bool True if binded successfully. * * @author Mark Lee <*****@*****.**> */ public function bind($data, $ignore = array()) { // Request the parent to bind the data. $state = parent::bind($data, $ignore); // Try to see if there's any params being set to the property as an array. if (!is_null($this->params) && is_array($this->params)) { $registry = FD::get('Registry'); foreach ($this->params as $key => $value) { $registry->set($key, $value); } // Set the params to a proper string. $this->params = $registry->toString(); } return $state; }
/** * Loads the application given the `element`, `type` and `group`. * * @since 1.0 * @access public * @param string The unique element name. (E.g: notes ) * @param string The group of the application. (E.g: people or group) * @param string The unique type of the app. (E.g: apps or fields ) * * @return bool True on success false otherwise * * @author Mark Lee <*****@*****.**> */ public function loadByElement($element, $group, $type) { $db = FD::db(); $query = array(); $query[] = 'SELECT * FROM ' . $db->nameQuote($this->_tbl); $query[] = 'WHERE ' . $db->nameQuote('element') . '=' . $db->Quote($element); $query[] = 'AND ' . $db->nameQuote('type') . '=' . $db->Quote($type); $query[] = 'AND ' . $db->nameQuote('group') . '=' . $db->Quote($group); $query = implode(' ', $query); $db->setQuery($query); $result = $db->loadObject(); if (!$result) { return false; } return parent::bind($result); }
/** * Binds a given array or object in this table's properties. * * @since 1.0 * @access public * @param object|array Data to be binded. * @param array An optional array or space separated list of properties to ignore while binding. * @return bool State of storing. */ public function bind($data, $ignore = array()) { $state = parent::bind($data, $ignore); // @task: If created is not set, we need to set it here. if (empty($this->created)) { $this->created = FD::get('Date')->toMySQL(); } // @task: If created is not set, we need to set it here. if (empty($this->state)) { // @TODO: Make this configurable. Default state to be published $this->state = SOCIAL_FRIENDS_LIST_PUBLISHED; } return $state; }
public function bind($src, $ignore = array()) { $state = parent::bind($src, $ignore); if (!$state) { return false; } $this->extractParams(); return true; }
/** * Loads the point record given the composite indices. * * @since 1.0 * @access public * @param string The command to lookup for. * @param string The extension to lookup for. * @return bool True if exists, false otherwise. */ public function loadByCommand($extension, $command) { $db = FD::db(); $sql = $db->sql(); $sql->select($this->_tbl); $sql->where('command', $command); $sql->where('extension', $extension); $db->setQuery($query); $row = $db->loadObject(); if (!$row) { return false; } return parent::bind($row); }
/** * Overrides parent's load implementation * * @since 1.0 * @access public */ public function load($keys = null, $reset = true) { if (self::$_cache) { if (is_array($keys)) { return parent::load($keys, $reset); } if (!isset(self::$_photos[$keys])) { $state = parent::load($keys); self::$_photos[$keys] = $this; return $state; } if (is_bool(self::$_photos[$keys])) { return false; } return parent::bind(self::$_photos[$keys]); } else { return parent::load($keys, $reset); } }
/** * Override parent's implementation. * * @since 1.0 * @access public * @param string $token The token that is generated. * @return boolean True if exists, false otherwise. */ public function loadByType($uid, $type) { $db = FD::db(); $query = 'SELECT * FROM ' . $db->nameQuote($this->_tbl) . ' WHERE ' . $db->nameQuote('uid') . '=' . $db->Quote($uid) . ' AND ' . $db->nameQuote('type') . '=' . $db->Quote($type); $db->setQuery($query); $obj = $db->loadObject(); return parent::bind($obj); }
/** * Override parent's store implementation * * @since 1.0 * @access public * @param Array An associative array or object to bind to the JTable instance. * @param Array An optional array or space separated list of properties to ignore while binding. * * @author Mark Lee <*****@*****.**> */ public function bind($data, $ignore = array()) { $state = parent::bind($data, $ignore); if (isset($data->element)) { $this->element = $data->element; } if (isset($data->value)) { $this->value = $data->value; } if (isset($data->value_binary)) { $this->value_binary = $data->value_binary; } return $state; }
/** * Some desc * * @since 1.0 * @access public * @param string * @return */ public function loadByUID($uid) { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_stream', 'a'); $sql->column('a.*'); $sql->join('#__social_stream_item', 'b'); $sql->on('b.uid', 'a.id'); $sql->where('b.id', $uid); $db->setQuery($sql); $obj = $db->loadObject(); return parent::bind($obj); }
/** * Override parent's implementation * * @since 1.2 * @access public * @param string * @return bool True on success false otherwise */ public function bindPost($post = array()) { $state = parent::bind($post); $icon = isset($post['mood_icon']) ? $post['mood_icon'] : $this->icon; $verb = isset($post['mood_verb']) ? $post['mood_verb'] : $this->verb; $subject = isset($post['mood_subject']) ? $post['mood_subject'] : $this->subject; $custom = isset($post['mood_custom']) ? $post['mood_custom'] : $this->custom; $text = isset($post['mood_text']) ? $post['mood_text'] : $this->text; // The "custom" string is being passed as "true" or "false" string and not a boolean value. $custom = $custom == "true" ? true : false; // If there's always no icon, and not a custom mood skip this if (empty($icon) && !$custom) { return false; } // The text must never be empty if ($custom && empty($text)) { return false; } // If this is a predefined one, verb has to exist if (!$custom && empty($subject)) { return false; } $this->icon = $icon; $this->verb = $verb; $this->subject = $subject; $this->custom = $custom ? true : false; $this->text = $text; return true; }
public function loadByNode($id) { $db = FD::db(); $query = 'SELECT * FROM ' . $db->nameQuote($this->_tbl); $query .= ' WHERE ' . $db->nameQuote('node_id') . '=' . $db->Quote($id) . ' ' . 'AND ' . $db->nameQuote('state') . ' = ' . $db->Quote(SOCIAL_STATE_DEFAULT); $db->setQuery($query); return parent::bind($db->loadAssoc()); }
/** * Loads an avatar object based on the given unique id and type. * * @since 1.0 * @access public * @param int The unique id. * @param string The unique type. * @return bool True if success false otherwise. */ public function loadByType($id, $type) { $db = FD::db(); $query[] = 'SELECT * FROM ' . $db->nameQuote($this->_tbl); $query[] = 'WHERE ' . $db->nameQuote('uid') . '=' . $db->Quote($id); $query[] = 'AND ' . $db->nameQuote('type') . '=' . $db->Quote($type); // Glue back the query. $query = implode(' ', $query); $db->setQuery($query); $result = $db->loadObject(); if (!$result) { return false; } return parent::bind($result); }
public function bind($data, $ignore = array()) { $state = parent::bind($data); $jConfig = FD::jconfig(); // @TODO: Admin can create multiple emails from in the future. if (is_null($this->sender_name)) { $this->sender_name = $jConfig->getValue('fromname'); } if (is_null($this->sender_email)) { $this->sender_email = $jConfig->getValue('mailfrom'); } if (is_null($this->created)) { $this->created = FD::get('Date')->toMySQL(); } if (is_null($this->priority)) { $this->priority = SOCIAL_MAILER_PRIORITY_NORMAL; } return $state; }
/** * Overrides parent's load implementation * * @since 1.0 * @access public */ public function load($keys = null, $reset = true) { $state = false; $loaded = false; if (is_array($keys)) { $state = parent::load($keys, $reset); } else { if (!isset(self::$_albums[$keys])) { $state = parent::load($keys); self::$_albums[$keys] = $this; } else { $value = self::$_albums[$keys]; if (is_bool($value)) { $state = false; } else { $state = parent::bind($value); } $loaded = true; } } if ($state && !$loaded) { // Converts params into an object first if (empty($this->params)) { $this->params = new stdClass(); } else { $this->params = FD::json()->decode($this->params); } } return $state; }