-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.php
95 lines (82 loc) · 2.46 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
require_once(str_replace('//','/',dirname(__FILE__).'/').'common/lib/api.php');
require_once(str_replace('//','/',dirname(__FILE__).'/').'models/adapter/user.php');
require_once(str_replace('//','/',dirname(__FILE__).'/').'models/selector/users.php');
require_once(str_replace('//','/',dirname(__FILE__).'/').'models/selector/actions.php');
class FeeligoWordPressApi extends FeeligoApi{
/* constructor
* should store an instance of FeeligoWordpressCommunity
* to be returned when the Community is requested
*/
public function __construct() {
global $bp;
parent::__construct();
// store the viewer
$this->_adapter_viewer = new FeeligoWordpressUser(get_user_by('id',$bp->loggedin_user->userdata->ID));
// store the subject
$this->_adapter_subject = null;
if ($bp->displayed_user->userdata->ID != null) {
$u_subj =new FeeligoWordpressUser((get_user_by('id',$bp->displayed_user->userdata->ID))) ;
// ensure the subject is not the same User as the viewer
if ($this->_adapter_viewer->id()!=$u_subj->id()) { //attention changer isSelf
$this->_adapter_subject = $u_subj;
}
}
}
public function community(){
return $this->_community;
}
public function has_viewer(){
global $bp;
$adpt_viewer = $bp->loggedin_user->userdata->ID;
if ($adpt_viewer != null){
return true;
}
else{
return false;
}
}
public function has_subject(){
global $bp;
$adpt_viewer = $bp->loggedin_user->userdata->ID;
$adpt_subject = $bp->displayed_user->userdata->ID;
if ($adpt_subject != null && $adpt_viewer!=$adpt_subject ){
return true;
}
else{
return false;
}
}
/* TODO: include this function as-is
* (Singleton pattern)
*/
public static function _() {
if( is_null(self::$_instance) ) {
self::$_instance = new self();
}
return self::$_instance;
}
public function viewer() {
return $this->_adapter_viewer;
}
public function subject() {
error_log("SUJET : ".$this->_adapter_subject->name());
return $this->_adapter_subject;
}
public function users() {
if (!isset($this->_users)) {
$this->_users = new Feeligo_Model_Selector_Users();
}
return $this->_users;
}
/*
* Accessor to the Actions adapter
*/
public function actions() {
if (!isset($this->_actions)) {
$this->_actions = new Feeligo_Model_Selector_Actions();
}
return $this->_actions;
}
}
?>