mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 19:02:35 +01:00
code syntax admin dir
This commit is contained in:
@@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors'));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$id = GETPOST('rowid', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = 'page,param';
|
||||
if (!$sortorder) $sortorder = 'ASC';
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'page,param';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'ASC';
|
||||
}
|
||||
|
||||
$defaulturl = GETPOST('defaulturl', 'alphanohtml');
|
||||
$defaultkey = GETPOST('defaultkey', 'alphanohtml');
|
||||
@@ -71,18 +79,23 @@ $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$defaulturl = '';
|
||||
$defaultkey = '';
|
||||
$defaultvalue = '';
|
||||
@@ -90,60 +103,51 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
$search_array_options = array();
|
||||
}
|
||||
|
||||
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
|
||||
{
|
||||
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
|
||||
else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
|
||||
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') {
|
||||
if (GETPOST('value')) {
|
||||
dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
|
||||
} else {
|
||||
dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
}
|
||||
|
||||
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify'))
|
||||
{
|
||||
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) {
|
||||
$error = 0;
|
||||
|
||||
if (($action == 'add' || (GETPOST('add') && $action != 'update')))
|
||||
{
|
||||
if (empty($defaulturl))
|
||||
{
|
||||
if (($action == 'add' || (GETPOST('add') && $action != 'update'))) {
|
||||
if (empty($defaulturl)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($defaultkey))
|
||||
{
|
||||
if (empty($defaultkey)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if (GETPOST('actionmodify'))
|
||||
{
|
||||
if (empty($urlpage))
|
||||
{
|
||||
if (GETPOST('actionmodify')) {
|
||||
if (empty($urlpage)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($key))
|
||||
{
|
||||
if (empty($key)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
|
||||
{
|
||||
if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
|
||||
}
|
||||
if (GETPOST('actionmodify'))
|
||||
{
|
||||
if (GETPOST('actionmodify')) {
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
|
||||
$sql .= " WHERE rowid = ".$id;
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||
$action = "";
|
||||
@@ -159,13 +163,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
|
||||
}
|
||||
|
||||
// Delete line from delete picto
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id);
|
||||
// Delete const
|
||||
$result = $db->query($sql);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@@ -187,8 +189,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp);
|
||||
$param = '&mode='.$mode;
|
||||
|
||||
$enabledisablehtml = $langs->trans("EnableDefaultValues").' ';
|
||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
|
||||
{
|
||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
|
||||
// Button off, click to enable
|
||||
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().'&value=1'.$param.'">';
|
||||
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
@@ -205,16 +206,30 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl
|
||||
print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
|
||||
print "<br>\n";
|
||||
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl);
|
||||
if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey);
|
||||
if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
if ($defaulturl) {
|
||||
$param .= '&defaulturl='.urlencode($defaulturl);
|
||||
}
|
||||
if ($defaultkey) {
|
||||
$param .= '&defaultkey='.urlencode($defaultkey);
|
||||
}
|
||||
if ($defaultvalue) {
|
||||
$param .= '&defaultvalue='.urlencode($defaultvalue);
|
||||
}
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
@@ -226,12 +241,10 @@ $head = defaultvalues_prepare_head();
|
||||
|
||||
print dol_get_fiche_head($head, $mode, '', -1, '');
|
||||
|
||||
if ($mode == 'sortorder')
|
||||
{
|
||||
if ($mode == 'sortorder') {
|
||||
print info_admin($langs->trans("WarningSettingSortOrder")).'<br>';
|
||||
}
|
||||
if ($mode == 'mandatory')
|
||||
{
|
||||
if ($mode == 'mandatory') {
|
||||
print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>';
|
||||
}
|
||||
|
||||
@@ -244,15 +257,17 @@ print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
// Page
|
||||
$texthelp = $langs->trans("PageUrlForDefaultValues");
|
||||
if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
|
||||
else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
|
||||
if ($mode == 'createform') {
|
||||
$texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
|
||||
} else {
|
||||
$texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
|
||||
}
|
||||
$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
|
||||
$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp);
|
||||
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
|
||||
// Field
|
||||
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
|
||||
if ($mode != 'sortorder')
|
||||
{
|
||||
if ($mode != 'sortorder') {
|
||||
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
|
||||
} else {
|
||||
$texthelp = 'field or alias.field';
|
||||
@@ -260,15 +275,12 @@ if ($mode != 'sortorder')
|
||||
}
|
||||
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
|
||||
// Value
|
||||
if ($mode != 'focus' && $mode != 'mandatory')
|
||||
{
|
||||
if ($mode != 'sortorder')
|
||||
{
|
||||
if ($mode != 'focus' && $mode != 'mandatory') {
|
||||
if ($mode != 'sortorder') {
|
||||
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
|
||||
unset($substitutionarray['__USER_SIGNATURE__']);
|
||||
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
foreach ($substitutionarray as $key => $val)
|
||||
{
|
||||
foreach ($substitutionarray as $key => $val) {
|
||||
$texthelp .= $key.' -> '.$val.'<br>';
|
||||
}
|
||||
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
|
||||
@@ -279,8 +291,11 @@ if ($mode != 'focus' && $mode != 'mandatory')
|
||||
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
// Entity
|
||||
if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
|
||||
else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||
print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
|
||||
} else {
|
||||
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
// Actions
|
||||
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
print "</tr>\n";
|
||||
@@ -299,15 +314,13 @@ print '<td>';
|
||||
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">';
|
||||
print '</td>';
|
||||
// Value
|
||||
if ($mode != 'focus' && $mode != 'mandatory')
|
||||
{
|
||||
if ($mode != 'focus' && $mode != 'mandatory') {
|
||||
print '<td>';
|
||||
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
|
||||
print '</td>';
|
||||
}
|
||||
// Limit to superadmin
|
||||
if (!empty($conf->multicompany->enabled) && !$user->entity)
|
||||
{
|
||||
if (!empty($conf->multicompany->enabled) && !$user->entity) {
|
||||
print '<td>';
|
||||
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
|
||||
print '</td>';
|
||||
@@ -318,7 +331,9 @@ if (!empty($conf->multicompany->enabled) && !$user->entity)
|
||||
}
|
||||
print '<td class="center">';
|
||||
$disabled = '';
|
||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"';
|
||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
|
||||
$disabled = ' disabled="disabled"';
|
||||
}
|
||||
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
@@ -333,13 +348,11 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
dol_syslog("translation::select from table", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
print "\n";
|
||||
@@ -348,27 +361,35 @@ if ($result)
|
||||
|
||||
// Page
|
||||
print '<td>';
|
||||
if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page;
|
||||
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
|
||||
if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) {
|
||||
print $obj->page;
|
||||
} else {
|
||||
print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
|
||||
}
|
||||
print '</td>'."\n";
|
||||
|
||||
// Field
|
||||
print '<td>';
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param;
|
||||
else print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">';
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
|
||||
print $obj->param;
|
||||
} else {
|
||||
print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">';
|
||||
}
|
||||
print '</td>'."\n";
|
||||
|
||||
// Value
|
||||
if ($mode != 'focus' && $mode != 'mandatory')
|
||||
{
|
||||
if ($mode != 'focus' && $mode != 'mandatory') {
|
||||
print '<td>';
|
||||
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
|
||||
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
|
||||
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
|
||||
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
|
||||
*/
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value);
|
||||
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
|
||||
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
|
||||
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
|
||||
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
|
||||
*/
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
|
||||
print dol_escape_htmltag($obj->value);
|
||||
} else {
|
||||
print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@@ -376,8 +397,7 @@ if ($result)
|
||||
|
||||
// Actions
|
||||
print '<td class="center">';
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
|
||||
{
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
|
||||
print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
|
||||
print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user