/** * Signin action for the admin. Will redirect to the dashboard if authenticated */ public function executeSignin(sfWebRequest $request) { $user = $this->getUser(); // if it is true, then we has been forwarded to signin. // Save it to redirect user back after successful signin. if ($this->getController()->getActionStack()->getFirstEntry()->getModuleName() !== $this->getModuleName() && $this->getController()->getActionStack()->getFirstEntry()->getActionName() !== $this->getActionName()) { $user->setAttribute('signin.redirectTo', $request->getUri()); } if ($user->isAuthenticated()) { $redirectTo = $user->getAttribute('signin.redirectTo', '@sympal_dashboard'); $user->getAttributeHolder()->remove('signin.redirectTo'); return $this->redirect($redirectTo); } $this->getResponse()->setTitle('Sympal Admin / Signin'); $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin'); $this->form = new $class(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signin')); if ($this->form->isValid()) { $values = $this->form->getValues(); $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); $redirectTo = $user->getAttribute('signin.redirectTo', '@sympal_dashboard'); $user->getAttributeHolder()->remove('signin.redirectTo'); return $this->redirect($redirectTo); } } }
public function executeFormComment(sfWebRequest $request) { $this->form = new CommentForm(); $this->form->setDefault('record_model', $this->object->getTable()->getComponentName()); $this->form->setDefault('record_id', $this->object->get('id')); if ($request->isMethod('post')) { //preparing temporary array with sent values $formValues = $request->getParameter($this->form->getName()); if (vjComment::isCaptchaEnabled() && !vjComment::isUserBoundAndAuthenticated()) { $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')); //Adding captcha $formValues = array_merge($formValues, array('captcha' => $captcha)); } if (vjComment::isUserBoundAndAuthenticated()) { //adding user id $formValues = array_merge($formValues, array('user_id' => $this->getUser()->getGuardUser()->getId())); } $this->form->bind($formValues); if ($this->form->isValid()) { $this->form->save(); $url = $request->getUri() . "#" . $this->getUser()->getAttribute("nextComment"); $this->getUser()->offsetUnset("nextComment"); sfContext::getInstance()->getController()->redirect($url, 0, 302); } } }
public function executeIndex(sfWebRequest $request) { #security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Member'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } $this->email_lists = EmailListPeer::doSelect(new Criteria()); $this->role_widget = new sfWidgetFormPropelChoiceMany(array('model' => 'Role', 'method' => 'getTitle')); }
public function executePaymentslist(sfWebRequest $request) { $enrolmentTable = Doctrine_Core::getTable('dsClassStudent'); $this->enrolments_pay_pending = $enrolmentTable->getByPayment(0); $this->getUser()->setFlash('redirect', $request->getUri() ) ; }
/** * Requests are forwarded here when using the ->askConfirmation() * method on the actions class */ public function executeAsk_confirmation(sfWebRequest $request) { if ($this->isAjax()) { $this->setLayout(false); } else { $this->loadAdminTheme(); } $this->url = $request->getUri(); $this->title = $request->getAttribute('title'); $this->message = $request->getAttribute('message'); $this->isAjax = $request->getAttribute('is_ajax'); }
public function executeAccessToken(sfWebRequest $request) { $req = OAuthRequest::from_request(NULL, $request->getUri()); // To get variable in header if ($req->get_parameter('oauth_version') == '1.0') { $oauthServer = new sfoauthserver(new sfOAuthDataStore()); $req = OAuthRequest::from_request(NULL, $request->getUri()); $q = Doctrine::getTable('sfOauthServerRequestToken')->findOneByToken($req->get_parameter('oauth_token')); $this->token = $oauthServer->fetch_access_token($req); if ($q->getUserId() == NULL && $q->getScope()) { throw new OAuthException('Token unauthorized'); } return $this->setTemplate('token'); } else { $q = Doctrine::getTable('sfOauthServerRequestToken')->findOneByToken($request->getParameter('code')); $oauthServer2 = new sfOauth2Server(); $oauthServer2->setUserId($q->getUserId()); $oauthServer2->grantAccessToken($q->getScope()); return sfView::NONE; } }
public function executeExplore(sfWebRequest $request) { $comparator = new Comparator($request->getUri()); $this->simple = $comparator->analyze_link('simple')->results(); $ids = $comparator->getOnlyTrueFeatures(); $this->true = $ids; $this->url = $request->getUri(); $this->goods = Doctrine_Core::getTable('Feature')->GetByIds($ids); if (isset($data['secondary']['false'])) { $this->bads = Doctrine_Core::getTable('Feature')->GetByIds($data['secondary']['false']); } /* First view only */ $this->apps = Doctrine_Core::getTable('Apartment')->createQuery('a')->limit(2)->execute(); }
public function executeDelete(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } $request->checkCSRFProtection(); try { $this->forward404Unless($vocation_class = VocationClassPeer::retrieveByPk($request->getParameter('id')), sprintf('Object vocation_class does not exist (%s).', $request->getParameter('id'))); $vocation_class->delete(); } catch (Exception $e) { $this->getUser()->setFlash('warning', "There are related persons to this vocation. Please remove them first."); } $this->redirect('vocation/index'); }
/** * Renders a form that makes it possible for the user to login * @param sfWebRequest $request */ public function executeLogin(sfWebRequest $request) { //set the referrer used when loggin in. $this->getUser()->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); $this->form = new sfAuthSigninForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('sf_auth_signin')); if ($this->form->isValid()) { $this->getUser()->setFlash('success', $this->getContext()->getI18N()->__('Welcome back :)')); $referer = $this->getUser()->getReferer($request->getReferer()); $this->redirectUnless(empty($referer), $referer); $this->redirect('@homepage'); } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeError404(sfWebRequest $request) { // URI $this->uri = $request->getUri(); // URL $this->url = @current(explode('?', $this->uri)); /* // main site $this->mainSite = Doctrine::getTable('Site')->findOneBySlug('cmais'); // editorials $this->editorials = Doctrine_Query::create() ->select('s.*') ->from('Section s') ->where('s.site_id = ?', $this->mainSite->id) ->andWhere('s.is_active = ?', 1) ->andWhere('s.is_editorial = ?', 1) ->orderBy('s.display_order') ->execute(); // channels $this->channels = array(); $this->live = array(); $this->coming = array(); $this->important = array(); $cs = Doctrine_Query::create() ->select('c.*') ->from('Channel c') ->where('c.is_active = ?', 1) ->orderBy('c.title') ->execute(); foreach($cs as $c){ $this->channels[$c->slug] = $c; $this->live[$c->slug] = $c->retriveLiveProgram(); $this->important[$c->slug] = $c->retriveImportantPrograms(1); $this->coming[$c->slug] = $c->retriveLivePrograms(3,$this->live[$c->slug][0]->getId()); } */ if ($request->getHost() == "culturafm.cmais.com.br") { $this->getResponse()->setTitle('cmais+ O portal de conteúdo da Cultura - Página não encontrada!', false); $this->setTemplate('sites/culturafm/error404', 'default'); } else { $this->getResponse()->setTitle('cmais+ O portal de conteúdo da Cultura - Puxa, puxa que puxa! Não conseguimos encontrar a página...', false); } }
/** * Shows login form * * @param sfRequest $request A request object */ public function executeLogin(sfWebRequest $request) { $form = new sfForm(); $this->csrf_tag = $form['_csrf_token']; if ($request->hasParameter('referer')) { $this->referer = $request->getParameter('referer'); } else { $this->referer = $request->getUri(); } if ($this->getUser()->isAuthenticated()) { if ($this->referer == "http://69.50.211.150/secure/login") { $this->redirect('/dashboard/index'); } else { $this->redirect($this->referer); // } } }
/** * Renders the login dialog, * calls the login action if Shibboleth data is present * or POST data is sent as a fall back, * redirects the user after successful authentication * * @param sfWebRequest $request The current web request. * * @return void */ public function execute($request) { $this->form = new sfForm(); $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); // Redirect to @homepage if the user is already authenticated if ($this->context->user->isAuthenticated()) { $this->redirect('@homepage'); } // Redirect to the current URI in case we're forwarded to the login page $this->form->setDefault('next', $request->getUri()); if ('user' == $request->module && 'login' == $request->action) { // Redirect to our referer otherwise $this->form->setDefault('next', $request->getReferer()); } $apache_params = $request->getPathInfoArray(); $this->form->setValidator('next', new sfValidatorString()); $this->form->setWidget('next', new sfWidgetFormInputHidden()); $this->form->setValidator('email', new sfValidatorEmail(array('required' => true), array('required' => $this->context->i18n->__('You must enter your email address'), 'invalid' => $this->context->i18n->__('This isn\'t a valid email address')))); $this->form->setWidget('email', new sfWidgetFormInput()); $this->form->setValidator('password', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('You must enter your password')))); $this->form->setWidget('password', new sfWidgetFormInputPassword()); if (strlen($apache_params['Shib-Session-Index']) >= 8) { if ($this->context->user->authenticate($apache_params['mail'], '', $request)) { if (null !== ($next = $this->form->getValue('next'))) { $this->redirect($next); } $this->redirect('@homepage'); } } if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { if ($this->context->user->authenticate($this->form->getValue('email'), $this->form->getValue('password'))) { if (null !== ($next = $this->form->getValue('next'))) { $this->redirect($next); } $this->redirect('@homepage'); } $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), 'Sorry, unrecognized email or password')); } } }
/** * Sign In functionality controller */ public function executeSignin(sfWebRequest $request) { if ($request->isMethod('post')) { if ($request->hasParameter('signin')) { $signin = $request->getParameter('signin'); $sUsername = $signin['username']; $sPassword = $signin['password']; $bRemember = isset($signin['remember']); $user = afStudioUser::getInstance()->retrieve($sUsername); if ($user) { if ($user['password'] === sha1($signin['password'])) { afStudioUser::getInstance()->set($sUsername, $sPassword, $bRemember); $signinUrl = $this->getRequest()->getReferer(); $signinUrl = $signinUrl != null ? $signinUrl : url_for('@homepage'); $result = array('success' => true, 'redirect' => $signinUrl, 'load' => 'page'); afsNotificationPeer::log('Successful login', 'afStudioAuth'); } else { $result = array('success' => false, 'message' => 'The username and/or password is invalid. Please try again.'); afsNotificationPeer::log('Failed to get authenticated in the system!', 'afStudioAuth'); } } else { $result = array('success' => false, 'message' => 'The username and/or password is invalid. Please try again.', 'redirect' => '/afsAuthorize/index', 'load' => 'page'); afsNotificationPeer::log('Failed to get authenticated in the system!', 'afStudioAuth'); } } else { $result = array('success' => false, 'message' => 'You were logged out ! You\'ll be redirected to the login page!', 'redirect' => '/afsAuthorize/index', 'load' => 'page'); afsNotificationPeer::log('Successful logout', 'afStudioAuth'); } } else { // if we have been forwarded, then the referer is the current URL // if not, this is the referer of the current request $user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); $module = sfConfig::get('sf_login_module'); if ($this->getModuleName() != $module) { $result = array('success' => false, 'message' => 'You were logged out ! You\'ll be redirected to the login page!', 'redirect' => '/afsAuthorize/index', 'load' => 'page'); afsNotificationPeer::log('Successful logout', 'afStudioAuth'); } } return $this->renderJson($result); }
public function executeSend(sfWebRequest $request) { $this->forward404Unless($request->isMethod('post')); if ($this->getUser()->getApiUserId()) { sfConfig::set('app_recaptcha_active', false); } $this->form = new FeedbackForm(); if ($this->getUser()->getApiUserId()) { unset($this->form['name']); unset($this->form['email']); } $requestData = $request->getParameter($this->form->getName()); if (sfConfig::get('app_recaptcha_active', false)) { $requestData['challenge'] = $this->getRequestParameter('recaptcha_challenge_field'); $requestData['response'] = $this->getRequestParameter('recaptcha_response_field'); } $this->form->bind($requestData); if ($this->form->isValid()) { if ($this->getUser()->getApiUserId()) { $user_data = Api::getInstance()->get('user/' . $this->getUser()->getApiUserId(), true); $user = ApiDoctrine::createQuickObject($user_data['body']); } else { $user = null; } $values = $this->form->getValues(); $name = $this->getUser()->getApiUserId() ? $user->getPreferredName() ? $user->getPreferredName() : $user->getFullName() : $this->form->getValue('name'); $email = $this->getUser()->getApiUserId() ? $user->getEmailAddress() : $this->form->getValue('email'); $signinUrl = $this->getUser()->getReferer($request->getReferer()); $message = $name . ' ' . $email . "\n" . $values['message'] . "\nReferer:" . $signinUrl; $to = ProjectConfiguration::getApplicationFeedbackAddress(); $subjects = sfConfig::get('app_feedback_subjects', array()); $subject = ProjectConfiguration::getApplicationName() . ': ' . (array_key_exists($values['subject'], $subjects) ? $subjects[$values['subject']] : $values['subject']); $from_address = $this->getUser()->getApiUserId() ? "{$name} <{$email}>" : ProjectConfiguration::getApplicationEmailAddress(); AppMail::sendMail($to, $from_address, $subject, $message); $this->getUser()->setFlash('notice', 'Your message has been sent to ' . ProjectConfiguration::getApplicationName() . '.'); return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage'); } $this->getUser()->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); $this->setTemplate('feedback'); }
/** * * @param sfWebRequest $request * @param ProfileForm $form */ protected function processEdit(sfWebRequest $request, ProfileForm $form) { $form->bind($request->getParameter('profile')); if ($form->isValid()) { $values = $form->getValues(); $user = $this->getUser()->getGuardUser(); if ($user->checkPassword($values['current_password'])) { // Set new password into sfGuardUser table if (!empty($values['new_password']) && $values['new_password'] == $values['confirm_new_password']) { $user->setPassword($values['new_password']); } $user->setFirstName($values['first_name']); $user->setLastName($values['last_name']); $user->setEmailAddress($values['email']); $user->save(); // Set referer $this->getUser()->setReferer($request->getUri()); // Redirect to referer $this->redirect($this->getUser()->getReferer()); } } }
/** * Wing add edit * CODE:wing_create */ public function executeUpdate(sfWebRequest $request) { #security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $this->wing = WingPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Wing'; $success = 'Wing has successfully edited!'; } else { $this->wing = new Wing(); $this->title = 'Add Wing'; $success = 'Wing has successfully created!'; } $this->form = new WingForm($this->wing); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('wing')); if ($this->form->isValid() && $this->form->getValue('name')) { $this->wing->setname($this->form->getValue('name')); $this->wing->setNewsletterAbbreviation($this->form->getValue('newsletter_abbreviation')); $this->wing->setDisplayName($this->form->getValue('display_name')); $this->wing->setState($this->form->getValue('state')); if ($this->wing->isNew()) { $content = $this->getUser()->getName() . ' added new Mission type: ' . $this->wing->getName(); ActivityPeer::log($content); } $this->wing->save(); $this->getUser()->setFlash('success', $success); $this->redirect('wing/index'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : 'wing/index'; } $this->wing = $this->wing; }
/** * Execute Login action * * @param sfWebRequest $request A request object */ public function executeLogin(sfWebRequest $request) { $user = $this->getUser(); if ($user->isAuthenticated()) { return $this->redirect('@homepage'); } $this->form = new LoginForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $values = $this->form->getValues(); $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); $signinUrl = $user->getReferer($request->getReferer()); return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage'); } } else { $user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); if ($this->getModuleName() != 'auth') { return $this->redirect('@login'); } $this->getResponse()->setStatusCode(401); } }
/** * * @param sfWebRequest $request * @return type */ public function executeSignin($request) { $user = $this->getUser(); if ($user->isAuthenticated()) { return $this->redirect('@homepage'); } $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin'); $this->form = new $class(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signin')); if ($this->form->isValid()) { $values = $this->form->getValues(); $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); // always redirect to a URL set in app.yml // or to the referer // or to the homepage $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer($request->getReferer())); if (!$request->isXmlHttpRequest()) { return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage'); } } } else { if ($request->isXmlHttpRequest()) { $this->getResponse()->setHeaderOnly(true); $this->getResponse()->setStatusCode(401); return sfView::NONE; } // if we have been forwarded, then the referer is the current URL // if not, this is the referer of the current request $user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); $module = sfConfig::get('sf_login_module'); if ($this->getModuleName() != $module) { return $this->redirect($module . '/' . sfConfig::get('sf_login_action')); } $this->getResponse()->setStatusCode(401); } }
/** * DOCUMENT ME * @param sfWebRequest $request * @return mixed */ public function executeShow(sfWebRequest $request) { $slug = $this->getRequestParameter('slug'); // remove trailing slashes from $slug $pattern = '/\\/$/'; if (preg_match($pattern, $slug) && $slug != '/') { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url')); $new_slug = preg_replace($pattern, '', $slug); $slug = addcslashes($slug, '/'); $new_uri = preg_replace('/' . $slug . '/', $new_slug, $request->getUri()); $this->redirect($new_uri); } if (substr($slug, 0, 1) !== '/') { $slug = "/{$slug}"; } $page = aPageTable::retrieveBySlugWithSlots($slug); if (!$page) { $redirect = Doctrine::getTable('aRedirect')->findOneBySlug($slug); if ($redirect) { $page = aPageTable::retrieveByIdWithSlots($redirect->page_id); return $this->redirect($page->getUrl(), 301); } } aTools::validatePageAccess($this, $page); aTools::setPageEnvironment($this, $page); $this->page = $page; $this->setTemplate($page->template); $tagstring = implode(',', $page->getTags()); if (strlen($tagstring)) { $this->getResponse()->addMeta('keywords', htmlspecialchars($tagstring)); } if (strlen($page->getMetaDescription())) { $this->getResponse()->addMeta('description', $page->getMetaDescription()); } return 'Template'; }
public function executePreview(sfWebRequest $request) { $this->getUser()->setFlash('redirect', $request->getUri() ) ; $message = $this->ds_class_letter->getMessage(); // preview $message->setClassReplacements($this->ds_class); $message->setEnrolmentReplacements( $this->ds_class->getEnrolments()->getFirst() ); $this->subject = $message->getSubjectPreview(); $this->body = $message->getBodyPreview(); if (preg_match("/%(\S+)%/i", $this->body)) { $this->getUser()->setFlash('error', 'Platzhalter nicht gefunden.'); } // $this->ds_class_letter->sendPreview( $this->getMailer(), $this->getController() ); // $this->getUser()->setFlash('notice', 'Diese Vorschau wurde auch per Email verschickt an: '.$this->getUser()->getProfile()->getEmail()); }
/** * Executes search action * * @param sfRequest $request A request object */ public function executeSearch(sfWebRequest $request) { $this->term = $request->getParameter('term'); $this->filter = $request->getParameter('filter'); if ($request->getParameter('site_id') > 0) { $this->search_site = Doctrine::getTable('Site')->findOneById($request->getParameter('site_id')); } if ($this->term == "") { $this->term = "ver todo o conteúdo"; $this->verify = true; } if ($this->term) { //$this->assets = Doctrine_Core::getTable('Asset')->getForLuceneQuery($query); //$this->query = Doctrine_Core::getTable('Asset')->getQueryFromLucene($this->term); //$this->query = Doctrine_Core::getTable('Asset')->getQueryFromLucene($this->term); $type_id = 0; if ($this->filter != "") { if ($this->filter == "content") { $type_id = 1; } elseif ($this->filter == "image") { $type_id = 2; } elseif ($this->filter == "audio") { $type_id = 4; } elseif ($this->filter == "video") { $type_id = 6; } elseif ($this->filter == "program") { $type_id = 100; } } if ($this->term == "ver todo o conteúdo") { if ($type_id > 0) { $this->query = Doctrine_Query::create()->select('a.*')->from('Asset a')->where('a.is_active = 1')->andWhere("a.asset_type_id = ?", $type_id)->orderBy('a.created_at desc')->limit(1000); } elseif ($type_id == 100) { $this->query = Doctrine_Query::create()->select('p.*')->from('Program p')->where('p.is_active = ?', 1)->orderBy('p.title')->limit(1000); } else { $this->query = Doctrine_Query::create()->select('a.*')->from('Asset a')->where('a.is_active = 1')->andWhereIn('a.asset_type_id', array(1, 2, 3, 4, 5, 6, 7))->orderBy('a.created_at desc')->limit(1000); } } elseif ($type_id > 0) { if ($type_id == 100) { $this->query = Doctrine_Query::create()->select('p.*')->from('Program p')->where('p.is_active = ?', 1)->andWhere("p.title like '%" . $this->term . "%' OR p.description like '%" . $this->term . "%'"); $this->query->orderBy('p.title')->limit(100); } else { $this->query = Doctrine_Query::create()->select('a.*')->from('Asset a')->where('a.is_active = 1')->andWhere("a.asset_type_id = ?", $type_id)->andWhere("a.title like '%" . $this->term . "%' OR a.description like '%" . $this->term . "%'"); if ($this->search_site) { $this->query->andWhere("a.site_id = ?", $this->search_site->getId()); } $this->query->orderBy('a.created_at desc')->limit(20); } } else { $this->query = Doctrine_Query::create()->select('a.*')->from('Asset a')->where('a.is_active = 1')->andWhereIn('a.asset_type_id', array(1, 2, 3, 4, 5, 6, 7))->andWhere("a.title like '%" . $this->term . "%' OR a.description like '%" . $this->term . "%'"); if ($this->search_site) { $this->query->andWhere("a.site_id = ?", $this->search_site->getId()); } $this->query->orderBy('a.created_at desc')->limit(20); } // title $this->getResponse()->setTitle('cmais+ O portal de conteúdo da Cultura', false); // pagination if (isset($this->query)) { $items = 10; if ($this->term == "ver todo o conteúdo") { $items = 100; } if ($type_id == 100) { $items = 100; $this->pager = new sfDoctrinePager('Program', $items); } else { $this->pager = new sfDoctrinePager('Asset', $items); } $this->pager->setQuery($this->query); $this->pager->setPage($request->getParameter('page', 1)); $this->pager->init(); } } // URI $this->uri = $request->getUri(); // URL $this->url = @current(explode('?', $this->uri)); // main site $this->mainSite = Doctrine::getTable('Site')->findOneBySlug('cmais'); $this->site = $this->mainSite; $this->type_id = $type_id; // editorials $this->editorials = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', $this->mainSite->id)->andWhere('s.is_active = ?', 1)->andWhere('s.is_editorial = ?', 1)->orderBy('s.display_order')->execute(); // channels $this->channels = array(); $this->live = array(); $this->coming = array(); $this->important = array(); $cs = Doctrine_Query::create()->select('c.*')->from('Channel c')->where('c.is_active = ?', 1)->orderBy('c.title')->execute(); foreach ($cs as $c) { $this->channels[$c->slug] = $c; $this->live[$c->slug] = $c->retriveLiveProgram(); $this->important[$c->slug] = $c->retriveImportantPrograms(1); $this->coming[$c->slug] = $c->retriveLivePrograms(3, $this->live[$c->slug][0]->getId()); //print "<br>>>>".$c->getSlug(); } if (!$this->term) { $this->getResponse()->setTitle('cmais+ O portal de conteúdo da Cultura', false); } else { $this->getResponse()->setTitle('Resultado de busca para "' . $this->term . '" cmais+ O portal de conteúdo da Cultura', false); } if ($this->term == "ver todo o conteúdo" && !$this->verify) { $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . '/tudo'); } else { $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . '/search'); } }
public function executeUploadFile(sfWebRequest $request, $type) { $this->forward404Unless($request->isMethod('POST')); $dest = File::getFilePath($type, $this->course->url, $this->lecture->url, $this->user->username); $this->forms[$type]->getValidator('file')->setOption('path', $dest); $this->forms[$type]->bind($request->getParameter($type), $request->getFiles($type)); if ($this->forms[$type]->isValid()) { $this->forms[$type]->updateObject($this->getObjectData()); $this->forms[$type]->save(); $this->getUser()->setFlash('message', 'Sikeresen feltöltötted a !' . $type); $this->redirect($request->getUri()); } }
/** * CODE: person_create */ public function executeUpdate(sfWebRequest $request) { #Security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } if ($request->getParameter('add_pass') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; if ($request->getParameter('camp_id')) { $this->camp_id = $request->getParameter('camp_id'); } $this->stepped = 1; } if ($request->getParameter('add_pass_iti') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; $this->itine = 1; } if ($request->getParameter('add_cont') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; $this->contact = 1; } if ($request->getParameter('id')) { $this->person = PersonPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit person'; } else { $this->person = new Person(); $this->title = 'Add person'; } # Person Form $this->form = new PersonForm($this->person); $this->back = $request->getReferer(); //session $this->key = $request->getParameter('key'); if (!$this->key) { $this->key = rand(1000, 9999); } if (strstr($request->getReferer(), 'person/view')) { if ($this->person) { //session $referer_session = $this->getUser()->getAttribute('ref'); if (!$referer_session) { $referer_session = array($this->key => array()); $this->getUser()->setAttribute('ref', $referer_session); } elseif (!isset($referer_session[$this->key])) { $a = '@person_view?id=' . $this->person->getId(); $referer_session[$this->key] = array('referer' => $a); $this->getUser()->setAttribute('ref', $referer_session[$this->key]); } } } $this->referer = $request->getParameter('referer'); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('per')); if ($this->form->isValid() && $this->form->getValue('first_name') && $this->form->getValue('last_name')) { $this->person->setTitle($this->form->getValue('title')); $this->person->setFirstName($this->form->getValue('first_name')); $this->person->setLastName($this->form->getValue('last_name')); $this->person->setAddress1($this->form->getValue('address1')); $this->person->setAddress2($this->form->getValue('address2')); $this->person->setCity($this->form->getValue('city')); $this->person->setCounty($this->form->getValue('county')); $this->person->setState($this->form->getValue('state')); $this->person->setCountry($this->form->getValue('country')); $this->person->setZipcode($this->form->getValue('zipcode')); $this->person->setDayPhone($this->form->getValue('day_phone')); $this->person->setDayComment($this->form->getValue('day_comment')); $this->person->setEveningPhone($this->form->getValue('evening_phone')); $this->person->setEveningComment($this->form->getValue('evening_comment')); $this->person->setMobilePhone($this->form->getValue('mobile_phone')); $this->person->setMobileComment($this->form->getValue('mobile_comment')); $this->person->setPagerPhone($this->form->getValue('paper_phone')); $this->person->setPagerComment($this->form->getValue('paper_comment')); $this->person->setOtherPhone($this->form->getValue('other_phone')); $this->person->setOtherComment($this->form->getValue('other_comment')); $this->person->setFaxPhone1($this->form->getValue('fax_phone1')); $this->person->setFaxComment1($this->form->getValue('fax_comment1')); $this->person->setAutoFax($this->form->getValue('auto_fax')); $this->person->setFaxPhone2($this->form->getValue('fax_phone2')); $this->person->setFaxComment2($this->form->getValue('fax_comment2')); $this->person->setEmail($this->form->getValue('email')); $this->person->setEmailTextOnly($this->form->getValue('email_text_only')); $this->person->setEmailBlocked($this->form->getValue('email_blocked')); $this->person->setComment($this->form->getValue('comment')); // $this->person->setBlockMailings($this->form->getValue('block_mailings')==0?null:$this->form->getValue('block_mailings')); $this->person->setBlockMailings($this->form->getValue('block_mailings')); $this->person->setNewsletter($this->form->getValue('newsletter')); $this->person->setGender($this->form->getValue('gender')); $this->person->setDeceased($this->form->getValue('deceased')); $this->person->setDeceasedComment($this->form->getValue('deceased_comment')); $this->person->setSecondaryEmail($this->form->getValue('secondary_email')); $this->person->setDeceasedDate($this->form->getValue('deceased_date')); $this->person->setMiddleName($this->form->getValue('middle_name')); $this->person->setSuffix($this->form->getValue('suffix')); $this->person->setNickname($this->form->getValue('nickname')); $this->person->setVeteran($this->form->getValue('veteran')); if ($this->person->isNew()) { $content = $this->getUser()->getName() . ' added new Person: ' . $this->person->getFirstName(); ActivityPeer::log($content); } $this->person->save(); //////////////////////////////////////#bglobal omar if ($this->person->getId()) { $c = new Criteria(); $c->add(RoleNotificationPeer::MID, 5); $c->add(RoleNotificationPeer::NOTIFICATION, 1); $c->addOr(RoleNotificationPeer::NOTIFICATION, 3); $c->addJoin(RoleNotificationPeer::ROLE_ID, PersonRolePeer::ROLE_ID); $c->addJoin(PersonRolePeer::PERSON_ID, PersonPeer::ID); $personemail = PersonPeer::doSelect($c); $allemail = array(); $pindex = 0; foreach ($personemail as $getEmail) { if (strlen($getEmail->getEmail()) > 0) { $allemail[$pindex++] = $getEmail->getEmail(); } else { if (strlen($getEmail->getSecondaryEmail()) > 0) { $allemail[$pindex++] = $getEmail->getSecondaryEmail(); } } } $allemail[$pindex] = "*****@*****.**"; /* echo "<pre>"; print_r($allemail); echo "</pre>"; */ $email['subject'] = "New Person added"; $link = $request->getHost() . "/person/view/" . $this->person->getId(); $body = "A new person added in " . $request->getHost() . "\r\n" . $this->person->getFirstName() . " " . $this->person->getLastName() . "\r\n Profile Link: " . $link; $email['body'] = $body; $email['sender_email'] = "*****@*****.**"; $this->getComponent('mail', 'sendBulk', array('subject' => $email['subject'], 'recievers' => $allemail, 'sender' => $email['sender_email'], 'body' => $email['body'])); } ///////////////////////////////////// if ($request->hasParameter('has')) { $data = ''; if ($request->getParameter('camp_id')) { $data = '&camp_id=' . $request->getParameter('camp_id'); } $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass='******'has') . '&p_id=' . $this->person->getId() . $data); } if ($request->hasParameter('iti')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass_iti=' . $request->getParameter('iti') . '&p_id=' . $this->person->getId()); } if ($request->hasParameter('contact')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add contact!'); $this->redirect('@contact_create?person_id=' . $this->person->getId()); } $this->getUser()->setFlash('success', 'Person information has been successfully saved!'); $last = $request->getParameter('back'); $referer_session = $this->getUser()->getAttribute('ref'); $back_url = '@person_view?id=' . $this->person->getId(); $this->redirect($back_url); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@person'; } }
/** * Display the form to add a new test session. * * @param sfWebRequest $request */ public function executeAdd(sfWebRequest $request) { $url_prefix = $this->getContext()->getInstance()->getRequest()->getUriPrefix() . $this->getContext()->getInstance()->getRequest()->getRelativeUrlRoot(); // Set referer if (!$request->isMethod("post")) { $route = $this->getContext()->getRouting()->findRoute(MiscUtils::getUri($url_prefix, $this->getUser()->getCurrentReferer())); if (strpos($route["pattern"], "upload") === false) { $this->getUser()->setReferer($request->getUri()); } } // Get referer to set default selected values in form $referer = MiscUtils::getUri($url_prefix, $this->getUser()->getReferer()); $route = $this->getContext()->getRouting()->findRoute($referer); $defaultProject = isset($route['parameters']['project']) ? $route['parameters']['project'] : ""; $defaultProduct = isset($route['parameters']['product']) ? $route['parameters']['product'] : ""; $defaultEnvironment = isset($route["parameters"]["environment"]) ? $route["parameters"]["environment"] : ""; $defaultImage = isset($route["parameters"]["image"]) ? $route["parameters"]["image"] : ""; $defaultBuild = isset($route["parameters"]["build"]) ? $route["parameters"]["build"] : ""; $defaultTestset = isset($route["parameters"]["testset"]) ? $route["parameters"]["testset"] : ""; // Get project group id from project group name defined in app.yml $this->projectGroupId = Doctrine_Core::getTable("sfGuardGroup")->getProjectGroupId(sfConfig::get('app_project_group')); if ($this->projectGroupId == null) { throw new ErrorException("Unable to retrieve project group configuration! Application might need additional configuration or data!", 500); } // Get security level of current user $userSecurityLevel = $this->getUser()->isAuthenticated() ? $userSecurityLevel = $this->getUser()->getGuardUser()->getProfile()->getSecurityLevel() : 0; // Get last build ids $this->lastBuildIds = Doctrine_Core::getTable("TestSession")->getLastBuildIds(); // Get last testsets $this->lastTestsets = Doctrine_Core::getTable("TestSession")->getLastTestsets(); // Get last environments and images used to add sessions (for user experience) $this->lastEnvironments = Doctrine_Core::getTable("TestEnvironment")->getLastEnvironments(); $this->lastImages = Doctrine_Core::getTable("Image")->getLastImages(); $this->mandatoryBuildId = sfConfig::get('app_mandatory_build_id', false); $this->mandatoryTestset = sfConfig::get('app_mandatory_testset', false); // Create a new session form to import test results $this->form = new ImportForm(array(), array("projectGroupId" => $this->projectGroupId, "securityLevel" => $userSecurityLevel, "projectSlug" => $defaultProject, "productSlug" => $defaultProduct, "environmentSlug" => $defaultEnvironment, "imageSlug" => $defaultImage, "buildSlug" => $defaultBuild, "testsetSlug" => $defaultTestset, "mandatoryBuildId" => $this->mandatoryBuildId, "mandatoryTestset" => $this->mandatoryTestset)); // Update list of products when submitting form (to match ajax selection) if (isset($_POST["test_session"])) { $project = Doctrine_Core::getTable("Project")->getBasicProjectById($_POST["test_session"]["project"]); $this->form = new ImportForm(array(), array("projectGroupId" => $this->projectGroupId, "securityLevel" => $userSecurityLevel, "projectSlug" => $project["name_slug"], "productSlug" => $defaultProduct, "environmentSlug" => $defaultEnvironment, "imageSlug" => $defaultImage, "buildSlug" => $defaultBuild, "testsetSlug" => $defaultTestset, "mandatoryBuildId" => $this->mandatoryBuildId, "mandatoryTestset" => $this->mandatoryTestset)); } // Process the form if ($request->isMethod("post")) { $this->processAdd($request, $this->form); } }
/** * Set the referer of the incoming user and show the signin page * * @param sfWebRequest $request */ public function executeSignin($request) { $this->getUser()->setReferer($request->getUri()); parent::executeSignin($request); }
public function executeListEditBulkSentEmail(sfWebRequest $request) { #Security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } $this->max_array = array(5, 10, 20, 30); $this->max = $this->getMaxBulkQueuedEmailValuePerPage($request, $this->max_array); $this->page = $request->getParameter('page', 1); $c = new Criteria(); $c->add(EmailQueuePeer::SEND_STATUS, 'SENT'); $c->addJoin(EmailQueuePeer::LETTER_ID, EmailLetterPeer::ID, Criteria::LEFT_JOIN); $c->setOffset(($this->page - 1) * $this->max); $c->setLimit($this->max); $this->email_letters = EmailLetterPeer::doSelect($c); $this->email_sents = EmailQueuePeer::doSelect($c); $this->pager = EmailQueuePeer::getPager($this->max, $this->page, $c); $this->sent_email_lists = array(); foreach ($this->email_letters as $key => $item) { $this->sent_email_lists[$key]['send_date'] = $this->email_sents[$key]->getSendDate(); $this->sent_email_lists[$key]['subject'] = $item->getSubject(); $this->sent_email_lists[$key]['sender_name'] = $item->getSenderName(); $this->sent_email_lists[$key]['sender_email'] = $item->getSenderEmail(); $this->sent_email_lists[$key]['body'] = $item->getBody(); $this->sent_email_lists[$key]['attach_file_path'] = $item->getAttachFilePath(); $this->sent_email_lists[$key]['recipients'] = explode(',', $item->getRecipients()); if ($key >= $this->max - 1) { break; } } }
public function executeShow(sfWebRequest $request) { $this->ds_person = $this->getRoute()->getObject(); $this->states = Doctrine_Core::getTable('dsClassStudent')->getTypes(); $this->versions = $this->ds_person->getVersions(); $this->enrolments_pending = $this->ds_person->getEnrolmentsByPayment(0); $this->enrolments_paid = $this->ds_person->getEnrolmentsByPayment(1); $this->getUser()->setFlash('redirect', $request->getUri() ); // $this->getUser()->setFlash('redirect', $this->getUser()->getFlash('redirect') ? $this->getUser()->getFlash('redirect') : $request->getUri() );//'ds_contact_show?slug='.$this->ds_person->getSlug() ); }
public function executeStartupData(sfWebRequest $request) { include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php'; $loggedInUser = PcUserPeer::getLoggedInUser(); $this->getUser()->setCulture($loggedInUser->getPreferredLanguage()); $userTodayQuote = null; if ($this->getUser()->getAttribute('user_first_login_of_the_day') === 1) { $userTodayQuote = PcQuoteOfTheDayPeer::getUserTodayQuote(); if ($userTodayQuote === null) { sfErrorNotifier::alert("THERE ARE NOT QUOTES LEFT!!!!!!"); } } $quoteContent = ''; $quoteAuthor = ''; if ($userTodayQuote) { $quoteContent = $userTodayQuote->getQuote(); $quoteContentInItalian = $userTodayQuote->getQuoteInItalian(); $quoteAuthor = $userTodayQuote->getQuoteAuthor(); $quoteAuthorInItalian = $userTodayQuote->getQuoteAuthorInItalian(); if ($loggedInUser->isItalian() && $quoteContentInItalian) { $quoteContent = $quoteContentInItalian; } if ($loggedInUser->isItalian() && $quoteAuthorInItalian) { $quoteAuthor = $quoteAuthorInItalian; } } $apiVersion = sfConfig::get('app_api_version'); $lists = PlancakeApiServer::getLists(array('api_ver' => $apiVersion, 'camel_case_keys' => 1)); $tags = PlancakeApiServer::getTags(array('api_ver' => $apiVersion, 'camel_case_keys' => 1)); $repetitionOptions = PlancakeApiServer::getRepetitionOptions(array('api_ver' => $apiVersion)); $userSettings = PlancakeApiServer::getUserSettings(array('api_ver' => $apiVersion, 'camel_case_keys' => 1)); $breakingNewsId = ''; $breakingNewsHeadline = ''; $breakingNewsLink = ''; if ($breakingNews = $loggedInUser->getBreakingNews()) { $breakingNewsId = $breakingNews->getId(); $breakingNewsHeadline = $breakingNews->getHeadline(); $breakingNewsLink = $breakingNews->getLink(); } $data = array('isPublicRelease' => (int) defined('PLANCAKE_PUBLIC_RELEASE'), 'isFirstDesktopLogin' => (int) $this->getUser()->getAttribute('user_still_to_load_desktop_app'), 'quoteAuthor' => $quoteAuthor, 'quoteContent' => $quoteContent, 'breakingNewsId' => $breakingNewsId, 'breakingNewsHeadline' => $breakingNewsHeadline, 'breakingNewsLink' => $breakingNewsLink, 'showExpiringSubscriptionAlert' => (int) $loggedInUser->isExpiringSubscriptionAlertToShow(), 'isSubscriptionExpired' => (int) $loggedInUser->isSubscriptionExpired()); $config = array('maxListsForFreeAccount' => sfConfig::get('app_site_maxListsForNonSupporter'), 'maxTagsForFreeAccount' => sfConfig::get('app_site_maxTagsForNonSupporter'), 'supportEmailAddress' => sfConfig::get('app_emailAddress_support'), 'custom' => $loggedInUser->getId() == 4 ? 1 : 0); // this 'custom' key is a temporal thing if (stripos($request->getUri(), '/mobile') === FALSE) { // the request doesn't come from the mobile app $this->getUser()->setAttribute('user_still_to_load_desktop_app', 0); } $lang = null; $strings = PcStringPeer::getWebAppStrings(); $i = 0; foreach ($strings as $string) { $lang[$string->getId()] = __($string->getId()); } $startupData = array('hideableHintsSetting' => $loggedInUser->getHideableHintsSetting(), 'lists' => $lists, 'tags' => $tags, 'repetitionOptions' => $repetitionOptions, 'userSettings' => $userSettings, 'data' => $data, 'config' => $config, 'lang' => $lang); if ($request->isXmlHttpRequest()) { return $this->renderJson($startupData); } }
public function executeConfirmation(sfWebRequest $request) { $this->url = $request->getUri(); $this->title = $request->getAttribute('title'); $this->message = $request->getAttribute('message'); }
/** * Searches for requesters * CODE: person_index */ public function executeFind(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } # filter Person Find $this->processFilter2($request); $this->pager = PersonPeer::getNotInRequesterPager($this->max, $this->page, $this->firstname, $this->lastname, $this->gender, $this->city, $this->state, $this->country, $this->county, $this->deceased, $this->deceased_until, $this->deceased_after); $this->persons = $this->pager->getResults(); $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text')); }