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


PHP Member::currentMember方法代码示例

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


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

示例1: onBeforeWrite

	/**
	 * These actions are performed when write() is called on this object.
	 */
	public function onBeforeWrite() {
		// save submitter if a Member is logged in
		$currentMember = Member::currentMember();
		if(!$this->SubmitterID && $currentMember) $this->SubmitterID = $currentMember->ID;
		
		parent::onBeforeWrite();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:10,代码来源:MultiFormSession.php

示例2: getModifierForm

    public function getModifierForm($optionalController = null, $optionalValidator = null)
    {
        $fields = new FieldSet();
        $fields->push($this->headingField());
        $fields->push($this->descriptionField());
        $orderID = Session::get('RepeatOrder');
        $createLink = RepeatOrdersPage::get_repeat_order_link('createorder');
        if ($orderID && Member::currentMember()) {
            $order = DataObject::get_by_id('RepeatOrder', $orderID);
            $updateLink = RepeatOrdersPage::get_repeat_order_link('update', $orderID);
            $cancelLink = RepeatOrdersPage::get_repeat_order_link('cancel', $orderID);
            if ($order->CanModify()) {
                $fields->push(new LiteralField('modifyRepeatOrder', <<<HTML
\t\t\t\t\t<div class="Actions"><input id="ModifyRepeatOrderUpdate"  class="action" type="button" value="Save changes to your Repeat Order #{$orderID}" onclick="window.location='{$updateLink}';" /></div>
HTML
));
            } else {
                $fields->push(new LiteralField('createRepeatOrder', <<<HTML
\t\t\t\t\t\t<div class="Actions"><input id="ModifyRepeatOrderCreate" class="action" type="button" value="Create a new Repeat Order" onclick="window.location='{$createLink}';" /></div>
HTML
));
            }
            Requirements::customScript("jQuery(document).ready(function(){jQuery(\"input[name='action_processOrder']\").hide();});", "hide_action_processOrder");
        } else {
            if (Member::currentMember()) {
                if (!Session::get("DraftOrderID")) {
                    $fields->push(new LiteralField('createRepeatOrder', <<<HTML
\t\t\t\t\t<div class="Actions"><input  id="ModifyRepeatOrderCreate" class="action" type="button" value="Turn this Order into a Repeat Order" onclick="window.location='{$createLink}';" /></div>
HTML
));
                    $page = DataObject::get_one("RepeatOrdersPage");
                    if ($page) {
                        $fields->push(new LiteralField("whatAreRepeatOrders", <<<HTML
\t\t\t\t\t<div id="WhatAreRepeatOrders">{$page->WhatAreRepeatOrders}</div>
HTML
));
                    }
                } else {
                    $fields->push(new LiteralField("whatAreRepeatOrders", <<<HTML
\t\t\t\t\t<div id="WhatAreRepeatOrders">This order is based on a Repeat Order.</div>
HTML
));
                }
            } else {
                $page = DataObject::get_one("RepeatOrdersPage");
                if ($page) {
                    $fields->push(new LiteralField("whatAreRepeatOrders", <<<HTML
\t\t\t\t\t<div id="WhatAreRepeatOrders">{$page->OnceLoggedInYouCanCreateRepeatOrder}</div>
HTML
));
                }
            }
        }
        return new RepeatOrderModifier_Form($optionalController, 'RepeatOrderModifier', $fields, new FieldSet(), $optionalValidator);
    }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-repeatorders,代码行数:55,代码来源:RepeatOrderModifier.php

示例3: onBeforeWrite

	function onBeforeWrite() {
		if(!$this->ID) {
			$category = $this->JobCategory();
			$this->notifySubscribers($category->Subscribers());	
			
			$currentMember = Member::currentMember();
			if($currentMember) $this->AuthorID = $currentMember->ID;
		}

		parent::onBeforeWrite();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:11,代码来源:Job.php

示例4: __construct

 function __construct($controller, $name)
 {
     Requirements::javascript(ECOMMERCE_DIR . '/javascript/OrderFormWithoutShippingAddress.js');
     parent::__construct($controller, $name);
     //stop people adding different shipping address
     $this->unsetActionByName("action_useDifferentShippingAddress");
     $this->unsetActionByName("useDifferentShippingAddress");
     $member = Member::currentMember();
     if (!$member || !$member->ID || $member->Password == '') {
         $this->fields->addFieldToTab("", new LiteralField('MemberInfoAlso', '<p class="message good LoginCallToAction">' . self::get_login_invite_alternative_text() . '</p>', $this), "FirstName");
         //improve password field TEMPORARY HACK!
         //$passwordField = new OptionalConfirmedPasswordField('Password', 'Password', '', null, true);
         //$passwordField->minLength = 6;
         //$passwordField->showOnClickTitle = "add password now";
         //$this->fields->replaceField("Password", $passwordField);
         Requirements::javascript(ECOMMERCE_DIR . '/javascript/OptionalConfirmedPasswordField.js');
         Requirements::block(SAPPHIRE_DIR . '/javascript/ConfirmedPasswordField.js');
     }
     $this->fields->removeFieldFromTab("RightOrder", "MemberInfo");
     //add extra fields
     foreach (self::$extra_fields as $fieldCombo) {
         $fieldCombo["FieldObject"]->setForm($this);
         $this->fields->addFieldToTab($fieldCombo["TabName"], $fieldCombo["FieldObject"]);
     }
     //replace field for address
     foreach ($this->fields->dataFields() as $i => $child) {
         if (is_object($child)) {
             $name = $child->Name();
             switch ($name) {
                 case "Membership Details":
                     $child->setTitle('Retain Personal Details with Password');
                     break;
                 case "Address":
                     $child->setTitle('Street Address');
                     break;
                 case "AddressLine2":
                     $child->setRightTitle('<a href="' . self::$postal_code_url . '" id="OrderFormWithoutShippingAddressPostalCodeLink">' . self::$postal_code_label . '</a>');
                     $child->setTitle('Postal Code');
                     break;
                 case "Country":
                     if (self::$fixed_country_code) {
                         $child->setValue(self::$fixed_country_code);
                         ShoppingCart::set_country(self::$fixed_country_code);
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     $this->fields->addFieldToTab("", new TextareaField('CustomerOrderNote', 'Note / Question', 7, 30, null, $this));
     $data = $this->getData();
     $this->loadDataFrom($data);
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:54,代码来源:OrderFormWithoutShippingAddress.php

示例5: validate

 /** PHP Validation **/
 function validate($validator)
 {
     $string = $this->value;
     $validator = new NZGovtPasswordValidator();
     $member = Member::currentMember();
     if (!$member) {
         $member = new Member();
         $member->ID = 0;
     }
     $outcome = $validator->validate($string, $member);
     if ($outcome->valid()) {
         return true;
     } else {
         $validator->validationError($this->name, "There is a problem with your password: it needs to contain at least seven characters including at least one uppercase, lowercase, digit and one punctuation character (e.g. Hu#9iowD is a valid password and Abababaa is not).", "validation");
         return false;
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-form-fields,代码行数:18,代码来源:NZGovtPasswordValidatorPasswordField.php

示例6: authenticate

 /**
  * Authentication is handled by Facebook rather than us this needs to 
  * return the new member object which is created. Creation of the member
  * is handled by {@link FacebookConnect::onBeforeInt()}
  *
  * @return false|Member
  */
 public static function authenticate($RAW_data, Form $form = null)
 {
     return ($member = Member::currentMember()) ? $member : false;
 }
开发者ID:helpfulrobot,项目名称:wilr-silverstripe-facebookconnect,代码行数:11,代码来源:FacebookAuthenticator.php

示例7: authenticate

 /**
  * Authenticates the user.
  *
  * @return bool|Member
  *
  * @author Sascha Koehler <skoehler@pixeltricks.de>
  * @since 2013-02-22
  */
 protected function authenticate()
 {
     $serverAuth = $this->checkServerLoginCredentials();
     if (!$serverAuth) {
         if ($member = Member::currentMember()) {
             return $member;
         } else {
             return false;
         }
     }
     $member = MemberAuthenticator::authenticate(array('Email' => $serverAuth['PHP_AUTH_USER'], 'Password' => $serverAuth['PHP_AUTH_PW']), null);
     if ($member) {
         $member->LogIn(false);
         return $member;
     } else {
         return false;
     }
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:26,代码来源:SilvercartRestfulServer.php

示例8: workOutMessagesAndActions


//.........这里部分代码省略.........
                     if ($checkoutPageLink && $this->currentOrder && $this->currentOrder->Items()) {
                         $this->actionLinks->push(new ArrayData(array("Title" => $this->ProceedToCheckoutLabel, "Link" => $checkoutPageLink)));
                     }
                 }
             }
         }
         //view account details
         if (isset($this->ShowAccountLabel) && $this->ShowAccountLabel) {
             if ($this->isOrderConfirmationPage() || $this->isCartPage()) {
                 if (AccountPage::find_link()) {
                     if ($currentUserID) {
                         $this->actionLinks->push(new ArrayData(array("Title" => $this->ShowAccountLabel, "Link" => AccountPage::find_link())));
                     }
                 }
             }
         }
         //go to current order
         if (isset($this->CurrentOrderLinkLabel) && $this->CurrentOrderLinkLabel) {
             if ($this->isCartPage()) {
                 if (!$viewingRealCurrentOrder) {
                     $this->actionLinks->push(new ArrayData(array("Title" => $this->CurrentOrderLinkLabel, "Link" => ShoppingCart::current_order()->Link())));
                 }
             }
         }
         //Save order - we assume only current ones can be saved.
         if (isset($this->SaveOrderLinkLabel) && $this->SaveOrderLinkLabel) {
             if ($viewingRealCurrentOrder) {
                 if ($currentUserID && $this->currentOrder->MemberID == $currentUserID) {
                     if ($this->isCartPage()) {
                         if ($this->currentOrder && $this->currentOrder->Items() && !$this->currentOrder->IsSubmitted()) {
                             $this->actionLinks->push(new ArrayData(array("Title" => $this->SaveOrderLinkLabel, "Link" => $this->Link("saveorder") . "/" . $this->currentOrder->ID . "/")));
                         }
                     }
                 }
             }
         }
         //load order
         if (isset($this->LoadOrderLinkLabel) && $this->LoadOrderLinkLabel) {
             if ($this->isCartPage() && $this->currentOrder) {
                 if (!$viewingRealCurrentOrder) {
                     $this->actionLinks->push(new ArrayData(array("Title" => $this->LoadOrderLinkLabel, "Link" => $this->Link("loadorder") . "/" . $this->currentOrder->ID . "/")));
                 }
             }
         }
         //delete order
         if (isset($this->DeleteOrderLinkLabel) && $this->DeleteOrderLinkLabel) {
             if ($this->isCartPage() && $this->currentOrder) {
                 if (!$viewingRealCurrentOrder) {
                     $this->actionLinks->push(new ArrayData(array("Title" => $this->DeleteOrderLinkLabel, "Link" => $this->Link("deleteorder") . "/" . $this->currentOrder->ID . "/")));
                 }
             }
         }
         //Start new order
         //Strictly speaking this is only part of the
         //OrderConfirmationPage but we put it here for simplicity's sake
         if (isset($this->StartNewOrderLinkLabel) && $this->StartNewOrderLinkLabel) {
             if ($this->isOrderConfirmationPage()) {
                 $this->actionLinks->push(new ArrayData(array("Title" => $this->StartNewOrderLinkLabel, "Link" => CartPage::new_order_link())));
             }
         }
         //copy order
         //Strictly speaking this is only part of the
         //OrderConfirmationPage but we put it here for simplicity's sake
         if (isset($this->CopyOrderLinkLabel) && $this->CopyOrderLinkLabel) {
             if ($this->isOrderConfirmationPage() && $this->currentOrder->ID) {
                 $this->actionLinks->push(new ArrayData(array("Title" => $this->CopyOrderLinkLabel, "Link" => OrderConfirmationPage::new_order_link($this->currentOrder->ID))));
             }
         }
         //actions from modifiers
         if ($this->isOrderConfirmationPage() && $this->currentOrder->ID) {
             $modifiers = $this->currentOrder->OrderModifiers();
             if ($modifiers) {
                 foreach ($modifiers as $modifier) {
                     $array = $modifier->PostSubmitAction();
                     if (is_array($array) && count($array)) {
                         $this->actionLinks->push(new ArrayData($array));
                     }
                 }
             }
         }
         //log out
         //Strictly speaking this is only part of the
         //OrderConfirmationPage but we put it here for simplicity's sake
         if (Member::currentMember()) {
             if ($this->isOrderConfirmationPage()) {
                 $this->actionLinks->push(new ArrayData(array("Title" => _t("CartPage.LOGOUT", "log out"), "Link" => "/Security/logout/")));
             }
         }
         //no items
         if ($this->currentOrder) {
             if (!$this->currentOrder->Items()) {
                 $this->message = $this->NoItemsInOrderMessage;
             }
         } else {
             $this->message = $this->NonExistingOrderMessage;
         }
         $this->workedOutMessagesAndActions = true;
         //does nothing at present....
     }
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:101,代码来源:CartPage.php

示例9: CreateOrReturnExistingMember

 /**
  * Returns a member linked to the order.
  * If a member is already linked, it will return the existing member.
  * Otherwise it will return a new Member.
  *
  * Any new member is NOT written, because we dont want to create a new member unless we have to!
  * We will not add a member to the order unless a new one is created in the checkout
  * OR the member is logged in / logs in.
  *
  * Also note that if a new member is created, it is not automatically written
  * @param Boolean $forceCreation - if set to true then the member will always be saved in the database.
  * @return: DataObject (Member)
  **/
 public function CreateOrReturnExistingMember($forceCreation = false)
 {
     if ($this->MemberID) {
         $member = $this->Member();
     } elseif ($member = Member::currentMember()) {
         if (!$member->IsShopAdmin()) {
             $this->MemberID = $member->ID;
             $this->write();
         }
     }
     $member = $this->Member();
     if (!$member) {
         $member = new Member();
     }
     if ($member && $forceCreation) {
         $member->write();
     }
     return $member;
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:32,代码来源:Order.php

示例10: authenticate

 protected function authenticate()
 {
     if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
         return false;
     }
     if ($member = Member::currentMember()) {
         return $member;
     }
     $member = MemberAuthenticator::authenticate(array('Email' => $_SERVER['PHP_AUTH_USER'], 'Password' => $_SERVER['PHP_AUTH_PW']), null);
     if ($member) {
         $member->LogIn(false);
         return $member;
     } else {
         return false;
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:16,代码来源:RestfulServer.php

示例11: createnewbusinesslistingfrompoint

 function createnewbusinesslistingfrompoint($request)
 {
     if (!isset($_GET["address"])) {
         $addressArray = array();
         $address = '';
     } else {
         $addressArray = unserialize($_GET["address"]);
         $address = $addressArray["address"];
     }
     if (!isset($_GET["name"])) {
         $name = '';
     } else {
         $name = Convert::raw2xml($_GET["name"]);
     }
     if (!isset($_GET["parent"])) {
         $parent = 0;
     } else {
         $parent = intval($_GET["parent"]);
     }
     if ($member = Member::currentMember()) {
         if ($name) {
             if ($parent && ($parentPage = DataObject::get_by_id("SiteTree", $parent))) {
                 if ($address && count($addressArray)) {
                     $allowedParents = BusinessPage::get_can_be_child_off();
                     if (is_array($allowedParents) && in_array($parentPage->ClassName, $allowedParents)) {
                         $extension = '';
                         if (Versioned::current_stage() == "Live") {
                             $extension = "_Live";
                         }
                         $page = DataObject::get_one("BusinessPage", "ParentID = " . $parentPage->ID . " AND SiteTree{$extension}.Title = '" . Convert::raw2sql($name) . "'");
                         if ($page) {
                             //do nothing
                         } else {
                             $page = new BusinessPage();
                             $page->Title = $name;
                             $page->MenuTitle = $name;
                             $page->MetaTitle = $name;
                             $page->Email = $member->Email;
                             $page->ParentID = $parentPage->ID;
                             $page->writeToStage('Stage');
                             $page->publish('Stage', 'Live');
                             $page->flushCache();
                             $page->Members()->add($member);
                             $member->addToGroupByCode(BusinessPage::get_member_group_code());
                         }
                         $point = new GoogleMapLocationsObject();
                         $point->addDataFromArray($addressArray);
                         $point->ParentID = $page->ID;
                         $point->write();
                         Director::redirect($page->Link());
                         return;
                     } else {
                         Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find correct parent page type ")));
                         return;
                     }
                 } else {
                     Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find address page.")));
                     return;
                 }
             } else {
                 Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find parent page.")));
                 return;
             }
         }
         Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find listing name.")));
         return;
     } else {
         Security::permissionFailure($this, "You must have an account and be logged in to create new a new listing.");
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-business-directory,代码行数:70,代码来源:AddBusinessPage.php

示例12: hasMainSitePermission

 static function hasMainSitePermission($member = null, $permissionCodes = array('ADMIN'))
 {
     if (!is_array($permissionCodes)) {
         user_error('Permissions must be passed to Subsite::hasMainSitePermission as an array', E_USER_ERROR);
     }
     if (!$member && $member !== FALSE) {
         $member = Member::currentMember();
     }
     if (!$member) {
         return false;
     }
     if (!in_array("ADMIN", $permissionCodes)) {
         $permissionCodes[] = "ADMIN";
     }
     $SQLa_perm = Convert::raw2sql($permissionCodes);
     $SQL_perms = join("','", $SQLa_perm);
     $memberID = (int) $member->ID;
     $groupCount = DB::query("\n\t\t\tSELECT COUNT(\"Permission\".\"ID\")\n\t\t\tFROM \"Permission\"\n\t\t\tINNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Permission\".\"GroupID\" AND \"Group\".\"AccessAllSubsites\" = 1\n\t\t\tINNER JOIN \"Group_Members\" ON \"Group_Members\".\"GroupID\" = \"Permission\".\"GroupID\"\n\t\t\tWHERE \"Permission\".\"Code\" IN ('{$SQL_perms}')\n\t\t\tAND \"MemberID\" = {$memberID}\n\t\t")->value();
     return $groupCount > 0;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:20,代码来源:Subsite.php

示例13: BlogEntryForm

 /**
  * A simple form for creating blog entries
  */
 function BlogEntryForm()
 {
     if (!Permission::check('BLOGMANAGEMENT')) {
         return Security::permissionFailure();
     }
     $id = 0;
     if ($this->request->latestParam('ID')) {
         $id = (int) $this->request->latestParam('ID');
     }
     $codeparser = new BBCodeParser();
     $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
     if (BlogEntry::$allow_wysiwyg_editing) {
         $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
     } else {
         $contentfield = new CompositeField(new LiteralField("BBCodeHelper", "<a id=\"BBCodeHint\" target='new'>" . _t("BlogEntry.BBH") . "</a><div class='clear'><!-- --></div>"), new TextareaField("BlogPost", _t("BlogEntry.CN"), 20), new LiteralField("BBCodeTags", "<div id=\"BBTagsHolder\">" . $codeparser->useable_tagsHTML() . "</div>"));
     }
     if (class_exists('TagField')) {
         $tagfield = new TagField('Tags', null, null, 'BlogEntry');
         $tagfield->setSeparator(', ');
     } else {
         $tagfield = new TextField('Tags');
     }
     $field = 'TextField';
     if (!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
         $field = 'ReadonlyField';
     }
     $fields = new FieldSet(new HiddenField("ID", "ID"), new TextField("Title", _t('BlogHolder.SJ', "Subject")), new $field("Author", _t('BlogEntry.AU'), $membername), $contentfield, $tagfield, new LiteralField("Tagsnote", " <label id='tagsnote'>" . _t('BlogHolder.TE', "For example: sport, personal, science fiction") . "<br/>" . _t('BlogHolder.SPUC', "Please separate tags using commas.") . "</label>"));
     $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
     $actions = new FieldSet($submitAction);
     $validator = new RequiredFields('Title', 'BlogPost');
     $form = new Form($this, 'BlogEntryForm', $fields, $actions, $validator);
     if ($id != 0) {
         $entry = DataObject::get_by_id('BlogEntry', $id);
         if ($entry->IsOwner()) {
             $form->loadDataFrom($entry);
             $form->datafieldByName('BlogPost')->setValue($entry->Content);
         }
     } else {
         $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
     }
     return $form;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:45,代码来源:BlogHolder.php

示例14: BlogEntryForm

	/**
	 * A simple form for creating blog entries
	 */
	function BlogEntryForm() {
		if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();

		Requirements::javascript('jsparty/behaviour.js');
		Requirements::javascript('jsparty/prototype.js');
		Requirements::javascript('jsparty/scriptaculous/effects.js');
		Requirements::javascript('cms/javascript/PageCommentInterface.js');
		Requirements::javascript('blog/javascript/bbcodehelp.js');
					
		$id = 0;
		if(Director::urlParam('ID')) {
			$id = (int) Director::urlParam('ID');
		}
		
		$codeparser = new BBCodeParser();
		$membername = Member::currentMember() ? Member::currentMember()->getName() : "";
		
		if(BlogEntry::$allow_wysiwyg_editing) {
			$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
		} else {
			$contentfield = new CompositeField( 
				new LiteralField("BBCodeHelper","<a id=\"BBCodeHint\" target='new'>"._t("BlogEntry.BBH")."</a><div class='clear'><!-- --></div>" ),
				new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already
				new LiteralField("BBCodeTags","<div id=\"BBTagsHolder\">".$codeparser->useable_tagsHTML()."</div>")
			);
		}
		
		if(class_exists('TagField')) {
			$tagfield = new TagField('Tags', null, null, 'BlogEntry');
			$tagfield->setSeparator(', ');
		} else {
			$tagfield = new TextField('Tags');
		}
		
		$fields = new FieldSet(
			new HiddenField("ID", "ID"),
			new TextField("Title",_t('BlogHolder.SJ', "Subject")),
			new TextField("Author",_t('BlogEntry.AU'),$membername),
			$contentfield,
			$tagfield,
			new LiteralField("Tagsnote"," <label id='tagsnote'>"._t('BlogHolder.TE', "For example: sport, personal, science fiction")."<br/>" .
												_t('BlogHolder.SPUC', "Please separate tags using commas.")."</label>")
		);	
		
		$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
		$actions = new FieldSet($submitAction);
		$validator = new RequiredFields('Title','Content');
			
		$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
	
		if($id != 0) {
			$entry = DataObject::get_by_id('BlogEntry', $id);
			$form->loadNonBlankDataFrom($entry);
			$form->datafieldByName('BlogPost')->setValue($entry->Content);
		} else {
			$form->loadNonBlankDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
		}
		
		return $form;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:63,代码来源:BlogHolder.php

示例15: get_member_for_wishlist

 /**
  * returns a real or fake member against which we save the wishlist.
  * @return Member | WishListMember
  */
 static function get_member_for_wishlist()
 {
     $member = Member::currentMember();
     if (!$member) {
         $wishListMemberID = Session::get(self::get_session_variable_name() . "_wishListMemberID");
         if ($wishListMemberID) {
             if ($wishListMember = DataObject::get_by_id("WishListMember", intval($wishListMemberID))) {
                 //do nothing
             } else {
                 $wishListMemberID = null;
             }
         }
         if (!$wishListMemberID) {
             $wishListMember = new WishListMember();
             $wishListMember->write();
             Session::set(self::get_session_variable_name() . "_wishListMemberID", $wishListMember->ID);
         }
         return $wishListMember;
     } else {
         //copy if the member does not have a wish list, but the session does.
         if (!$member->WishList) {
             if (!$member->IsAdmin()) {
                 $wishListMemberID = Session::get(self::get_session_variable_name() . "_wishListMemberID");
                 if ($wishListMemberID) {
                     if ($wishListMember = DataObject::get_by_id("WishListMember", intval($wishListMemberID))) {
                         if ($wishListMember->WishList) {
                             $member->WishList = $wishListMember->WishList;
                             $member->write();
                         }
                         $wishListMember->delete();
                         Session::clear(self::get_session_variable_name() . "_wishListMemberID");
                     }
                 }
             }
         }
         return $member;
     }
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-wishlist,代码行数:42,代码来源:WishListDecorator.php


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