/**
  * work out the options for the user
  **/
 protected function workOutMessagesAndActions()
 {
     if (!$this->workedOutMessagesAndActions) {
         $this->actionLinks = new ArrayList(array());
         //what order are we viewing?
         $viewingRealCurrentOrder = $this->CurrentOrderIsInCart();
         $currentUserID = Member::currentUserID();
         //Continue Shopping
         if (isset($this->ContinueShoppingLabel) && $this->ContinueShoppingLabel) {
             if ($viewingRealCurrentOrder) {
                 if ($this->isCartPage()) {
                     $continueLink = $this->ContinueShoppingLink();
                     if ($continueLink) {
                         $this->actionLinks->push(new ArrayData(array("Title" => $this->ContinueShoppingLabel, "Link" => $continueLink)));
                     }
                 }
             }
         }
         //Proceed To CheckoutLabel
         if (isset($this->ProceedToCheckoutLabel) && $this->ProceedToCheckoutLabel) {
             if ($viewingRealCurrentOrder) {
                 if ($this->isCartPage()) {
                     $checkoutPageLink = CheckoutPage::find_link();
                     if ($checkoutPageLink && $this->currentOrder && $this->currentOrder->getTotalItems()) {
                         $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->getTotalItems() && !$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($this->currentOrder->ID))));
             }
         }
         //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::copy_order_link($this->currentOrder->ID))));
             }
         }
         //actions from modifiers
         if ($this->isOrderConfirmationPage() && $this->currentOrder->ID) {
             $modifiers = $this->currentOrder->Modifiers();
             if ($modifiers->count()) {
                 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::currentUser()) {
             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->getTotalItems()) {
                 $this->message = $this->NoItemsInOrderMessage;
             }
         } else {
             $this->message = $this->NonExistingOrderMessage;
         }
         $this->workedOutMessagesAndActions = true;
         //does nothing at present....
     }
 }