Ejemplo n.º 1
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'Категория создана успешно.' : 'Категория изменена успешно.';
         $Category = $form->save();
         foreach ((array) $request->getParameter('category_preference') as $key => $value) {
             if (isset($value['id']) and $value['id'] != 0) {
                 $category_preference = CategoryPreferencePeer::retrieveByPk(intval($value['id']));
             } else {
                 $category_preference = new CategoryPreference();
                 $category_preference->setCategoryId($form->getObject()->getId());
             }
             if (isset($value['delete'])) {
                 $category_preference->delete();
             } elseif ($value['name'] != '') {
                 $category_preference->setKey($value['name']);
                 $category_preference->setPreferenceType($value['preference_type']);
                 $category_preference->setPreferenceUnit($value['preference_unit']);
                 $category_preference->setFilterStatus(isset($value['filter_status']) ? $value['filter_status'] : 0);
                 $category_preference->save();
             }
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Category)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' Вы можете создать еще одну.');
             $this->redirect('@category_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'category_edit', 'sf_subject' => $Category));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $new = !$form->getObject()->exists();
         $site = $form->save();
         if ($new) {
             $dispatcher = $this->getContext()->getEventDispatcher();
             $formatter = new sfFormatter();
             chdir(sfConfig::get('sf_root_dir'));
             $task = new sfGenerateAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalEnableForAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalCreateSiteTask($dispatcher, $formatter);
             $task->run(array($site->slug), array('no-confirmation'));
             $site = Doctrine_Core::getTable('sfSympalSite')->findOneByTitle($site->title);
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $site)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') . ' You can add another one below.');
             $this->redirect('@sympal_sites_new');
         } else {
             $this->redirect('@sympal_sites_edit?id=' . $site->getId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             $stock = $form->save();
             $stock->calc($stock->getDate());
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $stock)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@stock_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect("stock/view?id=" . $stock->getId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
Ejemplo n.º 4
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $i18n = sfContext::getInstance()->getI18N();
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     $s = Doctrine::getTable('Service')->find($form->getValue('service_id'));
     $form->setValidator['uri'] = new sfValidatorRegex(array('pattern' => '/^' . $s->getEntitlementPrefix() . ':.*$/'));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? $i18n->__('The entitlement has been created.') : $i18n->__('The entitlement has been updated');
         try {
             $entitlement = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $entitlement)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@entitlement_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect("show/index?id=" . $form->getObject()->getServiceId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
Ejemplo n.º 5
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $params = $request->getParameter($form->getName());
     $this->forward404Unless($this->location = Doctrine::getTable('Location')->find(array($params['location_id'])), sprintf('Location does not exist (%s).', $params['location_id']));
     $form->bind($params);
     if ($form->isValid()) {
         $detailsData = (array) json_decode($form->getValue('details'));
         $photosData = (array) json_decode($form->getValue('photos'));
         print_r($photosData);
         die;
         $form->save()->updateDetails($detailsData)->updatePhotos($photosData);
         BotNet::create()->spammed($form->getObject(), 'description', $form->getObject()->getLocation()->getDateTimeObject('created_at')->format('U'));
         if ($cache = $this->getContext()->getViewCacheManager()) {
             $cache->remove('@sf_cache_partial?module=profit&action=_last&sf_cache_key=profit', '', 'all');
         }
         $this->redirect('profit/show?id=' . $form->getObject()->getId());
     } else {
         //            foreach ($form->getFormFieldSchema() as $name => $formField) {
         //                if ($formField->getError() != "") {
         //                    echo "ActionClassName::methodName( ): Field Error for :" . $name . " : " . $formField->getError();
         //                }
         //            }
     }
     return null;
 }
Ejemplo n.º 6
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $arrayFromRequest = $request->getParameter($form->getName());
     $typologies = Doctrine_Core::getTable('Typologie')->findAll();
     $arrayResultScore = array();
     foreach ($typologies as $typologie) {
         $id = 'score_' . $typologie->getGuid();
         $arrayResultScore[$typologie->getGuid()] = $arrayFromRequest[$id];
         unset($arrayFromRequest[$id]);
     }
     $arrayFromRequest["score"] = json_encode($arrayResultScore);
     $form->bind($arrayFromRequest, $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             $validatedFile = $form->getValue('file');
             unset($form['file']);
             if ($validatedFile) {
                 $validatedFile->save($form->getObject()->getInteractifDataPath() . "/source.zip");
             }
             $interactif = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         } catch (Doctrine_Connection_Mysql_Exception $e) {
             $message = "An object with this label already exist";
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $interactif)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@interactif_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $route = 'interactif';
             $action = $form->getObject()->isNew() ? 'new' : 'edit';
             $redirection = strtolower($this->configuration->getValue($action . '.redirection'));
             if (isset($redirection) && 'list' !== $redirection) {
                 $route .= '_' . $redirection;
             }
             $url = array('sf_route' => $route);
             if (isset($redirection) && 'list' !== $redirection) {
                 $url['sf_subject'] = $interactif;
             }
             $this->redirect($url);
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
function url_for_form_confirm(sfForm $form, $routePrefix)
{
    $format = '%s/%s';
    if ('@' == $routePrefix[0]) {
        $format = '%s_%s';
        $routePrefix = substr($routePrefix, 1);
    }
    $uri = sprintf($format, $routePrefix, $form->getObject()->isNew() ? 'cfnew' : 'cfedit');
    return url_for($uri, $form->getObject());
}
 /**
  * Returns a routed URL (for forms), based on route collection name
  * 
  * @param   sfForm  $form
  * @param   string  $routePrefix    Base route name in route collection or module name
  * @return  string  Generated url
  */
 public static function urlf(sfForm $form, $routePrefix)
 {
     $format = '%s/%s';
     if ('@' == $routePrefix[0]) {
         $format = '%s_%s';
         $routePrefix = substr($routePrefix, 1);
     }
     $uri = sprintf($format, $routePrefix, $form->getObject()->isNew() ? 'create' : 'update');
     return self::urlr($uri, $form->getObject());
 }
Ejemplo n.º 9
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             if ($form->isNew() && $form->getValue("password") == "" || is_null($form->getValue("password"))) {
                 throw new Exception("invalid password");
             }
             $sf_guard_user = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         } catch (Doctrine_Connection_Mysql_Exception $e) {
             $message = "An object with this label already exist";
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         } catch (Exception $e) {
             $message = "The password is mandatory";
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_guard_user)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@sf_guard_user_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $route = 'sf_guard_user';
             $action = $form->getObject()->isNew() ? 'new' : 'edit';
             $redirection = strtolower($this->configuration->getValue($action . '.redirection'));
             if (isset($redirection) && 'list' !== $redirection) {
                 $route .= '_' . $redirection;
             }
             $url = array('sf_route' => $route);
             if (isset($redirection) && 'list' !== $redirection) {
                 $url['sf_subject'] = $sf_guard_user;
             }
             $this->redirect($url);
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
Ejemplo n.º 10
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             $event = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $event)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@event_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $params = $request->getParameter('event');
             if (isset($params['main_slideshow'])) {
                 $objEvCat = EventCategoryTable::ExistByEventAndCat($event->get('id'), 2);
                 if (is_null($objEvCat)) {
                     $obj = new EventCategory();
                     $obj->setCategoryId(2);
                     $obj->setEventId($event->get('id'));
                     $obj->save();
                 }
             } else {
                 $objEvCat = EventCategoryTable::ExistByEventAndCat($event->get('id'), 2);
                 if (!is_null($objEvCat)) {
                     $objEvCat->delete();
                 }
             }
             if ($params['event_cat'] != '') {
                 $obj = new EventCategory();
                 $obj->setCategoryId($params['event_cat']);
                 $obj->setEventId($event->get('id'));
                 $obj->save();
             }
             $this->redirect('events/index');
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $requestparam = $request->getParameter('accountentry');
     $account = AccountTable::fetchById($requestparam['account_id']);
     $qty = $requestparam['qty'];
     $date = $requestparam['date']['year'] . "-" . $requestparam['date']['month'] . "-" . $requestparam['date']['day'];
     //$ref_class=$requestparam['ref_class'];
     //$ref_id=$requestparam['ref_id'];
     $type = $requestparam['type'] != "" ? $requestparam['type'] : 'Adjustment';
     //$priority=0;
     $description = $requestparam['description'];
     if ($qty == 0) {
         $this->redirect('home/error?msg="Invalid Qty"');
     }
     $accountentry = $account->addEntry($date, $qty, null, null, $type, $description);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $accountentry)));
         $this->getUser()->setFlash('notice', $notice);
         $this->redirect('account/view?id=' . $accountentry->getaccountId());
     } else {
         if ($form['qty']->getError()) {
             $this->redirect('home/error?msg="Invalid Qty: ' . $qty . '"');
         }
         if ($form['date']->getError()) {
             $this->redirect('home/error?msg="Invalid Date: ' . $date . '"');
         }
         //$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         // kommt vom multiupload-gedingse
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         $sf_filebase_file = $form->save();
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_filebase_file)));
         if (!$request->hasParameter('swfupload_filesource')) {
             if ($request->hasParameter('_save_and_add')) {
                 $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
                 $this->redirect('@sf_filebase_file_new');
             } else {
                 $this->getUser()->setFlash('notice', $notice);
                 $this->redirect(array('sf_route' => 'sf_filebase_file_edit', 'sf_subject' => $sf_filebase_file));
             }
         }
         return true;
     } else {
         if (!$request->hasParameter('swfupload_filesource')) {
             $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
         }
         return false;
     }
 }
  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $isNew = $form->getObject()->isNew();
      $notice = $isNew ? 'Your reply was saved successfully.' : 'The item was updated successfully.';

      $sf_nested_comment = $form->save();

      $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_nested_comment)));
      
      $email_pref = sfNestedCommentConfig::isMailEnabled();
      $enable_mail_alert = $email_pref === true || $email_pref == 'moderated';

      if ($isNew && $enable_mail_alert && $sf_nested_comment->isReply())
      {
        $userComment = $sf_nested_comment->getsfNestedCommentRelatedBySfCommentId();
        $params = $this->prepareMailParameter($sf_nested_comment, $userComment);
        sfNestedCommentTools::sendEmail($this->getMailer(), $params);
      }
      
      $this->getUser()->setFlash('notice', $notice);
      $this->redirect('@sf_nested_comment');
    }
    else
    {
      $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
    }
  }
Ejemplo n.º 14
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $file = '';
         $year = $form->getValue('years');
         $semester = $form->getValue('semester');
         $year = substr($year, 0, 4);
         $form->getObject()->setYear($year . $semester);
         if ($form->getValue('file_path') !== null || $form->getValue('file_path') != '') {
             $myfile = $this->form->getObject()->getFilePath();
             if ($myfile !== null || $myfile != '') {
                 //previously there was something there
                 $this->delExam($myfile);
             }
             $file = $form->getValue('file_path');
             $dateTime = new DateTime('now');
             $filename = '' . $dateTime->format(skuleadminConst::EXAM_FILE_DATEFORMAT) . '';
             $extension = $file->getOriginalExtension();
             $path = sfConfig::get('sf_web_dir') . skuleadminConst::INDIVIDUALEXAMFOLDER . $year . '/';
             if ($file->save($path . $filename . $extension)) {
                 $exam = $form->save();
                 $this->redirect('adminexam/edit?id=' . $exam->getId());
             } else {
                 $this->redirect('adminexam/failederr?msg=save');
             }
         } else {
             $exam = $form->save();
             $this->redirect('adminexam/edit?id=' . $exam->getId());
         }
     }
 }
Ejemplo n.º 15
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     $form->getObject()->setPersonId($request->getParameter("person_id"));
     if ($form->isValid()) {
         $wing_leader = $form->save();
     }
 }
Ejemplo n.º 16
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $compte_banquaire = $form->save();
         $this->redirect('compte', $form->getObject()->getAsso());
     }
 }
Ejemplo n.º 17
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             $values = $form->getValues();
             if ($form->getObject()->hasAlreadyMedailleWithParameters($values['visiteur_id'], $values['medaille_id'])) {
                 $message = sprintf("The medal %s is unique for this visitor %s", $values['medaille_id'], $values['visiteur_id']);
                 $this->getUser()->setFlash('error', $message);
                 return sfView::SUCCESS;
             }
             $visiteur_medaille = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $visiteur_medaille)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@visiteur_medaille_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $route = 'visiteur_medaille';
             $action = $form->getObject()->isNew() ? 'new' : 'edit';
             $redirection = strtolower($this->configuration->getValue($action . '.redirection'));
             if (isset($redirection) && 'list' !== $redirection) {
                 $route .= '_' . $redirection;
             }
             $url = array('sf_route' => $route);
             if (isset($redirection) && 'list' !== $redirection) {
                 $url['sf_subject'] = $visiteur_medaille;
             }
             $this->redirect($url);
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
Ejemplo n.º 18
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     $form->getObject()->setParentId(skuleadminConst::DISCIPLINE_PARENT_ID);
     if ($form->isValid()) {
         $enum_item = $form->save();
         $this->redirect('admindiscipline/edit?id=' . $enum_item->getId());
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->getObject()->User = $this->getUser()->getGuardUser();
         $form->save();
         $this->redirect('showcase/wall');
     }
 }
Ejemplo n.º 20
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         // NEW: deal with tags
         if ($form->getValue('remove_tags')) {
             foreach (preg_split('/\\s*,\\s*/', $form->getValue('remove_tags')) as $tag) {
                 $form->getObject()->removeTag($tag);
             }
         }
         if ($form->getValue('new_tags')) {
             foreach (preg_split('/\\s*,\\s*/', $form->getValue('new_tags')) as $tag) {
                 // sorry, it would be better to not hard-code this string
                 if ($tag == 'Add tags with commas') {
                     continue;
                 }
                 $form->getObject()->addTag($tag);
             }
         }
         try {
             $peanut_posts = $form->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $peanut_posts)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@peanut_posts_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'peanut_posts_edit', 'sf_subject' => $peanut_posts));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
Ejemplo n.º 21
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     $params = $request->getParameter($this->form->getName());
     if ($form->isValid()) {
         // $notice = $form->getObject()->isNew() ? 'Booking was created successfully.' : 'Booking was updated successfully.';
         try {
             /* Start booking */
             $apartment = Doctrine_Core::getTable('Apartment')->find($params['apartment_id']);
             $booking = $form->getObject();
             $from = $params['date_from']['year'] . '-' . $params['date_from']['month'] . '-' . $params['date_from']['day'];
             $to = $params['date_to']['year'] . '-' . $params['date_to']['month'] . '-' . $params['date_to']['day'];
             $booking->date_from = $from;
             $booking->date_to = $to;
             if ($booking->StartBooking($apartment, $params['pax'])) {
                 $booking->Apartment = $apartment;
                 $booking->client_id = $params['client_id'];
                 $booking->pax = $params['pax'];
                 $booking->valid = $params['valid'];
                 $booking->canceled = $params['canceled'];
                 $booking->price = Booking::CalculatePrice($apartment, $from, $to);
                 $booking->save();
                 //   return sfView::SUCCESS;
                 $this->redirect(array('sf_route' => 'booking_edit', 'sf_subject' => $booking));
                 $this->getUser()->setFlash('error', ' Booking successfully created. ', false);
             } else {
                 $this->getUser()->setFlash('error', 'Apartment is unavalible for this dates !', false);
                 return sfView::SUCCESS;
             }
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $booking)));
     } else {
         $this->getUser()->setFlash('error', 'There are some errors ...', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $requestparamspurchase = $request->getParameter("purchase");
     $requestparams = $request->getParameter($form->getName());
     $barcoderoot = $requestparams["product_id"] . str_pad($requestparamspurchase["pono"], 5, "0", STR_PAD_LEFT);
     $requestparams["barcode"] = MyBarcode::standardize($barcoderoot);
     $form->bind($requestparams);
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             $purchasedetail = $form->save();
             $purchasedetail->updateStockentry();
             $purchasedetail->updateProduct();
             //custom calculation
             if ($purchasedetail->getDescription() == "") {
                 $purchasedetail->setDescription($purchasedetail->getProduct()->getDescription());
             }
             $purchasedetail->calc();
             $purchasedetail->save();
             $purchase = $purchasedetail->getPurchase();
             $purchase->calc();
             $purchase->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $purchasedetail)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@purchasedetail_new?purchase_id=' . $purchase->getId());
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect('purchase/view?id=' . $purchasedetail->getPurchaseId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $form->getObject()->setSite($this->getSympalContext()->getSite());
         $tree = $form->save();
         $this->clearMenuCache();
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $tree)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') . ' You can add another one below.');
             $this->redirect('@sympal_menu_items_new');
         } else {
             $this->redirect('@sympal_menu_items_edit?id=' . $tree['id']);
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.');
     }
 }
Ejemplo n.º 24
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter('person'));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $person = $form->save();
         $this->redirect('@contacts_show?id=' . $person['id']);
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.');
     }
 }
Ejemplo n.º 25
0
 protected function processCriteriaForm(sfWebRequest $request, sfForm $form, $template_id = 0)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($template_id) {
         $form->getObject()->setTemplateId($template_id);
     }
     if ($form->isValid()) {
         $criteria_template = $form->save();
         $this->redirect('type_template/criteriaEdit?id=' . $criteria_template->getId());
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         if ($this->getUser()->hasCredential('expertbank_admin')) {
             $form->getObject()->active = true;
         }
         $form->save();
         $this->redirect('expertbank', 'index');
     }
 }
Ejemplo n.º 27
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     $isnew = $form->getObject()->isNew();
     if ($form->isValid()) {
         $sf_oauth_server_consumer = $form->save();
         if ($isnew) {
             $sf_oauth_server_consumer->addDeveloper($this->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser'));
         }
         $this->redirect('sfOauthDeveloper/edit?id=' . $sf_oauth_server_consumer->getId());
     }
 }
Ejemplo n.º 28
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $file = $this->form->getValue('image');
         $image = $this->form->getObject();
         $notice = $image->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             // Image
             $filename = 'app_' . sha1($file->getOriginalName() . rand(1, 100));
             $extension = str_replace('.', '', $file->getOriginalExtension());
             $path = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $filename . '.' . $extension;
             $file->save($path);
             // Thumb
             $img = new sfImage($path, 'image/jpg');
             $img->thumbnail(150, 150);
             $img->saveAs(sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . $filename . '_thumb' . '.' . $extension);
             // Save
             $image->path = $filename . '.' . $extension;
             $image->type = $extension;
             $image->name = $request->getPostParameter('picture[name]');
             $image->description = $request->getPostParameter('picture[description]');
             $image->apartment_id = $request->getPostParameter('picture[apartment_id]');
             $image->save();
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         // $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $picture)));
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 protected function processForm(sfForm $form, $data = array())
 {
     $form->bind($data);
     if ($form->isValid()) {
         try {
             $report = $form->save();
             return $report;
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             throw new sfException($message);
         }
     } else {
         if ($es = $form->getErrorSchema()) {
             throw new sfException($es->getMessage());
         }
         throw new sfException('The item has not been saved due to some errors.');
     }
 }
Ejemplo n.º 30
0
 protected function processForm(sfWebRequest $request, sfForm $form, $type = null)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->getObject()->setPersonId($request->getParameter('person_id'));
         $wing_job = $form->save();
         if (!$type) {
             $this->getUser()->setFlash("success", "Wing Role Saved Successfully");
         } else {
             $this->getUser()->setFlash("success", "Wing Role Modified Successfully");
         }
         $this->redirect("person/view?id=" . $request->getParameter("person_id"));
     }
 }