/** */ public function setImage() { // Form Submitted... if ($this->request->isPost() && $this->form->isValid($_POST)) { // file uploaded? if ($this->form->{$this->file_element}->isUploaded()) { $this->form->{$this->file_element}->receive(); // must have $receive_path = $this->form->{$this->file_element}->getFileName(); $filename = $this->form->{$this->file_element}->getValue(); $extension = strtolower(pathinfo($receive_path, PATHINFO_EXTENSION)); if ($this->profile_name) { // delete old tmp image files $Storage = new Application_Model_Storage(); $StorageAdapter = $Storage->getAdapter(); $StorageAdapter->deleteOldTmpFiles(0, 'profileimage_' . $this->profile_name); $tmp_filename = 'profileimage_' . $this->profile_name . '.' . $extension; // move new file to tmp folder rename($receive_path, TMP_PATH . '/' . $tmp_filename); // check if valid image if (!Application_Plugin_ImageLib::isValidImage(TMP_PATH . '/' . $tmp_filename)) { unlink(TMP_PATH . '/' . $tmp_filename); Application_Plugin_Alerts::error($this->translator->translate('Server-side error'), 'off'); $this->redirector->gotoUrl(); return; } Application_Plugin_Alerts::success($this->translator->translate('You can adjust the picture here'), 'off'); // go back to current page after editing $base_url = Application_Plugin_Common::getFullBaseUrl(false); $callback_url = $base_url . $this->request->getRequestUri() . '/edit_done/1'; // save params to session and redirect to edit page $session = new Zend_Session_Namespace('Default'); $pass_params = array('tmp_image' => $tmp_filename, 'image_type' => $this->image_type, 'callback' => $callback_url, 'profile_name' => $this->profile_name); $session->pass_params = $pass_params; $this->redirector->gotoUrl('images/edit'); } else { // here we store site settings images // i.e. network background image $this->form->{$this->file_element}->receive(); // must have $receive_path = $this->form->{$this->file_element}->getFileName(); $filename = $this->form->{$this->file_element}->getValue(); $extension = strtolower(pathinfo($receive_path, PATHINFO_EXTENSION)); $file_name = $this->image_type . '.' . $extension; // move new file to public image folder rename($receive_path, PUBLIC_PATH . '/images/' . $file_name); // store to app settings & refresh $app_option_key = $this->image_type; $AppOptions = new Application_Model_AppOptions(); $AppOptions->updateOption($app_option_key, $file_name); $current_config = Zend_Registry::get('config'); $current_config->{$app_option_key} = $file_name; Zend_Registry::set('config', $current_config); Application_Plugin_Alerts::success($this->translator->translate('Image uploaded'), 'off'); $base_url = Application_Plugin_Common::getFullBaseUrl(false); $callback_url = $base_url . $this->request->getRequestUri(); // flush url $this->redirector->gotoUrl($callback_url); } } else { if ($this->is_requiered) { // nothing to upload Application_Plugin_Alerts::error($this->translator->translate('Please choose a picture'), 'off'); } } } // somethig went wrong, image too big? if ($this->request->isPost() && !$this->form->isValid($_POST)) { Application_Plugin_Alerts::error($this->translator->translate('File not allowed or too big'), 'off'); } }
/** * Theme & style */ public function stylesAction() { $this->buildSettingsMenu(); $request = $this->getRequest(); $form = new Application_Form_SettingsStyle(); $this->view->form = $form; if ($request->isPost() && $form->isValid($_POST)) { $AppOptions = new Application_Model_AppOptions(); $AppOptions->updateOption('css_theme', $form->getValue('css_theme')); $AppOptions->updateOption('css_custom', $form->getValue('css_custom')); $AppOptions->updateOption('cover_ysize', $form->getValue('cover_ysize')); $AppOptions->updateOption('user_background', $form->getValue('user_background')); $AppOptions->updateOption('subscriber_background', $form->getValue('subscriber_background')); $AppOptions->updateOption('wide_layout', $form->getValue('wide_layout')); Application_Plugin_Alerts::success($this->view->translate('Settings updated, please clear your browser cache'), 'off'); // flush url $this->redirect('admin/styles/section/styles/'); } }