public function executeFor(sfWebRequest $request) { $this->forward404Unless($request->isMethod(sfRequest::POST)); //@todo: check component name input $componentName = $request->getParameter('component'); $commentName = 'Comment' . $componentName; $formName = $commentName . 'Form'; $form = new $formName(); $toward = $form->getToward(); $data = $request->getParameter($form->getName()); $tree = Doctrine::getTable($commentName)->getTree(); $tree->setBaseQuery(Doctrine_Query::create()->from($commentName . ' c')->where('c.' . $toward . '_id = ?', $data[$toward . '_id'])); $form->bind($data, $request->getFiles($form->getName())); if ($form->isValid()) { $root = $tree->fetchRoots()->getFirst(); if (!$root) { $root = new $commentName(); $root->message = 'root'; $root[$toward . '_id'] = $data[$toward . '_id']; $root->parent = null; $root->save(); $tree->createRoot($root); $getterCommented = "get{$componentName}"; BotNet::create()->attachTo($root, BotNet::create()->getRandomBot(), $root->{$getterCommented}()->getDateTimeObject('created_at')->format('U')); } $parent = $root; if ($data['parent']) { $parent = Doctrine_Core::getTable('Comment')->find($data['parent']); } $data['parent'] = $parent->getId(); $form->bind($data, $request->getFiles($form->getName())); $this->comment = $form->save(); $this->comment->getNode()->insertAsLastChildOf($parent); $prevCom = $parent; if ($parent->message == 'root') { $sibling = $this->comment->getNode()->getPrevSibling(); if ($sibling) { $prevCom = $sibling; } } BotNet::create()->spammed($this->comment, 'message', $prevCom->getDateTimeObject('created_at')->format('U')); $this->noVote = $form->getValue('noVote', false); if ($cache = $this->getContext()->getViewCacheManager()) { $cache->remove('@sf_cache_partial?module=comment&action=_last&sf_cache_key=comment', '', 'all'); } $this->setTemplate('created'); } else { foreach ($form->getFormFieldSchema() as $name => $formField) { if ($formField->getError() != "") { echo "ActionClassName::methodName( ): Field Error for :" . $name . " : " . $formField->getError(); } } } }
protected function submitForm(sfWebRequest $request, sfForm $form, sfForm $form2) { //processform logic $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); $form2->bind($request->getParameter($form2->getName()), $request->getFiles($form2->getName())); if ($form2->isValid()) { if ($form->isValid()) { $instructresult = $form->save(); $form2->getObject()->setInstructorId($instructresult->getId()); $instructdetailresult = $form2->save(); $this->redirect('admininstructor/edit?id=' . $instructresult->getId()); //$this->redirect('course/index'); } } }
public function executeAttachmentSave(sfWebRequest $request) { $files = $request->getFiles('attachment'); $this->setTemplate('iframe'); if ($this->isUpload($files)) { if (!$this->isEmptyFile($files)) { $this->bindAttachment($request->getParameter('attachment'), $files); if ($this->form->isValid()) { $this->form->save(); } else { $errors = $this->form->getErrorList(); $this->alert = implode("\n", $errors); } } else { $this->alert = 'Please select a file to upload'; } } else { $this->bindExternalUrl($request); if ($this->form->isValid()) { $this->form->save(); } else { $errors = $this->form->getErrorList(); $this->alert = 'Errors on: ' . implode(", ", array_keys($errors)) . ': ' . implode("\n", $errors); } } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $contact_req = new ContactRequest(); $contact_req->setRequestDate(date('Y-m-d')); $contact_req->setTitle($request->getParameter('contact_request[title]')); $contact_req->setFirstName($request->getParameter('contact_request[first_name]')); $contact_req->setLastName($request->getParameter('contact_request[last_name]')); $contact_req->setAddress1($request->getParameter('contact_request[address1]')); $contact_req->setAddress2($request->getParameter('contact_request[address2]')); $contact_req->setCity($request->getParameter('contact_request[city]')); $contact_req->setState($request->getParameter('contact_request[state]')); $contact_req->setZipcode($request->getParameter('contact_request[zipcode]')); $contact_req->setCountry($request->getParameter('contact_request[country]')); $contact_req->setDayPhone($request->getParameter('contact_request[day_phone]')); $contact_req->setEvePhone($request->getParameter('contact_request[eve_phone]')); $contact_req->setFaxPhone($request->getParameter('contact_request[fax_phone]')); $contact_req->setMobilePhone($request->getParameter('contact_request[mobile_phone]')); $contact_req->setEmail($request->getParameter('contact_request[email]')); $contact_req->setRefSourceId($request->getParameter('contact_request[ref_source_id]')); $contact_req->setSendAppFormat($request->getParameter('contact_request[send_app_format]')); $contact_req->setComment($request->getParameter('contact_request[comment]')); //Set Session Id $sessionId = session_id(); $contact_req->setSessionId($sessionId); //end set session id $contact_req->setIpAddress($request->getRemoteAddress()); $contact_req->save(); $this->redirect('contact_request/thankyou'); } }
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()); } } }
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()) { $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); } }
public function executeAdvancedRender(sfWebRequest $request) { $this->form = new AdvancedSearchForm(); if (!$request->isMethod("POST")) { $this->forward("Not Supported!"); } $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $page = $request->getParameter($this->form->getName() . "[page]"); $arr = array(); $arr["jobStatus"] = $request->getParameter($this->form->getName() . "[status_id]"); $arr["dueDateStart"] = $this->getFormattedDate($request->getParameter($this->form->getName() . "[due_date_start]")); $arr["dueDateEnd"] = $this->getFormattedDate($request->getParameter($this->form->getName() . "[due_date_end]")); $arr["shootDateStart"] = $this->getFormattedDate($request->getParameter($this->form->getName() . "[shoot_date_start]")); $arr["shootDateEnd"] = $this->getFormattedDate($request->getParameter($this->form->getName() . "[shoot_date_end]")); $arr["clientId"] = $request->getParameter($this->form->getName() . "[client_id]"); $arr["photographerId"] = $request->getParameter($this->form->getName() . "[photo_id]"); $arr["sortOn"] = $request->getParameter($this->form->getName() . "[sort]"); $arr["sortDirection"] = $request->getParameter($this->form->getName() . "[sort_direction]"); $c = $this->createAdvancedSearchCriteria($arr); $this->pager = new sfPropelPager("Job", sfConfig::get("app_items_per_page")); $this->pager->setCriteria($c); $this->pager->setPage($page); $this->pager->setPeerMethod("doSelectJoinAll"); $this->pager->init(); $this->results = $this->pager->getResults(); sfPropelActAsTaggableBehavior::preloadTags($this->results); }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); $comprobanteFlash = $this->getUser()->getFlash('comprobante'); if ($form->isValid()) { $comprobante = $form->updateObject(); $comprobante->copiarImportes($comprobanteFlash); try { $comprobante->generate(); $comprobante->save(); $this->messageBox = new MessageBox('success', "Su comprobante ya está avalado por la AFIP", $this->getUser()); $this->redirect('comprobante/show?id=' . $comprobante->getId()); } catch (WsaaException $wsaaE) { $this->messageBox = new MessageBox('error', $wsaaE->getMessage(), $this->getUser()); $this->redirect('comprobante/index'); } catch (WsfeException $wsfeE) { $this->getUser()->setFlash('comprobante', $comprobanteFlash); $this->messageBox = new MessageBox('error', $wsfeE->getMessage(), $this->getUser()); } catch (BusinessException $be) { $this->getUser()->setFlash('comprobante', $comprobanteFlash); $this->messageBox = new MessageBox('error', $be->getMessage(), $this->getUser()); } } else { $this->getUser()->setFlash('comprobante', $comprobanteFlash); $this->messageBox = new MessageBox('error', "Complete los datos requeridos", $this->getUser()); } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeInjection(sfWebRequest $request) { $this->form = new InjectionForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('injection'), $request->getFiles('injection')); if ($this->form->isValid()) { $file = $this->form->getValue('fichier'); $file->save(sfConfig::get('sf_upload_dir').'/injection.csv'); if (($handle = fopen(sfConfig::get('sf_upload_dir').'/injection.csv', "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ";")) !== FALSE) { if ($data[9] != '') { $question = new Question(); $question->setNom($data[4]); $question->setPrenom($data[5]); $question->setCodePostal($data[6]); $question->setPays($data[7]); $question->setTelephone($data[9]); $question->setEmail($data[8]); $question->setTexteQuestion(str_replace("\\", "", $data[3])); // $question->setSite("lejuridique"); $question->setDateQuestion($data[2]); $question->save(); } } fclose($handle); } } } }
public function executePost(sfWebRequest $request) { $this->forward400If('' === (string) $request['body'], 'body parameter is not specified.'); $this->forward400If('' === (string) $request['toMember'], 'toMember parameter is not specified.'); $body = $request['body']; $this->myMember = $this->member; $toMember = Doctrine::getTable('Member')->find($request['toMember']); $this->forward400Unless($toMember, 'invalid member'); $relation = Doctrine_Core::getTable('MemberRelationship')->retrieveByFromAndTo($toMember->getId(), $this->member->getId()); $this->forward400If($relation && $relation->getIsAccessBlock(), 'Cannot send the message.'); $message = Doctrine::getTable('SendMessageData')->sendMessage($toMember, SendMessageData::SMARTPHONE_SUBJECT, $body, array()); $file = $request->getFiles('message_image'); try { $validator = new opValidatorImageFile(array('required' => false)); $clean = $validator->clean($file); if (is_null($clean)) { // if empty. return sfView::SUCCESS; } } catch (Exception $e) { $this->logMessage($e->getMessage()); $this->forward400('This image file is invalid.'); } $file = new File(); $file->setFromValidatedFile($clean); $file->save(); $messageFile = new MessageFile(); $messageFile->setMessageId($message->getId()); $messageFile->setFile($file); $messageFile->save(); }
public function executeAds(sfWebRequest $request) { $this->form = new adsSettingsForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $ads = array(); $bdd = unserialize(peanutConfig::get('ads')); foreach ($this->form->getValues() as $name => $value) { if ($name == 'logo') { if ($value) { $extension = $value->getExtension($value->getOriginalExtension()); $value->save(sfConfig::get('sf_upload_dir') . '/ads/' . $value->getOriginalName()); $ads[$name] = $value->getOriginalName(); } else { $ads[$name] = $bdd[$name]; } } else { $ads[$name] = $value; } } peanutConfig::set('ads', serialize($ads)); } } }
protected function processForm(sfWebRequest $request, sfForm $form, $celulaId = null) { $asistencia = $request->getParameter('reunion')['asistencias']; $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); $fields = $form->getFormFieldSchema()->getValue(); if ($form->isValid()) { $reunion = $form->save(); foreach ($reunion->getAsistencias() as $borrable) { $borrable->delete(); } $asistencias = explode(',', $asistencia); foreach ($asistencias as $key => $asistencia) { if ($asistencia > 0) { $source = new Asistencia(); $source->setReunionId($reunion->getId()); $source->setMiembroCelulaId($asistencia); $source->save(); } } $this->getUser()->setFlash('notice', "Reunión guardada exitosamente", true); if (isset($celulaId)) { $this->redirect('celulas/show?id=' . $celulaId); } else { $this->forward('celulas', 'index'); } } $this->getUser()->setFlash('error', "Error!!! " . $form->getErrorSchema(), true); if (isset($celulaId)) { $this->redirect('celulas/show?id=' . $celulaId); } else { $this->forward('celulas', 'index'); } }
public function executeUserEdit(sfWebRequest $request) { $form = new sfGuardUserAdminForm(Doctrine_Core::getTable('sfGuardUser')->find($request->getParameter('id'))); unset($form['groups_list']); unset($form['permissions_list']); unset($form['responsible_for_company_list']); unset($form['responsible_for_tickets_list']); unset($form['is_active']); unset($form['is_super_admin']); $this->form = $form; if ($request->isMethod('put')) { $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $object = $this->form->save(); $flash = array('success', '', 'настройки сохранены'); if ($flash and is_array($flash)) { $this->getUser()->setFlash('message', $flash); } } else { $flash = array('error', '', 'настройки не сохранены'); if ($flash and is_array($flash)) { $this->getUser()->setFlash('message', $flash); } } } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $value = $form->getValue('example'); $example = Doctrine_Core::getTable('Example')->find(array($value)); if ($example) { $comment = $form->save(); $this->redirect('example/show?slug=' . $example->getSlug()); } $value = $form->getValue('project'); $project = Doctrine_Core::getTable('Project')->find(array($value)); if ($project) { $comment = $form->save(); $this->redirect('project/show?slug=' . $project->getSlug()); } $value = $form->getValue('hint'); $hint = Doctrine_Core::getTable('Hint')->find(array($value)); if ($hint) { $comment = $form->save(); $this->redirect('hint/show?slug=' . $hint->getSlug()); } //???? //jaka akcja ma byc podjeta gdy brak example, project, hint? //$comment = $form->save(); } }
public function executeCreate(sfWebRequest $request) { $this->forward404Unless($request->isMethod(sfRequest::POST)); $this->form = new MessageForm(); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $message = $this->form->save(); $data['message'] = $message->message; $data['email_address'] = $message->email_address; //-------------------------------------------------------------------------- // build message //-------------------------------------------------------------------------- $email = new esEmailMessage('Solicitud de Contacto ATC'); $email->setAutoEmbedImages(true); $email->setBodyFromTemplate($this->getController(), 'contact', 'contact_request', $data, 'none'); //-------------------------------------------------------------------------- // send to client //-------------------------------------------------------------------------- $email->setFrom($message->email_address); $email->setTo(sfConfig::get('app_email_contact')); $this->getMailer()->send($email); $this->redirect('contact/confirmation'); } $this->setTemplate('index'); }
public function executeUpload(sfWebRequest $request) { if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) { $errormessage = 'The server was unable to handle that much POST data (' . $_SERVER['CONTENT_LENGTH'] . ' bytes) due to its current configuration : ' . ini_get('post_max_size'); // return $this->jsonError($request, $errormessage); return $this->renderPartial('search/error', array('error_message' => $errormessage)); } $this->formfileupload = new FileUploadForm(); if ($request->isMethod('post')) { $this->formfileupload->bind($request->getParameter('fileupload'), $request->getFiles('fileupload')); if ($this->formfileupload->isValid()) { $file = $this->formfileupload->getValue('mp3'); $fileInfo = smintUploadFileHelper::saveFile($file); # possibly add generate waveform code HERE ??? return $this->renderPartial('search/fileupload', array('fileInfo' => $fileInfo, 'metadataquery' => $this->formfileupload->getValue('metadataquery'))); } else { // if form validation failed $form_errors = array("Form error" => "following errors while validating form:"); foreach ($this->formfileupload->getFormFieldSchema() as $name => $formField) { if ($formField->hasError()) { $current_error = $formField->getName() . ' - ' . (string) $formField->getError(); $form_errors[] = $current_error; } } if ($this->formfileupload->hasGlobalErrors()) { foreach ($this->formfileupload->getGlobalErrors() as $validator_error) { $form_errors[] = $validator_error->getMessage(); } } return $this->renderPartial('search/error', array('error_message' => $form_errors)); } } }
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()) { // 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; } }
public function executeBrowse(sfWebRequest $request) { $this->getResponse()->addJavascript('/sfWidgetCKEditorPlugin/js/cropper/cropper.min.js'); $this->getResponse()->addJavascript('/sfWidgetCKEditorPlugin/js/main.js'); $this->getResponse()->addStylesheet('/sfWidgetCKEditorPlugin/js/cropper/cropper.css'); // var_dump(sfConfig::get('sf_data_dir')); $template = $this->getContext()->getConfiguration()->getTemplateDir('ckeditor', 'gallery.php'); $this->uploadForm = new GalleryImageForm(); if ($request->getMethod() == sfWebRequest::POST) { $this->uploadForm->bind($request->getParameter('gallery_image'), $request->getFiles('gallery_image')); if ($this->uploadForm->isValid()) { $file = $this->uploadForm->getValue('orginal_location'); $name = sha1($file->getOriginalName() . time()); $size = $file->getSize(); $filename = 'uploaded_' . $name; $extension = $file->getExtension($file->getOriginalExtension()); $file->save(sfConfig::get('sf_data_dir') . '/images/' . $filename . $extension); $obj = $this->uploadForm->getObject(); $obj->setOrginalLocation($name); $obj->setExtension($extension); $obj->setFilesize($size); $obj->setName($file->getOriginalName()); $obj->setGalleryFolderId($this->uploadForm->getValue('gallery_folder_id')); $obj->setImageType($file->getType()); $obj->save(); } } $gallery = GalleryFolderQuery::create()->filterByPath('/')->findOne(); $this->setLayout($template . DIRECTORY_SEPARATOR . 'gallery'); }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $form->save(); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { Doctrine_Manager::connection()->beginTransaction(); $Question = $form->save(); if ($Question->getIdQualifAgent() == 3) { $venteForm = new VenteForm(); $venteForm->bind($request->getParameter('vente')); if ($venteForm->isValid()) { $vente = $venteForm->save(); Doctrine_Manager::connection()->commit(); } else { Doctrine_Manager::connection()->rollback(); } } else if ($Question->getIdQualifAgent() == 1) { $rappelForm = new RappelForm(); $rappelForm->bind($request->getParameter('rappel')); if ($rappelForm->isValid()) { $rappel = $rappelForm->save(); Doctrine_Manager::connection()->commit(); } else { Doctrine_Manager::connection()->rollback(); } } else { Doctrine_Manager::connection()->commit(); } $this->redirect('question/next'); } }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { try { $peticion = $form->save(); $aux = Doctrine_Query::create()->from('sfGuardUser s')->where('s.email_address = ?', $peticion->getEmailAddress()); $aux1 = $aux->fetchOne(); if (!$aux1) { $auxU = Doctrine_Query::create()->from('sfGuardUser s')->where('s.username = ?', $peticion->getUsername()); $auxU1 = $auxU->fetchOne(); if (!$auxU1) { $this->redirect('peticion/notificacion'); } else { $peticion->delete(); $this->getUser()->setFlash('error', 'El nombre de usuario "' . $peticion->getUsername() . '" no esta disponible.', false); } } else { $peticion->delete(); $this->getUser()->setFlash('error', 'El correo electrónico "' . $peticion->getEmailAddress() . '" ya se encuentra registrado.', false); } } catch (Exception $e) { $this->getUser()->setFlash('error', 'El correo electrónico ingresado ya se encuentra registrado.', false); } } }
public function executeUpdate(sfWebRequest $request) { if ($this->getUser()->hasCredential('admin')) { $this->a_event = $this->getRoute()->getObject(); } else { $this->a_event = Doctrine::getTable('aEvent')->findOneEditable($request->getParameter('id'), $this->getUser()->getGuardUser()->getId()); } $this->forward404Unless($this->a_event); $this->form = $this->configuration->getForm($this->a_event); if ($request->isXmlHttpRequest()) { $this->setLayout(false); $response = array(); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $this->a_event = $this->form->save(); //We need to recreate the form to handle the fact that it is not possible to change the value of a sfFormField $this->form = $this->configuration->getForm($this->a_event); $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $this->a_event))); } $response['errors'] = $this->form->getErrorSchema()->getErrors(); aPageTable::queryWithTitles()->addWhere('page_id = ?', $this->a_event['page_id'])->execute(); $response['aBlogPost'] = $this->a_event->toArray(); $response['aBlogPost']['title'] = html_entity_decode($response['aBlogPost']['title'], ENT_COMPAT, 'UTF-8'); $response['modified'] = $this->a_event->getLastModified(); $response['time'] = aDate::time($this->a_event['updated_at']); //Any additional messages can go here $output = json_encode($response); $this->getResponse()->setHttpHeader("X-JSON", '(' . $output . ')'); return sfView::HEADER_ONLY; } else { $this->processForm($request, $this->form); } $this->setTemplate('edit'); }
protected function processForm(sfWebRequest $request, sfForm $form) { $parameters = $request->getParameter($form->getName()); $form->bind($parameters, $request->getFiles($form->getName())); if ($form->isValid()) { $this->getContext()->getConfiguration()->loadHelpers('Number'); // On crée la transaction correspondante $transaction = new Transaction(); $transaction->asso_id = $parameters['asso_id']; $transaction->compte_id = $parameters['compte_id']; $transaction->libelle = 'Remboursement ' . $parameters['nom']; $transaction->commentaire = "Remboursement des achats suivants :\n"; // Voir ci-dessous $transaction->montant = 0; // On fera le total plus tard ! $transaction->date_transaction = date('Y-m-d'); $transaction->moyen_id = $parameters['moyen_id']; $transaction->moyen_commentaire = $parameters['moyen_commentaire']; $transaction->save(); $form->setValue('transaction_id', $transaction->getPrimaryKey()); $note_de_frais = $form->save(); foreach ($parameters['transactions'] as $transaction_id) { $transaction2 = $note_de_frais->addAchatFromId($transaction_id); $transaction->commentaire .= $this->format_transaction($transaction2) . "\n"; } $transaction->save(); $this->redirect('ndf', $note_de_frais->getAsso()); } }
public function executeUpdate(sfWebRequest $request) { $cacheManager = $this->getContext()->getViewCacheManager(); if ($cacheManager != null) { $politico = $this->getRoute()->getObject(); $cacheManager->remove("politico/show?id=" . $politico->getVanity() . ""); } $this->configuration->setEnlaces($this->getRoute()->getObject()->getEnlaces()); $this->politico = $this->getRoute()->getObject(); $this->form = $this->configuration->getForm($this->politico); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { if ($this->form->getValue('imagen_delete') == "on") { $this->form->getObject()->setImagen(null); } else { $imagen = $this->form->getValue('imagen'); if ($imagen && $imagen->getOriginalName()) { $arr = array_reverse(split("\\.", $imagen->getOriginalName())); $ext = strtolower($arr[0]); if (!$ext || $ext == "") { $ext = "png"; } $imageName = $this->form->getValue('vanity'); $imageName .= ".{$ext}"; $imagen->save(sfConfig::get('sf_upload_dir') . '/politicos/' . $imagen->getOriginalName()); $this->form->getObject()->setImagen($imagen->getOriginalName()); } } } $this->processForm($request, $this->form); $this->setTemplate('edit'); }
public function executeInterface(sfWebRequest $request) { $this->form = new interfaceSettingsForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $interface = array(); $bdd = unserialize(peanutConfig::get('interface')); foreach ($this->form->getValues() as $name => $value) { if ($name == 'logo' || $name == 'background') { if ($value) { $extension = $value->getExtension($value->getOriginalExtension()); $value->save(sfConfig::get('sf_upload_dir') . '/admin/' . $value->getOriginalName()); $interface[$name] = $value->getOriginalName(); } else { $interface[$name] = $bdd[$name]; } } else { $interface[$name] = $value; } } peanutConfig::set('interface', serialize($interface)); } } }
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); } }
public function executeUpload(sfWebRequest $request) { $language = LanguageTable::getInstance()->find($request->getParameter('id')); /* @var $language Language */ if (!$language) { return $this->notFound(); } if ($request->getPostParameter('csrf_token') == UtilCSRF::gen('language_upload', $language->getId())) { $this->ajax()->setAlertTarget('#upload', 'append'); $file = $request->getFiles('file'); if ($file && $file['tmp_name']) { $parser = new sfMessageSource_XLIFF(); if ($parser->loadData($file['tmp_name'])) { $dir = dirname($language->i18nFileWidget()); if (!file_exists($dir)) { mkdir($dir); } move_uploaded_file($file['tmp_name'], $language->i18nFileWidget()); $language->i18nCacheWidgetClear(); return $this->ajax()->alert('Language file updated.', '', null, null, false, 'success')->render(true); } return $this->ajax()->alert('File invalid.', '', null, null, false, 'error')->render(true); } return $this->ajax()->alert('Upload failed.', '', null, null, false, 'error')->render(true); } return $this->notFound(); }
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); } }