/**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_MediaPanelService
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 public function imagesDeleteProcess()
 {
     $config = OW::getConfig();
     // check if uninstall is in progress
     if (!$config->getValue('blogs', 'uninstall_inprogress')) {
         return;
     }
     // check if cron queue is not busy
     if ($config->getValue('blogs', 'uninstall_cron_busy')) {
         return;
     }
     $config->saveConfig('blogs', 'uninstall_cron_busy', 1);
     $mediaPanelService = BOL_MediaPanelService::getInstance();
     $mediaPanelService->deleteImages('blogs', self::IMAGES_DELETE_LIMIT);
     $config->saveConfig('blogs', 'uninstall_cron_busy', 0);
     if (!$mediaPanelService->countGalleryImages('blogs')) {
         $config->saveConfig('blogs', 'uninstall_inprogress', 0);
         BOL_PluginService::getInstance()->uninstall('blogs');
     }
 }
Example #3
0
 public function topicsDeleteProcess()
 {
     $config = OW::getConfig();
     // check if uninstall is in progress
     if (!$config->getValue('forum', 'uninstall_inprogress')) {
         return;
     }
     // check if cron queue is not busy
     if ($config->getValue('forum', 'uninstall_cron_busy')) {
         return;
     }
     $config->saveConfig('forum', 'uninstall_cron_busy', 1);
     $forumService = FORUM_BOL_ForumService::getInstance();
     $forumService->deleteTopics(self::TOPICS_DELETE_LIMIT);
     $mediaPanelService = BOL_MediaPanelService::getInstance();
     $mediaPanelService->deleteImages('forum', self::MEDIA_DELETE_LIMIT);
     $config->saveConfig('forum', 'uninstall_cron_busy', 0);
     if ((int) $forumService->countAllTopics() + (int) $mediaPanelService->countGalleryImages('forum') == 0) {
         $config->saveConfig('forum', 'uninstall_inprogress', 0);
         BOL_PluginService::getInstance()->uninstall('forum');
         FORUM_BOL_ForumService::getInstance()->setMaintenanceMode(false);
     }
 }
Example #4
0
 public function onDeleteMediaPanelFiles(OW_Event $e)
 {
     $params = $e->getParams();
     $userId = (int) $params['userId'];
     BOL_MediaPanelService::getInstance()->deleteImagesByUserId($userId);
 }
Example #5
0
 private function importMediaPanelFiles()
 {
     $mediaPanelUrl = $this->configs['media_panel_url'];
     $list = array();
     $list = BOL_MediaPanelService::getInstance()->findAll();
     $list = is_array($list) ? $list : array();
     foreach ($list as $dto) {
         $filename = $dto->getId() . '-' . $dto->getData()->name;
         $fileContent = file_get_contents($mediaPanelUrl . '/' . $filename);
         if (!empty($fileContent)) {
             OW::getStorage()->fileSetContent(OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . $filename, $fileContent);
         }
     }
 }
Example #6
0
 public static function process($plugin, $params)
 {
     $language = OW::getLanguage();
     $uploaddir = OW::getPluginManager()->getPlugin('base')->getUserFilesDir();
     $name = $_FILES['file']['name'];
     if (!UTIL_File::validateImage($name)) {
         OW::getFeedback()->error("Invalid file type. Acceptable file types: JPG/PNG/GIF");
         OW::getApplication()->redirect();
     }
     $tmpname = $_FILES['file']['tmp_name'];
     if ((int) $_FILES['file']['size'] > (double) OW::getConfig()->getValue('base', 'tf_max_pic_size') * 1024 * 1024) {
         OW::getFeedback()->error($language->text('base', 'upload_file_max_upload_filesize_error'));
         OW::getApplication()->redirect();
     }
     $image = new UTIL_Image($tmpname);
     $height = $image->getHeight();
     $width = $image->getWidth();
     $id = BOL_MediaPanelService::getInstance()->add($plugin, 'image', OW::getUser()->getId(), array('name' => $name, 'height' => $height, 'width' => $width));
     $uploadFilePath = $uploaddir . $id . '-' . $name;
     $tmpUploadFilePath = $uploaddir . 'tmp_' . $id . '-' . $name;
     $image->saveImage($tmpUploadFilePath);
     $storage = OW::getStorage();
     $storage->copyFile($tmpUploadFilePath, $uploadFilePath);
     @unlink($tmpUploadFilePath);
     $params['pid'] = $id;
     OW::getApplication()->redirect(OW::getRouter()->urlFor('BASE_CTRL_MediaPanel', 'gallery', $params) . '#bottom');
 }
Example #7
0
 /**
  * Add file
  * 
  * @param string $plugin
  * @return integer|string
  */
 public static function addFile($plugin)
 {
     $uploaddir = OW::getPluginManager()->getPlugin('base')->getUserFilesDir();
     $name = $_FILES['file']['name'];
     if (!UTIL_File::validateImage($name)) {
         return OW::getLanguage()->text('base', 'invalid_file_type_acceptable_file_types_jpg_png_gif');
     }
     $tmpname = $_FILES['file']['tmp_name'];
     if ((int) $_FILES['file']['size'] > (double) OW::getConfig()->getValue('base', 'tf_max_pic_size') * 1024 * 1024) {
         return OW::getLanguage()->text('base', 'upload_file_max_upload_filesize_error');
     }
     $image = new UTIL_Image($tmpname);
     $height = $image->getHeight();
     $width = $image->getWidth();
     $id = BOL_MediaPanelService::getInstance()->add($plugin, 'image', OW::getUser()->getId(), array('name' => $name, 'height' => $height, 'width' => $width));
     OW::getStorage()->copyFile($tmpname, $uploaddir . $id . '-' . $name);
     @unlink($tmpname);
     return $id;
 }