noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Dossier Class Reference

manage the current dossier, everywhere we need to know to which folder we are connected, because we can't use $_SESSION, we need to pass the dossier_id via a _GET or a POST variable private static $variable=array("id"=>"dos_id", "name"=>"dos_name", "desc"=>"dos_description"); More...

+ Collaboration diagram for Dossier:

Public Member Functions

 __construct ($p_id)
 
 count ()
 Count the number of folder in the repository.
 
 get_info ()
 
 get_parameter ($p_string)
 
 get_user_folder ($sql="")
 Return all the users as an array but NOALYSS_ADMINISTRATOR, that user cannot be changed by the interface for administrating user.
 
 load ()
 
 save ()
 
 set_parameter ($p_string, $p_value)
 
 update ()
 

Static Public Member Functions

static check ()
 check if gDossier is set ?? dead code ???
 
static connect ()
 
static get ()
 return a string to put to gDossier into a GET
 
static get_version ($p_cn)
 
static hidden ()
 return a string to set gDossier into a FORM
 
static id ()
 return the 'gDossier' value after a check
 
static name ($id=0)
 retrieve the name of the current dossier
 
static set_current ($p_dossier)
 Set the current dossier to $p_dossier.
 
static show_dossier ($p_type, $p_login="", $p_text="", $limit=0)
 Show the folder where user have access.
 
static synchro_admin ($p_id)
 connect to folder and give to admin.
 
static upgrade ()
 Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch until X equal DBVERSIONREPO-1 After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder.
 

Data Fields

 $cn
 Database connexion.
 
 $dos_description
 
 $dos_email
 
 $dos_id
 number of db
 
 $dos_name
 

Static Private Attributes

static $variable
 

Detailed Description

manage the current dossier, everywhere we need to know to which folder we are connected, because we can't use $_SESSION, we need to pass the dossier_id via a _GET or a POST variable private static $variable=array("id"=>"dos_id", "name"=>"dos_name", "desc"=>"dos_description");

Definition at line 39 of file dossier.class.php.

Constructor & Destructor Documentation

◆ __construct()

Dossier::__construct ( $p_id)

Definition at line 53 of file dossier.class.php.

54 {
55 $this->cn=new Database(); // Connect to the repository
56 $this->dos_id=$p_id;
57 }
$input_from cn
contains the class for connecting to Noalyss

References $p_id, and cn.

Member Function Documentation

◆ check()

static Dossier::check ( )
static

check if gDossier is set ?? dead code ???

Definition at line 174 of file dossier.class.php.

175 {
176 try {
177 $http=new HttpInput();
178 $id=$http->request("gDossier","number");
179 if ($id > 999999 || $id < 0) throw new \Exception(_("Dossier max dépassé "));
180 } catch (\Exception $e) {
181
182 die('Dossier invalide ');
183 }
184
185 }
_("actif, passif,charge,...")
manage the http input (get , post, request) and extract from an array

References $e, $http, $id, and _.

◆ connect()

static Dossier::connect ( )
static

Definition at line 294 of file dossier.class.php.

295 {
296 static $cn=null;
297 if ($cn!=null)
298 return $cn;
299 $id=Dossier::id();
300 $cn=new Database($id);
301 return $cn;
302 }
$cn
Database connexion.

References $cn, $id, and id().

+ Here is the call graph for this function:

◆ count()

Dossier::count ( )

Count the number of folder in the repository.

Returns
integer

Definition at line 129 of file dossier.class.php.

130 {
131 $nb_folder=$this->cn->get_value('select count(*) from ac_dossier');
132 return $nb_folder;
133 }
$nb_folder
Definition test.php:77

References $nb_folder, and cn.

Referenced by synchro_admin().

◆ get()

static Dossier::get ( )
static

return a string to put to gDossier into a GET

Definition at line 191 of file dossier.class.php.

192 {
193 $http=new \HttpInput();
194 return "gDossier=".$http->request("gDossier","number");
195 }

References $http.

◆ get_info()

Dossier::get_info ( )

Definition at line 242 of file dossier.class.php.

243 {
244 return var_export(self::$variable, true);
245 }

◆ get_parameter()

Dossier::get_parameter ( $p_string)

Definition at line 220 of file dossier.class.php.

221 {
222 if (array_key_exists($p_string, self::$variable))
223 {
224 $idx=self::$variable[$p_string];
225 return $this->$idx;
226 }
227 else
228 throw new Exception("Attribut inexistant $p_string");
229 }

References $idx.

◆ get_user_folder()

Dossier::get_user_folder ( $sql = "")

Return all the users as an array but NOALYSS_ADMINISTRATOR, that user cannot be changed by the interface for administrating user.

Parameters
SQL$sqlsql string to add to the query :
Note
that string MUST be the result of Database\escape_string

Definition at line 141 of file dossier.class.php.

142 {
143
144 $sql="
145 select
146 use_id,
147 use_first_name,
148 use_name,
149 use_email,
150 use_login,
151 use_active,
152 use_admin,
153 ag_dossier,
154 use_auth_method
155 from
156 ac_users as ac
157 left join
158 (select array_to_string(array_agg(dos_name),',') as ag_dossier,
159 jt.use_id as jt_use_id
160 from ac_dossier as ds
161 join jnt_use_dos as jt on (jt.dos_id=ds.dos_id)
162 group by jt.use_id) as dossier_name on (jt_use_id=ac.use_id)
163 $sql
164 ";
165
166 $res=$this->cn->get_array($sql);
167 return $res;
168 }

References $res, $sql, and cn.

◆ get_version()

static Dossier::get_version ( $p_cn)
static

Definition at line 289 of file dossier.class.php.

290 {
291 return $p_cn->get_value('select max(val) from version');
292 }

◆ hidden()

static Dossier::hidden ( )
static

return a string to set gDossier into a FORM

Definition at line 201 of file dossier.class.php.

202 {
203 $http=new \HttpInput();
204
205 return '<input type="hidden" id="gDossier" name="gDossier" value="'.$http->request("gDossier","number").'">';
206 }

References $http.

◆ id()

static Dossier::id ( )
static

return the 'gDossier' value after a check

Definition at line 61 of file dossier.class.php.

62 {
63 $http=new HttpInput();
64
65 return $http->request('gDossier','number');
66 }

References $http.

Referenced by connect().

◆ load()

Dossier::load ( )

Definition at line 271 of file dossier.class.php.

272 {
273
274 $sql="select * from ac_dossier where dos_id=$1";
275
276 $res=$this->cn->exec_sql(
277 $sql, array($this->dos_id)
278 );
279
280 if (Database::num_row($res)==0)
281 return;
283 foreach ( self::$variable as $idx)
284 {
285 $this->$idx=$row[$idx];
286 }
287 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows

References $idx, $res, $row, $sql, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ name()

static Dossier::name ( $id = 0)
static

retrieve the name of the current dossier

Definition at line 210 of file dossier.class.php.

211 {
212
213 $http=new \HttpInput();
214 $cn=new Database();
215 $id=($id==0)?$http->request("gDossier","number"):$id;
216 $name=$cn->get_value("select dos_name from ac_dossier where dos_id=$1", array($id));
217 return $name;
218 }

References $cn, $http, $id, and $name.

◆ save()

Dossier::save ( )

Definition at line 247 of file dossier.class.php.

248 {
249 $this->update();
250 }

References update().

+ Here is the call graph for this function:

◆ set_current()

static Dossier::set_current ( $p_dossier)
static

Set the current dossier to $p_dossier.

Parameters
numeric$p_dossier

Definition at line 429 of file dossier.class.php.

429 {
430
431 self::check($p_dossier);
432 put_global([ [ "key"=>"gDossier","value"=>$p_dossier]]);
433
434 }
put_global($array)
Put in superglobal (get,post,request) the value contained in the parameter field (me_parameter)

References put_global().

+ Here is the call graph for this function:

◆ set_parameter()

Dossier::set_parameter ( $p_string,
$p_value )

Definition at line 231 of file dossier.class.php.

232 {
233 if (array_key_exists($p_string, self::$variable))
234 {
235 $idx=self::$variable[$p_string];
236 $this->$idx=$p_value;
237 }
238 else
239 throw new Exception("Attribut inexistant $p_string");
240 }

References $idx.

◆ show_dossier()

static Dossier::show_dossier ( $p_type,
$p_login = "",
$p_text = "",
$limit = 0 )
static

Show the folder where user have access.

Parameters
p_typestring
  • A for all dossiers
  • R for accessible folders
  • X forbidden folders
p_loginis the user name
p_textis a part of the name where are looking for
Returns
nothing

Definition at line 79 of file dossier.class.php.

80 {
81 $cn=new Database();
82 $str_limit=($limit==0)?'':' limit '.$limit;
83 if ($p_type=="A")
84 {
85 $l_sql="select *, 'W' as priv_priv "
86 ."from ac_dossier "
87 ."where "
88 ."dos_name ilike '%'|| $2 ||'%'"
89 ."or dos_description ilike '%'|| $2 || '%' "
90 ."ORDER BY dos_name $str_limit ";
91 $a_row=$cn->get_array($l_sql, $p_text);
92 return $a_row;
93 }
94 else if ($p_type=="R")
95 {
96 $l_sql="select * from jnt_use_dos
97 natural join ac_dossier
98 natural join ac_users
99 where
100 use_login=$1
101 and ( dos_name ilike '%'|| $2 || '%' or dos_description ilike '%'|| $2|| '%' )
102
103 order by dos_name
104 $str_limit
105 ";
106
107 $a_row=$cn->get_array($l_sql, array($p_login, $p_text));
108 return $a_row;
109 }
110 else if ($p_type=='X')
111 {
112 $l_sql=" select * from ac_dossier where dos_id not in
113 (select dos_id from jnt_use_dos where use_id=$1)
114 and ( dos_name ilike '%'|| $2|| '%' or dos_description ilike '%'|| $2 || '%')
115 order by dos_name ".$str_limit;
116 $a_row=$cn->get_array($l_sql, array($p_login, $p_text));
117 return $a_row;
118 }
119 else
120 {
121 throw new Exception(_("Erreur paramètre"));
122 }
123 }

References $a_row, $cn, $limit, $p_type, and _.

◆ synchro_admin()

static Dossier::synchro_admin ( $p_id)
static

connect to folder and give to admin.

the profile Admin(builtin)

Parameters
int$p_iddossier::id()

synchro global

Definition at line 308 of file dossier.class.php.

309 {
310// connect to target
311 $cn=new Database($p_id);
312
313 if (!$cn->exist_table("profile_menu"))
314 {
315 echo_warning("Dossier invalide");
316 return;
317 }
318// connect to repo
319 $repo=new Database();
320
321 $a_admin=$repo->get_array("select use_login from ac_users where
322 use_admin=1 and use_active=1");
323 try
324 {
325 /**
326 * synchro global
327 */
328 $cn->start();
329 for ($i=0; $i<count($a_admin); $i++)
330 {
331 Noalyss_user::grant_admin_access($a_admin[$i]['use_login'], $p_id);
332 }
333 $cn->commit();
334 }
335 catch (Exception $e)
336 {
337
338 echo_warning($e->getMessage());
339 record_log($e);
340 $cn->rollback();
341 }
342 }
echo_warning($p_string)
warns
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
if(isset($_REQUEST['gDossier']) && $http->request("gDossier","number", 0) !=0) $repo

References $cn, $e, $i, $p_id, $repo, count(), echo_warning(), and record_log().

Referenced by upgrade().

+ Here is the call graph for this function:

◆ update()

Dossier::update ( )

Definition at line 252 of file dossier.class.php.

253 {
254 if (noalyss_strlentrim($this->dos_name)==0)
255 return;
256
257 if ($this->cn->get_value("select count(*) from ac_dossier "
258 ." where dos_name=$1 and dos_id<>$2", array($this->dos_name, $this->dos_id))!=0)
259 return;
260
261 $sql="update ac_dossier set dos_name=$1,dos_description=$2 ,dos_email=$3".
262 " where dos_id = $4";
263 $res=$this->cn->exec_sql(
264 $sql, array(trim($this->dos_name),
265 trim($this->dos_description),
266 $this->dos_email,
267 $this->dos_id)
268 );
269 }
noalyss_strlentrim($p_string)

References $res, $sql, cn, and noalyss_strlentrim().

Referenced by save().

+ Here is the call graph for this function:

◆ upgrade()

static Dossier::upgrade ( )
static

Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch until X equal DBVERSIONREPO-1 After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder.

Definition at line 350 of file dossier.class.php.

351 {
352 $rep=new Database();
353 /* If multi folders */
354 $Resdossier=$rep->exec_sql("select dos_id, dos_name from ac_dossier");
355 $MaxDossier=$rep->size($Resdossier);
356
357 //----------------------------------------------------------------------
358 // Upgrade the account_repository
359 //----------------------------------------------------------------------
360 echo "<h2>"._("Mise à jour de la base de données principale")."</h2>";
361 $cn=new Database();
362 if (DEBUGNOALYSS == 0)
363 ob_start();
364 $MaxVersion=DBVERSIONREPO-1;
365 for ($i=4; $i<=$MaxVersion; $i++)
366 {
367 if ($cn->get_version()<=$i)
368 {
369 $cn->execute_script(NOALYSS_INCLUDE.'/sql/patch/ac-upgrade'.$i.'.sql');
370 }
371 }
372 if (DEBUGNOALYSS == 0) ob_end_clean();
373 //----------------------------------------------------------------------
374 // Upgrade the folders
375 //----------------------------------------------------------------------
376 echo "<h2>"._("Mise à jour dossiers")."</h2>";
377
378 for ($e=0; $e<$MaxDossier; $e++)
379 {
380 $db_row=Database::fetch_array($Resdossier, $e);
381 $name=$rep->format_name($db_row['dos_id'], 'dos');
382 echo "<h3>Patching ".$db_row['dos_name'].'</h3>';
383 echo _('Base de données')." ".$name;
384
385 if ($rep->exist_database($name)>0)
386 {
387 $db=new Database($db_row['dos_id'], 'dos');
388 $db->apply_patch($db_row['dos_name']);
389 Dossier::synchro_admin($db_row['dos_id']);
390 Noalyss_user::remove_inexistant_user($db_row['dos_id']);
391 $db->clean_orphan_lob();
392 }
393 else
394 {
395 echo_warning(_("Dossier inexistant")." $name");
396 }
397 }
398
399 //----------------------------------------------------------------------
400 // Upgrade the template
401 //----------------------------------------------------------------------
402 $Resdossier=$rep->exec_sql("select mod_id, mod_name from modeledef");
403 $MaxDossier=$rep->size();
404 echo "<h2>"._("Mise à jour modèles")."</h2>";
405
406 for ($e=0; $e<$MaxDossier; $e++)
407 {
408 $db_row=Database::fetch_array($Resdossier, $e);
409 $name=$rep->format_name($db_row['mod_id'], 'mod');
410 echo "<h3>Patching ".$db_row['mod_name']."</h3>";
411 echo _('Base de données')." ".$name;
412 if ($rep->exist_database($name)>0)
413 {
414 $db=new Database($db_row['mod_id'], 'mod');
415 $db->apply_patch($db_row['mod_name']);
416 $db->clean_orphan_lob();
417 }
418 else
419 {
420 echo_warning(_("Modèle inexistant")." $name");
421 }
422 }
423 }
static synchro_admin($p_id)
connect to folder and give to admin.
const DBVERSIONREPO
Definition constant.php:37

References $cn, $e, $i, $name, $rep, _, DBVERSIONREPO, echo_warning(), DatabaseCore\fetch_array(), and synchro_admin().

+ Here is the call graph for this function:

Field Documentation

◆ $cn

Dossier::$cn

Database connexion.

Definition at line 47 of file dossier.class.php.

Referenced by connect(), name(), show_dossier(), synchro_admin(), and upgrade().

◆ $dos_description

Dossier::$dos_description

Definition at line 50 of file dossier.class.php.

◆ $dos_email

Dossier::$dos_email

Definition at line 51 of file dossier.class.php.

◆ $dos_id

Dossier::$dos_id

number of db

Definition at line 48 of file dossier.class.php.

◆ $dos_name

Dossier::$dos_name

Definition at line 49 of file dossier.class.php.

◆ $variable

Dossier::$variable
staticprivate
Initial value:
=array("id"=>"dos_id",
"name"=>"dos_name",
"desc"=>"dos_description",
"max_email"=>'dos_email')

Definition at line 42 of file dossier.class.php.


The documentation for this class was generated from the following file: