Exemple #1
1
 /**
  * Prepare the comments object for the photo item
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function comments()
 {
     // Get the verb to use.
     $verb = $this->getPhotoVerb();
     // The context should always be photos
     $context = SOCIAL_TYPE_PHOTO;
     // The object id should always be the photo id
     $id = $this->data->id;
     $streamId = $this->getPhotoStreamId($id, $verb, false);
     if ($verb == 'upload') {
         // we now this photo is uploaded via stream's story form.
         $model = FD::model('Stream');
         $aggregated = $model->isAggregated($this->data->id, 'photos');
         if ($aggregated) {
             $streamId = '0';
         }
     }
     // Get the permalink to the photo
     $permalink = $this->data->getPermalink(false, true);
     return FD::comments($id, $context, $verb, $this->type, array('url' => $permalink), $streamId);
 }
Exemple #2
0
 /**
  * Prepare the comments object for the photo item
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function comments()
 {
     // Get the verb to use.
     $verb = $this->getPhotoVerb();
     // The context should always be photos
     $context = SOCIAL_TYPE_PHOTO;
     // The object id should always be the photo id
     $id = $this->data->id;
     // stream id
     $streamId = $this->getPhotoStreamId($id, $verb, false);
     // Get the permalink to the photo
     $permalink = $this->data->getPermalink(false, true);
     return FD::comments($id, $context, $verb, $this->type, array('url' => $permalink), $streamId);
 }
Exemple #3
0
 /**
  * Retrieves a list of tag recipients on a photo
  *
  * @since   1.2
  * @access  private
  */
 private function getTagRecipients(&$recipients, SocialTablePhoto &$photo, $exclusion = array())
 {
     // Get a list of tagged users
     $tags = $photo->getTags(true);
     if (!$tags) {
         return;
     }
     foreach ($tags as $tag) {
         if (!in_array($tag->uid, $exclusion)) {
             $recipients[] = $tag->uid;
         }
     }
 }
Exemple #4
0
 /**
  * Creates the necessary images to be used as an avatar.
  *
  * @since	1.0
  * @access	public
  * @param	SocialTablePhoto	The photo table
  * @param 	array 				options - createStream
  * @return
  */
 public function store(SocialTablePhoto &$photo, $options = array())
 {
     // setup the options.
     $createStream = isset($options['addstream']) ? $options['addstream'] : true;
     // default to true.
     // Check if there's a profile photos album that already exists.
     $model = FD::model('Albums');
     // Create default album if necessary
     $album = $model->getDefaultAlbum($this->uid, $this->type, SOCIAL_ALBUM_PROFILE_PHOTOS);
     // Load avatar table
     $avatarTable = FD::table('Avatar');
     $exists = $avatarTable->load(array('uid' => $this->uid, 'type' => $this->type));
     // Cleanup previous avatars only if they exist.
     if ($exists) {
         $this->cleanup($avatarTable);
     }
     // Create the images
     $this->create($avatarTable, $options);
     // Set the avatar composite indices.
     $avatarTable->uid = $this->uid;
     $avatarTable->type = $this->type;
     // Link the avatar to the photo
     $avatarTable->photo_id = $photo->id;
     // Unlink the avatar from gallery item
     $avatarTable->avatar_id = 0;
     // Set the last modified time to now.
     $avatarTable->modified = FD::date()->toMySQL();
     // We need to always reset the avatar back to "joomla"
     $avatarTable->storage = SOCIAL_STORAGE_JOOMLA;
     // Store the avatar now
     $avatarTable->store();
     // @points: profile.avatar.update
     // Assign points to the current user for uploading their avatar
     $photo->assignPoints('profile.avatar.update', $this->uid);
     // @Add stream item when a new profile avatar is uploaded
     if ($createStream) {
         $photo->addPhotosStream('uploadAvatar');
     }
     // Once the photo is finalized as the profile picture we need to update the state
     $photo->state = SOCIAL_STATE_PUBLISHED;
     // If album doesn't have a cover, set the current photo as the cover.
     if (!$album->hasCover()) {
         $album->cover_id = $photo->id;
         // Store the album
         $album->store();
     }
     // Prepare the dispatcher
     FD::apps()->load($this->type);
     if ($this->type == SOCIAL_TYPE_USER) {
         $node = FD::user($this->uid);
     } else {
         $node = FD::group($this->uid);
     }
     $args = array(&$photo, $node);
     $dispatcher = FD::dispatcher();
     // @trigger: onUserAvatarUpdate
     $dispatcher->trigger($this->type, 'onAvatarBeforeSave', $args);
     // Once it is created, store the photo as we need to update
     $state = $photo->store();
     // @trigger: onUserAvatarUpdate
     $dispatcher->trigger($this->type, 'onAvatarAfterSave', $args);
     return $state;
 }
Exemple #5
0
 public function setCacheable($cache = false)
 {
     self::$_cache = $cache;
 }
Exemple #6
0
 /**
  * Retrieves variation for an image
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getVariations(SocialTablePhoto $photo)
 {
     $result = array();
     require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/photos/photos.php';
     foreach (SocialPhotos::$sizes as $title => $size) {
         $key = 'system/' . strtolower($title);
         // Create variation
         $variation = new stdClass();
         $variation->key = $key;
         $variation->name = $title;
         $variation->type = 'system';
         $variation->url = $photo->getSource($title);
         $variation->width = $size['width'];
         $variation->height = $size['height'];
         $variation->size = 0;
         $result[$key] = $variation;
     }
     return $result;
 }