Friend   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 100
ccs 0
cts 58
cp 0
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 2

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A index() 0 5 1
A friend_list() 0 8 1
A find() 0 8 1
A add_request() 0 5 1
A accept_request() 0 5 1
A reject_request() 0 5 1
A requests() 0 8 1
A ajax_search() 0 7 1
1
<?php
2
3
/**
4
 * Friend controller
5
 */
6
class Friend extends MY_Controller {
7
8
	/**
9
	 * Constructor
10
	 */
11
	public function __construct()
12
	{
13
		parent::__construct();
14
15
		$this->load->model('friend_model');
16
17
		$this->page->set_title('Friends');
18
		$this->page->set_foot_js_group('js');
19
	}
20
21
	/**
22
	 * Alias for friend list
23
	 */
24
	public function index()
25
	{
26
		$this->friend_list();
27
		return;
28
	}
29
30
	/**
31
	 * Get the users's friends
32
	 */
33
	public function friend_list()
34
	{
35
		$data = [
36
			'friend_list' => $this->friend_model->get_friends()
37
		];
38
		$this->page->set_title('Friends List');
39
		$this->page->build('friend/list', $data);
40
	}
41
42
	/**
43
	 * Friend finder form
44
	 */
45
	public function find()
46
	{
47
		$data = [
48
			'results' => NULL
49
		];
50
		$this->page->set_title('Find Friends');
51
		$this->page->build('friend/search', $data);
52
	}
53
54
	/**
55
	 * Send a friend request
56
	 */
57
	public function add_request()
58
	{
59
		$friend_id = (int) $this->input->post('fid');
60
		$this->output->set_output($this->friend_model->send_request($friend_id));
61
	}
62
63
	/**
64
	 * Accept a friend request
65
	 */
66
	public function accept_request()
67
	{
68
		$aid = $this->input->post('aid', TRUE);
69
		$this->output->set_output($this->friend_model->accept_request($aid));
70
	}
71
72
	/**
73
	 * Reject a friend request
74
	 */
75
	public function reject_request()
76
	{
77
		$rid = $this->input->post('rid', TRUE);
78
		$this->output->set_output($this->friend_model->reject_request($rid));
79
	}
80
81
	/**
82
	 * Get list of friend requests
83
	 */
84
	public function requests()
85
	{
86
		$data = [
87
			'request_list' =>  $this->friend_model->get_requests()
88
		];
89
		$this->page->set_title('Friend Reqests');
90
		$this->page->build('friend/requests', $data);
91
	}
92
93
	/**
94
	 * Get results for friend finder
95
	 */
96
	public function ajax_search()
97
	{
98
		$data = [
99
			'results' => $this->friend_model->find_friends()
100
		];
101
		$this->load->view('friend/ajax_search', $data);
102
	}
103
	
104
105
}
106
// End of controllers/friend.php