public static function decomposeURL(sfContext $context, sfRequest $request) { $module = $context->getModuleName(); $action = $context->getActionName(); $parameters = $request->getParameterHolder()->getAll(); return array("module" => $module, "action" => $action, "parameters" => $parameters); }
/** * Executes link action * * @param sfRequest $request A request object */ public function executeLink($request) { $this->redirectUnless(opConfig::get('enable_friend_link'), '@error'); $this->redirectIf($this->relation->isAccessBlocked(), '@error'); if ($this->relation->isFriend()) { $this->getUser()->setFlash('error', 'This member already belongs to %my_friend%.'); $this->getUser()->setFlash('error_params', array('%my_friend%' => Doctrine::getTable('SnsTerm')->get('my_friend')->pluralize())); $this->redirect('member/profile?id=' . $this->id); } if ($this->relation->isFriendPreFrom()) { $this->getUser()->setFlash('error', '%Friend% request is already sent.'); $this->redirect('member/profile?id=' . $this->id); } $this->form = new FriendLinkForm(); if ($request->isMethod(sfWebRequest::POST)) { $this->form->bind($request->getParameter('friend_link')); if ($this->form->isValid()) { $this->getUser()->setFlash('notice', 'You have requested %friend% link.'); $this->redirectToHomeIfIdIsNotValid(); $this->relation->setFriendPre(); $this->dispatcher->notify(new sfEvent($this, 'op_action.post_execute_' . $this->moduleName . '_' . $this->actionName, array('moduleName' => $this->moduleName, 'actionName' => $this->actionName, 'actionInstance' => $this, 'result' => sfView::SUCCESS))); $this->redirect('member/profile?id=' . $this->id); } } $this->member = Doctrine::getTable('Member')->find($this->id); return sfView::INPUT; }
/** * Executes configUID action * * @param sfRequest $request A request object */ public function executeConfigUID($request) { $option = array('member' => $this->getUser()->getMember()); $this->passwordForm = new sfOpenPNEPasswordForm(array(), $option); $mobileUid = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('mobile_uid', $this->getUser()->getMemberId()); $this->isSetMobileUid = !is_null($mobileUid); $this->isDeletableUid = (int) opConfig::get('retrieve_uid') < 2 && $this->isSetMobileUid; if ($request->isMethod('post')) { $this->passwordForm->bind($request->getParameter('password')); if ($this->passwordForm->isValid()) { if ($request->hasParameter('update')) { $memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('mobile_uid', $this->getUser()->getMemberId()); if (!$memberConfig) { $memberConfig = new MemberConfig(); $memberConfig->setMember($this->getUser()->getMember()); $memberConfig->setName('mobile_uid'); } $memberConfig->setValue($request->getMobileUID()); $memberConfig->save(); $this->getUser()->setFlash('notice', 'Your mobile UID was set successfully.'); $this->redirect('member/configUID'); } elseif ($request->hasParameter('delete') && $this->isDeletableUid) { $mobileUid->delete(); $this->getUser()->setFlash('notice', 'Your mobile UID was deleted successfully.'); $this->redirect('member/configUID'); } } } return sfView::SUCCESS; }
/** * Executes index action * * @param sfRequest $request A request object */ public function execute($request) { sfContext::getInstance()->getConfiguration()->loadHelpers('Url'); $this->editForm = new dayForm(); $this->day = DaysOrderTable::getInstance()->findOneById($this->getRequest()->getParameter('id')); if ($this->day) { $this->editForm->setDefaults($this->day->toArray()); } if ($this->getRequest()->hasParameter('editDay')) { $this->editForm->bind($this->getRequest()->getParameter('editDay'), $this->getRequest()->getFiles('editDay')); if ($this->editForm->isValid()) { $files = $request->getFiles('editDay'); $i = ''; foreach ($files as $key => $file) { if ($file['name']) { $image = new UploadService(); $image->setPath('./uploads/'); $image->setFile($file); $image->setFileName(md5($file['name'] . date('YmdGis')) . '.' . UploadService::findexts($file['name'])); $image->save(); $this->day['image_name' . $i] = $image->getFileName(); } $i = 2; } $this->day->fromArray(array('day_number' => $this->editForm->getValue('day_number'), 'day_tip' => $this->editForm->getValue('day_tip'), 'day_letter' => $this->editForm->getValue('day_letter'))); $this->day->save(); $this->getUser()->setFlash('editSuccess', true); $this->redirect(url_for2('default', array('module' => 'days', 'action' => 'index'))); } } }
/** * Executes this action * * @param sfRequest $request A request object */ public function execute($request) { if ($request->isSmartphone()) { $this->setLayout('smtLayoutSns'); $this->setTemplate('smtUserAgreement'); } }
/** * Executes this action * * @param sfRequest $request A request object */ public function execute($request) { if ($request->isSmartphone()) { $this->setLayout('smtLayoutSns'); $this->setTemplate('smtPrivacyPolicy'); } }
public function executeEdit(sfRequest $request) { $this->logMessage("====== in aInsetAreaSlotActions::executeEdit", "info"); $this->editSetup(); // Work around FCK's incompatibility with AJAX and bracketed field names // (it insists on making the ID bracketed too which won't work for AJAX) // Don't forget, there's a CSRF field out there too. We need to grep through // the submitted fields and get all of the relevant ones, reinventing what // PHP's bracket syntax would do for us if FCK were compatible with it $values = $request->getParameterHolder()->getAll(); $value = array(); foreach ($values as $k => $v) { if (preg_match('/^slot-form-' . $this->id . '-(.*)$/', $k, $matches)) { $value[$matches[1]] = $v; } } $this->form = new aInsetAreaSlotForm($this->id, $this->options); $this->form->bind($value); if ($this->form->isValid()) { $value = $this->form->getValue('value'); $this->slot->value = $value; $result = $this->editSave(); return $result; } else { // Makes $this->form available to the next iteration of the // edit view so that validation errors can be seen return $this->editRetry(); } }
/** * Executes feedback action * */ public function executeFeedback(sfRequest $request) { $section = $request->getParameter('section', false); $this->form = new aFeedbackForm($section); $this->feedbackSubmittedBy = false; $this->failed = false; sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag', 'Url')); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('feedback'), $request->getFiles('feedback')); // $this->form->bind(array_merge($request->getParameter('feedback'), array('captcha' => $request->getParameter('captcha'))), $request->getFiles('feedback')); if ($this->form->isValid()) { $feedback = $this->form->getValues(); $feedback['browser'] = $_SERVER['HTTP_USER_AGENT']; try { aZendSearch::registerZend(); $mail = new Zend_Mail(); $mail->setBodyText($this->getPartial('feedbackEmailText', array('feedback' => $feedback)))->setFrom($feedback['email'], $feedback['name'])->addTo(sfConfig::get('app_aFeedback_email_auto'))->setSubject($this->form->getValue('subject', 'New aBugReport submission')); if ($screenshot = $this->form->getValue('screenshot')) { $mail->createAttachment(file_get_contents($screenshot->getTempName()), $screenshot->getType()); } $mail->send(); // A new form for a new submission $this->form = new aFeedbackForm(); } catch (Exception $e) { $this->logMessage('Request email failed: ' . $e->getMessage(), 'err'); $this->failed = true; return 'Success'; } $this->getUser()->setFlash('reportSubmittedBy', $feedback['name']); $this->redirect($feedback['section']); } } }
/** * DOCUMENT ME * @param sfRequest $request * @return mixed */ public function executeEdit(sfRequest $request) { $this->editSetup(); // Work around FCK's incompatibility with AJAX and bracketed field names // (it insists on making the ID bracketed too which won't work for AJAX) // Don't forget, there's a CSRF field out there too. We need to grep through // the submitted fields and get all of the relevant ones, reinventing what // PHP's bracket syntax would do for us if FCK were compatible with it $values = $request->getParameterHolder()->getAll(); $value = array(); foreach ($values as $k => $v) { if (preg_match('/^slot-form-' . $this->id . '-(.*)$/', $k, $matches)) { $value[$matches[1]] = $v; } } // HTML is carefully filtered to allow only elements, attributes and styles that // make sense in the context of a rich text slot, and you can adjust that. // See aHtml::simplify(). You can do slot-specific overrides by setting the // allowed-tags, allowed-attributes and allowed-styles options $this->form = new aRichTextForm($this->id, $this->options); $this->form->bind($value); if ($this->form->isValid()) { // The form validator took care of validating well-formed HTML // and removing elements, attributes and styles we don't permit $this->slot->value = $this->form->getValue('value'); return $this->editSave(); } else { // Makes $this->form available to the next iteration of the // edit view so that validation errors can be seen (although there // aren't any in this case) return $this->editRetry(); } }
/** * Executes joinlist action * * @param sfRequest $request A request object */ public function executeJoinlist($request) { sfConfig::set('sf_nav_type', 'default'); if ($request->hasParameter('id') && $request->getParameter('id') != $this->getUser()->getMemberId()) { sfConfig::set('sf_nav_type', 'friend'); } return parent::executeJoinlist($request); }
/** * Handles setDefault action * * @param sfRequest $request A request object */ public function executeSetDefault($request) { $c = BadgePeer::retrieveByPK($request->getParameter('id')); if ($c) { $c->setAsDefault(); } $this->redirect('badge/list'); }
/** * Executes delete action * * @param sfRequest $request A redirect object */ public function executeDelete($request) { $request->checkCSRFProtection(); $this->forward404Unless($this->communityEventComment->isDeletable($this->getUser()->getMemberId())); $this->communityEventComment->delete(); $this->getUser()->setFlash('notice', 'The comment was deleted successfully.'); $this->redirect('@communityEvent_show?id=' . $this->communityEvent->getId()); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfRequest $request) { $params = array('filename' => $request->getParameter('filename', null), 'format' => $request->getParameter('format', null), 'width' => str_replace('w', '', $request->getParameter('width', null)), 'height' => str_replace('h', '', $request->getParameter('height', null))); $image = new sfImageHandler($params); $this->forward404Unless($image->isValidSource(), 'Invalid URL.'); $binary = $image->createImage(); header('Content-Type:' . $image->getContentType()); echo $binary; exit; }
/** * Executes login action * * * @param sfRequest $request A request object */ public function executeLogin($request) { $this->form = new LoginForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('login')); if ($this->form->isValid()) { $this->redirect('@homepage'); } } }
/** * @param sfRequest $request * @param jenkinsKhanUser $user * * @return JenkinsGroupRun * @throws RuntimeException */ public function getJenkinsGroupRun(sfRequest $request, jenkinsKhanUser $user) { $branchName = $request->getParameter('git_branch_slug'); $userId = $user->getUserId(); $groupRun = JenkinsGroupRunPeer::retrieveBySfGuardUserIdAndGitBranchSlug($userId, $branchName); if (null === $groupRun) { throw new RuntimeException(sprintf('Can\'t retrieve JenkinsGroupRun with branch name %s for user %s.', $branchName, $user->getUsername())); } return $groupRun; }
/** * * @param sfRequest $request The current sfRequest object * * @return mixed A string containing the view name associated with this action */ function execute($request) { $this->forward404Unless($request->hasParameter('id'), 'id parameter is required'); $jenkinsGroupRun = JenkinsGroupRunPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($jenkinsGroupRun instanceof JenkinsGroupRun, sprintf('Can\'t create JenkinsGroupRun with id %s', $request->getParameter('id'))); //suppression du group run (et, en cascade, des runs) $jenkinsGroupRun->delete(null); $this->getUser()->setFlash('info', sprintf('Build branch [%s] has been deleted', $jenkinsGroupRun->getLabel())); $this->redirect('jenkins/index'); }
/** * * @param sfRequest $request */ public function execute($request) { $this->setForm(new BeaconRegistrationForm()); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $result = $this->form->save(); $this->getUser()->setFlash($result['messageType'], $result['message']); } } }
public function executeEdit(sfRequest $request) { $this->editSetup(); $item = Doctrine::getTable('aMediaItem')->find($request->getParameter('aMediaId')); if (!$item || $item->type !== 'video') { return $this->redirectToPage(); } $this->slot->unlink('MediaItems'); $this->slot->link('MediaItems', array($item->id)); $this->editSave(); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex($request) { $this->form = new reCaptchaForm(); if ($request->isMethod('post')) { $requestData = array('challenge' => $this->getRequestParameter('recaptcha_challenge_field'), 'response' => $this->getRequestParameter('recaptcha_response_field')); $this->form->bind($requestData); if ($this->form->isValid()) { // captcha is valid } } }
/** * Executes insertEntry action * * @param sfRequest $request A request object */ public function executeInsertEntry($request) { $this->result = $this->api->insert($this->api->getEntryXMLFromRequestBody()); $this->forward404Unless($this->result); $params = array('model' => $request->getParameter('model'), 'id' => $this->result->getId()); $url = $this->generateUrl('feeds_community_retrieve_resource_normal', $params, true); $this->getResponse()->setStatusCode(201); $this->getResponse()->setHttpHeader('Location', $url); $entry = $this->api->createEntryByInstance($this->result); return $this->renderText($this->api->convertEmojiForAPI($entry->publish())); }
/** * Execute * * @param sfRequest $request A request object */ public function execute($request) { $user = $this->getUser()->getUserRecord(); $start = $this->getVar('start') ? $this->getVar('start') : $request->getParameter('start', date('Y-m-01')); $start = preg_replace("/(\\d{2})\\.(\\d{2})\\.(\\d{4})/", "\$3-\$2-\$1", $start); $returnJSON = $this->getVar('returnJSON') ? true : false; $budget = new BudgetManager(); $rate = $this->getContext()->getMyCurrencyExchange()->getRate($user->getCurrencyId()); $budgetCategories = $budget->load($user, new DateTime($start)); $this->setVar('budgetCategories', $budgetCategories, $noEscape = true); $this->setVar('returnJSON', $returnJSON); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex($request) { if ($request->hasParameter('show')) { $this->getUser()->setAttribute('show', $request->getParameter('show')); } $this->show = $this->getUser()->getAttribute('show', 'people'); $table = $this->getShowTable($this->show); $this->pager = new sfDoctrinePager($table, sfConfig::get('app_max_entities_on_contacts')); $this->pager->setQuery(Doctrine::getTable($table)->getListQuery()); $this->pager->setPage($request->getParameter('page', 1)); $this->pager->init(); }
/** * Processes the current request. * * @param sfRequest A sfRequest instance * * @return Boolean true if the form is valid, false otherwise */ public function process(sfRequest $request) { $data = array('language' => $request->getParameter('language')); if ($request->hasParameter(self::$CSRFFieldName)) { $data[self::$CSRFFieldName] = $request->getParameter(self::$CSRFFieldName); } $this->bind($data); if ($isValid = $this->isValid()) { $this->save(); } return $isValid; }
/** * Processes the current request. * * @param sfRequest A sfRequest instance * * @return Boolean true if the form is valid, false otherwise */ public function process(sfRequest $request) { $data = array('max_per_page' => $request->getParameter('max_per_page', $this->user->getAttribute(self::getMaxPerPageName(), $this->getDefault('max_per_page')))); if ($request->hasParameter(self::$CSRFFieldName)) { $data[self::$CSRFFieldName] = $request->getParameter(self::$CSRFFieldName); } $this->bind($data); if ($isValid = $this->isValid()) { $this->save(); } return $isValid; }
/** * Redirect process for a failed login * * @param sfRequest $request * @param sfUser $user * @return mixed */ protected function _redirectError($request, $user) { 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()); $this->redirect(sfConfig::get('sf_login_module') . '/' . sfConfig::get('sf_login_action')); }
/** * Executes this action * * @param sfRequest $request A request object */ public function execute($request) { $this->getUser()->setAuthenticated(false); $this->form = new opAdminLoginForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('admin_user')); if ($this->form->isValid()) { $this->getUser()->login($this->form->getValue('adminUser')->getId()); $this->redirect('default/top'); } return sfView::ERROR; } return sfView::SUCCESS; }
/** * Executes deleteLeaveType action * * @param sfRequest $request A request object */ public function execute($request) { if ($request->isMethod('post')) { if (count($request->getParameter('chkSelectRow')) == 0) { $this->getUser()->setFlash('notice', __(TopLevelMessages::SELECT_RECORDS)); } else { $leaveTypeService = $this->getLeaveTypeService(); $leaveTypeIds = $request->getParameter('chkSelectRow'); $leaveTypeService->deleteLeaveType($leaveTypeIds); $this->getUser()->setFlash('success', __(TopLevelMessages::DELETE_SUCCESS)); } $this->redirect('leave/leaveTypeList'); } }
/** * Executes user action * * @param sfRequest $request A request object */ public function executeUser($request) { if (!$request->hasParameter('id')) { $this->member = $this->getUser()->getMember(); } else { $this->member = $this->getRoute()->getObject(); $relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($this->getUser()->getMemberId(), $this->member->getId()); $this->forward404If($relation && $relation->isAccessBlocked()); } $this->blogRssCacheList = Doctrine::getTable('BlogRssCache')->findByMemberId($this->member->getId(), sfConfig::get('app_blog_action_size')); if (!count($this->blogRssCacheList)) { return sfView::ALERT; } }
/** * Executes list action * * @param sfRequest $request A request object */ public function executeList($request) { $this->id = $this->getRequestParameter('id', $this->getUser()->getMemberId()); $this->forward404Unless($this->id === $this->getUser()->getMemberId()); $this->pager = Doctrine::getTable('Ashiato')->getAshiatoListPager($this->id, $request->getParameter('page'), sfConfig::get('mod_ashiato_max_ashiato')); if (!$this->pager->getNbResults()) { return sfView::ERROR; } $this->count = (int) $this->getUser()->getMember()->getConfig('op_ashiato_count'); if (!$this->count) { $this->count = Doctrine::getTable('Ashiato')->getAshiatoMemberListCount($this->id); } return sfView::SUCCESS; }
/** * @param sfRequest $request The current sfRequest object * * @return mixed A string containing the view name associated with this action */ function execute($request) { $runs = JenkinsRunPeer::getDelayed($this->getUser()); $form = new DelayedRunForm(array(), array('runs' => $runs)); $jenkins = $this->getJenkins(); if (sfRequest::POST === $request->getMethod()) { $form->bind($request->getParameter('delayed_run')); if ($form->isValid()) { $messages = array(); foreach ($form->getValue('runs') as $id => $datas) { $run = JenkinsRunPeer::retrieveByPK($id); if ('on' !== $datas['launch_job']) { $run->setLaunchDelayed(null); $run->save(); continue; } $launchAt = null; if (strlen($datas['scheduled_at']) > 0) { $launchAt = strtotime($datas['scheduled_at']); } if (null === $launchAt) { $run->launchDelayed($this->getJenkins()); $messages[] = sprintf('The job [%s] in build branch has been launched', $run->getJobName(), $run->getGitBranch()); } else { $run->setLaunchDelayed($launchAt); $run->save(); $messages[] = sprintf('The job [%s] in build %s branch will be launched at %s ', $run->getJobName(), $run->getGitBranch(), $run->getLaunchDelayed('Y-m-d H:i')); } } $this->getUser()->setFlash('info', $messages); $this->redirect('jenkins/index'); } } $delayedRuns = array(); $durationFormatter = new durationFormatter(); foreach ($runs as $run) { $groupRun = $run->getJenkinsGroupRun(); $parameters = $run->getParameters(); $build = $run->getJenkinsJob($jenkins)->getLastSuccessfulBuild($jenkins); $lastDuration = 0; if (null !== $build) { $lastDuration = $build->getDuration(); } $delayedRuns[$run->getId()] = array('group_run_label' => $groupRun->getLabel(), 'group_run_url' => $this->generateUrl('branch_view', $groupRun), 'group_run_result' => $groupRun->getResult($jenkins), 'last_duration' => $lastDuration, 'parameters' => null === $parameters ? $parameters : json_decode($run->getParameters(), true)); } $this->setVar('form', $form); $this->setVar('delayed_runs', $delayedRuns); $this->setVar('duration_formatter', $durationFormatter); }