Exemplo n.º 1
0
 /**
  * Executes edit action
  *
  * @param sfRequest $request A request object
  */
 public function executeEdit(opWebRequest $request)
 {
     $this->forward404If($this->id && !$this->isEditCommunity);
     $this->community = Doctrine::getTable('Community')->find($this->id);
     if (!$this->community) {
         $this->community = new Community();
     } else {
         if ($request->isMethod('post') && $request->hasParameter('is_delete')) {
             $this->redirect('@community_delete');
         }
     }
     $this->communityForm = new CommunityForm($this->community);
     $this->communityConfigForm = new CommunityConfigForm(array(), array('community' => $this->community));
     $this->communityFileForm = isset($this->enableImage) && $this->enableImage ? new CommunityFileForm(array(), array('community' => $this->community)) : new CommunityFileForm();
     if ($request->isMethod('post')) {
         $params = $request->getParameter('community');
         $params['id'] = $this->id;
         $this->communityForm->bind($params);
         $this->communityConfigForm->bind($request->getParameter('community_config'));
         $this->communityFileForm->bind($request->getParameter('community_file'), $request->getFiles('community_file'));
         if ($this->communityForm->isValid() && $this->communityConfigForm->isValid() && $this->communityFileForm->isValid()) {
             $this->communityForm->save();
             $this->communityConfigForm->save();
             $this->communityFileForm->save();
             $this->redirect('@community_home?id=' . $this->community->getId());
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Executes smtCofigImage action
  *
  * @param opWebRequest $request A request object
  */
 public function executeSmtConfigImage(opWebRequest $request)
 {
     $options = array('member' => $this->getUser()->getMember());
     $this->form = new MemberImageForm(array(), $options);
     if ($request->isMethod(sfWebRequest::POST)) {
         try {
             if (!$this->form->bindAndSave($request->getParameter('member_image'), $request->getFiles('member_image'))) {
                 $errors = $this->form->getErrorSchema()->getErrors();
                 if (isset($errors['file'])) {
                     $error = $errors['file'];
                     $i18n = $this->getContext()->getI18N();
                     $this->getUser()->setFlash('error', $i18n->__($error->getMessageFormat(), $error->getArguments()));
                 }
             }
         } catch (opRuntimeException $e) {
             $this->getUser()->setFlash('error', $e->getMessage());
         }
         $this->redirect('@member_config_image');
     }
     return parent::executeConfigImage($request);
 }