public function EditLink($id)
 {
     if ($obj = $this->list->byID($id)) {
         if ($obj->canEdit(Member::currentUser())) {
             return HTTP::setGetVar($this->ID(), $id);
         }
     }
 }
 public function PageLengthLimits()
 {
     $lengths = func_get_args();
     $result = new ArrayList();
     foreach ($lengths as $length) {
         $result->push(new ArrayData(array('PageLength' => $length, 'Link' => HTTP::setGetVar($this->getPaginationGetVar(), 0, HTTP::setGetVar($this->getLengthGetVar(), $length, null, '&')), 'CurrentBool' => $this->getPageLength() == $length || $length == $this->unlimitedLengthText && $this->getPageLength() == $this->unlimitedLength)));
     }
     return $result;
 }
 /**
  * Adds metadata into the URL.
  *
  * @param $url string
  * @param $obj DataObject to inject
  *
  * @return string transformed URL.
  */
 public function addObject($url, DataObject $dataObject)
 {
     $updatedUrl = HTTP::setGetVar('_ID', $dataObject->ID, $url, '&');
     $updatedUrl = HTTP::setGetVar('_ClassName', $dataObject->ClassName, $updatedUrl, '&');
     // Hack: fix the HTTP::setGetVar removing leading slash from the URL if BaseURL is used.
     if (strpos($url, '/') === 0) {
         return '/' . $updatedUrl;
     } else {
         return $updatedUrl;
     }
 }
 /**
  * Action: get list of products for base feed
  * @param SS_HTTPRequest $request
  * @return XML list of GoogleBase products
  */
 function products($request)
 {
     $limit = $request->getVar('limit') ? $request->getVar('limit') : false;
     if (!$limit) {
         $link = Director::absoluteURL(HTTP::setGetVar('limit', 1000));
         die('A Limit is required, please try again using something like: <a href="' . $link . '">' . $link . '</a>');
     }
     $products = $this->ProductList();
     if ($products && $products->Count() > 0) {
         $productsItems = PaginatedList::create($products, $request)->setPageLength($limit)->setPaginationGetVar('start');
         $data = array('FeedTitle' => SiteConfig::current_site_config()->Title, 'FeedLink' => Director::absoluteURL('/'), 'FeedDescription' => 'Google Base Feed', 'Products' => $productsItems);
         return $this->renderWith('GoogleBase', $data);
     }
 }
 /**
  * Tests {@link HTTP::setGetVar()}
  */
 public function testSetGetVar()
 {
     // Hackery to work around volatile URL formats in test invocation,
     // and the inability of Director::absoluteBaseURL() to produce consistent URLs.
     $origURI = $_SERVER['REQUEST_URI'];
     $_SERVER['REQUEST_URI'] = 'relative/url/';
     $this->assertContains('relative/url/?foo=bar', HTTP::setGetVar('foo', 'bar'), 'Omitting a URL falls back to current URL');
     $_SERVER['REQUEST_URI'] = $origURI;
     $this->assertEquals('relative/url?foo=bar', HTTP::setGetVar('foo', 'bar', 'relative/url'), 'Relative URL without existing query params');
     $this->assertEquals('relative/url?baz=buz&amp;foo=bar', HTTP::setGetVar('foo', 'bar', '/relative/url?baz=buz'), 'Relative URL with existing query params, and new added key');
     $this->assertEquals('http://test.com/?foo=new&amp;buz=baz', HTTP::setGetVar('foo', 'new', 'http://test.com/?foo=old&buz=baz'), 'Absolute URL without path and multipe existing query params, overwriting an existing parameter');
     $this->assertContains('http://test.com/?foo=new', HTTP::setGetVar('foo', 'new', 'http://test.com/?foo=&foo=old'), 'Absolute URL and empty query param');
     // http_build_query() escapes angular brackets, they should be correctly urldecoded by the browser client
     $this->assertEquals('http://test.com/?foo%5Btest%5D=one&amp;foo%5Btest%5D=two', HTTP::setGetVar('foo[test]', 'two', 'http://test.com/?foo[test]=one'), 'Absolute URL and PHP array query string notation');
     $urls = array('http://www.test.com:8080', 'http://test.com:3000/', 'http://test.com:3030/baz/', 'http://*****:*****@test.com', 'http://baz@test.com/', 'http://*****:*****@test.com:8080', 'http://baz@test.com:8080');
     foreach ($urls as $testURL) {
         $this->assertEquals($testURL . '?foo=bar', HTTP::setGetVar('foo', 'bar', $testURL), 'Absolute URL and Port Number');
     }
 }
 /**
  * Overrides the ContentControllerSearchExtension and adds snippets to results.
  */
 function results($data, $form, $request)
 {
     $this->linkToAllSiteRSSFeed();
     $results = $form->getResults();
     $query = $form->getSearchQuery();
     // Add context summaries based on the queries.
     foreach ($results as $result) {
         $contextualTitle = new Text();
         $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
         $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);
         if (!$result->Content && $result->ClassName == 'File') {
             // Fake some content for the files.
             $result->ContextualContent = "A file named \"{$result->Name}\" ({$result->Size}).";
         } else {
             $result->ContextualContent = $result->obj('Content')->ContextSummary(300, $query);
         }
     }
     $rssLink = HTTP::setGetVar('rss', '1');
     // Render the result.
     $data = array('Results' => $results, 'Query' => $query, 'Title' => _t('SearchForm.SearchResults', 'Search Results'), 'RSSLink' => $rssLink);
     // Choose the delivery method - rss or html.
     if (!$this->owner->request->getVar('rss')) {
         // Add RSS feed to normal search.
         RSSFeed::linkToFeed($rssLink, "Search results for query \"{$query}\".");
         return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
     } else {
         // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
         $fullList = $results->getList()->sort('LastEdited', 'DESC');
         // Get some descriptive strings
         $siteName = SiteConfig::current_site_config()->Title;
         $siteTagline = SiteConfig::current_site_config()->Tagline;
         if ($siteName) {
             $title = "{$siteName} search results for query \"{$query}\".";
         } else {
             $title = "Search results for query \"{$query}\".";
         }
         // Generate the feed content.
         $rss = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
         $rss->setTemplate('Page_results_rss');
         return $rss->outputToBrowser();
     }
 }
 /**
  * Change the password
  *
  * @param array $data The user submitted data
  */
 function doChangePassword(array $data)
 {
     if ($member = Member::currentUser()) {
         // The user was logged in, check the current password
         if (isset($data['OldPassword']) && $member->checkPassword($data['OldPassword']) == false) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), "bad");
             Director::redirectBack();
             return;
         }
     }
     if (!$member) {
         if (Session::get('AutoLoginHash')) {
             $member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
         }
         // The user is not logged in and no valid auto login hash is available
         if (!$member) {
             Session::clear('AutoLoginHash');
             Director::redirect('loginpage');
             return;
         }
     }
     // Check the new password
     if ($data['NewPassword1'] == $data['NewPassword2']) {
         $isValid = $member->changePassword($data['NewPassword1']);
         if ($isValid->valid()) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.PASSWORDCHANGED', "Your password has been changed, and a copy emailed to you."), "good");
             Session::clear('AutoLoginHash');
             $redirectURL = HTTP::setGetVar('BackURL', urlencode(Director::absoluteBaseURL()), Security::Link('login'));
             Director::redirect($redirectURL);
         } else {
             $this->clearMessage();
             $this->sessionMessage(nl2br("We couldn't accept that password:\n" . $isValid->starredList()), "bad");
             Director::redirectBack();
         }
     } else {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "Your have entered your new password differently, try again"), "bad");
         Director::redirectBack();
     }
 }
 /**
  * @param mixed $subject
  * @throws EntityValidationException
  * @throws NotFoundEntityException
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     if (!$speaker->hasPendingRegistrationRequest()) {
         throw new EntityValidationException('speaker not has a pending registration request!');
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL)->first();
     if (is_null($email)) {
         throw new NotFoundEntityException(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL));
     }
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $summit->getIdentifier())->first();
     if (is_null($schedule_page)) {
         throw new NotFoundEntityException('Summit Schedule page does not exists!');
     }
     // reset token ...
     $registration_request = $speaker->RegistrationRequest();
     $token = $registration_request->generateConfirmationToken();
     $registration_request->write();
     $registration_url = Controller::join_links(Director::baseURL(), 'summit-login', 'registration');
     $registration_url = HTTP::setGetVar(SpeakerRegistrationRequest::ConfirmationTokenParamName, $token, $registration_url);
     $speaker->registerCreateMembershipSent();
     $email = EmailFactory::getInstance()->buildEmail(null, $speaker->getEmail());
     $email->setUserTemplate(PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'Summit' => $summit, 'RegistrationUrl' => $registration_url))->send();
 }
 /**
  * Returns a link to the previous page, if the first page is not currently
  * active.
  *
  * @return string
  */
 public function PrevLink()
 {
     if ($this->NotFirstPage()) {
         return HTTP::setGetVar($this->getPaginationGetVar(), $this->getPageStart() - $this->getPageLength());
     }
 }
 /**
  * Use the CMS domain for iframed CMS previews to prevent single-origin violations
  * and SSL cert problems.
  */
 public function alternatePreviewLink($action = null)
 {
     $url = Director::absoluteURL($this->owner->Link());
     if ($this->owner->SubsiteID) {
         $url = HTTP::setGetVar('SubsiteID', $this->owner->SubsiteID, $url);
     }
     return $url;
 }
 /**
  * returns the URL of the page with a specific
  * index
  * @param int $page
  * @return String
  */
 public function getUrl($page)
 {
     return HTTP::setGetVar($this->paginatedList->getPaginationGetVar(), ($page - 1) * $this->paginatedList->getPageLength());
 }
 /**
  *	Request media page children from the filtered date.
  */
 public function dateFilter()
 {
     // Apply the from date filter.
     $request = $this->getRequest();
     $from = $request->getVar('from');
     $link = $this->Link();
     $separator = '?';
     if ($from) {
         // Determine the formatted URL to represent the request filter.
         $date = new DateTime($from);
         $link .= $date->Format('Y/m/d/');
     }
     // Preserve the category/tag filters if they exist.
     $category = $request->getVar('category');
     $tag = $request->getVar('tag');
     if ($category) {
         $link = HTTP::setGetVar('category', $category, $link, $separator);
         $separator = '&';
     }
     if ($tag) {
         $link = HTTP::setGetVar('tag', $tag, $link, $separator);
     }
     // Allow extension customisation.
     $this->extend('updateFilter', $link);
     // Request the filtered paginated children.
     return $this->redirect($link);
 }
 /**
  *	Attempt to redirect towards the highest priority link mapping that may have been defined.
  *
  *	@URLparameter direct <{BYPASS_LINK_MAPPINGS}> boolean
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     // Bypass the request filter when requesting specific director rules such as "/admin" or "/dev".
     $requestURL = $request->getURL();
     $configuration = Config::inst();
     foreach ($configuration->get('Director', 'rules') as $segment => $controller) {
         // Retrieve the specific director rules.
         if (($position = strpos($segment, '$')) !== false) {
             $segment = rtrim(substr($segment, 0, $position), '/');
         }
         // Determine if the current request matches a specific director rule.
         if ($segment && strpos($requestURL, $segment) === 0) {
             // Continue processing the response.
             return true;
         }
     }
     // Bypass the request filter when using the direct GET parameter.
     if ($request->getVar('direct')) {
         // Continue processing the response.
         return true;
     }
     // Determine the default automated URL handling response status.
     $status = $response->getStatusCode();
     $success = $status >= 200 && $status < 300;
     $error = $status === 404;
     // Either hook into a page not found, or when enforced, replace the default automated URL handling.
     $enforce = $configuration->get('MisdirectionRequestFilter', 'enforce_misdirection');
     $replace = $configuration->get('MisdirectionRequestFilter', 'replace_default');
     if (($error || $enforce || $replace) && ($map = $this->service->getMappingByRequest($request))) {
         // Update the response code where appropriate.
         $responseCode = $map->ResponseCode;
         if ($responseCode == 0) {
             $responseCode = 303;
         } else {
             if ($responseCode == 301 && $map->ForwardPOSTRequest) {
                 $responseCode = 308;
             } else {
                 if ($responseCode == 303 && $map->ForwardPOSTRequest) {
                     $responseCode = 307;
                 }
             }
         }
         // Update the response using the link mapping redirection.
         $response->redirect($map->getLink(), $responseCode);
     } else {
         if ($error && ($fallback = $this->service->determineFallback($requestURL))) {
             // Update the response code where appropriate.
             $responseCode = $fallback['code'];
             if ($responseCode === 0) {
                 $responseCode = 303;
             }
             // Update the response using the fallback, enforcing no further redirection.
             $response->redirect(HTTP::setGetVar('direct', true, Controller::join_links(Director::absoluteBaseURL(), $fallback['link'])), $responseCode);
         } else {
             if (!$error && !$success && $replace) {
                 $response->setStatusCode(404);
                 // Retrieve the appropriate page not found response.
                 ClassInfo::exists('SiteTree') && ($page = ErrorPage::response_for(404)) ? $response->setBody($page->getBody()) : $response->setBody('No URL was matched!');
             }
         }
     }
     // Continue processing the response.
     return true;
 }
Beispiel #14
0
 function BaseLink()
 {
     $link = $this->FormAction() . "&action_callfieldmethod&fieldName={$this->Name()}&ctf[ID]={$this->sourceID()}&methodName=ajax_refresh&SecurityID=" . Session::get('SecurityID');
     if (isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
         $link = HTTP::setGetVar("ctf[{$this->Name()}][sort]", $_REQUEST['ctf'][$this->Name()]['sort']);
     }
     if (isset($_REQUEST['ctf'][$this->Name()]['dir'])) {
         $link = HTTP::setGetVar("ctf[{$this->Name()}][dir]", $_REQUEST['ctf'][$this->Name()]['dir']);
     }
     return str_replace('&amp;', '&', $link);
 }
 /**
  *	Determine the fallback for a URL when the CMS module is present.
  *
  *	@parameter <{URL}> string
  *	@return array(string, integer)
  */
 public function determineFallback($URL)
 {
     // Make sure the CMS module is present.
     if (ClassInfo::exists('SiteTree') && $URL) {
         // Instantiate the required variables.
         $segments = explode('/', self::unify_URL($URL));
         $applicableRule = null;
         $nearestParent = null;
         $thisPage = null;
         $toURL = null;
         $responseCode = 303;
         // Retrieve the default site configuration fallback.
         $config = SiteConfig::current_site_config();
         if ($config && $config->Fallback) {
             $applicableRule = $config->Fallback;
             $nearestParent = $thisPage = Director::baseURL();
             $toURL = $config->FallbackLink;
             $responseCode = $config->FallbackResponseCode;
         }
         // This is required to support multiple sites.
         $parentID = ClassInfo::exists('Multisites') ? Multisites::inst()->getCurrentSiteId() : 0;
         // Determine the page specific fallback.
         $apply = false;
         for ($iteration = 0; $iteration < count($segments); $iteration++) {
             $page = SiteTree::get()->filter(array('URLSegment' => $segments[$iteration], 'ParentID' => $parentID))->first();
             if ($page) {
                 // Determine the home page URL when appropriate.
                 $link = $page->Link() === Director::baseURL() ? Controller::join_links(Director::baseURL(), 'home/') : $page->Link();
                 $nearestParent = $link;
                 // Keep track of the current page fallback.
                 if ($page->Fallback) {
                     $applicableRule = $page->Fallback;
                     $thisPage = $link;
                     $toURL = $page->FallbackLink;
                     $responseCode = $page->FallbackResponseCode;
                 }
                 $parentID = $page->ID;
             } else {
                 // The bottom of the chain has been reached.
                 $apply = true;
                 break;
             }
         }
         // Determine the applicable fallback.
         if ($apply && $applicableRule) {
             $link = null;
             switch ($applicableRule) {
                 case 'Nearest':
                     $link = $nearestParent;
                     break;
                 case 'This':
                     $link = $thisPage;
                     break;
                 case 'URL':
                     $link = $toURL;
                     break;
             }
             if ($link) {
                 return array('link' => self::is_external_URL($link) ? $link : Controller::join_links(Director::baseURL(), HTTP::setGetVar('misdirected', true, $link)), 'code' => (int) $responseCode);
             }
         }
     }
     // No fallback has been found.
     return null;
 }
 /**
  * @return void
  */
 public function doDateReset()
 {
     $params = $this->parseParams(false);
     // Reset the link - only include the tag.
     $link = $this->AbsoluteLink();
     if (isset($params['tag'])) {
         $link = HTTP::setGetVar('tag', $params['tag'], $link, '&');
     }
     $this->redirect($link);
 }
 public function display()
 {
     // We don't want the dashboard to display in the dashboard. This might create problems.
     $excluded = array("SiteDashboardPage");
     // If this call is the result of some javascript, grab the pageID or pageURL.
     $pageID = $this->getRequest()->getVar('pageID');
     $pageURL = $this->getRequest()->getVar('pageURL');
     // Use this pageID, else the pageURL, else fall back to the previously set page name field.
     if (isset($pageID)) {
         $page = Page::get()->byID($pageID);
     } else {
         if (isset($pageURL)) {
             $segments = explode('?', $pageURL);
             $page = Site::get_by_link($segments[0]);
             // If a certain page is excluded, we don't want it to display in the viewing dashlet.
         } else {
             // If a certain page is excluded, we don't want it to display in the viewing dashlet.
             $page = Page::get()->filter(array('Title' => $this->PageName))->first();
         }
     }
     foreach ($excluded as $exclude) {
         if ($page instanceof $exclude) {
             $page = null;
             break;
         }
     }
     // Display the matching page object and render it using the template, falling back on a basic custom template.
     if ($page) {
         // We need to create a controller for the given model.
         $controller = ModelAsController::controller_for($page);
         // Make sure any query parameters carry across.
         if (isset($segments) && isset($segments[1])) {
             $URL = $segments[0];
             $parameters = null;
             parse_str($segments[1], $parameters);
             foreach ($parameters as $parameter => $value) {
                 $URL = HTTP::setGetVar($parameter, $value, $URL);
             }
             $controller->setRequest(new SS_HTTPRequest('GET', $URL, $parameters));
         }
         // If the page is not the launch page, we want to track the interaction.
         if ($page->URLSegment != 'home') {
             $this->interactions->trackInteraction('page-view', $controller->data());
         }
         // Make sure the correct template is used for a media type.
         if ($page->MediaType) {
             $templates[] = "Layout/{$page->ClassName}_{$page->MediaType}";
         }
         $templates[] = "Layout/{$page->ClassName}";
         $templates[] = 'Layout/Page';
         // We want to remove the page wrapper, so we only use the layout directory.
         return $controller->renderWith($templates);
     } else {
         // If we are clicking an invalid page link from our viewing dashlet, we don't want to refresh the dashlet.
         if (isset($pageURL)) {
             return "invalid_page";
         } else {
             return "Please select a valid page.";
         }
     }
 }
	function PrintLink() {
		$link = Controller::join_links($this->Link(), 'printall');
		if(isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
			$link = HTTP::setGetVar("ctf[{$this->Name()}][sort]",Convert::raw2xml($_REQUEST['ctf'][$this->Name()]['sort']), $link);
		}
		return $link;
	}
 /**
  *	Retrieve the redirection URL.
  *
  *	@return string
  */
 public function getLink()
 {
     if ($this->RedirectType === 'Page') {
         // Determine the home page URL when appropriate.
         if (($page = $this->getRedirectPage()) && ($link = $page->Link() === Director::baseURL() ? Controller::join_links(Director::baseURL(), 'home/') : $page->Link())) {
             // This is to support multiple sites, where the absolute page URLs are treated as relative.
             return MisdirectionService::is_external_URL($link) ? ltrim($link, '/') : $link;
         }
     } else {
         // Apply the regular expression pattern replacement.
         if ($link = $this->LinkType === 'Regular Expression' && $this->matchedURL ? preg_replace("%{$this->MappedLink}%i", $this->RedirectLink, $this->matchedURL) : $this->RedirectLink) {
             // When appropriate, prepend the base URL to match a page redirection.
             return MisdirectionService::is_external_URL($link) ? ClassInfo::exists('Multisites') ? HTTP::setGetVar('misdirected', true, $link) : $link : Controller::join_links(Director::baseURL(), $link);
         }
     }
     // No redirection URL has been found.
     return null;
 }
 /**
  * Change the password
  *
  * @param array $data The user submitted data
  * @return SS_HTTPResponse
  */
 public function doChangePassword(array $data)
 {
     /**
      * @var LDAPService $service
      */
     $service = Injector::inst()->get('LDAPService');
     if ($member = Member::currentUser()) {
         try {
             $userData = $service->getUserByGUID($member->GUID);
         } catch (Exception $e) {
             SS_Log::log($e->getMessage(), SS_Log::ERR);
             $this->clearMessage();
             $this->sessionMessage(_t('LDAPAuthenticator.NOUSER', 'Your account hasn\'t been setup properly, please contact an administrator.'), 'bad');
             return $this->controller->redirect($this->controller->Link('changepassword'));
         }
         $loginResult = $service->authenticate($userData['samaccountname'], $data['OldPassword']);
         if (!$loginResult['success']) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), "bad");
             // redirect back to the form, instead of using redirectBack() which could send the user elsewhere.
             return $this->controller->redirect($this->controller->Link('changepassword'));
         }
     }
     if (!$member) {
         if (Session::get('AutoLoginHash')) {
             $member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
         }
         // The user is not logged in and no valid auto login hash is available
         if (!$member) {
             Session::clear('AutoLoginHash');
             return $this->controller->redirect($this->controller->Link('login'));
         }
     }
     // Check the new password
     if (empty($data['NewPassword1'])) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), "bad");
         // redirect back to the form, instead of using redirectBack() which could send the user elsewhere.
         return $this->controller->redirect($this->controller->Link('changepassword'));
     } else {
         if ($data['NewPassword1'] == $data['NewPassword2']) {
             $isValid = $service->setPassword($member, $data['NewPassword1']);
             // try to catch connection and other errors that the ldap service can through
             if ($isValid->valid()) {
                 $member->logIn();
                 Session::clear('AutoLoginHash');
                 // Clear locked out status
                 $member->LockedOutUntil = null;
                 $member->FailedLoginCount = null;
                 $member->write();
                 if (!empty($_REQUEST['BackURL']) && Director::is_site_url($_REQUEST['BackURL'])) {
                     $url = Director::absoluteURL($_REQUEST['BackURL']);
                     return $this->controller->redirect($url);
                 } else {
                     // Redirect to default location - the login form saying "You are logged in as..."
                     $redirectURL = HTTP::setGetVar('BackURL', Director::absoluteBaseURL(), $this->controller->Link('login'));
                     return $this->controller->redirect($redirectURL);
                 }
             } else {
                 $this->clearMessage();
                 $this->sessionMessage($isValid->message(), "bad");
                 // redirect back to the form, instead of using redirectBack() which could send the user elsewhere.
                 return $this->controller->redirect($this->controller->Link('changepassword'));
             }
         } else {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), "bad");
             // redirect back to the form, instead of using redirectBack() which could send the user elsewhere.
             return $this->controller->redirect($this->controller->Link('changepassword'));
         }
     }
 }
 /**
  * Build up search filters from user's search criteria and hand off
  * to the {@link query()} method to search against the database.
  *
  * @param array $data Form request data
  * @param Form Form object for submitted form
  * @param SS_HTTPRequest
  * @return array
  */
 public function doRegistryFilter($data, $form, $request)
 {
     // Basic parameters
     $parameters = array('start' => 0, 'Sort' => 'ID', 'Dir' => 'ASC');
     // Data record-specific parameters
     $singleton = $this->dataRecord->getDataSingleton();
     if ($singleton) {
         $fields = $singleton->getSearchFields();
         if ($fields) {
             foreach ($fields as $field) {
                 $parameters[$field->Name] = '';
             }
         }
     }
     // Read them from the request
     foreach ($parameters as $key => $default) {
         $value = $this->request->getVar($key);
         if (!$value || $value == $default) {
             unset($parameters[$key]);
         } else {
             $parameters[$key] = $value;
         }
     }
     // Link back to this page with the relevant parameters.
     $link = $this->AbsoluteLink();
     foreach ($parameters as $key => $value) {
         $link = HTTP::setGetVar($key, $value, $link, '&');
     }
     $this->redirect($link);
 }
	/**
	 * Returns the URL of the next page.
	 * @return string
	 */
	public function NextLink() {
		if($this->pageStart + $this->pageLength < $this->totalSize) {
			return HTTP::setGetVar($this->paginationGetVar, $this->pageStart + $this->pageLength);
		}
	}
 /**
  * #################################
  *           Pagination
  * #################################
  */
 function PopupBaseLink()
 {
     $link = $this->FormAction() . "&action_callfieldmethod&fieldName={$this->Name()}";
     if (!strpos($link, 'ctf[ID]')) {
         $link = str_replace('&amp;', '&', HTTP::setGetVar('ctf[ID]', $this->sourceID(), $link));
     }
     return $link;
 }
 public function getDateFilterLink()
 {
     return HTTP::setGetVar("Date[{$this->ID}]", 3);
 }
 /**
  * getLinkedTagList
  * Gets a list of tags with links, keeping current year and month request vars
  * @return ArrayList
  **/
 public function getLinkedTagList()
 {
     $link = $this->Link();
     $link = HTTP::setGetVar('year', $this->getCurrentYear(), $link, '&');
     $link = HTTP::setGetVar('month', $this->getCurrentMonth(), $link, '&');
     $tags = $this->data()->getTagList();
     $list = ArrayList::create();
     $currentTag = $this->getCurrentTag();
     $list->push(ArrayData::create(array("Title" => 'All', "Link" => HTTP::setGetVar('tag', null, $link, '&'), "Current" => !$currentTag)));
     foreach ($tags as $tag) {
         $list->push(ArrayData::create(array("Title" => $tag->Title, "Link" => HTTP::setGetVar('tag', $tag->ID, $link, '&'), "Current" => $tag->ID == $currentTag)));
     }
     return $list;
 }
 /**
  * Change the password
  *
  * @param array $data The user submitted data
  */
 function doChangePassword(array $data)
 {
     if ($member = Member::currentUser()) {
         // The user was logged in, check the current password
         if (empty($data['OldPassword']) || !$member->checkPassword($data['OldPassword'])->valid()) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), "bad");
             $this->controller->redirectBack();
             return;
         }
     }
     if (!$member) {
         if (Session::get('AutoLoginHash')) {
             $member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
         }
         // The user is not logged in and no valid auto login hash is available
         if (!$member) {
             Session::clear('AutoLoginHash');
             $this->controller->redirect('loginpage');
             return;
         }
     }
     // Check the new password
     if (empty($data['NewPassword1'])) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), "bad");
         $this->controller->redirectBack();
         return;
     } else {
         if ($data['NewPassword1'] == $data['NewPassword2']) {
             $isValid = $member->changePassword($data['NewPassword1']);
             if ($isValid->valid()) {
                 $member->logIn();
                 // TODO Add confirmation message to login redirect
                 Session::clear('AutoLoginHash');
                 if (isset($_REQUEST['BackURL']) && $_REQUEST['BackURL'] && Director::is_site_url($_REQUEST['BackURL'])) {
                     $this->controller->redirect($_REQUEST['BackURL']);
                 } else {
                     // Redirect to default location - the login form saying "You are logged in as..."
                     $redirectURL = HTTP::setGetVar('BackURL', Director::absoluteBaseURL(), $this->controller->Link('login'));
                     $this->controller->redirect($redirectURL);
                 }
             } else {
                 $this->clearMessage();
                 $this->sessionMessage(_t('Member.INVALIDNEWPASSWORD', "We couldn't accept that password: {password}", array('password' => nl2br("\n" . $isValid->starredList()))), "bad");
                 $this->controller->redirectBack();
             }
         } else {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), "bad");
             $this->controller->redirectBack();
         }
     }
 }
 /**
  * Returns a link to unflag a comment
  *
  * @return string
  */
 public function UnflagLink()
 {
     $link = Controller::join_links('CommentingController', 'unflagcomment', $this->owner->ID);
     return HTTP::setGetVar('token', $this->owner->FlaggedSecurityToken, $link);
 }
 public function Events()
 {
     $event_filter = null;
     $announcement_filter = null;
     $endDate = $this->endDate;
     if ($search = $this->getRequest()->getVar('s')) {
         $s = Convert::raw2sql($search);
         $event_filter = "\"SiteTree\".\"Title\" LIKE '%{$s}%' OR \"SiteTree\".\"Content\" LIKE '%{$s}%'";
         $announcement_filter = "\"CalendarAnnouncement\".\"Title\" LIKE '%{$s}%' OR \"CalendarAnnouncement\".\"Content\" LIKE '%{$s}%'";
         $this->SearchQuery = $search;
         $endDate = sfDate::getInstance()->addMonth($this->DefaultFutureMonths);
     }
     $all = $this->data()->getEventList($this->startDate ? $this->startDate->date() : null, $endDate ? $endDate->date() : null, $event_filter, null, $announcement_filter);
     $all_events_count = $all->count();
     $list = $all->limit($this->EventsPerPage, $this->getOffset());
     $next = $this->getOffset() + $this->EventsPerPage;
     $this->MoreEvents = $next < $all_events_count;
     $this->MoreLink = HTTP::setGetVar("start", $next);
     return $list;
 }
Beispiel #29
0
 /**
  * Handles the registration. Validates and creates the member, then redirects
  * to the appropriate place
  *  
  * @param  array $data
  * @param  BootstrapForm $form
  * @return SSViewer
  */
 public function doRegister($data, $form)
 {
     try {
         Session::set("FormInfo.{$form->getName()}.data", $data);
         $member = Member::get()->filter('Email', $data['Email'])->first();
         if ($member) {
             $form->sessionMessage('Bah! We\'ve already got a user with that email.', 'bad');
             return $this->redirectBack();
         }
         if ($data['Password'] != $data['Password_confirm']) {
             $form->sessionMessage('Passwords do not match.', 'bad');
             return $this->redirectBack();
         }
         $member = Member::create(array('FirstName' => $data['FirstName'], 'Surname' => $data['Surname'], 'Email' => $data['Email'], 'Password' => $data['Password']));
         $member->write();
         if (!empty($data[SpeakerRegistrationRequest::ConfirmationTokenParamName])) {
             $speaker_registration_token = $data[SpeakerRegistrationRequest::ConfirmationTokenParamName];
             $this->speaker_registration_request_manager->confirm($speaker_registration_token, $member);
         }
         $member->addToGroupByCode('speakers');
         $member->sendWelcomeEmail();
         Session::clear("FormInfo.{$form->getName()}.data");
         if ($data['BackURL']) {
             $redirect = HTTP::setGetVar('welcome', 1, $data['BackURL']);
             return OpenStackIdCommon::loginMember($member, $redirect);
         }
         $form->sessionMessage('Awesome! You should receive an email shortly.', 'good');
         return OpenStackIdCommon::loginMember($member, $this->redirectBackUrl());
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::WARN);
         return $this->httpError(404, $ex->getMessage());
     }
 }
 public function index(SS_HTTPRequest $request)
 {
     $properties = Property::get();
     $filters = ArrayList::create();
     if ($search = $request->getVar('Keywords')) {
         $filters->push(ArrayData::create(array('Label' => "Keywords: '{$search}'", 'RemoveLink' => HTTP::setGetVar('Keywords', null))));
         $properties = $properties->filter(array('Title:PartialMatch' => $search));
     }
     if ($arrival = $request->getVar('ArrivalDate')) {
         $arrivalStamp = strtotime($arrival);
         $nightAdder = '+' . $request->getVar('Nights') . ' days';
         $startDate = date('Y-m-d', $arrivalStamp);
         $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp));
         $properties = $properties->filter(array('AvailableStart:GreaterThanOrEqual' => $startDate, 'AvailableEnd:LessThanOrEqual' => $endDate));
     }
     if ($bedrooms = $request->getVar('Bedrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bedrooms} bedrooms", 'RemoveLink' => HTTP::setGetVar('Bedrooms', null))));
         $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms));
     }
     if ($bathrooms = $request->getVar('Bathrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bathrooms} bathrooms", 'RemoveLink' => HTTP::setGetVar('Bathrooms', null))));
         $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Min. \${$minPrice}", 'RemoveLink' => HTTP::setGetVar('MinPrice', null))));
         $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Max. \${$maxPrice}", 'RemoveLink' => HTTP::setGetVar('MaxPrice', null))));
         $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s');
     return array('Results' => $paginatedProperties, 'ActiveFilters' => $filters);
 }