2015-02-13 16:19:01 -04:00
< ? php
/**
* Description of ActionsByEmailFeature
*
*/
2015-03-03 17:54:30 -04:00
if ( ! class_exists ( 'enterprisePlugin' )) {
return ;
}
// Load dependences
G :: LoadClass ( 'feature' );
class ActionsByEmailFeature extends PMFeature
2015-02-13 16:19:01 -04:00
{
2015-03-03 17:54:30 -04:00
public function __construct ( $namespace , $filename = null )
{
$result = parent :: __construct ( $namespace , $filename );
$this -> sFriendlyName = 'Actions By Email' ;
$this -> sDescription = 'Actions by Email using variables as multiple choice actions delivered by email' ;
$this -> sFeatureFolder = 'ActionsByEmail' ;
$this -> sSetupPage = '' ;
$this -> iVersion = self :: getFeatureVersion ( $namespace );
$this -> aWorkspaces = null ;
$this -> aDependences = array ( array ( 'sClassName' => 'enterprise' ), array ( 'sClassName' => 'pmLicenseManager' ));
$this -> bPrivate = parent :: registerEE ( $this -> sFeatureFolder , $this -> iVersion );
return $result ;
}
2015-02-13 16:19:01 -04:00
public function setup ()
{
2015-03-03 17:54:30 -04:00
try {
// Register the extended tab for the task properties
//$this->registerTaskExtendedProperty('actionsByEmail/configActionsByEmail', "Actions by Email");
//$this->registerTaskExtendedProperty('actionsByEmail/configActionsByEmail', 'Actions by Email');
//$this->registerMenu('setup', 'menusetup.php');
// Register the trigger for the hook PM_CREATE_NEW_DELEGATION
if ( ! defined ( 'PM_CREATE_NEW_DELEGATION' )) {
throw new Exception ( 'It might be using a version of ProcessMaker which is not totally compatible with this plugin, the minimun required version is 2.0.37' );
}
$this -> registerTrigger ( PM_CREATE_NEW_DELEGATION , 'sendActionsByEmail' );
// Register the external step for the tracking form
//$this->registerStep('4939290144f0745f5ddb1d1019823738', 'externalStep', 'Actions by Email - Tracking Form'); // ToDo: For the next release
} catch ( Exception $error ) {
//G::SendMessageText($error->getMessage(), 'WARNING');
}
2015-02-13 16:19:01 -04:00
}
2015-03-03 17:54:30 -04:00
2015-02-13 16:19:01 -04:00
public function install ()
{
2015-03-03 17:54:30 -04:00
$this -> checkTables ();
2015-02-13 16:19:01 -04:00
}
2015-03-03 17:54:30 -04:00
2015-02-13 16:19:01 -04:00
public function enable ()
{
2015-03-03 17:54:30 -04:00
$this -> checkTables ();
2015-02-13 16:19:01 -04:00
}
2015-03-03 17:54:30 -04:00
2015-02-13 16:19:01 -04:00
public function disable ()
{
2015-03-03 17:54:30 -04:00
// Nothing to do for now
}
/**
* This method get the version of this plugin , when the plugin is packaged in the tar . gz
* the file " version " in the plugin folder has this information for development purposes ,
* we calculate the version using git commands , because the repository is in GIT
*
* @ param String $namespace The namespace of the plugin
* @ return String $version
*/
private static function getFeatureVersion ( $namespace )
{
return " 2.0.20 " ;
}
public function checkTables ()
{
$con = Propel :: getConnection ( 'workflow' );
$stmt = $con -> createStatement ();
// setting the path of the sql schema files
$filenameSql = PATH_PLUGINS . 'actionsByEmail/data/schema.sql' ;
// checking the existence of the schema file
if ( ! file_exists ( $filenameSql )) {
throw new Exception ( " File data/schema.sql doesn't exists " );
}
// exploding the sql query in an array
$sql = explode ( ';' , file_get_contents ( $filenameSql ));
$stmt -> executeQuery ( 'SET FOREIGN_KEY_CHECKS = 0;' );
// executing each query stored in the array
foreach ( $sql as $sentence ) {
if ( trim ( $sentence ) != '' ) {
$stmt -> executeQuery ( $sentence );
}
}
2015-02-13 16:19:01 -04:00
}
}