コード例 #1
0
ファイル: extra.php プロジェクト: phpsource/CrowdFunding
 /**
  * Remove an extra image from database and file system.
  *
  * <code>
  * $imageId = 1;
  * $imagesFolder = "/.../folder";
  *
  * $image   = new CrowdFundingImageRemoverExtra(JFactory::getDbo(), $image, $imagesFolder);
  * $image->remove();
  * </code>
  */
 public function remove()
 {
     // Get the image
     $query = $this->db->getQuery(true);
     $query->select("a.image, a.thumb")->from($this->db->quoteName("#__crowdf_images", "a"))->where("a.id = " . (int) $this->imageId);
     $this->db->setQuery($query);
     $row = $this->db->loadObject();
     if (!empty($row)) {
         // Remove the image from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->image);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Remove the thumbnail from the filesystem
         $file = JPath::clean($this->imagesFolder . DIRECTORY_SEPARATOR . $row->thumb);
         if (JFile::exists($file)) {
             JFile::delete($file);
         }
         // Delete the record
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName("#__crowdf_images"))->where($this->db->quoteName("id") . " = " . (int) $this->imageId);
         $this->db->setQuery($query);
         $this->db->execute();
     }
 }
コード例 #2
0
 /**
  * Remove all sessions for the user name
  *
  * Method is called after user data is deleted from the database
  *
  * @param   array   $user    Holds the user data
  * @param   boolean $success True if user was successfully stored in the database
  * @param   string  $msg     Message
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onUserAfterDelete($user, $success, $msg)
 {
     $userId = Joomla\Utilities\ArrayHelper::getValue($user, 'id', 0, 'int');
     if (!$success or !$userId) {
         return false;
     }
     // Remove profile images.
     $profile = new Socialcommunity\Profile\Profile($this->db);
     $profile->load(array('user_id' => $userId));
     if ($profile->getId()) {
         // Remove profile record.
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName('#__itpsc_profiles'))->where($this->db->quoteName('user_id') . '=' . (int) $userId);
         $this->db->setQuery($query);
         $this->db->execute();
         // Remove profile images.
         $params = JComponentHelper::getParams('com_socialcommunity');
         /** @var $params Joomla\Registry\Registry */
         jimport('Prism.libs.init');
         $filesystemHelper = new Prism\Filesystem\Helper($params);
         $mediaFolder = $filesystemHelper->getMediaFolder($userId);
         $filesystem = $filesystemHelper->getFilesystem();
         $profile->removeImages($filesystem, $mediaFolder);
     }
     return true;
 }
コード例 #3
0
 /**
  * Execute the query
  *
  * @param  string                            $sql  The query (optional, it will use the setQuery one otherwise)
  * @return \mysqli_result|\resource|boolean        A database resource if successful, FALSE if not.
  *
  * @throws  \RuntimeException
  */
 public function query($sql = null)
 {
     if ($sql !== null) {
         $this->setQuery($sql);
     }
     return $this->_db->execute();
 }
コード例 #4
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;
	}
コード例 #5
0
 /**
  * Register a hit on a record
  *
  * @param   integer  $oid  The primary key value of the record
  * @param   boolean  $log  Should I log the hit?
  *
  * @return  boolean  True on success
  */
 public function hit($oid = null, $log = false)
 {
     if (!$this->onBeforeHit($oid, $log)) {
         return false;
     }
     // If there is no hits field, just return true.
     $hits_field = $this->getColumnAlias('hits');
     if (!in_array($hits_field, $this->getKnownFields())) {
         return true;
     }
     $k = $this->_tbl_key;
     $pk = is_null($oid) ? $this->{$k} : $oid;
     // If no primary key is given, return false.
     if ($pk === null) {
         $result = false;
     } else {
         // Check the row in by primary key.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set($this->_db->qn($hits_field) . ' = (' . $this->_db->qn($hits_field) . ' + 1)');
         $query->where($this->_tbl_key . ' = ' . $this->_db->q($pk));
         $this->_db->setQuery($query);
         $this->_db->execute();
         // Set table values in the object.
         $this->hits++;
         $result = true;
     }
     if ($result) {
         $result = $this->onAfterHit($oid);
     }
     return $result;
 }
コード例 #6
0
ファイル: item.php プロジェクト: pippogsm/UserIdeas
 protected function storeVotes()
 {
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__uideas_items"))->set($this->db->quoteName("votes") . "=" . (int) $this->votes)->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #7
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();
 }
コード例 #8
0
ファイル: table.php プロジェクト: deenison/joomla-cms
 /**
  * Delete a record
  *
  * @param   integer $oid  The primary key value of the item to delete
  *
  * @throws  UnexpectedValueException
  *
  * @return  boolean  True on success
  */
 public function delete($oid = null)
 {
     if ($oid) {
         $this->load($oid);
     }
     $k = $this->_tbl_key;
     $pk = !$oid ? $this->{$k} : $oid;
     // If no primary key is given, return false.
     if (!$pk) {
         throw new UnexpectedValueException('Null primary key not allowed.');
     }
     // Execute the logic only if I have a primary key, otherwise I could have weird results
     if (!$this->onBeforeDelete($oid)) {
         return false;
     }
     // Delete the row by primary key.
     $query = $this->_db->getQuery(true);
     $query->delete();
     $query->from($this->_tbl);
     $query->where($this->_tbl_key . ' = ' . $this->_db->q($pk));
     $this->_db->setQuery($query);
     $this->_db->execute();
     $result = $this->onAfterDelete($oid);
     return $result;
 }
コード例 #9
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;
	}
コード例 #10
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;
 }
コード例 #11
0
ファイル: base.php プロジェクト: prox91/joomla-dev
 /**
  * Unmap two contnet
  *
  * @param   string  $content_id1  The id of content 1
  * @param   string  $content_id2  The id of content 2
  *
  * @return  void
  *
  * @since   1.0
  */
 public function unmap($content_id1, $content_id2 = null)
 {
     $contentType = $this->state->get('content.type');
     // Check if the content type is set.
     if (empty($contentType)) {
         // Get the content type for the id.
         if (!is_null($content_id2)) {
             $results = $this->getTypes($content_id2);
             // Assert that the content type was found.
             if (empty($results[$content_id2])) {
                 throw new UnexpectedValueException(sprintf('%s->getItem() could not find the content type for item %s.', get_class($this), $content_id2));
             }
             // Set the content type alias.
             $contentType = $results[$content_id2]->type;
         } else {
             throw new UnexpectedValueException(sprintf('%s->getItem() could not find the content type for item %s.', get_class($this), $content_id2));
         }
     }
     $query = $this->db->getQuery(true);
     $query->clear();
     $query->delete();
     $query->from($this->db->quoteName('#__content_' . $contentType . '_map'));
     $query->where($this->db->quoteName('content_id') . '=' . $content_id1);
     if (!is_null($content_id2)) {
         $query->where($this->db->quoteName('tag_id') . '=' . $content_id2);
     }
     $this->db->setQuery($query);
     try {
         $this->db->execute();
     } catch (Exception $er) {
         return false;
     }
     return true;
 }
コード例 #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
ファイル: importer.php プロジェクト: adjaika/J3Base
 /**
  * Merges the incoming structure definition with the existing structure.
  *
  * @return  void
  *
  * @note    Currently only supports XML format.
  * @since   13.1
  * @throws  RuntimeException on error.
  */
 public function mergeStructure()
 {
     $prefix = $this->db->getPrefix();
     $tables = $this->db->getTableList();
     if ($this->from instanceof SimpleXMLElement) {
         $xml = $this->from;
     } else {
         $xml = new SimpleXMLElement($this->from);
     }
     // Get all the table definitions.
     $xmlTables = $xml->xpath('database/table_structure');
     foreach ($xmlTables as $table) {
         // Convert the magic prefix into the real table name.
         $tableName = (string) $table['name'];
         $tableName = preg_replace('|^#__|', $prefix, $tableName);
         if (in_array($tableName, $tables)) {
             // The table already exists. Now check if there is any difference.
             if ($queries = $this->getAlterTableSql($xml->database->table_structure)) {
                 // Run the queries to upgrade the data structure.
                 foreach ($queries as $query) {
                     $this->db->setQuery((string) $query);
                     $this->db->execute();
                 }
             }
         } else {
             // This is a new table.
             $sql = $this->xmlToCreate($table);
             $this->db->setQuery((string) $sql);
             $this->db->execute();
         }
     }
 }
コード例 #15
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();
 }
コード例 #16
0
ファイル: session.php プロジェクト: phpsource/CrowdFunding
 /**
  * Remove a payment session record from database.
  *
  * <code>
  * $keys = (
  *  "user_id"  => 2,
  *  "intention_id" => 3
  * );
  *
  * $paymentSession   = new CrowdFundingPaymentSession(JFactory::getDbo());
  * $paymentSession->load($keys);
  * $paymentSession->delete();
  * </code>
  */
 public function delete()
 {
     $query = $this->db->getQuery(true);
     $query->delete($this->db->quoteName("#__crowdf_payment_sessions"))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
     $this->reset();
 }
コード例 #17
0
 /**
  * Update reward state to SENT or NOT SENT.
  *
  * <code>
  * $keys = array(
  *  "id" = 1,
  *  "receiver_id" => 2
  * );
  *
  * $transaction    = new CrowdFundingTransaction(JFactory::getDbo());
  * $transaction->load($keys);
  *
  * // 0 = NOT SENT, 1 = SENT
  * $transaction->updateRewardState(CrowdFundingConstants::SENT);
  * </code>
  *
  * @param integer $state
  */
 public function updateRewardState($state)
 {
     $state = !$state ? 0 : 1;
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__crowdf_transactions"))->set($this->db->quoteName("reward_state") . " = " . (int) $state)->where($this->db->quoteName("id") . " = " . (int) $this->id)->where($this->db->quoteName("receiver_id") . " = " . (int) $this->receiver_id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #18
0
ファイル: table.php プロジェクト: ZerGabriel/joomla-platform
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table.  The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param   mixed    $pks     An optional array of primary key values to update.
  *                            If not set the instance property value is used.
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published]
  * @param   integer  $userId  The user id of the user performing the operation.
  *
  * @return  boolean  True on success; false if $pks is empty.
  *
  * @link    http://docs.joomla.org/JTable/publish
  * @since   11.1
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_keys;
     if (!is_null($pks)) {
         foreach ($pks as $key => $pk) {
             if (!is_array($pk)) {
                 $pks[$key] = array($this->_tbl_key => $pk);
             }
         }
     }
     $userId = (int) $userId;
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         $pk = array();
         foreach ($this->_tbl_keys as $key) {
             if ($this->{$key}) {
                 $pk[$this->{$key}] = $this->{$key};
             } else {
                 return false;
             }
         }
         $pks = array($pk);
     }
     foreach ($pks as $pk) {
         // Update the publishing state for rows with the given primary keys.
         $query = $this->_db->getQuery(true);
         $query->update($this->_tbl);
         $query->set('published = ' . (int) $state);
         // Determine if there is checkin support for the table.
         if (property_exists($this, 'checked_out') || property_exists($this, 'checked_out_time')) {
             $query->where('(checked_out = 0 OR checked_out = ' . (int) $userId . ')');
             $checkin = true;
         } else {
             $checkin = false;
         }
         // Build the WHERE clause for the primary keys.
         $this->appendPrimaryKeys($query, $pk);
         $this->_db->setQuery($query);
         $this->_db->execute();
         // If checkin is supported and all rows were adjusted, check them in.
         if ($checkin && count($pks) == $this->_db->getAffectedRows()) {
             $this->checkin($pk);
         }
         $ours = true;
         foreach ($this->_tbl_keys as $key) {
             if ($this->{$key} != $pk[$key]) {
                 $ours = false;
             }
         }
         if ($ours) {
             $this->published = $state;
         }
     }
     $this->setError('');
     return true;
 }
コード例 #19
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();
 }
コード例 #20
0
ファイル: Remover.php プロジェクト: pashakiz/crowdf
 /**
  * Remove an extra image from database and file system.
  *
  * <code>
  * $fileId = 1;
  * $filesFolder = "/.../folder";
  *
  * $file   = new CrowdfundingFiles\File\Remover(JFactory::getDbo(), $fileId, $mediaFolder);
  * $file->remove();
  * </code>
  */
 public function remove()
 {
     // Get the image
     $query = $this->db->getQuery(true);
     $query->select("a.filename")->from($this->db->quoteName("#__cffiles_files", "a"))->where("a.id = " . (int) $this->fileId);
     $this->db->setQuery($query, 0, 1);
     $fileName = $this->db->loadResult();
     if (!empty($fileName)) {
         // Remove the file from the filesystem
         $file = \JPath::clean($this->mediaFolder . DIRECTORY_SEPARATOR . $fileName);
         if (\JFile::exists($file)) {
             \JFile::delete($file);
         }
         // Delete the record
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName("#__cffiles_files"))->where($this->db->quoteName("id") . " = " . (int) $this->fileId);
         $this->db->setQuery($query);
         $this->db->execute();
     }
 }
コード例 #21
0
ファイル: Reward.php プロジェクト: bharatthakkar/CrowdFunding
 /**
  * Set the reward state as trashed.
  *
  * <code>
  * $rewardId  = 1;
  *
  * $reward    = new Crowdfunding\Reward(\JFactory::getDbo());
  * $reward->load($rewardId);
  *
  * $reward->trash();
  * </code>
  */
 public function trash()
 {
     if (!$this->id) {
         throw new \RuntimeException("LIB_CROWDFUNDING_INVALID_REWARD");
     }
     // Set the state to "trashed" value.
     $this->published = Prism\Constants::TRASHED;
     $query = $this->db->getQuery(true);
     $query->update($this->db->quoteName("#__crowdf_rewards"))->set($this->db->quoteName("published") . "=" . $this->db->quote($this->published))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #22
0
ファイル: JomSocial.php プロジェクト: bellodox/PrismLibrary
 /**
  * Store information about activity.
  *
  * <code>
  * $userId = 1;
  * $content = "...";
  *
  * $activity = new Prism\Integration\Activity\JomSocial($userId, $content);
  * $activity->setDb(JFactory::getDbo());
  * $activity->store();
  * </code>
  *
  * @throws \RuntimeException
  */
 public function store()
 {
     if (!$this->app) {
         throw new \RuntimeException(\JText::_('LIB_PRISM_ERROR_INVALID_JOMSOCIAL_APP'));
     }
     $query = $this->db->getQuery(true);
     $date = new \JDate();
     $query->insert($this->db->quoteName('#__community_activities'))->set($this->db->quoteName('actor') . '=' . (int) $this->actorId)->set($this->db->quoteName('content') . '=' . $this->db->quote($this->content))->set($this->db->quoteName('archived') . '=' . $this->db->quote($this->archived))->set($this->db->quoteName('app') . '=' . $this->db->quote($this->app))->set($this->db->quoteName('created') . '=' . $this->db->quote($date->toSql()));
     $this->db->setQuery($query);
     $this->db->execute();
     // Get the ID of the record.
     $this->id = $this->db->insertid();
 }
コード例 #23
0
ファイル: vote.php プロジェクト: johngrange/wookeyholeweb
 /**
  * This method saves the data about a vote to database.
  *
  * <code>
  * $data = array(
  *      "item_id"    => 1,
  *      "user_id"    => 2,
  *      "votes"      => 1
  * );
  *
  * $vote   = new UserIdeasVote(JFactory::getDbo());
  * $vote->bind($data);
  * $vote->store();
  * </code>
  */
 public function store()
 {
     $query = $this->db->getQuery(true);
     $query->set($this->db->quoteName("item_id") . "=" . $this->db->quote($this->item_id))->set($this->db->quoteName("user_id") . "=" . $this->db->quote($this->user_id))->set($this->db->quoteName("votes") . "=" . $this->db->quote($this->votes));
     if (!empty($this->id)) {
         // Update
         $query->update($this->db->quoteName("#__uideas_votes"))->where($this->db->quoteName("id") . "=" . (int) $this->id);
     } else {
         $query->insert($this->db->quoteName("#__uideas_votes"));
     }
     $this->db->setQuery($query);
     $this->db->execute();
 }
コード例 #24
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);
     }
 }
コード例 #25
0
 /**
  * Remove all sessions for the user name
  *
  * Method is called after user data is deleted from the database
  *
  * @param   array   $user    Holds the user data
  * @param   boolean $success True if user was succesfully stored in the database
  * @param   string  $msg     Message
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onUserAfterDelete($user, $success, $msg)
 {
     $userId = JArrayHelper::getValue($user, "id");
     if (!$success or !$userId) {
         return false;
     }
     // Remove profile images.
     $profile = new SocialCommunity\Profile($this->db);
     $profile->load($userId);
     if ($profile->getId()) {
         // Remove profile record.
         $query = $this->db->getQuery(true);
         $query->delete($this->db->quoteName("#__itpsc_profiles"))->where($this->db->quoteName("id") . "=" . $userId);
         $this->db->setQuery($query);
         $this->db->execute();
         // Remove profile images.
         /** @var  $params Joomla\Registry\Registry */
         $params = JComponentHelper::getParams("com_socialcommunity");
         $imagesFolder = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $params->get("images_directory", "images/profiles"));
         // Remove images
         $profile->removeImages($imagesFolder);
     }
     return true;
 }
コード例 #26
0
 /**
  * Store information about activity.
  *
  * <code>
  * $userId = 1;
  * $content = "...";
  *
  * $activity = new ITPrismIntegrateActivityJomSocial($userId, $content);
  * $activity->setDb(JFactory::getDbo());
  * $activity->store();
  * </code>
  *
  * @param string $content
  *
  * @throws Exception
  */
 public function store($content = "")
 {
     if (!empty($content)) {
         $this->content = $content;
     }
     if (!$this->app) {
         throw new Exception(JText::_("LIB_ITPRISM_ERROR_INVALID_JOMSOCIAL_APP"));
     }
     $query = $this->db->getQuery(true);
     $date = new JDate();
     $query->insert("#__community_activities")->set($this->db->quoteName("actor") . "=" . (int) $this->actorId)->set($this->db->quoteName("content") . "=" . $this->db->quote($this->content))->set($this->db->quoteName("archived") . "=" . $this->db->quote($this->archived))->set($this->db->quoteName("app") . "=" . $this->db->quote($this->app))->set($this->db->quoteName("created") . "=" . $this->db->quote($date->toSql()));
     $this->db->setQuery($query);
     $this->db->execute();
     // Get the ID of the record.
     $this->id = $this->db->insertid();
 }
コード例 #27
0
ファイル: changeitem.php プロジェクト: exntu/joomla-cms
 /**
  * Runs the update query to apply the change to the database
  *
  * @return  void
  *
  * @since   2.5
  */
 public function fix()
 {
     if ($this->checkStatus === -2) {
         // At this point we have a failed query
         $this->db->setQuery($this->updateQuery);
         if ($this->db->execute()) {
             if ($this->check()) {
                 $this->checkStatus = 1;
                 $this->rerunStatus = 1;
             } else {
                 $this->rerunStatus = -2;
             }
         } else {
             $this->rerunStatus = -2;
         }
     }
 }
コード例 #28
0
ファイル: table.php プロジェクト: ranwaldo/joomla-platform
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table.  The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param   mixed    $pks     An optional array of primary key values to update.
  *                            If not set the instance property value is used.
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published]
  * @param   integer  $userId  The user id of the user performing the operation.
  *
  * @return  boolean  True on success; false if $pks is empty.
  *
  * @link    http://docs.joomla.org/JTable/publish
  * @since   11.1
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     // Sanitize input.
     JArrayHelper::toInteger($pks);
     $userId = (int) $userId;
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             return false;
         }
     }
     // Update the publishing state for rows with the given primary keys.
     $query = $this->_db->getQuery(true);
     $query->update($this->_tbl);
     $query->set('published = ' . (int) $state);
     // Determine if there is checkin support for the table.
     if (property_exists($this, 'checked_out') || property_exists($this, 'checked_out_time')) {
         $query->where('(checked_out = 0 OR checked_out = ' . (int) $userId . ')');
         $checkin = true;
     } else {
         $checkin = false;
     }
     // Build the WHERE clause for the primary keys.
     $query->where($k . ' = ' . implode(' OR ' . $k . ' = ', $pks));
     $this->_db->setQuery($query);
     $this->_db->execute();
     // If checkin is supported and all rows were adjusted, check them in.
     if ($checkin && count($pks) == $this->_db->getAffectedRows()) {
         // Checkin the rows.
         foreach ($pks as $pk) {
             $this->checkin($pk);
         }
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->published = $state;
     }
     $this->setError('');
     return true;
 }
コード例 #29
0
 /**
  * Store a notification to database.
  *
  * <code>
  * $userId = 1;
  * $content = "....";
  *
  * $notification = new ITPrismIntegrateNotificationEasySocial($userId, $content);
  * $notification->setDb(JFactory::getDbo());
  *
  * $notification->send();
  * </code>
  *
  * @param string $content
  */
 public function send($content = "")
 {
     if (!empty($content)) {
         $this->content = $content;
     }
     $query = $this->db->getQuery(true);
     $date = new JDate();
     $query->insert($this->db->quoteName("#__social_notifications"))->set($this->db->quoteName("uid") . "=" . (int) $this->uid)->set($this->db->quoteName("actor_id") . "=" . (int) $this->actorId)->set($this->db->quoteName("actor_type") . "=" . $this->db->quote($this->actorType))->set($this->db->quoteName("target_id") . "=" . (int) $this->targetId)->set($this->db->quoteName("target_type") . "=" . $this->db->quote($this->targetType))->set($this->db->quoteName("content") . "=" . $this->db->quote($this->content))->set($this->db->quoteName("cmd") . "=" . $this->db->quote($this->cmd))->set($this->db->quoteName("type") . "=" . $this->db->quote($this->type))->set($this->db->quoteName("url") . "=" . $this->db->quote($this->url))->set($this->db->quoteName("state") . "=" . (int) $this->state)->set($this->db->quoteName("created") . "=" . $this->db->quote($date->toSql()));
     if (!empty($this->image)) {
         $query->set($this->db->quoteName("image") . "=" . $this->db->quote($this->image));
     }
     if (!empty($this->title)) {
         $query->set($this->db->quoteName("title") . "=" . $this->db->quote($this->title));
     }
     $this->db->setQuery($query);
     $this->db->execute();
     $this->id = $this->db->insertid();
 }
コード例 #30
0
ファイル: EasySocial.php プロジェクト: bellodox/PrismLibrary
 /**
  * Store a notification to database.
  *
  * <code>
  * $userId = 1;
  * $content = "....";
  *
  * $notification = new Prism\Integration\Notification\EasySocial($userId, $content);
  * $notification->setDb(JFactory::getDbo());
  *
  * $notification->send();
  * </code>
  *
  * @param string $content
  */
 public function send($content = '')
 {
     if (\JString::strlen($content) > 0) {
         $this->content = $content;
     }
     $query = $this->db->getQuery(true);
     $date = new \JDate();
     $query->insert($this->db->quoteName('#__social_notifications'))->set($this->db->quoteName('uid') . '=' . (int) $this->uid)->set($this->db->quoteName('actor_id') . '=' . (int) $this->actorId)->set($this->db->quoteName('actor_type') . '=' . $this->db->quote($this->actorType))->set($this->db->quoteName('target_id') . '=' . (int) $this->targetId)->set($this->db->quoteName('target_type') . '=' . $this->db->quote($this->targetType))->set($this->db->quoteName('content') . '=' . $this->db->quote($this->content))->set($this->db->quoteName('cmd') . '=' . $this->db->quote($this->cmd))->set($this->db->quoteName('type') . '=' . $this->db->quote($this->type))->set($this->db->quoteName('url') . '=' . $this->db->quote($this->url))->set($this->db->quoteName('state') . '=' . (int) $this->state)->set($this->db->quoteName('created') . '=' . $this->db->quote($date->toSql()));
     if ($this->image !== null) {
         $query->set($this->db->quoteName('image') . '=' . $this->db->quote($this->image));
     }
     if ($this->title !== null) {
         $query->set($this->db->quoteName('title') . '=' . $this->db->quote($this->title));
     }
     $this->db->setQuery($query);
     $this->db->execute();
     $this->id = $this->db->insertid();
 }