Beispiel #1
0
 public function action_unsubscribe()
 {
     $list_id = $this->request->param('id');
     $list = new Model_List($list_id);
     $this->redirect_if_not_on_list();
     if (!$list->is_user_subscribed($this->me())) {
         Message::add('danger', 'You are already unsubscribed from this list');
         Request::current()->redirect('list/friend/' . $list->id);
     }
     $me = new Model_Owner($this->me()->id);
     $me->unsubscribe_from_list($list);
     Message::add('success', 'Unsubscribed from this list');
     //Request::current()->redirect('list/friend/' . $list->id);
 }
Beispiel #2
0
 public function action_mark_as_bought()
 {
     $gift = new Model_Gift((int) $this->request->param('id'));
     if ($gift->reserver_id != $this->me()->id) {
         Message::add('danger', __('You have not reserved this gift.'));
         Request::current()->redirect('');
     }
     if ($gift->buyer_id) {
         Message::add('success', __('This gift has already been bought.'));
         Request::current()->redirect('');
     }
     if (arr::get($_POST, 'bought')) {
         $gift->buyer_id = $gift->reserver_id;
         $gift->save();
         // automnatically unsubscribe from list
         $me = new Model_Owner($this->me()->id);
         $me->unsubscribe_from_list($gift->list);
         Message::add('success', __('This gift has been marked as bought.'));
         Request::current()->redirect('gift/shopping');
     }
     $this->template->title = 'Confirm';
     $view = View::factory('gift/mark-as-bought');
     $view->gift = $gift;
     $this->template->content = $view;
 }