-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRemoteControlHandler.php
91 lines (89 loc) · 3.25 KB
/
RemoteControlHandler.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
<?php
/**
* Handler for extendRemoteControl Plugin for LimeSurvey : add yours functions here
*
* @author Denis Chenu <[email protected]>
* @copyright 2015-2016 Denis Chenu <http://sondages.pro>
* @license GPL v3
* @version 1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
class RemoteControlHandler extends remotecontrol_handle
{
/**
* @inheritdoc
* Disable webroute else json returned can be broken
*/
public function __construct(AdminController $controller)
{
/* Deactivate web log */
foreach (Yii::app()->log->routes as $route) {
$route->enabled = $route->enabled && !($route instanceOf CWebLogRoute);
}
parent::__construct($controller);
}
/**
* RPC Routine to get information on user from extendRemoteControl plugin
*
* @access public
* @param string $sSessionKey Auth credentials
* @return array The information on user (except password)
*/
public function get_me($sSessionKey)
{
if ($this->_checkSessionKey($sSessionKey))
{
$oUser=User::model()->find("uid=:uid",array(":uid"=>Yii::app()->session['loginID']));
if($oUser) // We have surely one, else no sessionkey ....
{
$aReturn=$oUser->attributes;
unset($aReturn['password']);
return $aReturn;
}
}
}
/**
* RPC Routine to get global permission of the actual user
*
* @access public
* @param string $sSessionKey Auth credentials
* @param string $sPermission string Name of the permission - see function getGlobalPermissions
* @param $sCRUD string The permission detailsyou want to check on: 'create','read','update','delete','import' or 'export'
* @return bool True if user has the permission
* @return boolean
*/
public function hasGlobalPermission($sSessionKey,$sPermission,$sCRUD='read')
{
$this->_checkSessionKey($sSessionKey);
return array(
'permission'=>Permission::model()->hasGlobalPermission($sPermission,$sCRUD)
);
}
/**
* RPC Routine to get survey permission of the actual user
*
* @access public
* @param string $sSessionKey Auth credentials
* @param $iSurveyID integer The survey ID
* @param $sPermission string Name of the permission
* @param $sCRUD string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'
* @return bool True if user has the permission
* @return boolean
*/
public function hasSurveyPermission($sSessionKey,$iSurveyID, $sPermission, $sCRUD='read')
{
$this->_checkSessionKey($sSessionKey);
return array(
'permission'=>\Permission::model()->hasSurveyPermission($iSurveyID, $sPermission, $sCRUD),
);
}
}