/**
  * 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');
     }
 }