$i++; print '<th class="essential">'; print $langs->trans("Default"); print '</th>'; $obj->aoColumns[$i]->mDataProp = "Status"; $obj->aoColumns[$i]->sDefaultContent = "false"; $obj->aoColumns[$i]->sClass = "center"; print '</tr>'; print '</thead>'; $obj->fnDrawCallback = "function(oSettings){\n if ( oSettings.aiDisplay.length == 0 )\n {\n return;\n }\n var nTrs = jQuery('#default_right tbody tr');\n var iColspan = nTrs[0].getElementsByTagName('td').length;\n var sLastGroup = '';\n for ( var i=0 ; i<nTrs.length ; i++ )\n {\n var iDisplayIndex = oSettings._iDisplayStart + i;\n var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData['name'];\n if (sGroup!=null && sGroup!='' && sGroup != sLastGroup)\n {\n var nGroup = document.createElement('tr');\n var nCell = document.createElement('td');\n nCell.colSpan = iColspan;\n nCell.className = 'group';\n nCell.innerHTML = sGroup;\n nGroup.appendChild( nCell );\n nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );\n sLastGroup = sGroup;\n }\n \n \n }\n\t}"; $i = 0; print '<tfoot>'; print '</tfoot>'; print '<tbody>'; try { $result = $object->getView("default_right"); } catch (Exception $exc) { print $exc->getMessage(); } if (count($result->rows)) { foreach ($result->rows as $aRow) { print '<tr>'; $object->values->name = $aRow->value->name; $object->values->numero = $aRow->value->numero; $object->values->rights_class = $aRow->value->rights_class; $object->values->id = $aRow->value->id; $object->values->perm = $aRow->value->perm; $object->values->Status = $aRow->value->Status == true ? "true" : "false"; print '<td>' . $aRow->value->id . '</td>'; print '<td>' . img_object('', $aRow->value->picto) . " " . $object->getName() . '</td>'; print '<td>' . $object->getPermDesc() . '<a name="' . $aRow->value->id . '"> </a></td>';
/** * Load setup values into conf object (read llx_const) * * @param DoliDB $db Handler d'acces base * @return int < 0 if KO, >= 0 if OK */ function setValues() { global $conf; dol_syslog(get_class($this) . "::setValues", LOG_INFO, get_class($this)); // Avoid warning if not defined if (empty($this->db->dolibarr_main_db_encryption)) { $this->db->dolibarr_main_db_encryption = 0; } if (empty($this->db->dolibarr_main_db_cryptkey)) { $this->db->dolibarr_main_db_cryptkey = ''; } /* * Definition de toutes les constantes globales d'environnement * - En constante php (TODO a virer) * - En $this->global->key=value */ $found = false; $result = dol_getcache("const"); if (is_object($result)) { $found = true; } if (!$found) { $result = array(); try { $result = $this->load('const'); //print_r($result); dol_setcache("const", $result); } catch (Exception $e) { dol_print_error("", $e->getMessage()); exit; } } $i = 0; if (count($result->values) == 0) { dol_print_error("", "Error in const document : values is empty !"); exit; } foreach ($result->values as $key => $value) { if ($key) { if (!defined("{$key}")) { define("{$key}", $value); } // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install) $this->global->{$key} = $value; if ($value && preg_match('/^MAIN_MODULE_/', $key)) { // If this is constant for a new tab page activated by a module. if (preg_match('/^MAIN_MODULE_([A-Z_]+)_TABS_/i', $key)) { $params = explode(':', $value, 2); $this->tabs_modules[$params[0]][] = $value; } elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_SMS$/i', $key, $reg)) { $modulename = strtolower($reg[1]); $this->sms_engine_modules[$modulename] = $modulename; // Add this module in list of modules that provide SMS } elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_([A-Z]+)$/i', $key, $reg)) { $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); //$varname = $partname.'_modules'; // TODO deprecated //if (! isset($this->$varname) || ! is_array($this->$varname)) { $this->$varname = array(); } // TODO deprecated if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } $arrValue = json_decode($value, true); if (is_array($arrValue) && !empty($arrValue)) { $value = $arrValue; } else { if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl', 'theme'))) { $value = '/' . $modulename . '/core/' . $partname . '/'; } else { if (in_array($partname, array('models'))) { $value = '/' . $modulename . '/'; } else { if ($value == 1) { $value = '/' . $modulename . '/core/modules/' . $partname . '/'; } } } } //$this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); } } } $i++; } // load configuration module $object = new DolibarrModules($this->db); $result = $object->getView("list", array(), true); foreach ($result->rows as $aRow) { $modulename = $aRow->key; $this->{$modulename} = $aRow->value; $this->modules[] = $modulename; } //print_r($this);exit; //var_dump($this->modules); //var_dump($this->modules_parts); // Second or others levels object $this->propal->cloture = (object) array(); $this->propal->facturation = (object) array(); $this->commande->client = (object) array(); $this->commande->fournisseur = (object) array(); $this->facture->client = (object) array(); $this->facture->fournisseur = (object) array(); $this->fournisseur->commande = (object) array(); $this->fournisseur->facture = (object) array(); $this->contrat->services = (object) array(); $this->contrat->services->inactifs = (object) array(); $this->contrat->services->expires = (object) array(); $this->adherent->cotisation = (object) array(); $this->bank->rappro = (object) array(); $this->bank->cheque = (object) array(); // Clean some variables if (empty($this->global->MAIN_MENU_STANDARD)) { $this->global->MAIN_MENU_STANDARD = "eldy_backoffice.php"; } if (empty($this->global->MAIN_MENUFRONT_STANDARD)) { $this->global->MAIN_MENUFRONT_STANDARD = "eldy_frontoffice.php"; } if (empty($this->global->MAIN_MENU_SMARTPHONE)) { $this->global->MAIN_MENU_SMARTPHONE = "eldy_backoffice.php"; } // Use eldy by default because smartphone does not work on all phones if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) { $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_frontoffice.php"; } // Ue eldy by default because smartphone does not work on all phones // Variable globales LDAP if (empty($this->global->LDAP_FIELD_FULLNAME)) { $this->global->LDAP_FIELD_FULLNAME = ''; } if (!isset($this->global->LDAP_KEY_USERS)) { $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME; } if (!isset($this->global->LDAP_KEY_GROUPS)) { $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME; } if (!isset($this->global->LDAP_KEY_CONTACTS)) { $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME; } if (!isset($this->global->LDAP_KEY_MEMBERS)) { $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME; } // Load translation object with current language if (empty($this->global->MAIN_LANG_DEFAULT)) { $this->global->MAIN_LANG_DEFAULT = "en_US"; } // By default, we repeat info on all tabs if (!isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) { $this->global->MAIN_REPEATCONTACTONEACHTAB = 1; } if (!isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) { $this->global->MAIN_REPEATADDRESSONEACHTAB = 1; } $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // Define default dir_output and dir_temp for directories of modules foreach ($this->modules as $module) { $this->{$module}->multidir_output = array($this->entity => $rootfordata . "/" . $module); $this->{$module}->multidir_temp = array($this->entity => $rootfordata . "/" . $module . "/temp"); // For backward compatibility $this->{$module}->dir_output = $rootfordata . "/" . $module; $this->{$module}->dir_temp = $rootfordata . "/" . $module . "/temp"; } // For mycompany storage $this->mycompany->dir_output = $rootfordata . "/mycompany"; $this->mycompany->dir_temp = $rootfordata . "/mycompany/temp"; // For admin storage $this->admin->dir_output = $rootfordata . '/admin'; $this->admin->dir_temp = $rootfordata . '/admin/temp'; // For user storage $this->user->multidir_output = array($this->entity => $rootfordata . "/users"); $this->user->multidir_temp = array($this->entity => $rootfordata . "/users/temp"); // For backward compatibility $this->user->dir_output = $rootforuser . "/users"; $this->user->dir_temp = $rootforuser . "/users/temp"; // For propal storage $this->propal->dir_output = $rootforuser . "/propale"; $this->propal->dir_temp = $rootforuser . "/propale/temp"; // Exception: Some dir are not the name of module. So we keep exception here // for backward compatibility. // Sous module bons d'expedition $this->expedition_bon->enabled = defined("MAIN_SUBMODULE_EXPEDITION") ? MAIN_SUBMODULE_EXPEDITION : 0; // Sous module bons de livraison $this->livraison_bon->enabled = defined("MAIN_SUBMODULE_LIVRAISON") ? MAIN_SUBMODULE_LIVRAISON : 0; // Module fournisseur $this->fournisseur->commande->dir_output = $rootfordata . "/fournisseur/commande"; $this->fournisseur->commande->dir_temp = $rootfordata . "/fournisseur/commande/temp"; $this->fournisseur->facture->dir_output = $rootfordata . "/fournisseur/facture"; $this->fournisseur->facture->dir_temp = $rootfordata . "/fournisseur/facture/temp"; // Module product/service $this->product->multidir_output = array($this->entity => $rootfordata . "/produit"); $this->product->multidir_temp = array($this->entity => $rootfordata . "/produit/temp"); $this->service->multidir_output = array($this->entity => $rootfordata . "/produit"); $this->service->multidir_temp = array($this->entity => $rootfordata . "/produit/temp"); // For backward compatibility $this->product->dir_output = $rootfordata . "/produit"; $this->product->dir_temp = $rootfordata . "/produit/temp"; $this->service->dir_output = $rootfordata . "/produit"; $this->service->dir_temp = $rootfordata . "/produit/temp"; // Module contrat $this->contrat->dir_output = $rootfordata . "/contracts"; $this->contrat->dir_temp = $rootfordata . "/contracts/temp"; // Set some default values // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) { $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; } if (empty($this->global->SOCIETE_CODEFOURNISSEUR_ADDON)) { $this->global->SOCIETE_CODEFOURNISSEUR_ADDON = $this->global->SOCIETE_CODECLIENT_ADDON; } if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) { $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum"; } // Security if (empty($this->global->USER_PASSWORD_GENERATED)) { $this->global->USER_PASSWORD_GENERATED = 'standard'; } // Default password generator if (empty($this->global->MAIN_UMASK)) { $this->global->MAIN_UMASK = '0664'; } // Default mask // conf->use_javascript_ajax $this->use_javascript_ajax = 1; if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) { $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT; } // If no javascript_ajax, Ajax features are disabled. if (!$this->use_javascript_ajax) { $this->global->PRODUIT_USE_SEARCH_TO_SELECT = 0; } // conf->currency if (empty($this->global->MAIN_MONNAIE)) { $this->global->MAIN_MONNAIE = 'EUR'; } $this->currency = $this->global->MAIN_MONNAIE; // conf->global->COMPTA_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) if (empty($this->global->COMPTA_MODE)) { $this->global->COMPTA_MODE = 'RECETTES-DEPENSES'; } // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) { $this->global->MAIN_SIZE_LISTE_LIMIT = 25; } $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT; // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_VIEW_LIMIT)) { $this->global->MAIN_SIZE_VIEW_LIMIT = 10000; } $this->view_limit = $this->global->MAIN_SIZE_VIEW_LIMIT; // conf->product->limit_size = constante de taille maximale des select de produit if (!isset($this->global->PRODUIT_LIMIT_SIZE)) { $this->global->PRODUIT_LIMIT_SIZE = 100; } $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE; // conf->theme et $this->css if (empty($this->global->MAIN_THEME)) { $this->global->MAIN_THEME = "eldy"; } $this->theme = $this->global->MAIN_THEME; $this->css = "/theme/" . $this->theme . "/style.css.php"; // conf->email_from = email pour envoi par dolibarr des mails automatiques $this->email_from = "*****@*****.**"; if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) { $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM; } // conf->notification->email_from = email pour envoi par Dolibarr des notifications $this->notification->email_from = $this->email_from; if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) { $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM; } // conf->mailing->email_from = email pour envoi par Dolibarr des mailings $this->mailing->email_from = $this->email_from; if (!empty($this->global->MAILING_EMAIL_FROM)) { $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; } // Format for date (used by default when not found or searched in lang) $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags $this->format_hour_short = "%H:%M"; $this->format_hour_short_duration = "%H:%M"; $this->format_date_text_short = "%d %b %Y"; $this->format_date_text = "%d %B %Y"; $this->format_date_hour_short = "%d/%m/%Y %H:%M"; $this->format_date_hour_text_short = "%d %b %Y %H:%M"; $this->format_date_hour_text = "%d %B %Y %H:%M"; // Limites decimales si non definie (peuvent etre egale a 0) if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) { $this->global->MAIN_MAX_DECIMALS_UNIT = 5; } if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) { $this->global->MAIN_MAX_DECIMALS_TOT = 2; } if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) { $this->global->MAIN_MAX_DECIMALS_SHOWN = 8; } // Timeouts if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) { $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; } if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) { $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; } // Set default variable to calculate VAT as if option tax_mode was 0 (standard) if (empty($this->global->TAX_MODE_SELL_PRODUCT)) { $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; } if (empty($this->global->TAX_MODE_BUY_PRODUCT)) { $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; } if (empty($this->global->TAX_MODE_SELL_SERVICE)) { $this->global->TAX_MODE_SELL_SERVICE = 'payment'; } if (empty($this->global->TAX_MODE_BUY_SERVICE)) { $this->global->TAX_MODE_BUY_SERVICE = 'payment'; } // Delay before warnings $this->actions->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60; $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 24 * 60 * 60; $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 24 * 60 * 60; $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 24 * 60 * 60; $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 24 * 60 * 60; $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 24 * 60 * 60; $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 24 * 60 * 60; $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 24 * 60 * 60; $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60; $this->adherent->cotisation->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60; $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 24 * 60 * 60; $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 24 * 60 * 60; // For backward compatibility if (isset($this->product)) { $this->produit = $this->product; } if (isset($this->facture)) { $this->invoice = $this->facture; } if (isset($this->commande)) { $this->order = $this->commande; } if (isset($this->contrat)) { $this->contract = $this->contrat; } if (isset($this->categorie)) { $this->category = $this->categorie; } // Define menu manager in setup if (empty($user->societe_id)) { // If internal user or not defined $this->top_menu = empty($this->global->MAIN_MENU_STANDARD_FORCED) ? $this->global->MAIN_MENU_STANDARD : $this->global->MAIN_MENU_STANDARD_FORCED; $this->smart_menu = empty($this->global->MAIN_MENU_SMARTPHONE_FORCED) ? $this->global->MAIN_MENU_SMARTPHONE : $this->global->MAIN_MENU_SMARTPHONE_FORCED; } else { // If external user $this->top_menu = empty($this->global->MAIN_MENUFRONT_STANDARD_FORCED) ? $this->global->MAIN_MENUFRONT_STANDARD : $this->global->MAIN_MENUFRONT_STANDARD_FORCED; $this->smart_menu = empty($this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? $this->global->MAIN_MENUFRONT_SMARTPHONE : $this->global->MAIN_MENUFRONT_SMARTPHONE_FORCED; } }
/** * Load permissions granted to user into object user * * @param string $moduletag Limit permission for a particular module ('' by default means load all permissions) * @return void */ function getrights($moduletag = '') { global $conf; if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) { // Le fichier de ce module est deja charge return; } if ($this->all_permissions_are_loaded) { // Si les permissions ont deja ete charge pour ce user, on quitte return; } $object = new DolibarrModules($this->db); try { $result = $object->getView("default_right", '', true); foreach ($this->values->roles as $aRow) // load groups $groups[] = $object->couchdb->getDoc("group:" . $aRow); } catch (Exception $exc) { print $exc->getMessage(); } if (count($result->rows)) { foreach ($result->rows as $aRow) { //$object->values->name = $aRow->value->name; //$object->values->numero = $aRow->value->numero; $rights_class = $aRow->value->rights_class; //$object->values->id = $aRow->value->id; $perm = $aRow->value->perm; // Add default rights if (count($perm) == 1) $this->rights->$rights_class->$perm[0] = $aRow->value->Status; elseif (count($perm) == 2) { if (isset($this->rights->$rights_class->$perm[0])) $this->rights->$rights_class->$perm[0]->$perm[1] = $aRow->value->Status; else $this->rights->$rights_class->$perm[0]->$perm[1] = $aRow->value->Status; } // Add user rights if ((is_array($this->values->rights) && isset($this->values->rights->$key)) || $this->admin) { if (count($perm) == 1) $this->rights->$rights_class->$perm[0] = true; elseif (count($perm) == 2) $this->rights->$rights_class->$perm[0]->$perm[1] = true; } // Add groups rights for ($i = 0; $i < count($groups); $i++) { $key = $aRow->value->id; if (isset($groups[$i]->rights->$key)) { if (count($perm) == 1) $this->rights->$rights_class->$perm[0] = true; elseif (count($perm) == 2) $this->rights->$rights_class->$perm[0]->$perm[1] = true; } } } } //print_r($this->rights); if (!$moduletag) { // Si module etait non defini, alors on a tout charge, on peut donc considerer // que les droits sont en cache (car tous charges) pour cet instance de user $this->all_permissions_are_loaded = 1; } else { // Si module defini, on le marque comme charge en cache $this->_tab_loaded[$moduletag] = 1; } }