public function store($updateNulls = false)
 {
     if (!$this->created) {
         $this->created = FD::get('Date', 'now', false)->toMySQL();
     }
     return parent::store();
 }
示例#2
0
 public function store($updateNulls = false)
 {
     if (empty($this->ordering)) {
         $this->ordering = $this->getNextOrder('type = ' . FD::db()->quote($this->type) . ' AND parent_uid = ' . FD::db()->quote($this->parent_uid));
     }
     parent::store($updateNulls);
 }
示例#3
0
 public function store($updateNulls = false)
 {
     // @TODO: Automatically set the alias
     if (!$this->alias) {
     }
     $state = parent::store();
     return $state;
 }
示例#4
0
 public function store($updateNulls = false)
 {
     if (empty($this->value) && !empty($this->title)) {
         $this->value = JString::strtolower(JString::str_ireplace(' ', '', $this->title));
     }
     if (empty($this->title) && !empty($this->value)) {
         $this->title = JString::ucfirst($this->value);
     }
     return parent::store($updateNulls);
 }
示例#5
0
 public function store($updateNulls = false)
 {
     if (empty($this->ordering)) {
         $this->ordering = $this->getNextOrder('type = ' . FD::db()->quote($this->type) . ' AND parent_uid = ' . FD::db()->quote($this->parent_uid));
     }
     if (empty($this->uid)) {
         $db = FD::db();
         $sql = $db->sql();
         $sql->raw("SELECT MAX(`uid`) FROM `#__social_regions` WHERE `type` = " . $db->q($this->type));
         $db->setQuery($sql);
         $result = (int) $db->loadResult();
         $this->uid = $result + 1;
     }
     parent::store($updateNulls);
 }
示例#6
0
 public function store($updateNulls = false)
 {
     $now = FD::date();
     // Set created to now by default
     if (empty($this->created)) {
         $this->created = $now->toSql();
     }
     // Set expired to 1 day later by default
     if (empty($this->expired)) {
         $this->expired = FD::date($now->toUnix() + 24 * 60 * 60)->toSql();
     }
     if (is_array($this->value) || is_object($this->value)) {
         $this->value = FD::json()->encode($this->value);
     }
     return parent::store($updateNulls);
 }
示例#7
0
 /**
  * Override parent's store function
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     // Generate an alias for this filter if it is empty.
     if (empty($this->alias)) {
         $alias = $this->title;
         $alias = JFilterOutput::stringURLSafe($alias);
         $tmp = $alias;
         $i = 1;
         while ($this->aliasExists($alias)) {
             $alias = $tmp . '-' . $i;
             $i++;
         }
         $this->alias = $alias;
     }
     $state = parent::store($updateNulls);
 }
示例#8
0
 /**
  * Override's parent's store behavior
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return	bool		True on success false otherwise
  */
 public function store($updateNulls = false)
 {
     // Determines if this is a new conversation object.
     $isNew = $this->id ? false : true;
     $state = parent::store();
     if ($isNew) {
         // @badge: conversation.create
         $badge = FD::badges();
         $badge->log('com_easysocial', 'conversation.create', $this->created_by, JText::_('COM_EASYSOCIAL_CONVERSATIONS_BADGE_STARTED_NEW_CONVERSATION'));
         // @points: conversation.create
         // Assign points when user starts new conversation
         $type = $this->type == SOCIAL_CONVERSATION_SINGLE ? '' : '.group';
         $points = FD::points();
         $points->assign('conversation.create' . $type, 'com_easysocial', $this->created_by);
     }
     return $state;
 }
示例#9
0
 public function store($updateNulls = false)
 {
     if (!$this->params instanceof SocialRegistry) {
         $this->params = FD::registry($this->params);
     }
     $this->params = $this->params->toString();
     $isNew = false;
     if (empty($this->id)) {
         $isNew = true;
     }
     // Get the necessary group
     $namespace = explode('.', $this->element);
     $group = isset($namespace[1]) ? $namespace[1] : SOCIAL_APPS_GROUP_USER;
     FD::apps()->load($group);
     if ($isNew && $this->_trigger) {
         if (!empty($this->parent)) {
             $parent = $this->getParent();
             if ($parent) {
                 $this->depth = $parent->depth + 1;
                 $parent->addChildCount();
             }
         }
         $this->setBoundary();
         // Get the dispatcher object
         $dispatcher = FD::dispatcher();
         $args = array(&$this);
         // @trigger: onBeforeCommentSave
         $dispatcher->trigger($group, 'onBeforeCommentSave', $args);
     }
     $state = parent::store();
     if (!$state) {
         FD::logError(__FILE__, __LINE__, $this->getError());
         return false;
     }
     if ($isNew && $this->_trigger) {
         // @trigger: onAfterCommentSave
         $dispatcher->trigger($group, 'onAfterCommentSave', $args);
     }
     return $state;
 }
示例#10
0
 /**
  * Override's parent's behavior of store.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     $state = parent::store();
     return $state;
 }
示例#11
0
 /**
  * Allows caller to lock a discussion
  *
  * @since	1.2
  * @access	public
  * @return	bool	True if success false otherwise
  */
 public function lock()
 {
     $this->lock = true;
     $state = parent::store();
     return $state;
 }
 /**
  * Override parent's store method so that we can
  * run our own maintenance here.
  */
 public function store($updateNulls = false)
 {
     $state = parent::store($updateNulls);
     if ($state) {
         // Add a new location item if address, latitude , longitude is provided.
         $latitude = JRequest::getVar('latitude');
         $longitude = JRequest::getVar('longitude');
         $address = JRequest::getVar('address');
         // Let's add the location now.
         if (!empty($latitude) && !empty($longitude) && !empty($address)) {
             $location = FD::table('Location');
             $location->latitude = $latitude;
             $location->longitude = $longitude;
             $location->address = $address;
             $location->uid = $this->id;
             $location->type = SOCIAL_TYPE_CONVERSATIONS;
             $location->user_id = $this->created_by;
             $location->store();
         }
     }
     return $state;
 }
示例#13
0
 public function createBlank()
 {
     // If created date is not provided, we generate it automatically.
     if (is_null($this->created)) {
         $this->created = FD::date()->toMySQL();
     }
     // Update the modified date.
     $this->modified = FD::date()->toMySQL();
     // Update ordering column.
     $this->ordering = $this->getNextOrder();
     // Store the item now so that we can get the incremented profile id.
     $state = parent::store();
     return $state;
 }
示例#14
0
 /**
  * Override's parent store method as we need to get the sequence if it's not being set.
  *
  * Example:
  * <code>
  * <?php
  * $table 	= FD::table( 'Workflow' );
  * $table->load( JRequest::getInt( 'id' ) );
  * $table->store();
  * ?>
  * </code>
  *
  * @since	1.0
  * @access	public
  * @param	bool	True to update fields even if they are null.
  * @return	bool	True on success, false otherwise.
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function store($updateNulls = false)
 {
     // Get next sequence
     if (!$this->sequence) {
         $lastSequence = $this->getLastSequence();
         $this->sequence = $lastSequence + 1;
     }
     return parent::store($updateNulls);
 }
示例#15
0
 public function store($updateNulls = false)
 {
     $isNew = true;
     if ($this->id) {
         $isNew = false;
     }
     if (empty($this->created)) {
         $this->created = FD::date()->toMySQL();
     }
     $state = parent::store($updateNulls);
     if ($state) {
         // TODO: do any triggering here.
     }
     return $state;
 }
示例#16
0
 /**
  * Some desc
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function move($newAlbumId, $where = '')
 {
     jimport('joomla.filesystem.folder');
     // If the current photo is the cover of the photo we need to update the cover
     // since the photo is already moved away
     if ($this->isCover()) {
         $this->setNewAlbumCover();
     }
     // Get the old album id as we need to move the old photo folder over
     $oldAlbumId = $this->album_id;
     // Get the path to the photos folder.
     $oldFolder = $this->getFolder();
     // Set the new album id.
     $this->album_id = $newAlbumId;
     // Get the new photo folder
     $newAlbumFolder = $this->getFolder(false);
     $newFolder = $this->getFolder();
     if (!JFolder::exists($newAlbumFolder)) {
         JFolder::create($newAlbumFolder);
     }
     // Save the photo with the new album
     $state = parent::store();
     if (!$state) {
         return $state;
     }
     JFolder::move($oldFolder, $newFolder);
     // Once the folder is moved, we also need to update all the metas.
     $model = FD::model('Photos');
     $metas = $model->getMeta($this->id, SOCIAL_PHOTOS_META_PATH);
     foreach ($metas as $meta) {
         $table = FD::table('PhotoMeta');
         $table->bind($meta);
         $fileName = basename($table->value);
         // Rebuild the new path
         $table->value = $newFolder . '/' . $fileName;
         $table->store();
     }
     // now we need to remove this photo from stream table.
     $model = FD::model('Photos');
     $model->delPhotoStream($this->id, $this->user_id, $oldAlbumId);
     return $state;
 }
示例#17
0
 /**
  * Override parent's store method.
  *
  * @access	public
  * @param	bool	$updateModified		Update modified time if this is true. Default true.
  * @return	bool	True on success, false on error.
  */
 public function store($updateModified = true)
 {
     if (empty($this->title)) {
         return false;
     }
     $isNew = empty($this->id) ? true : false;
     $now = FD::get('Date')->toMySQL();
     // If script needs us to alter the modified date or if it's a new record,
     // ensure that the modified column contains proper values.
     if ($updateModified || empty($this->modified)) {
         $this->modified = $now;
     }
     if ($isNew) {
         // @badge: friends.list.create
         $badge = FD::badges();
         $badge->log('com_easysocial', 'friends.list.create', $this->user_id, JText::_('COM_EASYSOCIAL_FRIENDS_BADGE_CREATED_FRIEND_LIST'));
         // @points: friends.list.create
         // Assign points when the user creates a new list.
         $points = FD::points();
         $points->assign('friends.list.create', 'com_easysocial', $this->user_id);
     }
     return parent::store();
 }
示例#18
0
 /**
  * Override parent's store function
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.2
  * @access public
  */
 public function store($updateNulls = null)
 {
     // Store this flag first because there are some actions that we might need to do only after saving, and that point isNew() won't return the correct flag.
     $isNew = $this->isNew();
     // Check alias
     $alias = !empty($this->alias) ? $this->alias : $this->title;
     $alias = JFilterOutput::stringURLSafe($alias);
     $model = FD::model('clusters');
     $i = 2;
     do {
         $aliasExists = $model->clusterCategoryAliasExists($alias, $this->id);
         if ($aliasExists) {
             $alias .= '-' . $i++;
         }
     } while ($aliasExists);
     $this->alias = $alias;
     if (empty($this->ordering)) {
         $this->ordering = $this->getNextOrder('type = ' . FD::db()->quote($this->type));
     }
     if (empty($this->created)) {
         $this->created = FD::date()->toSql();
     }
     if (empty($this->uid)) {
         $this->uid = FD::user()->id;
     }
     $state = parent::store($updateNulls);
     if ($isNew) {
         // Create default fields
         FD::model('fields')->createDefaultItems($this->id, SOCIAL_TYPE_CLUSTERS, $this->type);
     }
     return $state;
 }
示例#19
0
 /**
  * Override the parent's store behavior
  *
  * @since	1.4
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     if (is_null($this->modified)) {
         $date = FD::date();
         $this->modified = $date->toSql();
     }
     return parent::store();
 }
示例#20
0
 /**
  * Overrides parent's store implementation
  *
  * @since	1.0
  * @access	public
  */
 public function store($updateNulls = false)
 {
     // Detect if this is a new album
     $isNew = $this->id ? false : true;
     // Set a default title if the title is not set.
     if (empty($this->title)) {
         $this->title = JText::_('COM_EASYSOCIAL_UNTITLED_ALBUM');
     }
     // Convert params back into json string
     if (!is_string($this->params)) {
         $this->params = FD::json()->encode($this->params);
     }
     // Set the date to now if created is empty
     if (empty($this->created)) {
         $this->created = FD::date()->toSql();
     }
     // Update ordering column.
     $this->ordering = $this->getNextOrder(array('uid' => $this->uid, 'type' => $this->type));
     // Invoke paren't store method.
     $state = parent::store($updateNulls);
     if ($isNew && !$this->core) {
         // @points: photos.albums.create
         // Add points for the author for creating an album
         $points = FD::points();
         $points->assign('photos.albums.create', 'com_easysocial', $this->uid);
     }
     JPluginHelper::importPlugin('finder');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onFinderAfterSave', array('easysocial.albums', &$this, $isNew));
     return $state;
 }
示例#21
0
 /**
  * Override parent's behavior
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function store($updateNulls = false)
 {
     $isNew = false;
     if (empty($this->id)) {
         $isNew = true;
     }
     // Get dispatcher library
     $dispatcher = FD::dispatcher();
     $group = SOCIAL_APPS_GROUP_USER;
     $like = new stdClass();
     foreach (get_object_vars($this) as $key => $value) {
         $like->{$key} = $value;
     }
     $like->element = $this->type;
     $like->group = $group;
     $like->verb = '';
     if (strpos($this->type, '.') !== false) {
         $tmp = explode('.', $this->type);
         $group = $tmp['1'];
         $like->element = $tmp[0];
         $like->group = $tmp[1];
         $like->verb = isset($tmp[2]) ? $tmp[2] : '';
     }
     // if( $like->element == 'stream' )
     // {
     // 	$like->streamid 	= $like->uid;
     // 	$like->otype 		= $this->type;
     // 	$origin = $this->getItemOrigin( $like->uid );
     // 	if( $origin )
     // 	{
     // 		$like->element 	= $origin->context_type;
     // 		$like->uid 		= $origin->context_id;
     // 		$like->type 	= $origin->context_type . '.' . $group;
     // 		if( $like->verb )
     // 		{
     // 			$like->type 	= $like->type . '.' . $like->verb;
     // 		}
     // 	}
     // }
     $args = array(&$like);
     // @trigger: onBeforeLikeSave
     $dispatcher->trigger($group, 'onBeforeLikeSave', $args);
     $state = parent::store();
     if (!$state) {
         return $state;
     }
     // @trigger: onAfterLikeSave
     $dispatcher->trigger($group, 'onAfterLikeSave', $args);
     return $state;
 }
示例#22
0
 /**
  * Override parent's store behavior
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public function store($updateNulls = false)
 {
     $isNew = $this->id ? false : true;
     $state = parent::store();
     return $state;
 }
示例#23
0
 /**
  * Overrides the parent's implementation of store
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function store($pk = null)
 {
     $isNew = !$this->id;
     // Save this into the table first
     parent::store($pk);
     // Add this into the mail queue
     if ($isNew) {
         $jconfig = FD::jconfig();
         $mailer = FD::mailer();
         $template = $mailer->getTemplate();
         $sender = FD::user($this->user_id);
         $params = new stdClass();
         $params->senderName = $sender->getName();
         $params->message = $this->message;
         $params->siteName = $jconfig->getValue('sitename');
         $params->manageAlerts = false;
         $params->link = FRoute::registration(array('invite' => $this->id, 'external' => true));
         $template->setSender($sender->getName(), $sender->email);
         $template->setReplyTo($sender->email);
         $template->setRecipient('', $this->email);
         $template->setTitle(JText::sprintf('COM_EASYSOCIAL_FRIENDS_INVITE_MAIL_SUBJECT', $jconfig->getValue('sitename')));
         $template->setTemplate('site/friends/invite', $params);
         $mailer->create($template);
         // Assign points to the user that created this invite
         $points = FD::points();
         $points->assign('friends.invite', 'com_easysocial', $this->user_id);
     }
 }
示例#24
0
 /**
  * Override parent's store implementation
  *
  * @since	1.0
  * @access	public
  * @param	bool	True to update fields even if they are null.
  * @param   bool	True to reset the default values before loading the new row.
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function store($updateNulls = false)
 {
     // Set the element back again.
     if (isset($this->element)) {
         $element = $this->element;
         unset($this->element);
     }
     // Update ordering column if this is a new item.
     if (!$this->id && is_null($this->ordering)) {
         $this->ordering = $this->getNextOrder(array('step_id' => $this->step_id));
     }
     $status = parent::store($updateNulls);
     // Set the element back again.
     if (isset($element)) {
         $this->element = $element;
     }
     return $status;
 }