Example #1
0
 public function import($params)
 {
     $importDir = $params['importDir'];
     $txtFile = $importDir . 'configs.txt';
     // import configs
     if (file_exists($txtFile)) {
         $string = file_get_contents($txtFile);
         $configs = json_decode($string, true);
     }
     if (!$configs) {
         return;
     }
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $types = array('main', 'preview', 'original');
     $photoDir = $photoService->getPhotoUploadDir();
     $page = 1;
     while (true) {
         $photos = $photoService->findPhotoList('latest', $page, 10);
         $page++;
         if (empty($photos)) {
             break;
         }
         foreach ($photos as $photo) {
             foreach ($types as $type) {
                 $path = $photoService->getPhotoPath($photo['id'], $photo['hash'], $type);
                 $photoName = str_replace($photoDir, '', $path);
                 $content = file_get_contents($configs['url'] . '/' . $photoName);
                 if (mb_strlen($content)) {
                     OW::getStorage()->fileSetContent($path, $content);
                 }
             }
         }
     }
 }
Example #2
0
 public function import($params)
 {
     $importDir = $params['importDir'];
     $configFile = $importDir . 'config.txt';
     $service = GROUPS_BOL_Service::getInstance();
     $string = file_get_contents($configFile);
     $configs = json_decode($string, true);
     $sourceDirUrl = $configs['dirUrl'];
     $counter = 0;
     while (true) {
         $list = $service->findGroupList(GROUPS_BOL_Service::LIST_ALL, $counter, 100);
         if (empty($list)) {
             break;
         }
         $counter += 100;
         foreach ($list as $dto) {
             $fileName = $service->getGroupImageFileName($dto);
             if ($fileName === null) {
                 continue;
             }
             $sourceFileUrl = $sourceDirUrl . '/' . $fileName;
             $content = file_get_contents($sourceFileUrl);
             $distFilePath = $service->getGroupImagePath($dto);
             if (!empty($content)) {
                 OW::getStorage()->fileSetContent($distFilePath, $content);
             }
         }
     }
 }
Example #3
0
 public function addTemplate($fileName, $roleIds = null, $default = false)
 {
     $canvasWidth = self::CANVAS_WIDTH;
     $canvasHeight = $this->config['cover_height'];
     $coverImage = new UTIL_Image($fileName);
     $imageHeight = $coverImage->getHeight();
     $imageWidth = $coverImage->getWidth();
     $css = array('width' => 'auto', 'height' => 'auto');
     $tmp = $canvasWidth * $imageHeight / $imageWidth;
     if ($tmp >= $canvasHeight) {
         $css['width'] = '100%';
     } else {
         $css['height'] = '100%';
     }
     $template = new UHEADER_BOL_Template();
     $extension = UTIL_File::getExtension($fileName);
     $template->file = uniqid('template-') . '.' . $extension;
     $template->default = $default;
     $template->timeStamp = time();
     $dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
     $template->setSettings(array('dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
     $this->service->saveTemplate($template);
     if ($roleIds !== null) {
         $this->service->saveRoleIdsForTemplateId($template->id, $roleIds);
     }
     $templatePath = $this->service->getTemplatePath($template);
     OW::getStorage()->copyFile($fileName, $templatePath);
 }
Example #4
0
 public function import($params)
 {
     $importDir = $params['importDir'];
     $txtFile = $importDir . 'configs.txt';
     // import configs
     if (file_exists($txtFile)) {
         $string = file_get_contents($txtFile);
         $configs = json_decode($string, true);
     }
     if (!$configs) {
         return;
     }
     $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
     $giftsDir = $giftService->getGiftUploadDir();
     $tpls = $giftService->getTemplateList();
     if (empty($tpls)) {
         return;
     }
     foreach ($tpls as $tpl) {
         $dto = $tpl['dto'];
         $path = $giftService->getGiftFilePath($dto->id, $dto->uploadTimestamp, $dto->extension);
         $name = str_replace($giftsDir, '', $path);
         $content = file_get_contents($configs['url'] . '/' . $name);
         if (mb_strlen($content)) {
             OW::getStorage()->fileSetContent($path, $content);
         }
     }
 }
Example #5
0
 public function import($params)
 {
     $importDir = $params['importDir'];
     $txtFile = $importDir . 'configs.txt';
     // import configs
     if (file_exists($txtFile)) {
         $string = file_get_contents($txtFile);
         $configs = json_decode($string, true);
     }
     if (!$configs) {
         return;
     }
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $attDir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $attachments = $attachmentService->findAllAttachments();
     if (!$attachments) {
         return;
     }
     foreach ($attachments as $file) {
         OW::getDbo()->query("SELECT 1 ");
         $ext = UTIL_File::getExtension($file->fileName);
         $path = $attachmentService->getAttachmentFilePath($file->id, $file->hash, $ext);
         $fileName = str_replace($attDir, '', $path);
         $content = file_get_contents($configs['url'] . '/' . $fileName);
         if (mb_strlen($content)) {
             OW::getStorage()->fileSetContent($path, $content);
         }
     }
 }
Example #6
0
 private function exportConfigs(ZipArchive $za, $archiveDir)
 {
     $this->configs['avatarUrl'] = OW::getStorage()->getFileUrl(BOL_AvatarService::getInstance()->getAvatarsDir());
     $tableName = OW::getDbo()->escapeString(str_replace(OW_DB_PREFIX, '%%TBL-PREFIX%%', BOL_ConfigDao::getInstance()->getTableName()));
     $query = " SELECT `key`, `name`, `value`, `description` FROM " . BOL_ConfigDao::getInstance()->getTableName() . " WHERE name NOT IN ( 'maintenance', 'update_soft', 'site_installed', 'soft_build', 'soft_version' )\n                    AND `key` NOT IN ( 'dataimporter', 'dataexporter' ) ";
     $sql = DATAEXPORTER_BOL_ExportService::getInstance()->exportTableToSql(OW_DB_PREFIX . 'base_config', false, false, true, $query);
     $za->addFromString($archiveDir . '/configs.sql', $sql);
 }
Example #7
0
 public function export($params)
 {
     /* @var $za ZipArchives */
     $za = $params['zipArchive'];
     $archiveDir = $params['archiveDir'];
     $plugin = OW::getPluginManager()->getPlugin('groups');
     $string = json_encode(array('dirUrl' => OW::getStorage()->getFileUrl($plugin->getUserFilesDir())));
     $za->addFromString($archiveDir . '/' . 'config.txt', $string);
 }
Example #8
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);
 }
Example #9
0
 public function export($params)
 {
     $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance();
     $url = OW::getStorage()->getFileUrl($giftService->getGiftUploadDir());
     /* @var $za ZipArchives */
     $za = $params['zipArchive'];
     $archiveDir = $params['archiveDir'];
     $string = json_encode(array('url' => $url));
     $za->addFromString($archiveDir . '/' . 'configs.txt', $string);
 }
Example #10
0
 public function onBeforeGroupDelete(OW_Event $event)
 {
     $params = $event->getParams();
     $groupId = $params['groupId'];
     $group = GROUPS_BOL_Service::getInstance()->findGroupById($groupId);
     $fileName = GROUPS_BOL_Service::getInstance()->getGroupImagePath($group);
     if ($fileName !== null) {
         OW::getStorage()->removeFile($fileName);
     }
 }
Example #11
0
 public function export($params)
 {
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $url = OW::getStorage()->getFileUrl($photoService->getPhotoUploadDir());
     /* @var $za ZipArchives */
     $za = $params['zipArchive'];
     $archiveDir = $params['archiveDir'];
     $string = json_encode(array('url' => $url));
     $za->addFromString($archiveDir . '/' . 'configs.txt', $string);
 }
Example #12
0
 public function export($params)
 {
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $dir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $url = OW::getStorage()->getFileUrl($dir);
     /* @var $za ZipArchives */
     $za = $params['zipArchive'];
     $archiveDir = $params['archiveDir'];
     $string = json_encode(array('url' => $url));
     $za->addFromString($archiveDir . '/' . 'configs.txt', $string);
 }
Example #13
0
 public static function getLocalPath($uri)
 {
     $userFilesUrl = OW::getStorage()->getFileUrl(OW_DIR_USERFILES);
     $path = null;
     if (stripos($uri, OW_URL_HOME) !== false) {
         $path = str_replace(OW_URL_HOME, OW_DIR_ROOT, $uri);
         $path = str_replace('/', DS, $path);
     } else {
         if (stripos($uri, $userFilesUrl) !== false) {
             $path = str_replace($userFilesUrl, OW_DIR_USERFILES, $uri);
             $path = str_replace('/', DS, $path);
         }
     }
     return $path;
 }
Example #14
0
 public function copy_resize_image($tmp_name, $slugimage, $idThumb, $extension, $width = null, $height = null)
 {
     if ($extension == null) {
         $extension = '';
     }
     $storage = OW::getStorage();
     $imagesDir = OW::getPluginManager()->getPlugin('spdownload')->getUserFilesDir();
     $imageName = $slugimage . '_' . $idThumb . '.' . $extension;
     $imagePath = $imagesDir . $imageName;
     $pluginfilesDir = Ow::getPluginManager()->getPlugin('spdownload')->getPluginFilesDir();
     $tmpImgPath = $slugimage . '_' . $idThumb . '.' . $extension;
     $image = new UTIL_Image($tmp_name);
     $image->resizeImage($width, $height)->saveImage($tmpImgPath);
     //Copy file into storage folder
     $storage->copyFile($tmpImgPath, $imagePath);
     unlink($tmpImgPath);
 }
Example #15
0
 private function prepareMarkup($photo, $layout = null)
 {
     $markup = array();
     $photo->title = UTIL_HtmlTag::autoLink($photo->title);
     $photo->url = OW::getStorage()->getFileUrl($this->themeService->getUserfileImagesDir() . $photo->getFilename());
     $photo->addDatetime = UTIL_DateTime::formatSimpleDate($photo->addDatetime, true);
     $markup['photo'] = $photo;
     $action = new BASE_ContextAction();
     $action->setKey('photo-moderate');
     $context = new BASE_CMP_ContextAction();
     $context->addAction($action);
     $lang = OW::getLanguage();
     $action = new BASE_ContextAction();
     $action->setKey('delete');
     $action->setParentKey('photo-moderate');
     $action->setLabel($lang->text('base', 'delete'));
     $action->setId('photo-delete');
     $action->addAttribute('rel', $photo->id);
     $context->addAction($action);
     $markup['contextAction'] = $context->render();
     $document = OW::getDocument();
     $onloadScript = $document->getOnloadScript();
     if (!empty($onloadScript)) {
         $markup['onloadScript'] = $onloadScript;
     }
     $scriptFiles = $document->getScripts();
     if (!empty($scriptFiles)) {
         $markup['scriptFiles'] = $scriptFiles;
     }
     $css = $document->getStyleDeclarations();
     if (!empty($css)) {
         $markup['css'] = $css;
     }
     $cssFiles = $document->getStyleSheets();
     if (!empty($cssFiles)) {
         $markup['cssFiles'] = $cssFiles;
     }
     $meta = $document->getMeta();
     if (!empty($meta)) {
         $markup['meta'] = $meta;
     }
     return $markup;
 }
Example #16
0
 /**
  * Removes file
  *
  * @param int $id
  */
 public function removeFile($id)
 {
     $path = $this->getFilePath($id);
     $storage = OW::getStorage();
     if ($storage->fileExists($path)) {
         $storage->removeFile($path);
     }
 }
Example #17
0
 public function addFromPhotos($query)
 {
     $photoId = $query['photoId'];
     $groupId = $query['groupId'];
     if (!GHEADER_CLASS_CreditsBridge::getInstance()->credits->isAvaliable(GHEADER_CLASS_Credits::ACTION_ADD)) {
         $error = GHEADER_CLASS_CreditsBridge::getInstance()->credits->getErrorMessage(GHEADER_CLASS_Credits::ACTION_ADD);
         throw new InvalidArgumentException($error);
     }
     $sourcePath = GHEADER_CLASS_PhotoBridge::getInstance()->pullPhoto($photoId);
     if ($sourcePath === null) {
         throw new InvalidArgumentException("The requested photo wasn't find");
     }
     $canvasWidth = $query['width'];
     $canvasHeight = OW::getConfig()->getValue('gheader', 'cover_height');
     $coverImage = new UTIL_Image($sourcePath);
     $imageHeight = $coverImage->getHeight();
     $imageWidth = $coverImage->getWidth();
     $css = array('width' => 'auto', 'height' => 'auto');
     $tmp = $canvasWidth * $imageHeight / $imageWidth;
     if ($tmp >= $canvasHeight) {
         $css['width'] = '100%';
     } else {
         $css['height'] = '100%';
     }
     $this->validateImage($coverImage, $canvasWidth, $canvasHeight);
     $cover = $this->service->findCoverByGroupId($groupId, GHEADER_BOL_Cover::STATUS_TMP);
     if ($cover === null) {
         $cover = new GHEADER_BOL_Cover();
     }
     $extension = UTIL_File::getExtension($sourcePath);
     $cover->file = uniqid('cover-' . $groupId . '-') . '.' . $extension;
     $cover->groupId = $groupId;
     $cover->status = GHEADER_BOL_Cover::STATUS_TMP;
     $cover->timeStamp = time();
     $dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
     $cover->setSettings(array('photoId' => $photoId, 'dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
     $this->service->saveCover($cover);
     $coverPath = $this->service->getCoverPath($cover);
     OW::getStorage()->copyFile($sourcePath, $coverPath);
     @unlink($sourcePath);
     $coverUrl = $this->service->getCoverUrl($cover);
     return array('src' => $coverUrl, 'data' => $cover->getSettings());
 }
Example #18
0
 /**
  * Removes photo file
  *
  * @param int $id
  * @param $hash
  * @param string $type
  */
 public function removePhotoFile($id, $hash, $type)
 {
     $path = $this->getPhotoPath($id, $hash, $type);
     $storage = OW::getStorage();
     if ($storage->fileExists($path)) {
         $storage->removeFile($path);
     }
 }
 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;
 }
Example #20
0
 /**
  * Returns list of users' avatars
  *
  * @param array $userIds
  * @param int $size
  * @return array
  */
 public function getAvatarsUrlList(array $userIds, $size = 1)
 {
     if (empty($userIds)) {
         return array();
     }
     $urlsList = array();
     if (is_array($userIds)) {
         $avatars = array();
         $prefix = OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . 'avatars' . DS . ($size == 1 ? self::AVATAR_PREFIX : self::AVATAR_BIG_PREFIX);
         $defAvatarUrl = $this->getDefaultAvatarUrl($size);
         $objList = $this->avatarDao->getAvatarsList($userIds);
         foreach ($objList as $avatar) {
             $avatars[$avatar->userId] = $avatar;
         }
         foreach ($userIds as $userId) {
             if (array_key_exists($userId, $avatars)) {
                 $urlsList[$userId] = OW::getStorage()->getFileUrl($prefix . $userId . '_' . $avatars[$userId]->hash . '.jpg');
                 if ($avatars[$userId]->status != BOL_ContentService::STATUS_ACTIVE) {
                     $urlsList[$userId] = $defAvatarUrl;
                 }
             } else {
                 $urlsList[$userId] = $defAvatarUrl;
             }
         }
     }
     return $urlsList;
 }
Example #21
0
 public function deleteImageById($id)
 {
     $image = $this->findById((int) $id);
     $data = $image->getData();
     $storage = OW::getStorage();
     $storage->removeFile(OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . $image->id . '-' . $data->name);
     $this->deleteById($image->id);
 }
Example #22
0
 private function unlinkControlValueImage($controlValue)
 {
     $fileName = basename(str_replace(')', '', $controlValue));
     if (OW::getStorage()->fileExists($this->userfileImagesDir . $fileName)) {
         OW::getStorage()->removeFile($this->userfileImagesDir . $fileName);
     }
 }
Example #23
0
 public function pullPhoto($photoId)
 {
     if (!$this->isActive()) {
         return null;
     }
     $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId);
     if (empty($photo)) {
         return null;
     }
     $source = PHOTO_BOL_PhotoService::getInstance()->getPhotoPath($photoId, $photo->hash);
     $pluginfilesDir = $this->plugin->getPluginFilesDir();
     $dist = $pluginfilesDir . uniqid('tmp_') . '.jpg';
     if (!OW::getStorage()->copyFileToLocalFS($source, $dist)) {
         return null;
     }
     return $dist;
 }
Example #24
0
 public function getAttachmentFileUrl($attId, $hash, $ext, $name = null)
 {
     $userfilesDir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $storage = OW::getStorage();
     return $storage->getFileUrl($userfilesDir . $this->getAttachmentFileName($attId, $hash, $ext, $name));
 }
 public function deleteAttachmentFiles()
 {
     $attachDtoList = $this->attachmentDao->getAttachmentForDelete();
     foreach ($attachDtoList as $attachDto) {
         /* @var $attachDto MAILBOX_BOL_Attachment */
         $ext = UTIL_File::getExtension($attachDto->fileName);
         $attachmentPath = $this->getAttachmentFilePath($attachDto->id, $attachDto->hash, $ext, $attachDto->fileName);
         try {
             OW::getStorage()->removeFile($attachmentPath);
             $this->attachmentDao->deleteById($attachDto->id);
         } catch (Exception $ex) {
         }
     }
 }
Example #26
0
 public function afterAvatarChange(OW_Event $event)
 {
     $params = $event->getParams();
     $userId = $params['userId'];
     $avatar = $this->avatarService->findByUserId($userId);
     $uAvatar = new UAVATARS_BOL_Avatar();
     $uAvatar->avatarId = $avatar->id;
     $uAvatar->userId = $userId;
     $avatarPath = $this->avatarService->getAvatarPath($userId, 3);
     $tmpPath = OW::getPluginManager()->getPlugin("uavatars")->getPluginFilesDir() . uniqid("tmp-") . '.jpg';
     if (!OW::getStorage()->copyFileToLocalFS($avatarPath, $tmpPath)) {
         return;
     }
     $photoStatus = $avatar->status == "active" ? "approved" : "approval";
     $photoId = $this->photoBridge->addPhoto($userId, $tmpPath, "", null, false, $photoStatus);
     @unlink($tmpPath);
     if (empty($photoId)) {
         return;
     }
     $uAvatar->photoId = $photoId;
     $uAvatar->timeStamp = time();
     $avatarPreview = $this->avatarService->getAvatarPath($userId, 2);
     $fileName = $this->uAvatarsService->storeAvatarImage($avatarPreview);
     if (empty($fileName)) {
         return;
     }
     if (!empty($uAvatar->fileName)) {
         $userfilesDir = OW::getPluginManager()->getPlugin('uavatars')->getUserFilesDir();
         OW::getStorage()->removeFile($userfilesDir . $uAvatar->fileName);
     }
     $uAvatar->fileName = $fileName;
     $this->uAvatarsService->saveAvatar($uAvatar);
 }
Example #27
0
 /**
  *
  * @param array $conversationIdList
  * @return array<MAILBOX_BOL_Attachment>
  */
 public function deleteAttachmentsByConversationList(array $conversationIdList)
 {
     $attachmentList = $this->attachmentDao->findAttachmentstByConversationList($conversationIdList);
     foreach ($attachmentList as $attachment) {
         $ext = UTIL_File::getExtension($attachment['fileName']);
         $path = $this->getAttachmentFilePath($attachment['id'], $attachment['hash'], $ext);
         if (OW::getStorage()->removeFile($path)) {
             $this->attachmentDao->deleteById($attachment['id']);
         }
     }
 }
Example #28
0
}
if (!$config->configExists('virtualgifts', 'uninstall_cron_busy')) {
    $config->addConfig('virtualgifts', 'uninstall_cron_busy', 0, 'Uninstall queue is busy');
}
if (!$config->configExists('virtualgifts', 'maintenance_mode_state')) {
    $state = (int) $config->getValue('base', 'maintenance');
    $config->addConfig('virtualgifts', 'maintenance_mode_state', $state, 'Stores site maintenance mode config before plugin uninstallation');
}
$sql = "CREATE TABLE IF NOT EXISTS `" . OW_DB_PREFIX . "virtualgifts_category` (\n  `id` int(11) NOT NULL auto_increment,\n  `order` int(11) default '0',\n  PRIMARY KEY  (`id`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
OW::getDbo()->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `" . OW_DB_PREFIX . "virtualgifts_template` (\n  `id` int(11) NOT NULL auto_increment,\n  `categoryId` int(11) default NULL,\n  `extension` varchar(10) NOT NULL,\n  `uploadTimestamp` int(11) NOT NULL default '0',\n  `price` int(10) default '0',\n  PRIMARY KEY  (`id`),\n  KEY `categoryId` (`categoryId`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
OW::getDbo()->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `" . OW_DB_PREFIX . "virtualgifts_user_gift` (\n  `id` int(11) NOT NULL auto_increment,\n  `templateId` int(11) NOT NULL,\n  `senderId` int(11) NOT NULL,\n  `recipientId` int(11) NOT NULL,\n  `sendTimestamp` int(11) NOT NULL,\n  `message` text,\n  `private` tinyint(1) NOT NULL default '0',\n  PRIMARY KEY  (`id`),\n  KEY `senderId` (`senderId`),\n  KEY `recipientId` (`recipientId`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
OW::getDbo()->query($sql);
try {
    $storage = OW::getStorage();
    $userfilesDir = OW_DIR_USERFILES . 'plugins' . DS . 'virtual_gifts' . DS;
    for ($i = 1; $i <= 15; $i++) {
        $defaultPath = dirname(__FILE__) . DS . 'static' . DS . 'default' . DS . 'gift' . $i . '.jpg';
        if (!file_exists($defaultPath)) {
            continue;
        }
        $time = time();
        $sql = "INSERT INTO `" . OW_DB_PREFIX . "virtualgifts_template` (`extension`, `uploadTimestamp`) VALUES ('jpg', :ts)";
        $id = OW::getDbo()->insert($sql, array('ts' => $time));
        if ($id) {
            $imagePath = $userfilesDir . 'gift_' . $id . '_' . $time . '.jpg';
            if (!$storage->copyFile($defaultPath, $imagePath)) {
                $sql = "DELETE FROM `" . OW_DB_PREFIX . "virtualgifts_template` WHERE `id` = :id";
                OW::getDbo()->query($sql, array('id' => $id));
            }
 public function deleteCoverByAlbumId($albumId)
 {
     if (empty($albumId) || ($cover = $this->findByAlbumId($albumId)) === NULL) {
         return FALSE;
     }
     $storate = OW::getStorage();
     $storate->removeFile($this->getAlbumCoverPathForCoverEntity($cover));
     $storate->removeFile($this->getAlbumCoverOrigPathForCoverEntity($cover));
     $example = new OW_Example();
     $example->andFieldEqual(self::ALBUM_ID, $albumId);
     return $this->deleteByExample($example);
 }
Example #30
0
 protected function saveImages($postFile, GROUPS_BOL_Group $group)
 {
     $service = GROUPS_BOL_Service::getInstance();
     $smallFile = $service->getGroupImagePath($group, GROUPS_BOL_Service::IMAGE_SIZE_SMALL);
     $bigFile = $service->getGroupImagePath($group, GROUPS_BOL_Service::IMAGE_SIZE_BIG);
     $tmpDir = OW::getPluginManager()->getPlugin('groups')->getPluginFilesDir();
     $smallTmpFile = $tmpDir . uniqid('small_') . '.jpg';
     $bigTmpFile = $tmpDir . uniqid('big_') . '.jpg';
     $image = new UTIL_Image($postFile['tmp_name']);
     $image->resizeImage(GROUPS_BOL_Service::IMAGE_WIDTH_BIG, null)->saveImage($bigTmpFile)->resizeImage(GROUPS_BOL_Service::IMAGE_WIDTH_SMALL, GROUPS_BOL_Service::IMAGE_WIDTH_SMALL, true)->saveImage($smallTmpFile);
     try {
         OW::getStorage()->copyFile($smallTmpFile, $smallFile);
         OW::getStorage()->copyFile($bigTmpFile, $bigFile);
     } catch (Exception $e) {
     }
     unlink($smallTmpFile);
     unlink($bigTmpFile);
 }