Exemple #1
0
 public function executePush_endpoint(sfWebRequest $request)
 {
     if ($request->getMethod() == sfWebRequest::GET && $request->getParameter("hub_mode") == 'subscribe' && $request->getParameter("hub_challenge", null)) {
         sfContext::getInstance()->getLogger()->info("{TestPushApi} subscribed to '" . $request->getParameter("hub_topic") . "'");
         $this->setLayout(false);
         return $this->renderText($request->getParameter("hub_challenge"));
     } elseif ($request->getMethod() == sfWebRequest::POST) {
         $updates = json_decode(file_get_contents("php://input"), true);
         sfContext::getInstance()->getLogger()->info("{TestPushApi} subscribed to '{$updates}'");
     } else {
         sfContext::getInstance()->getLogger()->err("{TestPushApi} " . print_r(file_get_contents("php://input"), true));
         $this->setLayout(false);
         return $this->renderText("geht net!");
     }
 }
Exemple #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");
 }
 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;
 }
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request)
    {
        $this->form = new ContactForm();
        $this->getUser()->setFlash('success', false);
        $this->getUser()->setFlash('error', false);
        if ($request->getMethod() == 'POST') {
            $this->form->bind($request->getParameter('contact'));
            if ($this->form->isValid()) {
                $contact = $request->getParameter('contact');
                //recupera o e-mail de contato
                $profile = Doctrine_Core::getTable('Profile')->findOneBy('id', 1);
                $message = $this->getMailer()->compose($contact['email'], array($profile->email), 'Contato Tiago Trespach', <<<EOF
Nome:{$contact['nome']}
E-mail:{$contact['email']}
Telefone:{$contact['telefone']}
Mensagem:{$contact['mensagem']}
EOF
);
                $this->getMailer()->send($message);
                $this->getUser()->setFlash('success', 'Mensagem enviada! Em breve responderei.');
                $this->form = new ContactForm();
            } else {
                $this->getUser()->setFlash('error', 'Oooops, alguns campos não estão preenchidos.');
            }
        }
    }
 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');
 }
Exemple #7
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->getResponse()->setSlot('js_document_ready', $this->getPartial('deal/js_init_deal.js'));
     $url = $request->getParameter("url", null);
     // handle form submit
     if ($request->getMethod() == "POST") {
         $params = $request->getParameter('like');
         $params['u_id'] = $this->getUser()->getUserId();
         if ($url) {
             $params['i_url'] = $url;
         }
         $activity = new Documents\YiidActivity();
         $activity->fromArray($params);
         // try to save activity
         try {
             $activity->save();
             $this->redirect("@coupon?id=" . $activity->getId() . "&u_code=" . $activity->getCCode());
         } catch (Exception $e) {
             // send error on exception
             $this->getLogger()->err($e->getMessage());
             $this->redirect('@default_deal');
             return sfView::SUCCESS;
         }
     }
     $deal = DealTable::getInstance()->getNextFromPool($this->getUser()->getUser(), $url);
     $this->deal = $deal;
     if (!$deal) {
         $this->hash = md5($this->getUser()->getId() . $url);
         $this->setTemplate('default_deal');
     }
 }
Exemple #8
0
 /**
  * action Control
  *
  * @author Damian Suarez
  */
 public function executeControl(sfWebRequest $request)
 {
     $this->revision = Doctrine::getTable('Revision')->find($request->getParameter('id'));
     $this->rev_items = $this->revision->getRevisionItem();
     if ($request->getMethod() == 'POST') {
         $params = $request->getParameter('items');
         if (!empty($params)) {
             foreach ($params as $key => $value) {
                 $rev_item = RevisionItemTable::retrieveByRevisionAndItem($this->revision->get('id'), $key);
                 if ($value != $rev_item->getState()) {
                     $rev_item->setState($value);
                     $rev_item->save();
                 }
             }
             $this->revision->setBlock(false);
             $this->revision->save();
         }
     }
     $this->rev_itemsGroup = array();
     foreach ($this->rev_items as $rev_item) {
         if (!array_key_exists($rev_item->getItem()->getGroup()->getId(), $this->rev_itemsGroup)) {
             $this->rev_itemsGroup[$rev_item->getItem()->getGroup()->getId()] = array();
         }
         array_push($this->rev_itemsGroup[$rev_item->getItem()->getGroup()->getId()], $rev_item);
     }
 }
Exemple #9
0
 public function executeOffres(sfWebRequest $request)
 {
     $this->filters = new InfoJobOffreFormFilter();
     if ($request->getMethod() == sfRequest::POST) {
         $this->filters->bind($request->getParameter($this->filters->getName()));
         if ($this->filters->isValid()) {
             $query = $this->filters->buildQuery($this->filters->getValues());
         }
         $query = InfoJobOffreTable::getInstance()->addStandardFilters($query)->orderBy('created_at DESC');
     } else {
         $query = InfoJobOffreTable::getInstance()->getLastOffreList();
     }
     $this->pager = new sfDoctrinePager('InfoJobOffre', sfConfig::get('app_portail_offres_par_page'));
     $this->pager->setQuery($query);
     $this->pager->setPage($request->getParameter('page', 1));
     $this->pager->init();
     $this->annonces = $this->pager->getResults();
     $this->isGet = $request->getMethod() == sfRequest::GET;
 }
 /**
  * @param sfWebRequest $request
  * @return application/json data
  */
 public function execute($request)
 {
     if ($request->getMethod() == \sfWebRequest::GET) {
         $datas = array('commit' => $request->getParameter('commit'), 'file_id' => $request->getParameter('fileId'), 'position' => $request->getParameter('position'), 'line' => $request->getParameter('line'), 'user_id' => $this->getUser()->getId());
     } else {
         if ($request->getMethod() == \sfWebRequest::POST) {
             // get the propel connection
             $con = Propel::getConnection();
             $con->beginTransaction();
             try {
                 // get the comment arguments parameter
                 $datas = $request->getParameter('comment');
                 $this->forward404Unless($datas, "Comment arguments not found");
                 $commit = $datas['commit'];
                 $this->forward404Unless($commit, 'Commit Hash Not Found');
                 $fileId = $datas['file_id'];
                 $this->forward404Unless($fileId, 'File Id Not Found');
                 $file = FileQuery::create()->filterById($fileId)->findOne();
                 $this->forward404Unless($file, 'File Not Found');
                 $position = $datas['position'];
                 $this->forward404Unless($position, 'Position Line Number Not Found');
                 $line = $datas['line'];
                 $this->forward404Unless($line, 'Line Number Not Found');
                 $value = $datas['value'];
                 $this->forward404Unless($value, 'Comment Value Not Found');
                 // new comment object
                 $lineComment = new Comment();
                 $lineComment->setUserId($this->getUser()->getId())->setCommit($commit)->setBranchId($file->getBranchId())->setFileId($fileId)->setPosition($position)->setLine($line)->setType(CommentPeer::TYPE_LINE)->setValue($value)->save($con);
                 $lineComment->getBranch()->setReviewRequest(false)->save();
                 $datas = array_merge($datas, array('form_visible' => false));
                 $con->commit();
                 $this->dispatcher->notify(new sfEvent($this, 'notification.comment', array('project-id' => $lineComment->getBranch()->getRepositoryId(), 'type' => 'line', 'object' => $lineComment)));
             } catch (Exception $e) {
                 $con->rollBack();
                 throw $e;
             }
         }
     }
     // returns a json object
     $this->getResponse()->setContentType('application/json');
     return $this->renderText(json_encode(array('html' => $this->getComponent('default', 'commentLine', $datas))));
 }
 public function executeQuickinput(sfWebRequest $request)
 {
     //this will only handle inputstring and parsing.
     //All other functions will be delegated.
     //---initialize vars-------------------------------------------------------------------------------
     $this->linestrings = array();
     $this->cellstrings = array();
     $this->inputstring = "";
     $this->errors = array();
     $this->messages = array();
     $this->pricelistdata = new PricelistDataGroup($this);
     $this->producttypedata = new ProducttypeDataGroup($this);
     $this->productdata = new ProductDataGroup($this);
     $this->quotedata = new QuoteDataGroup($this);
     $this->productsfromproducttypedata = new ProductsFromProducttypeDataGroup($this);
     //---------case 1: if id given, method=get: load data object: [ok] ---------
     //just display it
     if ($request->getParameter("id") and $request->getMethod() == "GET") {
         $this->pricelistdata->processById($request->getParameter("id"));
     } else {
         if ($request->getMethod() == "GET") {
             $this->pricelistdata->processEmpty();
         } else {
             $this->inputstring = $request->getParameter("inputstring");
             $this->parse();
             $this->pricelistdata->process($this->cellstrings, $request);
             $this->producttypedata->process($this->cellstrings);
             $this->productdata->process($this->cellstrings, $this->producttypedata);
             $this->quotedata->process($this->cellstrings, $request);
             $this->productsfromproducttypedata->process($this->cellstrings, $this->producttypedata);
             if ($request->getParameter("submit") == "Save" and count($this->errors) == 0) {
                 $this->pricelistdata->save();
                 $this->producttypedata->save();
                 $this->productdata->save();
                 $this->quotedata->save();
             }
             //---update input string-----------------------------------------------------------------------
             $this->inputstring = $this->pricelistdata->getInputString() . $this->producttypedata->getInputString() . $this->productdata->getInputString();
         }
     }
 }
 public function executeIndex(sfWebRequest $request)
 {
     $this->fields = myParamsConfig::$fields;
     $this->form = new myParamsForm();
     if ($request->getMethod() === sfRequest::POST) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->getUser()->setFlash('notice', 'Your applications settings has been updated');
             $this->redirect('myConfiguration/index');
         }
     }
 }
Exemple #13
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->filters = new AnnonceFormFilter();
     if ($request->getMethod() == sfRequest::POST) {
         $this->filters->bind($request->getParameter($this->filters->getName()));
         if ($this->filters->isValid()) {
             $query = $this->filters->buildQuery($this->filters->getValues());
         }
     } else {
         $query = Doctrine_Core::getTable('Annonce')->createQuery('a')->orderBy('a.created_at DESC');
     }
     $this->annonces = $query->execute();
 }
Exemple #14
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");
         }
     }
 }
 public function executeDelete(sfWebRequest $request)
 {
     $this->form = new BudgetCategoryEditForm();
     $getParameters = 'get' . ucfirst(strtolower($request->getMethod()));
     $getParameters .= 'Parameters';
     $this->form->bind($request->{$getParameters}());
     $budgetCategory = $this->form->getObject();
     if ($budgetCategory && $budgetCategory->delete()) {
         return $this->renderJson(array('result' => array('text' => '')));
     } else {
         return $this->renderJson(array('error' => array('text' => 'Ошибка при удалении бюджета')));
     }
 }
Exemple #16
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"));
         }
     }
 }
Exemple #17
0
 /**
  * Process delete requests
  *
  * @param sfEventDispatcher $dispatcher
  * @param sfWebRequest $request
  * @param array $config
  * @return string
  */
 public function executeDelete(sfEventDispatcher $dispatcher, sfWebRequest $request, $config)
 {
     $twig = $this->getTwig($config, 'table');
     if ($request->getMethod() == sfWebRequest::POST) {
         $table_object = $this->getTableObject($config);
         $table_object->deleteTable($request->getParameter('table'));
         $template = $twig->loadTemplate('delete-success.tmpl');
         $content = $template->render(array('tablename' => $request->getParameter('table')));
     } else {
         $template = $twig->loadTemplate('error.tmpl');
         $content = $template->render(array('error' => 'Delete requested wasnt POSTed'));
     }
     return $content;
 }
 /**
  * Display the user profile form.
  * @param sfWebRequest $request
  */
 public function executeProfile(sfWebRequest $request)
 {
     $this->culture = $this->getUser()->getCulture();
     $this->form = new sfPlopGuardUserForm($this->getUser()->getGuardUser(), array('user_culture' => $this->getUser()->getProfile()->getCulture(), 'culture' => $this->culture));
     if ($request->getMethod() == sfRequest::POST) {
         $values = $request->getParameter('sf_guard_user');
         $this->form->bind($values);
         if ($this->form->isValid()) {
             $sf_guard_user = $this->form->save();
             $this->getUser()->setCulture($sf_guard_user->getProfile()->getCulture());
             $this->redirect('@sf_plop_profile');
         }
     }
     $this->block_unregister = $this->getUser()->isSuperAdmin() && sfPlopGuard::isLastSuperAdminUser();
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $celula = $form->save();
         $lider_id = $celula->getDiscipuloLiderId();
         if ($lider_id == $this->getUser()->getUserId() && $request->getMethod() != 'PUT') {
             $miembroCelula = new MiembroCelula();
             $miembroCelula->asignarLiderAsMiembro($celula->getId(), $this->getUser()->getUserId());
         }
         $this->redirect('celulas/index');
     }
     $this->mi_id = $this->getUser()->getUserId();
     $this->mi_nombre = $this->getUser()->getName();
 }
Exemple #20
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");
         }
     }
 }
Exemple #21
0
 /**
  *
  * @param sfWebRequest $request 
  * @return WSRequestParameters
  */
 public function extractParameters(sfWebRequest $request)
 {
     $webRequestParameters = new WSRequestParameters();
     $logger = Logger::getLogger('core.webservices');
     $requestMethod = $request->getMethod();
     $contentType = $request->getContentType();
     $logger->debug("HTTP Method: {$requestMethod}, Content-Type: {$contentType}");
     $requestParameters = $request->getRequestParameters();
     $logger->debug("Request Parameters: " . print_r($requestParameters, true));
     if (!isset($requestParameters['ws_method'])) {
         throw new WebServiceException('Web service method is not specified', 400);
     }
     $webServiceMethod = $requestParameters['ws_method'];
     $methodParameters = array();
     // Checking for deprecated method of sending parameters using an http header
     $header = $request->getHttpHeader('ohrm_ws_method_parameters');
     if (!empty($header)) {
         $methodParameters = json_decode($header, true);
         if (!is_array($methodParameters)) {
             throw new WebServiceException("header ohrm_ws_method_parameters should be json encoded", 400);
         }
     } else {
         // get request parameters in URL (eg: /empNumber/11) after removing the default parameters
         $methodParameters = array_diff_key($requestParameters, array_flip(array('action', 'module', 'ws_method', '_sf_route')));
         // Merge with GET parameters
         $methodParameters = array_merge($methodParameters, $request->getGetParameters());
         // Check for JSON encoded body
         if ($contentType === 'application/json') {
             $postParams = json_decode(file_get_contents('php://input'), true);
             $methodParameters = array_merge($methodParameters, $postParams);
         } else {
             if ($requestMethod === 'POST') {
                 $methodParameters = array_merge($methodParameters, $request->getPostParameters());
             }
         }
     }
     //        $arrayName = $this->getArrayNameForFunction($function);
     //        if(!array_key_exists($arrayName, $methodParameters)) {
     //            throw new WebServiceException('Required array name not provided', 404);
     //        }
     $webRequestParameters->setRequestMethod($requestMethod);
     $webRequestParameters->setMethod($webServiceMethod);
     $webRequestParameters->setParameters($methodParameters);
     //        $webRequestParameters->setAppId($authenticationParamerters['app_id']);
     //        $webRequestParameters->setAppToken($authenticationParamerters['app_token']);
     //        $webRequestParameters->setSessionToken($authenticationParamerters['session_token']);
     return $webRequestParameters;
 }
Exemple #22
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $lUrl = $request->getParameter("url", null);
     $lUrl = UrlUtils::narmalizeUrlScheme($lUrl);
     $request->setParameter("url", $lUrl);
     $this->url = $lUrl;
     $this->error = $this->pError = null;
     if (!$lUrl) {
         return $this->setTemplate("share");
     }
     if ($request->getMethod() == "POST") {
         $lParams = $request->getParameter('like');
         $lParams['u_id'] = $this->getUser()->getUserId();
         $lActivity = new Documents\YiidActivity();
         $lActivity->fromArray($lParams);
         // try to save activity
         try {
             $lActivity->save();
             $this->redirect("@deal?url=" . urlencode($lUrl));
         } catch (Exception $e) {
             // send error on exception
             $this->getLogger()->err($e->getMessage());
             $this->pError = $e->getMessage();
         }
     }
     $dm = MongoManager::getDM();
     $this->pActivity = $dm->getRepository("Documents\\YiidActivity")->findOneBy(array("url" => $lUrl, "u_id" => intval($this->getUser()->getId()), "d_id" => array('$exists' => false)));
     // if user has already liked
     if ($this->pActivity) {
         $this->redirect("@deal?url=" . urlencode($lUrl));
     }
     $lYiidMeta = new YiidMeta();
     $lYiidMeta->fromParams($request->getParameterHolder());
     $this->pYiidMeta = SocialObjectParser::fetch($request->getParameter("url"), $lYiidMeta);
     if ($this->pYiidMeta === false) {
         $this->error = "the url '{$lUrl}' is not well formed!";
         return $this->setTemplate("share");
     }
     $domainProfile = DomainProfileTable::getInstance()->retrieveByUrl($lUrl);
     $this->trackingUrl = null;
     if ($domainProfile) {
         $this->trackingUrl = $domainProfile->getTrackingUrl();
     }
     $this->getResponse()->setSlot('js_document_ready', $this->getPartial('like/js_init_like.js', array('pImgCount' => count($this->pYiidMeta->getImages()), 'pUrl' => $request->getParameter("url"))));
 }
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new sfHtml5FormDemoForm();
     $this->formMock = new sfHtml5FormDemoMockForm();
     if ($request->getMethod() == 'POST') {
         if ($request->hasParameter($this->form->getName())) {
             $this->params = $request->getParameter($this->form->getName());
             $this->form->bind($request->getParameter($this->form->getName()));
             if ($this->form->isValid()) {
                 $this->getUser()->setFlash('ok', 'Form is valid.');
             } else {
                 $this->getUser()->setFlash('error', 'Form is invalid.');
             }
         }
         if ($request->hasParameter($this->formMock->getName())) {
             var_dump($request->getParameter($this->formMock->getName()));
         }
     }
 }
 public function executeUpdate(sfWebRequest $request)
 {
     $this->setABlogPostForUser();
     $this->form = new aBlogPostForm($this->a_blog_post);
     if ($request->getMethod() === 'POST') {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->a_blog_post = $this->form->save();
             // We do this here to avoid some nasty race conditions that crop up when
             // we try to push things to the page inside the Doctrine form transaction
             $this->a_blog_post->updatePageTagsAndCategories();
             // Recreate the form to get rid of bound values for the publication field,
             // so we can see the new setting
             $this->form = new aBlogPostForm($this->a_blog_post);
         }
     }
     if (!$request->isXmlHttpRequest()) {
         $this->setTemplate('edit');
     }
 }
Exemple #25
0
 public function executePromo(sfWebRequest $request)
 {
     $this->form = new sfGuardPromoRegisterForm();
     if ($request->getMethod() === sfRequest::POST) {
         if ($this->getUser()->isAuthenticated()) {
             $this->getUser()->setFlash('notice', 'You are already registered and signed in!');
             $this->redirect('/project');
         }
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $user = $this->form->save();
             $message = $this->getMailer()->compose(array(sfConfig::get('app_info_email') => sfConfig::get('app_sf_guard_plugin_default_from_email')), $user->email_address, '[Sensorsix] Confirm your email address');
             $message->setBody($this->getPartial('confirmation_email', array('user' => $user)));
             $message->setContentType('text/html');
             $this->getMailer()->send($message);
             $this->getUser()->setFlash('notice', 'Check your e-mail! You should verify your email address.');
             $this->redirect('@sf_guard_signin');
         }
     }
 }
Exemple #26
0
 public function executeGlobal(sfWebRequest $request)
 {
     $this->filter = new MatchsFormFilter($this->getFilters());
     $query = $this->filter->buildQuery($this->getFilters());
     $this->filterValues = $this->getFilters();
     $matchs = $this->getUser()->getAttribute("global.stats.matchs", array());
     if (count($matchs) > 0) {
         $this->matchs = $query->andWhere("id IN ?", array($matchs))->execute();
     } else {
         $this->matchs = $query->execute();
     }
     if ($request->getMethod() == sfWebRequest::POST) {
         if (is_array($request->getPostParameter("ids"))) {
             $matchTab = array();
             foreach ($request->getPostParameter("ids") as $id) {
                 if (!is_numeric($id)) {
                     continue;
                 }
                 if (in_array($id, $matchTab)) {
                     continue;
                 }
                 if (!MatchsTable::getInstance()->find($id)) {
                     continue;
                 }
                 $matchTab[] = $id;
             }
             if (count($matchTab) == 0) {
                 $this->getUser()->setFlash("notification.error", "No entry found.");
                 $this->getUser()->setAttribute("global.stats.matchs", null);
             } else {
                 $this->getUser()->setFlash("notification.ok", "Filter applied.");
                 $this->getUser()->setAttribute("global.stats.matchs", $matchTab);
             }
         } else {
             $this->getUser()->setFlash("notification.ok", "The filter was resetted.");
             $this->getUser()->setAttribute("global.stats.matchs", null);
         }
         $this->redirect("global_stats");
     }
 }
Exemple #27
0
 public function executeApply_api(sfWebRequest $request)
 {
     $this->pUser = $this->getUser()->getGuardUser();
     $this->pPaymentMethods = $this->getUser()->getGuardUser()->getPaymentMethods();
     $this->pPaymentMethodForm = new PaymentMethodForm();
     if ($request->getMethod() == 'POST') {
         $lParams = $request->getPostParameters();
         $lIsNew = true;
         $lParams['sf_guard_user_id'] = $this->getUser()->getUserId();
         //check if the user selected an old address or if he inserted a new
         //if he selected an old, overwrite the form-values with the database-data -> needet for validation
         if (isset($lParams['existing_pm_id']) && $lParams['existing_pm_id'] != 'false') {
             //find the selected pm object
             $lSelectedPM = PaymentMethodTable::getInstance()->find($lParams['existing_pm_id']);
             //fill the values for validation
             $lParams['company'] = $lSelectedPM->getCompany();
             $lParams['contact_name'] = $lSelectedPM->getContactName();
             $lParams['address'] = $lSelectedPM->getAddress();
             $lParams['zip'] = $lSelectedPM->getZip();
             $lParams['city'] = $lSelectedPM->getCity();
             //$lParams['payment_method_id'] = $lParams['existing_pm_id'];
             //bind the object to the form -> needed for update (if you don't do this, symfony always inserts a new db entry)
             $this->pPaymentMethodForm = new PaymentMethodForm($lSelectedPM);
         }
         $lParams['api_method'] = true;
         //unset the param, that check, if user selected an existent payment method
         unset($lParams['existing_pm_id']);
         $this->pPaymentMethodForm->bind($lParams);
         if ($this->pPaymentMethodForm->isValid()) {
             $lPm = $this->pPaymentMethodForm->save();
             $lText = "Der User " . $this->pUser->getFirstName() . " " . $this->pUser->getLastName() . " (" . $this->pUser->getUsername() . ") ";
             $lText .= "mit der Email-Adresse " . $this->pUser->getEmailAddress() . " hat einen API Key beantragt. Um ihn zu bearbeiten bitte folgenden Link klicken: \n\n";
             $lText .= sfConfig::get("app_settings_url") . "/backend.php/guard/users/" . $this->pUser->getId() . "/edit";
             //backend/guard/users/2/edit
             //app_settings_support_email
             sfContext::getInstance()->getMailer()->composeAndSend(array(sfConfig::get("app_email_address") => sfConfig::get("app_email_sender")), sfConfig::get("app_settings_support_email"), 'Neue Api Anfrage', $lText);
             $this->redirect('advertiser/apply_api_thanks');
         }
     }
 }
Exemple #28
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"));
         }
     }
 }
Exemple #29
0
 public function executeCreate_wildcard(sfWebRequest $request)
 {
     if ($request->getParameter('create') == 1) {
         $this->lWildcardName = $request->getParameter('wildcard_name');
         $this->lCreateAfterEmptySearch = true;
     } else {
         $this->lWildcardName = '';
         $this->lCreateAfterEmptySearch = false;
     }
     if ($request->getMethod() == 'POST') {
         $lWildcardSource = $request->getParameter('wildcard_name');
         $lToTranslateParams = $request->getParameter('to_translate');
         if ($lWildcardSource == '') {
             $this->getUser()->setFlash('error', 'Please insert a wildcard name!');
             $this->redirect('trans_unit/create_wildcard');
         }
         // create wildcard
         TransUnitTable::createWildcard($lWildcardSource, 'messages');
         // create translations
         $lTransUnitData = $request->getParameter('wildcard');
         foreach (LanguageTable::getAllLanguages(false) as $lCulture) {
             $lTransUnit = TransUnitTable::retrieveWildcardObject($lCulture, 'messages', $lWildcardSource);
             $lTransUnit->setTarget($lTransUnitData["{$lCulture}"]['target']);
             //$lTransUnit->setComments($lTransUnitData['comment']);
             $lTransUnit->setAuthor('hugo');
             //$this->getUser()->getUser()->getFullname());
             if (isset($lToTranslateParams["{$lCulture}"]) && $lToTranslateParams["{$lCulture}"] == 'on' || $lTransUnitData["{$lCulture}"]['target'] == '') {
                 $lTransUnit->setTranslated(false);
             } else {
                 $lTransUnit->setTranslated(true);
             }
             $lTransUnit->save();
         }
         $this->getUser()->setFlash('wildcard_edited', $lTransUnit->getId());
         //die();
         $this->redirect('trans_unit/new');
     }
 }
Exemple #30
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeList(sfWebRequest $request)
 {
     $this->form = new GuestbookForm();
     $page = $request->getParameter('page') != '' ? $request->getParameter('page') : 1;
     $messages = Doctrine_Core::getTable('Guestbook')->listMessagesByDate();
     $this->pager = new sfDoctrinePager('Guestbook', 10);
     $this->pager->setQuery($messages);
     $this->pager->setPage($page);
     $this->pager->init();
     $this->messages = $this->pager->getResults();
     $this->getUser()->setFlash('success', false);
     $this->getUser()->setFlash('error', false);
     if ($request->getMethod() == 'POST') {
         $requestData = $request->getParameter($this->form->getName());
         $this->form->bind($requestData);
         if ($this->form->isValid()) {
             $this->form->save();
             $this->getUser()->setFlash('success', 'Mensagem enviada com sucesso! Aguarde aprovação!');
         } else {
             $this->getUser()->setFlash('error', 'Oooops, alguns campos não estão preenchidos corretamente');
         }
     }
 }