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


PHP Member::currentUserID方法代码示例

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


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

示例1: __construct

	/**
	 * Constructor
	 *
	 * @param Controller $controller The parent controller, necessary to
	 *                               create the appropriate form action tag.
	 * @param string $name The method on the controller that will return this
	 *                     form object.
	 * @param FieldSet|FormField $fields All of the fields in the form - a
	 *                                   {@link FieldSet} of {@link FormField}
	 *                                   objects.
	 * @param FieldSet|FormAction $actions All of the action buttons in the
	 *                                     form - a {@link FieldSet} of
	 *                                     {@link FormAction} objects
	 * @param bool $checkCurrentUser If set to TRUE, it will be checked if a
	 *                               the user is currently logged in, and if
	 *                               so, only a logout button will be rendered
	 * @param string $authenticatorClassName Name of the authenticator class that this form uses.
	 */
	function __construct($controller, $name, $fields = null, $actions = null,
											 $checkCurrentUser = true) {

		// This is now set on the class directly to make it easier to create subclasses
		// $this->authenticator_class = $authenticatorClassName;

		$customCSS = project() . '/css/member_login.css';
		if(Director::fileExists($customCSS)) {
			Requirements::css($customCSS);
		}
		
		// Focus on the email input when the page is loaded
		Requirements::customScript("
			(function($){
				$(document).ready(function() {
					$('#Email input').focus();
				});
			})(jQuery);
		");

		if(isset($_REQUEST['BackURL'])) {
			$backURL = $_REQUEST['BackURL'];
		} else {
			$backURL = Session::get('BackURL');
		}

		if($checkCurrentUser && Member::currentUserID()) {
			$fields = new FieldSet();
			$actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
		} else {
			if(!$fields) {
				$fields = new FieldSet(
					new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
					new TextField("Email", _t('Member.EMAIL', 'Email'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
					new PasswordField("Password", _t('Member.PASSWORD', 'Password'))
				);
				if(Security::$autologin_enabled) {
					$fields->push(new CheckboxField(
						"Remember", 
						_t('Member.REMEMBERME', "Remember me next time?")
					));
				}
			}
			if(!$actions) {
				$actions = new FieldSet(
					new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")),
					new LiteralField(
						'forgotPassword',
						'<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'
					)
				);
			}
		}

		if(isset($backURL)) {
			$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
		}

		parent::__construct($controller, $name, $fields, $actions);
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:78,代码来源:MemberLoginForm.php

示例2: Link

 /**
  * If profile editing is disabled, but the current user can add members,
  * just link directly to the add action.
  *
  * @param string $action
  */
 public function Link($action = null)
 {
     if (!$action && Member::currentUserID() && !$this->AllowProfileEditing && $this->CanAddMembers()) {
         $action = 'add';
     }
     return parent::Link($action);
 }
开发者ID:SilbinaryWolf,项目名称:silverstripe-memberprofiles,代码行数:13,代码来源:MemberProfilePage.php

示例3: onBeforeWrite

 /**
  * Set the owner automatically if needed
  */
 protected function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->OwnerID) {
         $this->OwnerID = Member::currentUserID();
     }
 }
开发者ID:markguinn,项目名称:silverstripe-wishlist,代码行数:10,代码来源:WishList.php

示例4: 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

示例5: load

 public function load($request)
 {
     $response = new SS_HTTPResponse();
     $response->addHeader('Content-Type', 'application/json');
     $response->setBody(Convert::array2json(array("_memberID" => Member::currentUserID())));
     return $response;
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:KeepAliveField.php

示例6: getCMSFields

 public function getCMSFields()
 {
     $fields = new FieldList();
     $_REQUEST['entity_survey'] = 1;
     $fields->add(new TextField('EntityName', 'Entity Name (Without Spaces)'));
     $fields->add(new CheckboxField('Enabled', 'Is Enabled?'));
     $fields->add(new CheckboxField('UseTeamEdition', 'Allow Team Edition?'));
     $fields->add(new HiddenField('CreatedByID', 'CreatedByID', Member::currentUserID()));
     $fields->add(new HiddenField('ParentID', 'ParentID'));
     //steps
     if ($this->ID > 0) {
         $_REQUEST['survey_template_id'] = $this->ID;
         // steps
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('SurveyRegularStepTemplate' => 'Regular Step'));
         $config->addComponent($multi_class_selector);
         $config->addComponent(new GridFieldSortableRows('Order'));
         $gridField = new GridField('Steps', 'Steps', $this->Steps(), $config);
         $fields->add($gridField);
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $migration_mapping_types = array('OldDataModelSurveyMigrationMapping' => 'Old Survey Data Mapping');
         $multi_class_selector->setClasses($migration_mapping_types);
         $config->addComponent($multi_class_selector);
         $gridField = new GridField('MigrationMappings', 'Migration Mappings', $this->MigrationMappings(), $config);
         $fields->add($gridField);
     }
     return $fields;
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:32,代码来源:EntitySurveyTemplate.php

示例7: Link

 /**
  * If profile editing is disabled, but the current user can add members,
  * just link directly to the add action.
  *
  * @param string $action
  */
 public function Link($action = null)
 {
     if (!$action && Member::currentUserID() && !$this->AllowProfileEditing && $this->AllowAdding && singleton('Member')->canCreate()) {
         $action = 'add';
     }
     return parent::Link($action);
 }
开发者ID:newsplash,项目名称:silverstripe-memberprofiles,代码行数:13,代码来源:MemberProfilePage.php

示例8: init

 public function init()
 {
     if (!Member::currentUserID() || !Permission::check($this->config()->access_permission)) {
         return Security::permissionFailure($this);
     }
     parent::init();
 }
开发者ID:nyeholt,项目名称:silverstripe-pixlr,代码行数:7,代码来源:PixlrController.php

示例9: init

 public function init()
 {
     parent::init();
     if (!Member::currentUserID()) {
         $this->redirect('Security/login?BackURL=' . $this->getRequest()->getVar('url'));
     }
 }
开发者ID:robert-h-curry,项目名称:retronaut,代码行数:7,代码来源:SecureController.php

示例10: validateStep

 public function validateStep($data, $form)
 {
     Session::set("FormInfo.{$form->FormName()}.data", $form->getData());
     $payment = $data['PaymentMethod'];
     $tickets = $this->getForm()->getSavedStepByClass('EventRegisterTicketsStep');
     $total = $tickets->getTotal();
     $registration = $this->form->getSession()->getRegistration();
     if (!is_subclass_of($payment, 'Payment')) {
         return false;
     }
     $payment = new $payment();
     $payment->Amount = $total;
     $payment->PaidForClass = 'EventRegistration';
     $payment->PaidForID = $registration->ID;
     $payment->PaidBy = Member::currentUserID();
     $payment->write();
     $registration->PaymentID = $payment->ID;
     $registration->write();
     $result = $payment->processPayment($data, $form);
     if ($result->isProcessing()) {
         throw new SS_HTTPResponse_Exception($result->getValue());
     }
     if (!$result->isSuccess()) {
         $form->sessionMessage($result->getValue(), 'required');
         return false;
     }
     // Write an empty registration object so we have an ID to reference the
     // payment against. This will be populated in the form's finish() method.
     $registration->Status = 'Valid';
     $registration->write();
     Session::set("EventRegistration.{$registration->ID}.message", strip_tags($payment->Message));
     return true;
 }
开发者ID:tim-lar,项目名称:silverstripe-eventmanagement,代码行数:33,代码来源:EventRegisterPaymentStep.php

示例11: init

 /**
  * Controller inititalisation
  * Check if user is logged in, if not redirect to login form
  */
 public function init()
 {
     parent::init();
     if (!Member::currentUserID()) {
         Security::permissionFailure();
     }
 }
开发者ID:helpfulrobot,项目名称:colymba-silverstripe-private-assets,代码行数:11,代码来源:PrivateAssetsController.php

示例12: onBeforeSave

 public function onBeforeSave()
 {
     parent::onBeforeSave();
     if (!$this->ID) {
         $this->AuthorID = Member::currentUserID();
     }
 }
开发者ID:halkyon,项目名称:silverstripe-ecommerce_experiment,代码行数:7,代码来源:OrderStatusLog.php

示例13: updateEditForm

 /**
  *	Display the current security token (allowing regeneration for an administrator).
  */
 public function updateEditForm(&$form)
 {
     // Determine whether the security section is being used.
     if ($this->owner instanceof SecurityAdmin) {
         $gridfield = null;
         foreach ($form->fields->items[0]->Tabs()->first()->Fields() as $field) {
             if ($field instanceof GridField) {
                 $gridfield = $field;
                 break;
             }
         }
     } else {
         $gridfield = $form->fields->items[0];
     }
     if (isset($gridfield) && $gridfield instanceof GridField) {
         // Restrict the security token to administrators.
         $user = Member::currentUserID();
         if (Permission::checkMember($user, 'ADMIN')) {
             Requirements::css(APIWESOME_PATH . '/css/apiwesome.css');
             // Display a confirmation message when regenerating the security token.
             Requirements::javascript(APIWESOME_PATH . '/javascript/apiwesome.js');
             $configuration = $gridfield->config;
             $configuration->addComponent(new APIwesomeTokenView());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:29,代码来源:APIwesomeTokenExtension.php

示例14: __construct

 /**
  * Constructor
  *
  * @param Controller $controller The parent controller, necessary to
  *                               create the appropriate form action tag.
  * @param string $name The method on the controller that will return this
  *                     form object.
  * @param FieldSet|FormField $fields All of the fields in the form - a
  *                                   {@link FieldSet} of {@link FormField}
  *                                   objects.
  * @param FieldSet|FormAction $actions All of the action buttons in the
  *                                     form - a {@link FieldSet} of
  *                                     {@link FormAction} objects
  * @param bool $checkCurrentUser If set to TRUE, it will be checked if a
  *                               the user is currently logged in, and if
  *                               so, only a logout button will be rendered
  */
 function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $this->authenticator_class = 'MemberAuthenticator';
     $customCSS = project() . '/css/member_login.css';
     if (Director::fileExists($customCSS)) {
         Requirements::css($customCSS);
     }
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     if ($checkCurrentUser && Member::currentUserID()) {
         $fields = new FieldSet();
         $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("Email", _t('Member.EMAIL'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new EncryptField("Password", _t('Member.PASSWORD'), null, $this), new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?"), Session::get('SessionForms.MemberLoginForm.Remember'), $this));
         }
         if (!$actions) {
             $actions = new FieldSet(new FormAction("dologin", _t('Member.BUTTONLOGIN', "Log in")), new FormAction("forgotPassword", _t('Member.BUTTONLOSTPASSWORD', "I've lost my password")));
         }
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
开发者ID:ramziammar,项目名称:websites,代码行数:45,代码来源:MemberLoginForm.php

示例15: login

 /**
  * Attempt to login
  * @param {stdClass} $data Data passed from ActionScript
  * @return {array} Returns a standard response array
  */
 public function login($data)
 {
     $response = CodeBank_ClientAPI::responseBase();
     $response['login'] = true;
     //Try to login
     $member = MemberAuthenticator::authenticate(array('Email' => $data->user, 'Password' => $data->pass));
     if ($member instanceof Member && $member->ID != 0 && Permission::check('CODE_BANK_ACCESS', 'any', $member)) {
         try {
             $member->logIn();
             $ipAgrement = CodeBankConfig::CurrentConfig()->IPAgreement;
             //Get preferences
             $prefs = new stdClass();
             $prefs->heartbeat = $member->UseHeartbeat;
             //Set the response to HELO
             $response['status'] = 'HELO';
             $response['message'] = _t('CodeBankAPI.WELCOME_USER', '_Welcome {user}', array('user' => htmlentities($member->Name)));
             //Set the message to "Welcome ...."
             $response['data'] = array('id' => Member::currentUserID(), 'hasIPAgreement' => !empty($ipAgrement), 'preferences' => $prefs, 'isAdmin' => Permission::check('ADMIN') !== false, 'displayName' => trim($member->Name) == '' ? $member->Email : trim($member->Name));
         } catch (Exception $e) {
             //Something happend on the server
             $response['status'] = 'EROR';
             $response['message'] = _t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
         }
     } else {
         //Bad username/pass combo
         $response['status'] = 'EROR';
         $response['message'] = _t('CodeBankAPI.INVALID_LOGIN', '_Invalid Login');
     }
     return $response;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:35,代码来源:CodeBankSessionManager.php


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