mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
QUAL: Code fix using rector
This commit is contained in:
parent
6aeccf1d48
commit
da2260d3c7
|
|
@ -10,19 +10,13 @@ composer install
|
|||
```
|
||||
#### Usage
|
||||
|
||||
##### To see change before apply
|
||||
##### To make changes (Add --dry-run for test mode only)
|
||||
```shell
|
||||
./vendor/bin/rector process --dry-run
|
||||
```
|
||||
|
||||
##### To apply change
|
||||
##### To make changes on a given directory
|
||||
|
||||
```shell
|
||||
./vendor/bin/rector process
|
||||
```
|
||||
|
||||
##### Run only for a directory
|
||||
|
||||
```shell
|
||||
./vendor/bin/rector process ../../../htdocs/core/
|
||||
./vendor/bin/rector process [--dry-run] ../../../htdocs/core/
|
||||
```
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ $module = $object->module;
|
|||
$element = $object->element;
|
||||
|
||||
$usesublevelpermission = ($module != $element ? $element : '');
|
||||
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
$usesublevelpermission = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ $object = fetchObjectByElement($id, $element);
|
|||
$module = $object->module;
|
||||
$element = $object->element;
|
||||
$usesublevelpermission = ($module != $element ? $element : '');
|
||||
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
$usesublevelpermission = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ $module = $object->module;
|
|||
$element = $object->element;
|
||||
|
||||
$usesublevelpermission = ($module != $element ? $element : '');
|
||||
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
$usesublevelpermission = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ $object = fetchObjectByElement($id, $element);
|
|||
$module = $object->module;
|
||||
$element = $object->element;
|
||||
$usesublevelpermission = ($module != $element ? $element : '');
|
||||
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
$usesublevelpermission = '';
|
||||
}
|
||||
|
||||
|
|
@ -102,10 +102,10 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
|
|||
$subelement = 'facture';
|
||||
}
|
||||
|
||||
if ($user->rights->$element->lire || $user->rights->$element->read
|
||||
|| (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read))
|
||||
if ($user->hasRight($element, 'lire') || $user->hasRight($element, 'read')
|
||||
|| (isset($subelement) && ($user->hasRight($element, $subelement, 'lire') || $user->hasRight($element, $subelement, 'read')))
|
||||
|| ($element == 'payment' && $user->hasRight('facture', 'lire'))
|
||||
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire)) {
|
||||
|| ($element == 'payment_supplier' && $user->hasRight('fournisseur', 'facture', 'lire'))) {
|
||||
if ($type == 'select') {
|
||||
$methodname = 'load_cache_'.$loadmethod;
|
||||
$cachename = 'cache_'.GETPOST('loadmethod', 'alpha');
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ $object->fields[$field] = array('type' => $format, 'enabled' => 1);
|
|||
$module = $object->module;
|
||||
$element = $object->element;
|
||||
$usesublevelpermission = ($module != $element ? $element : '');
|
||||
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
$usesublevelpermission = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,42 +86,42 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
|||
$perm = 1;
|
||||
} elseif ($table_element_line == 'emailcollector_emailcollectoraction' && $user->admin) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'bom_bomline' && $user->rights->bom->write) {
|
||||
} elseif ($table_element_line == 'bom_bomline' && $user->hasRight('bom', 'write')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'mrp_production' && $user->rights->mrp->write) {
|
||||
} elseif ($table_element_line == 'mrp_production' && $user->hasRight('mrp', 'write')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'supplier_proposaldet' && $user->rights->supplier_proposal->creer) {
|
||||
} elseif ($table_element_line == 'supplier_proposaldet' && $user->hasRight('supplier_proposal', 'creer')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'commande_fournisseurdet' && $user->rights->fournisseur->commande->creer) {
|
||||
} elseif ($table_element_line == 'commande_fournisseurdet' && $user->hasRight('fournisseur', 'commande', 'creer')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'facture_fourn_det' && $user->rights->fournisseur->facture->creer) {
|
||||
} elseif ($table_element_line == 'facture_fourn_det' && $user->hasRight('fournisseur', 'facture', 'creer')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'facture_fourn_det_rec' && $user->rights->fournisseur->facture->creer) {
|
||||
} elseif ($table_element_line == 'facture_fourn_det_rec' && $user->hasRight('fournisseur', 'facture', 'creer')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'product_attribute_value' && $fk_element == 'fk_product_attribute' && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'ecm_files') { // Used when of page "documents.php"
|
||||
if (!empty($user->rights->ecm->creer)) {
|
||||
if ($user->hasRight('ecm', 'creer')) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_product' && ($user->hasRight('produit', 'creer') || !empty($user->rights->service->creer))) {
|
||||
} elseif ($fk_element == 'fk_product' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) {
|
||||
} elseif ($fk_element == 'fk_ticket' && $user->hasRight('ticket', 'write')) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_holiday' && !empty($user->rights->holiday->write)) {
|
||||
} elseif ($fk_element == 'fk_holiday' && $user->hasRight('holiday', 'write')) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_soc' && !empty($user->rights->societe->creer)) {
|
||||
} elseif ($fk_element == 'fk_soc' && $user->hasRight('societe', 'creer')) {
|
||||
$perm = 1;
|
||||
}
|
||||
} elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && ($user->hasRight('produit', 'creer') || !empty($user->rights->service->creer))) {
|
||||
} elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) {
|
||||
} elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->hasRight('projet', 'creer')) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'contratdet' && $fk_element == 'fk_contrat' && $user->hasRight('contrat', 'creer')) {
|
||||
$perm = 1;
|
||||
} else {
|
||||
$tmparray = explode('_', $table_element_line);
|
||||
$tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]);
|
||||
if (!empty($tmpmodule) && !empty($tmpobject) && !empty($conf->$tmpmodule->enabled) && !empty($user->rights->$tmpobject->write)) {
|
||||
if (!empty($tmpmodule) && !empty($tmpobject) && !empty($conf->$tmpmodule->enabled) && $user->hasRight($tmpobject, 'write')) {
|
||||
$perm = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ $object = fetchObjectByElement($id, $element);
|
|||
$module = $object->module;
|
||||
$element = $object->element;
|
||||
$usesublevelpermission = ($module != $element ? $element : '');
|
||||
if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
|
||||
$usesublevelpermission = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ if (empty($reshook)) {
|
|||
|
||||
// This pushes a search entry to the top
|
||||
if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) {
|
||||
$key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE;
|
||||
$key = 'searchinto' . getDolGlobalString('DEFAULT_SEARCH_INTO_MODULE');
|
||||
if (array_key_exists($key, $arrayresult)) {
|
||||
$arrayresult[$key]['position'] = -1000;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,14 +92,14 @@ class box_actions extends ModeleBoxes
|
|||
$sql .= ", s.code_client, s.code_compta, s.client";
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||
$sql .= " WHERE a.fk_action = ta.id";
|
||||
$sql .= " AND a.entity IN (".getEntity('actioncomm').")";
|
||||
$sql .= " AND a.percent >= 0 AND a.percent < 100";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -94,14 +94,14 @@ class box_actions_future extends ModeleBoxes
|
|||
$sql .= ", s.code_client, s.code_compta, s.client";
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||
$sql .= " WHERE a.fk_action = ta.id";
|
||||
$sql .= " AND a.entity IN (".getEntity('actioncomm').")";
|
||||
//$sql .= " AND a.percent >= 0 AND a.percent < 100";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")";
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -113,13 +113,13 @@ class box_activity extends ModeleBoxes
|
|||
|
||||
$sql = "SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb";
|
||||
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= ")";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('propal').")";
|
||||
$sql .= " AND p.fk_soc = s.rowid";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
@ -202,13 +202,13 @@ class box_activity extends ModeleBoxes
|
|||
|
||||
$sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
|
||||
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= ")";
|
||||
$sql .= " WHERE c.entity IN (".getEntity('commande').")";
|
||||
$sql .= " AND c.fk_soc = s.rowid";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
@ -287,12 +287,12 @@ class box_activity extends ModeleBoxes
|
|||
$data = array();
|
||||
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
|
||||
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= ")";
|
||||
$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class box_boms extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max));
|
||||
|
||||
if ($user->rights->bom->read) {
|
||||
if ($user->hasRight('bom', 'read')) {
|
||||
$sql = "SELECT p.ref as product_ref";
|
||||
$sql .= ", p.rowid as productid";
|
||||
$sql .= ", p.tosell";
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class box_bookmarks extends ModeleBoxes
|
|||
$this->info_box_head['subtext'] = $langs->trans("ListOfBookmark");
|
||||
}
|
||||
|
||||
if ($user->rights->bookmark->lire) {
|
||||
if ($user->hasRight('bookmark', 'lire')) {
|
||||
$sql = "SELECT b.title, b.url, b.target, b.favicon";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b";
|
||||
$sql .= " WHERE fk_user = ".((int) $user->id);
|
||||
|
|
|
|||
|
|
@ -92,12 +92,12 @@ class box_clients extends ModeleBoxes
|
|||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= ", s.datec, s.tms, s.status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE s.client IN (1, 3)";
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
// Add where from hooks
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class box_commandes extends ModeleBoxes
|
|||
$sql .= ", c.total_tva";
|
||||
$sql .= ", c.total_ttc";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE c.fk_soc = s.rowid";
|
||||
|
|
@ -108,7 +108,7 @@ class box_commandes extends ModeleBoxes
|
|||
if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) {
|
||||
$sql .= " AND c.fk_statut = 1";
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class box_comptes extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts"));
|
||||
|
||||
if ($user->rights->banque->lire) {
|
||||
if ($user->hasRight('banque', 'lire')) {
|
||||
$sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url";
|
||||
$sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban";
|
||||
$sql .= ", b.domiciliation, b.proprio, b.owner_address";
|
||||
|
|
|
|||
|
|
@ -107,11 +107,11 @@ class box_contacts extends ModeleBoxes
|
|||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('contact').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
// Add where from hooks
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class box_contracts extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max));
|
||||
|
||||
if ($user->rights->contrat->lire) {
|
||||
if ($user->hasRight('contrat', 'lire')) {
|
||||
$contractstatic = new Contrat($this->db);
|
||||
$thirdpartytmp = new Societe($this->db);
|
||||
|
||||
|
|
@ -86,12 +86,12 @@ class box_contracts extends ModeleBoxes
|
|||
$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,";
|
||||
$sql .= " c.ref_customer, c.ref_supplier";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE c.fk_soc = s.rowid";
|
||||
$sql .= " AND c.entity = ".$conf->entity;
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -93,12 +93,12 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
|
|||
$sql .= ", s.outstanding_limit";
|
||||
$sql .= ", s.datec, s.tms, s.status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE s.client IN (1, 3)";
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@ class box_factures extends ModeleBoxes
|
|||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE f.fk_soc = s.rowid";
|
||||
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -100,12 +100,12 @@ class box_factures_fourn extends ModeleBoxes
|
|||
$sql .= ', f.date_lim_reglement as datelimite, f.tms, f.type';
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE f.fk_soc = s.rowid";
|
||||
$sql .= " AND f.entity = ".$conf->entity;
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -99,14 +99,14 @@ class box_factures_fourn_imp extends ModeleBoxes
|
|||
$sql2 = " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql2 .= ",".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql2 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql2 .= " WHERE f.fk_soc = s.rowid";
|
||||
$sql2 .= " AND f.entity IN (".getEntity('supplier_invoice').")";
|
||||
$sql2 .= " AND f.paye = 0";
|
||||
$sql2 .= " AND fk_statut = 1";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql2 .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class box_factures_imp extends ModeleBoxes
|
|||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql2 .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql2 .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
|
|
@ -118,7 +118,7 @@ class box_factures_imp extends ModeleBoxes
|
|||
$sql2 .= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql2 .= " AND f.paye = 0";
|
||||
$sql2 .= " AND fk_statut = 1";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql2 .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class box_ficheinter extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max));
|
||||
|
||||
if (!empty($user->rights->ficheinter->lire)) {
|
||||
if ($user->hasRight('ficheinter', 'lire')) {
|
||||
$sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
|
||||
$sql .= ", f.datec";
|
||||
$sql .= ", f.date_valid as datev";
|
||||
|
|
@ -89,13 +89,13 @@ class box_ficheinter extends ModeleBoxes
|
|||
$sql .= ", s.code_client, s.code_compta, s.client";
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir)) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir')) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
|
||||
$sql .= " WHERE f.fk_soc = s.rowid ";
|
||||
$sql .= " AND f.entity = ".$conf->entity;
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ class box_fournisseurs extends ModeleBoxes
|
|||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= ", s.datec, s.tms, s.status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE s.fournisseur = 1";
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
// Add where from hooks
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) || $socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
|
||||
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class box_graph_invoices_peryear extends ModeleBoxes
|
|||
$prefix = '';
|
||||
$socid = 0;
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if (empty($user->rights->societe->client->voir) || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
if (!$user->hasRight('societe', 'client', 'voir') || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
|
||||
if ($user->hasRight('facture', 'lire')) {
|
||||
$mesg = '';
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
|
|||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) || $socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
|
||||
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes
|
|||
$minimumdatec = dol_time_plus_duree($today, -1 * ($days - 1), 'd');
|
||||
$minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc');
|
||||
|
||||
if ($user->rights->ticket->read) {
|
||||
if ($user->hasRight('ticket', 'read')) {
|
||||
$sql = "SELECT CAST(t.datec AS DATE) as datec, COUNT(t.datec) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
|
||||
$sql .= " WHERE CAST(t.datec AS DATE) > '".$this->db->idate($minimumdatec)."'";
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes
|
|||
$listofopplabel = array();
|
||||
$listofoppcode = array();
|
||||
$colorseriesstat = array();
|
||||
if ($user->rights->ticket->read) {
|
||||
if ($user->hasRight('ticket', 'read')) {
|
||||
$sql = "SELECT ctt.rowid, ctt.label, ctt.code";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_ticket_type as ctt";
|
||||
$sql .= " WHERE ctt.active = 1";
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class box_graph_orders_permonth extends ModeleBoxes
|
|||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) || $socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
|
||||
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,11 +98,11 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
|
|||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) || $socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
|
||||
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
}
|
||||
|
||||
if ($user->rights->fournisseur->commande->lire) {
|
||||
if ($user->hasRight('fournisseur', 'commande', 'lire')) {
|
||||
$langs->load("orders");
|
||||
|
||||
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
|
||||
|
|
|
|||
|
|
@ -110,10 +110,10 @@ class box_graph_product_distribution extends ModeleBoxes
|
|||
if (!isModEnabled('facture') || !$user->hasRight('facture', 'lire')) {
|
||||
$showinvoicenb = 0;
|
||||
}
|
||||
if (isModEnabled('propal') || empty($user->rights->propal->lire)) {
|
||||
if (isModEnabled('propal') || !$user->hasRight('propal', 'lire')) {
|
||||
$showpropalnb = 0;
|
||||
}
|
||||
if (!isModEnabled('commande') || empty($user->rights->commande->lire)) {
|
||||
if (!isModEnabled('commande') || !$user->hasRight('commande', 'lire')) {
|
||||
$showordernb = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class box_graph_propales_permonth extends ModeleBoxes
|
|||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) || $socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
|
||||
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class box_mos extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max));
|
||||
|
||||
if ($user->rights->mrp->read) {
|
||||
if ($user->hasRight('mrp', 'read')) {
|
||||
$sql = "SELECT p.ref as product_ref";
|
||||
$sql .= ", p.rowid as productid";
|
||||
$sql .= ", p.tosell";
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class box_produits_alerte_stock extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max));
|
||||
|
||||
if (($user->rights->produit->lire || $user->hasRight('service', 'lire')) && $user->rights->stock->lire) {
|
||||
if (($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire')) && $user->hasRight('stock', 'lire')) {
|
||||
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,";
|
||||
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
|
||||
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
|
||||
|
|
@ -95,10 +95,10 @@ class box_produits_alerte_stock extends ModeleBoxes
|
|||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
|
||||
$sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
|
||||
$sql .= " AND p.seuil_stock_alerte > 0";
|
||||
if (empty($user->rights->produit->lire)) {
|
||||
if (!$user->hasRight('produit', 'lire')) {
|
||||
$sql .= ' AND p.fk_product_type <> 0';
|
||||
}
|
||||
if (empty($user->rights->service->lire)) {
|
||||
if (!$user->hasRight('service', 'lire')) {
|
||||
$sql .= ' AND p.fk_product_type <> 1';
|
||||
}
|
||||
// Add where from hooks
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class box_project extends ModeleBoxes
|
|||
|
||||
$i = 0;
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire) {
|
||||
if ($user->hasRight('projet', 'lire')) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
$projectstatic = new Project($this->db);
|
||||
|
|
@ -97,7 +97,7 @@ class box_project extends ModeleBoxes
|
|||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId = '';
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ class box_project extends ModeleBoxes
|
|||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok
|
||||
$sql .= " AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED); // Only open projects
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class box_project_opportunities extends ModeleBoxes
|
|||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId = '';
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ class box_project_opportunities extends ModeleBoxes
|
|||
$sql .= " AND p.fk_opp_status > 0";
|
||||
$sql .= " AND p.fk_statut IN (".$this->db->sanitize($projectstatic::STATUS_DRAFT.",".$projectstatic::STATUS_VALIDATED).")"; // draft and open projects
|
||||
//$sql .= " AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED); // Only open projects
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,12 +89,12 @@ class box_propales extends ModeleBoxes
|
|||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= ", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE p.fk_soc = s.rowid";
|
||||
$sql .= " AND p.entity IN (".getEntity('propal').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -93,12 +93,12 @@ class box_prospect extends ModeleBoxes
|
|||
$sql .= ", s.fk_stcomm";
|
||||
$sql .= ", s.datec, s.tms, s.status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE s.client IN (2, 3)";
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
// Add where from hooks
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class box_services_contracts extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract", $max));
|
||||
|
||||
if ($user->rights->service->lire && $user->hasRight('contrat', 'lire')) {
|
||||
if ($user->hasRight('service', 'lire') && $user->hasRight('contrat', 'lire')) {
|
||||
$contractstatic = new Contrat($this->db);
|
||||
$contractlinestatic = new ContratLigne($this->db);
|
||||
$thirdpartytmp = new Societe($this->db);
|
||||
|
|
@ -95,7 +95,7 @@ class box_services_contracts extends ModeleBoxes
|
|||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
$sql .= ")";
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ class box_services_expired extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max));
|
||||
|
||||
if ($user->rights->contrat->lire) {
|
||||
if ($user->hasRight('contrat', 'lire')) {
|
||||
// Select contracts with at least one expired service
|
||||
$sql = "SELECT ";
|
||||
$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,";
|
||||
$sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'";
|
||||
|
|
@ -95,7 +95,7 @@ class box_services_expired extends ModeleBoxes
|
|||
if ($user->socid) {
|
||||
$sql .= ' AND c.fk_soc = '.((int) $user->socid);
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
$sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid";
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class box_shipments extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max));
|
||||
|
||||
if ($user->rights->expedition->lire) {
|
||||
if ($user->hasRight('expedition', 'lire')) {
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
|
||||
$sql .= ", s.code_client, s.code_compta, s.client";
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
|
|
@ -101,7 +101,7 @@ class box_shipments extends ModeleBoxes
|
|||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||
}
|
||||
$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
|
||||
|
|
@ -111,7 +111,7 @@ class box_shipments extends ModeleBoxes
|
|||
if ($user->socid > 0) {
|
||||
$sql.= " AND s.rowid = ".((int) $user->socid);
|
||||
}
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND sc.fk_user = ".((int) $user->id);
|
||||
} else {
|
||||
$sql .= " ORDER BY e.date_delivery, e.ref DESC ";
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class box_supplier_orders extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."SupplierOrders", $max));
|
||||
|
||||
if ($user->rights->fournisseur->commande->lire) {
|
||||
if ($user->hasRight('fournisseur', 'commande', 'lire')) {
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
|
||||
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
|
|
@ -92,12 +92,12 @@ class box_supplier_orders extends ModeleBoxes
|
|||
$sql .= ", c.fk_statut as status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE c.fk_soc = s.rowid";
|
||||
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
|
|||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max));
|
||||
|
||||
if ($user->rights->fournisseur->commande->lire) {
|
||||
if ($user->hasRight('fournisseur', 'commande', 'lire')) {
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
|
||||
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
|
|
@ -92,14 +92,14 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
|
|||
$sql .= ", c.fk_statut as status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql .= " WHERE c.fk_soc = s.rowid";
|
||||
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
|
||||
$sql .= " AND c.date_livraison IS NOT NULL";
|
||||
$sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")";
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class box_task extends ModeleBoxes
|
|||
);
|
||||
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire) {
|
||||
if ($user->hasRight('projet', 'lire')) {
|
||||
$boxcontent .= '<div id="ancor-idfilter'.$this->boxcode.'" style="display: block; position: absolute; margin-top: -100px"></div>'."\n";
|
||||
$boxcontent .= '<div id="idfilter'.$this->boxcode.'" class="center" >'."\n";
|
||||
$boxcontent .= '<form class="flat " method="POST" action="'.$_SERVER["PHP_SELF"].'#ancor-idfilter'.$this->boxcode.'">'."\n";
|
||||
|
|
@ -145,7 +145,7 @@ class box_task extends ModeleBoxes
|
|||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId = '';
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ class box_task extends ModeleBoxes
|
|||
$sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
|
||||
$sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
|
||||
$sql .= " AND p.usage_task = 1 ";
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class box_validated_projects extends ModeleBoxes
|
|||
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
|
||||
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire) {
|
||||
if ($user->hasRight('projet', 'lire')) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projectstatic = new Project($this->db);
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ class box_validated_projects extends ModeleBoxes
|
|||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId = '';
|
||||
if (empty($user->rights->projet->all->lire)) {
|
||||
if (!$user->hasRight('projet', 'all', 'lire')) {
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ print "login=".$conf->db->user."\n";
|
|||
print "database=".$conf->db->name."\n";
|
||||
print "\n";
|
||||
print "----- To LDAP database:\n";
|
||||
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";
|
||||
print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n";
|
||||
print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n";
|
||||
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
|
||||
print "DN target=".$conf->global->LDAP_CONTACT_DN."\n";
|
||||
print "DN target=" . getDolGlobalString('LDAP_CONTACT_DN')."\n";
|
||||
print "\n";
|
||||
|
||||
if (!$confirmed) {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ if ($resql) {
|
|||
$sql2 .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql2 .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".((int) $id);
|
||||
if ($conf->global->MAILING_LIMIT_SENDBYCLI > 0 && empty($max)) {
|
||||
$sql2 .= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
|
||||
$sql2 .= " LIMIT " . getDolGlobalString('MAILING_LIMIT_SENDBYCLI');
|
||||
} elseif ($conf->global->MAILING_LIMIT_SENDBYCLI > 0 && $max > 0) {
|
||||
$sql2 .= " LIMIT ".min($conf->global->MAILING_LIMIT_SENDBYCLI, $max);
|
||||
} elseif ($max > 0) {
|
||||
|
|
@ -229,9 +229,9 @@ if ($resql) {
|
|||
$substitutionarray['__OTHER5__'] = $other5;
|
||||
$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
|
||||
$substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility
|
||||
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.urlencode($obj->tag).'&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
|
||||
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
|
||||
$substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY."-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid);
|
||||
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.urlencode($obj->tag).'&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY') . "-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
|
||||
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY') . "-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
|
||||
$substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY') . "-".$obj->tag."-".$obj->email."-".$obj->rowid, "md5").'&email='.urlencode($obj->email).'&mtid='.((int) $obj->rowid);
|
||||
|
||||
$onlinepaymentenabled = 0;
|
||||
if (isModEnabled('paypal')) {
|
||||
|
|
@ -251,10 +251,10 @@ if ($resql) {
|
|||
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
|
||||
} else {
|
||||
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'order'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'invoice'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYMENT_SECURITY_TOKEN') . 'contractline'.$obj->source_id, 2);
|
||||
}
|
||||
}
|
||||
/* For backward compatibility */
|
||||
|
|
@ -264,25 +264,25 @@ if ($resql) {
|
|||
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
|
||||
} else {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'membersubscription'.$obj->source_id, 2);
|
||||
}
|
||||
|
||||
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
|
||||
} else {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'order'.$obj->source_id, 2);
|
||||
}
|
||||
|
||||
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
|
||||
} else {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'invoice'.$obj->source_id, 2);
|
||||
}
|
||||
|
||||
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
|
||||
} else {
|
||||
$substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
|
||||
$substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash(getDolGlobalString('PAYPAL_SECURITY_TOKEN') . 'contractline'.$obj->source_id, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ print "login=".$conf->db->user."\n";
|
|||
print "database=".$conf->db->name."\n";
|
||||
print "\n";
|
||||
print "----- To LDAP database:\n";
|
||||
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";
|
||||
print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n";
|
||||
print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n";
|
||||
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
|
||||
print "DN target=".$conf->global->LDAP_MEMBER_DN."\n";
|
||||
print "DN target=" . getDolGlobalString('LDAP_MEMBER_DN')."\n";
|
||||
print "\n";
|
||||
|
||||
if (!$confirmed) {
|
||||
|
|
|
|||
|
|
@ -115,15 +115,15 @@ print "Mails sending disabled (useless in batch mode)\n";
|
|||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||
print "\n";
|
||||
print "----- Synchronize all records from LDAP database:\n";
|
||||
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";
|
||||
print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n";
|
||||
print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n";
|
||||
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
|
||||
print "DN to extract=".$conf->global->LDAP_MEMBER_DN."\n";
|
||||
print "DN to extract=" . getDolGlobalString('LDAP_MEMBER_DN')."\n";
|
||||
if (!empty($conf->global->LDAP_MEMBER_FILTER)) {
|
||||
print 'Filter=('.$conf->global->LDAP_MEMBER_FILTER.')'."\n"; // Note: filter is defined into function getRecords
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_MEMBER_FILTER').')'."\n"; // Note: filter is defined into function getRecords
|
||||
} else {
|
||||
print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_KEY_MEMBERS').'=*)'."\n";
|
||||
}
|
||||
print "----- To Dolibarr database:\n";
|
||||
print "type=".$conf->db->type."\n";
|
||||
|
|
@ -201,35 +201,35 @@ if ($result >= 0) {
|
|||
$member = new Adherent($db);
|
||||
|
||||
// Propriete membre
|
||||
$member->firstname = $ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME];
|
||||
$member->lastname = $ldapuser[$conf->global->LDAP_FIELD_NAME];
|
||||
$member->login = $ldapuser[$conf->global->LDAP_FIELD_LOGIN];
|
||||
$member->pass = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD];
|
||||
$member->firstname = $ldapuser[getDolGlobalString('LDAP_FIELD_FIRSTNAME')];
|
||||
$member->lastname = $ldapuser[getDolGlobalString('LDAP_FIELD_NAME')];
|
||||
$member->login = $ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')];
|
||||
$member->pass = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD')];
|
||||
|
||||
// $member->societe;
|
||||
$member->address = $ldapuser[$conf->global->LDAP_FIELD_ADDRESS];
|
||||
$member->zip = $ldapuser[$conf->global->LDAP_FIELD_ZIP];
|
||||
$member->town = $ldapuser[$conf->global->LDAP_FIELD_TOWN];
|
||||
$member->country = $ldapuser[$conf->global->LDAP_FIELD_COUNTRY];
|
||||
$member->address = $ldapuser[getDolGlobalString('LDAP_FIELD_ADDRESS')];
|
||||
$member->zip = $ldapuser[getDolGlobalString('LDAP_FIELD_ZIP')];
|
||||
$member->town = $ldapuser[getDolGlobalString('LDAP_FIELD_TOWN')];
|
||||
$member->country = $ldapuser[getDolGlobalString('LDAP_FIELD_COUNTRY')];
|
||||
$member->country_id = $countries[$hashlib2rowid[strtolower($member->country)]]['rowid'];
|
||||
$member->country_code = $countries[$hashlib2rowid[strtolower($member->country)]]['code'];
|
||||
|
||||
$member->phone = $ldapuser[$conf->global->LDAP_FIELD_PHONE];
|
||||
$member->phone_perso = $ldapuser[$conf->global->LDAP_FIELD_PHONE_PERSO];
|
||||
$member->phone_mobile = $ldapuser[$conf->global->LDAP_FIELD_MOBILE];
|
||||
$member->email = $ldapuser[$conf->global->LDAP_FIELD_MAIL];
|
||||
$member->phone = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE')];
|
||||
$member->phone_perso = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE_PERSO')];
|
||||
$member->phone_mobile = $ldapuser[getDolGlobalString('LDAP_FIELD_MOBILE')];
|
||||
$member->email = $ldapuser[getDolGlobalString('LDAP_FIELD_MAIL')];
|
||||
|
||||
$member->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION];
|
||||
$member->note = $ldapuser[getDolGlobalString('LDAP_FIELD_DESCRIPTION')];
|
||||
$member->morphy = 'phy';
|
||||
$member->photo = '';
|
||||
$member->public = 1;
|
||||
$member->birth = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_BIRTHDATE]);
|
||||
$member->birth = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_BIRTHDATE')]);
|
||||
|
||||
$member->statut = - 1;
|
||||
if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS])) {
|
||||
$member->datec = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
|
||||
$member->datevalid = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
|
||||
$member->statut = $ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS];
|
||||
if (isset($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')])) {
|
||||
$member->datec = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')]);
|
||||
$member->datevalid = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')]);
|
||||
$member->statut = $ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')];
|
||||
}
|
||||
// if ($member->statut > 1) $member->statut=1;
|
||||
|
||||
|
|
@ -254,17 +254,17 @@ if ($result >= 0) {
|
|||
|
||||
$datefirst = '';
|
||||
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE) {
|
||||
$datefirst = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
|
||||
$pricefirst = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT]);
|
||||
$datefirst = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')]);
|
||||
$pricefirst = price2num($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')]);
|
||||
}
|
||||
|
||||
$datelast = '';
|
||||
if ($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE) {
|
||||
$datelast = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE]);
|
||||
$pricelast = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT]);
|
||||
$datelast = dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')]);
|
||||
$pricelast = price2num($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')]);
|
||||
} elseif ($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) {
|
||||
$datelast = dol_time_plus_duree(dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION]), - 1, 'y') + 60 * 60 * 24;
|
||||
$pricelast = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT]);
|
||||
$datelast = dol_time_plus_duree(dol_stringtotime($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')]), - 1, 'y') + 60 * 60 * 24;
|
||||
$pricelast = price2num($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')]);
|
||||
|
||||
// Cas special ou date derniere <= date premiere
|
||||
if ($datefirst && $datelast && $datelast <= $datefirst) {
|
||||
|
|
|
|||
|
|
@ -97,12 +97,12 @@ print "Mails sending disabled (useless in batch mode)\n";
|
|||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||
print "\n";
|
||||
print "----- Synchronize all records from LDAP database:\n";
|
||||
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";
|
||||
print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n";
|
||||
print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n";
|
||||
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
|
||||
print "DN to extract=".$conf->global->LDAP_MEMBER_TYPE_DN."\n";
|
||||
print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS_TYPES.'=*)'."\n";
|
||||
print "DN to extract=" . getDolGlobalString('LDAP_MEMBER_TYPE_DN')."\n";
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_KEY_MEMBERS_TYPES').'=*)'."\n";
|
||||
print "----- To Dolibarr database:\n";
|
||||
print "type=".$conf->db->type."\n";
|
||||
print "host=".$conf->db->host."\n";
|
||||
|
|
@ -139,9 +139,9 @@ if ($result >= 0) {
|
|||
// Warning $ldapuser has a key in lowercase
|
||||
foreach ($ldaprecords as $key => $ldapgroup) {
|
||||
$membertype = new AdherentType($db);
|
||||
$membertype->fetch($ldapgroup[$conf->global->LDAP_KEY_MEMBERS_TYPES]);
|
||||
$membertype->label = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME];
|
||||
$membertype->description = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION];
|
||||
$membertype->fetch($ldapgroup[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]);
|
||||
$membertype->label = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME')];
|
||||
$membertype->description = $ldapgroup[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION')];
|
||||
$membertype->entity = $conf->entity;
|
||||
|
||||
// print_r($ldapgroup);
|
||||
|
|
|
|||
|
|
@ -92,15 +92,15 @@ print "Mails sending disabled (useless in batch mode)\n";
|
|||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||
print "\n";
|
||||
print "----- Synchronize all records from LDAP database:\n";
|
||||
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";
|
||||
print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n";
|
||||
print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n";
|
||||
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
|
||||
print "DN to extract=".$conf->global->LDAP_GROUP_DN."\n";
|
||||
print "DN to extract=" . getDolGlobalString('LDAP_GROUP_DN')."\n";
|
||||
if (!empty($conf->global->LDAP_GROUP_FILTER)) {
|
||||
print 'Filter=('.$conf->global->LDAP_GROUP_FILTER.')'."\n"; // Note: filter is defined into function getRecords
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_GROUP_FILTER').')'."\n"; // Note: filter is defined into function getRecords
|
||||
} else {
|
||||
print 'Filter=('.$conf->global->LDAP_KEY_GROUPS.'=*)'."\n";
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_KEY_GROUPS').'=*)'."\n";
|
||||
}
|
||||
print "----- To Dolibarr database:\n";
|
||||
print "type=".$conf->db->type."\n";
|
||||
|
|
@ -138,10 +138,10 @@ if ($result >= 0) {
|
|||
// Warning $ldapuser has a key in lowercase
|
||||
foreach ($ldaprecords as $key => $ldapgroup) {
|
||||
$group = new UserGroup($db);
|
||||
$group->fetch('', $ldapgroup[$conf->global->LDAP_KEY_GROUPS]);
|
||||
$group->name = $ldapgroup[$conf->global->LDAP_GROUP_FIELD_FULLNAME];
|
||||
$group->fetch('', $ldapgroup[getDolGlobalString('LDAP_KEY_GROUPS')]);
|
||||
$group->name = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_FULLNAME')];
|
||||
$group->nom = $group->name; // For backward compatibility
|
||||
$group->note = $ldapgroup[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION];
|
||||
$group->note = $ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_DESCRIPTION')];
|
||||
$group->entity = $conf->entity;
|
||||
|
||||
// print_r($ldapgroup);
|
||||
|
|
|
|||
|
|
@ -110,15 +110,15 @@ print "Mails sending disabled (useless in batch mode)\n";
|
|||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||
print "\n";
|
||||
print "----- Synchronize all records from LDAP database:\n";
|
||||
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";
|
||||
print "port=" . getDolGlobalString('LDAP_SERVER_PORT')."\n";
|
||||
print "login=" . getDolGlobalString('LDAP_ADMIN_DN')."\n";
|
||||
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
|
||||
print "DN to extract=".$conf->global->LDAP_USER_DN."\n";
|
||||
print "DN to extract=" . getDolGlobalString('LDAP_USER_DN')."\n";
|
||||
if (!empty($conf->global->LDAP_FILTER_CONNECTION)) {
|
||||
print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_FILTER_CONNECTION').')'."\n"; // Note: filter is defined into function getRecords
|
||||
} else {
|
||||
print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n";
|
||||
print 'Filter=(' . getDolGlobalString('LDAP_KEY_USERS').'=*)'."\n";
|
||||
}
|
||||
print "----- To Dolibarr database:\n";
|
||||
print "type=".$conf->db->type."\n";
|
||||
|
|
@ -184,25 +184,25 @@ if ($result >= 0) {
|
|||
// Warning $ldapuser has a key in lowercase
|
||||
foreach ($ldaprecords as $key => $ldapuser) {
|
||||
// If login into exclude list, we discard record
|
||||
if (in_array($ldapuser[$conf->global->LDAP_FIELD_LOGIN], $excludeuser)) {
|
||||
print $langs->transnoentities("UserDiscarded").' # '.$key.': login='.$ldapuser[$conf->global->LDAP_FIELD_LOGIN].' --> Discarded'."\n";
|
||||
if (in_array($ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')], $excludeuser)) {
|
||||
print $langs->transnoentities("UserDiscarded").' # '.$key.': login='.$ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')].' --> Discarded'."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$fuser = new User($db);
|
||||
|
||||
if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) {
|
||||
$fuser->fetch('', '', $ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le SID
|
||||
$fuser->fetch('', '', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le SID
|
||||
} elseif ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) {
|
||||
$fuser->fetch('', $ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le login
|
||||
$fuser->fetch('', $ldapuser[getDolGlobalString('LDAP_KEY_USERS')]); // Chargement du user concerné par le login
|
||||
}
|
||||
|
||||
// Propriete membre
|
||||
$fuser->firstname = $ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME];
|
||||
$fuser->lastname = $ldapuser[$conf->global->LDAP_FIELD_NAME];
|
||||
$fuser->login = $ldapuser[$conf->global->LDAP_FIELD_LOGIN];
|
||||
$fuser->pass = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD];
|
||||
$fuser->pass_indatabase_crypted = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED];
|
||||
$fuser->firstname = $ldapuser[getDolGlobalString('LDAP_FIELD_FIRSTNAME')];
|
||||
$fuser->lastname = $ldapuser[getDolGlobalString('LDAP_FIELD_NAME')];
|
||||
$fuser->login = $ldapuser[getDolGlobalString('LDAP_FIELD_LOGIN')];
|
||||
$fuser->pass = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD')];
|
||||
$fuser->pass_indatabase_crypted = $ldapuser[getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED')];
|
||||
|
||||
// $user->societe;
|
||||
/*
|
||||
|
|
@ -214,14 +214,14 @@ if ($result >= 0) {
|
|||
* $fuser->country_code=$countries[$hashlib2rowid[strtolower($fuser->country)]]['code'];
|
||||
*/
|
||||
|
||||
$fuser->office_phone = $ldapuser[$conf->global->LDAP_FIELD_PHONE];
|
||||
$fuser->user_mobile = $ldapuser[$conf->global->LDAP_FIELD_MOBILE];
|
||||
$fuser->office_fax = $ldapuser[$conf->global->LDAP_FIELD_FAX];
|
||||
$fuser->email = $ldapuser[$conf->global->LDAP_FIELD_MAIL];
|
||||
$fuser->ldap_sid = $ldapuser[$conf->global->LDAP_FIELD_SID];
|
||||
$fuser->office_phone = $ldapuser[getDolGlobalString('LDAP_FIELD_PHONE')];
|
||||
$fuser->user_mobile = $ldapuser[getDolGlobalString('LDAP_FIELD_MOBILE')];
|
||||
$fuser->office_fax = $ldapuser[getDolGlobalString('LDAP_FIELD_FAX')];
|
||||
$fuser->email = $ldapuser[getDolGlobalString('LDAP_FIELD_MAIL')];
|
||||
$fuser->ldap_sid = $ldapuser[getDolGlobalString('LDAP_FIELD_SID')];
|
||||
|
||||
$fuser->job = $ldapuser[$conf->global->LDAP_FIELD_TITLE];
|
||||
$fuser->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION];
|
||||
$fuser->job = $ldapuser[getDolGlobalString('LDAP_FIELD_TITLE')];
|
||||
$fuser->note = $ldapuser[getDolGlobalString('LDAP_FIELD_DESCRIPTION')];
|
||||
$fuser->admin = 0;
|
||||
$fuser->socid = 0;
|
||||
$fuser->contact_id = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user