/** * Allows caller to move a photo over to album * * @since 1.0 * @access public * @return */ public function move() { // Check for request forgeries FD::checkToken(); // Only allow logged in user FD::requireLogin(); // Get the view $view = $this->getCurrentView(); // Get the current photo id. $id = JRequest::getInt('id'); $photo = FD::table('Photo'); $photo->load($id); // Only allow valid photos if (!$id || !$photo->id) { $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Get the target album id to move this photo to. $albumId = JRequest::getInt('albumId'); $album = FD::table('Album'); $album->load($albumId); if (!$albumId || !$album->id) { $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_INVALID_ALBUM_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Load the library $lib = FD::photo($photo->uid, $photo->type, $photo); // Check if the user can actually manage this photo if (!$lib->canMovePhoto()) { $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_NO_PERMISSION_TO_MOVE_PHOTO'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Load up the target album $albumLib = FD::albums($album->uid, $album->type, $album); // Check if the target album is owned by the user if (!$albumLib->isOwner()) { $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_NO_PERMISSION_TO_MOVE_PHOTO'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Try to move the photo to the new album now if (!$photo->move($albumId)) { $view->setMessage($photo->getError(), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } $view->setMessage(JText::_('COM_EASYSOCIAL_PHOTOS_PHOTO_MOVED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__); }
/** * Retrieves the album's library * * @since 1.0 * @access public * @return SocialAlbums */ public function album() { return FD::albums($this->data->uid, $this->data->type, $this->data->album_id); }
/** * Displays the albums a user has * * @since 1.0 * @access public * @author Mark Lee <*****@*****.**> */ public function output($uid, $type, $content = '', $album = false) { // Load up the albums library $lib = FD::albums($uid, $type, $album ? $album->id : null); // If no layout was given, load recent layout $layout = $this->input->get('layout', 'recent', 'cmd'); // Browser menu $id = $this->input->get('id', '', 'int'); // Load up the model $model = FD::model('Albums'); // Get a list of core albums $coreAlbums = $model->getAlbums($lib->uid, $lib->type, array('coreAlbumsOnly' => true)); // Get a list of normal albums $options = array(); $options['core'] = false; $options['order'] = 'a.assigned_date'; $options['direction'] = 'DESC'; $options['privacy'] = true; $albums = $model->getAlbums($lib->uid, $lib->type, $options); // Browser frame // Get the user alias $userAlias = ''; // $userAlias = $user->getAlias(); $this->set('lib', $lib); $this->set('userAlias', $userAlias); $this->set('id', $id); $this->set('coreAlbums', $coreAlbums); $this->set('albums', $albums); $this->set('content', $content); $this->set('uuid', uniqid()); $this->set('layout', $layout); echo parent::display('site/albums/default'); }
/** * Displays paginated photos within an album * * @since 1.0 * @access public * @param string * @return */ public function loadMore() { // Check for request forgeries FD::checkToken(); $view = $this->getCurrentView(); // Get params $id = JRequest::getInt('albumId', 0); $start = JRequest::getInt('start', 0); if ($start == '-1') { return $view->call(__FUNCTION__, '', $start); } $album = FD::table('Album'); $album->load($id); if (!$id || !$album->id) { $view->setMessage(JText::_('COM_EASYSOCIAL_ALBUMS_INVALID_ALBUM_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } $lib = FD::albums($album->uid, $album->type, $album); $result = $lib->getPhotos($album->id, array('start' => $start, 'privacy' => true)); // This will generate $photos, $nextStart extract($result); return $view->call(__FUNCTION__, $photos, $nextStart); }
public function create_album() { // Get the uid and type $app = JFactory::getApplication(); $uid = $app->input->get('uid', 0, 'INT'); $type = $app->input->get('type', 0, 'USER'); $title = $app->input->get('title', 0, 'USER'); // Load the album $album = FD::table('Album'); $album->load(); // Determine if this item is a new item $isNew = true; if ($album->id) { $isNew = false; } // Load the album's library $lib = FD::albums($uid, $type); // Check if the person is allowed to create albums if ($isNew && !$lib->canCreateAlbums()) { return false; } // Set the album uid and type $album->uid = $uid; $album->type = $type; $album->title = $title; // Determine if the user has already exceeded the album creation if ($isNew && $lib->exceededLimits()) { return false; } // Set the album creation alias $album->assigned_date = FD::date()->toMySQL(); // Set custom date if (isset($post['date'])) { $album->assigned_date = $post['date']; unset($post['date']); } // Set the user creator $album->user_id = $uid; // Try to store the album $state = $album->store(); // Throw error when there's an error saving album if (!$state) { return false; } $photo_obj = new EasySocialApiUploadHelper(); $photodata = $photo_obj->albumPhotoUpload($uid, $type, $album->id); $album->params = $photodata; if (!$album->cover_id) { $album->cover_id = $photodata->id; // Store the album $album->store(); } return $album; }
/** * Post processing when creating a new album * * @since 1.0 * @access public */ public function store($album = null) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } // Success message $theme = FD::themes(); $theme->set('album', $album); $message = $theme->output('site/albums/message.album.save'); // Notify user that the msg is saved $ajax->notify($message, SOCIAL_MSG_SUCCESS); // Load up the library $lib = FD::albums($album->uid, $album->type, $album->id); $output = $lib->renderItem(); return $ajax->resolve($album->export(), $output); }
public function getPhotos($options = array()) { if (!$this->id) { return array('photos' => array(), 'nextStart' => -1); } $lib = FD::albums($this->uid, $this->type, $this->id); return $lib->getPhotos($this->id, $options); }