417 |
* \return int >0 si ok, <0 si erreur |
* \return int >0 si ok, <0 si erreur |
418 |
*/ |
*/ |
419 |
|
|
420 |
function fetch($socid) |
function fetch($socid, $user=0) |
421 |
{ |
{ |
422 |
global $langs; |
global $langs; |
423 |
|
|
424 |
|
/* Lecture des permissions */ |
425 |
|
if ($user <> 0) |
426 |
|
{ |
427 |
|
$sql = "SELECT p.pread, p.pwrite, p.pperms"; |
428 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe_perms as p"; |
429 |
|
$sql .= " WHERE p.fk_user = '".$user->id."'"; |
430 |
|
$sql .= " AND p.fk_soc = '".$socid."';"; |
431 |
|
|
432 |
|
$resql=$this->db->query($sql); |
433 |
|
|
434 |
|
if ($resql) |
435 |
|
{ |
436 |
|
if ($row = $this->db->fetch_row($resql)) |
437 |
|
{ |
438 |
|
$this->perm_read = $row[0]; |
439 |
|
$this->perm_write = $row[1]; |
440 |
|
$this->perm_perms = $row[2]; |
441 |
|
} |
442 |
|
} |
443 |
|
} |
444 |
|
|
445 |
$this->id = $socid; |
$this->id = $socid; |
446 |
|
|
447 |
$sql = "SELECT s.idp, s.nom, s.address,".$this->db->pdate("s.datec")." as dc, prefix_comm"; |
$sql = "SELECT s.idp, s.nom, s.address,".$this->db->pdate("s.datec")." as dc, prefix_comm"; |