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'); } }
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); } }
public function onDeleteMediaPanelFiles(OW_Event $e) { $params = $e->getParams(); $userId = (int) $params['userId']; BOL_MediaPanelService::getInstance()->deleteImagesByUserId($userId); }
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); } } }
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'); }
/** * 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; }