mirror of
https://github.com/dducret/kopano-webapp-passwd
synced 2026-07-27 10:32:26 +02:00
commit initial skeleton of the plugin
nothing is working
This commit is contained in:
parent
b6c8396ab6
commit
843f674854
7 changed files with 397 additions and 0 deletions
198
build.xml
Normal file
198
build.xml
Normal file
|
|
@ -0,0 +1,198 @@
|
||||||
|
<project default="all">
|
||||||
|
<property environment="env"/>
|
||||||
|
<property name="root-folder" value="${basedir}/../../"/>
|
||||||
|
<property name="tools-folder" value="${root-folder}/tools/"/>
|
||||||
|
<property name="target-folder" value="${root-folder}/deploy/plugins"/>
|
||||||
|
|
||||||
|
<import file="${tools-folder}/antutil.xml"/>
|
||||||
|
|
||||||
|
<typedef file="${tools-folder}/antlib.xml">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${tools-folder}/tools.jar"/>
|
||||||
|
</classpath>
|
||||||
|
</typedef>
|
||||||
|
|
||||||
|
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${tools-folder}/lib/ant-contrib-1.0b3.jar"/>
|
||||||
|
</classpath>
|
||||||
|
</taskdef>
|
||||||
|
|
||||||
|
<!-- Determine plugin name -->
|
||||||
|
<var name="plugin" unset="true"/>
|
||||||
|
<basename file="${basedir}" property="plugin"/>
|
||||||
|
|
||||||
|
<!-- The Plugin distribution files -->
|
||||||
|
<property name="plugin-folder" value="${plugin}"/>
|
||||||
|
<property name="plugin-debugfile" value="${plugin}-debug.js"/>
|
||||||
|
<property name="plugin-file" value="${plugin}.js"/>
|
||||||
|
|
||||||
|
<!-- The Plugin CSS files -->
|
||||||
|
<property name="plugin-css-folder" value="resources/css"/>
|
||||||
|
<property name="plugin-css-file" value="${plugin}.css"/>
|
||||||
|
|
||||||
|
<!-- Meta target -->
|
||||||
|
<target name="all" depends="concat, compress"/>
|
||||||
|
|
||||||
|
<!-- Clean -->
|
||||||
|
<target name="clean">
|
||||||
|
<delete includeemptydirs="true" failonerror="false">
|
||||||
|
<!-- Delete the Plugin files -->
|
||||||
|
<fileset dir="${target-folder}/${plugin-folder}/js">
|
||||||
|
<include name="${plugin-file}"/>
|
||||||
|
<include name="${plugin-debugfile}"/>
|
||||||
|
</fileset>
|
||||||
|
</delete>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Concatenates JavaScript files with automatic dependency generation -->
|
||||||
|
<target name="concat">
|
||||||
|
<!-- Concatenate plugin JS file -->
|
||||||
|
<if>
|
||||||
|
<available file="js" type="dir" />
|
||||||
|
<then>
|
||||||
|
<mkdir dir="${target-folder}/${plugin-folder}/js"/>
|
||||||
|
<echo message="Concatenating: ${plugin-debugfile}"/>
|
||||||
|
<zConcat outputFolder="${target-folder}/${plugin-folder}/js" outputFile="${plugin-debugfile}" prioritize="\w+">
|
||||||
|
<concatfiles>
|
||||||
|
<fileset dir="js" includes="**/*.js" />
|
||||||
|
</concatfiles>
|
||||||
|
</zConcat>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- Concatenate plugin CSS files -->
|
||||||
|
<if>
|
||||||
|
<available file="${plugin-css-folder}" type="dir" />
|
||||||
|
<then>
|
||||||
|
<mkdir dir="${target-folder}/${plugin-folder}/${plugin-css-folder}"/>
|
||||||
|
<echo message="Concatenating: ${plugin-css-file}"/>
|
||||||
|
<zConcat outputFolder="${target-folder}/${plugin-folder}/${plugin-css-folder}" outputFile="${plugin-css-file}">
|
||||||
|
<concatfiles>
|
||||||
|
<fileset dir="${plugin-css-folder}" includes="**/*.css" />
|
||||||
|
</concatfiles>
|
||||||
|
</zConcat>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Preformat the Concatenated Javascript files to improve compilation -->
|
||||||
|
<target name="preformat" depends="concat">
|
||||||
|
<if>
|
||||||
|
<available file="${target-folder}/${plugin-folder}/js/${plugin-debugfile}" type="file" />
|
||||||
|
<then>
|
||||||
|
<echo message="Preformatting: ${plugin-debugfile}"/>
|
||||||
|
<replaceregexp byline="true">
|
||||||
|
<regexp pattern="(^[ ,\t]*\*[ ,\t]@.*)\{(.*)\[\]\}"/>
|
||||||
|
<substitution expression="\1{\2\|Array}"/>
|
||||||
|
<fileset dir="${target-folder}/${plugin-folder}/js" includes="${plugin-debugfile}"/>
|
||||||
|
</replaceregexp>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Compress JavaScript -->
|
||||||
|
<target name="compress" depends="preformat">
|
||||||
|
<if>
|
||||||
|
<available file="${target-folder}/${plugin-folder}/js/${plugin-debugfile}" type="file" />
|
||||||
|
<then>
|
||||||
|
<echo message="Compiling: ${plugin-debugfile}" />
|
||||||
|
<zCompile inputFolder="${target-folder}/${plugin-folder}/js" inputFile="${plugin-debugfile}" outputFolder="${target-folder}/${plugin-folder}/js" outputFile="${plugin-file}">
|
||||||
|
<externs>
|
||||||
|
var Ext = {};
|
||||||
|
var Zarafa = {};
|
||||||
|
var container = {};
|
||||||
|
var _ = function(key, domain) {};
|
||||||
|
var dgettext = function(domain, msgid) {};
|
||||||
|
var dngettext = function(domain, msgid, msgid_plural, count) {};
|
||||||
|
var dnpgettext = function(domain, msgctxt, msgid, msgid_plural, count) {};
|
||||||
|
var dpgettext = function(domain, msgctxt, msgid) {};
|
||||||
|
var ngettext = function(msgid, msgid_plural, count) {};
|
||||||
|
var npgettext = function(msgctxt, msgid, msgid_plural, count) {};
|
||||||
|
var pgettext = function(msgctxt, msgid) {};
|
||||||
|
</externs>
|
||||||
|
</zCompile>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- syntax check all PHP files -->
|
||||||
|
<target name="validate">
|
||||||
|
<if>
|
||||||
|
<available file="php" filepath="${env.PATH}" />
|
||||||
|
<then>
|
||||||
|
<if>
|
||||||
|
<available file="config.php" type="file" />
|
||||||
|
<then>
|
||||||
|
<antcall target="syntax-check">
|
||||||
|
<param name="file" value="config.php"/>
|
||||||
|
</antcall>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
<if>
|
||||||
|
<available file="php" type="dir" />
|
||||||
|
<then>
|
||||||
|
<foreach target="syntax-check" param="file">
|
||||||
|
<path>
|
||||||
|
<fileset dir=".">
|
||||||
|
<include name="**/*.php"/>
|
||||||
|
</fileset>
|
||||||
|
</path>
|
||||||
|
</foreach>
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
</then>
|
||||||
|
<else>
|
||||||
|
<echo message="WARNING: PHP not available, not performing syntax-check on php files"/>
|
||||||
|
</else>
|
||||||
|
</if>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="syntax-check">
|
||||||
|
<echo message="validating ${file}"/>
|
||||||
|
<exec executable="php" failonerror="true">
|
||||||
|
<arg value="-l"/>
|
||||||
|
<arg value="${file}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Install all files into the target folder -->
|
||||||
|
<target name="deploy" depends="compress, validate">
|
||||||
|
<mkdir dir="${target-folder}/${plugin-folder}"/>
|
||||||
|
|
||||||
|
<!-- Copy (and validate) manifest.xml -->
|
||||||
|
<if>
|
||||||
|
<available file="xmllint" filepath="${env.PATH}" />
|
||||||
|
<then>
|
||||||
|
<exec executable="xmllint" output="${target-folder}/${plugin-folder}/manifest.xml" failonerror="true" error="/dev/stdout">
|
||||||
|
<arg value="--valid"/>
|
||||||
|
<arg value="--path"/>
|
||||||
|
<arg value="${root-folder}/server"/>
|
||||||
|
<arg value="manifest.xml"/>
|
||||||
|
</exec>
|
||||||
|
</then>
|
||||||
|
<else>
|
||||||
|
<echo message="WARNING: xmllint not available, not performing syntax-check on manifest.xml"/>
|
||||||
|
<!-- xmllint is not available, so we must copy the file manually -->
|
||||||
|
<copy todir="${target-folder}/${plugin-folder}">
|
||||||
|
<fileset dir=".">
|
||||||
|
<include name="manifest.xml"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</else>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- copy files -->
|
||||||
|
<copy todir="${target-folder}/${plugin-folder}">
|
||||||
|
<fileset dir=".">
|
||||||
|
<include name="resources/**/*.*"/>
|
||||||
|
<include name="php/**/*.php"/>
|
||||||
|
<include name="config.php"/>
|
||||||
|
<!-- exclude the ant script -->
|
||||||
|
<exclude name="build.xml"/>
|
||||||
|
<!-- CSS is generated during build -->
|
||||||
|
<exclude name="resources/css/*.*"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
4
config.php
Normal file
4
config.php
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
/** Enable the passwd plugin for all clients **/
|
||||||
|
define('PLUGIN_PASSWD_USER_DEFAULT_ENABLE', true);
|
||||||
|
?>
|
||||||
8
js/ABOUT.js
Normal file
8
js/ABOUT.js
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
Ext.namespace('Zarafa.plugins.passwd');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Zarafa.plugins.passwd.ABOUT
|
||||||
|
*
|
||||||
|
* The copyright string holding the copyright notice for the Zarafa passwd Plugin.
|
||||||
|
*/
|
||||||
|
Zarafa.plugins.sugarcrm.ABOUT = "Something should be here";
|
||||||
56
js/PasswdPlugin.js
Normal file
56
js/PasswdPlugin.js
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
Ext.namespace('Zarafa.plugins.passwd');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Zarafa.plugins.passwd.PasswdPlugin
|
||||||
|
* @extends Zarafa.core.Plugin
|
||||||
|
*
|
||||||
|
* Passwd plugin.
|
||||||
|
* Allows users to change password from webapp.
|
||||||
|
*/
|
||||||
|
Zarafa.plugins.passwd.PasswdPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the plugin by registering to the insertion point
|
||||||
|
* to add something to the right end of the main tab bar.
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
initPlugin : function()
|
||||||
|
{
|
||||||
|
Zarafa.plugins.passwd.PasswdPlugin.superclass.initPlugin.apply(this, arguments);
|
||||||
|
|
||||||
|
this.registerInsertionPoint('main.maintabbar.right', this.putTabbarButton, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the button to add to the insertion point as called
|
||||||
|
* by init().
|
||||||
|
* @return A struct with the necessary configuration for the button.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
putTabbarButton : function()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
text : _('Change Password'),
|
||||||
|
handler : this.clickPasswdButton
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger function called when the user clicks the button in the
|
||||||
|
* main tab bar.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
clickPasswdButton : function()
|
||||||
|
{
|
||||||
|
// open a dialog
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Zarafa.onReady(function() {
|
||||||
|
container.registerPlugin(new Zarafa.core.PluginMetaData({
|
||||||
|
name : 'passwd',
|
||||||
|
displayName : _('Password Change Plugin'),
|
||||||
|
about : Zarafa.plugins.passwd.ABOUT,
|
||||||
|
pluginConstructor : Zarafa.plugins.passwd.PasswdPlugin
|
||||||
|
}));
|
||||||
|
});
|
||||||
34
manifest.xml
Normal file
34
manifest.xml
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE plugin SYSTEM "manifest.dtd">
|
||||||
|
<plugin version="2">
|
||||||
|
<info>
|
||||||
|
<version>0.1</version>
|
||||||
|
<name>Passwd</name>
|
||||||
|
<title>Password Changer Plugin</title>
|
||||||
|
<author>Saket Patel</author>
|
||||||
|
<authorURL>http://www.zarafa.com</authorURL>
|
||||||
|
<description>Change your password from zarafa webapp</description>
|
||||||
|
</info>
|
||||||
|
<config>
|
||||||
|
<configfile>config.php</configfile>
|
||||||
|
</config>
|
||||||
|
<components>
|
||||||
|
<component>
|
||||||
|
<files>
|
||||||
|
<server>
|
||||||
|
<serverfile>php/plugin.passwd.php</serverfile>
|
||||||
|
<serverfile type="module" module="passwdmodule">php/class.passwdmodule.php</serverfile>
|
||||||
|
</server>
|
||||||
|
<client>
|
||||||
|
<clientfile load="release">js/passwd.js</clientfile>
|
||||||
|
<clientfile load="debug">js/passwd-debug.js</clientfile>
|
||||||
|
<clientfile load="source">js/PasswdPlugin.js</clientfile>
|
||||||
|
<clientfile load="source">js/ABOUT.js</clientfile>
|
||||||
|
</client>
|
||||||
|
<!-- <resources>
|
||||||
|
<resourcefile load="release">resources/css/passwd.css</resourcefile>
|
||||||
|
</resources> -->
|
||||||
|
</files>
|
||||||
|
</component>
|
||||||
|
</components>
|
||||||
|
</plugin>
|
||||||
42
php/class.passwdmodule.php
Normal file
42
php/class.passwdmodule.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Passwd module.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PasswdModule extends Module
|
||||||
|
{
|
||||||
|
public function __construct($id, $data) {
|
||||||
|
parent::Module($id, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the incoming events that were fire by the client.
|
||||||
|
*
|
||||||
|
* @return boolean True if everything was processed correctly.
|
||||||
|
*/
|
||||||
|
public function execute()
|
||||||
|
{
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
foreach($this->data as $actionType => $actionData)
|
||||||
|
{
|
||||||
|
if(isset($actionType)) {
|
||||||
|
try {
|
||||||
|
switch($actionType)
|
||||||
|
{
|
||||||
|
case "save":
|
||||||
|
$this->save($actionData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->handleUnknownActionType($actionType);
|
||||||
|
}
|
||||||
|
} catch (MAPIException $e) {
|
||||||
|
$this->sendFeedback(false, $this->errorDetailsFromException($e));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
55
php/plugin.passwd.php
Normal file
55
php/plugin.passwd.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Passwd plugin.
|
||||||
|
*
|
||||||
|
* Allows to change user password from webapp.
|
||||||
|
*
|
||||||
|
* Author: Saket patel <s.patel@zarafa.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Pluginpasswd extends Plugin {
|
||||||
|
|
||||||
|
public function __construct() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function initializes the Plugin and registers all hooks
|
||||||
|
*/
|
||||||
|
function init() {
|
||||||
|
$this->registerHook('server.core.settings.init.before');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function is executed when a hook is triggered by the PluginManager
|
||||||
|
*
|
||||||
|
* @param string $eventID the id of the triggered hook
|
||||||
|
* @param mixed $data object(s) related to the hook
|
||||||
|
*/
|
||||||
|
function execute($eventID, &$data) {
|
||||||
|
switch($eventID) {
|
||||||
|
case 'server.core.settings.init.before' :
|
||||||
|
$this->injectPluginSettings($data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the core Settings class is initialized and ready to accept sysadmin default
|
||||||
|
* settings. Registers the sysadmin defaults for the SugarCRM plugin.
|
||||||
|
* @param Array $data Reference to the data of the triggered hook
|
||||||
|
*/
|
||||||
|
function injectPluginSettings(&$data) {
|
||||||
|
$data['settingsObj']->addSysAdminDefaults(Array(
|
||||||
|
'zarafa' => Array(
|
||||||
|
'v1' => Array(
|
||||||
|
'plugins' => Array(
|
||||||
|
'sugarcrm' => Array(
|
||||||
|
'enable' => PLUGIN_PASSWD_USER_DEFAULT_ENABLE,
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue