/** * Edit image */ public function editAction() { $request = $this->getRequest(); $do_rotate = $request->getParam('rotate'); $do_skip = $request->getParam('skip'); $Profiles = new Application_Model_Profiles(); $profile = $Profiles->getProfileRow($this->profile_name, true, true); if (!$profile) { $this->redirect(''); } $extension = strtolower(pathinfo(TMP_PATH . '/' . $this->image_name, PATHINFO_EXTENSION)); if ($request->isPost() || $do_skip) { if ($do_skip) { // skip editing and use the full image Application_Plugin_ImageLib::resample(TMP_PATH . '/' . $this->image_name, TMP_PATH . '/' . $this->image_name, $this->target_x, $this->target_y, false); } else { $x = intval($_POST['x']); $y = intval($_POST['y']); $w = intval($_POST['w']); $h = intval($_POST['h']); if ($x + $y + $w + $h == 0) { $this->redirect(''); } Application_Plugin_ImageLib::crop(TMP_PATH . '/' . $this->image_name, $x, $y, $w, $h, $this->target_x, $this->target_y); } $Storage = new Application_Model_Storage(); $StorageAdapter = $Storage->getAdapter(); // delete old file if (strstr($profile->{$this->db_field}, 'default') === false) { $StorageAdapter->deleteFileFromStorage($profile->{$this->db_field}, $this->image_type); } $new_filename = $StorageAdapter->moveFileToStorage($this->view->image, $this->image_type); $profile->{$this->db_field} = $new_filename; $profile->save(); Application_Plugin_Alerts::success($this->view->translate('Image saved')); // kill tmp session $session = new Zend_Session_Namespace('Default'); $session->pass_params = false; // refresh user session in case profile picture is updated Zend_Auth::getInstance()->getStorage()->write($Profiles->getProfileRowObject()); // go back $this->redirect($this->callback); } elseif ($do_rotate) { Application_Plugin_ImageLib::rotate(TMP_PATH . '/' . $this->image_name); } }
/** * Edit page */ public function editpageAction() { $this->buildMenu(true); $request = $this->getRequest(); $Profiles = new Application_Model_Profiles(); $profile_form = new Application_Form_EditPage(); $this->view->profile_form = $profile_form; if ($request->isPost() && $profile_form->isValid($_POST)) { $profile_name = $profile_form->getValue('name'); $profile = $Profiles->getProfileRow($profile_name, false, true); $profile->screen_name = $profile_form->getValue('screen_name'); $profile->is_hidden = $profile_form->getValue('is_hidden'); $ret = $profile->save(); $ProfilesMeta = new Application_Model_ProfilesMeta(); $ProfilesMeta->metaUpdate('description', $profile_form->getValue('description'), $profile->id); Application_Plugin_Alerts::success($this->view->translate('Page updated')); $this->redirect('editprofile/listpages'); } }