示例#1
0
 /**
  * Performs the logic for logging into the LWS backend CMS.
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->setLayout('login');
     if ($request->isMethod('POST')) {
         $dao = new DAO();
         $pw = md5($dao->getEscapedSQLString(trim($request->getPostParameter('pw'))));
         $email = $dao->getEscapedSQLString(trim(strtolower($request->getPostParameter('email'))));
         $dao->query("\n  \t\t\tSELECT be_user.*, role \n  \t\t\tFROM be_user INNER JOIN be_role USING(role_id) \n  \t\t\tWHERE email='{$email}' AND password='******' LIMIT 1\n  \t\t");
         if ($dao->queryOK()) {
             $user = $dao->next();
             $dao->query("SELECT last_login_ts FROM be_user WHERE email='{$user['email']}'");
             // I know that there is a record in the DB with this email, so no need to check
             $ts_row = $dao->next();
             $last_login = is_null($ts_row['last_login_ts']) ? 'N/A' : date('M jS Y @ g:i A', $ts_row['last_login_ts']);
             $dao->query("UPDATE be_user SET last_login_ts=UNIX_TIMESTAMP() WHERE email='{$user['email']}'");
             $this->getUser()->setAttribute('be_user', array('first_name' => $user['first_name'], 'last_name' => $user['last_name'], 'full_name' => "{$user['first_name']} {$user['last_name']}", 'email' => $user['email'], 'role' => $user['role'], 'phone' => $user['phone'], 'phone_ext' => $user['phone_ext'], 'last_login' => $last_login, 'password' => $user['password']));
             $this->getUser()->setAuthenticated(true);
             $this->getUser()->addCredential($user['role']);
         } else {
             if ($this->getUser()->hasAttribute('be_user')) {
                 $this->getUser()->getAttributeHolder()->remove('be_user');
             }
             $this->getUser()->setAuthenticated(false);
             $this->getUser()->setFlash('login_error', 'Invalid email and/or password!');
         }
         // allows users to go directly to requested page after login
         $uri = $this->getContext()->getRouting()->getCurrentInternalUri(true);
         $this->redirect($uri);
     }
     return sfView::SUCCESS;
 }
示例#2
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->form = new ServersForm();
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             if (!preg_match("!^\\d+.\\d+.\\d+.\\d+:\\d+\$!", $this->form->getValue("ip"))) {
                 $datas = $request->getPostParameter($this->form->getName());
                 $added = array();
                 $counter = 1;
                 $name = $this->form->getValue("hostname");
                 if (preg_match("!^(\\d+).(\\d+).(\\d+).(?<start>\\d+)\\-(?<end>\\d+):(\\d+)\$!", $this->form->getValue("ip"), $match)) {
                     for ($i = $match["start"]; $i <= $match["end"]; $i++) {
                         $ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $i . ":" . $match[6];
                         $datas["ip"] = $ip;
                         $datas["hostname"] = $name . " #" . $counter++;
                         $this->form = new ServersForm();
                         $this->form->bind($datas);
                         $this->form->save();
                         $added[] = $ip;
                     }
                 } elseif (preg_match("!^(\\d+).(\\d+).(\\d+).(?<start>\\d+)\\-(?<end>\\d+):(?<port>[0-9\\-]+)\$!", $this->form->getValue("ip"), $match)) {
                     $ports = explode("-", $match["port"]);
                     for ($i = $match["start"]; $i <= $match["end"]; $i++) {
                         foreach ($ports as $port) {
                             $ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $i . ":" . $port;
                             $datas["ip"] = $ip;
                             $datas["hostname"] = $name . " #" . $counter++;
                             $this->form = new ServersForm();
                             $this->form->bind($datas);
                             $this->form->save();
                             $added[] = $ip;
                         }
                     }
                 } elseif (preg_match("!^(\\d+).(\\d+).(\\d+).(\\d+):(?<port>[0-9\\-]+)\$!", $this->form->getValue("ip"), $match)) {
                     $ports = explode("-", $match["port"]);
                     foreach ($ports as $port) {
                         $ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $match[4] . ":" . $port;
                         $datas["ip"] = $ip;
                         $datas["hostname"] = $name . " #" . $counter++;
                         $this->form = new ServersForm();
                         $this->form->bind($datas);
                         $this->form->save();
                         $added[] = $ip;
                     }
                 } else {
                     $this->getUser()->setFlash("notification_error", $this->__("Unknown Server-Format"));
                 }
                 if (count($added) > 0) {
                     $this->getUser()->setFlash("notification_ok", count($added) . $this->__(" server were added ") . "(" . implode(", ", $added) . ")");
                     $this->redirect("servers_create");
                 }
             } else {
                 $server = $this->form->save();
                 $this->getUser()->setFlash("notification_ok", $this->__("1 Server was added with IP (") . $server->getIp() . ")");
                 $this->redirect("servers_create");
             }
         }
     }
 }
 public function executeNew(sfWebRequest $request)
 {
     if ($request->getMethod() != "POST") {
         return;
     }
     $this->username = $request->getPostParameter("username");
     if (!$this->username) {
         return $this->setErrorMsg("Username is a required field!");
     }
     $this->user = UserDAO::getUser($this->username);
     if ($this->user) {
         return $this->setErrorMsg("That username is already in use!");
     }
     $this->password1 = $request->getPostParameter("password1");
     $this->password2 = $request->getPostParameter("password2");
     if (!$this->password1 || !$this->password2) {
         return $this->setErrorMsg("Password is a required field");
     }
     if ($this->password1 != $this->password2) {
         return $this->setErrorMsg("Password and password confirm must match!");
     }
     $this->email = $request->getPostParameter("email");
     $this->user = UserDAO::createUser($this->username, $this->password1, $this->email);
     $this->login($this->user);
     $this->redirect("dashboard/index");
 }
 /**
  * Action permettant d'enregistrer ou de mettre à jour automatiquement un device
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     if ($request->getPostParameter('drivers') == null) {
         $response = array("error" => "Error with the post parameters drivers.", "success" => false);
     } else {
         $JSONArray = json_decode($request->getPostParameter('drivers'));
         //die("json: ".$JSONArray. " / error:".json_last_error());
         $device_identifier = $request->getParameter('device_identifier');
         $device_type_name = $request->getParameter('device_type');
         $response = array("error" => "An error occured when we try to create / update the device.", "success" => false);
         try {
             $device = Doctrine_Core::getTable("EiDevice")->findOneBy("device_identifier", $device_identifier);
             if ($device != null) {
                 /* Si le device existe, on efface ses drivers (les browsers sont effacés en cascade) */
                 $device_drivers = $device->getEiDeviceDriver();
                 foreach ($device_drivers as $device_driver) {
                     $device_driver->delete();
                 }
             } else {
                 /* Sinon on créé ce device */
                 $device = new EiDevice();
                 $device->setDeviceIdentifier($device_identifier);
                 $device_type = Doctrine_Core::getTable('EiDeviceType')->findOneBy('hidden_name', $device_type_name);
                 $device->setDeviceTypeId($device_type);
                 $device->save();
             }
             /* On créé les drivers et browsers de ces drivers pour le device */
             foreach ($JSONArray as $driver) {
                 $driver_type_name = $driver->{'driver_type'};
                 $driver_type = Doctrine_Core::getTable("EiDriverType")->findOneBy("hidden_name", $driver_type_name);
                 $device_driver = new EiDeviceDriver();
                 $device_driver->setDeviceId($device->getId());
                 $device_driver->setDriverTypeId($driver_type->getId());
                 $device_driver->save();
                 foreach ($driver->{'browsers'} as $browser_name) {
                     $browser_type = Doctrine_Core::getTable("EiBrowserType")->findOneBy("hidden_name", $browser_name);
                     $driver_browser = new EiDriverBrowser();
                     $driver_browser->setDeviceDriverId($device_driver->getId());
                     $driver_browser->setBrowserTypeId($browser_type->getId());
                     $driver_browser->save();
                 }
             }
             unset($response["error"]);
             $response["success"] = true;
         } catch (Exception $e) {
             $response = array("error" => "Exception : An error occured when we try to create / update the device: " . $e->getMessage());
         }
     }
     return $this->renderText(json_encode($response));
 }
示例#5
0
 public function executeSearch(sfWebRequest $request)
 {
     if ($request->getParameter('flag') == 'movie') {
         $q = Doctrine_Query::create()->select('DISTINCT a.id')->from('Actor a, MovieActor m')->where('a.id = m.actor_id')->andWhere('a.name LIKE ?', $request->getPostParameter('value'))->orderBy('a.name ASC');
         $this->actors = $q->execute();
         $this->flag = 'movies';
     } else {
         $q = Doctrine_Query::create()->select('DISTINCT a.id')->from('Actor a, TVShowActor m')->where('a.id = m.actor_id')->andWhere('a.name LIKE ?', $request->getPostParameter('value'))->orderBy('a.name ASC');
         $this->actors = $q->execute();
         $this->flag = 'tvshows';
     }
     $this->setTemplate('index');
 }
示例#6
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->config = $this->getRoute()->getObject();
     $this->form = new configsForm($this->config);
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $config = $this->form->save();
             $config->setContent($request->getPostParameter('config'));
             $config->save();
             $this->getUser()->setFlash("notification_ok", $this->__("Config edited successfully."));
             $this->redirect("configs/index");
         }
     }
 }
 public function executeReturn(sfWebRequest $request)
 {
     //--------------------------------------------------------------------------
     // if txn_id is posted, we can assume that PDT (Payment Data Transfer) is
     // inactive and return method has been set to 2
     // PDT is not tested yet and requires additional investigation
     //--------------------------------------------------------------------------
     if ($request->getPostParameter('txn_id')) {
         //--------------------------------------------------------------------------
         // instanciate application specific Paypal Interface
         //--------------------------------------------------------------------------
         $pp_class = sfConfig::get('app_es_paypal_plugin_handler', 'esPaypalHandler');
         $pp = new $pp_class();
         //--------------------------------------------------------------------------
         // handle data posted by Paypal (store as transaction)
         //--------------------------------------------------------------------------
         $transaction = $pp->handleReturn($request->getPostParameters());
         $this->data = $request->getPostParameters();
         $this->relatedEntity = $pp->getRelatedEntity();
         $this->transaction = $transaction;
     } else {
         $this->data = $request->getGetParameters();
     }
     $this->handleReturn($this->data);
 }
示例#8
0
 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();
 }
示例#9
0
 public function executeSelectorNodeForm(sfWebRequest $request)
 {
     $versionId = $request->getParameter("ei_version_id") ? $request->getParameter("ei_version_id") : $this->ei_version_id;
     /** @var EiVersion $version */
     $version = Doctrine_Core::getTable("EiVersion")->find($versionId);
     $tree = null;
     $selected = null;
     if ($request->getMethod() === "POST") {
         $blockForeach = $request->getPostParameter("ei_block_foreach");
         if ($blockForeach != null && isset($blockForeach["Iterator"]["ei_dataset_structure_id"])) {
             $selected = $blockForeach["Iterator"]["ei_dataset_structure_id"];
         }
     } elseif (isset($this->block) && $this->block instanceof EiBlockForeach) {
         $selected = $this->block->getIteratorMapping()->getEiDataSetStructureMapping()->getId();
     }
     if ($version != null && $version->getId() != "") {
         /** @var EiDataSetStructureTable $tableStructure */
         $tableStructure = Doctrine_Core::getTable("EiDataSetStructure");
         // Réupération de la structure du scénario.
         $structures = $tableStructure->getTreeArrayForITree($version->getEiScenarioId(), array(EiDataSetStructure::$TYPE_NODE));
         // Création du TreeViewer.
         $treeViewer = new TreeViewer("EiDataSetStructure");
         $treeViewer->import($structures);
         // TreeViewer pour le mapping.
         $tree = new TreeView($treeViewer, new ModeSelectInHiddenInputTreeStrategy(), array("id" => "select_node_iterator_" . time(), "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "inputTarget" => "ei_block_foreach_Iterator_ei_dataset_structure_id", "selected" => $selected, "actions" => array()));
     }
     $this->tree = $tree;
 }
示例#10
0
 public function executePriceUpdate(sfWebRequest $request)
 {
     if ($request->isMethod('POST')) {
         $display = $request->getPostParameter('display');
         $part_no = $request->getPostParameter('part_no');
         $dao = new BE_DAO();
         $dao->query("UPDATE store set display={$display} WHERE part_no='{$part_no}'");
         if ($dao->UpdateOK()) {
             $cp_msg = "{$part_no} pricing has been updated successfully.";
         } else {
             $err = $dao->getError();
             $cp_msg = "There was an error trying to update the price for {$part_no}.<br />MySQL Error: {$err}";
         }
         $this->getUser()->setFlash('cp_msg', $cp_msg);
         $this->redirect('@control_panel');
     }
     return sfView::NONE;
 }
示例#11
0
 public function executeFilters(sfWebRequest $request)
 {
     $this->filter = new MatchsFormFilter();
     $this->filter->bind($request->getPostParameter($this->filter->getName()));
     if ($this->filter->isValid()) {
         $this->setFilters($this->filter->getValues());
     }
     $this->redirect($request->getReferer());
 }
示例#12
0
 public function executeCreateBooking(sfWebRequest $request)
 {
     if ($this->getUser()->isAuthenticated()) {
         $app = Doctrine_Core::getTable('Apartment')->find($request->getPostParameter('apid'));
         $date_from = $request->getPostParameter('date_from');
         $date_to = $request->getPostParameter('date_to');
         $pax = $request->getPostParameter('pax');
         $booking = new Booking();
         $booking->Apartment = $app;
         $booking->pax = $pax;
         $booking->date_from = $date_from;
         $booking->date_to = $date_to;
         $booking->DoBooking($this->getUser()->getGuardUser());
         $this->success = true;
     } else {
         return sfView::NONE;
         /* Log this !*/
     }
 }
 /**
  * Action permettant de récupérer l'arbre des jeux de données.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT RECUPERATION ARBRE DATA SET");
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     $response = array("error" => "An error occured when we try to create your directory.");
     try {
         $this->getUser()->signIn($this->user, true);
         /** @var EiNodeTable $tableEiNode */
         $tableEiNode = Doctrine_Core::getTable("EiNode");
         // Récupération des données.
         $nom = $request->getPostParameter("name");
         $parentNodeId = $request->getPostParameter("parent_node_id");
         if ($nom == null || $parentNodeId == null) {
             $response["error"] = "You have to select a parent directory and type a valid directory name";
         } else {
             /** @var EiNode $parentNode Récupération du noeud parent. */
             $parentNode = $tableEiNode->find($parentNodeId);
             if ($parentNode != null && $parentNode->getId() != "" && $parentNode->getEiScenarioNode()->getObjId() == $this->scenario->getId()) {
                 try {
                     $folder = new EiNode();
                     $folder->setName($nom);
                     $folder->setType(EiNode::$TYPE_DATASET_FOLDER);
                     $folder->setProjectId($parentNode->getProjectId());
                     $folder->setProjectRef($parentNode->getProjectRef());
                     $folder->setRootId($parentNode->getId());
                     $folder->save();
                     unset($response["error"]);
                     $response["id"] = $folder->getId();
                 } catch (Exception $exc) {
                     $response["error"] = "An error occured when we tried to create directory : " . $exc->getMessage();
                 }
             } else {
                 $response["error"] = "We are not able to accommodate your request.";
             }
         }
     } catch (Exception $e) {
         $response = array();
     }
     return $this->renderText(json_encode($response));
 }
示例#14
0
 public function executeAddToCart(sfWebRequest $request)
 {
     $product = timpanyProductTable::getInstance()->findOneBySlug($request->getParameter('product'));
     $count = $request->getPostParameter('timpany_add_to_cart[count]', 1);
     $this->cart = timpanyCart::getInstance($this->getUser());
     $this->cart->addProduct($product, $count);
     $this->cart->save();
     $this->getUser()->setFlash('last_added_product', $product->getSlug());
     $this->redirect('@timpany_cart');
 }
示例#15
0
 public function executeAddWallpost(sfWebRequest $request)
 {
     $message = $request->getPostParameter('message');
     $source_id = $this->getUser()->getAttribute('viewing_profile_id');
     $actor_id = $this->getUser()->getAttribute('id');
     $stream = new Stream();
     $stream->message = $message;
     $stream->actor_id = $actor_id;
     $stream->source_id = $source_id;
     $stream->save();
     $this->redirect('profile/index?uid=' . $source_id);
 }
 /**
  * view Holiday list
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $holidayIds = $request->getPostParameter('chkSelectRow[]');
     if (!empty($holidayIds)) {
         foreach ($holidayIds as $key => $id) {
             $this->getHolidayService()->deleteHoliday($id);
         }
         $this->getUser()->setFlash('templateMessage', array('SUCCESS', __(TopLevelMessages::DELETE_SUCCESS)));
     } else {
         $this->getUser()->setFlash('templateMessage', array('NOTICE', __(TopLevelMessages::SELECT_RECORDS)));
     }
     $this->redirect('leave/viewHolidayList');
 }
示例#17
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->form = new SeasonsForm();
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $datas = $request->getPostParameter($this->form->getName());
             $upload = $request->getFiles($this->form->getName());
             $datas["name"] = $this->form->getValue("name");
             $datas["link"] = $this->form->getValue("link");
             $datas["start"] = $this->form->getValue("start");
             $datas["end"] = $this->form->getValue("end");
             $this->form = new SeasonsForm();
             $this->form->bind($datas, $upload);
             $this->form->save();
             $this->getUser()->setFlash("notification_ok", $this->__("Season created successfully"));
             $this->redirect("seasons_create");
         } else {
             $this->getUser()->setFlash("notification_error", $this->__("Error, invalid form"));
         }
     }
 }
示例#18
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);
     }
 }
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $arLogin = Doctrine_Core::getTable('Usuario')->createQuery('u')->where('u.login = \'' . $request->getPostParameter('usuario[login]') . '\'')->fetchArray();
     if (count($arLogin) > 0) {
         $this->getUser()->setFlash('mensagem_erro', 'Login já cadastrado, tente outro.');
         $this->redirect('usuario/new');
     } else {
         $this->form = new UsuarioForm();
         $this->processForm($request, $this->form);
     }
     $this->setTemplate('new');
 }
示例#20
0
 public function executeTestmail(sfWebRequest $request)
 {
     $form = new TestmailForm();
     if ($request->isMethod('post')) {
         $form->bind($request->getPostParameter($form->getName()));
         if ($form->isValid()) {
             UtilMail::send(null, $form->getValue('from'), $form->getValue('to'), $form->getValue('subject'), $form->getValue('body'));
             return $this->ajax()->form($form)->alert('Mail sent.', '', '#testmail', 'after')->render();
         }
         return $this->ajax()->form($form)->render();
     }
     $this->form = $form;
 }
示例#21
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->user = $this->getRoute()->getObject();
     $this->form = new sfGuardUserAdminForm($this->user);
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->getUser()->setFlash("notification_ok", $this->__("User edited successfully"));
             $this->redirect("users/index");
         }
     }
 }
示例#22
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->form = new AdvertisingForm();
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->getUser()->setFlash("notification_ok", $this->__("Advert added successfully"));
             $this->redirect("advertising/index");
         } else {
             $this->getUser()->setFlash("notification_error", $this->__("Error, invalid form"));
         }
     }
 }
 /**
  * Auth form & redirect to OpenID provider
  */
 public function executeLogin(sfWebRequest $request)
 {
     if ($this->getUser()->isAuthenticated()) {
         $this->redirect(sfConfig::get('app_open_auth_redirect_signin'));
     }
     if ($request->isMethod('post') && $request->hasParameter('openid_identifier')) {
         $identity = $request->getPostParameter('openid_identifier');
         // TODO: use form instead
         $validator = new sfValidatorUrl(array('protocols' => array('http', 'https')));
         try {
             $identity = $validator->clean($request->getPostParameter('openid_identifier'));
         } catch (sfValidatorError $e) {
             $this->error = 'Некорректно указан идентификатор.';
             $this->getResponse()->setStatusCode(400);
             return sfView::SUCCESS;
         }
         $response = new sfOpenAuthZendResponse();
         $consumer = $this->_makeConsumer();
         $sreg = $this->_makeSreg();
         $urlVerify = $this->getController()->genUrl('open_auth_verify', true);
         $urlTrust = $this->getController()->genUrl('homepage', true);
         if (!$consumer->login($identity, $urlVerify, $urlTrust, $sreg, $response)) {
             // $consumer->getError();
             $this->error = 'Ошибка! Возможно указанный аккаунт не существует.';
             $this->getResponse()->setStatusCode(400);
             return sfView::SUCCESS;
         }
         // Get "Location" header from Zend
         foreach ($response->getHeaders() as $item) {
             $this->getResponse()->setHttpHeader($item['name'], $item['value'], $item['replace']);
         }
         // Show auth form
     } else {
         $this->getResponse()->setStatusCode(401);
     }
 }
示例#24
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $this->materiel = MaterielTable::getInstance()->find($request->getPostParameter('emprunt[materiel_id]'));
     if (!$this->getUser()->isAuthenticated() || !$this->getUser()->getGuardUser()->hasAccess($this->materiel->getAsso()->getLogin(), 0x40)) {
         $this->getUser()->setFlash('error', 'Vous n\'avez pas le droit d\'effectuer cette action.');
         $this->redirect('asso/show?login='******'post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             if ($emprunt->emprunter($this->form)) {
                 $this->getUser()->setFlash('success', 'Vous avez emprunté ' . $request->getPostParameter('emprunt[materiel_id]') . 'x ' . $emprunt->getMateriel()->getNom() . '.');
             } else {
                 $this->getUser()->setFlash('error', 'Impossible d\'emprunter ' . $request->getPostParameter('emprunt[materiel_id]') . 'x ' . $emprunt->getMateriel()->getNom() . ', pas assez de stock.');
             }
             $this->redirect('materiel', $this->materiel->getAsso());
         }
     }
     $this->setTemplate('new');
 }
示例#25
0
 /**
  * Add a new shout
  */
 public function executeAdd(sfWebRequest $r)
 {
     // We're excepting a POST request. If GET => 404
     if (!$r->isMethod('post')) {
         $this->forward404();
     }
     // Trim the string
     $txt = trim($r->getPostParameter("sht_txt"));
     // If it's long enough, save it !
     if (strlen($txt) >= 3) {
         $s = Doctrine::getTable("Shoutbox")->setShout($txt);
         return $this->renderText("ok");
     } else {
         return $this->renderText("error");
     }
 }
示例#26
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $sf_guard_user = $form->save();
         if ($form->isNew()) {
             $data = $request->getPostParameter('sf_guard_user');
             $mensaje = Swift_Message::newInstance()->setFrom(sfConfig::get('app_email_sifactadmin'))->setTo($sf_guard_user->getProfile()->getEmail())->setSubject('Datos de registro Sifact')->setBody($this->getPartial('registerConfirmTemplate', array('profile' => $data)), 'text/html');
             $this->getMailer()->send($mensaje);
             $this->redirect('register/register');
         } else {
             $this->getUser()->setFlash('editSuccess', 'Se ha actualizado su perfil con éxito');
             $this->redirect('register/edit');
         }
     }
 }
示例#27
0
 public function executeSave(sfWebRequest $request)
 {
     $settings = Doctrine_Core::getTable('Settings')->findOneByUserId($this->getUser()->getGuardUser()->getId());
     $data = $request->getPostParameter('data');
     $util = new Util();
     $settings->language = $data['language'];
     $settings->theme = $data['theme'];
     $settings->tvshows = $data['tvshows'];
     $settings->anime = $data['anime'];
     $settings->photos = $data['photos'];
     $settings->root_path = $data['root_path'];
     $settings->web_path = $data['root_path'] . '\\web';
     $settings->covers = $data['covers'];
     $settings->music_root = $data['music_root'];
     $settings->music_root_rel = $data['music_root_rel'];
     $settings->music_thumb_abs_index = $settings['web_path'] . '\\images\\thumbnails\\music\\index';
     $settings->music_thumb_abs_show = $settings['web_path'] . '\\images\\thumbnails\\music\\show';
     $settings->music_thumb_rel_index = '\\images\\thumbnails\\music\\index';
     $settings->music_thumb_rel_show = '\\images\\thumbnails\\music\\show';
     $settings->movies_root = $data['movies_root'];
     $settings->movies_root_rel = $data['movies_root_rel'];
     $settings->movies_thumb_abs_index = $settings['web_path'] . '\\images\\thumbnails\\movies\\index';
     $settings->movies_thumb_abs_show = $settings['web_path'] . '\\images\\thumbnails\\movies\\show';
     $settings->movies_thumb_rel_index = '\\images\\thumbnails\\movies\\index';
     $settings->movies_thumb_rel_show = '\\images\\thumbnails\\movies\\show';
     $settings->tvshows_root = $data['tvshows_root'];
     $settings->tvshows_root_rel = $data['tvshows_root_rel'];
     $settings->tvshows_thumb_abs_index = $settings['web_path'] . '\\images\\thumbnails\\tvshows\\index';
     $settings->tvshows_thumb_abs_show = $settings['web_path'] . '\\images\\thumbnails\\tvshows\\show';
     $settings->tvshows_thumb_rel_index = '\\images\\thumbnails\\tvshows\\index';
     $settings->tvshows_thumb_rel_show = '\\images\\thumbnails\\tvshows\\show';
     $settings->animes_root = $data['animes_root'];
     $settings->animes_root_rel = $data['animes_root_rel'];
     $settings->animes_thumb_abs_index = $settings['web_path'] . '\\images\\thumbnails\\animes\\index';
     $settings->animes_thumb_abs_show = $settings['web_path'] . '\\images\\thumbnails\\animes\\show';
     $settings->animes_thumb_rel_index = '\\images\\thumbnails\\animes\\index';
     $settings->animes_thumb_rel_show = '\\images\\thumbnails\\animes\\show';
     $settings->photoalbums_root = $data['photoalbums_root'];
     $settings->photoalbums_root_rel = $data['photoalbums_root_rel'];
     $settings->photoalbums_thumb_abs_index = $settings['web_path'] . '\\images\\thumbnails\\photoalbums\\index';
     $settings->photoalbums_thumb_abs_show = $settings['web_path'] . '\\images\\thumbnails\\photoalbums\\show';
     $settings->photoalbums_thumb_rel_index = '\\images\\thumbnails\\photoalbums\\index';
     $settings->photoalbums_thumb_rel_show = '\\images\\thumbnails\\photoalbums\\show';
     $settings->save();
     exit;
 }
示例#28
0
 public function executeSenha(sfWebRequest $request)
 {
     $this->form = new PasswordForm(array('id' => $this->getUser()->getAttribute('id', null, 'usuario')));
     if ($request->isMethod(sfRequest::POST)) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $values = $request->getPostParameter($this->form->getName());
             $usuario = Doctrine::getTable('Usuario')->find($values['id']);
             $usuario->senha = $values['nova_senha'];
             $usuario->save();
             $this->getUser()->setFlash('success', 'Senha alterada com sucesso!');
             $this->redirect('profile/senha');
         } else {
             $this->getUser()->setFlash('error', 'O formulário contém erros!', false);
         }
     }
 }
示例#29
0
 public function executeAddListener(sfWebRequest $request)
 {
     $guid = $request->getParameter('guid');
     /** @var $rulerz Rulerz */
     $rulerz = RulerzTable::getInstance()->find($guid);
     if ($rulerz && $request->isMethod(sfWebRequest::POST)) {
         $eventName = $request->getPostParameter('select_event');
         $query = Doctrine_Query::create();
         $rules = $query->from('Rulerz r')->leftJoin('r.Listeners l')->where('r.guid = ?', array($guid))->andWhere('l.event = ?', array($eventName))->execute();
         if (count($rules) == 0) {
             $listener = new RulerzListener();
             $listener->setRulerz($rulerz);
             $listener->setEvent($eventName);
             $listener->save();
             //$this->getUser()->setFlash('success', 'Lu');
         }
     }
     $this->redirect($this->generateUrl('rulerz_show', array('guid' => $rulerz->getGuid())));
 }
示例#30
0
 public function executeAction(sfWebRequest $request)
 {
     if ($request->getPostParameter('csrf_token') !== UtilCSRF::gen('tickets')) {
         return $this->ajax()->alert('CSRF Attack detected, please relogin.', 'Error', '#todo', 'append')->render();
     }
     $ids = $request->getPostParameter('ids');
     $method = $request->getPostParameter('method');
     if (!in_array($method, array('approve', 'decline'))) {
         return $this->ajax()->alert('Something is wrong.', 'Error', '#todo')->render();
     }
     if (is_array($ids)) {
         $tickets = TicketTable::getInstance()->queryIds($ids)->execute();
         foreach ($tickets as $ticket) {
             /* @var $ticket Ticket */
             if (in_array($ticket->getStatus(), array(TicketTable::STATUS_APPROVED, TicketTable::STATUS_DENIED))) {
                 continue;
             }
             if (!$this->hasTicketRight($ticket)) {
                 return $this->ajax()->alert('You have no rights to handle this ticket.', 'Error', '#todo', 'append')->render();
             }
             if ($method === 'approve') {
                 $ticket->setStatus(TicketTable::STATUS_APPROVED);
                 $handler = $ticket->getKindHandler();
                 if (method_exists($this, $handler)) {
                     $this->{$handler}($ticket);
                 } else {
                     return $this->ajax()->alert('No handler for ticket.', 'Error', '#todo')->render();
                 }
             } else {
                 $ticket->setStatus(TicketTable::STATUS_DENIED);
             }
             $ticket->save();
         }
     }
     $vars = array();
     $campaign_id = $request->getPostParameter('campaign_id');
     if (is_numeric($campaign_id)) {
         $vars['campaign_id'] = $campaign_id;
     }
     $petition_id = $request->getPostParameter('petition_id');
     if (is_numeric($petition_id)) {
         $vars['petition_id'] = $petition_id;
     }
     if ($request->getPostParameter('view') == 'close') {
         $this->ajax()->modal('#ticket_view_modal', 'hide')->remove('#ticket_view_modal');
     }
     return $this->ajax()->replaceWithComponent('#todo', 'ticket', 'todo', $vars)->render();
 }