/[phpcompta]/phpcompta/include/class_user.php
ViewVC logotype

Diff of /phpcompta/include/class_user.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by sparkyx, Tue Oct 25 12:10:28 2005 UTC revision 1.15 by sparkyx, Tue Oct 25 13:21:14 2005 UTC
# Line 106  class cl_user { Line 106  class cl_user {
106                $_SESSION['use_name']=$r['use_name'];                $_SESSION['use_name']=$r['use_name'];
107                $_SESSION['use_first_name']=$r['use_first_name'];                $_SESSION['use_first_name']=$r['use_first_name'];
108                                
               $this->theme=$_SESSION['g_theme'];  
109                $this->admin=$_SESSION['use_admin'];                $this->admin=$_SESSION['use_admin'];
110                $this->name=$_SESSION['use_name'];                $this->name=$_SESSION['use_name'];
111                $this->first_name=$_SESSION['use_first_name'];                $this->first_name=$_SESSION['use_first_name'];
# Line 281  function GetPreferences () Line 280  function GetPreferences ()
280    
281  function GetGlobalPref()  function GetGlobalPref()
282  {  {
283            echo_debug(__FILE__,__LINE__,"function GetGlobalPref");
284    $cn=Dbconnect();    $cn=Dbconnect();
285    // Load everything in an array    // Load everything in an array
286    $Res=ExecSql ($cn,"select parameter_type,parameter_value from    $Res=ExecSql ($cn,"select parameter_type,parameter_value from
287                    user_global_pref                    user_global_pref
288                    where user_id='".$this->id."'");                    where user_id='".$this->id."'");
289    $Max=pg_NumRows($Res);    $Max=pg_NumRows($Res);
290    if (  $Max == 0 ) return null;    if (  $Max == 0 ) {
291              $this->insert_default_global_pref();
292              $this->GetGlobalPref();
293              return;
294              }
295    // Load value into array    // Load value into array
296    $line=array();    $line=array();
297    for ($i=0;$i<$Max;$i++) {    for ($i=0;$i<$Max;$i++) {
# Line 298  function GetGlobalPref() Line 302  function GetGlobalPref()
302    // save array into g_ variable    // save array into g_ variable
303    $array_pref=array ('g_theme'=>'THEME','g_pagesize'=>'PAGESIZE');    $array_pref=array ('g_theme'=>'THEME','g_pagesize'=>'PAGESIZE');
304    foreach ($array_pref as $name=>$parameter ) {    foreach ($array_pref as $name=>$parameter ) {
305              if ( ! isset ($line[$parameter]) ) {
306                      echo_debug("Missing pref : ".$parameter);
307                      $this->insert_default_global_pref($parameter);
308                    $this->GetGlobalPref();
309                    return;
310                    }      
311      $_SESSION[$name]=$line[$parameter];      $_SESSION[$name]=$line[$parameter];
312    }    }
313  }  }
314    
315    /* function insert_default_global_pref
316     **************************************************
317     * Purpose : insert default pref
318     *        if no parameter are given insert all the existing
319     *        parameter otherwise only the requested
320     * parm :
321     *      - parameter's type or nothing
322     * gen :
323     *      - none
324     * return: nothing
325     */
326    function insert_default_global_pref($p_type="",$p_value="") {
327            echo_debug(__FILE__,__LINE__,"function insert_default_global_pref");
328            echo_debug(__FILE__,__LINE__,"parameter p_type $p_type p_value  $p_value");
329    
330            $default_parameter= array("THEME"=>"Light",
331                    "PAGESIZE"=>"50");
332            $cn=Dbconnect();
333            $Sql="insert into user_global_pref(user_id,parameter_type,parameter_value)
334                                    values ('%s','%s','%s')";
335            if ( $p_type == "" ) {
336                    foreach ( $default_parameter as $name=>$value) {
337                            $Insert=sprintf($Sql,$this->id,$name,$value);
338                            ExecSql($cn,$Insert);
339                    }
340            }
341            else {
342                    $value=($p_value=="")?$default_parameter[$p_type]:$p_value;
343                    $Insert=sprintf($Sql,$this->id,$p_type,$value);
344                    ExecSql($cn,$Insert);
345            }
346    
347    
348    }
349    
350    /* function update_global_pref
351     **************************************************
352     * Purpose : update default pref
353     *           if value is not given then use the default value
354     * parm :
355     *      - parameter's type
356     *      - parameter's value value of the type
357     * gen :
358     *      - none
359     * return: nothing
360     */
361    function update_global_pref($p_type,$p_value="") {
362            $default_parameter= array("THEME"=>"Light",
363                    "PAGESIZE"=>"50");
364            $cn=Dbconnect();
365            $Sql="update user_global_pref set parameter_value='%s'
366                            where parameter_type='%s' and
367                                    user_id='%s'";
368            $value=($p_value=="")?$default_parameter[$p_type]:$p_value;
369            $Update=sprintf($Sql,$value,$p_type,$this->id);
370            ExecSql($cn,$Update);
371    
372     }//end function
373  }  }
374  ?>  ?>

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26