Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 require_once 'class_menu_ref_sql.php';
00039
00040 class Extension extends Menu_Ref_sql
00041 {
00042 public function verify()
00043 {
00044
00045 if (trim($this->me_code)=="") throw new Exception('Le code ne peut pas être vide');
00046 if (trim($this->me_menu)=="") throw new Exception('Le nom ne peut pas être vide');
00047 if (trim($this->me_file)=="") throw new Exception('Chemin incorrect');
00048 if (file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'ext'.DIRECTORY_SEPARATOR.$this->me_file) == false)
00049 throw new Exception ('Extension non trouvée, le chemin est-il correct?');
00050 }
00051
00052 function search($p_what)
00053 {
00054 $this->me_code=strtoupper($p_what);
00055 if ( $this->load() == -1) return null;
00056 return 1;
00057 }
00058
00059
00060
00061
00062
00063 function can_request($p_login)
00064 {
00065 $cnt=$this->cn->get_value("select count(*) from menu_ref
00066 join profile_menu using (me_code)
00067 join profile_user using (p_id)
00068 where
00069 me_code=$1
00070 and user_name=$2",
00071 array($this->me_code,$p_login));
00072 if ( $cnt > 0) return 1;
00073 return 0;
00074 }
00075
00076
00077
00078
00079 static function make_array($cn)
00080 {
00081 $sql="select DISTINCT me_code as value, me_menu as label from ".
00082 " menu_ref join profile_menu using (me_code)
00083 join profile_user using (p_id) where ".
00084 " user_name=$1 and me_type='PL' ORDER BY ME_MENU";
00085 $a=$cn->get_array($sql,array($_SESSION['g_user']));
00086 return $a;
00087 }
00088 static function check_version($i)
00089 {
00090 global $version_noalyss;
00091 if ( ! isset ($version_noalyss) || $version_noalyss < $i )
00092 {
00093 alert('Cette extension ne fonctionne pas sur cette version de NOALYSS'.
00094 ' Veuillez mettre votre programme a jour. Version minimum '.$i);
00095 exit();
00096 }
00097 Extension::check_plugin_version();
00098 }
00099 function insert_plugin()
00100 {
00101 try
00102 {
00103 $this->cn->start();
00104 $this->verify();
00105
00106 $this->me_code = strtoupper($this->me_code);
00107 $count = $this->cn->get_value("select count(*) from menu_ref where me_code=$1", array($this->me_code));
00108 if ($count != 0)
00109 throw new Exception("Doublon");
00110 $this->me_type = 'PL';
00111 $this->insert();
00112
00113
00114
00115 $this->cn->exec_sql("insert into profile_menu(me_code,me_code_dep,p_type_display,p_id)
00116 values ($1,$2,$3,$4)",array($this->me_code,'EXT','S',1));
00117 $this->cn->commit();
00118 }
00119 catch (Exception $exc)
00120 {
00121 echo alert($exc->getMessage());
00122 }
00123 }
00124 function update_plugin()
00125 {
00126 try
00127 {
00128 $this->cn->start();
00129 $this->verify();
00130 $this->me_type = 'PL';
00131 $this->update();
00132 $this->cn->commit();
00133 }
00134 catch (Exception $exc)
00135 {
00136 echo alert($exc->getMessage());
00137 }
00138 }
00139 function remove_plugin()
00140 {
00141 try
00142 {
00143 $this->cn->start();
00144 $this->delete();
00145 $this->cn->commit();
00146 }
00147 catch (Exception $exc)
00148 {
00149 echo alert($exc->getMessage());
00150 }
00151 }
00152
00153
00154
00155
00156 static function clean(Database $p_cn)
00157 {
00158 $a_ext=array("tva_belge","amortissement","impdol","coprop","importbank");
00159 for($i=0;$i<count($a_ext);$i++){
00160 if ($p_cn->exist_schema($a_ext[$i])) {
00161 $p_cn->exec_sql("drop schema ".$a_ext[$i]." cascade");
00162 }
00163 }
00164 }
00165 static function check_plugin_version()
00166 {
00167 global $g_user,$version_plugin;
00168 if ($g_user->Admin() == 1)
00169 {
00170 if (SITE_UPDATE_PLUGIN != "")
00171 {
00172 $update = @file_get_contents(SITE_UPDATE_PLUGIN);
00173 if ($update > $version_plugin)
00174 {
00175 echo '<div class="inner_box" style="position:absolute;zindex:2;top:5px;left:360px">';
00176 echo '<p class="notice">';
00177 echo "Mise à jour disponible des plugins pour NOALYSS, version actuelle : $update votre version $version_plugin";
00178 echo '</p>';
00179 echo '</div>';
00180 }
00181 }
00182 }
00183 }
00184 }
00185