/** * 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 profile */ public function editAction() { $Profiles = new Application_Model_Profiles(); $this->buildMenu(); $profile_form = new Application_Form_Profile(); $this->view->profile_form = $profile_form; $request = $this->getRequest(); if ($request->isPost() && $profile_form->isValid($_POST)) { Application_Plugin_Common::redirectOnDemoAccount(); $profile = $Profiles->getProfileRow(); // do not foreach this! $profile->screen_name = $profile_form->getValue('screen_name'); $profile->profile_privacy = $profile_form->getValue('profile_privacy'); $profile->save(); $ProfilesMeta = new Application_Model_ProfilesMeta(); $elements = $profile_form->getElements(); $system_elements = array('identifier', 'formsubmit', 'profile_privacy', 'screen_name', 'csrf', 'name', 'email', 'id'); // foreach meta elements foreach ($elements as $element) { $element_id = $element->getId(); $element_value = $element->getValue(); // skip system & readonly fields if (in_array($element_id, $system_elements)) { continue; } // custom date element? if ($element->helper == 'formDate') { if ($element_value) { $dateval = date("Y-m-d H:i:s", strtotime($element_value['day'] . '-' . $element_value['month'] . '-' . $element_value['year'])); $ProfilesMeta->metaUpdate($element_id, $dateval, $profile->id); } else { $ProfilesMeta->deleteProfilesMetaKey($profile->id, $element_id); } continue; } $ProfilesMeta->metaUpdate($element_id, $element_value, $profile->id); } Application_Plugin_Alerts::success($this->view->translate('Profile updated')); // refresh user session Zend_Auth::getInstance()->getStorage()->write($Profiles->getProfileRowObject()); // flush url $this->redirect('editprofile/edit'); } }