Merge pull request #5 in KWA/mobile-device-management from ~RTOUSSAINT/mobile-device-management:improvement/KMP-4-show-z-push-version-in-settings to master
* commit 'd610e9e1816a16b8458fd00016c8542af7981f44': KMP-4: - Retrieve the zpush version from the About() service request and show it in the settings
This commit is contained in:
commit
edd376b5b8
13
js/MDM.js
13
js/MDM.js
@ -26,6 +26,7 @@ Zarafa.plugins.mdm.MDM = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
initPlugin : function()
|
initPlugin : function()
|
||||||
{
|
{
|
||||||
this.registerInsertionPoint('context.settings.categories', this.createSettingCategory, this);
|
this.registerInsertionPoint('context.settings.categories', this.createSettingCategory, this);
|
||||||
|
this.registerInsertionPoint('settings.versioninformation', this.createVersionInfo, this);
|
||||||
Zarafa.plugins.mdm.MDM.superclass.initPlugin.apply(this, arguments);
|
Zarafa.plugins.mdm.MDM.superclass.initPlugin.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -37,8 +38,18 @@ Zarafa.plugins.mdm.MDM = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
return [{
|
return [{
|
||||||
xtype : 'Zarafa.plugins.mdm.mdmsettingscategory'
|
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() {
|
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;
|
$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.
|
* Helper to setup a client.
|
||||||
*/
|
*/
|
||||||
function getSoapClient()
|
function getSoapClient($url='')
|
||||||
{
|
{
|
||||||
|
if ( empty($url) ){
|
||||||
|
$url = $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
return new SoapClient(null, array(
|
return new SoapClient(null, array(
|
||||||
'location' => $this->url,
|
'location' => $url,
|
||||||
'uri' => $this->server,
|
'uri' => $this->server,
|
||||||
'trace' => 1,
|
'trace' => 1,
|
||||||
'login' => $this->username,
|
'login' => $this->username,
|
||||||
|
@ -9,6 +9,9 @@ class PluginMDM extends Plugin {
|
|||||||
*/
|
*/
|
||||||
function init(){
|
function init(){
|
||||||
$this->registerHook('server.core.settings.init.before');
|
$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':
|
case 'server.core.settings.init.before':
|
||||||
$this->onBeforeSettingsInit($data);
|
$this->onBeforeSettingsInit($data);
|
||||||
break;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user