/[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.11 by sparkyx, Wed Jul 27 16:32:05 2005 UTC revision 1.12 by sparkyx, Sun Oct 23 18:53:37 2005 UTC
# Line 60  class cl_user { Line 60  class cl_user {
60               use_name,               use_name,
61               use_login,               use_login,
62               use_active,               use_active,
63               use_admin from ac_users               use_admin
64                         from ac_users
65               where use_id=$p_id";               where use_id=$p_id";
66      $Res=pg_exec($p_cn,$Sql);        $cn=DbConnect();
67      if (($Max=pg_NumRows($Res)) == 0 ) return -1;        $Res=pg_exec($cn,$Sql);
68      $row=pg_fetch_array($Res,0);        if (($Max=pg_NumRows($Res)) == 0 ) return -1;
69      $this->first_name=$row['use_first_name'];        $row=pg_fetch_array($Res,0);
70      $this->name=$row['use_name'];        $this->first_name=$row['use_first_name'];
71      $this->active=$row['use_active'];        $this->name=$row['use_name'];
72      $this->login=$row['use_login'];        $this->active=$row['use_active'];
73      $this->admin=$row['use_admin'];        $this->login=$row['use_login'];
74          $this->admin=$row['use_admin'];
75      }      }
76    }    }
77    /*++    /*++
# Line 87  class cl_user { Line 89  class cl_user {
89                    
90          $res=0;          $res=0;
91          $pass5=md5($this->pass);          $pass5=md5($this->pass);
92          //if ( $this->valid == 1 ) { return; }          if  ( $this->valid == 1 ) { return; }
93          $cn=DbConnect();          $cn=DbConnect();
94          if ( $cn != false ) {          if ( $cn != false ) {
95            $sql="select ac_users.use_login,ac_users.use_active, ac_users.use_pass,            $sql="select ac_users.use_login,ac_users.use_active, ac_users.use_pass,
# Line 188  class cl_user { Line 190  class cl_user {
190   *   *
191   */   */
192  function SetPeriode($p_periode) {  function SetPeriode($p_periode) {
193    $sql="update user_pref set pref_periode=$p_periode where pref_user='$this->id'";    $sql="update user_local_pref set parameter_value='$p_periode' where user_id='$this->id' and parameter_type='PERIODE'";
194    $Res=ExecSql($this->db,$sql);    $Res=ExecSql($this->db,$sql);
195  }  }
196  /* function GetPeriode  /* function GetPeriode
# Line 206  function SetPeriode($p_periode) { Line 208  function SetPeriode($p_periode) {
208    
209  function GetPeriode() {  function GetPeriode() {
210    $array=$this->GetPreferences();    $array=$this->GetPreferences();
211    return $array['active_periode'];    return $array['PERIODE'];
212  }  }
213  /* function GetPreferences  /* function GetPreferences
214   * Purpose : Get the default user's preferences   * Purpose : Get the default user's preferences
# Line 223  function GetPeriode() { Line 225  function GetPeriode() {
225  function GetPreferences ()  function GetPreferences ()
226  {  {
227    // si preference n'existe pas, les créer    // si preference n'existe pas, les créer
228    $sql="select pref_periode as active_periode from user_pref where pref_user='".$this->id."'";    $sql="select parameter_type,parameter_value from user_local_pref where user_id='".$this->id."'";
229    $Res=ExecSql($this->db,$sql);    $Res=ExecSql($this->db,$sql);
230    if (pg_NumRows($Res) == 0 ) {    if (pg_NumRows($Res) == 0 ) {
231      $sql=sprintf("insert into user_pref (pref_periode,pref_user) values      // default periode
232                   ( %d , '%s')" ,      $sql=sprintf("insert into user_local_pref (pref_periode,pref_user)
233                   1, $this->id);                   select min(p_id),'%s' from parm_periode where p_closed=false"
234                     , $this->id);
235      $Res=ExecSql($this->db,$sql);      $Res=ExecSql($this->db,$sql);
236    
237      $l_array=$this->GetPreferences();      $l_array=$this->GetPreferences();
238    } else {    } else {
239      $l_array= pg_fetch_array($Res,0);      for ( $i =0;$i < pg_NumRows($Res);$i++) {
240          $row= pg_fetch_array($Res,0);
241          $type=$row['parameter_type'];
242          $l_array[$type]=$row['parameter_value'];
243        }
244    }    }
245    return $l_array;    return $l_array;
246  }  }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

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