当前位置: 首页>>代码示例>>PHP>>正文


PHP Member::currentUser方法代码示例

本文整理汇总了PHP中Member::currentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Member::currentUser方法的具体用法?PHP Member::currentUser怎么用?PHP Member::currentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Member的用法示例。


在下文中一共展示了Member::currentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generatePrintData

 /**
  * Export core
  *
  * Replaces definition in GridFieldPrintButton
  * same as original except sources data from $gridField->getList() instead of $gridField->getManipulatedList()
  *
  * @param GridField
  */
 public function generatePrintData(GridField $gridField)
 {
     $printColumns = $this->getPrintColumnsForGridField($gridField);
     $header = null;
     if ($this->printHasHeader) {
         $header = new ArrayList();
         foreach ($printColumns as $field => $label) {
             $header->push(new ArrayData(array("CellString" => $label)));
         }
     }
     // The is the only variation from the parent class, using getList() instead of getManipulatedList()
     $items = $gridField->getList();
     $itemRows = new ArrayList();
     foreach ($items as $item) {
         $itemRow = new ArrayList();
         foreach ($printColumns as $field => $label) {
             $value = $gridField->getDataFieldValue($item, $field);
             $itemRow->push(new ArrayData(array("CellString" => $value)));
         }
         $itemRows->push(new ArrayData(array("ItemRow" => $itemRow)));
         $item->destroy();
     }
     $ret = new ArrayData(array("Title" => $this->getTitle($gridField), "Header" => $header, "ItemRows" => $itemRows, "Datetime" => SS_Datetime::now(), "Member" => Member::currentUser()));
     return $ret;
 }
开发者ID:mandrew,项目名称:silverstripe-securityreport,代码行数:33,代码来源:GridFieldPrintReportButton.php

示例2: index

 /**
  * Ensure all root requests go to login
  * @return SS_HTTPResponse
  */
 public function index()
 {
     if (Member::currentUser()) {
         return $this->redirect($this->Link('directory'));
     }
     return $this->redirect('/Security/login/?BackURL=/summit-admin');
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:11,代码来源:SummitAppAdminController.php

示例3: Save

 /**
  * @param $data
  * @param $form
  * @return bool|SS_HTTPResponse|void
  * @throws ValidationException
  * @throws null
  */
 public function Save($data, $form)
 {
     /** @var Form $form */
     $data = $form->getData();
     if ($CurrentMember = Member::currentUser()) {
         if ($member = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
             $form->addErrorMessage('Email', 'Sorry, that Email already exists.', 'validation');
             return $this->controller->redirectBack();
         } else {
             /** If no password don't save the field */
             if (!isset($data['password'])) {
                 unset($data['password']);
             }
             $this->controller->setFlash('Your profile has been updated', 'success');
             $form->saveInto($CurrentMember);
             $CurrentMember->write();
             return $this->controller->redirect($this->controller->Link());
         }
     } else {
         /** Get registration page otherwise display warning.
          *
          * @var RegistrationPage $registerPage
          */
         if ($registerPage = DataObject::get_one('RegistrationPage')) {
             return Security::PermissionFailure($this->controller, 'You must <a href="' . $registerPage->Link() . '">registered</a> and logged in to edit your profile.');
         } else {
             $this->controller->setFlash('You must registered and logged in to edit your profile.', 'warning');
             return $this->controller->redirect(Director::absoluteBaseURL());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:ryanpotter-silverstripe-boilerplate,代码行数:38,代码来源:EditProfileForm.php

示例4: edit

 public function edit()
 {
     $member = Member::currentUser();
     $this->customise(array("ClassName" => "AccountPage", "Form" => $this->EditAccountForm()->loadDataFrom($member)));
     $this->extend("onBeforeEdit");
     return $this->renderWith(array("UserAccount_edit", "UserAccount", "Page"));
 }
开发者ID:spekulatius,项目名称:silverstripe-users,代码行数:7,代码来源:Users_Account_Controller.php

示例5: updateCMSFields

 /**
  * Adds token creation fields to CMS
  * 
  * @param FieldSet $fields
  * @return void
  */
 public function updateCMSFields(FieldSet &$fields)
 {
     // Only modify file objects with parent nodes
     if (!$this->owner instanceof Folder || !$this->owner->ID) {
         return;
     }
     // Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
     if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) {
         return;
     }
     // Update Security Tab
     $secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security'));
     $secureFilesTab->push(new HeaderField(_t('SecureFiles.TOKENACCESSTITLE', 'Token Access')));
     if (!$this->owner->containsFiles()) {
         $secureFilesTab->push(new ReadonlyField('DummyTokenList', '', _t('SecureFiles.NOFILESINFOLDER', 'There are no files in this folder.')));
         return;
     }
     $secureFilesTab->push($tokenList = new ComplexTableField($this->owner, 'ContainedFileTokens', 'SecureFileAccessToken', null, null, "File.ParentID = '{$this->owner->ID}'", $sourceSort = null, "JOIN File ON FileID = File.ID"));
     $tokenList->setParentIdName('FolderID');
     $tokenList->setRelationAutoSetting(false);
     // Remove add link if there are no files in this folder
     if (!$this->owner->containsFiles()) {
         $tokenList->setPermissions(array('edit', 'delete'));
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-securefiles,代码行数:31,代码来源:SecureFileTokenPermissionDecorator.php

示例6: validateStep

 /**
  * This does not actually perform any validation, but just creates the
  * initial registration object.
  */
 public function validateStep($data, $form)
 {
     $form = $this->getForm();
     $datetime = $form->getController()->getDateTime();
     $confirmation = $datetime->Event()->RegEmailConfirm;
     $registration = $this->getForm()->getSession()->getRegistration();
     // If we require email validation for free registrations, then send
     // out the email and mark the registration. Otherwise immediately
     // mark it as valid.
     if ($confirmation) {
         $email = new Email();
         $config = SiteConfig::current_site_config();
         $registration->TimeID = $datetime->ID;
         $registration->Status = 'Unconfirmed';
         $registration->write();
         if (Member::currentUserID()) {
             $details = array('Name' => Member::currentUser()->getName(), 'Email' => Member::currentUser()->Email);
         } else {
             $details = $form->getSavedStepByClass('EventRegisterTicketsStep');
             $details = $details->loadData();
         }
         $link = Controller::join_links($this->getForm()->getController()->Link(), 'confirm', $registration->ID, '?token=' . $registration->Token);
         $regLink = Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token);
         $email->setTo($details['Email']);
         $email->setSubject(sprintf('Confirm Registration For %s (%s)', $datetime->getTitle(), $config->Title));
         $email->setTemplate('EventRegistrationConfirmationEmail');
         $email->populateTemplate(array('Name' => $details['Name'], 'Registration' => $registration, 'RegLink' => $regLink, 'Title' => $datetime->getTitle(), 'SiteConfig' => $config, 'ConfirmLink' => Director::absoluteURL($link)));
         $email->send();
         Session::set("EventRegistration.{$registration->ID}.message", $datetime->Event()->EmailConfirmMessage);
     } else {
         $registration->Status = 'Valid';
         $registration->write();
     }
     return true;
 }
开发者ID:tardinha,项目名称:silverstripe-eventmanagement,代码行数:39,代码来源:EventRegisterFreeConfirmationStep.php

示例7: init

 public function init()
 {
     parent::init();
     $member = Member::currentUser();
     $this->member = $member;
     $request = $this->getRequest();
     //echo $request->getVar('test');
     //Setting dates based on request variables
     //We could add some sanity check herre
     $this->start = $request->getVar('start');
     $this->end = $request->getVar('end');
     if ($request->getVar('allDay') == 'true') {
         $this->allDay = true;
     }
     //Setting event based on request vars
     if (($eventID = (int) $request->getVar('eventID')) && $eventID > 0) {
         $event = Event::get()->byID($eventID);
         if ($event && $event->exists()) {
             if ($event->ClassName == 'PrivateEvent') {
                 //Only show private events to their owners
                 if ($event->OwnerID == $member->ID) {
                     $this->event = $event;
                 }
             } else {
                 $this->event = $event;
             }
         }
     }
 }
开发者ID:andrewandante,项目名称:silverstripe-calendar,代码行数:29,代码来源:FullcalendarController.php

示例8: validateData

 /**
  * @param Order $order
  * @param array $data
  *
  * @throws ValidationException
  */
 public function validateData(Order $order, array $data)
 {
     $result = ValidationResult::create();
     $existingID = !empty($data[$this->addresstype . "AddressID"]) ? (int) $data[$this->addresstype . "AddressID"] : 0;
     if ($existingID) {
         // If existing address selected, check that it exists in $member->AddressBook
         if (!Member::currentUserID() || !Member::currentUser()->AddressBook()->byID($existingID)) {
             $result->error("Invalid address supplied", $this->addresstype . "AddressID");
             throw new ValidationException($result);
         }
     } else {
         // Otherwise, require the normal address fields
         $required = parent::getRequiredFields($order);
         $addressLabels = singleton('Address')->fieldLabels(false);
         foreach ($required as $fieldName) {
             if (empty($data[$fieldName])) {
                 // attempt to get the translated field name
                 $fieldLabel = isset($addressLabels[$fieldName]) ? $addressLabels[$fieldName] : $fieldName;
                 $errorMessage = _t('Form.FIELDISREQUIRED', '{name} is required', array('name' => $fieldLabel));
                 $result->error($errorMessage, $fieldName);
                 throw new ValidationException($result);
             }
         }
     }
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:31,代码来源:AddressBookCheckoutComponent.php

示例9: updateCMSFields

 /**
  * standard SS function - we dont need to show the Wish List field in the CMS.
  */
 function updateCMSFields(&$fields)
 {
     $fields->removeByName("WishList");
     $member = Member::currentUser();
     if ($member && $member->IsAdmin()) {
         $html = "";
         $array = unserialize($this->owner->WishList);
         $links = array();
         if (is_array($array) && count($array)) {
             foreach ($array as $item) {
                 $object = DataObject::get_by_id($item[0], $item[1]);
                 if ($object) {
                     $links[] = "<a href=\"" . $object->Link() . "\">" . $object->Title . "</a>";
                 } else {
                     $links[] = "error in retrieving object " . implode(", ", $item);
                 }
             }
         } else {
             $links[] = "no items on wishlist";
         }
         $html = "<ul><li>" . implode("</li><li>", $links) . "</li></ul>";
         $field = new LiteralField("WishListOverview", $html);
         $fields->addFieldToTab("Root.WishList", $field);
     } else {
         $fields->removeByName("WishList");
     }
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-wishlist,代码行数:30,代码来源:WishListMemberDecorator.php

示例10: save_address

 /**
  * If the flag has been set from the provided array, create a new
  * address and assign to the current user.
  *
  * @param $data Form data submitted
  */
 private function save_address($data)
 {
     $member = Member::currentUser();
     // If the user ticked "save address" then add to their account
     if ($member && array_key_exists('SaveAddress', $data) && $data['SaveAddress']) {
         // First save the details to the users account if they aren't set
         // We don't save email, as this is used for login
         $member->FirstName = $member->FirstName ? $member->FirstName : $data['FirstName'];
         $member->Surname = $member->Surname ? $member->Surname : $data['Surname'];
         $member->Company = $member->Company ? $member->Company : $data['Company'];
         $member->PhoneNumber = $member->PhoneNumber ? $member->PhoneNumber : $data['PhoneNumber'];
         $member->write();
         $address = MemberAddress::create();
         $address->Company = $data['Company'];
         $address->FirstName = $data['FirstName'];
         $address->Surname = $data['Surname'];
         $address->Address1 = $data['Address1'];
         $address->Address2 = $data['Address2'];
         $address->City = $data['City'];
         $address->PostCode = $data['PostCode'];
         $address->Country = $data['Country'];
         $address->OwnerID = $member->ID;
         $address->write();
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-checkout,代码行数:31,代码来源:BillingDetailsForm.php

示例11: canCreate

 /**
  * @param Member $member
  * @return boolean
  */
 public function canCreate($member = null)
 {
     if (!$member) {
         $member = Member::currentUser();
     }
     return false || Permission::check('ADMIN', 'any', $member) || Permission::check('CMS_ACCESS_AdvancedReportsAdmin', 'any', $member);
 }
开发者ID:helpfulrobot,项目名称:maldicore-advancedreports,代码行数:11,代码来源:RelatedReport.php

示例12: changePassword

 /**
  * @param string $token
  * @param string $password
  * @param string $password_confirmation
  * @throws InvalidResetPasswordTokenException
  * @throws EmptyPasswordException
  * @throws InvalidPasswordException
  * @throws PasswordMismatchException
  */
 public function changePassword($token, $password, $password_confirmation)
 {
     $member = Member::currentUser();
     if (!$member) {
         if (empty($token)) {
             throw new InvalidResetPasswordTokenException();
         }
         $member = Member::member_from_autologinhash($token);
     }
     if (!$member) {
         throw new InvalidResetPasswordTokenException();
     }
     if (empty($password)) {
         throw new EmptyPasswordException();
     }
     if ($password !== $password_confirmation) {
         throw new PasswordMismatchException();
     }
     $isValid = $member->changePassword($password);
     if (!$isValid->valid()) {
         throw new InvalidPasswordException($isValid->starredList());
     }
     //invalidate former auto login token
     $member->generateAutologinTokenAndStoreHash();
     //send confirmation email
     $email = EmailFactory::getInstance()->buildEmail(CHANGE_PASSWORD_EMAIL_FROM, $member->Email, CHANGE_PASSWORD_EMAIL_SUBJECT);
     $email->setTemplate('ChangedPasswordEmail');
     $email->populateTemplate(array('MemberName' => $member->getFullName()));
     $email->send();
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:39,代码来源:PasswordManager.php

示例13: initialValue

 /**
  * @return mixed
  */
 public function initialValue()
 {
     if (Member::currentUser()) {
         return Member::currentUser()->Email;
     }
     return '';
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:10,代码来源:SurveyMemberEmailQuestionTemplate.php

示例14: init

 /**
  * Initialise the controller
  */
 public function init()
 {
     parent::init();
     if (!Member::currentUser() || !Member::currentUser()->IsAdmin()) {
         $this->redirect('cloud/index');
     }
 }
开发者ID:andrelohmann,项目名称:vagrant-cloud,代码行数:10,代码来源:BoxAdminController.php

示例15: testAccessingStageWithBlankStage

	function testAccessingStageWithBlankStage() {
		$this->useDraftSite(false);
		$this->autoFollowRedirection = false;
		
		$page = $this->objFromFixture('Page', 'draftOnlyPage');

		if($member = Member::currentUser()) {
			$member->logOut();
		}
		
		$response = $this->get($page->URLSegment . '?stage=Live');
		$this->assertEquals($response->getStatusCode(), '404');
		
		$response = $this->get($page->URLSegment . '?stage=');
		$this->assertEquals($response->getStatusCode(), '404');
		
		// should be prompted for a login
		$response = $this->get($page->URLSegment . '?stage=Stage');
		$this->assertEquals($response->getStatusCode(), '302');
		$this->assertContains('Security/login', $response->getHeader('Location'));
		
		$this->logInWithPermission('ADMIN');
		
		$response = $this->get($page->URLSegment . '?stage=Live');
		$this->assertEquals($response->getStatusCode(), '404');
		
		$response = $this->get($page->URLSegment . '?stage=Stage');
		$this->assertEquals($response->getStatusCode(), '200');
		
		$response = $this->get($page->URLSegment . '?stage=');
		$this->assertEquals($response->getStatusCode(), '404');
	}
开发者ID:redema,项目名称:silverstripe-cms,代码行数:32,代码来源:SiteTreePermissionsTest.php


注:本文中的Member::currentUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。