manage the extension, it involves the table extension
More...
|
| | __toString () |
| |
| | can_request ($p_login) |
| | return 1 if the user given in parameter can access this extension otherwise returns 0
|
| |
| | check_xml (SimpleXMLElement $xml) |
| | Check that the xml contains all the needed information to change them into a extension, the exception code is 0 if the element is optional.
|
| |
| | insert_plugin () |
| | Insert a plugin into the given profile, by default always insert into EXT.
|
| |
| | insert_profile_menu ($p_id=1) |
| | insert into the table profile_menu for the given profile id and depending of the module $p_module
|
| |
| | remove_from_profile_menu ($p_id) |
| |
| | remove_plugin () |
| |
| | save_plugin () |
| | save a plugin into MENU_REF , calls insert_plugin or update_plugin if it already exists
|
| |
| | search ($p_what) |
| | search a extension, the what is the column (extends_code
|
| |
| | update_plugin () |
| |
| | verify () |
| |
|
| static | check_plugin_version ($p_plugin_code) |
| | compare the version of the plugin and the last version , propose to update it if a new version exists
|
| |
| static | check_version ($i, $p_plugin_code=null) |
| | check the version of the plugin , null stands for one of the standard plugins, it means self::aStandard_plugin @global type $version_noalyss
|
| |
| static | clean (Database $p_cn) |
| | remove all the standard plugins schema
|
| |
| static | find_extension_code ($a_extension, $access_code) |
| | find the extension with the me_code = last part of access_code
|
| |
| static | get_version ($xml_file, $plugin_code) |
| | retrieve the version of the current plugin
|
| |
| static | make_array ($cn) |
| | make an array of the available plugin for the current user
|
| |
| static | read_definition ($p_file) |
| | Parse a XML file to complete an array of extension objects, in the plugin.xml file , you can find several plugins sharing some parts.
|
| |
|
| | $depend |
| | default depending menu (can be override by config menu)
|
| |
| | $noalyss_version |
| | minimum version of NOALYSS for this plugin
|
| |
| | $order |
| | $order in the menu (can be override by config menu)
|
| |
| | $schema |
| | default database schema to store data for the plugin
|
| |
| | $version |
| | Variables from plugin.xml.
|
| |
| const | aStandard_plugin |
| |
manage the extension, it involves the table extension
Data member
Definition at line 39 of file extension.class.php.
◆ __toString()
| Extension::__toString |
( |
| ) |
|
Definition at line 428 of file extension.class.php.
428 : string
429 {
431 $r .=
" me_code " . $this->me_code.PHP_EOL;
432 $r .=
" me_menu.".$this->me_menu.PHP_EOL;
433 $r .=
" version".$this->version.PHP_EOL;
434 $r .=
" noalyss_version".$this->noalyss_version.PHP_EOL;
435 $r .=
" me_file" . $this->me_file.PHP_EOL;
436 $r .=
" me_url" . $this->me_url.PHP_EOL;
437 $r .=
" me_description" . $this->me_description.PHP_EOL;
438 $r .=
" me_parameter" . $this->me_parameter.PHP_EOL;
439 $r .=
" me_javascript" . $this->me_javascript.PHP_EOL;
440 $r .=
" me_type" . $this->me_type.PHP_EOL;
441 $r .=
" me_descrition_etendue" . $this->me_description_etendue.PHP_EOL;
442 $r .=
" noalyss_version " . $this->noalyss_version.PHP_EOL;
443 $r .=
" version " . $this->version.PHP_EOL;
444 $r .=
" order " . $this->order.PHP_EOL;
445 $r .=
" depend " . $this->
depend.PHP_EOL;
446 return "Extension $r";
447 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
font $a_plugin[ $e] depend
References $r, and depend.
◆ can_request()
| Extension::can_request |
( |
| $p_login | ) |
|
return 1 if the user given in parameter can access this extension otherwise returns 0
- Parameters
-
- Returns
- 1 has access, 0 has no access
Definition at line 86 of file extension.class.php.
87 {
88 $cnt=$this->
cn->get_value(
"select count(*) from menu_ref
89 join profile_menu using (me_code)
90 join profile_user using (p_id)
91 where
92 me_code=$1
93 and user_name=$2", array($this->me_code, $p_login));
95 return 1;
96 return 0;
97 }
for($i=0; $i< $nb_vatex_code; $i++)($i % 2==0) ? " odd " $cnt
References $cnt, and cn.
◆ check_plugin_version()
| static Extension::check_plugin_version |
( |
| $p_plugin_code | ) |
|
|
static |
compare the version of the plugin and the last version , propose to update it if a new version exists
- Todo
- add a mechanism to check once a day @global User $g_user @global number $version_plugin
Definition at line 293 of file extension.class.php.
294 {
295 global
$g_user, $version_plugin;
297 {
298 if ( in_array($p_plugin_code, self::aStandard_plugin) && SITE_UPDATE_PLUGIN!="")
299 {
300 $update=@file_get_contents(SITE_UPDATE_PLUGIN);
301 if ($update>$version_plugin)
302 {
303 echo '<div id="version_plugin_div_id" class="inner_box" style="position:absolute;zindex:2;top:5px;left:37.5%;width:25%">';
304 echo '<p class="notice">';
305 echo "Mise à jour disponible des plugins pour NOALYSS, version actuelle : $update votre version $version_plugin";
306 echo '</p>';
307 echo '<p style="text-align:center">'.
308 '<a id="version_plugin_button" class="button" onclick="$(\'version_plugin_div_id\').remove()">'.
310 "</a></p>";
311 echo '</div>';
312 }
313 }
314 }
315 }
global $g_user
if no group available , then stop
_("actif, passif,charge,...")
References $g_user, and _.
Referenced by check_version().
◆ check_version()
| static Extension::check_version |
( |
| $i, |
|
|
| $p_plugin_code = null ) |
|
static |
check the version of the plugin , null stands for one of the standard plugins, it means self::aStandard_plugin @global type $version_noalyss
- Parameters
-
| type | $i | |
| type | $p_plugin_code | |
- Returns
- type
Definition at line 121 of file extension.class.php.
122 {
125 {
126 alert(
_(
'Cette extension ne fonctionne pas sur cette version de NOALYSS'.
127 ' Veuillez mettre votre programme a jour. Version minimum ').
$i);
128 return;
129 }
131 }
alert($p_msg, $buffer=false)
alert in javascript
static check_plugin_version($p_plugin_code)
compare the version of the plugin and the last version , propose to update it if a new version exists
References $i, $version_noalyss, _, alert(), and check_plugin_version().
◆ check_xml()
| Extension::check_xml |
( |
SimpleXMLElement | $xml | ) |
|
Check that the xml contains all the needed information to change them into a extension, the exception code is 0 if the element is optional.
Check XML.
- Parameters
-
- Exceptions
-
Definition at line 324 of file extension.class.php.
325 {
326 try
327 {
328 if (!isset(
$xml->plugin))
329 throw new Exception(
_(
'Manque plugin'), 1);
331
333 {
334 if (!isset(
$xml->plugin[
$i]->name))
335 throw new Exception(
_(
'Manque nom'), 1);
336 if (!isset(
$xml->plugin[
$i]->description))
337 throw new Exception(
_(
'Manque description'), 0);
338 if (!isset(
$xml->plugin[
$i]->code))
339 throw new Exception(
_(
'Manque code'), 1);
340 if (!isset(
$xml->plugin[
$i]->author))
341 throw new Exception(
_(
'Manque auteur'), 0);
342 if (!isset(
$xml->plugin[
$i]->root))
343 throw new Exception(
_(
'Manque répertoire racine'), 1);
344 if (!isset(
$xml->plugin[
$i]->file))
345 throw new Exception(
_(
'Manque fichier à inclure'), 1);
346 if (!isset(
$xml->plugin[
$i]->version))
347 throw new Exception(
_(
"Manque version de l'extension"), 1);
348
349 if (!isset(
$xml->plugin[
$i]->depend))
350 $xml->plugin[
$i]->depend=
"EXT";
351 if (!isset(
$xml->plugin[
$i]->order))
352 $xml->plugin[
$i]->order=9000;
353 }
354 }
355 catch (Exception
$ex)
356 {
358 }
359 }
for($e=0;$e< $nb_dirscan;$e++) $nb_plugin
References $ex, $i, $nb_plugin, $xml, and _.
◆ clean()
| static Extension::clean |
( |
Database | $p_cn | ) |
|
|
static |
remove all the standard plugins schema
- Parameters
-
Definition at line 275 of file extension.class.php.
276 {
277 $a_ext=array("tva_belge", "amortissement", "impdol", "coprop", "importbank");
278 for (
$i=0;
$i<count($a_ext);
$i++)
279 {
281 {
282 $p_cn->
exec_sql(
"drop schema ".$a_ext[
$i].
" cascade");
283 }
284 }
285 }
exec_sql($p_string, $p_array=null)
send a sql string to the database
exist_schema($p_name)
test if a schema exists
References $i, DatabaseCore\exec_sql(), and DatabaseCore\exist_schema().
◆ find_extension_code()
| static Extension::find_extension_code |
( |
| $a_extension, |
|
|
| $access_code ) |
|
static |
find the extension with the me_code = last part of access_code
- Parameters
-
| $a_extension | |
| $access_code | find the ME_CODE (normally last part ) |
- Returns
- the extension or null
Definition at line 416 of file extension.class.php.
416 :Extension|null
417 {
419 if (empty($a_me_code ) ) return null;
420 $nb_me_code=count($a_me_code);
424 }
425 return null;
426 }
catch(\Exception $e) $extension
References $access_code, $extension, and $me_code.
Referenced by get_version().
◆ get_version()
| static Extension::get_version |
( |
| $xml_file, |
|
|
| $plugin_code ) |
|
static |
retrieve the version of the current plugin
- Parameters
-
| $xml_file | always DIR."/plugin.xml" |
| $plugin_code | the plugin or $_REQUEST['ac'] |
- Returns
- int version or -1 if not found
Definition at line 455 of file extension.class.php.
455 :int
456 {
457 $aExtension=\Extension::read_definition($xml_file);
459 if ( empty($plugin_code)) return -1;
461 }
static find_extension_code($a_extension, $access_code)
find the extension with the me_code = last part of access_code
References $extension, find_extension_code(), and read_definition().
◆ insert_plugin()
| Extension::insert_plugin |
( |
| ) |
|
Insert a plugin into the given profile, by default always insert into EXT.
- Parameters
-
- Exceptions
-
| Exception | if duplicate or error db |
Definition at line 220 of file extension.class.php.
221 {
222 try
223 {
226
227 $this->me_code=strtoupper($this->me_code);
228 $count=$this->
cn->get_value(
"select count(*) from menu_ref where me_code=$1", array($this->me_code));
230 throw new Exception("Doublon");
231 $this->me_type='PL';
232 $this->insert();
234 }
235 catch (Exception $exc)
236 {
237 echo
alert($exc->getMessage());
238 }
239 }
References $count, alert(), cn, and verify().
Referenced by save_plugin().
◆ insert_profile_menu()
| Extension::insert_profile_menu |
( |
| $p_id = 1 | ) |
|
insert into the table profile_menu for the given profile id and depending of the module $p_module
- Parameters
-
- Exceptions
-
| Exception | 10 : profile absent , 20 module absent , 30 No parent menu |
Definition at line 140 of file extension.class.php.
141 {
143
145
148 {
149 throw new Exception(
_(
'Profil inexistant'), 10);
150 }
151
152
155 {
156 throw new Exception(
_(
'Module inexistant'), 20);
157 }
158
159 $dep_id=
$cn->get_array(
'select pm_id from profile_menu
160 where
161 p_id=$1
162 and me_code = $2 ', array(
$p_id, $p_module));
163
164 if (empty($dep_id))
165 {
166 $msg = sprintf(
_(
"Le menu %s dont dépend %s doit être crée ou %s doit être ajouté depuis le menu C0PROFL"),
167 $p_module,$this->me_code,$this->me_code);
168 throw new Exception(
$msg, 30);
169 }
171
172
174 {
175 $profil_menu=
new Profile_Menu(
$cn);
177 $profil_menu->me_code_dep=$p_module;
178 $profil_menu->p_type_display='S';
179 $profil_menu->p_id=
$p_id;
180 $profil_menu->pm_id_dep=$dep_id[
$i][
'pm_id'];
181 $profil_menu->pm_default=0;
183
184 $cnt=$profil_menu->count(
' where pm_id_dep=$3 and p_id=$1 and me_code = $2',
185 array(
$p_id, $this->me_code, $dep_id[
$i][
'pm_id']));
187 {
188 $profil_menu->insert();
189 }
190 }
191 }
$order
$order in the menu (can be override by config menu)
$depend
default depending menu (can be override by config menu)
foreach(array('magic_quotes_gpc', 'magic_quotes_runtime') as $a) $module
References $cn, $cnt, $depend, $i, $me_code, $module, $msg, $nb_dep, $order, $p_id, $profile, and _.
◆ make_array()
| static Extension::make_array |
( |
| $cn | ) |
|
|
static |
make an array of the available plugin for the current user
- Returns
- an array
- See also
- ISelect
Definition at line 104 of file extension.class.php.
105 {
106 $sql=
"select DISTINCT me_code as value, me_menu as label from ".
107 " menu_ref join profile_menu using (me_code)
108 join profile_user using (p_id) where ".
109 " user_name=$1 and me_type='PL' ORDER BY ME_MENU";
110 $a=
$cn->get_array(
$sql, array($_SESSION[SESSION_KEY.
'g_user']));
112 }
References $a, $cn, and $sql.
◆ read_definition()
| static Extension::read_definition |
( |
| $p_file | ) |
|
|
static |
Parse a XML file to complete an array of extension objects, in the plugin.xml file , you can find several plugins sharing some parts.
- Parameters
-
- Returns
- array array of Extension
Definition at line 368 of file extension.class.php.
369 {
371 $dom=new DomDocument('1.0');
372 $dom->load($p_file);
373 $xml=simplexml_import_dom($dom);
375 $a_extension=array();
377 {
378
380 try
381 {
383 }
384 catch (Exception
$ex)
385 {
387 if (
$ex->getCode()==1)
388 {
389 continue;
390 }
391 }
402 $extension->noalyss_version=(isset(
$xml->plugin[
$i]->noalyss_version))?trim(
$xml->plugin[
$i]->noalyss_version):8000;
404
406 }
407 return $a_extension;
408 }
echo_warning($p_string)
warns
References $cn, $ex, $extension, $i, $nb_plugin, $xml, and echo_warning().
Referenced by get_version().
◆ remove_from_profile_menu()
| Extension::remove_from_profile_menu |
( |
| $p_id | ) |
|
Definition at line 193 of file extension.class.php.
194 {
196
197 $cn->exec_sql(
'delete from profile_menu where (me_code = $1 or me_code in (select me_code from menu_ref where me_file=$2)) and p_id=$3',
198 array($this->me_code, $this->me_file,
$p_id));
199 }
References $cn, and $p_id.
◆ remove_plugin()
| Extension::remove_plugin |
( |
| ) |
|
Definition at line 257 of file extension.class.php.
258 {
259 try
260 {
262 $this->delete();
264 }
265 catch (Exception $exc)
266 {
267 echo
alert($exc->getMessage());
268 }
269 }
References alert(), and cn.
◆ save_plugin()
| Extension::save_plugin |
( |
| ) |
|
save a plugin into MENU_REF , calls insert_plugin or update_plugin if it already exists
- Returns
- void
Definition at line 205 of file extension.class.php.
206 {
207 if ( $this->
cn->get_value(
"select count(*) from menu_ref where me_code=$1",[$this->me_code]) > 0) {
209 } else {
211
212 }
213 }
insert_plugin()
Insert a plugin into the given profile, by default always insert into EXT.
References cn, insert_plugin(), and update_plugin().
◆ search()
| Extension::search |
( |
| $p_what | ) |
|
search a extension, the what is the column (extends_code
Definition at line 72 of file extension.class.php.
73 {
74 $this->me_code=strtoupper($p_what);
75 if ($this->load()==false)
76 return null;
77 return 1;
78 }
◆ update_plugin()
| Extension::update_plugin |
( |
| ) |
|
◆ verify()
Definition at line 57 of file extension.class.php.
58 {
59
60 if (trim($this->me_code)=="")
61 throw new Exception('Le code ne peut pas être vide');
62 if (trim($this->me_menu)=="")
63 throw new Exception('Le nom ne peut pas être vide');
64 if (trim($this->me_file)=="")
65 throw new Exception('Chemin incorrect');
66 if (file_exists(NOALYSS_PLUGIN.'/'.$this->me_file)==false)
67 throw new Exception("$this->me_code $this->me_file".'Extension non trouvée, le chemin est-il correct?');
68 }
Referenced by insert_plugin(), and update_plugin().
◆ $depend
◆ $noalyss_version
| Extension::$noalyss_version |
◆ $order
◆ $schema
◆ $version
◆ aStandard_plugin
| const Extension::aStandard_plugin |
Initial value:=
array('AMORTIS','BACKNOADM','COPRO','IMPCARD',
'IMPORTBANK','INVOICING','LISTING',
'MODOP','RAPAV','SAV',
'TOOLPCMN','TOOLS','TRANSFORM',
'TVA')
Definition at line 42 of file extension.class.php.
The documentation for this class was generated from the following file: