Group   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 92
ccs 0
cts 57
cp 0
rs 10
c 0
b 0
f 0
wmc 10
lcom 1
cbo 2

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A index() 0 5 1
A group_list() 0 8 1
A add_sub() 0 10 2
A del_group() 0 5 1
B manage() 0 32 4
1
<?php
2
3
/**
4
 * Group management controller
5
 */
6
class Group extends MY_Controller{
7
8
	/**
9
	 * Constructor
10
	 */
11
	public function __construct()
12
	{
13
		parent::__construct();
14
		$this->page->set_foot_js_group('js');
15
		$this->page->set_title('Groups');
16
	}
17
18
	/**
19
	 * Redirect to group list
20
	 */
21
	public function index()
22
	{
23
		//303 Redirect
24
		$this->todo->redirect_303('groups/list');
25
	}
26
27
	/**
28
	 * List of user's groups
29
	 */
30
	public function group_list()
31
	{
32
		$data = [
33
			'group' => $this->todo->get_group_list((int) $this->session->userdata('uid'))
34
		];
35
		$this->page->set_title("Group List");
36
		$this->page->build('friend/group_list', $data);
37
	}
38
39
	/**
40
	 * Add a new group
41
	 */
42
	public function add_sub()
43
	{
44
		if($this->input->post('add_sub') != FALSE)
45
		{
46
			$this->todo->add_group();
47
48
			//Redirect to the group list
49
			$this->todo->redirect_303('group/manage');
50
		}
51
	}
52
53
	/**
54
	 * Delete a group
55
	 */
56
	public function del_group()
57
	{
58
		$group_id = (int) $this->uri->segment('3');
59
		$this->output->set_output($this->todo->del_group($group_id));
60
	}
61
62
	/**
63
	 * Add/Edit a group
64
	 */
65
	public function manage($group_id = NULL)
66
	{
67
		if(is_null($group_id))
68
		{
69
			$this->group_list();
70
			return;
71
		}
72
		
73
		if($this->input->post('friends'))
74
		{
75
			$this->todo->update_group();
76
		}
77
		
78
		$group_id = (int) $group_id;
79
80
		$friends_array = array();
81
		$array = $this->todo->get_friends_in_group($group_id);
82
		
83
		foreach($array as $a)
84
		{
85
			$friends_array[] = $a['user_id'];
86
		}
87
88
		$data = array();
89
		$data['group_name'] = $this->todo->get_group_name_by_id($group_id);
90
		$data['friends'] = $this->todo->get_friend_list();
91
		$data['selected_friends'] = $friends_array;
92
		$data['group_perms'] = array();
93
	
94
		$this->page->set_title("Manage Group");
95
		$this->page->build('friend/manage', $data);
96
	}
97
}
98
// End of controllers/group.php