コード例 #1
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->transaction_type = $request->getParameter("transaction_type");
     $this->transaction_id = $request->getParameter("transaction_id");
     $keywords = explode(" ", $request->getParameter("searchstring"));
     //search in name
     $query = Doctrine_Query::create()->from('Product p')->orderBy("p.name")->where('p.id != 0');
     foreach ($keywords as $keyword) {
         $query->andWhere("p.name LIKE '%" . $keyword . "%'");
     }
     //search in description
     $query->orWhere('p.id != 0');
     foreach ($keywords as $keyword) {
         $query->andWhere("p.description LIKE '%" . $keyword . "%'");
     }
     $this->products = $query->execute();
     $productids = array();
     foreach ($this->products as $product) {
         $productids[] = $product->getId();
     }
     $stocks = Doctrine_Query::create()->from('Stock s')->whereIn('s.product_id', $productids)->andWhere('s.warehouse_id = ' . SettingsTable::fetch('default_warehouse_id'))->execute();
     $this->stockarray = array();
     foreach ($stocks as $stock) {
         $this->stockarray[$stock->getProductId()] = $stock;
     }
 }
 public function executeUndo_tree_ajax(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $id_tree = $request->getParameter('treeId');
     $production = $request->getParameter('production');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $tree = TreeScPeer::retrieveByPK($id_tree);
         if (is_object($tree)) {
             //si es el dueño del arbol
             if ($tree->getUserId() == $user->getId()) {
                 $tree->setFlag(1);
                 if ($production == 'production') {
                     $tree->setProduccion('production');
                 }
                 $tree->save();
                 return sfView::SUCCESS;
             } else {
                 $this->message = 'owner not found';
                 return sfView::ERROR;
             }
         } else {
             $this->message = 'objet not found';
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expird';
         return sfView::ERROR;
     }
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: noikiy/qdpm
 public function executeIndex(sfWebRequest $request)
 {
     app::setPageTitle('Gantt Chart', $this->getResponse());
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTasksAccess('view', false, $this->projects);
     } else {
         $this->checkTasksAccess('view');
     }
     if (!$this->getUser()->hasAttribute('gantt_filter' . $this->get_pid($request))) {
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), Tasks::getDefaultFilter($request, $this->getUser(), 'ganttChart'));
     }
     $this->filter_by = $this->getUser()->getAttribute('gantt_filter' . $this->get_pid($request));
     if ($fb = $request->getParameter('filter_by')) {
         $this->filter_by[key($fb)] = current($fb);
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by);
         $this->redirect('ganttChart/index' . $this->add_pid($request));
     }
     if ($request->hasParameter('remove_filter')) {
         unset($this->filter_by[$request->getParameter('remove_filter')]);
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by);
         $this->redirect('ganttChart/index' . $this->add_pid($request));
     }
     $this->tasks_tree = array();
     $this->tasks_list = $this->getTasks($request, $this->tasks_tree);
 }
コード例 #4
0
 public function executeIndex(sfWebRequest $request)
 {
     if ($request->hasParameter('object_id') && $request->hasParameter('object_class')) {
         $this->object = Doctrine::getTable($request->getParameter('object_class'))->find($request->getParameter('object_id'));
     }
     $this->setLayout(false);
 }
コード例 #5
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     // Download the image
     $url = $request->getParameter("url");
     $remote_file = $url;
     //urldecode( $url );
     //$remote_file   = "/Users/robbymillsap/Sites/eventflo.dev/web/images/myface.jpg";
     $remote_handle = fopen($remote_file, "r");
     $temp = tempnam(sfConfig::get('sf_upload_dir'), 'Img') . '.jpg';
     $temp_handle = fopen($temp, "w");
     while ($cline = fgets($remote_handle)) {
         fwrite($temp_handle, $cline);
     }
     fclose($temp_handle);
     fclose($remote_handle);
     //$url_to_tmp = realpath(dirname($temp));
     // Process the image
     /*
           $path = sfConfig::get('sf_upload_dir') . '/';
           $src  = "myface.jpg";
           $new  = "myface.jpg";
     *
     */
     // Run image magick
     $cmd = "convert {$temp} -resize " . $request->getParameter("size") . " " . $temp;
     shell_exec($cmd);
     // show image
     $this->showImage($temp);
     shell_exec("rm {$temp}");
     return sfView::NONE;
 }
コード例 #6
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 public function executePaymentSuccess(sfWebRequest $request)
 {
     $payment_type = $request->getParameter('type');
     /** @var sfGuardUser $user */
     $user = $this->getUser()->getGuardUser();
     /** @var PaymentTransaction $payment */
     $payment = $user->getLastNotPayedTransaction($payment_type);
     $gtw = new PaypalGateway(array('amount' => $payment->amount, 'success_url' => $this->generateUrl('payment\\success', array('type' => $payment_type)), 'cancel_url' => $this->generateUrl('payment\\cancel'), 'token' => $request->getParameter('token'), 'payer_id' => $request->getParameter('PayerID')));
     $res = $gtw->doExpressCheckout();
     if ($res) {
         $payment->is_payed = true;
         $payment->date_payed = date('Y-m-d H:i:s');
         $payment->status_code = 'success';
         $payment->stamp = $request->getParameter('PayerID');
         $payment->save();
         $user->account_type = $payment->type;
         $user->credit = $payment->type == 'basic' ? 12 : -1;
         $user->last_payment_date = date('Y-m-d H:i:s');
         $user->save();
         $this->getUser()->setFlash('notice', 'The payment is accepted, thank you!');
     } else {
         $this->getUser()->setFlash('error', 'PayPal connection error');
     }
     $this->redirect('/project/user/account');
 }
コード例 #7
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $requestparam = $request->getParameter('accountentry');
     $account = AccountTable::fetchById($requestparam['account_id']);
     $qty = $requestparam['qty'];
     $date = $requestparam['date']['year'] . "-" . $requestparam['date']['month'] . "-" . $requestparam['date']['day'];
     //$ref_class=$requestparam['ref_class'];
     //$ref_id=$requestparam['ref_id'];
     $type = $requestparam['type'] != "" ? $requestparam['type'] : 'Adjustment';
     //$priority=0;
     $description = $requestparam['description'];
     if ($qty == 0) {
         $this->redirect('home/error?msg="Invalid Qty"');
     }
     $accountentry = $account->addEntry($date, $qty, null, null, $type, $description);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $accountentry)));
         $this->getUser()->setFlash('notice', $notice);
         $this->redirect('account/view?id=' . $accountentry->getaccountId());
     } else {
         if ($form['qty']->getError()) {
             $this->redirect('home/error?msg="Invalid Qty: ' . $qty . '"');
         }
         if ($form['date']->getError()) {
             $this->redirect('home/error?msg="Invalid Date: ' . $date . '"');
         }
         //$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
コード例 #8
0
 /**
  * @param string $fileName 
  * @param string $directory 
  * @param sfWebRequest $request 
  * @return string
  */
 protected function generateThumbnailPath($fileName, $directory, sfWebRequest $request)
 {
     $extension = $this->getFileExtension($fileName);
     $baseName = $this->getFileBaseName($fileName);
     $fileName = sprintf('%s_%s%s%s', $baseName, (int) $request->getParameter('scale', 1), (int) $request->getParameter('inflate', 1), $extension);
     return $directory . $fileName;
 }
コード例 #9
0
ファイル: actions.class.php プロジェクト: ketheriel/ETVA
 public function executeFile(sfWebRequest $request)
 {
     $file = $request->getParameter('filename');
     $type = $request->getParameter('type');
     switch ($type) {
         case 'backup':
             $apl = new Appliance();
             $base_dir = $apl->get_archive_base_dir();
             break;
         default:
             break;
     }
     if (!$base_dir) {
         return sfView::NONE;
     }
     $path = realpath($base_dir . '/' . $file);
     // if base_dir isn't at the front 0==strpos, most likely hacking attempt
     if (strpos($path, $base_dir)) {
         die('Invalid Path');
     } elseif (file_exists($path)) {
         $this->prepareDownload($file);
         readfile($path);
     } else {
         die('Invalid Path');
     }
     return sfView::NONE;
 }
コード例 #10
0
ファイル: actions.class.php プロジェクト: niryuu/OpenPNE3
 public function executeTemplate(sfWebRequest $request)
 {
     $this->name = $request->getParameter('name', '');
     if ('' !== $this->name) {
         $this->forward404Unless(in_array($this->name, $this->generateMailTemplateNames($this->config)));
     }
     $obj = Doctrine::getTable('NotificationMail')->findOneByName($this->name);
     if (!$obj) {
         $obj = Doctrine::getTable('NotificationMail')->create(array('name' => $this->name));
     }
     $translation = $obj->Translation[sfDoctrineRecord::getDefaultCulture()];
     $this->form = new NotificationMailTranslationForm($translation);
     $this->form->updateDefaultsByConfig($this->getMailConfiguration($this->config, $this->name));
     if ($this->request->isMethod(sfWebRequest::POST)) {
         $this->form->bind($request->getParameter('notification_mail_translation'));
         if ($this->form->isValid()) {
             if (!$this->form->getObject()->exists()) {
                 if ($this->form->getObject()->id instanceof Doctrine_Record) {
                     $this->form->getObject()->id->save();
                 }
             }
             $this->form->save();
             $this->getUser()->setFlash('notice', 'Saved.');
             $this->redirect('@mail_template_specified?name=' . $this->name);
         }
         $this->getUser()->setFlash('error', (string) $this->form->getErrorSchema());
     }
 }
コード例 #11
0
ファイル: actions.class.php プロジェクト: remberto/university
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     // Recuperar el Tramite y el Proceso
     $this->setLayout('descarga');
     $template = Doctrine::getTable('ClaDocumentos')->findOneByClaTramiteIdAndClaProcesoId($request->getParameter('tramite'), $request->getParameter('proceso'));
     $seguimiento = Doctrine::getTable('ProcSeguimiento')->getTramite($request->getParameter('seguimiento'));
     $PHPWord = new PHPWord();
     $filename = 'carta_' . $request->getParameter('tramite') . '_' . $request->getParameter('proceso') . '.docx';
     $document = $PHPWord->loadTemplate(sfConfig::get('sf_root_dir') . '/archivos/templates/' . $template->getPath());
     date_default_timezone_set('America/La_Paz');
     setlocale(LC_TIME, 'spanish');
     $document->setValue('fecha_carta', strftime("%d de %B de %Y"));
     foreach ($seguimiento->ProcFormularios as $formulario) {
         $tabla = Doctrine::getTable($formulario->ClaTabla->getDescripcion())->findOneById($formulario->getGetId());
         if ($formulario->ClaTabla->getDescripcion() == 'DatPersonas') {
             $document->setValue('nombre_estudiante', $tabla->getNombreCompleto());
         }
     }
     $document->save(sfConfig::get('sf_root_dir') . '/archivos/generados/' . $filename);
     //        $guardar = new ClaDocumentos();
     //        $guardar->setClaTramiteId(1);
     //        $guardar->setClaProcesoId(1);
     //        $guardar->setPath($filename);
     //        $guardar->save();
     $this->filename = $filename;
     $this->enlace = sfConfig::get('sf_root_dir') . '/archivos/generados//' . $filename;
 }
コード例 #12
0
 public function executeIndex(sfWebRequest $request)
 {
   // get the name of the form object we are building the validation for
   $form = $request->getParameter('form');
   
   // make sure that the form class specified actually exists
   // and it is really a symfony form
   $this->forward404Unless($this->isValidSfFormName($form));
   
   // errors have to be disabled because any kind of warning message will break
   // the outputted javascript
   // error_reporting('E_NONE'); // Very bad practice
   
   // create an instance of the sfJqueryFormValidationRules object
   $this->sf_jq_rules = new sfJqueryFormValidationRules(new $form);
   
   // add embedded forms
   $embedded_form = $request->getParameter('embedded_form');
   if (is_array($embedded_form)) {
     foreach($embedded_form as $name => $form) {
       if ($this->isValidSfFormName($form))  {
         $this->sf_jq_rules->addEmbeddedForm($name, new $form);
       }
     }
   }
 }
コード例 #13
0
 public function executeBuild(sfWebRequest $request)
 {
     if (!$request->isMethod("post")) {
         return;
     }
     $this->new_url = "http://imgmky.com/gen?key=" . $request->getParameter("key") . '&url=' . urlencode($request->getParameter("url")) . '&size=' . $request->getParameter("size");
 }
コード例 #14
0
ファイル: actions.class.php プロジェクト: nacef/juriste
  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      Doctrine_Manager::connection()->beginTransaction();
      
      $Question = $form->save();

      if ($Question->getIdQualifAgent() == 3) {
        $venteForm = new VenteForm();
        $venteForm->bind($request->getParameter('vente'));
        if ($venteForm->isValid()) {
          $vente = $venteForm->save();
          Doctrine_Manager::connection()->commit();
        } else {
          Doctrine_Manager::connection()->rollback();
        }
      } else if ($Question->getIdQualifAgent() == 1) {
        $rappelForm = new RappelForm();
        $rappelForm->bind($request->getParameter('rappel'));
        if ($rappelForm->isValid()) {
          $rappel = $rappelForm->save();
          Doctrine_Manager::connection()->commit();
        } else {
          Doctrine_Manager::connection()->rollback();
        }
      } else {
        Doctrine_Manager::connection()->commit();
      }
      $this->redirect('question/next');      
    }
  }
コード例 #15
0
 /**
  * @param sfWebRequest $request
  * @return application/json data
  */
 public function execute($request)
 {
     $con = Propel::getConnection();
     $con->beginTransaction();
     $html = '';
     try {
         $type = $request->getParameter('type');
         $this->forward404Unless($type, 'Comment Type Not Found');
         $id = $request->getParameter('id');
         $this->forward404Unless($id, 'Comment ID Not Found');
         $aComment = CommentQuery::create()->filterByType($type)->filterById($id)->findOne();
         $this->forward404Unless($aComment, sprintf('%s Comment Not Found', ucfirst($type)));
         $this->forward404Unless($aComment->getUserId() == $this->getUser()->getId(), 'Your are not authorized to delete this comment');
         // construction of returns array
         switch ($type) {
             case CommentPeer::TYPE_BRANCH:
                 $returns = array('id' => $aComment->getBranchId(), 'type' => $type);
                 break;
             case CommentPeer::TYPE_FILE:
                 $returns = array('id' => $aComment->getFileId(), 'type' => $type);
                 break;
         }
         $aComment->delete($con);
         $html = $this->getComponent('default', 'commentGlobal', $returns);
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
     // returns a json object
     $this->getResponse()->setContentType('application/json');
     return $this->renderText(json_encode(array('html' => $html)));
 }
コード例 #16
0
 /**
  * List unassigned currencies for given employee and pay grade
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->setLayout(false);
     sfConfig::set('sf_web_debug', false);
     sfConfig::set('sf_debug', false);
     $currencies = array();
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     }
     $payGrade = $request->getParameter('paygrade');
     $empNumber = $request->getParameter('empNumber');
     if (!empty($payGrade) && !empty($empNumber)) {
         $employeeService = $this->getEmployeeService();
         // TODO: call method that returns data in array format (or pass parameter)
         $currencies = $employeeService->getAssignedCurrencyList($payGrade, true);
     } else {
         //
         // Return full currency list
         //
         $currencyService = $this->getCurrencyService();
         $currencies = $currencyService->getCurrencyList(true);
     }
     $currencyArray = array();
     foreach ($currencies as $currency) {
         $currency['currency_name'] = __($currency['currency_name']);
         $currencyArray[] = $currency;
     }
     return $this->renderText(json_encode($currencyArray));
 }
コード例 #17
0
ファイル: actions.class.php プロジェクト: vmorant/ttupf
 public function executeTest(sfWebRequest $request)
 {
     $sfGuardUser = $request->getParameter('sfGuardUser');
     $sfOauthConsumer = $request->getParameter('sfOauthConsumer');
     $this->infos = array('userId' => $sfGuardUser ? $sfGuardUser->getId() : null, 'consumerId' => $sfOauthConsumer->getId());
     //return $this->renderText(json_encode($this->infos));
 }
コード例 #18
0
 /**
  * Method executed when searching an expedition - trigger by the click on the search button
  * @param SearchExpeditionForm $form    The search expedition form instantiated that will be binded with the data contained in request
  * @param sfWebRequest         $request Request coming from browser
  * @var   int                  $pagerSlidingSize: Get the config value to define the range size of pager to be displayed in numbers (i.e.: with a value of 5, it will give this: << < 1 2 3 4 5 > >>)
  */
 protected function searchResults(IgsSearchFormFilter $form, sfWebRequest $request)
 {
     if ($request->getParameter('searchExpeditionIgs', '') !== '') {
         // Bind form with data contained in searchExpedition array
         $form->bind($request->getParameter('searchExpeditionIgs'));
         // Modify the s_url to call the searchResult action when on result page and playing with pager
         $this->s_url = 'expeditionsIgs/search?is_choose=false';
         // Test that the form binded is still valid (no errors)
         if ($form->isValid()) {
             // Define all properties that will be either used by the data query or by the pager
             // They take their values from the request. If not present, a default value is defined
             $query = $form->getQuery()->orderby($this->orderBy . ' ' . $this->orderDir);
             $pager = new DarwinPager($query, $this->currentPage, $this->form->getValue('rec_per_page'));
             // Replace the count query triggered by the Pager to get the number of records retrieved
             $count_q = clone $query;
             // Remove from query the group by and order by clauses
             $count_q = $count_q->select('count( distinct expedition_ref, ig_ref)')->removeDqlQueryPart('groupby')->removeDqlQueryPart('orderby');
             // Initialize an empty count query
             $counted = new DoctrineCounted();
             // Define the correct select count() of the count query
             $counted->count_query = $count_q;
             // And replace the one of the pager with this new one
             $pager->setCountQuery($counted);
             $this->pagerLayout = new PagerLayoutWithArrows($pager, new Doctrine_Pager_Range_Sliding(array('chunk' => $this->pagerSlidingSize)), $this->getController()->genUrl($this->s_url . $this->o_url) . '/page/{%page_number}');
             // Sets the Pager Layout templates
             $this->setDefaultPaggingLayout($this->pagerLayout);
             // If pager not yet executed, this means the query has to be executed for data loading
             if (!$this->pagerLayout->getPager()->getExecuted()) {
                 $this->expeditions = $this->pagerLayout->execute();
             }
         }
     }
 }
コード例 #19
0
 /**
  * List Custom fields
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $admin = $this->getUser()->hasCredential(Auth::ADMIN_ROLE);
     if (!$admin) {
         $this->forward("auth", "unauthorized");
     } else {
         if ($this->getUser()->hasFlash('templateMessage')) {
             list($this->messageType, $this->message) = $this->getUser()->getFlash('templateMessage');
         } else {
             if ($request->hasParameter('message')) {
                 $message = $request->getParameter('message');
                 if ($message == 'UPDATE_SUCCESS') {
                     $this->messageType = 'success';
                     $this->message = __(TopLevelMessages::UPDATE_SUCCESS);
                 }
             }
         }
         $this->form = new CustomFieldForm(array(), array(), true);
         $this->deleteForm = new CustomFieldDeleteForm(array(), array(), true);
         $customFieldsService = $this->getCustomFieldService();
         $this->sorter = new ListSorter('propoerty.sort', 'admin_module', $this->getUser(), array('field_num', ListSorter::ASCENDING));
         $sortBy = 'name';
         $sortOrder = 'ASC';
         if ($request->getParameter('sort')) {
             $sortBy = $request->getParameter('sort');
             $sortOrder = $request->getParameter('order');
         }
         $this->sorter->setSort(array($sortBy, $sortOrder));
         $this->listCustomField = $customFieldsService->getCustomFieldList(null, $sortBy, $sortOrder);
     }
 }
コード例 #20
0
 public function executeLogin(sfWebRequest $request)
 {
     if ($this->getUser()->isAuthenticated()) {
         $this->redirect('default/index');
     }
     if ($request->isMethod('post')) {
         $login = $request->getParameter('login');
         $psw = $request->getParameter('psw');
         $c = new Criteria();
         $c->add(UserPeer::LOGIN, $login);
         $c->add(UserPeer::PSW, $psw);
         $user = UserPeer::doSelectOne($c);
         if (false == empty($user)) {
             $this->getUser()->setAuthenticated(true);
             $this->getUser()->addCredentials($user->getStatus());
             $this->getUser()->setCulture('ru_UA');
             $this->getUser()->setAttribute('user', $user);
             if (!empty($remember)) {
                 $data = array('login' => $user->getLogin(), 'email' => $user->getEmail(), 'psw' => $user->getPsw(), 'status' => $user->getStatus());
                 $values = base64_encode(serialize($data));
                 $this->getResponse()->setCookie('user', $values, time() + 2592000);
                 $this->redirect('default/index');
             } else {
                 $this->redirect('default/index');
             }
         }
     }
 }
コード例 #21
0
ファイル: actions.class.php プロジェクト: nothan/OpenPNE3
 /**
  * Executes search action
  *
  * @param sfWebRequest $request a request object
  */
 public function executeSearch(sfWebRequest $request)
 {
     sfConfig::set('sf_nav_type', 'default');
     $params = $request->getParameter('community', array());
     $this->isResult = false;
     $this->category_id = 0;
     if (isset($params['name'])) {
         $params['name'] = $params['name'];
         $this->isResult = true;
     }
     if (isset($params['community_category_id'])) {
         $this->category_id = $params['community_category_id'];
         $params['community_category_id'] = $this->category_id;
         $this->isResult = true;
     }
     $this->filters = new CommunityFormFilter();
     $this->filters->bind($params);
     $q = $this->filters->getQuery()->orderBy('id desc');
     $this->pager = new sfDoctrinePager('Community', 10);
     $this->pager->setQuery($q);
     $this->pager->setPage($request->getParameter('page', 1));
     $this->pager->init();
     $this->categorys = Doctrine::getTable('CommunityCategory')->createQuery()->where('lft > 1')->execute();
     return sfView::SUCCESS;
 }
コード例 #22
0
 /**
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     /** @var JenkinsRun $run */
     $run = $this->getRoute()->getObject();
     if (!$run->getLaunched()) {
         // Job trouvé, actuellement en delayed => on le lance de suite
         $run->launchDelayed($this->getJenkins());
         $this->getUser()->setFlash('info', sprintf('The build [%s] has been launched and removed from the delayed list', $run->getJobName()));
     } else {
         if ($request->getParameter('delayed') == 1) {
             $this->getUser()->setFlash('info', sprintf('The build [%s] has been added to the delayed list', $run->getJobName()));
         } else {
             $build = $run->getJenkinsBuild($this->getJenkins());
             if (null !== $build && $build->isRunning() && ($executor = $build->getExecutor())) {
                 $executor->stop();
                 $this->getUser()->setFlash('info', sprintf('The build [%s] was running, has been cancelled, and relaunched', $run->getJobName()));
             } else {
                 $this->getUser()->setFlash('info', sprintf('The build [%s] has been relaunched', $run->getJobName()));
             }
         }
         $run->rebuild($this->getJenkins(), $request->getParameter('delayed') == 1);
         $run->computeJobBuildNumber($this->getJenkins(), $this->getUser());
     }
     $this->redirect($this->generateUrl('branch_view', $run->getJenkinsGroupRun()));
 }
コード例 #23
0
ファイル: actions.class.php プロジェクト: solutema/siwapp-sf1
 public function executeSave(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $invoices = (array) $request->getParameter('invoices', array());
     $estimates = (array) $request->getParameter('estimates', array());
     // check that there is only one template for each one
     if (count($invoices) > 1 || count($estimates) > 1) {
         $this->getUser()->error($this->getContext()->getI18N()->__('There must be only one template for model.'));
         $this->redirect('@templates');
     }
     $templates = Doctrine::getTable('Template')->createQuery()->execute();
     foreach ($templates as $t) {
         $models = array();
         if (in_array($t->getId(), $invoices)) {
             $models[] = 'Invoice';
         }
         if (in_array($t->getId(), $estimates)) {
             $models[] = 'Estimate';
         }
         $t->setModels(implode(',', $models));
         $t->save();
     }
     $this->getUser()->info($this->getContext()->getI18N()->__('Successfully saved.'));
     $this->redirect('@templates');
 }
コード例 #24
0
ファイル: actions.class.php プロジェクト: kcornejo/usac
 public function executeAcceso(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     $defaults = array();
     $Menu = MenuQuery::create()->usePerfilMenuQuery()->filterByPerfilId($id)->endUse()->find();
     foreach ($Menu as $fila) {
         $defaults['Menu'][] = $fila->getId();
     }
     $this->form = new AccesoForm($defaults);
     if ($request->isMethod('POST')) {
         $this->form->bind($request->getParameter('acceso'));
         if ($this->form->isValid()) {
             $valores = $this->form->getValues();
             PerfilMenuQuery::create()->findByPerfilId($id)->delete();
             foreach ($valores['Menu'] as $fila) {
                 $PerfilMenu = new PerfilMenu();
                 $PerfilMenu->setPerfilId($id);
                 $PerfilMenu->setMenuId($fila);
                 $PerfilMenu->save();
             }
             $idUsuario = $this->getUser()->getAttribute('usuario', null, 'seguridad');
             $html = Usuario::generaArbol($idUsuario);
             $this->getUser()->setAttribute('menu', $html, 'seguridad');
             $this->getUser()->setFlash('exito', 'Asignacion de Menús realizado correcamente.');
             $this->redirect('perfil/index');
         }
     }
     $this->id = $id;
 }
コード例 #25
0
ファイル: actions.class.php プロジェクト: solutema/siwapp-sf1
 /**
  * ajax action for customer name autocompletion
  *
  * @return JSON
  * @author Enrique Martinez
  **/
 public function executeAjaxCustomerAutocomplete(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     $q = $request->getParameter('q');
     $items = Doctrine::getTable('Customer')->simpleRetrieveForSelect($request->getParameter('q'), $request->getParameter('limit'));
     return $this->renderText(json_encode($items));
 }
コード例 #26
0
 public function executeGetCities(sfWebRequest $request)
 {
     //We get the parameters of the request
     $q = $request->getParameter('q');
     $limit = $request->getParameter('limit');
     $country = $request->getParameter('country_id');
     //If it's a number, we seek a postal code
     if (is_numeric($q)) {
         $cities = Doctrine::getTable('AddressCity')->findPostalCode($q, $limit, $country);
     } else {
         $cities = Doctrine::getTable('AddressCity')->findCity($q, $limit, $country);
     }
     //We put the suggestions in a list, $list. It looks like this :
     //$list[id] = city_name (postal_code)
     $list = array();
     foreach ($cities as $city) {
         if ($city->getPostalCode()) {
             $list[$city->getId()] = sprintf('%s (%s)', $city->getName(), $city->getPostalCode());
         } else {
             $list[$city->getId()] = sprintf('%s', $city->getName());
         }
     }
     //We render the text to the template.
     return $this->renderText(json_encode($list));
 }
コード例 #27
0
 public function executeSave_slots(sfWebRequest $request)
 {
     $this->contentSlots = array();
     $this->failedContentSlots = array();
     $this->errors = array();
     $slotIds = $request->getParameter('slot_ids');
     $contentIds = $request->getParameter('content_ids');
     foreach ($slotIds as $slotId) {
         $content = Doctrine_Core::getTable('sfSympalContent')->find($contentIds[$slotId]);
         $contentSlot = Doctrine_Core::getTable('sfSympalContentSlot')->find($slotId);
         $contentSlot->setContentRenderedFor($content);
         $form = $contentSlot->getEditForm();
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             if ($request->getParameter('preview')) {
                 $form->updateObject();
             } else {
                 $form->save();
             }
             $this->contentSlots[] = $contentSlot;
         } else {
             $this->failedContentSlots[] = $contentSlot;
             foreach ($form as $name => $field) {
                 if ($field->hasError()) {
                     $this->errors[$contentSlot->getName()] = $field->getError();
                 }
             }
         }
     }
 }
コード例 #28
0
ファイル: actions.class.php プロジェクト: rgevaert/uas
 public function executeChangepassword(sfWebRequest $request)
 {
     $this->form = new ChangePasswordForm();
     $this->user = Doctrine::getTable('User')->find($this->getUser()->getAttribute('user_id'));
     if ($request->isMethod('post')) {
         // if the form is submitted
         $this->form->bind($request->getParameter('changepassword'));
         if ($this->form->isValid()) {
             $pass_parameters = $request->getParameter('changepassword');
             $password = new Password($pass_parameters['new_password']);
             $current_password = new Password($pass_parameters['password']);
             if ($this->user->checkPassword($current_password)) {
                 $this->user->setPasswordObject($password);
                 $this->getUser()->setFlash('notice', "You have changed your password successfully");
             } else {
                 $this->getUser()->setFlash('notice', "Please type your existing password correctly");
                 $this->redirect('user/changepassword');
             }
             $this->redirect('user/show?id=' . $this->user->getId());
         }
     } else {
         // not a post, just a get
         //		$this->setTemplate('changepassword');
     }
 }
コード例 #29
0
ファイル: actions.class.php プロジェクト: morganney/livewire
 /**
  * Ajax method. Returns JSON data.
  * @param sfWebRequest $request
  */
 public function executeSelect(sfWebRequest $request)
 {
     $this->getResponse()->addCacheControlHttpHeader('no-cache');
     $this->getResponse()->setContentType('application/json');
     $this->getResponse()->sendHttpHeaders();
     $group = $request->getParameter('group');
     $type = $request->getParameter('type');
     $amps = $request->getParameter('amps');
     $choices_made = array();
     if (intval($group) != -1) {
         $choices_made['grp'] = $group;
     }
     if (intval($type) != -1) {
         $choices_made['frame_type'] = $type;
     }
     if (intval($amps) != -1) {
         $choices_made['amps'] = $amps;
     }
     $manuf_id = intval($request->getParameter('manuf_id'));
     $category = new BUCategory();
     $dependent_dropdowns = $category->fetchSelectionCriteriaByManuf($manuf_id, $choices_made);
     $matching_parts = $category->fetchMatchingParts($manuf_id, $choices_made);
     $json_data = json_encode(array_merge($dependent_dropdowns, $matching_parts));
     return $this->renderText($json_data);
 }
コード例 #30
0
ファイル: components.class.php プロジェクト: TheoJD/portail
 public function executeMenu(sfWebRequest $request)
 {
     if ($login = $request->getParameter('login', null)) {
         $this->asso = AssoTable::getInstance()->getOneByLogin($login)->select('q.id, q.login')->fetchOne();
     } else {
         if ($login = $request->getParameter('asso', null)) {
             $this->asso = AssoTable::getInstance()->getOneByLogin($login)->select('q.id, q.login')->fetchOne();
         } else {
             $this->asso = AssoTable::getInstance()->getOneById(1)->select('q.id, q.login')->fetchOne();
         }
     }
     // BDE
     if ($this->asso) {
         if ($this->asso->isPole()) {
             $this->couleur = PoleTable::getInstance()->findOneBy('asso_id', $this->asso->getId())->getCouleur();
         } else {
             $this->couleur = $this->asso->getPole()->getCouleur();
         }
     }
     /*
      * Si l'utilisateur est membre
      * et que l'association n'a pas de président,
      * on lui propose de suivre la procédure de signature de charte.
      */
     if ($this->getUser()->isAuthenticated() && $this->asso && $this->getUser()->getGuardUser()->isMember($this->asso->getLogin())) {
         $pres = AssoMemberTable::getInstance()->getPresident($this->asso)->fetchOne();
         $this->charte = !$pres ? true : false;
     } else {
         $this->charte = false;
     }
 }