Ejemplo n.º 1
0
 /**
  * Method acts as ajax responder. Calls methods using ajax
  * 
  * @return JSON encoded string
  *
  */
 public function getPhotosContent()
 {
     if (empty($_GET['photo_id']) || !$_GET['photo_id']) {
         throw new Redirect404Exception();
         exit;
     }
     $userId = OW::getUser()->getId();
     $photoId = (int) $_GET['photo_id'];
     $photo = $this->photoService->findPhotoById($photoId);
     if (!$photo) {
         exit(json_encode(array('result' => 'error')));
     }
     // is moderator
     $moderatorMode = OW::getUser()->isAuthorized('photo');
     $userId = OW::getUser()->getId();
     $contentOwner = $this->photoService->findPhotoOwner($photoId);
     $ownerMode = $contentOwner == $userId;
     $canView = true;
     $message = '';
     if (!$ownerMode && !OW::getUser()->isAuthorized('photo', 'view')) {
         $canView = false;
         $message = OW::getLanguage()->text('base', 'authorization_failed_feedback');
     }
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $photos = $this->photoService->getAlbumPhotos($photo->albumId, 1, $photoCount);
     foreach ($photos as $item) {
         $photosList[] = array('photo_id' => $item['id'], 'thumb' => $item['url'], 'src' => $this->photoService->getPhotoUrl($item['id']), 'active' => $item['id'] == $_GET['photo_id'], 'title' => '', 'description' => '');
     }
     //var_dump($photos);die;
     exit(json_encode(array('photos' => $photosList, 'count' => $photoCount, 'album_title' => $album->name, 'album_href' => OW::getRouter()->urlForRoute('photo_user_album', array('user' => $ownerName, 'album' => $photo->albumId)), 'owner_title' => BOL_UserService::getInstance()->getDisplayName($album->userId), 'owner_href' => BOL_UserService::getInstance()->getUserUrl($album->userId), 'authorized' => $ownerMode || $moderatorMode || OW::getUser()->isAuthorized('photo', 'view'), 'message' => $message)));
 }
Ejemplo n.º 2
0
 public function __construct($listType, $count, $exclude = null, $albumId = null)
 {
     parent::__construct();
     $this->photoService = PHOTO_BOL_PhotoService::getInstance();
     $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $checkPrivacy = !OW::getUser()->isAuthorized('photo');
     if ($albumId) {
         $photos = $this->photoService->getAlbumPhotos($albumId, 1, $count, $exclude);
     } else {
         $photos = $this->photoService->findPhotoList($listType, 1, $count, $checkPrivacy, $exclude);
     }
     $this->assign('photos', $photos);
     foreach ($photos as $photo) {
         array_push($exclude, $photo['id']);
     }
     if ($albumId) {
         $loadMore = $this->photoAlbumService->countAlbumPhotos($albumId, $exclude);
     } else {
         $loadMore = $this->photoService->countPhotos($listType, $checkPrivacy, $exclude);
     }
     if (!$loadMore) {
         $script = "OWM.trigger('photo.hide_load_more', {});";
         OW::getDocument()->addOnloadScript($script);
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns class instance
  *
  * @return PHOTO_BOL_PhotoAlbumService
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Ejemplo n.º 4
0
 public function __construct($albumId)
 {
     parent::__construct('albumEditForm');
     $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId);
     $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_update_photo'));
     $this->setAjax(TRUE);
     $this->setAjaxResetOnSuccess(FALSE);
     $albumIdField = new HiddenField('album-id');
     $albumIdField->setValue($album->id);
     $albumIdField->setRequired();
     $albumIdField->addValidator(new PHOTO_CLASS_AlbumOwnerValidator());
     $this->addElement($albumIdField);
     $albumNameField = new TextField('albumName');
     $albumNameField->setValue($album->name);
     $albumNameField->setRequired();
     if ($album->name != trim(OW::getLanguage()->text('photo', 'newsfeed_album'))) {
         $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(TRUE, NULL, $album->name));
     }
     $albumNameField->addAttribute('class', 'ow_photo_album_name_input');
     $this->addElement($albumNameField);
     $desc = new Textarea('desc');
     $desc->setValue(!empty($album->description) ? $album->description : NULL);
     $desc->setHasInvitation(TRUE);
     $desc->setInvitation(OW::getLanguage()->text('photo', 'describe_photo'));
     $desc->addAttribute('class', 'ow_photo_album_description_textarea');
     $this->addElement($desc);
 }
Ejemplo n.º 5
0
 public function albumsDeleteProcess()
 {
     $config = OW::getConfig();
     // check if uninstall is in progress
     if (!$config->getValue('photo', 'uninstall_inprogress')) {
         return;
     }
     // check if cron queue is not busy
     if ($config->getValue('photo', 'uninstall_cron_busy')) {
         return;
     }
     $config->saveConfig('photo', 'uninstall_cron_busy', 1);
     $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     try {
         $albumService->deleteAlbums(self::ALBUMS_DELETE_LIMIT);
     } catch (Exception $e) {
         OW::getLogger()->addEntry(json_encode($e));
     }
     $config->saveConfig('photo', 'uninstall_cron_busy', 0);
     if (!$albumService->countAlbums()) {
         BOL_PluginService::getInstance()->uninstall('photo');
         $config->saveConfig('photo', 'uninstall_inprogress', 0);
         PHOTO_BOL_PhotoService::getInstance()->setMaintenanceMode(false);
     }
 }
Ejemplo n.º 6
0
 public function __construct($albumId)
 {
     parent::__construct(self::FORM_NAME);
     $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId);
     $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_update_photo'));
     $this->setAjax(true);
     $this->setAjaxResetOnSuccess(false);
     $albumIdField = new HiddenField(self::ELEMENT_ALBUM_ID);
     $albumIdField->setValue($album->id);
     $albumIdField->setRequired();
     $albumIdField->addValidator(new PHOTO_CLASS_AlbumOwnerValidator());
     $this->addElement($albumIdField);
     $albumNameField = new TextField(self::ELEMENT_ALBUM_NAME);
     $albumNameField->setValue($album->name);
     $albumNameField->setRequired();
     if ($album->name != trim(OW::getLanguage()->text('photo', 'newsfeed_album'))) {
         $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(true, null, $album->name));
     }
     $albumNameField->addAttribute('class', 'ow_photo_album_name_input');
     $this->addElement($albumNameField);
     $desc = new Textarea(self::ELEMENT_DESC);
     $desc->setValue(!empty($album->description) ? $album->description : NULL);
     $desc->setHasInvitation(TRUE);
     $desc->setInvitation(OW::getLanguage()->text('photo', 'describe_photo'));
     $desc->addAttribute('class', 'ow_photo_album_description_textarea');
     $this->addElement($desc);
     $this->triggerReady(array('albumId' => $albumId));
 }
Ejemplo n.º 7
0
 public function process()
 {
     $values = $this->getValues();
     $photoIdList = array_unique(array_map('intval', explode(',', $values['photos'])));
     sort($photoIdList);
     OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_BEFORE_PHOTO_MOVE, array('fromAlbum' => $values['from-album'], 'toAlbum' => $values['to-album'], 'photoIdList' => $photoIdList)));
     $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $fromAlbum = $albumService->findAlbumById($values['from-album']);
     $userDto = BOL_UserService::getInstance()->findUserById($fromAlbum->userId);
     $albumName = htmlspecialchars(trim($values['album-name']));
     $isNewAlbum = FALSE;
     if (($toAlbum = $albumService->findAlbumByName($albumName, $userDto->id)) === NULL) {
         $toAlbum = new PHOTO_BOL_PhotoAlbum();
         $toAlbum->name = $albumName;
         $toAlbum->description = htmlspecialchars(trim($values['desc']));
         $toAlbum->userId = $userDto->id;
         $toAlbum->entityId = $userDto->id;
         $toAlbum->entityType = 'user';
         $toAlbum->createDatetime = time();
         $albumService->addAlbum($toAlbum);
         $this->getElement('to-album')->setValue($toAlbum->id);
         $isNewAlbum = TRUE;
     }
     if ($photoService->movePhotosToAlbum($photoIdList, $toAlbum->id, $isNewAlbum)) {
         $values = $this->getValues();
         OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_AFTER_PHOTO_MOVE, array('fromAlbum' => $values['from-album'], 'toAlbum' => $values['to-album'], 'photoIdList' => $photoIdList)));
     }
     return TRUE;
 }
Ejemplo n.º 8
0
 public function onAddProfileContentMenu(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if (empty($params['userId'])) {
         return;
     }
     $userId = (int) $params['userId'];
     $lang = OW::getLanguage();
     $linkId = uniqid('photo');
     $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $exclude = array();
     $newsfeedAlbum = $albumService->getNewsfeedAlbum($userId);
     if ($newsfeedAlbum !== null) {
         $exclude[] = $newsfeedAlbum->id;
     }
     if (!$albumService->countUserAlbums($userId, $exclude)) {
         return;
     }
     $albumList = $albumService->findUserAlbumList($userId, 1, 1, $exclude);
     $cover = !empty($albumList[0]['cover']) ? $albumList[0]['cover'] : null;
     $username = BOL_UserService::getInstance()->getUserName($userId);
     $url = OW::getRouter()->urlForRoute('photo_user_albums', array('user' => $username));
     $resultArray = array(BASE_MCMP_ProfileContentMenu::DATA_KEY_LABEL => $lang->text('photo', 'user_photo_albums_widget'), BASE_MCMP_ProfileContentMenu::DATA_KEY_LINK_HREF => $url, BASE_MCMP_ProfileContentMenu::DATA_KEY_LINK_ID => $linkId, BASE_MCMP_ProfileContentMenu::DATA_KEY_LINK_CLASS => 'owm_profile_nav_photo', BASE_MCMP_ProfileContentMenu::DATA_KEY_THUMB => $cover);
     $event->add($resultArray);
 }
Ejemplo n.º 9
0
 public function collectAlbumsForAvatar(BASE_CLASS_EventCollector $e)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $params = $e->getParams();
     $userId = OW::getUser()->getId();
     $total = $this->albumService->countUserAlbums($userId);
     $albums = $this->albumService->findUserAlbums($userId, 0, $total);
     if (!$albums) {
         return;
     }
     foreach ($albums as $album) {
         $photoCount = $this->photoService->countAlbumPhotos($album->id, array());
         if (!$photoCount) {
             continue;
         }
         $photos = $this->photoService->getAlbumPhotos($album->id, 1, $params['limit']);
         $list = array();
         foreach ($photos as $photo) {
             $list[] = array('id' => $photo['id'], 'entityId' => $album->id, 'entityType' => 'photo_album', 'url' => $photo['url'], 'bigUrl' => $this->photoService->getPhotoUrlByType($photo['id'], PHOTO_BOL_PhotoService::TYPE_MAIN, $photo['dto']->hash, $photo['dto']->dimension));
         }
         $section = array('entityId' => $album->id, 'entityType' => 'photo_album', 'label' => $album->name, 'count' => $photoCount, 'list' => $list);
         $e->add($section);
     }
 }
Ejemplo n.º 10
0
 public function __construct($userId, $limit, $exclude)
 {
     parent::__construct();
     $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $user = BOL_UserService::getInstance()->findUserById($userId);
     $this->assign('username', $user->getUsername());
     $albums = $this->photoAlbumService->findUserAlbumList($user->id, 1, $limit, $exclude, true);
     $this->assign('albums', $albums);
     foreach ($albums as $album) {
         array_push($exclude, $album['dto']->id);
     }
     $loadMore = $this->photoAlbumService->countUserAlbums($userId, $exclude);
     if (!$loadMore) {
         $script = "OWM.trigger('photo.hide_load_more', {});";
         OW::getDocument()->addOnloadScript($script);
     }
 }
Ejemplo n.º 11
0
 public function view(array $params)
 {
     if (!isset($params['id']) || !($photoId = (int) $params['id'])) {
         throw new Redirect404Exception();
     }
     $lang = OW::getLanguage();
     $photo = $this->photoService->findPhotoById($photoId);
     if (!$photo) {
         throw new Redirect404Exception();
     }
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     $ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
     $albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('album' => $album->id, 'user' => $ownerName));
     $this->assign('albumUrl', $albumUrl);
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
         $this->assign('authError', $status['msg']);
         return;
     }
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $this->assign('photo', $photo);
     $fullsizeUrl = (int) OW::getConfig()->getValue('photo', 'store_fullsize') && $photo->hasFullsize ? $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash) : null;
     $this->assign('fullsizeUrl', $fullsizeUrl);
     $this->assign('nextPhoto', $this->photoService->getNextPhotoId($photo->albumId, $photo->id));
     $this->assign('previousPhoto', $this->photoService->getPreviousPhotoId($photo->albumId, $photo->id));
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $this->assign('photoCount', $photoCount);
     $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $this->assign('photoIndex', $photoIndex);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $photoCmts = new BASE_MCMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
     OW::getDocument()->setHeading($album->name);
     $description = strip_tags($photo->description);
     $description = mb_strlen($description) ? $description : $photo->id;
     OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_view', array('title' => $description)));
 }
Ejemplo n.º 12
0
 /**
  * @param int $userId
  */
 public function __construct($userId, $exclude)
 {
     parent::__construct();
     if (empty($userId)) {
         $this->setVisible(false);
         return;
     }
     $this->assign('albumNameList', PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumNameListByUserId($userId, $exclude));
 }
Ejemplo n.º 13
0
 public function __construct($albumId, $photoId = NULL, $userId = NULL)
 {
     parent::__construct();
     if (empty($userId)) {
         $userId = OW::getUser()->getId();
     }
     if (empty($userId) || ($album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId)) === null || ($album->userId != $userId || !OW::getUser()->isAuthorized('photo', 'view'))) {
         $this->setVisible(FALSE);
         return;
     }
     if ($photoId === NULL && !PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->isAlbumCoverExist($albumId)) {
         $this->setVisible(FALSE);
         return;
     }
     $storage = OW::getStorage();
     if (empty($photoId)) {
         if ($storage instanceof BASE_CLASS_FileStorage) {
             $photoPath = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverPathByAlbumId($albumId);
         } else {
             $photoPath = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverUrlByAlbumId($albumId, true);
         }
         $info = getimagesize($photoPath);
         if ($info['0'] < 330 || $info['1'] < 330) {
             $this->assign('imgError', OW::getLanguage()->text('photo', 'to_small_cover_img'));
             return;
         }
         $this->assign('coverUrl', PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverUrlByAlbumId($albumId, TRUE));
     } else {
         $photo = PHOTO_BOL_PhotoDao::getInstance()->findById($photoId);
         $this->assign('coverUrl', PHOTO_BOL_PhotoDao::getInstance()->getPhotoUrl($photo->id, $photo->hash, FALSE));
         if (!empty($photo->dimension)) {
             $info = json_decode($photo->dimension, true);
             if ($info[PHOTO_BOL_PhotoService::TYPE_ORIGINAL]['0'] < 330 || $info[PHOTO_BOL_PhotoService::TYPE_ORIGINAL]['1'] < 330) {
                 $this->assign('imgError', OW::getLanguage()->text('photo', 'to_small_cover_img'));
                 return;
             }
         } else {
             if ($storage instanceof BASE_CLASS_FileStorage) {
                 $photoPath = PHOTO_BOL_PhotoDao::getInstance()->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL);
             } else {
                 $photoPath = PHOTO_BOL_PhotoDao::getInstance()->getPhotoUrl($photo->id, $photo->hash, FALSE);
             }
             $info = getimagesize($photoPath);
             if ($info['0'] < 330 || $info['1'] < 330) {
                 $this->assign('imgError', OW::getLanguage()->text('photo', 'to_small_cover_img'));
                 return;
             }
         }
     }
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('base')->getStaticCssUrl() . 'jquery.Jcrop.css');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.Jcrop.js');
     $form = new PHOTO_CLASS_MakeAlbumCover();
     $form->getElement('albumId')->setValue($albumId);
     $form->getElement('photoId')->setValue($photoId);
     $this->addForm($form);
 }
Ejemplo n.º 14
0
 /**
  * Returns user's photo albums list
  *
  * @param string $listType
  * @param int $page
  * @param int $limit
  * @return array of PHOTO_BOL_PhotoAlbum
  */
 public function findAlbumList($listType, $page, $limit, $search = '')
 {
     $albums = $this->advancedphotoAlbumDao->getAlbumList($listType, $page, $limit, $search);
     $list = array();
     if ($albums) {
         $albumIdList = array();
         foreach ($albums as $key => $album) {
             array_push($albumIdList, $album['id']);
             $list[$key]['dto'] = $album;
         }
         $covers = $this->albumService->getAlbumCoverForList($albumIdList);
         $counters = $this->albumService->countAlbumPhotosForList($albumIdList);
         foreach ($albums as $key => $album) {
             $list[$key]['cover'] = $covers[$album['id']];
             $list[$key]['photo_count'] = $counters[$album['id']];
         }
     }
     return $list;
 }
Ejemplo n.º 15
0
 public function isValid($albumName)
 {
     if (strcasecmp(trim($this->albumName), OW::getLanguage()->text('photo', 'newsfeed_album')) === 0) {
         return TRUE;
     }
     if (strcasecmp(trim($albumName), OW::getLanguage()->text('photo', 'newsfeed_album')) === 0) {
         return FALSE;
     } elseif ($this->checkDuplicate && strcasecmp($albumName, $this->albumName) !== 0 && PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumByName($albumName, $this->userId) !== NULL) {
         $this->setErrorMessage(OW::getLanguage()->text('photo', 'album_name_error'));
         return FALSE;
     }
     return TRUE;
 }
Ejemplo n.º 16
0
 private function getAlbum($userId)
 {
     $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $albumName = $this->getAlbumName();
     $album = $albumService->findAlbumByName($albumName, $userId);
     if (empty($album)) {
         $album = new PHOTO_BOL_PhotoAlbum();
         $album->name = $albumName;
         $album->userId = $userId;
         $album->createDatetime = time();
         $albumService->addAlbum($album);
     }
     return $album;
 }
Ejemplo n.º 17
0
 public function __construct($albumId = NULL, $albumName = NULL, $albumDescription = null, $url = NULL)
 {
     if (!OW::getUser()->isAuthorized('photo', 'upload')) {
         $this->setVisible(FALSE);
         return;
     }
     $userId = OW::getUser()->getId();
     $document = OW::getDocument();
     PHOTO_BOL_PhotoTemporaryService::getInstance()->deleteUserTemporaryPhotos($userId);
     $plugin = OW::getPluginManager()->getPlugin('photo');
     $document->addStyleSheet($plugin->getStaticCssUrl() . 'photo_upload.css');
     $document->addScript($plugin->getStaticJsUrl() . 'jQueryRotate.min.js');
     $document->addScript($plugin->getStaticJsUrl() . 'codemirror.min.js');
     $document->addScript($plugin->getStaticJsUrl() . 'upload.js');
     $document->addScriptDeclarationBeforeIncludes(UTIL_JsGenerator::composeJsString(';window.ajaxPhotoUploadParams = {};
             Object.defineProperties(ajaxPhotoUploadParams, {
                 actionUrl: {
                     value: {$url},
                     writable: false,
                     enumerable: true
                 },
                 maxFileSize: {
                     value: {$size},
                     writable: false,
                     enumerable: true
                 },
                 deleteAction: {
                     value: {$deleteAction},
                     writable: false,
                     enumerable: true
                 }
             });', array('url' => OW::getRouter()->urlForRoute('photo.ajax_upload'), 'size' => PHOTO_BOL_PhotoService::getInstance()->getMaxUploadFileSize(), 'deleteAction' => OW::getRouter()->urlForRoute('photo.ajax_upload_delete'))));
     $document->addOnloadScript(';window.ajaxPhotoUploader.init();');
     $this->addForm(new PHOTO_CLASS_AjaxUploadForm('user', $userId, $albumId, $albumName, $albumDescription, $url));
     $newsfeedAlbum = PHOTO_BOL_PhotoAlbumService::getInstance()->getNewsfeedAlbum($userId);
     $this->assign('albumNameList', PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumNameListByUserId($userId, !empty($newsfeedAlbum) ? array($newsfeedAlbum->id) : array()));
     $language = OW::getLanguage();
     $language->addKeyForJs('photo', 'not_all_photos_uploaded');
     $language->addKeyForJs('photo', 'size_limit');
     $language->addKeyForJs('photo', 'type_error');
     $language->addKeyForJs('photo', 'dnd_support');
     $language->addKeyForJs('photo', 'dnd_not_support');
     $language->addKeyForJs('photo', 'drop_here');
     $language->addKeyForJs('photo', 'please_wait');
     $language->addKeyForJs('photo', 'create_album');
     $language->addKeyForJs('photo', 'album_name');
     $language->addKeyForJs('photo', 'album_desc');
     $language->addKeyForJs('photo', 'describe_photo');
     $language->addKeyForJs('photo', 'photo_upload_error');
 }
Ejemplo n.º 18
0
 public function __construct($photoId = NULL)
 {
     parent::__construct('photo-edit-form');
     $this->setAjax(TRUE);
     $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxUpdatePhoto'));
     $this->bindJsFunction('success', 'function( data )
         {
             OW.trigger("photo.afterPhotoEdit", data);
         }');
     $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
     $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId);
     $photoIdField = new HiddenField('photoId');
     $photoIdField->setRequired(TRUE);
     $photoIdField->setValue($photo->id);
     $photoIdField->addValidator(new PHOTO_CLASS_PhotoOwnerValidator());
     $this->addElement($photoIdField);
     $albumField = new TextField('album');
     $albumField->setId('ajax-upload-album');
     $albumField->setRequired();
     $albumField->setValue($album->name);
     $albumField->setLabel(OW::getLanguage()->text('photo', 'create_album'));
     $albumField->addAttribute('class', 'ow_dropdown_btn ow_inputready ow_cursor_pointer');
     $albumField->addAttribute('autocomplete', 'off');
     $albumField->addAttribute('readonly');
     $this->addElement($albumField);
     $albumNameField = new TextField('album-name');
     $albumNameField->setRequired();
     $albumNameField->setValue($album->name);
     $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(FALSE, NULL, $album->name));
     $albumNameField->setHasInvitation(TRUE);
     $albumNameField->setInvitation(OW::getLanguage()->text('photo', 'album_name'));
     $albumNameField->addAttribute('class', 'ow_smallmargin invitation');
     $this->addElement($albumNameField);
     $desc = new Textarea('description');
     $desc->setHasInvitation(TRUE);
     $desc->setInvitation(OW::getLanguage()->text('photo', 'album_desc'));
     $this->addElement($desc);
     $photoDesc = new PHOTO_CLASS_HashtagFormElement('photo-desc');
     $photoDesc->setValue($photo->description);
     $photoDesc->setLabel(OW::getLanguage()->text('photo', 'album_desc'));
     $this->addElement($photoDesc);
     $submit = new Submit('edit');
     $submit->setValue(OW::getLanguage()->text('photo', 'btn_edit'));
     $this->addElement($submit);
 }
Ejemplo n.º 19
0
 /**
  * Class constructor
  */
 public function __construct($photoId)
 {
     parent::__construct('photo-edit-form');
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxUpdatePhoto'));
     $language = OW::getLanguage();
     $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
     $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId);
     $userId = OW::getUser()->getId();
     // photo id field
     $photoIdField = new HiddenField('id');
     $photoIdField->setRequired(true);
     $this->addElement($photoIdField);
     // photo album Field
     $albumField = new SuggestField('album');
     $responderUrl = OW::getRouter()->urlFor('PHOTO_CTRL_Upload', 'suggestAlbum', array('userId' => $userId));
     $albumField->setResponderUrl($responderUrl);
     if ($album) {
         $albumField->setValue($album->name);
     }
     $albumField->setRequired(true);
     $albumField->setLabel($language->text('photo', 'album'));
     $this->addElement($albumField);
     // description Field
     $descField = new WysiwygTextarea('description', null, false);
     $descField->setId("photo-desc-area");
     $this->addElement($descField->setLabel($language->text('photo', 'description')));
     $tags = array();
     $entityTags = BOL_TagService::getInstance()->findEntityTags($photo->id, 'photo');
     if ($entityTags) {
         $tags = array();
         foreach ($entityTags as $entityTag) {
             $tags[] = $entityTag->label;
         }
         $tagsField = new TagsInputField('tags');
         $tagsField->setValue($tags);
     } else {
         $tagsField = new TagsInputField('tags');
     }
     $this->addElement($tagsField->setLabel($language->text('photo', 'tags')));
     $submit = new Submit('edit');
     $submit->setValue($language->text('photo', 'btn_edit'));
     $this->addElement($submit);
 }
Ejemplo n.º 20
0
 /**
  * @return Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $userId = $paramObj->additionalParamList['entityId'];
     $user = BOL_UserService::getInstance()->getUserName($userId);
     $this->assign('user', $user);
     $num = isset($paramObj->customParamList['albumsCount']) ? $paramObj->customParamList['albumsCount'] : 4;
     $albums = $photoAlbumService->findUserAlbumList($userId, 1, $num);
     if ($albums) {
         $this->assign('albums', $albums);
         $albumsCount = $photoAlbumService->countUserAlbums($userId);
         $this->assign('albumsCount', $albumsCount);
     } else {
         if (!$paramObj->customizeMode) {
             $this->setVisible(false);
         }
         $this->assign('albums', null);
         $this->assign('albumsCount', 0);
         $albumsCount = 0;
     }
     // privacy check
     $viewerId = OW::getUser()->getId();
     $ownerMode = $userId == $viewerId;
     $modPermissions = OW::getUser()->isAuthorized('photo');
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $userId, 'viewerId' => $viewerId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         try {
             OW::getEventManager()->trigger($event);
         } catch (RedirectException $e) {
             $this->setVisible(false);
         }
     }
     $showTitles = isset($paramObj->customParamList['showTitles']) ? $paramObj->customParamList['showTitles'] : false;
     $this->assign('showTitles', $showTitles);
     $lang = OW::getLanguage();
     $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => $lang->text('photo', 'total_albums', array('total' => $albumsCount))), array('label' => $lang->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('photo_user_albums', array('user' => $user)))));
 }
Ejemplo n.º 21
0
 public function __construct($albumId = null, $albumName = null, $albumDescription = null, $url = null, $data = null)
 {
     parent::__construct();
     if (!OW::getUser()->isAuthorized('photo', 'upload')) {
         $this->setVisible(false);
         return;
     }
     $userId = OW::getUser()->getId();
     $document = OW::getDocument();
     PHOTO_BOL_PhotoTemporaryService::getInstance()->deleteUserTemporaryPhotos($userId);
     $plugin = OW::getPluginManager()->getPlugin('photo');
     $document->addStyleSheet($plugin->getStaticCssUrl() . 'photo_upload.css');
     $document->addScript($plugin->getStaticJsUrl() . 'codemirror.min.js');
     $document->addScript($plugin->getStaticJsUrl() . 'upload.js');
     $document->addScriptDeclarationBeforeIncludes(UTIL_JsGenerator::composeJsString(';window.ajaxPhotoUploadParams = Object.freeze({$params});', array('params' => array('actionUrl' => OW::getRouter()->urlForRoute('photo.ajax_upload'), 'maxFileSize' => PHOTO_BOL_PhotoService::getInstance()->getMaxUploadFileSize(), 'deleteAction' => OW::getRouter()->urlForRoute('photo.ajax_upload_delete')))));
     $document->addOnloadScript(';window.ajaxPhotoUploader.init();');
     $form = new PHOTO_CLASS_AjaxUploadForm('user', $userId, $albumId, $albumName, $albumDescription, $url, $data);
     $this->addForm($form);
     $this->assign('extendInputs', $form->getExtendedElements());
     $this->assign('albumId', $albumId);
     $this->assign('userId', $userId);
     $newsfeedAlbum = PHOTO_BOL_PhotoAlbumService::getInstance()->getNewsfeedAlbum($userId);
     $exclude = !empty($newsfeedAlbum) ? array($newsfeedAlbum->id) : array();
     $this->addComponent('albumNames', OW::getClassInstance('PHOTO_CMP_AlbumNameList', $userId, $exclude));
     $language = OW::getLanguage();
     $language->addKeyForJs('photo', 'not_all_photos_uploaded');
     $language->addKeyForJs('photo', 'size_limit');
     $language->addKeyForJs('photo', 'type_error');
     $language->addKeyForJs('photo', 'dnd_support');
     $language->addKeyForJs('photo', 'dnd_not_support');
     $language->addKeyForJs('photo', 'drop_here');
     $language->addKeyForJs('photo', 'please_wait');
     $language->addKeyForJs('photo', 'create_album');
     $language->addKeyForJs('photo', 'album_name');
     $language->addKeyForJs('photo', 'album_desc');
     $language->addKeyForJs('photo', 'describe_photo');
     $language->addKeyForJs('photo', 'photo_upload_error');
 }
Ejemplo n.º 22
0
    public function __construct($photoId)
    {
        parent::__construct();
        if (($photo = PHOTO_BOL_PhotoDao::getInstance()->findById($photoId)) === NULL || ($album = PHOTO_BOL_PhotoAlbumDao::getInstance()->findById($photo->albumId)) === null || !($album->userId == OW::getUser()->getId() || OW::getUser()->isAuthorized('photo'))) {
            $this->setVisible(FALSE);
            return;
        }
        $this->addForm(new PHOTO_CLASS_EditForm($photo->id));
        $newsfeedAlbum = PHOTO_BOL_PhotoAlbumService::getInstance()->getNewsfeedAlbum($album->userId);
        $exclude = array();
        if (!empty($newsfeedAlbum)) {
            $exclude[] = $newsfeedAlbum->id;
        }
        $this->assign('albumNameList', PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumNameListByUserId(OW::getUser()->getId(), $exclude));
        $language = OW::getLanguage();
        OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString(';var panel = $(document.getElementById("photo_edit_form"));
                var albumList = $(".ow_dropdown_list", panel);
                var albumInput = $("input[name=\'album\']", panel);
                var album = {$album};
                var hideAlbumList = function()
                {
                    albumList.hide();
                    $(".upload_photo_spinner", panel).removeClass("ow_dropdown_arrow_up").addClass("ow_dropdown_arrow_down");
                };
                var showAlbumList = function()
                {
                    albumList.show();
                    $(".upload_photo_spinner", panel).removeClass("ow_dropdown_arrow_down").addClass("ow_dropdown_arrow_up");
                };

                $(".upload_photo_spinner", panel).add(albumInput).on("click", function( event )
                {
                    if ( albumList.is(":visible") )
                    {
                        hideAlbumList();
                    }
                    else
                    {
                        showAlbumList();
                    }

                    event.stopPropagation();
                });

                albumList.find("li").on("click", function()
                {
                    hideAlbumList();
                    owForms["photo-edit-form"].removeErrors();
                }).eq(0).on("click", function()
                {
                    albumInput.val({$create_album});
                    $(".new-album", panel).show();
                    $("input[name=\'album-name\']", panel).val({$album_name});
                    $("textarea", panel).val({$album_desc});
                }).end().slice(2).on("click", function()
                {
                    albumInput.val($(this).html());
                    $(".new-album", panel).hide();
                    $("input[name=\'album-name\']", panel).val(albumInput.val());
                    $("textarea", panel).val("");
                });

                $(document).on("click", function( event )
                {
                    if ( event.target.id === "ajax-upload-album" )
                    {
                        event.stopPropagation();

                        return false;
                    }

                    hideAlbumList();
                });
                
                OW.bind("base.onFormReady.photo-edit-form", function()
                {
                    if ( album.name == {$newsfeedAlbumName} )
                    {
                        this.getElement("album-name").validators.length = 0;
                        this.getElement("album-name").addValidator({
                            validate : function( value ){
                            if(  $.isArray(value) ){ if(value.length == 0  ) throw {$required}; return;}
                            else if( !value || $.trim(value).length == 0 ){ throw {$required}; }
                            },
                            getErrorMessage : function(){ return {$required} }
                        });
                        this.bind("submit", function()
                        {
                            
                        });
                    }
                });
                ', array('create_album' => $language->text('photo', 'create_album'), 'album_name' => $language->text('photo', 'album_name'), 'album_desc' => $language->text('photo', 'album_desc'), 'album' => get_object_vars($album), 'newsfeedAlbumName' => OW::getLanguage()->text('photo', 'newsfeed_album'), 'required' => OW::getLanguage()->text('base', 'form_validator_required_error_message'))));
    }
Ejemplo n.º 23
0
 *
 *
 *
 */
//$app = new \Slim\Slim();
$app = new \Slim\Slim();
//$baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
$BOL_UserDao = BOL_UserDao::getInstance();
$ow_user = OW::getUser();
$OW_Auth_inst = OW_Auth::getInstance();
$Userservice = BOL_UserService::getInstance();
$EmailVerifyService = BOL_EmailVerifyService::getInstance();
$BOL_AvatarService_inst = BOL_AvatarService::getInstance();
$SKAPI_BOL_Service_inst = SKAPI_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService_inst = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
$PHOTO_BOL_PhotoTemporaryService = PHOTO_BOL_PhotoTemporaryService::getInstance();
$UserResetPassword = BOL_UserResetPasswordDao::getInstance();
$QuestionService = BOL_QuestionService::getInstance();
$AccountTypeToGenderService = SKADATE_BOL_AccountTypeToGenderService::getInstance();
$BOL_AuthorizationService = BOL_AuthorizationService::getInstance();
$BOL_UserOnlineDao = BOL_UserOnlineDao::getInstance();
$USEARCH_BOL_Service = USEARCH_BOL_Service::getInstance();
$BOL_SearchService = BOL_SearchService::getInstance();
$getPluginManager = OW::getPluginManager();
$CONTACTUS_BOL_Service = CONTACTUS_BOL_Service::getInstance();
$PHOTO_BOL_PhotoService = PHOTO_BOL_PhotoService::getInstance();
$PHOTO_BOL_PhotoAlbumCoverDao = PHOTO_BOL_PhotoAlbumCoverDao::getInstance();
$PHOTO_BOL_PhotoDao = PHOTO_BOL_PhotoDao::getInstance();
$getRouter = OW::getRouter();
$language = OW::getLanguage();
Ejemplo n.º 24
0
 public function getAlbumCoverPathByAlbumId($albumId)
 {
     if (empty($albumId) || ($cover = $this->findByAlbumId($albumId)) === NULL) {
         $lastPhoto = PHOTO_BOL_PhotoAlbumService::getInstance()->getLastPhotoByAlbumId($albumId);
         return PHOTO_BOL_PhotoDao::getInstance()->getPhotoPath($lastPhoto->id, $lastPhoto->hash, 'main');
     }
     return OW::getPluginManager()->getPlugin('photo')->getUserFilesDir() . self::PREFIX_ALBUM_COVER_ORIG . $cover->id . '_' . $cover->hash . '.jpg';
 }
Ejemplo n.º 25
0
 public function findUserAlbums($userId, $start, $offset)
 {
     if (!$this->isActive()) {
         return null;
     }
     $service = PHOTO_BOL_PhotoAlbumService::getInstance();
     $albumDao = PHOTO_BOL_PhotoAlbumDao::getInstance();
     $example = new OW_Example();
     $example->andFieldEqual('userId', $userId);
     $example->setOrder('createDatetime DESC');
     $example->setLimitClause($start, $offset);
     $albumList = $albumDao->findListByExample($example);
     $albumListIds = array();
     foreach ($albumList as $album) {
         $albumListIds[] = $album->id;
     }
     $covers = $service->getAlbumCoverForList($albumIdList);
     $out = array();
     foreach ($albumList as $album) {
         $out[] = array('id' => $album->id, 'cover' => $covers[$album->id], 'name' => $album->name);
     }
     return $out;
 }
Ejemplo n.º 26
0
 /**
  * Class constructor
  *
  * @param string $listType
  * @param int $count
  * @param string $tag
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $photoId = $params['photoId'];
     $config = OW::getConfig();
     $lang = OW::getLanguage();
     $this->photoService = PHOTO_BOL_PhotoService::getInstance();
     $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $photo = $this->photoService->findPhotoById($photoId);
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     $canView = true;
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $canView = false;
     }
     $this->assign('canView', $canView);
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
     $photoRates = new BASE_CMP_Rate('photo', 'photo_rates', $photo->id, $contentOwner);
     $this->addComponent('rate', $photoRates);
     $photoTags = new BASE_CMP_EntityTagCloud('photo');
     $photoTags->setEntityId($photo->id);
     $photoTags->setRouteName('view_tagged_photo_list');
     $this->addComponent('tags', $photoTags);
     $description = $photo->description;
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $this->assign('photo', $photo);
     $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
     $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId));
     $is_featured = PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id);
     if ((int) $config->getValue('photo', 'store_fullsize') && $photo->hasFullsize) {
         $this->assign('fullsizeUrl', $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash));
     } else {
         $this->assign('fullsizeUrl', null);
     }
     $action = new BASE_ContextAction();
     $action->setKey('photo-moderate');
     $context = new BASE_CMP_ContextAction();
     $context->addAction($action);
     $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photoId, 'photoDto' => $photo));
     OW::getEventManager()->trigger($contextEvent);
     foreach ($contextEvent->getData() as $contextAction) {
         $action = new BASE_ContextAction();
         $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
         $action->setParentKey('photo-moderate');
         $action->setLabel($contextAction['label']);
         if (!empty($contextAction['id'])) {
             $action->setId($contextAction['id']);
         }
         if (!empty($contextAction['order'])) {
             $action->setOrder($contextAction['order']);
         }
         if (!empty($contextAction['class'])) {
             $action->setClass($contextAction['class']);
         }
         if (!empty($contextAction['url'])) {
             $action->setUrl($contextAction['url']);
         }
         $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
         foreach ($attributes as $key => $value) {
             $action->addAttribute($key, $value);
         }
         $context->addAction($action);
     }
     if ($userId && !$ownerMode) {
         $action = new BASE_ContextAction();
         $action->setKey('flag');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'flag'));
         $action->setId('btn-photo-flag');
         $action->addAttribute('rel', $photoId);
         $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)));
         $context->addAction($action);
     }
     if ($ownerMode || $modPermissions) {
         $action = new BASE_ContextAction();
         $action->setKey('edit');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'edit'));
         $action->setId('btn-photo-edit');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
         $action = new BASE_ContextAction();
         $action->setKey('delete');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'delete'));
         $action->setId('photo-delete');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
     }
     if ($modPermissions) {
         if ($is_featured) {
             $action = new BASE_ContextAction();
             $action->setKey('unmark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'remove_from_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'remove_from_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         } else {
             $action = new BASE_ContextAction();
             $action->setKey('mark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'mark_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'mark_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         }
     }
     $this->addComponent('contextAction', $context);
     $nextPhoto = $this->photoService->getNextPhoto($photo->albumId, $photo->id);
     $this->assign('nextPhoto', $nextPhoto);
     $previousPhoto = $this->photoService->getPreviousPhoto($photo->albumId, $photo->id);
     $this->assign('previousPhoto', $previousPhoto);
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $this->assign('photoCount', $photoCount);
     $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $this->assign('photoIndex', $photoIndex);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
 }
Ejemplo n.º 27
0
 public function getPhotoFeedData($entityType, $entityId)
 {
     $newsfeedService = $this->getService('newsfeed');
     $photoFeed = $newsfeedService->findAction($entityType, $entityId);
     $photoFeedData = json_decode($photoFeed->data, true);
     $string = $photoFeedData['string'];
     //print_r($string);die;
     preg_match("((.+)([0-9]+)(.+)<a.*?href=[\"']([^\"']+)[\"'][^>]?>(.+)</a>)i", $string, $matches);
     // img match
     $content = $photoFeedData['content'];
     if (!isset($matches[5])) {
         $photo = $this->getEntity('photo', $entityType, $entityId);
         $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId);
         $albumName = $album->name;
     } else {
         $albumName = $matches[5];
     }
     return array('photoNumber' => isset($matches[2]) ? $matches[2] : 1, 'albumUrl' => isset($matches[4]) ? $matches[4] : '', 'albumName' => $albumName);
 }
Ejemplo n.º 28
0
 public function getLastPhotoIdList($listType, $checkPrivacy, $photoId)
 {
     $privacy = $this->getPrivacyCondition($checkPrivacy);
     $privaceQuery = $privacy['query'];
     $condition = PHOTO_BOL_PhotoService::getInstance()->getQueryCondition($listType, array('photo' => 'p', 'album' => 'a', 'featured' => 'f'));
     $params = array_merge($condition['params'], array('status' => 'approved', 'limit' => PHOTO_BOL_PhotoService::ID_LIST_LIMIT), $privacy['params']);
     switch ($listType) {
         case 'latest':
             $sql = 'SELECT `p`.`id`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a`
                         ON(`a`.`id` = `p`.`albumId`)
                 ' . $condition['join'] . '
                 WHERE `p`.`status` = :status' . $privaceQuery . ' AND
                 ' . $condition['where'] . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :limit';
             break;
         case 'userPhotos':
             $ownerId = PHOTO_BOL_PhotoService::getInstance()->findPhotoOwner($photoId);
             $sql = 'SELECT `p`.`id`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON(`a`.`id` = `p`.`albumId`)
                 WHERE `p`.`status` = :status AND `a`.`userId` = :userId' . $privaceQuery . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :limit';
             $params['userId'] = $ownerId;
             break;
         case 'entityPhotos':
             $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
             $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId);
             $sql = 'SELECT `p`.`id`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON(`a`.`id` = `p`.`albumId`)
                 WHERE `p`.`status` = :status AND `a`.`entityId` = :entityId AND `a`.`entityType` = :entityType ' . $privaceQuery . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :limit';
             $params['id'] = $photoId;
             $params['entityType'] = $album->entityType;
             $params['entityId'] = $album->entityId;
             break;
         case 'albumPhotos':
             $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
             $sql = 'SELECT `p`.`id`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON(`a`.`id` = `p`.`albumId`)
                 WHERE `p`.`status` = :status AND  `p`.`albumId` = :albumId' . $privaceQuery . '
                 ORDER BY `p`.`id` DESC
                 LIMIT :limit';
             $params['albumId'] = $photo->albumId;
             break;
         case 'featured':
             $sql = 'SELECT `p`.`id`
                 FROM `' . $this->getTableName() . '` AS `p`
                     INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a`
                         ON(`p`.`albumId` = `a`.`id`)
                     INNER JOIN `' . PHOTO_BOL_PhotoFeaturedDao::getInstance()->getTableName() . '` AS `f`
                         ON(`p`.`id` = `f`.`photoId`)
                 ' . $condition['join'] . '
                 WHERE `f`.`photoId` < :id AND `p`.`status` = :status' . $privaceQuery . ' AND
                 ' . $condition['where'] . '
                 ORDER BY `f`.`photoId` DESC
                 LIMIT :limit';
             $params['id'] = $photoId;
             break;
     }
     return $this->dbo->queryForColumnList($sql, $params);
 }
Ejemplo n.º 29
0
    public function __construct(array $params)
    {
        parent::__construct();
        //Mehul change
        $is_user_id = $_SESSION['userId'];
        if (!empty($is_user_id)) {
            $this->user = BOL_UserService::getInstance()->findUserById($is_user_id);
            $user_sex = $this->user->getAccountType();
            $this->assign('user_sex', $user_sex);
        }
        //Mehul change
        $plugin = OW::getPluginManager()->getPlugin('photo');
        $hasSideBar = OW::getThemeManager()->getCurrentTheme()->getDto()->getSidebarPosition() != 'none';
        $photoParams = array('classicMode' => (bool) OW::getConfig()->getValue('photo', 'photo_list_view_classic'));
        $contParams = array('isClassic' => $photoParams['classicMode'], 'isModerator' => OW::getUser()->isAuthorized('photo'));
        switch ($params['type']) {
            case 'albums':
                $photoParams = array('userId' => $params['userId'], 'action' => 'getAlbumList', 'level' => $hasSideBar ? 3 : 4, 'classicMode' => (bool) OW::getConfig()->getValue('photo', 'album_list_view_classic'), 'isOwner' => $params['userId'] == OW::getUser()->getId() || OW::getUser()->isAuthorized('photo'));
                $contParams['isOwner'] = $photoParams['isOwner'];
                $contParams['isClassic'] = $photoParams['classicMode'];
                break;
            case 'albumPhotos':
                $photoParams['albumId'] = $params['albumId'];
                $photoParams['isOwner'] = PHOTO_BOL_PhotoAlbumService::getInstance()->isAlbumOwner($params['albumId'], OW::getUser()->getId());
                $photoParams['level'] = $photoParams['classicMode'] ? $hasSideBar ? 4 : 5 : 4;
                $contParams['isOwner'] = $photoParams['isOwner'];
                $contParams['albumId'] = $params['albumId'];
                break;
            case 'userPhotos':
                $photoParams['userId'] = $params['userId'];
                $photoParams['isOwner'] = $params['userId'] == OW::getUser()->getId();
                $photoParams['level'] = $photoParams['classicMode'] ? $hasSideBar ? 4 : 5 : 4;
                $contParams['isOwner'] = $photoParams['isOwner'];
                break;
            case 'tag':
                $photoParams['searchVal'] = $params['tag'];
            default:
                $photoParams['level'] = $photoParams['classicMode'] ? $hasSideBar ? 4 : 5 : 4;
                break;
        }
        $photoDefault = array('getPhotoURL' => OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder'), 'listType' => $params['type'], 'rateUserId' => OW::getUser()->getId(), 'urlHome' => OW_URL_HOME);
        $contDefault = array('downloadAccept' => (bool) OW::getConfig()->getValue('photo', 'download_accept'), 'downloadUrl' => OW_URL_HOME . 'photo/download-photo/:id', 'actionUrl' => $photoDefault['getPhotoURL'], 'listType' => $params['type']);
        $document = OW::getDocument();
        $document->addScriptDeclarationBeforeIncludes(';window.browsePhotoParams = ' . json_encode(array_merge($photoDefault, $photoParams)) . ';');
        $document->addOnloadScript(';window.browsePhoto.init();');
        $document->addScriptDeclarationBeforeIncludes(';window.photoContextActionParams = ' . json_encode(array_merge($contDefault, $contParams)));
        $document->addOnloadScript(';window.photoContextAction.init();');
        $this->assign('isClassicMode', $photoParams['classicMode']);
        $this->assign('hasSideBar', $hasSideBar);
        $this->assign('type', $params['type']);
        $document->addStyleSheet($plugin->getStaticCssUrl() . 'browse_photo.css');
        $document->addScript($plugin->getStaticJsUrl() . 'browse_photo.js');
        $language = OW::getLanguage();
        if ($params['type'] != 'albums') {
            $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_INIT_FLOATBOX);
            OW::getEventManager()->trigger($event);
            $script = '$(document.getElementById("browse-photo")).on("click", ".ow_photo_item_wrap img", function( event )
            {
            console.log("photo_list.php");
                var data = $(this).closest(".ow_photo_item_wrap").data(), _data = {};

                if ( data.dimension && data.dimension.length )
                {
                    try
                    {
                        var dimension = JSON.parse(data.dimension);

                        _data.main = dimension.main;
                    }
                    catch( e )
                    {
                        _data.main = [this.naturalWidth, this.naturalHeight];
                    }
                }
                else
                {
                    _data.main = [this.naturalWidth, this.naturalHeight];
                }

                _data.mainUrl = data.photoUrl;

                photoView.setId(data.photoId, data.listType, browsePhoto.getMoreData(), _data);
            });';
            $document->addOnloadScript($script);
            $language->addKeyForJs('photo', 'tb_edit_photo');
            $language->addKeyForJs('photo', 'confirm_delete');
            $language->addKeyForJs('photo', 'mark_featured');
            $language->addKeyForJs('photo', 'remove_from_featured');
            $language->addKeyForJs('photo', 'no_photo');
            $language->addKeyForJs('photo', 'rating_total');
            $language->addKeyForJs('photo', 'rating_your');
            $language->addKeyForJs('base', 'rate_cmp_owner_cant_rate_error_message');
            $language->addKeyForJs('photo', 'download_photo');
            $language->addKeyForJs('photo', 'delete_photo');
            $language->addKeyForJs('photo', 'save_as_avatar');
            $language->addKeyForJs('photo', 'save_as_cover');
            $language->addKeyForJs('photo', 'search_invitation');
            $language->addKeyForJs('photo', 'set_as_album_cover');
            $language->addKeyForJs('photo', 'search_result_empty');
        } else {
            $language->addKeyForJs('photo', 'edit_album');
            $language->addKeyForJs('photo', 'delete_album');
            $language->addKeyForJs('photo', 'album_delete_not_allowed');
            $language->addKeyForJs('photo', 'newsfeed_album');
            $language->addKeyForJs('photo', 'are_you_sure');
        }
        $language->addKeyForJs('photo', 'no_items');
    }
Ejemplo n.º 30
0
 public function moveTemporaryPhoto($tmpId, $albumId, $desc, $tag = NULL, $angle = 0, $uploadKey = null, $status = null)
 {
     $tmp = $this->photoTemporaryDao->findById($tmpId);
     $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId);
     if (!$tmp || !$album) {
         return FALSE;
     }
     $previewTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 1);
     $mainTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 2);
     $originalTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 3);
     $smallTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 4);
     $fullscreenTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 5);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $album->userId, 'action' => 'photo_view_album'));
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $photo = new PHOTO_BOL_Photo();
     $photo->description = htmlspecialchars(trim($desc));
     $photo->albumId = $albumId;
     $photo->addDatetime = time();
     $photo->status = empty($status) ? "approved" : $status;
     $photo->hasFullsize = (int) $tmp->hasFullsize;
     $photo->privacy = !empty($privacy) ? $privacy : 'everybody';
     $photo->hash = uniqid();
     $photo->uploadKey = empty($uploadKey) ? $photoService->getPhotoUploadKey($albumId) : $uploadKey;
     PHOTO_BOL_PhotoDao::getInstance()->save($photo);
     try {
         $storage = OW::getStorage();
         $dimension = array();
         if ((int) $angle !== 0) {
             $tmpImage = $tmp->hasFullsize ? (bool) OW::getConfig()->getValue('photo', 'store_fullsize') ? $originalTmp : $fullscreenTmp : $mainTmp;
             $smallImg = new UTIL_Image($tmpImage);
             $smallImg->resizeImage(PHOTO_BOL_PhotoService::DIM_SMALL_WIDTH, PHOTO_BOL_PhotoService::DIM_SMALL_HEIGHT, TRUE)->rotate($angle)->saveImage($smallTmp);
             $storage->copyFile($smallTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_SMALL));
             $dimension[PHOTO_BOL_PhotoService::TYPE_SMALL] = array($smallImg->getWidth(), $smallImg->getHeight());
             $smallImg->destroy();
             $previewImage = new UTIL_Image($tmpImage);
             $previewImage->resizeImage(PHOTO_BOL_PhotoService::DIM_PREVIEW_WIDTH, PHOTO_BOL_PhotoService::DIM_PREVIEW_HEIGHT)->rotate($angle)->saveImage($previewTmp);
             $storage->copyFile($previewTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_PREVIEW));
             $dimension[PHOTO_BOL_PhotoService::TYPE_PREVIEW] = array($previewImage->getWidth(), $previewImage->getHeight());
             $previewImage->destroy();
             $main = new UTIL_Image($tmpImage);
             $main->resizeImage(PHOTO_BOL_PhotoService::DIM_MAIN_WIDTH, PHOTO_BOL_PhotoService::DIM_MAIN_HEIGHT)->rotate($angle)->saveImage($mainTmp);
             $storage->copyFile($mainTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_MAIN));
             $dimension[PHOTO_BOL_PhotoService::TYPE_MAIN] = array($main->getWidth(), $main->getHeight());
             $main->destroy();
             $originalImage = new UTIL_Image($tmpImage);
             $originalImage->resizeImage(PHOTO_BOL_PhotoService::DIM_ORIGINAL_WIDTH, PHOTO_BOL_PhotoService::DIM_ORIGINAL_HEIGHT)->rotate($angle)->saveImage($originalTmp);
             $storage->copyFile($originalTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL));
             $dimension[PHOTO_BOL_PhotoService::TYPE_ORIGINAL] = array($originalImage->getWidth(), $originalImage->getHeight());
             $originalImage->destroy();
             if ($tmp->hasFullsize && (bool) OW::getConfig()->getValue('photo', 'store_fullsize')) {
                 $fullscreen = new UTIL_Image($tmpImage);
                 $fullscreen->resizeImage(PHOTO_BOL_PhotoService::DIM_FULLSCREEN_WIDTH, PHOTO_BOL_PhotoService::DIM_FULLSCREEN_HEIGHT)->rotate($angle)->saveImage($fullscreenTmp);
                 $storage->copyFile($fullscreenTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN));
                 $dimension[PHOTO_BOL_PhotoService::TYPE_FULLSCREEN] = array($fullscreen->getWidth(), $fullscreen->getHeight());
                 $fullscreen->destroy();
             }
         } else {
             $storage->copyFile($smallTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_SMALL));
             list($width, $height) = getimagesize($smallTmp);
             $dimension[PHOTO_BOL_PhotoService::TYPE_SMALL] = array($width, $height);
             $storage->copyFile($previewTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_PREVIEW));
             list($width, $height) = getimagesize($previewTmp);
             $dimension[PHOTO_BOL_PhotoService::TYPE_PREVIEW] = array($width, $height);
             $storage->copyFile($mainTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_MAIN));
             list($width, $height) = getimagesize($mainTmp);
             $dimension[PHOTO_BOL_PhotoService::TYPE_MAIN] = array($width, $height);
             $storage->copyFile($originalTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL));
             list($width, $height) = getimagesize($originalTmp);
             $dimension[PHOTO_BOL_PhotoService::TYPE_ORIGINAL] = array($width, $height);
             if ($tmp->hasFullsize && (bool) OW::getConfig()->getValue('photo', 'store_fullsize')) {
                 $storage->copyFile($fullscreenTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN));
                 list($width, $height) = getimagesize($fullscreenTmp);
                 $dimension[PHOTO_BOL_PhotoService::TYPE_FULLSCREEN] = array($width, $height);
             }
         }
         $photo->setDimension(json_encode($dimension));
         PHOTO_BOL_PhotoDao::getInstance()->save($photo);
         if (mb_strlen($desc)) {
             BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', $photoService->descToHashtag($desc));
         }
         if (mb_strlen($tag)) {
             BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', explode(',', $tag));
         }
         OW::getEventManager()->trigger(new OW_Event('photo.onMoveTemporaryPhoto', array('tmpId' => $tmpId, 'albumId' => $albumId, 'photoId' => $photo->id)));
     } catch (Exception $e) {
         $photo = NULL;
     }
     return $photo;
 }