Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
dc6f90c4a7
@ -48,7 +48,7 @@ if (!defined('NOREQUIRETRAN')) {
|
|||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
|
||||||
|
$hookmanager->initHooks(array('rowinterface'));
|
||||||
// Security check
|
// Security check
|
||||||
// This is done later into view.
|
// This is done later into view.
|
||||||
|
|
||||||
@ -120,7 +120,15 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
|||||||
$perm = 1;
|
$perm = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$parameters = array('roworder'=> &$roworder, 'table_element_line' => &$table_element_line, 'fk_element' => &$fk_element, 'element_id' => &$element_id, 'perm' => &$perm);
|
||||||
|
$row = new GenericObject($db);
|
||||||
|
$row->table_element_line = $table_element_line;
|
||||||
|
$row->fk_element = $fk_element;
|
||||||
|
$row->id = $element_id;
|
||||||
|
$reshook = $hookmanager->executeHooks('checkRowPerms', $parameters, $row, $action);
|
||||||
|
if ($reshook > 0) {
|
||||||
|
$perm = $hookmanager->resArray['perm'];
|
||||||
|
}
|
||||||
if (! $perm) {
|
if (! $perm) {
|
||||||
// We should not be here. If we are not allowed to reorder rows, feature should not be visible on script.
|
// We should not be here. If we are not allowed to reorder rows, feature should not be visible on script.
|
||||||
// If we are here, it is a hack attempt, so we report a warning.
|
// If we are here, it is a hack attempt, so we report a warning.
|
||||||
@ -137,10 +145,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = new GenericObject($db);
|
|
||||||
$row->table_element_line = $table_element_line;
|
|
||||||
$row->fk_element = $fk_element;
|
|
||||||
$row->id = $element_id;
|
|
||||||
|
|
||||||
$row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line
|
$row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line
|
||||||
|
|
||||||
|
|||||||
@ -291,11 +291,12 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage,
|
|||||||
* @param string $fileindex Full path of file index.php
|
* @param string $fileindex Full path of file index.php
|
||||||
* @param string $filetpl File tpl the index.php page redirect to (used only if $fileindex is provided)
|
* @param string $filetpl File tpl the index.php page redirect to (used only if $fileindex is provided)
|
||||||
* @param string $filewrapper Full path of file wrapper.php
|
* @param string $filewrapper Full path of file wrapper.php
|
||||||
|
* @param Website $object Object website
|
||||||
* @return boolean True if OK
|
* @return boolean True if OK
|
||||||
*/
|
*/
|
||||||
function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
|
function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object = null)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $db;
|
||||||
|
|
||||||
$result1 = false;
|
$result1 = false;
|
||||||
$result2 = false;
|
$result2 = false;
|
||||||
@ -320,6 +321,44 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
|
|||||||
if (!empty($conf->global->MAIN_UMASK)) {
|
if (!empty($conf->global->MAIN_UMASK)) {
|
||||||
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
|
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_object($object) && $object->fk_default_home > 0) {
|
||||||
|
$objectpage = new WebsitePage($db);
|
||||||
|
$objectpage->fetch($object->fk_default_home);
|
||||||
|
|
||||||
|
// Create a version for sublanguages
|
||||||
|
if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) {
|
||||||
|
if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && is_object($object) && !empty($object->otherlang)) {
|
||||||
|
$dirname = dirname($fileindex);
|
||||||
|
foreach (explode(',', $object->otherlang) as $sublang) {
|
||||||
|
// Avoid to erase main alias file if $sublang is empty string
|
||||||
|
if (empty(trim($sublang))) continue;
|
||||||
|
$fileindexsub = $dirname.'/'.$sublang.'/index.php';
|
||||||
|
|
||||||
|
// Same indexcontent than previously but with ../ instead of ./ for master and tpl file include/require_once.
|
||||||
|
$relpath = '..';
|
||||||
|
$indexcontent = '<?php'."\n";
|
||||||
|
$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
|
||||||
|
$indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
|
||||||
|
$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once '".$relpath."/master.inc.php'; } // Load master if not already loaded\n";
|
||||||
|
$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
|
||||||
|
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||||
|
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
|
||||||
|
$indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
|
||||||
|
$indexcontent .= "}\n";
|
||||||
|
$indexcontent .= "include_once '".$relpath."/".basename($filetpl)."'\n"; // use .. instead of .
|
||||||
|
$indexcontent .= '// END PHP ?>'."\n";
|
||||||
|
$result = file_put_contents($fileindexsub, $indexcontent);
|
||||||
|
if ($result === false) {
|
||||||
|
dol_syslog("Failed to write file ".$fileindexsub, LOG_WARNING);
|
||||||
|
}
|
||||||
|
if (!empty($conf->global->MAIN_UMASK)) {
|
||||||
|
@chmod($fileindexsub, octdec($conf->global->MAIN_UMASK));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$result1 = true;
|
$result1 = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,6 @@ $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
|
|||||||
$tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
|
$tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
|
||||||
$filepath = (empty($filepath) ? '' : $filepath);
|
$filepath = (empty($filepath) ? '' : $filepath);
|
||||||
|
|
||||||
|
|
||||||
if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1 && $conf->browser->layout != 'phone') { ?>
|
if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1 && $conf->browser->layout != 'phone') { ?>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|||||||
@ -1185,6 +1185,7 @@ class Task extends CommonObjectLine
|
|||||||
dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG);
|
dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG);
|
||||||
|
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
|
$now = dol_now();
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (!is_object($user)) {
|
if (!is_object($user)) {
|
||||||
@ -1222,6 +1223,7 @@ class Task extends CommonObjectLine
|
|||||||
$sql .= ", task_duration";
|
$sql .= ", task_duration";
|
||||||
$sql .= ", fk_user";
|
$sql .= ", fk_user";
|
||||||
$sql .= ", note";
|
$sql .= ", note";
|
||||||
|
$sql .= ", datec";
|
||||||
$sql .= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
$sql .= ((int) $this->id);
|
$sql .= ((int) $this->id);
|
||||||
$sql .= ", '".$this->db->idate($this->timespent_date)."'";
|
$sql .= ", '".$this->db->idate($this->timespent_date)."'";
|
||||||
@ -1230,6 +1232,7 @@ class Task extends CommonObjectLine
|
|||||||
$sql .= ", ".((int) $this->timespent_duration);
|
$sql .= ", ".((int) $this->timespent_duration);
|
||||||
$sql .= ", ".((int) $this->timespent_fk_user);
|
$sql .= ", ".((int) $this->timespent_fk_user);
|
||||||
$sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null");
|
$sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null");
|
||||||
|
$sql .= ", '".$this->db->idate($now)."'";
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
@ -788,7 +788,7 @@ class Website extends CommonObject
|
|||||||
|
|
||||||
// Re-generates the index.php page to be the home page, and re-generates the wrapper.php
|
// Re-generates the index.php page to be the home page, and re-generates the wrapper.php
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
$result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper);
|
$result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper, $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,7 +1277,7 @@ class Website extends CommonObject
|
|||||||
|
|
||||||
// Regenerate index page to point to the new index page
|
// Regenerate index page to point to the new index page
|
||||||
$pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
|
$pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
|
||||||
dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php');
|
dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php', $object);
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
@ -1289,7 +1289,7 @@ class Website extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuild all files of a containers of a website. Rebuild also the wrapper.php file. TODO Add other files too.
|
* Rebuild all files of all the pages/containers of a website. Rebuild also the index and wrapper.php file.
|
||||||
* Note: Files are already regenerated during importWebSite so this function is useless when importing a website.
|
* Note: Files are already regenerated during importWebSite so this function is useless when importing a website.
|
||||||
*
|
*
|
||||||
* @return int <0 if KO, >=0 if OK
|
* @return int <0 if KO, >=0 if OK
|
||||||
@ -1341,12 +1341,12 @@ class Website extends CommonObject
|
|||||||
$aliasesarray[] = $objectpagestatic->pageurl;
|
$aliasesarray[] = $objectpagestatic->pageurl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regenerate all aliases pages (pages with a natural name)
|
// Regenerate also all aliases pages (pages with a natural name) by calling dolSavePageAlias()
|
||||||
if (is_array($aliasesarray)) {
|
if (is_array($aliasesarray)) {
|
||||||
foreach ($aliasesarray as $aliasshortcuttocreate) {
|
foreach ($aliasesarray as $aliasshortcuttocreate) {
|
||||||
if (trim($aliasshortcuttocreate)) {
|
if (trim($aliasshortcuttocreate)) {
|
||||||
$filealias = $conf->website->dir_output.'/'.$object->ref.'/'.trim($aliasshortcuttocreate).'.php';
|
$filealias = $conf->website->dir_output.'/'.$object->ref.'/'.trim($aliasshortcuttocreate).'.php';
|
||||||
$result = dolSavePageAlias($filealias, $object, $objectpagestatic);
|
$result = dolSavePageAlias($filealias, $object, $objectpagestatic); // This includes also a copy into sublanguage directories.
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->errors[] = 'Failed to write file '.basename($filealias);
|
$this->errors[] = 'Failed to write file '.basename($filealias);
|
||||||
$error++;
|
$error++;
|
||||||
@ -1359,10 +1359,15 @@ class Website extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
// Save wrapper.php
|
// Save index.php and wrapper.php
|
||||||
$pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
|
$pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
|
||||||
|
$fileindex = $pathofwebsite.'/index.php';
|
||||||
|
$filetpl = '';
|
||||||
|
if ($object->fk_default_home > 0) {
|
||||||
|
$filetpl = $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php';
|
||||||
|
}
|
||||||
$filewrapper = $pathofwebsite.'/wrapper.php';
|
$filewrapper = $pathofwebsite.'/wrapper.php';
|
||||||
dolSaveIndexPage($pathofwebsite, '', '', $filewrapper);
|
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object); // This includes also a version of index.php into sublanguage directories
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
|
|||||||
@ -1087,7 +1087,7 @@ if ($action == 'addcontainer' && $usercanedit) {
|
|||||||
$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php';
|
$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php';
|
||||||
|
|
||||||
// Generate the index.php page (to be the home page) and the wrapper.php file
|
// Generate the index.php page (to be the home page) and the wrapper.php file
|
||||||
$result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper);
|
$result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
|
||||||
|
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
setEventMessages('Failed to write file '.$fileindex, null, 'errors');
|
setEventMessages('Failed to write file '.$fileindex, null, 'errors');
|
||||||
@ -1666,7 +1666,7 @@ if ($action == 'updatecss' && $usercanedit) {
|
|||||||
|
|
||||||
|
|
||||||
// Save wrapper.php
|
// Save wrapper.php
|
||||||
$result = dolSaveIndexPage($pathofwebsite, '', '', $filewrapper);
|
$result = dolSaveIndexPage($pathofwebsite, '', '', $filewrapper, $object);
|
||||||
|
|
||||||
|
|
||||||
// Message if no error
|
// Message if no error
|
||||||
@ -1707,7 +1707,7 @@ if ($action == 'setashome' && $usercanedit) {
|
|||||||
$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php';
|
$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php';
|
||||||
|
|
||||||
// Generate the index.php page to be the home page
|
// Generate the index.php page to be the home page
|
||||||
$result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper);
|
$result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||||
@ -2227,7 +2227,7 @@ if ($action == 'regeneratesite' && $usercanedit) {
|
|||||||
$pathtomediasinwebsite = $pathofwebsite.'/medias';
|
$pathtomediasinwebsite = $pathofwebsite.'/medias';
|
||||||
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
|
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
|
||||||
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
|
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
|
||||||
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists
|
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists
|
||||||
$result = symlink($pathtomedias, $pathtomediasinwebsite);
|
$result = symlink($pathtomedias, $pathtomediasinwebsite);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user