Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.workspace.php

    r2229 r2566  
    2222     protected $table;        ///< <b>string</b> Preferences table name 
    2323     protected $user_id;      ///< <b>string</b> User ID 
    24       
     24 
    2525     protected $global_prefs = array(); ///< <b>array</b> Global prefs array 
    2626     protected $local_prefs = array();  ///< <b>array</b> Local prefs array 
    2727     protected $prefs = array();        ///< <b>array</b> Associative prefs array 
    2828     protected $ws;           ///< <b>string</b> Current workspace 
    29       
     29 
    3030     /** 
    3131     Object constructor. Retrieves user prefs and puts them in $prefs 
    3232     array. Local (user) prefs have a highest priority than global prefs. 
    33       
     33 
    3434     @param    name      <b>string</b>       ID for this workspace 
    3535     */ 
     
    4141               throw new Exception(sprintf(__('Invalid dcWorkspace: %s'),$name)); 
    4242          } 
    43            
     43 
    4444          $this->con =& $core->con; 
    4545          $this->table = $core->prefix.'pref'; 
    4646          $this->user_id =& $user_id; 
    47            
     47 
    4848          try {$this->getPrefs($rs);} catch (Exception $e) { 
    4949               if (version_compare($core->getVersion('core'),'2.3','>')) { 
     
    5252          } 
    5353     } 
    54       
     54 
    5555     private function getPrefs($rs=null) 
    56      {     
     56     { 
    5757          if ($rs == null) { 
    5858               $strReq = 'SELECT user_id, pref_id, pref_value, '. 
     
    6363                         "AND pref_ws = '".$this->con->escape($this->ws)."' ". 
    6464                         'ORDER BY pref_id ASC '; 
    65            
     65 
    6666               try { 
    6767                    $rs = $this->con->select($strReq); 
     
    7878               $value = $rs->f('pref_value'); 
    7979               $type = $rs->f('pref_type'); 
    80                 
     80 
    8181               if ($type == 'float' || $type == 'double') { 
    8282                    $type = 'float'; 
     
    8484                    $type = 'string'; 
    8585               } 
    86                 
     86 
    8787               settype($value,$type); 
    88                 
     88 
    8989               $array = $rs->user_id ? 'local' : 'global'; 
    90                 
     90 
    9191               $this->{$array.'_prefs'}[$id] = array( 
    9292                    'ws' => $this->ws, 
     
    9797               ); 
    9898          } 
    99            
     99 
    100100          $this->prefs = $this->global_prefs; 
    101            
     101 
    102102          foreach ($this->local_prefs as $id => $v) { 
    103103               $this->prefs[$id] = $v; 
    104104          } 
    105            
     105 
    106106          return true; 
    107107     } 
    108       
     108 
    109109     public function prefExists($id,$global=false) 
    110110     { 
     
    112112          return isset($this->{$array.'_prefs'}[$id]); 
    113113     } 
    114       
     114 
    115115     /** 
    116116     Returns pref value if exists. 
    117       
     117 
    118118     @param    n         <b>string</b>       Pref name 
    119119     @return   <b>mixed</b> 
     
    124124               return $this->prefs[$n]['value']; 
    125125          } 
    126            
     126 
    127127          return null; 
    128128     } 
     
    130130     /** 
    131131     Returns global pref value if exists. 
    132       
     132 
    133133     @param    n         <b>string</b>       Pref name 
    134134     @return   <b>mixed</b> 
     
    139139               return $this->global_prefs[$n]['value']; 
    140140          } 
    141            
     141 
    142142          return null; 
    143143     } 
    144       
     144 
    145145     /** 
    146146     Returns local pref value if exists. 
    147       
     147 
    148148     @param    n         <b>string</b>       Pref name 
    149149     @return   <b>mixed</b> 
     
    154154               return $this->local_prefs[$n]['value']; 
    155155          } 
    156            
     156 
    157157          return null; 
    158      }     
     158     } 
    159159     /** 
    160160     Magic __get method. 
     
    165165          return $this->get($n); 
    166166     } 
    167       
     167 
    168168     /** 
    169169     Sets a pref in $prefs property. This sets the pref for script 
    170170     execution time only and if pref exists. 
    171       
     171 
    172172     @param    n         <b>string</b>       Pref name 
    173173     @param    v         <b>mixed</b>        Pref value 
     
    179179          } 
    180180     } 
    181       
     181 
    182182     /** 
    183183     Magic __set method. 
     
    188188          $this->set($n,$v); 
    189189     } 
    190       
     190 
    191191     /** 
    192192     Creates or updates a pref. 
    193       
     193 
    194194     $type could be 'string', 'integer', 'float', 'boolean' or null. If $type is 
    195195     null and pref exists, it will keep current pref type. 
    196       
     196 
    197197     $value_change allow you to not change pref. Useful if you need to change 
    198198     a pref label or type and don't want to change its value. 
    199       
     199 
    200200     @param    id             <b>string</b>       Pref ID 
    201201     @param    value          <b>mixed</b>        Pref value 
     
    210210               throw new Exception(sprintf(__('%s is not a valid pref id'),$id)); 
    211211          } 
    212            
     212 
    213213          # We don't want to change pref value 
    214214          if (!$value_change) 
     
    220220               } 
    221221          } 
    222            
     222 
    223223          # Pref type 
    224224          if ($type == 'double') 
     
    240240               $type = 'string'; 
    241241          } 
    242            
     242 
    243243          # We don't change label 
    244244          if ($label == null) 
     
    250250               } 
    251251          } 
    252            
     252 
    253253          settype($value,$type); 
    254            
     254 
    255255          $cur = $this->con->openCursor($this->table); 
    256256          $cur->pref_value = ($type == 'boolean') ? (string) (integer) $value : (string) $value; 
    257257          $cur->pref_type = $type; 
    258258          $cur->pref_label = $label; 
    259            
     259 
    260260          #If we are local, compare to global value 
    261261          if (!$global && $this->prefExists($id,true)) 
     
    264264               $same_pref = $g['ws'] == $this->ws && $g['value'] == $value 
    265265               && $g['type'] == $type && $g['label'] == $label; 
    266                 
     266 
    267267               # Drop pref if same value as global 
    268268               if ($same_pref && $this->prefExists($id,false)) { 
     
    272272               } 
    273273          } 
    274            
     274 
    275275          if ($this->prefExists($id,$global) && $this->ws == $this->prefs[$id]['ws']) 
    276276          { 
     
    280280                    $where = "WHERE user_id = '".$this->con->escape($this->user_id)."' "; 
    281281               } 
    282                 
     282 
    283283               $cur->update($where."AND pref_id = '".$this->con->escape($id)."' AND pref_ws = '".$this->con->escape($this->ws)."' "); 
    284284          } 
     
    288288               $cur->user_id = $global ? null : $this->user_id; 
    289289               $cur->pref_ws = $this->ws; 
    290                 
     290 
    291291               $cur->insert(); 
    292292          } 
     
    305305               throw new Exception(__('No workspace specified')); 
    306306          } 
    307            
     307 
    308308          if (!array_key_exists($oldId,$this->prefs) || array_key_exists($newId,$this->prefs)) { 
    309309               return false; 
     
    322322          return true; 
    323323     } 
    324       
    325      /** 
    326      Removes an existing pref. Workspace  
    327       
     324 
     325     /** 
     326     Removes an existing pref. Workspace 
     327 
    328328     @param    id        <b>string</b>       Pref ID 
    329329     @param    force_global   <b>boolean</b> Force global pref drop 
     
    334334               throw new Exception(__('No workspace specified')); 
    335335          } 
    336            
     336 
    337337          $strReq = 'DELETE FROM '.$this->table.' '; 
    338            
     338 
    339339          if (($force_global) || ($this->user_id === null)) { 
    340340               $strReq .= 'WHERE user_id IS NULL '; 
     
    344344               $global = false; 
    345345          } 
    346            
     346 
    347347          $strReq .= "AND pref_id = '".$this->con->escape($id)."' "; 
    348348          $strReq .= "AND pref_ws = '".$this->con->escape($this->ws)."' "; 
    349            
     349 
    350350          $this->con->execute($strReq); 
    351            
     351 
    352352          if ($this->prefExists($id,$global)) { 
    353353               $array = $global ? 'global' : 'local'; 
     
    362362 
    363363     /** 
    364      Removes all existing pref. in a Workspace  
    365       
     364     Removes all existing pref. in a Workspace 
     365 
    366366     @param    force_global   <b>boolean</b> Force global pref drop 
    367367     */ 
     
    371371               throw new Exception(__('No workspace specified')); 
    372372          } 
    373            
     373 
    374374          $strReq = 'DELETE FROM '.$this->table.' '; 
    375            
     375 
    376376          if (($force_global) || ($this->user_id === null)) { 
    377377               $strReq .= 'WHERE user_id IS NULL '; 
     
    381381               $global = false; 
    382382          } 
    383            
     383 
    384384          $strReq .= "AND pref_ws = '".$this->con->escape($this->ws)."' "; 
    385            
     385 
    386386          $this->con->execute($strReq); 
    387            
     387 
    388388          $array = $global ? 'global' : 'local'; 
    389389          unset($this->{$array.'_prefs'}); 
    390390          $this->{$array.'_prefs'} = array(); 
    391            
     391 
    392392          $array = $global ? 'local' : 'global'; 
    393393          $this->prefs = $this->{$array.'_prefs'}; 
    394394     } 
    395       
     395 
    396396     /** 
    397397     Returns $prefs property content. 
    398       
     398 
    399399     @return   <b>array</b> 
    400400     */ 
     
    403403          return $this->prefs; 
    404404     } 
    405       
     405 
    406406     /** 
    407407     Returns $local_prefs property content. 
    408       
     408 
    409409     @return   <b>array</b> 
    410410     */ 
     
    416416     /** 
    417417     Returns $global_prefs property content. 
    418       
     418 
    419419     @return   <b>array</b> 
    420420     */ 
     
    425425 
    426426} 
    427 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map