1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Callbacks for members plugin |
5
|
|
|
* |
6
|
|
|
* PHP Version 5 |
7
|
|
|
* |
8
|
|
|
* @category Plugins |
9
|
|
|
* @package Members |
10
|
|
|
* @author Hans-Joachim Piepereit <[email protected]> |
11
|
|
|
* @copyright 2013 cSphere Team |
12
|
|
|
* @license http://opensource.org/licenses/bsd-license Simplified BSD License |
13
|
|
|
* @link http://www.csphere.eu |
14
|
|
|
**/ |
15
|
|
|
|
16
|
|
|
namespace csphere\plugins\members\classes; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Callbacks for members plugin |
20
|
|
|
* |
21
|
|
|
* @category Plugins |
22
|
|
|
* @package Members |
23
|
|
|
* @author Hans-Joachim Piepereit <[email protected]> |
24
|
|
|
* @copyright 2013 cSphere Team |
25
|
|
|
* @license http://opensource.org/licenses/bsd-license Simplified BSD License |
26
|
|
|
* @link http://www.csphere.eu |
27
|
|
|
**/ |
28
|
|
|
|
29
|
|
|
abstract class Callbacks |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Add group and user name to data |
33
|
|
|
* |
34
|
|
|
* @param array $array Array with data for template |
35
|
|
|
* |
36
|
|
|
* @return array |
37
|
|
|
**/ |
|
|
|
|
38
|
|
|
|
39
|
|
|
public static function data(array $array) |
40
|
|
|
{ |
41
|
|
|
// User table |
42
|
|
|
$user_name = ''; |
43
|
|
|
|
44
|
|
|
if (!empty($array['user_id'])) { |
45
|
|
|
|
46
|
|
|
$dm_users = new \csphere\core\datamapper\Model('users'); |
47
|
|
|
$user = $dm_users->read($array['user_id']); |
48
|
|
|
$user_name = empty($user['user_name']) ? '' : $user['user_name']; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$array['user_name'] = $user_name; |
52
|
|
|
|
53
|
|
|
// Group table |
54
|
|
|
$group_name = ''; |
55
|
|
|
|
56
|
|
|
if (!empty($array['group_id'])) { |
57
|
|
|
$dm_groups = new \csphere\core\datamapper\Model('groups'); |
58
|
|
|
$group = $dm_groups->read($array['group_id']); |
59
|
|
|
$group_name = empty($group['group_name']) ? '' : $group['group_name']; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$array['group_name'] = $group_name; |
63
|
|
|
|
64
|
|
|
return $array; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Add group and user serial to record |
69
|
|
|
* |
70
|
|
|
* @param array $array Array with data of record |
71
|
|
|
* |
72
|
|
|
* @return array |
73
|
|
|
**/ |
|
|
|
|
74
|
|
|
|
75
|
|
|
public static function record(array $array) |
76
|
|
|
{ |
77
|
|
|
// User table |
78
|
|
|
$user_id = ''; |
79
|
|
|
|
80
|
|
|
if (!empty($array['user_name'])) { |
81
|
|
|
|
82
|
|
|
$dm_users = new \csphere\core\datamapper\Model('users'); |
83
|
|
|
$user = $dm_users->read($array['user_name'], 'user_name'); |
84
|
|
|
$user_id = empty($user['user_id']) ? '' : $user['user_id']; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$array['user_id'] = $user_id; |
88
|
|
|
unset($array['user_name']); |
89
|
|
|
|
90
|
|
|
// Group table |
91
|
|
|
$group_id = ''; |
92
|
|
|
|
93
|
|
|
if (!empty($array['group_name'])) { |
94
|
|
|
$dm_groups = new \csphere\core\datamapper\Model('groups'); |
95
|
|
|
$group = $dm_groups->read($array['group_name'], 'group_name'); |
96
|
|
|
$group_id = empty($group['group_id']) ? '' : $group['group_id']; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
$array['group_id'] = $group_id; |
100
|
|
|
unset($array['group_name']); |
101
|
|
|
|
102
|
|
|
return $array; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|