예제 #1
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);
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         // kommt vom multiupload-gedingse
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         $sf_filebase_file = $form->save();
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_filebase_file)));
         if (!$request->hasParameter('swfupload_filesource')) {
             if ($request->hasParameter('_save_and_add')) {
                 $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
                 $this->redirect('@sf_filebase_file_new');
             } else {
                 $this->getUser()->setFlash('notice', $notice);
                 $this->redirect(array('sf_route' => 'sf_filebase_file_edit', 'sf_subject' => $sf_filebase_file));
             }
         }
         return true;
     } else {
         if (!$request->hasParameter('swfupload_filesource')) {
             $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
         }
         return false;
     }
 }
 public function executeSave(sfWebRequest $request)
 {
     if ($request->hasParameter('w3s_sm_source') && $request->hasParameter('w3s_sm_dest')) {
         $slotMapperPanel = new w3sSlotMapperPanel($request->getParameter('sourceId'), $request->getParameter('destId'));
         $this->result = $slotMapperPanel->save($request->getParameter('w3s_sm_source'), $request->getParameter('w3s_sm_dest'));
     }
 }
예제 #4
0
 public function executeEncaminhamento(sfWebRequest $request)
 {
     $this->pager = new sfDoctrinePager('Atendimento', 10);
     if ($request->hasParameter('modo')) {
         if ($request->getParameter('modo') == 'mensal') {
             $start = strtotime(date('Y') . '-' . date('m') . '-01');
             $end = $this->getMonthLastDay();
             $this->datesQueryFormated = $this->getDatesQueryFormated($start, $end);
             $queries = Doctrine_Core::getTable('Atendimento')->getEncaminhamentosBydate($this->datesQueryFormated);
         } elseif ($request->getParameter('modo') == 'semanal') {
             $this->datesQueryFormated = $this->getDatesQueryFormated();
             $queries = Doctrine_Core::getTable('Atendimento')->getEncaminhamentosBydate($this->datesQueryFormated);
         }
     } else {
         if ($request->hasParameter('start') || $request->hasParameter('end')) {
             $start = $request->hasParameter('start') ? $request->getParameter('start') : NULL;
             $end = $request->hasParameter('end') ? $request->getParameter('end') : NULL;
             $this->datesQueryFormated = $this->getDatesQueryFormated($start, $end);
             $queries = Doctrine_Core::getTable('Atendimento')->getEncaminhamentosBydate($this->datesQueryFormated);
         } else {
             $this->datesQueryFormated = $this->getDatesQueryFormated();
             $queries = Doctrine_Core::getTable('Atendimento')->getEncaminhamentosBydate($this->datesQueryFormated);
         }
     }
     $this->pager->setQuery($queries['encaminhamento']);
     $graphData = $queries['chartData']->execute();
     $this->pager->getQuery()->orderBy('created_at DESC');
     $this->pager->setPage($this->getRequestParameter('page', 1));
     $this->pager->init();
     $this->prepareGraphData($graphData);
     $this->pagerURL = $this->preparePagerURL('encaminhamento');
     $this->lstLinks = array("@relatorio_encaminhamento?modo=semanal" => "Semanal", "@relatorio_encaminhamento?modo=mensal" => "Mensal", "@relatorio_historico" => "Voltar");
 }
예제 #5
0
 public function executeAdd(sfWebRequest $request)
 {
     //Set the local vars used in this function for easy access.
     $uid_from = $this->getUser()->getAttribute('id');
     $uid_to = $request->getParameter('uid');
     //Error Checking
     $this->errorCheck(!$this->getUser()->hasAttribute('id'), "Required request paramater uid_from is not set.");
     $this->errorCheck(!$request->hasParameter('uid'), "Required request paramater uid is not set.");
     $this->errorCheck($uid_to == null || $uid_to == 0, "Account id can not be null.");
     $this->errorCheck($uid_to == 1, "Friendship requests to the Administrator account are not allowed.");
     $this->errorCheck(!AccountTable::accountExists($uid_from), "Account ({$uid_from}) does not exist in database.");
     $this->errorCheck(!AccountTable::accountExists($uid_to), "Account ({$uid_to}) does not exist in database.");
     $this->errorCheck(FriendTable::areFriends($uid_from, $uid_to), "Account ({$uid_from}) and ({$uid_to}) are already friends.");
     $this->errorCheck(FriendRequestTable::requestPending($uid_from, $uid_to), "Account ({$uid_from}) has already requested ({$uid_to}) for friendship.");
     $this->errorCheck(FriendRequestTable::requestPending($uid_to, $uid_from), "Account ({$uid_to}) has already requested ({$uid_from}) for friendship.");
     $this->errorCheck($uid_from == $uid_to, "Account ({$uid_from}) can not request friendship with itself.");
     //Request is valid if code reaches here so make a friend request object and save it.
     $friendRequest = new FriendRequest();
     $friendRequest->uid_from = $uid_from;
     $friendRequest->uid_to = $uid_to;
     $friendRequest->save();
     $url = "default/index";
     if ($request->hasParameter('redirect_url')) {
         $url = $request->getParameter('redirect_url') . 'index';
     }
     $this->flashAndRedirect("Friendship successfully requested.", $url);
 }
예제 #6
0
 public function executeIndex(sfWebRequest $request)
 {
     if ($request->hasParameter('group_id') || $request->hasParameter('nodeid')) {
         $this->setFilters($this->configuration->getFilterDefaults());
     }
     parent::executeIndex($request);
 }
예제 #7
0
 /**
  * Searches aircrafts by filter
  */
 private function processFilter(sfWebRequest $request)
 {
     $params = $this->getUser()->getAttribute('aircraft', array(), 'aircraft');
     if (!isset($params['make'])) {
         $params['make'] = null;
     }
     if (!isset($params['model'])) {
         $params['model'] = null;
     }
     if (!isset($params['name'])) {
         $params['name'] = null;
     }
     $this->max_array = array(5, 10, 20, 30);
     if (in_array($request->getParameter('max'), $this->max_array)) {
         $params['max'] = $request->getParameter('max');
     } else {
         if (!isset($params['max'])) {
             $params['max'] = sfConfig::get('app_max_person_per_page', 10);
         }
     }
     if ($request->hasParameter('filter')) {
         $params['make'] = $request->getParameter('make');
         $params['model'] = $request->getParameter('model');
         $params['name'] = $request->getParameter('name');
     }
     if ($request->hasParameter('search') && $request->getParameter('search') == 'pilots') {
         $params['name'] = $request->getParameter('name');
     }
     $this->page = $page = $request->getParameter('page', 1);
     $this->max = $params['max'];
     $this->make = $params['make'];
     $this->model = $params['model'];
     $this->name = $params['name'];
     $this->getUser()->setAttribute('aircraft', $params, 'aircraft');
 }
예제 #8
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->checkProjectsAccess('view');
     if (!$this->getUser()->hasAttribute('projects_filter')) {
         $this->getUser()->setAttribute('projects_filter', Projects::getDefaultFilter($this->getUser()));
     }
     $this->filter_by = $this->getUser()->getAttribute('projects_filter');
     if ($fb = $request->getParameter('filter_by')) {
         $this->filter_by[key($fb)] = current($fb);
         $this->getUser()->setAttribute('projects_filter', $this->filter_by);
         $this->redirect('projects/index');
     }
     if ($request->hasParameter('remove_filter')) {
         unset($this->filter_by[$request->getParameter('remove_filter')]);
         $this->getUser()->setAttribute('projects_filter', $this->filter_by);
         $this->redirect('projects/index');
     }
     if ($request->hasParameter('user_filter')) {
         $this->filter_by = Projects::useProjectsFilter($request->getParameter('user_filter'), $this->getUser());
         $this->getUser()->setAttribute('projects_filter', $this->filter_by);
         $this->redirect('projects/index');
     }
     if ($set_order = $request->getParameter('set_order')) {
         $this->getUser()->setAttribute('projects_listing_order', $set_order);
         $this->redirect('projects/index');
     }
     app::setPageTitle('Projects', $this->getResponse());
 }
 /**
  * Tag typeahead AJAX. You might want to secure this action to prevent
  * information discovery in some cases
  *
  */
 public function executeComplete(sfWebRequest $request)
 {
     $this->setLayout(false);
     $current = '';
     if ($request->hasParameter('q')) {
         $current = $request->getParameter('q');
     } elseif ($request->hasParameter('term')) {
         $current = $request->getParameter('term');
     } else {
         $current = $request->getParameter('current');
     }
     $tags = array();
     $tagsInfo = array();
     $tagsAll = array();
     while (preg_match("/^(([\\s\\,]*)([^\\,]+?)(\\s*(\\,|\$)))(.*)\$/", $current, $matches)) {
         list($dummy, $all, $left, $tagName, $right, $dummy, $current) = $matches;
         $tagsInfo[] = array('left' => $left, 'name' => $tagName, 'right' => $right);
         $tagsAll[] = $all;
     }
     $this->tagSuggestions = array();
     $all = '';
     $n = 0;
     $presentOrSuggested = array();
     foreach ($tagsInfo as $tagInfo) {
         $tag = Doctrine_Query::create()->from('Tag t')->where('t.name = ?', $tagInfo['name'])->fetchOne();
         $all .= $tagInfo['left'];
         if ($tag) {
             $presentOrSuggested[$tagInfo['name']] = true;
         } else {
             // $suggestedTags = sfTagtoolsToolkit::getBeginningWith($tagInfo['name']);
             $q = $this->getQuery($tagInfo['name']);
             $suggestedTags = $q->execute();
             foreach ($suggestedTags as $tag) {
                 if (isset($presentOrSuggested[$tag->getName()])) {
                     continue;
                 }
                 // At least some browsers actually submitted the
                 // nonbreaking spaces as ordinals distinct from regular spaces,
                 // producing distinct tags. So leave the spaces alone.
                 // Also, we no longer display 'left' visibly anyway because
                 // that was never compatible with a list of tags that required scrolling
                 $suggestion['left'] = $all;
                 $suggestion['suggested'] = $tag->getName();
                 $presentOrSuggested[$tag->getName()] = true;
                 $suggestion['right'] = $tagInfo['right'] . implode('', array_slice($tagsAll, $n + 1));
                 $this->tagSuggestions[] = $suggestion;
             }
         }
         $all .= $tagInfo['name'];
         $all .= $tagInfo['right'];
         $n++;
     }
     if ($this->hasRequestParameter('q')) {
         $this->setTemplate('jQueryAutocompleteOld');
     } elseif ($this->hasRequestParameter('term')) {
         $this->setTemplate('jQueryAutocomplete');
     }
 }
예제 #10
0
 public function executeTrust(sfWebRequest $request)
 {
     sfOpenPNEApplicationConfiguration::registerJanRainOpenID();
     require_once 'Auth/OpenID/Server.php';
     require_once 'Auth/OpenID/FileStore.php';
     require_once 'Auth/OpenID/SReg.php';
     require_once 'Auth/OpenID/AX.php';
     $info = unserialize($_SESSION['request']);
     $this->forward404Unless($info);
     $trusted = $request->hasParameter('trust') || $request->hasParameter('permanent');
     if (!$trusted) {
         unset($_SESSION['request']);
         $url = $info->getCancelURL();
         $this->redirect($url);
     }
     $reqUrl = $this->getController()->genUrl('OpenID/member?id=' . $this->getUser()->getMemberId(), true);
     if (!$info->idSelect()) {
         $this->forward404Unless($reqUrl === $info->identity, 'request:' . $reqUrl . '/identity:' . $info->identity);
     }
     unset($_SESSION['request']);
     $server = new Auth_OpenID_Server(new Auth_OpenID_FileStore(sfConfig::get('sf_cache_dir')), $info->identity);
     $response = $info->answer(true, null, $reqUrl);
     $sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
     $axRequest = Auth_OpenID_AX_FetchRequest::fromOpenIDRequest($info);
     $allowedProfiles = $request->getParameter('profiles', array());
     $requiredProfiles = $this->createListOfRequestedProfiles($sregRequest, $axRequest);
     $rejectedProfiles = array_diff_key($requiredProfiles, array_flip($allowedProfiles));
     if (in_array(true, $rejectedProfiles)) {
         $url = $info->getCancelURL();
         $this->redirect($url);
     }
     if ($sregRequest) {
         $sregExchange = new opOpenIDProfileExchange('sreg', $this->getUser()->getMember());
         $sregResp = Auth_OpenID_SRegResponse::extractResponse($sregRequest, $sregExchange->getData($allowedProfiles));
         $response->addExtension($sregResp);
     }
     if ($axRequest && !$axRequest instanceof Auth_OpenID_AX_Error) {
         $axResp = new Auth_OpenID_AX_FetchResponse();
         $axExchange = new opOpenIDProfileExchange('ax', $this->getUser()->getMember());
         $userData = $axExchange->getData($allowedProfiles);
         foreach ($axRequest->requested_attributes as $k => $v) {
             if (!empty($userData[$k])) {
                 $axResp->addValue($k, $userData[$k]);
             }
         }
         $response->addExtension($axResp);
     }
     $log = Doctrine::getTable('OpenIDTrustLog')->log($info->trust_root, $this->getUser()->getMemberId());
     if ($request->hasParameter('permanent')) {
         $log->is_permanent = true;
         $log->save();
     }
     $response = $server->encodeResponse($response);
     return $this->writeResponse($response);
 }
예제 #11
0
 public function executeInsertCategory(sfWebRequest $request)
 {
     if ($request->hasParameter("categoryid") && $request->hasParameter("categoryname")) {
         $parent = Doctrine_Core::getTable('Category')->findOneById($request->getParameter("categoryid"));
         $category = new Category();
         $category->setName($request->getParameter("categoryname"));
         $category->setActive(true);
         $category->getNode()->insertAsLastChildOf($parent);
         return true;
     }
 }
 /**
  * Shows assets as icons.
  *
  * @param sfWebRequest $request
  */
 public function executeIcons(sfWebRequest $request)
 {
     if ($request->hasParameter('page')) {
         $this->getUser()->setAttribute('page', $request->getParameter('page'));
     }
     if ($folder_id = $request->getParameter('folder_id')) {
         $this->getUser()->setAttribute('folder_id', $folder_id);
         $this->getUser()->setAttribute('page', 1);
     }
     $folder_id = $this->getUser()->getAttribute('folder_id', 0);
     $this->folder = lyMediaFolderTable::getInstance()->retrieveCurrent($folder_id);
     $this->forward404Unless($this->folder);
     $this->folders = $this->folder->getNode()->getChildren();
     if ($request->hasParameter('sort')) {
         $this->getUser()->setAttribute('sort_field', $request->getParameter('sort'));
     }
     $this->sort_field = $this->getUser()->getAttribute('sort_field', 'name');
     if ($request->hasParameter('dir')) {
         $this->getUser()->setAttribute('sort_dir', $request->getParameter('dir'));
     }
     $this->sort_dir = $this->getUser()->getAttribute('sort_dir');
     if ($request->hasParameter('hide')) {
         $this->getUser()->setAttribute('hide', $request->getParameter('hide') ? 1 : 0);
     }
     $this->hide = $this->getUser()->getAttribute('hide');
     $this->pager = new sfDoctrinePager('lyMediaAsset', sfConfig::get('app_lyMediaManager_assets_per_page', 20));
     $this->pager->setQuery($this->folder->retrieveAssetsQuery(array('sort_field' => $this->sort_field, 'sort_dir' => $this->sort_dir)));
     $this->pager->setPage($this->getUser()->getAttribute('page', 1));
     $this->pager->init();
     if ($request->getParameter('popup')) {
         $this->getUser()->setAttribute('popup', true);
     } else {
         $this->getUser()->getAttributeHolder()->remove('popup');
     }
     if ($this->popup = $this->getUser()->getAttribute('popup')) {
         $this->setLayout($this->getContext()->getConfiguration()->getTemplateDir('lyMediaAsset', 'popupLayout.php') . DIRECTORY_SEPARATOR . 'popupLayout');
         $this->getResponse()->addJavascript('/lyMediaManagerPlugin/js/lymedia_popup.js');
         if ($request->hasParameter('editor')) {
             $this->getUser()->setAttribute('editor', $request->getParameter('editor') == 'fck' ? 'fck' : 'tiny');
         }
         if ($this->getUser()->getAttribute('editor') == 'fck') {
             $this->getResponse()->addJavascript('/lyMediaManagerPlugin/js/lymedia_fck_popup.js', 'last');
         } else {
             $this->getResponse()->addJavascript('tiny_mce/tiny_mce_popup');
             $this->getResponse()->addJavascript('/lyMediaManagerPlugin/js/lymedia_tiny_popup.js', 'last');
         }
         $this->getResponse()->addStyleSheet('/lyMediaManagerPlugin/css/lymedia_popup.css');
     }
     $this->getUser()->setAttribute('view', 'icons');
     $this->folder_form = new lyMediaCreateFolderForm();
     $this->asset_form = new lyMediaSimplerAssetForm(null, array('folder_id' => $this->folder->getId()));
     $this->nbfolders = $this->folders ? count($this->folders) : 0;
     $this->total_size = $this->folder->sumFileSizes();
 }
예제 #13
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tasks', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     if ($this->reports_id > 0) {
         $q = UserReports::addFiltersToQuery($q, $this->reports_id, $this->getUser()->getAttribute('id'));
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'TasksComments', 't', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'tasks', $this->getUser());
     } else {
         $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
         $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     }
     $this->pager = false;
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Tasks', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->tasks_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=userReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = 'redirect_to=tasksList';
         if ($request->hasParameter('projects_id')) {
             $this->url_params = 'projects_id=' . $request->getParameter('projects_id');
         }
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
     $this->users_schema = Users::getSchema();
 }
예제 #14
0
 public function executeSubmitExam(sfWebRequest $request)
 {
     if ($request->isMethod(sfRequest::POST) && $request->hasParameter('security') && $request->hasParameter('year') && $request->hasParameter('descr')) {
         $files = $request->getFiles();
         $file = $files['file'];
         $descr = $request->getParameter('descr');
         if (isset($file) && strtoupper(substr($file['name'], -3, 3)) == 'PDF' && !helperFunctions::isMaliciousString($descr)) {
             if ($request->getParameter("security") != $_SESSION['securityImage']) {
                 echo "<input type='text' id='status' value='Security'/>";
                 exit;
             }
             $year = $request->getParameter("year") . $request->getParameter("term");
             // make directories if not exist
             if (!is_dir("exams/custom")) {
                 if (!mkdir("exams/custom")) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     exit;
                 }
             }
             $tgt_path = "exams/custom/" . $year;
             if (!is_dir($tgt_path)) {
                 if (!mkdir($tgt_path)) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     exit;
                 }
             }
             $fileName = time() . ".pdf";
             if (move_uploaded_file($file['tmp_name'], $tgt_path . "/" . $fileName)) {
                 // register in db
                 $conn = Propel::getConnection();
                 $exam = new Exam();
                 $exam->setCourseId($request->getParameter("course"));
                 $exam->setFilePath($tgt_path . "/" . $fileName);
                 $exam->setYear($year);
                 $exam->setType($request->getParameter("type"));
                 $exam->setDescr($descr);
                 $exam->save($conn);
                 // send notification email
                 $ip = $_SERVER['REMOTE_ADDR'];
                 $msg = "Submitted by " . $ip . " [id=" . $exam->getId() . "]";
                 helperFunctions::sendEmailNotice("Exam Submission", $msg);
                 echo "<input type='text' id='status' value='Success'/>";
             } else {
                 echo "<input type='text' id='status' value='Moving'/>";
             }
         } else {
             echo "<input type='text' id='status' value='PDF'/>";
         }
     }
     exit;
 }
예제 #15
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tickets', $this->getUser())) {
             $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     if ($this->reports_id > 0) {
         $q = TicketsReports::addFiltersToQuery($q, $this->reports_id, $this->getUser());
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'TicketsComments', 't', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'tickets', $this->getUser());
     } else {
         $q = Tickets::addFiltersToQuery($q, $this->getUser()->getAttribute('tickets_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
         $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id'));
     }
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Tickets', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->tickets_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=ticketsReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = 'redirect_to=ticketsList';
         if ($request->hasParameter('projects_id')) {
             $this->url_params = 'projects_id=' . $request->getParameter('projects_id');
         }
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
 }
예제 #16
0
 public function executeIndex(sfWebRequest $request)
 {
     $curr_pg = $request->getParameter('page', 1);
     $max_pg = sfConfig::get('app_max_items_on_index');
     $this->route = $this->getContext()->getRouting()->getCurrentInternalUri();
     $this->pager = new sfDoctrinePager('ScssWeek', $max_pg);
     $q = Doctrine::getTable('ScssWeek')->createQuery('w');
     if ($request->hasParameter('country_slug') && $request->hasParameter('zone_slug') && $request->hasParameter('district_slug') && $request->hasParameter('camp_slug')) {
         $q->leftJoin('w.Camp c')->leftJoin('c.District d')->leftJoin('d.Zone z')->leftJoin('z.Country y')->where('z.slug    = ?', $request->getParameter('zone_slug'))->andWhere('y.slug = ?', $request->getParameter('country_slug'))->andWhere('d.slug = ?', $request->getParameter('district_slug'))->andWhere('c.slug = ?', $request->getParameter('camp_slug'));
     }
     $q->orderBy('d.name ASC');
     $this->pager->setQuery($q);
     $this->pager->setPage($curr_pg);
     $this->pager->init();
 }
예제 #17
0
 public function executeIndex(sfWebRequest $request)
 {
     // searching
     if ($request->hasParameter('search')) {
         $this->setSearch($request->getParameter('search'));
         $request->setParameter('page', 1);
     }
     // filtering
     if ($request->getParameter('filters')) {
         $this->setFilters($request->getParameter('filters'));
     }
     // sorting
     if ($request->getParameter('sort')) {
         $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
     }
     //maxPerPage
     if ($request->getParameter('maxPerPage')) {
         $this->setMaxPerPage($request->getParameter('maxPerPage'));
         $this->setPage(1);
     }
     // pager
     if ($request->getParameter('page')) {
         $this->setPage($request->getParameter('page'));
     }
     $this->pager = $this->getPager();
     $this->sort = $this->getSort();
     if ($request->isXmlHttpRequest()) {
         $partialFilter = null;
         sfConfig::set('sf_web_debug', false);
         $this->setLayout(false);
         sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Date'));
         if ($request->hasParameter('search')) {
             $partialSearch = $this->getPartial('visite/search', array('configuration' => $this->configuration));
         }
         if ($request->hasParameter('_reset')) {
             $partialFilter = $this->getPartial('visite/filters', array('form' => $this->filters, 'configuration' => $this->configuration));
         }
         $partialList = $this->getPartial('visite/list', array('pager' => $this->pager, 'sort' => $this->sort, 'helper' => $this->helper));
         if (isset($partialSearch)) {
             $partialList .= '#__filter__#' . $partialSearch;
         }
         if (isset($partialFilter)) {
             $partialList .= '#__filter__#' . $partialFilter;
         }
         return $this->renderText($partialList);
     }
     return sfView::SUCCESS;
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         try {
             $stock = $form->save();
             $stock->calc($stock->getDate());
         } catch (Doctrine_Validator_Exception $e) {
             $errorStack = $form->getObject()->getErrorStack();
             $message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
             foreach ($errorStack as $field => $errors) {
                 $message .= "{$field} (" . implode(", ", $errors) . "), ";
             }
             $message = trim($message, ', ');
             $this->getUser()->setFlash('error', $message);
             return sfView::SUCCESS;
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $stock)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@stock_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect("stock/view?id=" . $stock->getId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 /**
  * 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
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->hasParameter('page')) {
         //$this->forward404();
     }
     $this->page = $request->getParameter('page');
 }
예제 #21
0
 public function executeAddWidget(sfWebRequest $request)
 {
     $widget = Doctrine::getTable('MyWidgets')->getWidget($this->getUser()->getAttribute('db_user_id'), $request->getParameter('widget', false), $request->getParameter('category') . "_widget");
     $this->forward404unless($widget);
     $positions = explode(',', $request->getParameter('place', '0'));
     $this->forward404unless(count($positions) >= $widget->getColNum());
     $widget->setVisible(true);
     $widget->setOrderBy($positions[$widget->getColNum() - 1]);
     $widget->save();
     Doctrine::getTable('MyWidgets')->incrementOrder($this->getUser()->getAttribute('db_user_id'), $request->getParameter('category') . "_widget", $widget->getColNum(), $positions[$widget->getColNum() - 1]);
     $category = $widget->getComponentFromCategory();
     if ($request->hasParameter('view')) {
         $category .= "view";
     }
     return $this->renderPartial('widgets/wlayout', array('widget' => $request->getParameter('widget'), 'is_opened' => true, 'is_mandatory' => $widget->getMandatory(), 'category' => $category, 'title' => $widget->getTitlePerso(), 'col_num' => $widget->getColNum(), 'options' => array('eid' => $request->getParameter('eid', null), 'table' => $widget->getTableFromCategory($request->getParameter('table', null)), 'view' => $request->hasParameter('view') ? true : false)));
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $new = !$form->getObject()->exists();
         $site = $form->save();
         if ($new) {
             $dispatcher = $this->getContext()->getEventDispatcher();
             $formatter = new sfFormatter();
             chdir(sfConfig::get('sf_root_dir'));
             $task = new sfGenerateAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalEnableForAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalCreateSiteTask($dispatcher, $formatter);
             $task->run(array($site->slug), array('no-confirmation'));
             $site = Doctrine_Core::getTable('sfSympalSite')->findOneByTitle($site->title);
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $site)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') . ' You can add another one below.');
             $this->redirect('@sympal_sites_new');
         } else {
             $this->redirect('@sympal_sites_edit?id=' . $site->getId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
예제 #23
0
 public function executeAddUsers(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($request->hasParameter('users'), 'users parameter is mandatory');
     $this->form = new UsergroupUsersForm();
     $this->form->addUsers(explode(',', $request->getParameter('users')));
 }
 /**
  * search asset
  * @param sfWebRequest $request
  */
 public function executeSearch(sfWebRequest $request)
 {
     $this->form = new sfAssetFormFilter();
     $this->form->bind($request->getParameter($this->form->getName()));
     $this->filterform = new sfAssetFormFilter();
     // We keep the search params in the session for easier pagination
     if ($request->hasParameter('search_params')) {
         $search_params = $request->getParameter('search_params');
         if (isset($search_params['created_at']['from']) && $search_params['created_at']['from'] !== '') {
             $search_params['created_at']['from'] = sfI18N::getTimestampForCulture($search_params['created_at']['from'], $this->getUser()->getCulture());
         }
         if (isset($search_params['created_at']['to']) && $search_params['created_at']['to'] !== '') {
             $search_params['created_at']['to'] = sfI18N::getTimestampForCulture($search_params['created_at']['to'], $this->getUser()->getCulture());
         }
         $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/sf_asset/search_params');
         $this->getUser()->getAttributeHolder()->add($search_params, 'sf_admin/sf_asset/search_params');
     }
     $this->search_params = $this->getUser()->getAttributeHolder()->getAll('sf_admin/sf_asset/search_params');
     if ($this->form->isValid()) {
         $c = $this->processSearch($this->form->getValues(), $request);
     } else {
         $c = new Criteria();
     }
     $pager = new sfPropelPager('sfAsset', sfConfig::get('app_sfAssetsLibrary_search_pager_size', 20));
     $pager->setCriteria($c);
     $pager->setPage($request->getParameter('page', 1));
     $pager->setPeerMethod('doSelectJoinsfAssetFolder');
     $pager->init();
     $this->pager = $pager;
     $this->removeLayoutIfPopup($request);
 }
예제 #25
0
 /**
  * Executes invite action
  *
  * @param sfWebRequest $request
  */
 public function executeInvite(sfWebRequest $request)
 {
     if ($request->isMethod(sfWebRequest::POST)) {
         $request->checkCSRFProtection();
         if ($request->hasParameter('invite')) {
             $result = $this->processInvite($request);
             $callback = '@application_render?id=' . $this->application->getId();
             if ($request->hasParameter('callback')) {
                 $callback .= '&url=' . urlencode($request->getParameter('callback'));
             }
             $this->redirect($callback);
         }
     }
     $fromMember = $this->getUser()->getMember();
     $this->nowpage = (int) $request->getParameter('nowpage', 1);
     if ($request->hasParameter('previous')) {
         $this->nowpage--;
     } else {
         if ($request->hasParameter('next')) {
             $this->nowpage++;
         }
     }
     $this->ids = $request->getParameter('ids', array());
     $this->forward404Unless($this->application->isHadByMember($fromMember->getId()));
     $this->pager = Doctrine::getTable('MemberRelationship')->getFriendListPager($fromMember->getId(), $this->nowpage, 15);
     $this->installedFriends = Doctrine::getTable('MemberApplication')->getInstalledFriendIds($this->application, $fromMember);
     $this->form = new BaseForm();
 }
예제 #26
0
 public function executeAdd(sfWebRequest $request)
 {
     if ($this->getUser()->isA(Users::REGISTERED_USER)) {
         $this->forwardToSecureAction();
     }
     $this->insurance = null;
     if ($request->hasParameter('rid')) {
         $this->insurance = Doctrine::getTable('Insurances')->find($request->getParameter('rid'));
     }
     if (!$this->insurance) {
         $this->insurance = new Insurances();
         $this->insurance->setRecordId($request->getParameter('id'));
         $this->insurance->setReferencedRelation($request->getParameter('table'));
     }
     $this->form = new InsurancesForm($this->insurance);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('insurances'));
         if ($this->form->isValid()) {
             try {
                 $this->form->save();
                 $this->form->getObject()->refreshRelated();
                 $this->form = new InsurancesForm($this->form->getObject());
                 //Ugly refresh
                 return $this->renderText('ok');
             } catch (Exception $e) {
                 $error = new sfValidatorError(new savedValidator(), $e->getMessage());
                 $this->form->getErrorSchema()->addError($error);
             }
         }
     }
 }
예제 #27
0
 public function executeCreatePassword(sfWebRequest $request)
 {
     $this->setLayout('login');
     if ($request->hasParameter('token')) {
         $this->token = Doctrine::getTable('Token')->findOneByValue($request->getParameter('token'));
         if ($this->token) {
             $this->user = $this->token->getUser();
             // doing validation
             if (strlen($request->getParameter('new_password')) < 6) {
                 $this->errors = $this->getContext()->getI18N()->__('Password must be at least 6 characters long');
                 $this->setTemplate('newPassword');
                 return sfView::SUCCESS;
             }
             if (strcmp($request->getParameter('new_password'), $request->getParameter('new_password_confirmation')) != 0) {
                 $this->errors = $this->getContext()->getI18N()->__('Password and confirmation must be identical');
                 $this->setTemplate('newPassword');
                 return sfView::SUCCESS;
             }
             // save the new user data
             $this->user->setPassword(md5($request->getParameter('new_password')));
             $this->user->save();
             $this->token->delete();
             // redirect to login page
             $this->getUser()->setFlash('notice_message', $this->getContext()->getI18N()->__('Your password was changed successfully. Please login again.'));
             $this->redirect('login/index');
         }
     }
     $this->errors = $this->getContext()->getI18N()->__('There is a problem with your token. Password can not be changed');
     $this->setTemplate('newPassword');
     return sfView::SUCCESS;
 }
예제 #28
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'Категория создана успешно.' : 'Категория изменена успешно.';
         $Category = $form->save();
         foreach ((array) $request->getParameter('category_preference') as $key => $value) {
             if (isset($value['id']) and $value['id'] != 0) {
                 $category_preference = CategoryPreferencePeer::retrieveByPk(intval($value['id']));
             } else {
                 $category_preference = new CategoryPreference();
                 $category_preference->setCategoryId($form->getObject()->getId());
             }
             if (isset($value['delete'])) {
                 $category_preference->delete();
             } elseif ($value['name'] != '') {
                 $category_preference->setKey($value['name']);
                 $category_preference->setPreferenceType($value['preference_type']);
                 $category_preference->setPreferenceUnit($value['preference_unit']);
                 $category_preference->setFilterStatus(isset($value['filter_status']) ? $value['filter_status'] : 0);
                 $category_preference->save();
             }
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Category)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' Вы можете создать еще одну.');
             $this->redirect('@category_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'category_edit', 'sf_subject' => $Category));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
예제 #29
0
 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);
 }
예제 #30
0
 /**
  * Searches for afa orgs
  * It also handles followings:
  */
 private function processFilter(sfWebRequest $request)
 {
     $params = $this->getUser()->getAttribute('afaorg', array(), 'afaorg');
     if (!isset($params['name'])) {
         $params['name'] = null;
     }
     if (!isset($params['phone'])) {
         $params['phone'] = null;
     }
     if (!isset($params['fax'])) {
         $params['fax'] = null;
     }
     $this->max_array = array(5, 10, 20, 30);
     if (in_array($request->getParameter('max'), $this->max_array)) {
         $params['max'] = $request->getParameter('max');
     } else {
         if (!isset($params['max'])) {
             $params['max'] = sfConfig::get('app_max_person_per_page', 10);
         }
     }
     if ($request->hasParameter('filter')) {
         $params['name'] = $request->getParameter('name');
         $params['phone'] = $request->getParameter('phone');
         $params['fax'] = $request->getParameter('fax');
     }
     $this->page = $page = $request->getParameter('page', 1);
     $this->max = $params['max'];
     $this->name = $params['name'];
     $this->phone = $params['phone'];
     $this->fax = $params['fax'];
     $this->getUser()->setAttribute('afaorg', $params, 'afaorg');
 }