Ejemplo n.º 1
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.º 2
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.º 3
0
 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();
     }
 }
Ejemplo n.º 4
0
 protected function redirectFromCreate(sfForm $form)
 {
     if (is_numeric($form->getValue('project_id'))) {
         $this->redirect('@projects_show?id=' . $form->getValue('project_id'));
     } else {
         if (is_numeric($form->getValue('entity_id'))) {
             $this->redirect('@contacts_show?id=' . $form->getValue('entity_id'));
         } else {
             throw new Exception('Must provide project or entity id');
         }
     }
 }
Ejemplo n.º 5
0
 protected function processForm(sfWebRequest $request, sfForm $form, $accion)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $cliente = ClientePeer::retrieveByPk($form->getValue('cliente_id'));
         $this->forward404Unless($cliente, sprintf('Cliente no encontrado (%s).', $form->getValue('cliente_id')));
         $contacto = $form->save();
         $this->messageBox = new MessageBox("success", "El contacto ha sido {$accion} correctamente", $this->getUser());
         $this->redirect('cliente/show?id=' . $contacto->getCliente()->getId());
     } else {
         $this->messageBox = new MessageBox("error", "Verifique los datos ingresados", $this->getUser());
     }
 }
Ejemplo n.º 6
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.º 7
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.º 8
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);
     }
 }
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.';
         // 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.º 10
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if (!is_null($form->getValue('home_automation_controller'))) {
             $nb = $form->getValue('home_automation_controller');
             // Récupère le contrôleur domotique sélectionné (grâce à sa position dans le ConfigurationHelper)
             $hac = ConfigurationHelper::getParameter(null, 'home_automation_controller' . ($nb + 1));
             $hac .= $nb + 1;
             $controller = ConfigurationHelper::getParameter($hac, 'controller_name');
             $name = EnergyactionPeer::buildName($controller, $form->getvalue('name'));
             $energyaction = $form->save();
             $energyaction->setName($name);
             $energyaction->save();
         } else {
             $energyaction = $form->save();
         }
         $this->redirect('energyaction/index');
     }
 }
Ejemplo n.º 11
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $sf_guard_user = $form->save();
         $this->redirect('@contacts_show?id=' . $form->getValue('person_id'));
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.');
     }
 }
Ejemplo n.º 12
0
 /**
  * Processes the "need time" form
  */
 protected function processAddNeedForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         $time = $form->save();
         $request->setAttribute('resource', $time);
         $body = $this->getController()->getPresentationFor('time', 'needEmail');
         $message = $this->getMailer()->compose(sfConfig::get('app_email_from'), $form->getValue('email'), dnConfig::getEmailSubject('need_time_creation'), $body);
         $message->setContentType('text/html');
         $this->getMailer()->send($message);
         $this->getUser()->setOwner($time);
         $this->redirect($this->generateUrl('time_show', array('sf_subject' => $time)));
     }
     $this->getUser()->setFlash('error', 'You are missing some of the required fields below.');
 }
Ejemplo n.º 13
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $nb = $form->getValue('physical_access_controller');
         // Récupère le contrôle d'accès physique sélectionné (grâce à sa position dans le ConfigurationHelper)
         $pac = ConfigurationHelper::getParameter(null, 'physical_access_controller' . ($nb + 1));
         $pac .= $nb + 1;
         $controller = ConfigurationHelper::getParameter($pac, 'controller_name');
         $name = RoomprofilePeer::buildName($controller, $form->getvalue('name'));
         $roomprofile = $form->save();
         $roomprofile->setName($name);
         $roomprofile->save();
         $this->redirect('roomprofile/index?roomId=' . $roomprofile->getRoomId());
     }
     $this->setTemplate('edit');
 }
Ejemplo n.º 14
0
	protected function processForm(sfWebRequest $request, sfForm $form)
	{
		//$form->bind($request->getParameter($form->getName()));
		$form->bind($request->getParameter($form->getName('ficheros')), $request->getFiles('ficheros'));
		 
		if ($form->isValid())
		{
			//Este metodo es para formularios doctrine
			//$form->saveFile ($field, $filename = null, $file = null);

			//Recoge archivo
			$file = $form->getValue('file');
			//Ruta de subida
			$directorio=sfConfig::get('sf_upload_dir').'/ficheros';

			//Si el directorio no existe le creo
			if (!is_dir($directorio))
			{
				mkdir ($directorio,0777);
			}

			$this-> existe_fichero = false;

			if (is_file($directorio.'/'.$file->getOriginalName()))
			{
				$this->logMessage("EXISTE UN FICHERO CON EL MISMO NOMBRE: " . $file->getOriginalName() ,"debug" );
				$this-> existe_fichero = true;
				$this->getUser()->setFlash('error', 'YA EXISTE UN FICHERO CON EL MISMO NOMBRE');
			}
			else{//si no existe el fichero lo guardamos
				//Guardo (subo) el fichero
				$file->save($directorio.'/'.$file->getOriginalName());
				//Actualizo el objeto del formulario
				$form->updateObject();
				//Añado los campos "propios"
				$form->getObject()->setFile($file->getOriginalName());
				//guardo el objeto
				$form->getObject()->save();
			}
			$this->redirect('ficheros/new');
		}
	}
Ejemplo n.º 15
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 {
             $rfid_groupe_visiteur = $form->save();
             $rfid_groupe_visiteur->createAnonymousVisitor($form->getValue('contexte_creation_id'));
         } 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' => $rfid_groupe_visiteur)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@rfid_groupe_visiteur_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $route = 'rfid_groupe_visiteur';
             $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'] = $rfid_groupe_visiteur;
             }
             $this->redirect($url);
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
Ejemplo n.º 16
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         //$this->ei_version_notice = $form->save();
         $this->success = $this->ei_version_notice->updateCentralNotice(array("description" => $form->getValue("description"), "expected" => $form->getValue("expected"), "result" => $form->getValue("result")));
     } else {
         $this->success = false;
     }
 }
Ejemplo n.º 17
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if ($form->getObject()->isNew()) {
             $tasks = Doctrine_Core::getTable('Tasks')->find($request->getParameter('tasks_id'));
             if ($form->getValue('tasks_priority_id') > 0) {
                 $tasks->setTasksPriorityId($form->getValue('tasks_priority_id'));
             } else {
                 unset($form['tasks_priority_id']);
             }
             if ($request->getParameter('tasks_labels_id') > 0) {
                 $tasks->setTasksLabelId($request->getParameter('tasks_labels_id'));
             }
             if ($request->getParameter('tasks_types_id') > 0) {
                 $tasks->setTasksTypeId($request->getParameter('tasks_types_id'));
             }
             if (strlen($form->getValue('due_date')) > 0) {
                 $tasks->setDueDate($form->getValue('due_date'));
             } else {
                 unset($form['due_date']);
             }
             if ($request->getParameter('progress') > 0) {
                 $tasks->setProgress($request->getParameter('progress'));
             }
             if ($form->getValue('tasks_status_id') > 0) {
                 $tasks->setTasksStatusId($form->getValue('tasks_status_id'));
                 if (in_array($form->getValue('tasks_status_id'), app::getStatusByGroup('closed', 'TasksStatus'))) {
                     $tasks->setClosedDate(date('Y-m-d H:i:s'));
                     $tasks->save();
                 }
                 if (!in_array($form->getValue('tasks_status_id'), app::getStatusByGroup('closed', 'TasksStatus'))) {
                     $tasks->setClosedDate(null);
                     $tasks->save();
                 }
             } else {
                 unset($form['tasks_status_id']);
             }
             $tasks->save();
         }
         if ($form->getObject()->isNew() and sfConfig::get('app_allow_adit_tasks_comments_date') != 'on') {
             $form->setFieldValue('created_at', date('Y-m-d H:i:s'));
         }
         $tasks_comments = $form->save();
         Attachments::insertAttachments($request->getFiles(), 'comments', $tasks_comments->getId(), $request->getParameter('attachments_info'), $this->getUser());
         TasksComments::sendNotification($this, $tasks_comments, $this->getUser());
         $this->redirect('tasksComments/index?projects_id=' . $request->getParameter('projects_id') . '&tasks_id=' . $request->getParameter('tasks_id'));
     }
 }
Ejemplo n.º 18
0
 protected function submitForm(sfWebRequest $request, sfForm $courseform, sfForm $courseDetailform, sfForm $courseDisAssocform)
 {
     $courseform->bind($request->getParameter($courseform->getName()), $request->getFiles($courseform->getName()));
     $courseDetailform->bind($request->getParameter($courseDetailform->getName()), $request->getFiles($courseDetailform->getName()));
     $courseDisAssocform->bind($request->getParameter($courseDisAssocform->getName()), $request->getFiles($courseDisAssocform->getName()));
     $courseDetailObj = $courseDetailform->getObject()->setCourseId($courseform->getValue('id'));
     $courseDisAssocObj = $courseDisAssocform->getObject()->setCourseId($courseform->getValue('id'));
     if ($courseform->isValid()) {
         if ($courseDetailform->isValid() && $courseDisAssocform->isValid()) {
             $courseresult = $courseform->save();
             $courseDetailresult = $courseDetailform->save();
             $courseDisAssocres = $courseDisAssocform->save();
             $_SESSION['update'] = $courseresult->getId();
             $this->redirect('admincourse/index');
             //$this->redirect('course/index');
         }
     }
 }
Ejemplo n.º 19
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $file = $form->getValue('path');
         if ($file != null) {
             $form->updateObject();
             $form->getObject()->setFilename($file->getOriginalName());
             $form->getObject()->save();
             $ei_subject_attachment = $form->getObject();
             //$ei_subject_attachment = $form->save();
             $this->getUser()->setFlash('alert_form', array('title' => 'Success', 'class' => 'alert-success', 'text' => 'Attachment has been add sucessfully ...'));
             //Suivant le type du fichier attaché , on éffectue la bonne redirection
         } else {
             $this->getUser()->setFlash('alert_form', array('title' => 'Error', 'class' => 'alert-danger', 'text' => 'Please select a file ...'));
         }
         $this->redirectWithinAttachmentType($form->getValue('type'));
     }
 }
Ejemplo n.º 20
0
 /**
  * Compute different sources to get the columns that must be showed
  * 1) from form request 2) from session 3) from default value
  * @param sfBasicSecurityUser $user the user
  * @param sfForm $form The filter form with the 'col_fields' field defined
  * @param bool $as_string specify if you want the return to be a string (concat of visible cols)
  * @return array of fields with check or uncheck or a list of visible fields separated by |
  */
 private function getVisibleColumns(sfBasicSecurityUser $user, sfForm $form, $as_string = false)
 {
     $flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'codes', 'chrono', 'ig', 'acquisition_category', 'litho', 'lithologic', 'mineral', 'expedition', 'type', 'individual_type', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'individual_count', 'part', 'object_name', 'part_status', 'building', 'floor', 'room', 'row', 'col', 'shelf', 'container', 'container_type', 'container_storage', 'sub_container', 'sub_container_type', 'sub_container_storage', 'specimen_count', 'part_codes', 'loans');
     $flds = array_fill_keys($flds, 'uncheck');
     if ($form->isBound() && $form->getValue('col_fields') != "") {
         $req_fields = $form->getValue('col_fields');
         $req_fields_array = explode('|', $req_fields);
     } else {
         $req_fields_array = $user->fetchVisibleCols();
     }
     if (empty($req_fields_array)) {
         $req_fields_array = explode('|', $form->getDefault('col_fields'));
     }
     if ($as_string) {
         return implode('|', $req_fields_array);
     }
     foreach ($req_fields_array as $k => $val) {
         $flds[$val] = 'check';
     }
     return $flds;
 }
Ejemplo n.º 21
0
 /**
  * Compute different sources to get the columns that must be showed
  * 1) from form request 2) from session 3) from default value
  * @param sfForm $form The form with the 'fields' field defined
  * @return array of fields with check or uncheck or a list of visible fields separated by |
  */
 private function getVisibleColumns(sfForm $form)
 {
     $flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'chrono', 'taxon_common_name', 'chrono_common_name', 'litho_common_name', 'lithologic_common_name', 'mineral_common_name', 'expedition', 'individual_type', 'litho', 'lithologic', 'mineral', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'specimen_count', 'object_name');
     $flds = array_fill_keys($flds, 'uncheck');
     if ($form->isBound()) {
         $req_fields = $form->getValue('col_fields');
         if ($form->getValue('taxon_common_name') != '' || $form->getValue('taxon_name') != '') {
             $req_fields .= '|taxon|taxon_common_name';
         }
         if ($form->getValue('chrono_common_name') != '' || $form->getValue('chrono_name') != '') {
             $req_fields .= '|chrono|chrono_common_name';
         }
         if ($form->getValue('litho_common_name') != '' || $form->getValue('litho_name') != '') {
             $req_fields .= '|litho|litho_common_name';
         }
         if ($form->getValue('lithology_common_name') != '' || $form->getValue('lithology_name') != '') {
             $req_fields .= '|lithologic|lithology_common_name';
         }
         if ($form->getValue('mineral_common_name') != '' || $form->getValue('mineral_name') != '') {
             $req_fields .= '|mineral|mineral_common_name';
         }
         if ($form->getValue('search_type', 'zoo') == 'zoo') {
             if (!strpos($req_fields, 'common_name')) {
                 $req_fields .= '|taxon|taxon_common_name';
                 // add taxon by default if there is not other catalogue
             }
         } else {
             if (!strpos($req_fields, 'common_name')) {
                 $req_fields .= '|chrono|litho|lithologic|mineral';
             }
             // add cols by default if there is not other catalogue
         }
         $req_fields_array = explode('|', $req_fields);
     }
     if (empty($req_fields_array)) {
         $req_fields_array = explode('|', $form->getDefault('col_fields'));
     }
     foreach ($req_fields_array as $k => $val) {
         $flds[$val] = 'check';
     }
     $form->setDefault('col_fields', $req_fields);
     return $flds;
 }
Ejemplo n.º 22
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->getValue('recipient_id') == $this->getUser()->getApiUserId()) {
         $this->getUser()->setFlash('error', 'You cannot sent messages to yourself.');
         $this->redirect('message');
     }
     if ($form->isValid() && $this->getUser()->getApiUserId()) {
         $auth_key = $this->getUser()->getApiAuthKey();
         if ($form->getValue('id')) {
             // Update existing item.
             $values = $form->getObject()->getModified();
             $message = $form->getObject();
             unset($values['id']);
             $id = $form->getValue('id');
             $result = Api::getInstance()->setUser($auth_key)->put('message/' . $id, $values);
             $success = $this->checkHttpCode($result, 'put', 'message/' . $id, json_encode($values));
             if ($success) {
                 $this->getUser()->setFlash('notice', 'Message was edited successfully.');
             }
             $test_message = ApiDoctrine::createObject('Message', $result['body']);
             $message = $test_message ? $test_message : $message;
         } else {
             // Create new item
             $values = $form->getValues();
             $message = $form->getObject();
             foreach ($values as $key => $value) {
                 if (is_null($value)) {
                     unset($values[$key]);
                 }
             }
             if (!array_key_exists('sender_id', $values)) {
                 $values['sender_id'] = $this->getUser()->getApiUserId();
             }
             $result = Api::getInstance()->setUser($auth_key)->post('message', $values);
             $success = $this->checkHttpCode($result, 'post', 'message', json_encode($values));
             if ($success) {
                 $this->getUser()->setFlash('notice', 'Message was sent successfully.');
             }
         }
         if (!$this->getUser()->getApiUserId()) {
             $this->getUser()->setFlash('error', 'You are not logged in!');
         }
         $this->redirect('message');
     }
 }
Ejemplo n.º 23
0
 protected function processPswChangeForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         // Save TMP image and check
         $form->getValue('img_file_name')->save();
         $rezult = $this->user->checkSequereImg($form->getValue('img_file_name')->getSavedName());
         @unlink($form->getValue('img_file_name')->getSavedName());
         return $rezult;
     }
     if (!is_object($form->getValue('img_file_name'))) {
         return false;
     }
     if ($form->getValue('img_file_name')->getSavedName() != '') {
         @unlink($form->getValue('img_file_name')->getSavedName());
     }
     return false;
 }
Ejemplo n.º 24
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $auth_key = $this->getUser()->getApiAuthKey();
         // Update existing item.
         $values = $form->getTaintedValues();
         $user_id = $form->getValue('id') ? $form->getValue('id') : $this->getUser()->getApiUserId();
         unset($values['_csrf_token'], $values['is_active'], $values['password'], $values['password_again'], $values['groups_list'], $values['permissions_list'], $values['is_validated'], $values['reddit_validation_key'], $values['is_authorized'], $values['email_authorization_key'], $values['authorized_at'], $values['is_super_admin'], $values['algorithm'], $values['id'], $values['salt'], $values['last_login']);
         if ($form->getValue('password')) {
             $values['password'] = $form->getValue('password');
         }
         $user_data = Api::getInstance()->get('user/' . $user_id);
         $user = ApiDoctrine::createObject('sfGuardUser', $user_data['body']);
         $user_values = $user->toArray();
         foreach ($values as $key => $value) {
             if ($value == $user_values[$key]) {
                 unset($values[$key]);
             }
         }
         if (array_key_exists('id', $values)) {
             unset($values['id']);
         }
         $id = $this->getUser()->getApiUserId();
         $result = Api::getInstance()->setUser($auth_key)->put('user/' . $id, $values);
         $success = $this->checkHttpCode($result, 'put', 'user/' . $id, json_encode($values));
         if ($success) {
             $this->getUser()->setFlash('notice', 'Profile was edited successfully.');
         }
         $this->redirect('profile');
     }
 }
Ejemplo n.º 25
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     $prefix = $form->getName();
     // get year
     $year = $form->getValue("year") . $form->getValue("term");
     $file = $_FILES["file_path"];
     if (isset($file) && $file["name"] != '') {
         // check the file is pdf
         $_fpath = $file["name"];
         if (strtoupper(substr($_fpath, -3, 3)) != "PDF") {
             $this->globalerrors = "File must be PDF";
             return;
         }
         $oldfile = $this->form->getObject()->getFilePath();
         if ($oldfile !== null || $oldfile != '') {
             //previously there was something there, delete it!
             if (!$this->delExam($oldfile)) {
                 $this->globalerrors = "Unable to physically remove file";
                 return;
             }
         }
         // determine what type of exam it is
         switch ($request->getParameter($prefix . "[type]")) {
             case EnumItemPeer::EXAM:
                 $examTypeAbbr = "exam";
                 break;
             case EnumItemPeer::TEST:
                 $examTypeAbbr = "ts";
                 break;
             case EnumItemPeer::QUIZ:
                 $examTypeAbbr = "qs";
                 break;
             case EnumItemPeer::PROBLEM_SET:
                 $examTypeAbbr = "ps";
                 break;
         }
         $fileName = substr($this->courseId, 0, 6) . '_' . substr($this->year, 0, 4) . '_' . $examTypeAbbr . '_' . time() . ".pdf";
         $path = skuleadminConst::INDIVIDUALEXAMFOLDER . $this->year . '/';
         $filePath = $path . $fileName;
         try {
             // make sure the directories are set up properly
             if (!is_dir($path)) {
                 if (!mkdir($path)) {
                     $globalerrors = "Unable to create directory";
                     return;
                 }
             }
             if (move_uploaded_file($file['tmp_name'], $filePath)) {
                 //die($form->getValue("descr"));
                 // now save the exam object
                 // TODO we have to do a manual save until we can figure out how to work the form with file upload
                 $exam = $form->getObject();
                 $exam->setCourseId($this->courseId);
                 $exam->setType($request->getParameter($prefix . "[type]"));
                 $exam->setYear($request->getParameter($prefix . "[year]") . $request->getParameter($prefix . "[term]"));
                 $exam->setDescr($request->getParameter($prefix . "[descr]"));
                 $exam->setFilePath($filePath);
                 $exam->save();
                 $this->redirect('adminexam/edit?id=' . $exam->getId() . "&course=" . $this->courseId . "&year=" . substr($this->year, 0, 4) . "&term=" . substr($this->year, 4, 1));
             } else {
                 $this->globalerrors = "Unable to save file";
                 return;
             }
         } catch (Exception $e) {
             $this->globalerrors = $e->getMessage();
             return;
         }
     } else {
         if ($form->getObject()->isNew()) {
             $this->globalerrors = "A file must be uploaded";
             return;
         }
         try {
             $exam = $form->getObject();
             $exam->setYear($year);
             $exam->setType($form->getValue("type"));
             $exam->setDescr($form->getValue("descr"));
             $exam->save();
             $this->redirect('adminexam/edit?id=' . $form->getObject()->getId() . "&course=" . $this->courseId . "&year=" . substr($this->year, 0, 4) . "&term=" . substr($this->year, 4, 1));
         } catch (Exception $e) {
             $this->globalerrors = $e->getMessage();
             return;
         }
     }
 }
Ejemplo n.º 26
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if ($form->getObject()->isNew()) {
             $discussions = Doctrine_Core::getTable('Discussions')->find($request->getParameter('discussions_id'));
             if ($form->getValue('discussions_status_id') > 0) {
                 $discussions->setDiscussionsStatusId($form->getValue('discussions_status_id'));
             } else {
                 unset($form['discussions_status_id']);
             }
             $discussions->save();
         }
         if ($form->getObject()->isNew()) {
             $form->setFieldValue('created_at', date('Y-m-d H:i:s'));
         }
         $discussions_comments = $form->save();
         Attachments::insertAttachments($request->getFiles(), 'discussionsComments', $discussions_comments->getId(), $request->getParameter('attachments_info'), $this->getUser());
         DiscussionsComments::sendNotification($this, $discussions_comments, $this->getUser());
         $this->redirect('discussionsComments/index?projects_id=' . $request->getParameter('projects_id') . '&discussions_id=' . $request->getParameter('discussions_id'));
     }
 }
Ejemplo n.º 27
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         $addressData = (array) json_decode($form->getValue('address'));
         $photos = (array) json_decode($form->getValue('photos'));
         $loc = $form->save()->updateAddress($addressData)->updatePhotos($photos);
         BotNet::create()->spammed($loc, 'description');
         return $loc;
     }
     return null;
 }
Ejemplo n.º 28
0
 protected function processOrganizerForm(sfWebRequest $request, sfForm $form)
 {
     //$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         //$form->save();
         $name = $form->getValue('name');
         $email = $form->getValue('email');
         //$colour = $form->getValue('colour_code');
         $guard_user = new sfGuardUser();
         $guard_user->setEmailAddress($email);
         $guard_user->setUsername($email);
         $guard_user->setPassword($form->getValue('password'));
         $guard_user->setIsActive(1);
         $guard_user->save();
         $organizer = new Organizer();
         $organizer->setName($name);
         $organizer->setSfGuardId($guard_user->getId());
         //$organizer->setColourCode($colour);
         $organizer->save();
         $this->redirect('organize/new');
     }
 }
Ejemplo n.º 29
0
 /**
  * Processing Forms
  * @param sfWebRequest $request
  * @param sfForm $form
  * @return <boolean>
  */
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if (isset($form['balance_add'])) {
             $user = $this->getUser()->getGuardUser();
             // заводим новую транзакцию и передаем пользователя платежной системе
             $transaction = $user->addFunds($form->getValue('balance_add'));
             $pay_test = SettingTable::getInstance()->findOneByName('Платежи в тестовом режиме');
             if ((int) $pay_test->getValue() > 0) {
                 $user->addFundsFin($transaction);
             } else {
                 // создаем объект онпей и затем редиректим на форму платежа
                 $onpay = OnPay::forTransaction($transaction, $this->generateUrl('profile_u_account', array(), true));
                 return $onpay->processFirstStep();
             }
             return true;
         }
         $user = $form->save();
         return true;
     }
     return false;
 }
Ejemplo n.º 30
-1
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $files = $request->getFiles($form->getName());
     $form->bind($request->getParameter($form->getName()), $files);
     if ($form->isValid()) {
         $profile = $form->save();
         $profile->getUser()->first_name = $form->getValue('first_name');
         $profile->getUser()->last_name = $form->getValue('last_name');
         $profile->getUser()->save();
         if ($files['userpic']['name']) {
             $userpic = new sfThumbnail(48, 48, false);
             $userpic->loadFile($files['userpic']['tmp_name']);
             $name = md5($profile->id . 'userpic f**k yea') . '.png';
             $userpic->save(sfConfig::get('sf_user_pic_dir') . $name, 'image/png');
             $profile->userpic = $name;
             $profile->save();
         }
         $this->redirect('profile/show?id=' . $profile->getId());
     } else {
         //            foreach ($form->getFormFieldSchema() as $name => $formField) {
         //                if ($formField->getError() != "") {
         //                    echo "ActionClassName::methodName( ): Field Error for :" . $name . " : " . $formField->getError();
         //                }
         //            }
     }
 }