[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/forms/ -> FormGroup.class.php (source)

   1  <?php
   2  /* 

   3   * phpMyVisites : website statistics and audience measurements

   4   * Copyright (C) 2002 - 2006

   5   * http://www.phpmyvisites.net/ 

   6   * phpMyVisites is free software (license GNU/GPL)

   7   * Authors : phpMyVisites team

   8  */
   9  
  10  // $Id: FormGroup.class.php 202 2007-01-18 04:08:48Z matthieu_ $

  11  
  12  
  13  
  14  require_once  INCLUDE_PATH . "/core/forms/Form.class.php";
  15  require_once  INCLUDE_PATH . "/core/include/SiteConfigDb.class.php";
  16  
  17  class FormGroup extends Form
  18  {
  19      
  20      var $valueName = '';
  21      var $valueMainUrl = '';
  22      var $valueLogo = 1;
  23      var $valueRecordGet = 'all';
  24      var $valueVariableNames = '';
  25      var $site;
  26      
  27  	function FormGroup( &$template, $siteAdmin)
  28      {
  29          parent::Form( $template);
  30          $this->idSite = $siteAdmin;
  31      }
  32      
  33  	function process()
  34      {
  35          /* 

  36           * OLD VERSION 

  37                

  38          $this->user = new UserConfigDb();

  39          

  40          $groups = $this->user->getGroups();

  41          

  42          $groups['no_permission'] = "No permission";

  43          foreach($groups as $id => $name)

  44          {

  45              $usersInGroup = $this->user->getUserByGroup( $id, $this->idSite );

  46              

  47              $formElements = array();

  48              

  49              foreach($usersInGroup as $info)

  50              {

  51                  

  52                  // general input

  53                  $formElements[] = array('checkbox',

  54                                          $info['login'],

  55                                          ' ',

  56                                          $info['alias'] . " (login : ". $info['login'].")"

  57                                          // ". $info['email']

  58                                      );

  59              }

  60              

  61              $groupCopy = $groups;

  62              $groupCopy = array_merge( array( 0 => $GLOBALS['lang']['admin_move_select']), 

  63                              $groupCopy);

  64              unset($groupCopy[$id]);

  65              

  66              $formElements[] = array('select',

  67                                      'group_to_move_to_'.$id,

  68                                      $GLOBALS['lang']['admin_move_group'],

  69                                      $groupCopy

  70                                  );

  71              

  72              $description = array();

  73              if($name == 'admin')

  74              {

  75                  $description['name'] = $GLOBALS['lang']['admin_group_admin_n'];

  76                  $description['description'] = $GLOBALS['lang']['admin_group_admin_d'];

  77              }

  78              elseif($name == 'view')

  79              {

  80                  $description['name'] = $GLOBALS['lang']['admin_group_view_n'];

  81                  $description['description'] = $GLOBALS['lang']['admin_group_view_d'];

  82              }

  83              else

  84              {

  85                  $description['name'] = $GLOBALS['lang']['admin_group_noperm_n'];

  86                  $description['description'] = $GLOBALS['lang']['admin_group_noperm_d'];

  87              }                

  88              $descriptionTxt = "<u>".$GLOBALS['lang']['generique_name']."</u> <b>$name</b> (".$description['name'] . ")<br><u>".$GLOBALS['lang']['generique_description'].

  89                                  "</u> " . $description['description']."<br>";    

  90              $this->addElements( $formElements , $descriptionTxt);

  91              

  92          }

  93          

  94          // launche process

  95          return parent::process( 'admin_group_title' );

  96          */
  97          
  98          // New version

  99          $this->user = new UserConfigDb();
 100          $o_user =& User::getInstance();
 101          
 102          $groups = $this->user->getGroups();
 103          $users = $o_user->getAllUsers();
 104          $users['anonymous'] = "Anonymous";
 105          $userRight = array();
 106  
 107          foreach($users as $login => $name)
 108          {
 109              $userRight[$login] = array();
 110              if (empty($name)) 
 111              {
 112                  $userRight[$login][0] = $login;
 113              }
 114              else 
 115              {
 116                  $userRight[$login][0] = $name;
 117              }
 118              $userRight[$login][1] = "no_permission";
 119          }
 120          
 121          
 122          foreach($groups as $id => $name)
 123          {
 124              $usersInGroup = $this->user->getUserByGroup( $id, $this->idSite );
 125              
 126              foreach($usersInGroup as $info)
 127              {
 128                  $userRight[$info['login']][1] = $id;
 129              }
 130          }
 131          $groups['no_permission'] = "No permission";
 132          
 133          $this->tpl->assign('id_site', $this->idSite);
 134          $this->tpl->assign('groups_available', $groups);
 135          $this->tpl->assign('users_available', $userRight);
 136          $this->tpl->assign('nb_users_available', count($userRight));
 137                  
 138          // launche process

 139          return parent::process( 'admin_group_title' );
 140          // End new Version

 141          
 142      }
 143      
 144  	function postProcess()
 145      {    
 146          /* 

 147           * OLD VERSION 

 148                

 149          $submitValues = $this->getSubmitValues();

 150          $loginValidated = array();

 151          //var_dump($submitValues);

 152          

 153          foreach($submitValues as $name => $value)

 154          {

 155              // new group detected

 156              if(substr_count( $name, 'group_to_move_to_') > 0)

 157              {

 158                  if($value !== '0')

 159                  {

 160                      //print_r($loginValidated);

 161                      

 162                      $this->user->setSiteGroups( $this->idSite, $value, $loginValidated);

 163                      

 164                      $loginValidated = array();

 165                  }

 166              }

 167              else

 168              {

 169                  $loginValidated[] = $name;

 170              }

 171          }

 172          $infoSite = array(    

 173              // db field name => new value

 174              'name' => $this->getSubmitValue('form_name'),

 175              'logo' => $this->getSubmitValue('form_logo'),

 176              'params_choice' => $this->getSubmitValue('form_params'),

 177          );

 178          

 179          $urlSite = $this->getSubmitValue('form_url');

 180          

 181          $params_names = $this->getSubmitValue('form_params_names');

 182          

 183          if(!empty($params_names))

 184          {

 185              $infoSite['params_names'] = $params_names;

 186          }

 187          */
 188          
 189          // New version

 190          $this->idSite = $this->getSubmitValue("id_site");
 191          $nbUser = $this->getSubmitValue("nb_users_available");
 192          $loginValidatedByGroup = array();
 193          // Read info

 194          for ($i =1; $i <= $nbUser; $i++ ) {
 195              $idgroup = $this->getSubmitValue('right'.$i);
 196              $login = $this->getSubmitValue('name'.$i);
 197              if (! isset($loginValidatedByGroup[$idgroup])) {
 198                  $loginValidatedByGroup[$idgroup] = array();
 199              }
 200              $loginValidatedByGroup[$idgroup][] = $login;
 201          }
 202          
 203          //var_dump($this->getSubmitValues());

 204          // Save data

 205          foreach($loginValidatedByGroup as $id => $loginValidated) 
 206          {
 207              $this->user->setSiteGroups( $this->idSite, $id, $loginValidated);
 208          }
 209              
 210      }
 211  }
 212  ?>


Généré le : Mon Nov 26 14:10:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics