clean code
This commit is contained in:
parent
2daa9b2dba
commit
0a67bff3d5
@ -88,8 +88,8 @@ if ($id > 0 || !empty($ref)) {
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->bookcal->availabilities->read;
|
||||
$permissiontoadd = $user->rights->bookcal->availabilities->write;
|
||||
$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
|
||||
$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permissiontoadd = 1;
|
||||
@ -100,7 +100,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -77,11 +77,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->bookcal->availabilities->read;
|
||||
$permissiontoadd = $user->rights->bookcal->availabilities->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
$permissiontodelete = $user->rights->bookcal->availabilities->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||
$permissionnote = $user->rights->bookcal->availabilities->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->rights->bookcal->availabilities->write; // Used by the include of actions_dellink.inc.php
|
||||
$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
|
||||
$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
$permissiontodelete = $user->hasRight('bookcal', 'availabilities', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||
$permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_dellink.inc.php
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
@ -97,7 +97,7 @@ $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -53,8 +53,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->bookcal->availabilities->read;
|
||||
$permission = $user->rights->bookcal->availabilities->write;
|
||||
$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
|
||||
$permission = $user->hasRight('bookcal', 'availabilities', 'write');
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permission = 1;
|
||||
@ -65,7 +65,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -78,8 +78,8 @@ if ($id > 0 || !empty($ref)) {
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->bookcal->availabilities->read;
|
||||
$permissiontoadd = $user->rights->bookcal->availabilities->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
|
||||
$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
|
||||
$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permissiontoadd = 1;
|
||||
@ -90,7 +90,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
@ -192,9 +192,9 @@ if ($object->id) {
|
||||
print dol_get_fiche_end();
|
||||
|
||||
$modulepart = 'bookcal';
|
||||
//$permissiontoadd = $user->rights->bookcal->availabilities->write;
|
||||
//$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
|
||||
$permissiontoadd = 1;
|
||||
//$permtoedit = $user->rights->bookcal->availabilities->write;
|
||||
//$permtoedit = $user->hasRight('bookcal', 'availabilities', 'write');
|
||||
$permtoedit = 1;
|
||||
$param = '&id='.$object->id;
|
||||
|
||||
|
||||
@ -132,9 +132,9 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->bookcal->availabilities->read;
|
||||
$permissiontoadd = $user->rights->bookcal->availabilities->write;
|
||||
$permissiontodelete = $user->rights->bookcal->availabilities->delete;
|
||||
$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
|
||||
$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
|
||||
$permissiontodelete = $user->hasRight('bookcal', 'availabilities', 'delete');
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permissiontoadd = 1;
|
||||
@ -147,7 +147,7 @@ if ($user->socid > 0) accessforbidden();
|
||||
//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden('Module not enabled');
|
||||
if (!isModEnabled('bookcal')) accessforbidden('Module not enabled');
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -56,9 +56,9 @@ if ($id > 0 || !empty($ref)) {
|
||||
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
|
||||
$enablepermissioncheck = 0;
|
||||
if ($enablepermissioncheck) {
|
||||
$permissiontoread = $user->rights->bookcal->availabilities->read;
|
||||
$permissiontoadd = $user->rights->bookcal->availabilities->write;
|
||||
$permissionnote = $user->rights->bookcal->availabilities->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
|
||||
$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
|
||||
$permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php
|
||||
} else {
|
||||
$permissiontoread = 1;
|
||||
$permissiontoadd = 1;
|
||||
@ -70,7 +70,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
// BEGIN MODULEBUILDER DRAFT MYOBJECT
|
||||
// Draft MyObject
|
||||
if ($user->rights->bookcal->availabilities->read && !empty($conf->bookcal->enabled)) {
|
||||
if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookcal')) {
|
||||
$langs->load("orders");
|
||||
|
||||
$sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
|
||||
@ -143,8 +143,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
||||
|
||||
/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
|
||||
// Last modified myobject
|
||||
if (! empty($conf->bookcal->enabled))
|
||||
{
|
||||
if (isModEnabled('bookcal')) {
|
||||
$sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
|
||||
$sql .= " FROM ". MAIN_DB_PREFIX . 'bookcal_booking';
|
||||
print "here2";
|
||||
|
||||
@ -100,7 +100,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ if ($user->socid > 0) accessforbidden();
|
||||
//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden('Module not enabled');
|
||||
if (!isModEnabled('bookcal')) accessforbidden('Module not enabled');
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ if ($enablepermissioncheck) {
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
|
||||
if (empty($conf->bookcal->enabled)) accessforbidden();
|
||||
if (!isModEnabled('bookcal')) accessforbidden();
|
||||
if (!$permissiontoread) accessforbidden();
|
||||
|
||||
|
||||
|
||||
@ -201,7 +201,7 @@ class Availabilities extends CommonObject
|
||||
}
|
||||
|
||||
// Example to show how to set values of fields definition dynamically
|
||||
/*if ($user->rights->bookcal->availabilities->read) {
|
||||
/*if ($user->hasRight('bookcal', 'availabilities', 'read')) {
|
||||
$this->fields['myfield']['visible'] = 1;
|
||||
$this->fields['myfield']['noteditable'] = 0;
|
||||
}*/
|
||||
@ -516,7 +516,7 @@ class Availabilities extends CommonObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->availabilities->write))
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('bookcal', 'availabilities', 'write'))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->availabilities->availabilities_advance->validate))))
|
||||
{
|
||||
$this->error='NotEnoughPermissions';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user