[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 04/05: Plugin : can specify what is the paren
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 04/05: Plugin : can specify what is the parent menu |
Date: |
Sun, 26 Feb 2017 09:06:04 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit a354944e467bc3783476a192dcb3db9f87a21d10
Author: Dany De Bontridder <address@hidden>
Date: Sun Feb 26 15:04:26 2017 +0100
Plugin : can specify what is the parent menu
---
doc/manuel-fr.odt | Bin 295880 -> 295572 bytes
include/cfgplugin.inc.php | 9 +++++++--
include/class/class_extension.php | 38 ++++++++++++++++++++++++--------------
3 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/doc/manuel-fr.odt b/doc/manuel-fr.odt
index 4c8bf63..b01a836 100644
Binary files a/doc/manuel-fr.odt and b/doc/manuel-fr.odt differ
diff --git a/include/cfgplugin.inc.php b/include/cfgplugin.inc.php
index 188f8c9..c11d599 100644
--- a/include/cfgplugin.inc.php
+++ b/include/cfgplugin.inc.php
@@ -78,7 +78,7 @@ if ( isset ($_POST['save_plugin'])){
}
try
{
- $a_plugin[$i]->insert_profile_menu($profile,'EXT');
+ $a_plugin[$i]->insert_profile_menu($profile);
}
catch (Exception $exc)
{
@@ -134,7 +134,12 @@ if ( isset ($_POST['save_plugin'])){
<?php echo h($a_plugin[$e]->me_menu); ?>
</td>
<td>
- <?php echo h($a_plugin[$e]->me_description); ?>
+ <?php echo h($a_plugin[$e]->me_description);?>
+ <span style="display:block">
+ <?php
+ printf(_("Installé par défaut dans
%s"),$a_plugin[$e]->depend);
+ ?>
+ </span>
</td>
<td>
<?php echo h($a_plugin[$e]->me_file); ?>
diff --git a/include/class/class_extension.php
b/include/class/class_extension.php
index 4ba9c69..54c6931 100644
--- a/include/class/class_extension.php
+++ b/include/class/class_extension.php
@@ -104,12 +104,13 @@ class Extension extends Menu_Ref_sql
* of the module $p_module
* @remark type $cn
* @param type $p_id profile.p_id
- * @param type $p_module menu_ref.me_code
* @throws Exception 10 : profile absent , 20 module absent , 30 No parent
menu
*/
- function insert_profile_menu($p_id=1,$p_module='EXT')
+ function insert_profile_menu($p_id=1)
{
global $cn;
+ // Module for the plugin
+ $p_module=$this->depend;
//profile exists ?
$profile=new Profile_sql($cn,$p_id);
if ( $profile->p_id != $p_id) {
@@ -121,25 +122,32 @@ class Extension extends Menu_Ref_sql
throw new Exception(_('Module inexistant'),20);
}
// Dependency
- $dep_id=$cn->get_value('select pm_id from profile_menu
+ $dep_id=$cn->get_array('select pm_id from profile_menu
where
p_id=$1
and me_code = $2 ',array($p_id,$p_module));
// throw an exception if there is no dependency
- if ($dep_id=="") {
+ if (empty($dep_id)) {
throw new Exception(_('Pas de menu ').$p_module,30);
}
+ $nb_dep=count($dep_id);
- $profil_menu=new Profile_Menu($cn);
- $profil_menu->me_code=$this->me_code;
- $profil_menu->me_code_dep=$p_module;
- $profil_menu->p_type_display='S';
- $profil_menu->p_id=$p_id;
- $profil_menu->pm_id_dep=$dep_id;
-
- $cnt=$profil_menu->count(' where p_id=$1 and me_code =
$2',array($p_id,$this->me_code));
- if ( $cnt==0) {
- $profil_menu->insert();
+ // insert at the right location
+ for ($i=0;$i<$nb_dep;$i++)
+ {
+ $profil_menu=new Profile_Menu($cn);
+ $profil_menu->me_code=$this->me_code;
+ $profil_menu->me_code_dep=$p_module;
+ $profil_menu->p_type_display='S';
+ $profil_menu->p_id=$p_id;
+ $profil_menu->pm_id_dep=$dep_id[$i]['pm_id'];
+ $profil_menu->pm_default=0;
+ $profil_menu->p_order=9000;
+
+ $cnt=$profil_menu->count(' where p_id=$1 and me_code =
$2',array($p_id,$this->me_code));
+ if ( $cnt==0) {
+ $profil_menu->insert();
+ }
}
@@ -262,6 +270,7 @@ class Extension extends Menu_Ref_sql
if ( !isset ($xml->plugin[$i]->author)) throw new
Exception(_('Manque auteur'),0);
if ( !isset ($xml->plugin[$i]->root)) throw new
Exception(_('Manque répertoire racine'),1);
if ( !isset ($xml->plugin[$i]->file)) throw new
Exception(_('Manque fichier à inclure'),1);
+ if ( !isset ($xml->plugin[$i]->depend))
$xml->plugin[$i]->depend="EXT";
}
} catch (Exception $ex) {
throw $ex;
@@ -301,6 +310,7 @@ class Extension extends Menu_Ref_sql
$extension->me_type='PL';
$extension->me_menu=trim($xml->plugin[$i]->name);
$extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code);
+
$extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):"";
$a_extension[]=clone $extension;
}
return $a_extension;