/** * entry method */ public static function exec($px) { $theme = new self($px); $src = $theme->bind($px); $px->bowl()->replace($src, ''); return true; }
/** * * @param string $sql * @param boolean $isReadOnly * @return self */ public static function create($sql, array $bindParams = null, $isReadOnly = NULL, $options = array()) { $instance = new self(null, $options); $instance->sql = $sql; if (!is_null($bindParams)) { $instance->bind($bindParams); } if (is_null($isReadOnly)) { $instance->isReadOnly = strncasecmp($sql, "SELECT", 6) == 0; } else { $instance->isReadOnly = $isReadOnly; } return $instance; }
/** * Loads and prepares the event classes. * * @author Jason Rey <*****@*****.**> * @since 1.3 * @access public * @param Mixed $ids The ids to load. * @return Mixed The event class or array of event classes. */ public static function loadEvents($ids = null) { if (is_object($ids)) { $obj = new self(); $obj->bind($ids); self::$instances[$ids->id] = $obj; return self::$instances[$ids->id]; } $argumentIsArray = is_array($ids); $ids = FD::makeArray($ids); if (empty($ids)) { return false; } $model = FD::model('Events'); $events = $model->getMeta($ids); if (empty($events)) { return false; } $result = array(); foreach ($events as $event) { if (!$event) { continue; } if (isset(self::$instances[$event->id])) { $result[] = self::$instances[$event->id]; continue; } $event->cover = self::getCoverObject($event); $guests = $model->getGuests($event->id); $event->guests = array(); foreach ($guests as $guest) { $event->guests[$guest->uid] = $guest; if ($guest->isAdmin()) { $event->admins[] = $guest->uid; } if (!isset($event->{self::$guestStates[$guest->state]}) || !is_array($event->{self::$guestStates[$guest->state]})) { $event->{self::$guestStates[$guest->state]} = array(); } // Guests states array only stores the id, and this needs to be mapped to the instance->guests property to get the guest table object. $event->{self::$guestStates[$guest->state]}[] = $guest->uid; } $obj = new SocialEvent($event); self::$instances[$event->id] = $obj; $result[] = self::$instances[$event->id]; } if (empty($result)) { return false; } if (!$argumentIsArray && count($result) === 1) { return $result[0]; } return $result; }
public static function staticBind($class) { $instance = new self(); return $instance->bind($class); }
/** * Loads a given group id or an array of id's. * * Example: * <code> * <?php * // Loads current logged in user. * $my = FD::get( 'User' ); * // Shorthand * $my = FD::user(); * * // Loads a single user. * $user = FD::get( 'User' , 42 ); * // Shorthand * $user = FD::user( 42 ); * * // Loads multiple users. * $users = FD::get( 'User' , array( 42 , 43 ) ); * // Shorthand * $users = FD::user( array( 42 , 43 ) ); * ?> * </code> * * @since 1.0 * @access public * @param int|Array Either an int or an array of id's in integer. * @return SocialUser The user object. * * @author Mark Lee <*****@*****.**> */ public static function loadGroups($ids = null, $debug = false) { if (is_object($ids)) { $obj = new self(); $obj->bind($ids); self::$instances[$ids->id] = $obj; return self::$instances[$ids->id]; } // Determine if the argument is an array. $argumentIsArray = is_array($ids); // Ensure that id's are always an array $ids = FD::makeArray($ids); // Reset the index of ids so we don't load multiple times from the same user. $ids = array_values($ids); if (empty($ids)) { return false; } // Get the metadata of all groups $model = FD::model('Groups'); $groups = $model->getMeta($ids); if (!$groups) { return false; } // Format the return data $result = array(); foreach ($groups as $group) { if ($group === false) { continue; } // Set the cover for the group $group->cover = self::getCoverObject($group); // Pre-load list of members for the group $members = $model->getMembers($group->id, array('users' => false)); $group->members = array(); $group->admins = array(); $group->pending = array(); if ($members) { foreach ($members as $member) { if ($member->state == SOCIAL_GROUPS_MEMBER_PUBLISHED) { $group->members[$member->uid] = $member->uid; } if ($member->admin) { $group->admins[$member->uid] = $member->uid; } if ($member->state == SOCIAL_GROUPS_MEMBER_PENDING) { $group->pending[$member->uid] = $member->uid; } } } // Attach custom fields for this group // $group->fileds = $model->getCustomFields( $group->id ); // Create an object $obj = new SocialGroup($group); self::$instances[$group->id] = $obj; $result[] = self::$instances[$group->id]; } if (!$result) { return false; } if (!$argumentIsArray && count($result) == 1) { return $result[0]; } return $result; }
/** * @see parent::loadQueryList() */ function loadQueryList($sql) { $ds = $this->_spec->ds; $cur = $ds->exec($sql); $list = array(); while ($row = $ds->fetchAssoc($cur)) { $newObject = new self(); // $this->_class >>>> "self" //$newObject->_ex_class_id = $this->_ex_class_id; //$newObject->setExClass(); $newObject->bind($row, false); $newObject->checkConfidential(); $newObject->updateFormFields(); $newObject->registerCache(); $list[$newObject->_id] = $newObject; } $ds->freeResult($cur); return $list; }
/** * Load Member Dashboard Prefs by uidNumber * * @param int $uidNumber Member uidNumber * @return object */ public static function loadForUser($uidNumber = null) { // get db $db = App::get('db'); // load prefs by userid $sql = "SELECT * FROM `#__xprofiles_dashboard_preferences` WHERE `uidNumber`=" . $db->quote($uidNumber) . " LIMIT 1"; $db->setQuery($sql); $data = $db->loadObject(); // create new instance of this object $object = new self(); // bind data if we have any if (isset($data)) { $object->bind($data); } // return object return $object; }
/** * Clone core folders and queries and assign * them to a given user ID * * @param integer $user_id User ID * @return array */ public function cloneCore($user_id = 0) { // Get all the default folders $folders = $this->find('list', array('user_id' => 0, 'sort' => 'ordering', 'sort_Dir' => 'asc', 'iscore' => 1)); $sq = new Query($this->_db); if (count($folders) <= 0) { $defaults = array(1 => array('Common', 'Mine', 'Custom'), 2 => array('Common', 'Mine')); foreach ($defaults as $iscore => $fldrs) { $i = 1; foreach ($fldrs as $fldr) { $f = new self($this->_db); $f->iscore = $iscore; $f->title = $fldr; $f->check(); $f->ordering = $i; $f->user_id = 0; $f->store(); switch ($f->alias) { case 'common': $j = $iscore == 1 ? $sq->populateDefaults('common', $f->id) : $sq->populateDefaults('commonnotacl', $f->id); break; case 'mine': $sq->populateDefaults('mine', $f->id); break; default: // Nothing for custom folder break; } $i++; if ($iscore == 1) { $folders[] = $f; } } } } $user_id = $user_id ?: User::get('id'); $fid = 0; // Loop through each folder foreach ($folders as $k => $folder) { // Copy the folder for the user $stqf = new self($this->_db); $stqf->bind($folder); $stqf->created_by = $user_id; $stqf->created = Date::toSql(); $stqf->id = null; $stqf->user_id = $user_id; $stqf->iscore = 0; $stqf->store(); $queries = $sq->find('list', array('folder_id' => $folder->id)); // Copy all the queries from the folder to the user foreach ($queries as $query) { $stq = new Query($this->_db); $stq->bind($query); $stq->created_by = $user_id; $stq->created = Date::toSql(); $stq->id = null; $stq->user_id = $user_id; $stq->folder_id = $stqf->get('id'); $stq->iscore = 0; $stq->store(); } // If the folder is "custom", get its ID if ($folder->alias == 'custom') { $fid = $stqf->get('id'); } $folders[$k] = $stqf; } if ($fid) { $this->_db->setQuery("UPDATE `#__support_queries` SET `folder_id`=" . $this->_db->quote($fid) . " WHERE `user_id`=" . $this->_db->quote($user_id) . " AND `iscore`=0 AND `folder_id`=0"); $this->_db->query(); } return $folders; }