Ignore:
Timestamp:
Jun 9, 2011, 3:52:13 PM (13 years ago)
Author:
cljosse
Message:

[extensions] set_plugins Storing the state of the fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/set_plugins/main.inc.php

    r11249 r11276  
    5151 if ($page['tab']!="installed") return ;
    5252  Affiche_set_plugins();
    53 
    5453        break;
    5554
     
    7069  global $user, $template, $val,$page,$conf;
    7170    include_once(SET_PLUGINS_PATH."include/constants.php");       
    72     include_once(SET_PLUGINS_PATH.'include/affiche.php');
    73     $all_tpl_vars = $template->get_template_vars('plugins');
    74  
    75     if(!$all_tpl_vars)  return;     
    76  
    77 $val_state="";
    7871
    79 if(  isset($_POST['unset_plugins']) || isset($_POST['set_plugins'])  ){
    80  if(isset($_POST['unset_plugins'])  )
     72    $all_tpl_vars = $template->get_template_vars('plugins'); 
     73    if(!$all_tpl_vars)  return;   
     74
     75    include_once(SET_PLUGINS_PATH.'include/affiche.php');     
     76    $val_state="";
     77    if(  isset($_POST['unset_plugins']) || isset($_POST['set_plugins'])  ){
     78     if(isset($_POST['unset_plugins'])  )
    8179                    $val_state='inactive';
    8280      elseif(isset($_POST['set_plugins'])  )
    8381        $val_state='active';
    84       $nb=isset($_POST['nb'])?$_POST['nb']:$nb ;
    85    
     82   
     83
    8684    if($val_state!=""){ 
    87     if($val_state=="activate")
    88         $sens ="DESC";
    89     else
    90         $sens="ASC";
    91 
     85      if($val_state=="activate")
     86          $sens ="DESC";
     87      else
     88          $sens="ASC";
    9289    //==== pré-liste ===
    9390      $query = 'SELECT *
     
    9794           LIMIT '.$nb.'
    9895      ';
    99           $result = pwg_query($query);
    100    
    101 
    102  
     96          $result = pwg_query($query);
     97       
    10398      $query = '
    10499      UPDATE '.PLUGINS_TABLE.'
     
    106101      WHERE `state` NOT LIKE "'.$val_state. '" AND id!="' . "set_plugins" . '"
    107102      ORDER BY `id`  '.$sens.'
    108        LIMIT '.$nb.'
    109       ;';
     103      LIMIT '.$nb.';';
     104      pwg_query($query);
     105 //=====================================
    110106
    111        pwg_query($query);
    112  
    113     $data = array();
    114     if($result)
    115     while ($row = pwg_db_fetch_assoc($result))
    116     {
    117  
    118      $url =  $row['id'] ;$vers= $row['version'];
    119       array_push($data, array('plugin' => $url,'version'=>$vers) );
     107      $liste_plugins = array();
     108      if($result)
     109        while ($row = pwg_db_fetch_assoc($result)) {
     110       
     111         $url =  $row['id'] ;
     112         $vers= $row['version'];
     113         $state=$row['state'];
     114         array_push($liste_plugins, array('plugin' => $url,'version'=>$vers,'state' =>$state ) );
     115        }   
     116  //=====================================       
     117       
     118       
     119        $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
     120        save_config(); 
     121        unset ($_POST);
     122        redirect($redirect_url);
     123      }
    120124    }
    121      
    122       unset ($_POST);
    123         $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
    124          $config=array();
    125              $config = array(
    126                           'state' => $val_state,
    127                           'list'=>$data,
    128                           'nb' =>$nb
    129                       );
    130 
    131         conf_update_param('set_plugins', pwg_db_real_escape_string(serialize($config)));
    132         redirect($redirect_url);
    133     }
    134 }
    135  
    136 
    137125               $template->set_filenames(
    138126                array(
Note: See TracChangeset for help on using the changeset viewer.