コード例 #1
0
ファイル: category.php プロジェクト: pippogsm/UserIdeas
 /**
  * This method loads data about category from a database.
  *
  * <code>
  * $db         = JFactory::getDbo();
  * $categoryId = 1;
  *
  * $category   = new UserIdeasCategory();
  * $category->setDb($db);
  * $category->load($categoryId);
  * </code>
  */
 public function load($id)
 {
     $query = $this->db->getQuery(true);
     $query->select("a.title, a.description," . $query->concatenate(array("a.id", "a.alias"), ":") . " AS slug")->from($this->db->quoteName("#__categories", "a"))->where("a.id = " . (int) $id)->where("a.extension = " . $this->db->quote("com_userideas"));
     $this->db->setQuery($query);
     $result = $this->db->loadAssoc();
     if (!empty($result)) {
         $this->bind($result);
     }
 }
コード例 #2
0
 /**
  * Update schemas of com_gamification.
  *
  * @param array $results
  * @param JDatabaseDriver $db
  *
  * @throws Exception
  */
 protected function updateGamificationPlatform($results, $db)
 {
     $extensions = 'com_gamification';
     JLoader::import('Gamification.Version');
     $version = new Gamification\Version();
     if (version_compare($results[$extensions]['version_id'], $version->getShortVersion(), '<')) {
         $query = $db->getQuery(true);
         $query->update($db->quoteName('#__schemas'))->set($db->quoteName('version_id') . '=' . $db->quote($version->getShortVersion()))->where($db->quoteName('extension_id') . ' = ' . $db->quote($results[$extensions]['extension_id']));
         $db->setQuery($query);
         $db->execute();
         $msg = JText::sprintf('PLG_SYSTEM_DISTRIBUTION_MIGRATION_UPDATED_SCHEMAS_S', $extensions, $results[$extensions]['extension_id'], $results[$extensions]['version_id'], $version->getShortVersion());
         JFactory::getApplication()->enqueueMessage($msg);
     }
 }
コード例 #3
0
ファイル: Extensions.php プロジェクト: bellodox/PrismLibrary
 /**
  * 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;
 }
コード例 #4
0
 /**
  * Count project funders.
  *
  * @param array $data
  * @param array $options
  *
  * @throws \RuntimeException
  */
 public function handle(&$data, array $options = array())
 {
     $funders = array();
     $ids = ArrayHelper::getIds($data, 'id');
     if (count($ids) > 0) {
         $query = $this->db->getQuery(true);
         $query->select('a.project_id, COUNT(*) AS funders')->from($this->db->quoteName('#__crowdf_transactions', 'a'))->where('a.project_id  IN (' . implode(',', $ids) . ')')->where('(a.txn_status = ' . $this->db->quote('completed') . ' OR a.txn_status = ' . $this->db->quote('pending') . ')')->group($this->db->quoteName('project_id'));
         $this->db->setQuery($query);
         $funders = (array) $this->db->loadObjectList('project_id');
     }
     foreach ($data as $item) {
         $item->funders = array_key_exists($item->id, $funders) ? $funders[$item->id]->funders : 0;
     }
     unset($funders);
 }
コード例 #5
0
 protected function updateObject()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__vc_transactions"))->set($this->db->quoteName("units") . "=" . $this->db->quote($this->units))->set($this->db->quoteName("txn_id") . "=" . $this->db->quote($this->txn_id))->set($this->db->quoteName("txn_amount") . "=" . $this->db->quote($this->txn_amount))->set($this->db->quoteName("txn_currency") . "=" . $this->db->quote($this->txn_currency))->set($this->db->quoteName("txn_status") . "=" . $this->db->quote($this->txn_status))->set($this->db->quoteName("txn_date") . "=" . $this->db->quote($this->txn_date))->set($this->db->quoteName("service_provider") . "=" . $this->db->quote($this->service_provider))->set($this->db->quoteName("currency_id") . "=" . $this->db->quote($this->currency_id))->set($this->db->quoteName("sender_id") . "=" . $this->db->quote($this->sender_id))->set($this->db->quoteName("receiver_id") . "=" . $this->db->quote($this->receiver_id))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #6
0
ファイル: object.php プロジェクト: BillVGN/PortalPRP
	/**
	 * Method to increment the hits for a row if the necessary property/field exists.
	 *
	 * @return bool True on success.
	 *
	 * @internal param mixed $pk An optional primary key value to increment. If not set the instance property value is used.
	 *
	 * @since    K4.0
	 */
	public function hit()
	{
		$pk = null;

		// If there is no hits field, just return true.
		if (!property_exists($this, 'hits'))
		{
			return true;
		}

		$k= static::$tbl_keys;
		$pk = (is_null($pk)) ? $this->$k : $pk;

		// If no primary key is given, return false.
		if ($pk === null)
		{
			return false;
		}

		// Check the row in by primary key.
		$query = static::$db->getQuery(true);
		$query->update(static::$tbl);
		$query->set(static::$db->quoteName('hits') . ' = (' . static::$db->quoteName('hits') . ' + 1)');
		$query->where(static::$tbl_key . ' = ' . static::$db->quote($pk));
		static::$db->setQuery($query);
		static::$db->execute();

		// Set table values in the object.
		$this->hits++;

		return true;
	}
コード例 #7
0
ファイル: cookie.php プロジェクト: adjaika/J3Base
 /**
  * This is where we delete any authentication cookie when a user logs out
  *
  * @param   array  $options  Array holding options (length, timeToExpiration)
  *
  * @return  boolean  True on success
  *
  * @since   3.2
  */
 public function onUserAfterLogout($options)
 {
     // No remember me for admin
     if ($this->app->isAdmin()) {
         return false;
     }
     $cookieName = 'joomla_remember_me_' . JUserHelper::getShortHashedUserAgent();
     $cookieValue = $this->app->input->cookie->get($cookieName);
     // There are no cookies to delete.
     if (!$cookieValue) {
         return true;
     }
     $cookieArray = explode('.', $cookieValue);
     // Filter series since we're going to use it in the query
     $filter = new JFilterInput();
     $series = $filter->clean($cookieArray[1], 'ALNUM');
     // Remove the record from the database
     $query = $this->db->getQuery(true)->delete('#__user_keys')->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series));
     try {
         $this->db->setQuery($query)->execute();
     } catch (RuntimeException $e) {
         // We aren't concerned with errors from this query, carry on
     }
     // Destroy the cookie
     $this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain'));
     return true;
 }
コード例 #8
0
 /**
  * Stores the login data into the database
  *
  * @param   array $data Array holding data to be stored.
  *
  * @return bool
  * @since   1.0
  */
 public function storeInDatabase($data)
 {
     $query = $this->db->getQuery(true);
     $columns = array('userid', 'username', 'ip', 'timestamp');
     $values = $this->db->quote(array($data['userid'], $data['username'], $data['ip'], $data['timestamp']));
     $query->insert($this->db->quoteName('#__userlogin_tracking'))->columns($this->db->quoteName($columns))->values(implode(',', $values));
     $this->db->setQuery($query);
     try {
         $this->db->execute();
     } catch (Exception $e) {
         throw $e;
         // Do nothing
         return false;
     }
     return true;
 }
コード例 #9
0
 /**
  * Remember me method to run onAfterInitialise
  *
  * @return  boolean
  *
  * @since   1.5
  * @throws  InvalidArgumentException
  */
 public function onAfterInitialise()
 {
     // No remember me for admin
     if ($this->app->isAdmin()) {
         return false;
     }
     $user = JFactory::getUser();
     $this->app->rememberCookieLifetime = $this->lifetime;
     $this->app->rememberCookieSecure = $this->secure;
     $this->app->rememberCookieLength = $this->length;
     // Check for a cookie
     if ($user->get('guest') == 1) {
         // Create the cookie name and data
         $rememberArray = JUserHelper::getRememberCookieData();
         if ($rememberArray !== false) {
             if (count($rememberArray) != 3) {
                 // Destroy the cookie in the browser.
                 $this->app->input->cookie->set(end($rememberArray), false, time() - 42000, $this->app->get('cookie_path'), $this->app->get('cookie_domain'));
                 JLog::add('Invalid cookie detected.', JLog::WARNING, 'error');
                 return false;
             }
             list($privateKey, $series, $uastring) = $rememberArray;
             if (!JUserHelper::clearExpiredTokens($this)) {
                 JLog::add('Error in deleting expired cookie tokens.', JLog::WARNING, 'error');
             }
             // Find the matching record if it exists
             $query = $this->db->getQuery(true)->select($this->db->quoteName(array('user_id', 'token', 'series', 'time', 'invalid')))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($uastring))->order($this->db->quoteName('time') . ' DESC');
             $results = $this->db->setQuery($query)->loadObjectList();
             $countResults = count($results);
             // We have a user but a cookie that is not in the database, or it is invalid. This is a possible attack, so invalidate everything.
             if (($countResults === 0 || $results[0]->invalid != 0) && !empty($results[0]->user_id)) {
                 JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
                 JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_INVALIDATED_COOKIES', $user->username), JLog::WARNING, 'security');
                 // Possibly e-mail user and admin here.
                 return false;
             }
             // We have a user with one cookie with a valid series and a corresponding record in the database.
             if ($countResults === 1) {
                 if (substr($results[0]->token, 0, 4) === '$2y$') {
                     if (JCrypt::hasStrongPasswordSupport()) {
                         $match = password_verify($privateKey, $results[0]->token);
                     }
                 } else {
                     if (JCrypt::timingSafeCompare($results[0]->token, $privateKey)) {
                         $match = true;
                     }
                 }
                 if (empty($match)) {
                     JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
                     JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_LOGIN_FAILED', $user->username), JLog::WARNING, 'security');
                     return false;
                 }
                 // Set up the credentials array to pass to onUserAuthenticate
                 $credentials = array('username' => $results[0]->user_id);
                 return $this->app->login($credentials, array('silent' => true, 'lifetime' => $this->lifetime, 'secure' => $this->secure, 'length' => $this->length));
             }
         }
     }
     return false;
 }
コード例 #10
0
 /**
  * Load categories.
  *
  * <code>
  * $parentId = 2;
  *
  * $options = array(
  *    "offset" => 0,
  *    "limit" => 10,
  *    "order_by" => "a.name",
  *    "order_dir" => "DESC",
  * );
  *
  * $categories   = new Crowdfunding\Categories();
  * $categories->setDb(\JFactory::getDbo());
  *
  * $categories->load($parentId);
  * </code>
  *
  * @param null|int $parentId Parent ID or "root".
  * @param array $options
  *
  * @throws \RuntimeException
  */
 public function load($parentId = null, array $options = array())
 {
     $offset = array_key_exists('offset', $options) ? $options['offset'] : 0;
     $limit = array_key_exists('limit', $options) ? $options['limit'] : 0;
     $orderBy = array_key_exists('order_by', $options) ? $options['order_by'] : 'a.title';
     $orderDir = array_key_exists('order_dir', $options) ? $options['order_dir'] : 'ASC';
     $published = array_key_exists('state', $options) ? $options['state'] : null;
     $orderDir = strtoupper($orderDir);
     if (!in_array($orderDir, array('ASC', 'DESC'), true)) {
         $orderDir = 'ASC';
     }
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.title, a.alias, a.description, a.params, ' . $query->concatenate(array('a.id', 'a.alias'), ':') . ' AS slug')->from($this->db->quoteName('#__categories', 'a'))->where('a.extension = ' . $this->db->quote($this->_extension));
     if ($parentId !== null) {
         $query->where('a.parent_id = ' . (int) $parentId);
     }
     // Filter by state.
     if ($published === null) {
         $query->where('a.published IN (0,1)');
     } else {
         $query->where('a.published = ' . (int) $published);
     }
     $query->order($this->db->escape($this->db->quoteName($orderBy) . ' ' . $orderDir));
     $this->db->setQuery($query, (int) $offset, (int) $limit);
     $this->data = (array) $this->db->loadAssocList('id');
 }
コード例 #11
0
ファイル: session.php プロジェクト: bellodox/VirtualCurrency
 protected function updateObject()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__vc_paymentsessions"))->set($this->db->quoteName("user_id") . "=" . (int) $this->user_id)->set($this->db->quoteName("currency_id") . "=" . (int) $this->currency_id)->set($this->db->quoteName("amount") . "=" . $this->db->quote($this->amount))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #12
0
ファイル: account.php プロジェクト: bellodox/VirtualCurrency
 /**
  * Update the amount of the account.
  *
  * <code>
  *  // Get user account by account ID
  *  $accountId = 1;
  *
  *  $account   = new VirtualCurrencyAccount();
  *  $account->setDb(JFactory::getDbo());
  *  $account->load($accountId);
  *
  *  // Increase the amount and store the new value.
  *  $account->increaseAmount(50);
  *  $account->updateAmount();
  * </code>
  */
 public function updateAmount()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__vc_accounts"))->set($this->db->quoteName("amount") . "=" . $this->db->quote($this->amount))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #13
0
ファイル: user.php プロジェクト: xop32/Proof-of-Identity
 /**
  * Create user record in database.
  *
  * <code>
  * $data = array(
  *    "id"     => 1,
  *    "name"   => "John Dow",
  *    "state"  => 1,
  * );
  *
  * $user    = new IdentityProofUser(JFactory::getDbo());
  * $user->bind($data);
  * $user->createUser();
  * </code>
  */
 public function createUser()
 {
     $query = $this->db->getQuery(true);
     $query->insert($this->db->quoteName("#__identityproof_users"))->set($this->db->quoteName("id") . "=" . $this->db->quote($this->id))->set($this->db->quoteName("state") . "=" . $this->db->quote($this->state));
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #14
0
ファイル: project.php プロジェクト: phpsource/CrowdFunding
 /**
  * Update project funds record.
  *
  * <code>
  * $projectId = 1;
  * $finds = 50;
  *
  * $project   = new CrowdFundingProject(JFactory::getDbo());
  * $project->load($projectId);
  * $project->addFunds($finds);
  * $project->updateFunds();
  * </code>
  */
 public function updateFunds()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__crowdf_projects"))->set($this->db->quoteName("funded") . "=" . $this->db->quote($this->funded))->where($this->db->quoteName("id") . "=" . $this->db->quote($this->id));
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #15
0
 /**
  * Load transactions from database.
  *
  * <code>
  * $ids = array(1,2,3);
  * $options = array(
  *  "txn_status" => "completed"
  * );
  *
  * $transactions    = new CrowdFundingTransactions();
  * $transactions->setDb(JFactory::getDbo());
  * $transactions->load($ids, $options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $ids
  * @param array $options
  *
  * @throws UnexpectedValueException
  */
 public function load($ids, $options = array())
 {
     // Set the newest ids.
     if (!is_array($ids)) {
         throw new UnexpectedValueException(JText::_("LIB_CROWDFUNDING_TRANSACTIONS_IDS_ARRAY"));
     }
     JArrayHelper::toInteger($ids);
     if (!$ids) {
         return;
     }
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, " . "a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, " . "a.receiver_id, a.service_provider, a.reward_state")->from($this->db->quoteName("#__crowdf_transactions", "a"))->where("a.id IN ( " . implode(",", $ids) . " )");
     // Filter by status.
     $status = JArrayHelper::getValue($options, "txn_status", null, "cmd");
     if (!empty($status)) {
         $query->where("a.txn_status = " . $this->db->quote($status));
     }
     $this->db->setQuery($query);
     $results = $this->db->loadObjectList();
     // Convert JSON string into an array.
     if (!empty($results)) {
         foreach ($results as $key => $result) {
             if (!empty($result->extra_data)) {
                 $result->extra_data = json_decode($result->extra_data, true);
                 $results[$key] = $result;
             }
         }
     } else {
         $results = array();
     }
     $this->items = $results;
 }
コード例 #16
0
ファイル: map.php プロジェクト: BillVGN/PortalPRP
	/**
	 * Method to delete a row from the database table by primary key value.
	 *
	 * @param   int|array  $pk  An optional primary key value (or array of key=>value pairs) to delete.  If not set the instance property value is used.
	 *
	 * @return  boolean  True on success.
	 *
	 * @link    http://docs.joomla.org/JTable/delete
	 * @throws  UnexpectedValueException
	 */
	public function delete($pk = null)
	{
		$k = $this->_tbl_key;
		$pk = (is_null($pk)) ? $this->{$k} : $pk;

		// If no primary key is given, return false.
		if ($pk === null)
		{
			throw new UnexpectedValueException('Null primary key not allowed.');
		}

		// Turn pk into array.
		if (!is_array($pk))
		{
			$pk = array($k => (int) $pk);
		}

		// Delete the row by primary key.
		$query = $this->_db->getQuery(true);
		$query->delete();
		$query->from($this->_tbl);

		foreach ($pk as $key=>$value)
		{
			$query->where($key . ' = ' . $this->_db->quote($value));
		}

		$this->_db->setQuery($query);

		// Delete items.
		$this->_db->execute();

		return true;
	}
コード例 #17
0
ファイル: table.php プロジェクト: klas/joomla-cms
 /**
  * Method to check a row in if the necessary properties/fields exist.  Checking
  * a row in will allow other users the ability to edit the row.
  *
  * @param   mixed  $pk  An optional primary key value to check out.  If not set the instance property value is used.
  *
  * @return  boolean  True on success.
  *
  * @link    https://docs.joomla.org/JTable/checkIn
  * @since   11.1
  * @throws  UnexpectedValueException
  */
 public function checkIn($pk = null)
 {
     $checkedOutField = $this->getColumnAlias('checked_out');
     $checkedOutTimeField = $this->getColumnAlias('checked_out_time');
     // If there is no checked_out or checked_out_time field, just return true.
     if (!property_exists($this, $checkedOutField) || !property_exists($this, $checkedOutTimeField)) {
         return true;
     }
     if (is_null($pk)) {
         $pk = array();
         foreach ($this->_tbl_keys as $key) {
             $pk[$this->{$key}] = $this->{$key};
         }
     } elseif (!is_array($pk)) {
         $pk = array($this->_tbl_key => $pk);
     }
     foreach ($this->_tbl_keys as $key) {
         $pk[$key] = empty($pk[$key]) ? $this->{$key} : $pk[$key];
         if ($pk[$key] === null) {
             throw new UnexpectedValueException('Null primary key not allowed.');
         }
     }
     // Check the row in by primary key.
     $query = $this->_db->getQuery(true)->update($this->_tbl)->set($this->_db->quoteName($checkedOutField) . ' = 0')->set($this->_db->quoteName($checkedOutTimeField) . ' = ' . $this->_db->quote($this->_db->getNullDate()));
     $this->appendPrimaryKeys($query, $pk);
     $this->_db->setQuery($query);
     // Check for a database error.
     $this->_db->execute();
     // Set table values in the object.
     $this->{$checkedOutField} = 0;
     $this->{$checkedOutTimeField} = '';
     return true;
 }
コード例 #18
0
 /**
  * Load user data
  *
  * <code>
  * $keys = array(
  *     'user_id' => $userId
  * );
  *
  * $profile = new Prism\Integration\Profile\Socialcommunity(\JFactory::getDbo());
  * $profile->load($keys);
  * </code>
  * 
  * @param array $keys
  * @param array $options
  */
 public function load($keys, array $options = array())
 {
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.user_id, a.image_icon, a.image_small, a.image_square, a.image, a.active, ' . $query->concatenate(array('a.id', 'a.alias'), ':') . ' AS slug, ' . 'b.name as location, b.country_code')->from($this->db->quoteName('#__itpsc_profiles', 'a'))->leftJoin($this->db->quoteName('#__itpsc_locations', 'b') . ' ON a.location_id = b.id');
     // Filter by keys.
     if (!is_array($keys)) {
         $query->where('a.id = ' . (int) $keys);
     } else {
         foreach ($keys as $key => $value) {
             $query->where($this->db->quoteName('a.' . $key) . ' = ' . $this->db->quote($value));
         }
     }
     $this->db->setQuery($query);
     $result = (array) $this->db->loadAssoc();
     $this->bind($result);
 }
コード例 #19
0
ファイル: stats.php プロジェクト: SysBind/joomla-cms
 /**
  * Save the plugin parameters
  *
  * @return  boolean
  *
  * @since   3.5
  */
 private function saveParams()
 {
     // Update params
     $this->params->set('lastrun', time());
     $this->params->set('unique_id', $this->getUniqueId());
     $interval = (int) $this->params->get('interval', 12);
     $this->params->set('interval', $interval ? $interval : 12);
     $query = $this->db->getQuery(true)->update($this->db->quoteName('#__extensions'))->set($this->db->quoteName('params') . ' = ' . $this->db->quote($this->params->toString('JSON')))->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin'))->where($this->db->quoteName('folder') . ' = ' . $this->db->quote('system'))->where($this->db->quoteName('element') . ' = ' . $this->db->quote('stats'));
     try {
         // Lock the tables to prevent multiple plugin executions causing a race condition
         $this->db->lockTable('#__extensions');
     } catch (Exception $e) {
         // If we can't lock the tables it's too risky to continue execution
         return false;
     }
     try {
         // Update the plugin parameters
         $result = $this->db->setQuery($query)->execute();
         $this->clearCacheGroups(array('com_plugins'), array(0, 1));
     } catch (Exception $exc) {
         // If we failed to execute
         $this->db->unlockTables();
         $result = false;
     }
     try {
         // Unlock the tables after writing
         $this->db->unlockTables();
     } catch (Exception $e) {
         // If we can't lock the tables assume we have somehow failed
         $result = false;
     }
     return $result;
 }
コード例 #20
0
ファイル: User.php プロジェクト: pashakiz/crowdf
 /**
  * Count the number of campaigns in a period.
  * If star date and end date are not provides, the system will get default values.
  * The default values will be the beginning of the year and the end of the year.
  *
  * <code>
  * $usersId = 1;
  *
  * $statistics        = new Crowdfunding\Statistics\Users(\JFactory::getDbo(), $usersId);
  * $numberOfCampaigns = $statistics->getNumberOfActiveCampaigns();
  * </code>
  *
  * @param string $startDate
  * @param string $endDate
  *
  * @return int
  */
 public function getNumberOfCampaignsInPeriod($startDate = null, $endDate = null)
 {
     // Set default start date.
     if (!(int) $startDate) {
         $date = new Prism\Date();
         $date = $date->getBeginOfYear();
         $startDate = $date->toSql();
     }
     // Set default end date.
     if (!(int) $endDate) {
         $date = new Prism\Date();
         $date = $date->getEndOfYear();
         $endDate = $date->toSql();
     }
     $startDate = new \JDate($startDate);
     $endDate = new \JDate($endDate);
     $query = $this->db->getQuery(true);
     $query->select("COUNT(*) AS number")->from($this->db->quoteName("#__crowdf_projects", "a"))->where("a.user_id = " . (int) $this->id)->where("a.funding_start >= " . $this->db->quote($startDate->toSql()))->where("a.funding_start <= " . $this->db->quote($endDate->toSql()));
     $this->db->setQuery($query, 0, 1);
     $result = $this->db->loadResult();
     if (!$result) {
         $result = 0;
     }
     return $result;
 }
コード例 #21
0
ファイル: table.php プロジェクト: houzhenggang/cobalt
 /**
  * Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
  * Negative numbers move the row up in the sequence and positive numbers move it down.
  *
  * @param integer $delta The direction and magnitude to move the row in the ordering sequence.
  * @param string  $where WHERE clause to use for limiting the selection of rows to compact the
  *                           ordering values.
  *
  * @return mixed Boolean  True on success.
  *
  * @link    http://docs.joomla.org/JTable/move
  * @since   11.1
  * @throws UnexpectedValueException
  */
 public function move($delta, $where = '')
 {
     // If there is no ordering field set an error and return false.
     if (!property_exists($this, 'ordering')) {
         throw new UnexpectedValueException(sprintf('%s does not support ordering.', get_class($this)));
     }
     // If the change is none, do nothing.
     if (empty($delta)) {
         return true;
     }
     $k = $this->_tbl_key;
     $row = null;
     $query = $this->_db->getQuery(true);
     // Select the primary key and ordering values from the table.
     $query->select($this->_tbl_key . ', ordering');
     $query->from($this->_tbl);
     // If the movement delta is negative move the row up.
     if ($delta < 0) {
         $query->where('ordering < ' . (int) $this->ordering);
         $query->order('ordering DESC');
     } elseif ($delta > 0) {
         $query->where('ordering > ' . (int) $this->ordering);
         $query->order('ordering ASC');
     }
     // Add the custom WHERE clause if set.
     if ($where) {
         $query->where($where);
     }
     // Select the first row with the criteria.
     $this->_db->setQuery($query, 0, 1);
     $row = $this->_db->loadObject();
     // If a row is found, move the item.
     if (!empty($row)) {
         // Update the ordering field for this instance to the row's ordering value.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('ordering = ' . (int) $row->ordering);
         $query->where($this->_tbl_key . ' = ' . $this->_db->quote($this->{$k}));
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Update the ordering field for the row to this instance's ordering value.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('ordering = ' . (int) $this->ordering);
         $query->where($this->_tbl_key . ' = ' . $this->_db->quote($row->{$k}));
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Update the instance value.
         $this->ordering = $row->ordering;
     } else {
         // Update the ordering field for this instance.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('ordering = ' . (int) $this->ordering);
         $query->where($this->_tbl_key . ' = ' . $this->_db->quote($this->{$k}));
         $this->_db->setQuery($query);
         $this->_db->execute();
     }
     return true;
 }
コード例 #22
0
 /**
  * Function to retrieve the full article object
  *
  * @param   object  $article  The content object
  *
  * @return  object  The full content object
  *
  * @since   1.0
  */
 private function loadArticle($article)
 {
     // Query the database for the article text
     $query = $this->db->getQuery(true)->select('*')->from($this->db->quoteName('#__content'))->where($this->db->quoteName('introtext') . ' = ' . $this->db->quote($article->text));
     $this->db->setQuery($query);
     return $this->db->loadObject();
 }
コード例 #23
0
ファイル: session.php プロジェクト: phpsource/CrowdFunding
 protected function updateObject()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__crowdf_payment_sessions"))->set($this->db->quoteName("user_id") . "=" . $this->db->quote($this->user_id))->set($this->db->quoteName("project_id") . "=" . $this->db->quote($this->project_id))->set($this->db->quoteName("reward_id") . "=" . $this->db->quote($this->reward_id))->set($this->db->quoteName("record_date") . "=" . $this->db->quote($this->record_date))->set($this->db->quoteName("txn_id") . "=" . $this->db->quote($this->txn_id))->set($this->db->quoteName("token") . "=" . $this->db->quote($this->token))->set($this->db->quoteName("gateway") . "=" . $this->db->quote($this->gateway))->set($this->db->quoteName("auser_id") . "=" . $this->db->quote($this->auser_id))->set($this->db->quoteName("intention_id") . "=" . $this->db->quote($this->intention_id))->where($this->db->quoteName("id") . "=" . $this->db->quote($this->id));
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #24
0
	/**
	 * Tests the JDatabaseDriver::quote method.
	 *
	 * @return  void
	 *
	 * @since   11.4
	 */
	public function testQuoteFloat()
	{
		$this->assertThat(
			$this->db->quote(3.14),
			$this->equalTo("'-3.14-'"),
			'Tests handling of float with escaping (default).'
		);
	}
コード例 #25
0
ファイル: contact.php プロジェクト: adjaika/J3Base
 /**
  * Retrieve Contact
  *
  * @param   int  $created_by  Id of the user who created the contact
  *
  * @return  mixed|null|integer
  */
 protected function getContactId($created_by)
 {
     static $contacts = array();
     if (isset($contacts[$created_by])) {
         return $contacts[$created_by];
     }
     $query = $this->db->getQuery(true);
     $query->select('MAX(contact.id) AS contactid');
     $query->from($this->db->quoteName('#__contact_details', 'contact'));
     $query->where('contact.published = 1');
     $query->where('contact.user_id = ' . (int) $created_by);
     if (JLanguageMultilang::isEnabled() == 1) {
         $query->where('(contact.language in ' . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' . ' OR contact.language IS NULL)');
     }
     $this->db->setQuery($query);
     $contacts[$created_by] = $this->db->loadResult();
     return $contacts[$created_by];
 }
コード例 #26
0
ファイル: intention.php プロジェクト: phpsource/CrowdFunding
 protected function insertObject()
 {
     $recordDate = !$this->record_date ? "NULL" : $this->db->quote($this->record_date);
     $query = $this->db->getQuery(true);
     $query->insert($this->db->quoteName("#__crowdf_intentions"))->set($this->db->quoteName("user_id") . "=" . $this->db->quote($this->user_id))->set($this->db->quoteName("project_id") . "=" . $this->db->quote($this->project_id))->set($this->db->quoteName("reward_id") . "=" . $this->db->quote($this->reward_id))->set($this->db->quoteName("record_date") . "=" . $recordDate)->set($this->db->quoteName("txn_id") . "=" . $this->db->quote($this->txn_id))->set($this->db->quoteName("token") . "=" . $this->db->quote($this->token))->set($this->db->quoteName("gateway") . "=" . $this->db->quote($this->gateway))->set($this->db->quoteName("auser_id") . "=" . $this->db->quote($this->auser_id))->set($this->db->quoteName("session_id") . "=" . $this->db->quote($this->session_id));
     $this->db->setQuery($query);
     $this->db->execute();
     $this->id = $this->db->insertid();
 }
コード例 #27
0
 /**
  * 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;
 }
コード例 #28
0
ファイル: currency.php プロジェクト: bellodox/VirtualCurrency
 protected function updateObject()
 {
     $description = !$this->description ? "NULL" : $this->db->quote($this->description);
     $params = !$this->params ? "NULL" : $this->db->quote($this->params);
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__vc_currencies"))->set($this->db->quoteName("title") . "=" . $this->db->quote($this->title))->set($this->db->quoteName("description") . "=" . $description)->set($this->db->quoteName("code") . "=" . (int) $this->code)->set($this->db->quoteName("symbol") . "=" . (int) $this->symbol)->set($this->db->quoteName("params") . "=" . $params)->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #29
0
ファイル: type.php プロジェクト: educakanchay/kanchay
 /**
  * Get the Content Type from the alias
  *
  * @param   string  $typeAlias  The alias for the type
  *
  * @return  object  The UCM Type data
  *
  * @since   3.2
  */
 public function getTypeByAlias($typeAlias = null)
 {
     $query = $this->db->getQuery(true);
     $query->select('ct.*');
     $query->from($this->db->quoteName('#__content_types', 'ct'));
     $query->where($this->db->quoteName('ct.type_alias') . ' = ' . $this->db->quote($typeAlias));
     $this->db->setQuery($query);
     $type = $this->db->loadObject();
     return $type;
 }
コード例 #30
0
ファイル: currency.php プロジェクト: phpsource/CrowdFunding
 /**
  * Load currency data from database.
  *
  * <code>
  * $currencyCode = "EUR";
  *
  * $currency   = new CrowdFundingCurrency();
  * $currency->setDb(JFactory::getDbo());
  *
  * $currency->loadByAbbr($currencyCode);
  * </code>
  *
  * @param string $abbr
  */
 public function loadByAbbr($abbr)
 {
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.title, a.abbr, a.symbol, a.position")->from($this->db->quoteName("#__crowdf_currencies", "a"))->where("a.abbr = " . $this->db->quote($abbr));
     $this->db->setQuery($query);
     $result = $this->db->loadAssoc();
     if (!$result) {
         $result = array();
     }
     $this->bind($result);
 }