KMP-4: - Retrieve the zpush version from the About() service request and show it in the settings

This commit is contained in:
Ronald Toussaint 2016-12-07 11:48:14 +01:00
parent 7385ef179e
commit d610e9e181
3 changed files with 64 additions and 11 deletions

View File

@ -26,6 +26,7 @@ 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);
},
@ -37,8 +38,18 @@ Zarafa.plugins.mdm.MDM = Ext.extend(Zarafa.core.Plugin, {
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() {

View File

@ -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,

View File

@ -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,6 +24,9 @@ class PluginMDM extends Plugin {
case 'server.core.settings.init.before':
$this->onBeforeSettingsInit($data);
break;
case 'server.index.load.main.before':
$this->addZPushVersionToSettings();
break;
}
}
@ -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);
}
}
?>