2
0
forked from Wavyzz/dolibarr

Work on modulebuilder

This commit is contained in:
Laurent Destailleur
2017-09-23 01:24:31 +02:00
parent 96aed9c29d
commit 57adc28256
9 changed files with 343 additions and 45 deletions

View File

@@ -77,6 +77,8 @@ if ($action == 'setproductionmode')
}
}
dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge
/*
* View

View File

@@ -32,7 +32,7 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel
{
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public');
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// Set public note
@@ -40,6 +40,6 @@ else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('
{
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private');
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}

View File

@@ -601,9 +601,10 @@ function dol_include_once($relpath, $classname='')
*
* @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
* @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
* @param int $returnemptyifnotfound If file was not found, do not return default path but an empty string
* @return string Full filesystem path (if mode=0), Full url path (if mode=1)
*/
function dol_buildpath($path, $type=0)
function dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
{
global $conf;
@@ -611,16 +612,20 @@ function dol_buildpath($path, $type=0)
if (empty($type)) // For a filesystem path
{
$res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard value
$res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
{
if ($key == 'main') continue;
if (file_exists($dirroot.'/'.$path))
{
$res=$dirroot.'/'.$path;
break;
return $res;
}
}
if ($returnemptyifnotfound) // Not found, we return empty string
{
return '';
}
}
else // For an url path
{

View File

@@ -66,3 +66,6 @@ NoTrigger=No trigger
NoWidget=No widget
EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION)
VisibleDesc=Is field is visible in list (-1 means not shown by default but can be added into list to be viewed)
MenusDefDesc=Define here the menus provided by your module (once defined, they are visible into the menu editor %s)
PermissionsDefDesc=Define here the new permissions provided by your module (once defined, they are visible into the default permissions setup %s)
ListOfPermissionsDefined=List of defined permissions

View File

@@ -682,17 +682,27 @@ if ($action == 'savefile' && empty($cancel))
// Save old version
if (dol_is_file($pathoffile))
{
dol_move($pathoffile, $pathoffilebackup, 0, 1, 0, 0);
dol_copy($pathoffile, $pathoffilebackup, 0, 1);
}
$content = GETPOST('editfilecontent');
$content = GETPOST('editfilecontent','none');
// Save file on disk
if ($content)
{
dol_delete_file($pathoffile);
file_put_contents($pathoffile, $content);
@chmod($pathoffile, octdec($newmask));
setEventMessages($langs->trans("FileSaved"), null);
}
else
{
setEventMessages($langs->trans("ContentCantBeEmpty"), null, 'errors');
//$action='editfile';
$error++;
}
}
}
// Enable module
@@ -1141,9 +1151,12 @@ elseif (! empty($module))
}
else
{
$fullpathoffile=dol_buildpath($file, 0); // Description - level 2
$fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2
if ($fullpathoffile)
{
$content = file_get_contents($fullpathoffile);
}
// New module
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@@ -1161,7 +1174,7 @@ elseif (! empty($module))
dol_fiche_end();
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1213,7 +1226,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1258,7 +1271,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'text'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1380,19 +1393,30 @@ elseif (! empty($module))
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.$pathtoapi.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("TestClassFile").' : <strong>'.$pathtophpunit.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.$pathtosql.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("DropTableIfEmpty").'</a>';
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileExtraFields").' : <strong>'.$pathtosqlextra.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&file='.urlencode($pathtosqlextra).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileKey").' : <strong>'.$pathtosqlkey.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosqlkey).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>';
print '<br>';
print '</div>';
print '<div class="fichehalfleft">';
print '<span class="fa fa-file"></span> '.$langs->trans("PageForList").' : <strong>'.$pathtolist.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolist).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
@@ -1587,7 +1611,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1601,14 +1625,251 @@ elseif (! empty($module))
if ($tab == 'menus')
{
print $langs->trans("FeatureNotYetAvailable");
$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
//$menus = $moduleobj->;
if ($action != 'editfile' || empty($file))
{
print $langs->trans("MenusDefDesc", '<a href="'.DOL_URL_ROOT.'/admin/menus/index.php">'.$langs->trans('Menus').'</a>').'<br>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>';
print '<br>';
//print load_fiche_titre($langs->trans("MenusList"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addproperty">';
print '<input type="hidden" name="tab" value="objects">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
/*
print '<div class="div-table-responsive">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print_liste_field_titre("Menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print "</tr>\n";
if (count($menus))
{
foreach ($cronjobs as $cron)
{
print '<tr class="oddeven">';
print '<td>';
print $cron['label'];
print '</td>';
print '<td>';
if ($cron['jobtype']=='method')
{
$text=$langs->trans("CronClass");
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
}
elseif ($cron['jobtype']=='command')
{
$text=$langs->trans('CronCommand');
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
}
print $form->textwithpicto($text, $texttoshow, 1);
print '</td>';
print '<td>';
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
print '</td>';
print '<td>';
print $cron['status'];
print '</td>';
print '<td>';
if (!empty($cron['comment'])) {print $cron['comment'];}
print '</td>';
print '</tr>';
}
}
else
{
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
print '</div>';
print '</form>';
*/
}
else
{
$fullpathoffile=dol_buildpath($file, 0);
$content = file_get_contents($fullpathoffile);
// New module
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="savefile">';
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
print '<input type="hidden" name="tab" value="'.$tab.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
print '</form>';
}
}
if ($tab == 'permissions')
{
print $langs->trans("FeatureNotYetAvailable");
$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
//$perms = $moduleobj->;
if ($action != 'editfile' || empty($file))
{
print $langs->trans("PermissionsDefDesc", '<a href="'.DOL_URL_ROOT.'/admin/perms.php">'.$langs->trans('DefaultPermissions').'</a>').'<br>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>';
print '<br>';
print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addproperty">';
print '<input type="hidden" name="tab" value="objects">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
print 'TODO...';
/*
print '<div class="div-table-responsive">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder);
print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print "</tr>\n";
if (count($cronjobs))
{
foreach ($cronjobs as $cron)
{
print '<tr class="oddeven">';
print '<td>';
print $cron['label'];
print '</td>';
print '<td>';
if ($cron['jobtype']=='method')
{
$text=$langs->trans("CronClass");
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
}
elseif ($cron['jobtype']=='command')
{
$text=$langs->trans('CronCommand');
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
}
print $form->textwithpicto($text, $texttoshow, 1);
print '</td>';
print '<td>';
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
print '</td>';
print '<td>';
print $cron['status'];
print '</td>';
print '<td>';
if (!empty($cron['comment'])) {print $cron['comment'];}
print '</td>';
print '</tr>';
}
}
else
{
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
print '</div>';
print '</form>';
*/
}
else
{
$fullpathoffile=dol_buildpath($file, 0);
$content = file_get_contents($fullpathoffile);
// New module
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="savefile">';
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
print '<input type="hidden" name="tab" value="'.$tab.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
print '</form>';
}
}
if ($tab == 'hooks')
@@ -1638,7 +1899,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1690,7 +1951,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1741,7 +2002,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
@@ -1842,6 +2103,8 @@ elseif (! empty($module))
print '</table>';
print '</div>';
print '</form>';
}
else
{
@@ -1861,7 +2124,7 @@ elseif (! empty($module))
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';

View File

@@ -1,4 +1,4 @@
# CHANGELOG FOR DOLIBARR ERP CRM
# CHANGELOG MYMODULE FOR DOLIBARR ERP CRM
## 1.0
Initial version

View File

@@ -144,7 +144,7 @@ class MyObject extends CommonObject
$this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $fields['rowid']['visible']=0;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
}
/**

View File

@@ -273,9 +273,21 @@ if ($action == 'create')
print '<tr id="field_'.$key.'"><td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) print ' fieldrequired';
if ($val['type'] == 'text') print ' tdtop';
print '"';
print '>'.$langs->trans($val['label']).'</td>';
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
print '<td>';
if ($val['type'] == 'text')
{
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
print GETPOST($key,'none');
print '</textarea>';
}
else
{
print '<input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
}
print '</td>';
print '</tr>';
}
print '</table>'."\n";
@@ -292,7 +304,7 @@ if ($action == 'create')
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
print load_fiche_titre($langs->trans("MyModule"));
print load_fiche_titre($langs->trans("MyObject"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="action" value="update">';
@@ -308,9 +320,21 @@ if (($id || $ref) && $action == 'edit')
print '<tr><td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) print ' fieldrequired';
if ($val['type'] == 'text') print ' tdtop';
print '"';
print '>'.$langs->trans($val['label']).'</td>';
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
print '<td>';
if ($val['type'] == 'text')
{
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
print GETPOST($key,'none');
print '</textarea>';
}
else
{
print '<input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
}
print '</td>';
print '</tr>';
}
print '</table>';
@@ -326,6 +350,7 @@ if (($id || $ref) && $action == 'edit')
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{

View File

@@ -275,11 +275,11 @@ if ($action == 'add')
}
else
{
$objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS');
$objectpage->lang = GETPOST('WEBSITE_LANG');
$objectpage->title = GETPOST('WEBSITE_TITLE','alpha');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha');
$objectpage->lang = GETPOST('WEBSITE_LANG','alpha');
}
if (! $error)
@@ -392,7 +392,7 @@ if ($action == 'updatecss')
// $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page
$htmlheadercontent.= "// END PHP ?>\n";*/
$htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER'));
$htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER', 'none'));
/*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n";
$htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
@@ -425,7 +425,7 @@ if ($action == 'updatecss')
$csscontent.= "header('Content-type: text/css');\n";
$csscontent.= "// END PHP ?>\n";
$csscontent.= GETPOST('WEBSITE_CSS_INLINE');
$csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none');
$csscontent.= "\n".'<?php // BEGIN PHP'."\n";
$csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
@@ -457,7 +457,7 @@ if ($action == 'updatecss')
$robotcontent.= "header('Content-type: text/css');\n";
$robotcontent.= "// END PHP ?>\n";*/
$robotcontent.= GETPOST('WEBSITE_ROBOT');
$robotcontent.= GETPOST('WEBSITE_ROBOT', 'none');
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
@@ -489,7 +489,7 @@ if ($action == 'updatecss')
$robotcontent.= "header('Content-type: text/css');\n";
$robotcontent.= "// END PHP ?>\n";*/
$htaccesscontent.= GETPOST('WEBSITE_HTACCESS');
$htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none');
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
@@ -587,11 +587,11 @@ if ($action == 'updatemeta')
{
$objectpage->old_object = clone $objectpage;
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
$objectpage->title = GETPOST('WEBSITE_TITLE');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS');
$objectpage->lang = GETPOST('WEBSITE_LANG');
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
$objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha');
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
$objectpage->lang = GETPOST('WEBSITE_LANG', 'alpha');
$res = $objectpage->update($user);
if (! $res > 0)