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); }
public function saveEventImage($imagePath, $imageId) { $storage = OW::getStorage(); if ($storage->fileExists($this->generateImagePath($imageId))) { $storage->removeFile($this->generateImagePath($imageId)); $storage->removeFile($this->generateImagePath($imageId, false)); } $pluginfilesDir = Ow::getPluginManager()->getPlugin('eventx')->getPluginFilesDir(); $tmpImgPath = $pluginfilesDir . 'img_' . uniqid() . '.jpg'; $tmpIconPath = $pluginfilesDir . 'icon_' . uniqid() . '.jpg'; $image = new UTIL_Image($imagePath); $image->resizeImage(295, null)->saveImage($tmpImgPath)->resizeImage(100, 100, true)->saveImage($tmpIconPath); unlink($imagePath); $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId)); $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false)); unlink($tmpImgPath); unlink($tmpIconPath); }
private function exportThemes(ZipArchive $za, $archiveDir) { $currentTheme = OW::getThemeManager()->getSelectedTheme()->getDto(); $currentThemeDir = OW::getThemeManager()->getSelectedTheme()->getRootDir(); $currentThemeUserfilesDir = OW_DIR_THEME_USERFILES; $this->configs['currentTheme'] = array('name' => $currentTheme->name, 'customCss' => $currentTheme->customCss, 'customCssFileName' => $currentTheme->customCssFileName, 'description' => $currentTheme->description, 'isActive' => $currentTheme->isActive, 'sidebarPosition' => $currentTheme->sidebarPosition, 'title' => $currentTheme->title); $controlValueList = OW::getDbo()->queryForList(" SELECT * FROM " . BOL_ThemeControlValueDao::getInstance()->getTableName() . " WHERE themeId = :themeId ", array('themeId' => $currentTheme->id)); foreach ($controlValueList as $controlValue) { $this->configs['controlValue'][$controlValue['themeControlKey']] = $controlValue['value']; } $za->addEmptyDir($archiveDir . '/' . $currentTheme->getName()); $this->zipFolder($za, $currentThemeDir, $archiveDir . '/' . $currentTheme->getName() . '/'); $themesDir = Ow::getPluginManager()->getPlugin('dataexporter')->getPluginFilesDir() . 'themes' . DS; UTIL_File::copyDir(OW_DIR_THEME_USERFILES, $themesDir); $fileList = Ow::getStorage()->getFileNameList(OW_DIR_THEME_USERFILES); mkdir($themesDir, 0777); foreach ($fileList as $file) { if (Ow::getStorage()->isFile($file)) { Ow::getStorage()->copyFileToLocalFS($file, $themesDir . mb_substr($file, mb_strlen(OW_DIR_THEME_USERFILES))); } } $za->addEmptyDir($archiveDir . '/themes'); $this->zipFolder($za, $themesDir, $archiveDir . '/themes/'); }
/** * Makes and saves event standard image and icon. * * @param string $imagePath * @param integer $imageId */ public function saveEventImage($tmpPath, $imageId) { $event = new OW_Event(self::EVENT_BEFORE_IMAGE_UPDATE, array("tmpPath" => $tmpPath, "eventId" => $imageId), array("tmpPath" => $tmpPath)); OW::getEventManager()->trigger($event); $data = $event->getData(); $imagePath = $data["tmpPath"]; $storage = OW::getStorage(); if ($storage->fileExists($this->generateImagePath($imageId))) { $storage->removeFile($this->generateImagePath($imageId)); $storage->removeFile($this->generateImagePath($imageId, false)); } $pluginfilesDir = Ow::getPluginManager()->getPlugin('event')->getPluginFilesDir(); $tmpImgPath = $pluginfilesDir . 'img_' . uniqid() . '.jpg'; $tmpIconPath = $pluginfilesDir . 'icon_' . uniqid() . '.jpg'; $image = new UTIL_Image($imagePath); $image->resizeImage(400, null)->saveImage($tmpImgPath)->resizeImage(100, 100, true)->saveImage($tmpIconPath); $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId)); $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false)); OW::getEventManager()->trigger(new OW_Event(self::EVENT_AFTER_IMAGE_UPDATE, array("tmpPath" => $tmpPath, "eventId" => $imageId))); unlink($imagePath); unlink($tmpImgPath); unlink($tmpIconPath); }
public function saveImage($goalId, $imagePath, $imageId) { $storage = OW::getStorage(); $goal = $this->goalDao->findById($goalId); if (!$imageId) { $imageId = uniqid(); $goal->image = $imageId; $this->goalDao->save($goal); } elseif ($storage->fileExists($this->generateImagePath($imageId))) { $storage->removeFile($this->generateImagePath($imageId)); $storage->removeFile($this->generateImagePath($imageId, false)); $imageId = uniqid(); $goal->image = $imageId; $this->goalDao->save($goal); } $pluginfilesDir = Ow::getPluginManager()->getPlugin('ocsfundraising')->getPluginFilesDir(); $tmpImgPath = $pluginfilesDir . 'project_image_' . $imageId . '.jpg'; $tmpIconPath = $pluginfilesDir . 'project_icon_' . $imageId . '.jpg'; $image = new UTIL_Image($imagePath); $image->resizeImage(300, null)->saveImage($tmpImgPath)->resizeImage(170, 130, true)->saveImage($tmpIconPath); unlink($imagePath); $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId)); $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false)); unlink($tmpImgPath); unlink($tmpIconPath); }
public static function getValidDir() { $dir = Ow::getPluginManager()->getPlugin('ynmediaimporter')->getUserFilesDir(); foreach (array(date('Y'), date('m'), date('d')) as $sub) { $dir = $dir . $sub . '/'; if (!realpath($dir)) { if (!mkdir($dir, 0777)) { throw new Exception("{$dir} is not writeable or is not exists!"); } } } return $dir; }
public function onUserRegister(OW_Event $event) { // init $params = $event->getParams(); $signupData = OW::getSession()->get(YNSOCIALCONNECT_CTRL_Sync::SESSION_SIGNUP_DATA); if (NULL != $params && is_array($params) && NULL != $signupData) { // process //// update ow_base_remote_auth $authAdapter = new YNSOCIALCONNECT_CLASS_AuthAdapter($signupData['identity'], $signupData['service']); $authAdapter->register($params['userId']); //// update agent table in social connect $provider = YNSOCIALCONNECT_BOL_ServicesService::getInstance()->getProvider($signupData['service']); $entity = new YNSOCIALCONNECT_BOL_Agents(); $entity->userId = (int) $params['userId']; $entity->identity = $signupData['identity']; $entity->serviceId = $provider->id; $entity->ordering = 0; $entity->status = 'login'; $entity->login = '******'; $entity->data = base64_encode(serialize($signupData['user'])); $entity->tokenData = base64_encode(serialize($signupData['user'])); $entity->token = time(); $entity->createdTime = time(); $entity->loginTime = time(); $entity->logoutTime = time(); YNSOCIALCONNECT_BOL_AgentsService::getInstance()->save($entity); ////add token in social bridge $oBridge = YNSOCIALCONNECT_CLASS_SocialBridge::getInstance(); if ($oBridge->hasProvider(strtolower($signupData['service']))) { $core = new YNSOCIALBRIDGE_CLASS_Core(); $obj = $core->getInstance($signupData['service']); $obj->saveToken(); } ////update signup statistic YNSOCIALCONNECT_BOL_ServicesService::getInstance()->updateStatistics($signupData['service'], 'signup'); ////add user linking $entityUserlinking = new YNSOCIALCONNECT_BOL_Userlinking(); $entityUserlinking->userId = (int) $params['userId']; $entityUserlinking->identity = $signupData['identity']; $entityUserlinking->serviceId = $provider->id; YNSOCIALCONNECT_BOL_UserlinkingService::getInstance()->save($entityUserlinking); // end if (isset($_SESSION['socialbridge_session'][$signupData['service']])) { unset($_SESSION['socialbridge_session'][$signupData['service']]); } //// clear session OW::getSession()->delete(YNSOCIALCONNECT_CTRL_Sync::SESSION_SIGNUP_DATA); // update avatar //// if avatar doesn't exist, update with profile image if (in_array($signupData['service'], array('facebook', 'linkedin', 'twitter'))) { $useProfilePhoto = OW::getSession()->get(YNSOCIALCONNECT_CMP_ViewInJoinPage::SESSION_USE_PROFILE_PHOTO); if ($useProfilePhoto == null || $useProfilePhoto != 'not_use') { $avatar = BOL_AvatarService::getInstance()->findByUserId($params['userId']); if (!$avatar) { $profilePicture = YNSOCIALCONNECT_CLASS_SocialConnect::getInstance()->getPhotoUrlFromTokenData($signupData['user'], $signupData['service']); // with facebook, linkedin, twitter if ($profilePicture != null) { $pluginfilesDir = Ow::getPluginManager()->getPlugin('ynsocialconnect')->getPluginFilesDir(); $tmpImgPath = $pluginfilesDir . 'img_' . uniqid() . '.jpg'; YNSOCIALCONNECT_CLASS_SocialConnect::getInstance()->fetchImage($profilePicture, $tmpImgPath); BOL_AvatarService::getInstance()->setUserAvatar($params['userId'], $tmpImgPath); @unlink($tmpImgPath); } } } } if (isset($params['quick_signup']) && $params['quick_signup']) { $userId = (int) $params['userId']; $event = new OW_Event('feed.action', array('pluginKey' => 'base', 'entityType' => 'user_join', 'entityId' => $userId, 'userId' => $userId, 'replace' => true), array('string' => OW::getLanguage()->text('base', 'feed_user_join'), 'view' => array('iconClass' => 'ow_ic_user'))); OW::getEventManager()->trigger($event); } } }