-
Notifications
You must be signed in to change notification settings - Fork 6
/
odooStep.php
executable file
·149 lines (121 loc) · 5.88 KB
/
odooStep.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Defines a PHP class for the plugin (which inherits from the PmPlugin class)
* to register the new plugin and define its methods to setup, install, activate, deactivate and uninstall the plugin.
*
*/
G::LoadClass("plugin");
define("PATH_PLUGIN_OS",PATH_CORE . "/plugins/odooStep/");
set_include_path(
PATH_PLUGIN_OS.PATH_SEPARATOR.
get_include_path()
);
class odooStepPlugin extends PMPlugin {
public function odooStepPlugin($sNamespace, $sFilename = null) {
$res = parent::PMPlugin($sNamespace, $sFilename);
$this->sFriendlyName = "odooStep Plugin";
$this->sDescription = "Añade un paso para conectar con el XML-RPC de Odoo";
$this->sPluginFolder = "odooStep";
$this->sSetupPage = "setup";
$this->iVersion = 1;
//$this->iPMVersion = 2425;
$this->aWorkspaces = null;
//$this->aWorkspaces = array("os");
return $res;
}
/**
* Any code added to the setup() method in the pluginName.php file WILL BE EXECUTED EVERY TIME (NOT TRULY TRUE)
* ProcessMaker loads a web page, so do not add code which takes too long to execute or may cause errors.
*/
public function setup() {
//http://wiki.processmaker.com/3.0/Internal_Functions_and_Classes#PMPlugin::registerMenu.28.29
$this->registerMenu("processmaker", "menuodooStep.php");
//$this->registerMenu("processmaker", "menuConfigPage.php");
/**
* The first parameter of the registerStep() method is the external step's unique ID number,
* which was automatically generated by ProcessMaker. The second parameter is the name of the file(s)
* (without the extension) that will be executed when running the step. The third parameter
* is the name of the external step that is displayed to the user in ProcessMaker. Feel free to edit the external step's name.
* Invalid value specified for `step_uid_obj`. Maximum 32 characters allowed. 45538 85635 943a6 89c55 44001 10498 85
* Bad Request: Invalid value specified for `step_uid_obj`. Minimum 32 characters required.
*//*
$c = new Criteria();
$c->addDescendingOrderByColumn('ID');
$steps = OdooStepStepPeer::doSelect($c);
foreach ($steps as $step) {
$this->registerStep($step->getStepId(), "stepodooStepApplication",$step->getModel());
} */
//$this->registerStep("4553885635943a689c55440011049885", "stepodooStepApplication", "odooStep external step","stepodooStepApplication");
$oHeadPublisher = &headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript("odooStep/dependencies/jquery-3.2.1.min", false); //Adding a javascript file .js
$oHeadPublisher->addExtJsScript("odooStep/override", false); //Adding a javascript file .js
//void headPublisher::addExtJsScript(string $filename, boolean $debug = false, boolean $isExternal = false)
}
/**
* Code that is executed during the import of the plugin.
*/
public function install() {
}
/**
* Code that is executed during the activation of the plugin.
*/
public function enable() {
try{
$sql = file_get_contents(PATH_CORE . 'plugins/odooStep/data/mysql/schema.sql');
//require_once(PATH_DB . SYS_SYS . '/db.php');
//$dsn = DB_ADAPTER . ':dbname=' . DB_NAME . ';host=' . DB_HOST;
//$dsn = DB_ADAPTER . '://' . DB_USER . ':' . DB_PASS . '@' . DB_HOST . '/' . DB_NAME;
mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Error connecting to MySQL server: ' . mysql_error());
mysql_select_db(DB_NAME) or die('Error selecting MySQL database: ' . mysql_error());
$templine = '';
$lines = file(PATH_CORE . 'plugins/odooStep/data/mysql/schema.sql');
foreach ($lines as $line) {
if (substr($line, 0, 2) == '--' || $line == '') // Skip it if it's a comment
continue;
$templine .= $line;
if (substr(trim($line), -1, 1) == ';') { // If it has a semicolon at the end, it's the end of the query
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
$templine = '';
}
}
//echo "Tables imported successfully";
} catch(Exception $e) {
$G_PUBLISH = new Publisher;
$aMessage["MESSAGE"] = $e->getMessage();
$G_PUBLISH->AddContent("xmlform", "xmlform", "odooStep/messageShow", "", $aMessage);
G::RenderPage("publish", "blank");
}
}
/**
* Code that is executed during the disabling of the plugin.
*/
public function disable() {
try{
$sql = file_get_contents(PATH_CORE . 'plugins/odooStep/data/mysql/schema.sql');
//require_once(PATH_DB . SYS_SYS . '/db.php');
//$dsn = DB_ADAPTER . ':dbname=' . DB_NAME . ';host=' . DB_HOST;
//$dsn = DB_ADAPTER . '://' . DB_USER . ':' . DB_PASS . '@' . DB_HOST . '/' . DB_NAME;
mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Error connecting to MySQL server: ' . mysql_error());
mysql_select_db(DB_NAME) or die('Error selecting MySQL database: ' . mysql_error());
$templine = '';
$lines = file(PATH_CORE . 'plugins/odooStep/data/mysql/dropschema.sql');
foreach ($lines as $line) {
if (substr($line, 0, 2) == '--' || $line == '') // Skip it if it's a comment
continue;
$templine .= $line;
if (substr(trim($line), -1, 1) == ';') { // If it has a semicolon at the end, it's the end of the query
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
$templine = '';
}
}
//echo "Tables deleted successfully";
} catch(Exception $e) {
$G_PUBLISH = new Publisher;
$aMessage["MESSAGE"] = $e->getMessage();
$G_PUBLISH->AddContent("xmlform", "xmlform", "odooStep/messageShow", "", $aMessage);
G::RenderPage("publish", "blank");
}
}
}
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$oPluginRegistry->registerPlugin("odooStep", __FILE__);