/** * Return a list with names of enabled extensions. * * <code> * $extensionsNames = array( * "com_crowdfunding", * "com_gamification" * ); * * $extensions = new Prism\Extensions(\JFactory::getDbo(), $extensionsNames); * * $enabled = $extensions->getEnabled(); * </code> * * @return array */ public function getEnabled() { $extensions = array(); if (!$this->extensions) { return $extensions; } foreach ($this->extensions as $extension) { $extensions[] = $this->db->quote($extension); } $query = $this->db->getQuery(true); $query->select('a.element')->from($this->db->quoteName('#__extensions', 'a'))->where('a.element IN (' . implode(',', $extensions) . ')')->where('a.enabled = 1'); $this->db->setQuery($query); $extensions = (array) $this->db->loadColumn(); return $extensions; }
/** * Return a list with names of enabled extensions. * * <code> * $extensionsNames = array( * "com_crowdfunding", * "com_gamification" * ); * * $extensions = new ITPrismExtensions(JFactory::getDbo(), $extensionsNames); * * $enabled = $extensions->getEnabled(); * </code> * * @return array */ public function getEnabled() { $extensions = array(); if (!$this->extensions) { return $extensions; } foreach ($this->extensions as $extension) { $extensions[] = $this->db->quote($extension); } $query = $this->db->getQuery(true); $query->select("a.element")->from($this->db->quoteName("#__extensions", "a"))->where("a.element IN (" . implode(",", $extensions) . ")")->where("a.enabled = 1"); $this->db->setQuery($query); $extensions = $this->db->loadColumn(); if (!$extensions) { $extensions = array(); } return $extensions; }
/** * Return list with followed campaigns. * * <code> * $userId = 1; * * $user = new Crowdfunding\User(\JFactory::getDbo()); * $user->load($userId) * * $followedCampaigns = $user->getFollowed() * </code> * * @return array */ public function getFollowed() { if (is_null($this->followed)) { $query = $this->db->getQuery(true); $query->select("a.project_id")->from($this->db->quoteName("#__crowdf_followers", "a"))->where("a.user_id = " . (int) $this->id); $this->db->setQuery($query); $this->followed = (array) $this->db->loadColumn(); } return $this->followed; }
/** * Method to load all mapped values from the database by primary key and bind the fields * to the JTable instance properties. * * @param mixed $keys An optional primary key value to load the row by, or an array of fields to match. If not * set the instance property value is used. * @param boolean $reset True to reset the default values before loading the new row. * * @return boolean True if successful. False if no rows were found. * * @link http://docs.joomla.org/JTable/load * @throws RuntimeException * @throws UnexpectedValueException */ public function load($keys = null, $reset = true) { if (empty($keys)) { // If empty, use the value of the current key $keyName = $this->_tbl_key; $keyValue = $this->{$keyName}; // If empty primary key there's is no need to load anything if (empty($keyValue)) { return true; } $keys = array($keyName => $keyValue); } elseif (!is_array($keys)) { // Load by primary key. $keys = array($this->_tbl_key => $keys); } if ($reset) { $this->reset(); } // Initialise the query. $query = $this->_db->getQuery(true); $query->select($this->_tbl_mapped); $query->from($this->_tbl); $fields = array_keys($this->getProperties()); foreach ($keys as $field => $value) { // Check that $field is in the table. if (!in_array($field, $fields)) { throw new UnexpectedValueException(sprintf('Missing field in database: %s   %s.', get_class($this), $field)); } // Add the search tuple to the query. $this->{$field} = $value; $query->where($this->_db->quoteName($field) . ' = ' . $this->_db->quote($value)); } $this->_db->setQuery($query); $mapName = $this->_tbl_mapped; $this->{$mapName} = (array) $this->_db->loadColumn(); return !empty($this->{$mapName}); }
/** * Method to handle any login logic and report back to the subject. * * @param array $user Holds the user data. * @param array $options Array holding options (remember, autoregister, group). * * @return boolean True on success. * * @since 1.5 */ public function onUserLogin($user, $options = array()) { $menu = $this->app->getMenu(); if ($this->app->isSite() && $this->params->get('automatic_change', 1)) { $assoc = JLanguageAssociations::isEnabled(); $lang_code = $user['language']; if (empty($lang_code)) { $lang_code = $this->default_lang; } // Get a 1-dimensional array of published language codes $query = $this->db->getQuery(true)->select($this->db->quoteName('a.lang_code'))->from($this->db->quoteName('#__languages', 'a'))->where($this->db->quoteName('published') . ' = 1'); $this->db->setQuery($query); $lang_codes = $this->db->loadColumn(); // The user language has been deleted/disabled or the related content language does not exist/has been unpublished // or the related home page does not exist/has been unpublished if (!array_key_exists($lang_code, MultilangstatusHelper::getSitelangs()) || !in_array($lang_code, $lang_codes) || !array_key_exists($lang_code, MultilangstatusHelper::getHomepages())) { $lang_code = $this->current_lang; } // Try to get association from the current active menu item $active = $menu->getActive(); $foundAssociation = false; if ($active) { if ($assoc) { $associations = MenusHelper::getAssociations($active->id); } if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) { $associationItemid = $associations[$lang_code]; $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $associationItemid); $foundAssociation = true; } elseif ($active->home) { // We are on a Home page, we redirect to the user site language home page $item = $menu->getDefault($lang_code); if ($item && $item->language != $active->language && $item->language != '*') { $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $item->id); $foundAssociation = true; } } } if ($foundAssociation && $lang_code != $this->current_lang) { // Change language. $this->current_lang = $lang_code; // Create a cookie. $this->setLanguageCookie($lang_code); // Change the language code. JFactory::getLanguage()->setLanguage($lang_code); } } }
/** * Load an array of single field results into an array * * @param int $offset The row offset to use to build the result array * @return array The array with the result (empty in case of error) * * @throws \RuntimeException */ public function loadResultArray($offset = 0) { return $this->_nullToArray($this->_db->loadColumn($offset)); }
/** * Load an array of single field results into an array */ function loadResultArray($numinarray = 0) { if (checkJversion() >= 2) { $result = $this->_db->loadColumn($numinarray); } else { $result = $this->_db->loadResultArray($numinarray); } return $this->_nullToArray($result); }