tims-todo/application/controllers/Friend.php

106 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2014-08-08 15:41:59 -04:00
<?php
/**
* Friend controller
*/
class Friend extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->model('friend_model');
$this->page->set_title('Friends');
$this->page->set_foot_js_group('js');
}
/**
* Alias for friend list
*/
public function index()
{
$this->friend_list();
return;
}
/**
* Get the users's friends
*/
public function friend_list()
{
2014-08-13 22:19:00 -04:00
$data = [
'friend_list' => $this->friend_model->get_friends()
];
2014-08-08 15:41:59 -04:00
$this->page->set_title('Friends List');
$this->page->build('friend/list', $data);
}
/**
* Friend finder form
*/
public function find()
{
2014-08-13 22:19:00 -04:00
$data = [
'results' => NULL
];
2014-08-08 15:41:59 -04:00
$this->page->set_title('Find Friends');
$this->page->build('friend/search', $data);
}
/**
* Send a friend request
*/
public function add_request()
{
$friend_id = (int) $this->input->post('fid');
$this->output->set_output($this->friend_model->send_request($friend_id));
}
/**
* Accept a friend request
*/
public function accept_request()
{
2014-08-13 22:19:00 -04:00
$aid = $this->input->post('aid', TRUE);
2014-08-08 15:41:59 -04:00
$this->output->set_output($this->friend_model->accept_request($aid));
}
/**
* Reject a friend request
*/
public function reject_request()
{
2014-08-13 22:19:00 -04:00
$rid = $this->input->post('rid', TRUE);
2014-08-08 15:41:59 -04:00
$this->output->set_output($this->friend_model->reject_request($rid));
}
/**
* Get list of friend requests
*/
public function requests()
{
2014-08-13 22:19:00 -04:00
$data = [
'request_list' => $this->friend_model->get_requests()
];
2014-08-08 15:41:59 -04:00
$this->page->set_title('Friend Reqests');
$this->page->build('friend/requests', $data);
}
/**
* Get results for friend finder
*/
public function ajax_search()
{
2014-08-13 22:19:00 -04:00
$data = [
'results' => $this->friend_model->find_friends()
];
2014-08-08 15:41:59 -04:00
$this->load->view('friend/ajax_search', $data);
}
}
// End of controllers/friend.php