noalyss Version-9
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 175 of file dossier.class.php.

176 {
177 try {
178 $http=new HttpInput();
179 $id=$http->request("gDossier","number");
180 if ($id > 999999 || $id < 0) throw new \Exception(_("Dossier max dépassé "));
181 } catch (\Exception $e) {
182
183 die('Dossier invalide ');
184 }
185
186 }
_("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 295 of file dossier.class.php.

296 {
297 static $cn=null;
298 if ($cn!=null)
299 return $cn;
300 $id=Dossier::id();
301 $cn=new Database($id);
302 return $cn;
303 }
$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 }

References cn.

Referenced by synchro_admin().

◆ get()

static Dossier::get ( )
static

return a string to put to gDossier into a GET

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

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

References $http.

◆ get_info()

Dossier::get_info ( )

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

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

◆ get_parameter()

Dossier::get_parameter ( $p_string)

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

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

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 from
155 ac_users as ac
156 left join
157 (select array_to_string(array_agg(dos_name),',') as ag_dossier,
158 jt.use_id as jt_use_id
159 from ac_dossier as ds
160 join jnt_use_dos as jt on (jt.dos_id=ds.dos_id)
161 group by jt.use_id) as dossier_name on (jt_use_id=ac.use_id)
162 where
163 use_login!=$1
164 $sql
165 ";
166
167 $res=$this->cn->get_array($sql, array(NOALYSS_ADMINISTRATOR));
168 return $res;
169 }
NOALYSS_ADMINISTRATOR
Definition install.php:744

References $res, $sql, cn, and NOALYSS_ADMINISTRATOR.

◆ get_version()

static Dossier::get_version ( $p_cn)
static

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

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

◆ hidden()

static Dossier::hidden ( )
static

return a string to set gDossier into a FORM

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

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

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 272 of file dossier.class.php.

273 {
274
275 $sql="select * from ac_dossier where dos_id=$1";
276
277 $res=$this->cn->exec_sql(
278 $sql, array($this->dos_id)
279 );
280
281 if (Database::num_row($res)==0)
282 return;
284 foreach ( self::$variable as $idx)
285 {
286 $this->$idx=$row[$idx];
287 }
288 }
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 211 of file dossier.class.php.

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

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

◆ save()

Dossier::save ( )

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

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

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 430 of file dossier.class.php.

430 {
431
432 self::check($p_dossier);
433 put_global([ [ "key"=>"gDossier","value"=>$p_dossier]]);
434
435 }
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 232 of file dossier.class.php.

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

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 309 of file dossier.class.php.

310 {
311// connect to target
312 $cn=new Database($p_id);
313
314 if (!$cn->exist_table("profile_menu"))
315 {
316 echo_warning("Dossier invalide");
317 return;
318 }
319// connect to repo
320 $repo=new Database();
321
322 $a_admin=$repo->get_array("select use_login from ac_users where
323 use_admin=1 and use_active=1");
324 try
325 {
326 /**
327 * synchro global
328 */
329 $cn->start();
330 for ($i=0; $i<count($a_admin); $i++)
331 {
332 Noalyss_user::grant_admin_access($a_admin[$i]['use_login'], $p_id);
333 }
334 $cn->commit();
335 }
336 catch (Exception $e)
337 {
338
339 echo_warning($e->getMessage());
340 record_log($e);
341 $cn->rollback();
342 }
343 }
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 253 of file dossier.class.php.

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

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