KMP-4: - Retrieve the zpush version from the About() service request and show it in the settings
This commit is contained in:
parent
7385ef179e
commit
d610e9e181
17
js/MDM.js
17
js/MDM.js
@ -3,7 +3,7 @@ Ext.namespace('Zarafa.plugins.mdm');
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.MDM
|
||||
* @extends Zarafa.core.Plugin
|
||||
*
|
||||
*
|
||||
* Plugin which lists all devices connected to a Kopano account with Z-Push.
|
||||
* The user can wipe, resync, remove a device using buttons in the WebApp.
|
||||
*/
|
||||
@ -26,19 +26,30 @@ Zarafa.plugins.mdm.MDM = Ext.extend(Zarafa.core.Plugin, {
|
||||
initPlugin : function()
|
||||
{
|
||||
this.registerInsertionPoint('context.settings.categories', this.createSettingCategory, this);
|
||||
this.registerInsertionPoint('settings.versioninformation', this.createVersionInfo, this);
|
||||
Zarafa.plugins.mdm.MDM.superclass.initPlugin.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a category in settings for Z-Push
|
||||
* @return {mdmsettingscategory}
|
||||
* @return {mdmsettingscategory}
|
||||
*/
|
||||
createSettingCategory: function() {
|
||||
return [{
|
||||
xtype : 'Zarafa.plugins.mdm.mdmsettingscategory'
|
||||
}];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a displayField that will show the version of the Z-Push server
|
||||
*/
|
||||
createVersionInfo : function() {
|
||||
var version = container.getSettingsModel().get('zarafa/v1/plugins/mdm/zpush-server-version', true);
|
||||
return {
|
||||
fieldLabel : _('Z-Push', 'plugin_mdm'),
|
||||
value : version
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Zarafa.onReady(function() {
|
||||
|
@ -30,13 +30,35 @@ class PluginMDMModule extends Module
|
||||
$this->url = $this->server .'/Microsoft-Server-ActiveSync?Cmd=WebserviceDevice&DeviceId=webservice&DeviceType=webservice&User=' . $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the Z-Push server
|
||||
* @return String
|
||||
*/
|
||||
function getServerVersion()
|
||||
{
|
||||
// Make a call to the service, so we can read the version
|
||||
// from the response headers
|
||||
try {
|
||||
$url = $this->server .'/Microsoft-Server-ActiveSync?Cmd=WebserviceInfo&DeviceId=webservice&DeviceType=webservice&User=' . $this->username;
|
||||
$client = $this->getSoapClient($url);
|
||||
return $client->About();
|
||||
} catch(Exception $e){}
|
||||
|
||||
// If we can't find a version, we will simply return not available
|
||||
return dgettext('plugin_mdm', 'n/a');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to setup a client.
|
||||
*/
|
||||
function getSoapClient()
|
||||
function getSoapClient($url='')
|
||||
{
|
||||
if ( empty($url) ){
|
||||
$url = $this->url;
|
||||
}
|
||||
|
||||
return new SoapClient(null, array(
|
||||
'location' => $this->url,
|
||||
'location' => $url,
|
||||
'uri' => $this->server,
|
||||
'trace' => 1,
|
||||
'login' => $this->username,
|
||||
@ -76,7 +98,7 @@ class PluginMDMModule extends Module
|
||||
* @return array $response array contains a list of devices connected to the users account
|
||||
*/
|
||||
function getDevices()
|
||||
{
|
||||
{
|
||||
$client = $this->getSoapClient();
|
||||
return $client->ListDevicesDetails();
|
||||
}
|
||||
@ -92,7 +114,7 @@ class PluginMDMModule extends Module
|
||||
$client = $this->getSoapClient();
|
||||
return $client->RemoveDevice($deviceid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes all the actions in the $data variable.
|
||||
* @return boolean true on success of false on fialure.
|
||||
@ -108,21 +130,21 @@ class PluginMDMModule extends Module
|
||||
case 'wipe':
|
||||
$this->wipeDevice($actionData['deviceid'], $actionData['password']);
|
||||
$this->addActionData('wipe', array(
|
||||
'type' => 3,
|
||||
'type' => 3,
|
||||
'wipe' => $this->wipeDevice($actionData['deviceid'], $actionData['password'])
|
||||
));
|
||||
$GLOBALS['bus']->addData($this->getResponseData());
|
||||
break;
|
||||
case 'resync':
|
||||
$this->addActionData('resync', array(
|
||||
'type' => 3,
|
||||
'type' => 3,
|
||||
'resync' => $this->resyncDevice($actionData['deviceid'])
|
||||
));
|
||||
$GLOBALS['bus']->addData($this->getResponseData());
|
||||
break;
|
||||
case 'remove':
|
||||
$this->addActionData('remove', array(
|
||||
'type' => 3,
|
||||
'type' => 3,
|
||||
'remove' => $this->removeDevice($actionData['deviceid'])
|
||||
));
|
||||
$GLOBALS['bus']->addData($this->getResponseData());
|
||||
|
@ -9,6 +9,9 @@ class PluginMDM extends Plugin {
|
||||
*/
|
||||
function init(){
|
||||
$this->registerHook('server.core.settings.init.before');
|
||||
|
||||
// This hook is used to add the Z-Push server version to the settings
|
||||
$this->registerHook('server.index.load.main.before');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,11 +24,14 @@ class PluginMDM extends Plugin {
|
||||
case 'server.core.settings.init.before':
|
||||
$this->onBeforeSettingsInit($data);
|
||||
break;
|
||||
case 'server.index.load.main.before':
|
||||
$this->addZPushVersionToSettings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the core Settings class is initialized and ready to accept sysadmin default
|
||||
* Called when the core Settings class is initialized and ready to accept sysadmin default
|
||||
* settings. Registers the sysadmin defaults for the StatsLogging plugin.
|
||||
* @param Array $data Reference to the data of the triggered hook
|
||||
*/
|
||||
@ -42,5 +48,19 @@ class PluginMDM extends Plugin {
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the version of the z-push server to the MDM settings
|
||||
*/
|
||||
function addZPushVersionToSettings(){
|
||||
// This is a bit ugly, but since all z-push logic was put in the MDM module class,
|
||||
// we have added the getServerVersion function there also
|
||||
require_once(BASE_PATH . 'server/includes/modules/class.module.php');
|
||||
require_once('class.pluginmdmmodule.php');
|
||||
|
||||
$module = new PluginMDMModule('fakeid', array());
|
||||
$version = $module->getServerVersion();
|
||||
$GLOBALS['settings']->set("zarafa/v1/plugins/mdm/zpush-server-version", $version);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user