Example #1
0
 public function action_request_cancel()
 {
     $friend_user = new Model_Owner($this->request->param('id'));
     if (!$friend_user->is_on_my_friends_list($this->me())) {
         Message::add('error', 'This person does not want to be your friend.');
         Request::current()->redirect('');
     }
     if ($friend_user->is_on_friends_friends_list($this->me())) {
         Message::add('error', 'You are already friends with this person.');
         Request::current()->redirect('');
     }
     if (arr::get($_POST, 'confirm')) {
         $mes = $friend_user->friends->where('email', '=', $this->me()->email)->find_all();
         foreach ($mes as $me) {
             $me->delete();
         }
         Message::add('success', 'Successfully ignored friend request');
         Request::current()->redirect('');
     }
     $this->template->title = 'Confirm';
     $this->template->content = View::factory('friend/request_cancel');
 }
Example #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;
 }
Example #3
0
 public function action_subscribe()
 {
     $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 subscribed to this list');
         Request::current()->redirect('list/friend/' . $list->id);
     }
     $me = new Model_Owner($this->me()->id);
     $me->subscribe_to_list($list);
     Message::add('success', 'Subscribed to this list');
     //Request::current()->redirect('list/friend/' . $list->id);
 }
Example #4
0
 /**
  * Close the current user's account.
  */
 public function action_unregister()
 {
     // set the template title (see Controller_App for implementation)
     $this->template->title = __('Close user account');
     if (Auth::instance()->logged_in() == false) {
         // No user is currently logged in
         $this->request->redirect('user/login');
     }
     // get the user id
     $id = Auth::instance()->get_user()->id;
     $user = ORM::factory('user', $id);
     // KO3 ORM is lazy loading, which means we have to access a single field to actually have something happen.
     if ($user->id != $id) {
         // If the user is not the current user, redirect
         $this->request->redirect('user/profile');
     }
     // check for confirmation
     if (is_numeric($id) && isset($_POST['confirmation']) && $_POST['confirmation'] == 'Y') {
         $owner = new Model_Owner($id);
         $owner->clear_all_related();
         if (Auth::instance()->logged_in()) {
             // Log the user out, their account will no longer exist
             Auth::instance()->logout();
         }
         // Delete the user
         $user->delete($id);
         // Delete any associated identities
         DB::delete('user_identity')->where('user_id', '=', $id)->execute();
         // message: save success
         //Message::add('success', __('Successfully deleted your account.'));
         $this->request->redirect('');
     }
     // display confirmation
     $this->template->content = View::factory('user/unregister')->set('id', $id)->set('data', array('username' => Auth::instance()->get_user()->username));
 }