if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); require_once NOALYSS_INCLUDE.'/class_extension.php'; /** * @file * @brief Automatic installation of plugins and activation */ global $cn; /****************************************************************************** * Scan the plugin folder and file in each subfolder a property file and * store them into an array a_plugin ****************************************************************************** */ $dirscan=scandir(NOALYSS_PLUGIN); $nb_dirscan=count($dirscan); $a_plugin=array(); for ($e=0;$e<$nb_dirscan;$e++) { if ($dirscan[$e] != '.' && $dirscan[$e]!='..' && is_dir(NOALYSS_PLUGIN.'/'.$dirscan[$e])) { $dir_plugin=$dirscan[$e]; if (file_exists(NOALYSS_PLUGIN.'/'.$dir_plugin.'/plugin.xml')) { $extension=Extension::read_definition(NOALYSS_PLUGIN.'/'.$dir_plugin.'/plugin.xml'); for ($i=0;$iget_array('select p_id,p_name from profile where p_id > 0 order by p_name'); $nb_profile=count($a_profile); /****************************************************************************** * save ******************************************************************************/ if ( isset ($_POST['save_plugin'])){ // retrieve array of plugin $plugin=HtmlInput::default_value_post('plugin', array()); // for each extension for ($i=0;$i<$nb_plugin;$i++) { $code=$a_plugin[$i]->me_code; // for each profile for ($e=0;$e<$nb_profile;$e++) { $profile=$a_profile[$e]['p_id']; if ( isset ($plugin[$code][$profile])) { // insert or update into db $count = $cn->get_value("select count(*) from menu_ref where me_code=$1", array($code)); if ( $count == 0 ) { $a_plugin[$i]->insert(); } try { $a_plugin[$i]->insert_profile_menu($profile,'EXT'); } catch (Exception $exc) { $profile_name=$cn->get_value('select profile.p_name from profile where p_id=$1' ,array($profile)); echo '

'; echo "code $code"," profile $profile_name ",$exc->getMessage(); echo '

'; } } else { // delete $a_plugin[$i]->remove_from_profile_menu ($profile); } } } } /****************************************************************************** * Display the Plugin and for each profile were it is installed or not ******************************************************************************/ ?>
get_array("select distinct p_id,p_name, (select count(*) from profile_menu as a where a.p_id=b.p_id and me_code=$1 )+ (select count(*) from menu_ref as c join profile_menu as d on (d.me_code=c.me_code) where d.p_id=b.p_id and me_file=$2 ) as cnt from profile as b where p_id > 0 order by p_name",array($a_plugin[$e]->me_code,$a_plugin[$e]->me_file)); $class=($e%2==0)?'odd':'even'; ?>
me_code); ?> me_menu); ?> me_description); ?> me_file); ?> me_code.']['.$a_profile[$w]['p_id'].']'); if ($a_profile[$w]['cnt']>0) $a->selected=true; echo $a->input(); echo $a_profile[$w]['p_name']; ?>