Exemplo n.º 1
0
 /**
  * Returns an instance of class.
  *
  * @return PHOTO_BOL_PhotoDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemplo n.º 2
0
 public function findPhotosInAlbum($albumId, array $photos)
 {
     $self = $this;
     return array_map(function ($photo) use($self) {
         $photo['url'] = $self->getPhotoUrlByType($photo['id'], PHOTO_BOL_PhotoService::TYPE_PREVIEW, $photo['hash'], !empty($photo['dimension']) ? $photo['dimension'] : false);
         return $photo;
     }, $this->photoDao->findPhotosInAlbum($albumId, $photos));
 }
Exemplo n.º 3
0
 private function __construct()
 {
     $this->photoDao = PHOTO_BOL_PhotoDao::getInstance();
     $this->photoCacheDao = PHOTO_BOL_PhotoCacheDao::getInstance();
     $this->dataDao = PHOTO_BOL_SearchDataDao::getInstance();
     $this->indexDao = PHOTO_BOL_SearchIndexDao::getInstance();
     $this->entityTypeDao = PHOTO_BOL_SearchEntityTypeDao::getInstance();
     $this->reloadEntityTypes();
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 public function findIndexedData($searchVal, array $entityTypes = array(), $limit = PHOTO_BOL_SearchService::SEARCH_LIMIT)
 {
     $condition = PHOTO_BOL_PhotoService::getInstance()->getQueryCondition('searchByDesc', array('photo' => 'p', 'album' => 'a'));
     $sql = 'SELECT `index`.*
         FROM `' . $this->getTableName() . '` AS `index`
             INNER JOIN `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '` AS `p` ON(`index`.`entityId` = `p`.`id`)
             INNER JOIN `' . PHOTO_BOL_PhotoAlbumDao::getInstance()->getTableName() . '` AS `a` ON(`a`.`id` = `p`.`albumId`)
         ' . $condition['join'] . '
         WHERE MATCH(`index`.`' . self::CONTENT . '`) AGAINST(:val IN BOOLEAN MODE) AND `p`.`privacy` = :everybody AND `p`.`status` = :status AND ' . $condition['where'];
     if (count($entityTypes) !== 0) {
         $sql .= ' AND `index`.`' . self::ENTITY_TYPE_ID . '` IN (SELECT `entity`.`id`
             FROM `' . PHOTO_BOL_SearchEntityTypeDao::getInstance()->getTableName() . '` AS `entity`
             WHERE `entity`.`' . PHOTO_BOL_SearchEntityTypeDao::ENTITY_TYPE . '` IN( ' . $this->dbo->mergeInClause($entityTypes) . '))';
     }
     $sql .= ' LIMIT :limit';
     return $this->dbo->queryForObjectList($sql, $this->getDtoClassName(), array_merge($condition['params'], array('val' => $searchVal, 'limit' => (int) $limit, 'everybody' => PHOTO_BOL_PhotoDao::PRIVACY_EVERYBODY, 'status' => 'approved')));
 }
Exemplo n.º 6
0
 public function findUserPhotos($userId, $start, $offset)
 {
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $photoDao = PHOTO_BOL_PhotoDao::getInstance();
     $albumDao = PHOTO_BOL_PhotoAlbumDao::getInstance();
     $query = 'SELECT p.* FROM ' . $photoDao->getTableName() . ' AS p
         INNER JOIN ' . $albumDao->getTableName() . ' AS a ON p.albumId=a.id
             WHERE a.userId=:u AND p.status = "approved" ORDER BY p.addDatetime DESC
                 LIMIT :start, :offset';
     $list = OW::getDbo()->queryForList($query, array('u' => $userId, 'start' => $start, 'offset' => $offset));
     $out = array();
     foreach ($list as $photo) {
         $id = $photo['id'];
         $out[$id] = array('id' => $id, 'thumb' => $photoService->getPhotoPreviewUrl($id), 'url' => $photoService->getPhotoUrl($id), 'path' => $photoService->getPhotoPath($id), 'description' => $photo['description'], 'permalink' => OW::getRouter()->urlForRoute('view_photo', array('id' => $id)));
         $out[$id]['oembed'] = json_encode(array('type' => 'photo', 'url' => $out[$id]['url'], 'href' => $out[$id]['permalink'], 'description' => $out[$id]['description']));
     }
     return $out;
 }
Exemplo n.º 7
0
 public function cropAlbumCover(PHOTO_BOL_PhotoAlbum $album, $coords, $viewSize, $photoId = 0)
 {
     if (!empty($photoId) && ($photo = $this->photoDao->findById($photoId)) !== NULL) {
         $path = $this->photoDao->getPhotoPath($photo->id, $photo->hash, 'main');
     } else {
         $path = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverPathByAlbumId($album->id);
     }
     $storage = OW::getStorage();
     $tmpPath = OW::getPluginManager()->getPlugin('photo')->getPluginFilesDir() . uniqid(time(), TRUE) . '.jpg';
     $storage->copyFileToLocalFS($path, $tmpPath);
     if (($coverDto = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->findByAlbumId($album->id)) === NULL) {
         $coverDto = new PHOTO_BOL_PhotoAlbumCover();
         $coverDto->albumId = $album->id;
         PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->save($coverDto);
     }
     $oldCover = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverPathForCoverEntity($coverDto);
     $oldCoverOrig = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverOrigPathForCoverEntity($coverDto);
     $coverDto->hash = uniqid();
     $coverDto->auto = 0;
     try {
         $image = new UTIL_Image($tmpPath);
         if ($image->getWidth() >= $coords['w'] && $coords['w'] > 0 && $image->getHeight() >= $coords['h'] && $coords['h'] > 0) {
             $width = $image->getWidth();
             $k = $width / $viewSize;
             $image->cropImage($coords['x'] * $k, $coords['y'] * $k, $coords['w'] * $k, $coords['h'] * $k);
         }
         $saveImage = OW::getPluginManager()->getPlugin('photo')->getPluginFilesDir() . uniqid(time(), TRUE) . '.jpg';
         $image->saveImage($saveImage);
         $image->destroy();
         $storage->copyFile($saveImage, PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverPathForCoverEntity($coverDto));
         $storage->copyFile($tmpPath, PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverOrigPathForCoverEntity($coverDto));
         $storage->removeFile($oldCover);
         $storage->removeFile($oldCoverOrig);
         @unlink($saveImage);
         @unlink($tmpPath);
         PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->save($coverDto);
     } catch (Exception $e) {
         return FALSE;
     }
     return array('cover' => PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverUrlForCoverEntity($coverDto), 'coverOrig' => PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverOrigUrlForCoverEntity($coverDto));
 }
Exemplo n.º 8
0
 public function updatePhotosPrivacy($userId, $privacy)
 {
     $albumIdList = $this->photoAlbumDao->getUserAlbumIdList($userId);
     if (!$albumIdList) {
         return;
     }
     $this->photoDao->updatePrivacyByAlbumIdList($albumIdList, $privacy);
     PHOTO_BOL_PhotoService::getInstance()->cleanListCache();
     foreach ($albumIdList as $albumId) {
         if (!($photos = $this->photoDao->getAlbumAllPhotos($albumId))) {
             continue;
         }
         $idList = array();
         foreach ($photos as $photo) {
             array_push($idList, $photo->id);
         }
         $status = $privacy == 'everybody';
         $event = new OW_Event('base.update_entity_items_status', array('entityType' => 'photo_rates', 'entityIds' => $idList, 'status' => $status));
         OW::getEventManager()->trigger($event);
     }
 }
 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;
 }
Exemplo n.º 10
0
    ');
} catch (Exception $e) {
    Updater::getLogger()->addEntry(json_encode($e));
}
try {
    UPDATE_Autoload::getInstance()->addPackagePointer('PHOTO_BOL', $plugin->getBolDir());
    PHOTO_BOL_SearchService::getInstance()->addEntityType(PHOTO_BOL_SearchService::ENTITY_TYPE_ALBUM);
    PHOTO_BOL_SearchService::getInstance()->addEntityType(PHOTO_BOL_SearchService::ENTITY_TYPE_PHOTO);
} catch (Exception $e) {
    Updater::getLogger()->addEntry(json_encode($e));
}
try {
    $entityTypeId = PHOTO_BOL_SearchService::getInstance()->getEntityTypeId(PHOTO_BOL_SearchService::ENTITY_TYPE_PHOTO);
    Updater::getDbo()->query('INSERT INTO `' . PHOTO_BOL_SearchDataDao::getInstance()->getTableName() . '` (`entityTypeId`, `entityId`, `content`)
        SELECT ' . $entityTypeId . ', `id`, `description`
        FROM `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '`');
} catch (Exception $e) {
    Updater::getLogger()->addEntry(json_encode($e));
}
$config = Updater::getConfigService();
if (!$config->configExists('photo', 'photo_list_view_classic')) {
    $config->addConfig('photo', 'photo_list_view_classic', FALSE);
}
if (!$config->configExists('photo', 'album_list_view_classic')) {
    $config->addConfig('photo', 'album_list_view_classic', FALSE);
}
if (!$config->configExists('photo', 'photo_view_classic')) {
    $config->addConfig('photo', 'photo_view_classic', FALSE);
}
if (!$config->configExists('photo', 'download_accept')) {
    $config->addConfig('photo', 'download_accept', TRUE);
Exemplo n.º 11
0
 public function isValid($value)
 {
     $photoIdList = explode(',', $value);
     $count = count($photoIdList);
     if ($count === 0 || (int) PHOTO_BOL_PhotoDao::getInstance()->countPhotosInAlbumByPhotoIdList($this->allbumId, $photoIdList) !== $count) {
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 12
0
 public function updatePhotoTags()
 {
     if (OW::getConfig()->getValue('photo', 'update_tag_process')) {
         $sql = 'SELECT `et`.`id`, `et`.`entityId`, `et`.`tagId`
             FROM `' . BOL_EntityTagDao::getInstance()->getTableName() . '` AS `et`
                 INNER JOIN `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '` AS `p` ON(`et`.`entityId` = `p`.`id`)
             WHERE `et`.`entityType` = :entityType AND
                 `et`.`id` NOT IN (SELECT `entityTagId` FROM `' . OW_DB_PREFIX . 'photo_update_tag`) AND
                 `p`.`dimension` IS NULL
             LIMIT :limit';
         $tagList = OW::getDbo()->queryForList($sql, array('entityType' => 'photo', 'limit' => 500));
         if (empty($tagList)) {
             OW::getConfig()->saveConfig('photo', 'update_tag_process', false);
             return;
         }
         $photoTagList = array();
         $tagIdList = array();
         foreach ($tagList as $tag) {
             if (!array_key_exists($tag['entityId'], $photoTagList)) {
                 $photoTagList[$tag['entityId']] = array();
             }
             $photoTagList[$tag['entityId']][] = $tag['tagId'];
             $tagIdList[] = $tag['id'];
         }
         foreach ($photoTagList as $photoId => $photoTag) {
             $tags = BOL_TagDao::getInstance()->findByIdList($photoTag);
             if (empty($tags)) {
                 continue;
             }
             $str = array();
             foreach ($tags as $tag) {
                 $str[] = '#' . implode('', array_map('trim', explode(' ', $tag->label)));
             }
             $photo = PHOTO_BOL_PhotoDao::getInstance()->findById($photoId);
             $photo->description .= ' ' . implode(' ', $str);
             PHOTO_BOL_PhotoDao::getInstance()->save($photo);
         }
         OW::getDbo()->query('INSERT IGNORE INTO `' . OW_DB_PREFIX . 'photo_update_tag`(`entityTagId`) VALUES(' . implode('),(', $tagIdList) . ');');
     }
 }
Exemplo n.º 13
0
 public function backgroundLoadPhoto(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['photoIdList'])) {
         return;
     }
     $photoList = PHOTO_BOL_PhotoDao::getInstance()->findByIdList($params['photoIdList']);
     $js = '$(window).load(function(){';
     foreach ($photoList as $photo) {
         if ($photo->hasFullsize) {
             $js .= ';new Image().src = ' . json_encode($this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash));
         } else {
             $js .= ';new Image().src = ' . json_encode($this->photoService->getPhotoUrl($photo->id, FALSE, $photo->hash));
         }
     }
     $js .= '});';
     OW::getDocument()->addScriptDeclaration($js);
 }
Exemplo n.º 14
0
 public function onUpdateInfo(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if ($params['entityType'] != self::ENTITY_TYPE) {
         return;
     }
     foreach ($data as $photoId => $info) {
         $status = $info['status'] == BOL_ContentService::STATUS_APPROVAL ? PHOTO_BOL_PhotoDao::STATUS_APPROVAL : PHOTO_BOL_PhotoDao::STATUS_APPROVED;
         $photo = $this->service->findPhotoById($photoId);
         $photo->status = $status;
         PHOTO_BOL_PhotoDao::getInstance()->save($photo);
         OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_CONTENT_UPDATE, array('id' => $photoId)));
     }
 }
Exemplo n.º 15
0
 public function countPhotos()
 {
     return PHOTO_BOL_PhotoDao::getInstance()->countPhotos('latest');
 }
Exemplo n.º 16
0
 public function findUserAlbumList($userId, $first, $limit, array $exclude = array())
 {
     $sql = 'SELECT `a`.*
         FROM `' . $this->getTableName() . '` AS `a`
             INNER JOIN `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '` AS `p` ON(`p`.`albumId` = `a`.`id` AND `p`.`status` = :status)
         WHERE `' . self::USER_ID . '` = :userId ' . (count($exclude) !== 0 ? ' AND `id` NOT IN (' . implode(',', array_map('intval', $exclude)) . ')' : '') . '
         GROUP BY `a`.`id`
         ORDER BY `id` DESC
         LIMIT :first, :limit';
     $params = array('userId' => $userId, 'status' => PHOTO_BOL_PhotoDao::STATUS_APPROVED, 'first' => (int) $first, 'limit' => (int) $limit);
     return $this->dbo->queryForList($sql, $params);
 }
Exemplo n.º 17
0
$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();
$getMailer = OW::getMailer();
$getConfig = OW::getConfig();
$getFeedback = OW::getFeedback();
$getEventManager = OW::getEventManager();
$getMailer = OW::getMailer();
$ow = OW_DB_PREFIX;
$LanguageService = BOL_LanguageService::getInstance();
$OW_Language = OW_Language::getInstance();
$QUESTION_PRESENTATION_DATE = BOL_QuestionService::QUESTION_PRESENTATION_DATE;
$QUESTION_PRESENTATION_RANGE = BOL_QuestionService::QUESTION_PRESENTATION_RANGE;
$QUESTION_PRESENTATION_BIRTHDATE = BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE;
$QUESTION_PRESENTATION_AGE = BOL_QuestionService::QUESTION_PRESENTATION_AGE;
$QUESTION_PRESENTATION_DATE = BOL_QuestionService::QUESTION_PRESENTATION_DATE;
Exemplo n.º 18
0
 public function countEntityPhotos($entityType, $entityId, $status = "approved")
 {
     return $this->photoDao->countEntityPhotos($entityType, $entityId, $status);
 }
Exemplo n.º 19
0
 public function ajaxDeletePhotos($params)
 {
     if (!empty($params['albumId']) && !empty($params['photoIdList']) && ($album = $this->photoAlbumService->findAlbumById($params['albumId'])) !== NULL && ($album->userId == OW::getUser()->getId() || OW::getUser()->isAuthorized('photo'))) {
         $photoIdList = array_unique($params['photoIdList']);
         OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_BEFORE_MULTIPLE_PHOTO_DELETE, array('albumId' => $album->id, 'photoIdList' => $photoIdList)));
         $photoList = PHOTO_BOL_PhotoDao::getInstance()->findByIdList($photoIdList);
         foreach ($photoList as $photo) {
             if ($photo->albumId != $album->id) {
                 continue;
             }
             $this->photoService->deletePhoto($photo->id, TRUE);
         }
         $cover = PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->findByAlbumId($album->id);
         if ($cover === NULL || (int) $cover->auto) {
             PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->deleteCoverByAlbumId($album->id);
             $this->photoService->createAlbumCover($album->id, array_reverse(PHOTO_BOL_PhotoDao::getInstance()->getAlbumAllPhotos($album->id)));
         }
         return array('result' => TRUE, 'coverUrl' => PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->getAlbumCoverUrlByAlbumId($album->id), 'isHasCover' => PHOTO_BOL_PhotoAlbumCoverDao::getInstance()->isAlbumCoverExist($album->id));
     }
     return array('result' => FALSE);
 }
Exemplo n.º 20
0
 public function findDistinctPhotoUploadKeyByAlbumId($albumId)
 {
     return $this->photoDao->findDistinctPhotoUploadKeyByAlbumId($albumId);
 }
Exemplo n.º 21
0
 public function upload($params)
 {
     $userId = OW::getUser()->getId();
     if (!$userId) {
         throw new ApiResponseErrorException("Undefined userId");
     }
     if (empty($_FILES['file'])) {
         throw new ApiResponseErrorException("Files were not uploaded");
     }
     $files = array("tmp_name" => array($_FILES['file']["tmp_name"]));
     $selectedAlbumId = null;
     $source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $userId);
     $source = $source == "album" ? "album" : "all";
     if ($source == "album") {
         $selectedAlbumId = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_album", $userId);
         if (!$selectedAlbumId) {
             $source = "all";
         }
     }
     if ($source == "all") {
         $event = new OW_Event('photo.getMainAlbum', array('userId' => $userId));
         OW::getEventManager()->trigger($event);
         $album = $event->getData();
         $selectedAlbumId = !empty($album['album']) ? $album['album']['id'] : null;
     }
     if (!$selectedAlbumId && isset($_POST["albumId"])) {
         $selectedAlbumId = (int) $_POST["albumId"];
     }
     if (!$selectedAlbumId) {
         throw new ApiResponseErrorException("Undefined album");
     }
     $uploadedIdList = array();
     foreach ($files['tmp_name'] as $path) {
         $photo = OW::getEventManager()->call('photo.add', array('albumId' => $selectedAlbumId, 'path' => $path));
         if (!empty($photo['photoId'])) {
             $uploadedIdList[] = $photo['photoId'];
             BOL_AuthorizationService::getInstance()->trackActionForUser($userId, 'photo', 'upload');
         }
     }
     $result = array();
     if ($uploadedIdList) {
         $uploadedList = PHOTO_BOL_PhotoDao::getInstance()->findByIdList($uploadedIdList);
         if ($uploadedList) {
             /* @var $photo PHOTO_BOL_Photo */
             foreach ($uploadedList as $photo) {
                 $result[] = self::preparePhotoData($photo->id, $photo->hash, $photo->dimension, $photo->status);
             }
         }
     }
     $this->assign("uploaded", array($photo, $result));
 }
Exemplo n.º 22
0
 public function updatePhotoStatus($photoId, $status)
 {
     if (!$this->isActive()) {
         return null;
     }
     $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
     $photo->status = $status;
     PHOTO_BOL_PhotoDao::getInstance()->save($photo);
 }
Exemplo n.º 23
0
 /**
  * Class constructor
  *
  */
 private function __construct()
 {
     $this->photoDao = PHOTO_BOL_PhotoDao::getInstance();
     $this->photoFeaturedDao = PHOTO_BOL_PhotoFeaturedDao::getInstance();
 }
Exemplo n.º 24
0
 protected function onSubmitComplete($entityType, $entityId, PHOTO_BOL_PhotoAlbum $album, $photos)
 {
     $this->photoService->createAlbumCover($album->id, $photos);
     $userId = OW::getUser()->getId();
     $result = array('result' => TRUE);
     if (empty($photos)) {
         $result['url'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($userId), 'album' => $album->id));
         return $result;
     }
     $movedArray = array();
     foreach ($photos as $photo) {
         $movedArray[] = array('entityType' => $entityType, 'entityId' => $entityId, 'addTimestamp' => $photo->addDatetime, 'photoId' => $photo->id, 'hash' => $photo->hash, 'description' => $photo->description);
     }
     $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_ADD, $movedArray);
     OW::getEventManager()->trigger($event);
     $photoCount = count($photos);
     $photoIdList = array();
     foreach ($photos as $photo) {
         $photoIdList[] = $photo->id;
     }
     $newPhotos = PHOTO_BOL_PhotoDao::getInstance()->findByIdList($photoIdList);
     $approvalPhotos = array();
     foreach ($newPhotos as $photo) {
         if ($photo->status != PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
             $approvalPhotos[] = $photo;
         }
     }
     if (($approvalCount = count($approvalPhotos)) === $photoCount) {
         if ($approvalCount === 1) {
             OW::getFeedback()->info(OW::getLanguage()->text('photo', 'photo_uploaded_pending_approval'));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('photo', 'photos_uploaded_pending_approval', array('count' => $approvalCount)));
         }
         if ($this->photoAlbumService->countAlbumPhotos($album->id) > 0) {
             $result['url'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($userId), 'album' => $album->id));
         } else {
             $result['url'] = OW::getRouter()->urlForRoute('photo_user_albums', array('user' => BOL_UserService::getInstance()->getUserName($userId)));
         }
         return $result;
     }
     if ($photoCount == 1) {
         $this->photoService->triggerNewsfeedEventOnSinglePhotoAdd($album, $photos[0]);
     } else {
         $this->photoService->triggerNewsfeedEventOnMultiplePhotosAdd($album, $photos);
     }
     $result['url'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($userId), 'album' => $album->id));
     OW::getFeedback()->info(OW::getLanguage()->text('photo', 'photos_uploaded', array('count' => $photoCount)));
     return $result;
 }
Exemplo n.º 25
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';
 }
Exemplo n.º 26
0
 /**
  * Class constructor
  *
  */
 private function __construct()
 {
     $this->advancedphotoDao = ADVANCEDPHOTO_BOL_PhotoDao::getInstance();
     $this->photoDao = PHOTO_BOL_PhotoDao::getInstance();
     $this->photoService = PHOTO_BOL_PhotoService::getInstance();
 }
Exemplo n.º 27
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'))));
    }
Exemplo n.º 28
0
 public function findUserAlbumList($userId, $first, $limit, array $exclude = array())
 {
     $condition = PHOTO_BOL_PhotoService::getInstance()->getQueryCondition('findUserAlbumList', array('album' => 'a', 'photo' => 'p'), array('userId' => $userId, 'first' => $first, 'limit' => $limit, 'exclude' => $exclude));
     $sql = 'SELECT `a`.*
         FROM `' . $this->getTableName() . '` AS `a`
             INNER JOIN `' . PHOTO_BOL_PhotoDao::getInstance()->getTableName() . '` AS `p` ON(`p`.`albumId` = `a`.`id` AND `p`.`status` = :status)
             ' . $condition['join'] . '
         WHERE `a`.`' . self::USER_ID . '` = :userId ' . (count($exclude) !== 0 ? ' AND `a`.`id` NOT IN (' . implode(',', array_map('intval', $exclude)) . ')' : '') . ' AND
             ' . $condition['where'] . '
         GROUP BY `a`.`id`
         ORDER BY `a`.`id` DESC
         LIMIT :first, :limit';
     $params = array('userId' => $userId, 'status' => PHOTO_BOL_PhotoDao::STATUS_APPROVED, 'first' => (int) $first, 'limit' => (int) $limit);
     return $this->dbo->queryForList($sql, array_merge($params, $condition['params']));
 }