mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
code syntax website directory
This commit is contained in:
parent
34ed5519fd
commit
256001ebd6
|
|
@ -244,7 +244,9 @@ class Website extends CommonObject
|
|||
if (is_array($tmplangarray)) {
|
||||
dol_mkdir($conf->website->dir_output.'/'.$this->ref);
|
||||
foreach ($tmplangarray as $val) {
|
||||
if (trim($val) == $this->lang) continue;
|
||||
if (trim($val) == $this->lang) {
|
||||
continue;
|
||||
}
|
||||
dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val));
|
||||
}
|
||||
}
|
||||
|
|
@ -540,7 +542,9 @@ class Website extends CommonObject
|
|||
if (is_array($tmplangarray)) {
|
||||
dol_mkdir($conf->website->dir_output.'/'.$this->ref);
|
||||
foreach ($tmplangarray as $val) {
|
||||
if (trim($val) == $this->lang) continue;
|
||||
if (trim($val) == $this->lang) {
|
||||
continue;
|
||||
}
|
||||
dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val));
|
||||
}
|
||||
}
|
||||
|
|
@ -603,8 +607,7 @@ class Website extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error && !empty($this->ref))
|
||||
{
|
||||
if (!$error && !empty($this->ref)) {
|
||||
$pathofwebsite = DOL_DATA_ROOT.'/website/'.$this->ref;
|
||||
|
||||
dol_delete_dir_recursive($pathofwebsite);
|
||||
|
|
@ -645,8 +648,7 @@ class Website extends CommonObject
|
|||
$object = new self($this->db);
|
||||
|
||||
// Check no site with ref exists
|
||||
if ($object->fetch(0, $newref) > 0)
|
||||
{
|
||||
if ($object->fetch(0, $newref) > 0) {
|
||||
$this->error = 'ErrorNewRefIsAlreadyUsed';
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -678,7 +680,9 @@ class Website extends CommonObject
|
|||
$object->fk_user_creat = $user->id;
|
||||
$object->position = ((int) $object->position) + 1;
|
||||
$object->status = self::STATUS_DRAFT;
|
||||
if (empty($object->lang)) $object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages
|
||||
if (empty($object->lang)) {
|
||||
$object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages
|
||||
}
|
||||
|
||||
// Create clone
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
|
|
@ -690,15 +694,13 @@ class Website extends CommonObject
|
|||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
dolCopyDir($pathofwebsiteold, $pathofwebsitenew, $conf->global->MAIN_UMASK, 0, null, 2);
|
||||
|
||||
// Check symlink to medias and restore it if ko
|
||||
$pathtomedias = DOL_DATA_ROOT.'/medias'; // Target
|
||||
$pathtomediasinwebsite = $pathofwebsitenew.'/medias'; // Source / Link name
|
||||
if (!is_link(dol_osencode($pathtomediasinwebsite)))
|
||||
{
|
||||
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
|
||||
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
|
||||
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists
|
||||
$result = symlink($pathtomedias, $pathtomediasinwebsite);
|
||||
|
|
@ -718,8 +720,7 @@ class Website extends CommonObject
|
|||
// Duplicate pages
|
||||
$objectpages = new WebsitePage($this->db);
|
||||
$listofpages = $objectpages->fetchAll($fromid);
|
||||
foreach ($listofpages as $pageid => $objectpageold)
|
||||
{
|
||||
foreach ($listofpages as $pageid => $objectpageold) {
|
||||
// Delete old file
|
||||
$filetplold = $pathofwebsitenew.'/page'.$pageid.'.tpl.php';
|
||||
dol_delete_file($filetplold);
|
||||
|
|
@ -728,43 +729,41 @@ class Website extends CommonObject
|
|||
$objectpagenew = $objectpageold->createFromClone($user, $pageid, $objectpageold->pageurl, '', 0, $object->id, 1);
|
||||
|
||||
//print $pageid.' = '.$objectpageold->pageurl.' -> '.$objectpagenew->id.' = '.$objectpagenew->pageurl.'<br>';
|
||||
if (is_object($objectpagenew) && $objectpagenew->pageurl)
|
||||
{
|
||||
if (is_object($objectpagenew) && $objectpagenew->pageurl) {
|
||||
$filealias = $pathofwebsitenew.'/'.$objectpagenew->pageurl.'.php';
|
||||
$filetplnew = $pathofwebsitenew.'/page'.$objectpagenew->id.'.tpl.php';
|
||||
|
||||
// Save page alias
|
||||
$result = dolSavePageAlias($filealias, $object, $objectpagenew);
|
||||
if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
if (!$result) {
|
||||
setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
}
|
||||
|
||||
$result = dolSavePageContent($filetplnew, $object, $objectpagenew);
|
||||
if (!$result) setEventMessages('Failed to write file '.$filetplnew, null, 'errors');
|
||||
if (!$result) {
|
||||
setEventMessages('Failed to write file '.$filetplnew, null, 'errors');
|
||||
}
|
||||
|
||||
if ($pageid == $oldidforhome)
|
||||
{
|
||||
if ($pageid == $oldidforhome) {
|
||||
$newidforhome = $objectpagenew->id;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setEventMessages($objectpageold->error, $objectpageold->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
// Restore id of home page
|
||||
$object->fk_default_home = $newidforhome;
|
||||
$res = $object->update($user);
|
||||
if (!($res > 0))
|
||||
{
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php';
|
||||
$filewrapper = $pathofwebsitenew.'/wrapper.php';
|
||||
|
||||
|
|
@ -821,10 +820,11 @@ class Website extends CommonObject
|
|||
|
||||
$linkstart = $linkend = '';
|
||||
|
||||
if ($withpicto)
|
||||
{
|
||||
if ($withpicto) {
|
||||
$result .= ($linkstart.img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result .= ' ';
|
||||
if ($withpicto != 2) {
|
||||
$result .= ' ';
|
||||
}
|
||||
}
|
||||
$result .= $linkstart.$this->ref.$linkend;
|
||||
return $result;
|
||||
|
|
@ -854,8 +854,7 @@ class Website extends CommonObject
|
|||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
|
||||
|
|
@ -865,7 +864,9 @@ class Website extends CommonObject
|
|||
}
|
||||
|
||||
$statusType = 'status5';
|
||||
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
|
||||
if ($status == self::STATUS_VALIDATED) {
|
||||
$statusType = 'status4';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
|
@ -909,16 +910,14 @@ class Website extends CommonObject
|
|||
|
||||
$website = $this;
|
||||
|
||||
if (empty($website->id) || empty($website->ref))
|
||||
{
|
||||
if (empty($website->id) || empty($website->ref)) {
|
||||
setEventMessages("Website id or ref is not defined", null, 'errors');
|
||||
return '';
|
||||
}
|
||||
|
||||
dol_syslog("Create temp dir ".$conf->website->dir_temp);
|
||||
dol_mkdir($conf->website->dir_temp);
|
||||
if (!is_writable($conf->website->dir_temp))
|
||||
{
|
||||
if (!is_writable($conf->website->dir_temp)) {
|
||||
setEventMessages("Temporary dir ".$conf->website->dir_temp." is not writable", null, 'errors');
|
||||
return '';
|
||||
}
|
||||
|
|
@ -928,8 +927,7 @@ class Website extends CommonObject
|
|||
dol_syslog("Clear temp dir ".$destdir);
|
||||
$count = 0; $countreallydeleted = 0;
|
||||
$counttodelete = dol_delete_dir_recursive($destdir, $count, 1, 0, $countreallydeleted);
|
||||
if ($counttodelete != $countreallydeleted)
|
||||
{
|
||||
if ($counttodelete != $countreallydeleted) {
|
||||
setEventMessages("Failed to clean temp directory ".$destdir, null, 'errors');
|
||||
return '';
|
||||
}
|
||||
|
|
@ -987,8 +985,7 @@ class Website extends CommonObject
|
|||
// Build sql file
|
||||
$filesql = $conf->website->dir_temp.'/'.$website->ref.'/website_pages.sql';
|
||||
$fp = fopen($filesql, "w");
|
||||
if (empty($fp))
|
||||
{
|
||||
if (empty($fp)) {
|
||||
setEventMessages("Failed to create file ".$filesql, null, 'errors');
|
||||
return '';
|
||||
}
|
||||
|
|
@ -998,20 +995,16 @@ class Website extends CommonObject
|
|||
|
||||
// Assign ->newid and ->newfk_page
|
||||
$i = 1;
|
||||
foreach ($listofpages as $pageid => $objectpageold)
|
||||
{
|
||||
foreach ($listofpages as $pageid => $objectpageold) {
|
||||
$objectpageold->newid = $i;
|
||||
$i++;
|
||||
}
|
||||
$i = 1;
|
||||
foreach ($listofpages as $pageid => $objectpageold)
|
||||
{
|
||||
foreach ($listofpages as $pageid => $objectpageold) {
|
||||
// Search newid
|
||||
$newfk_page = 0;
|
||||
foreach ($listofpages as $pageid2 => $objectpageold2)
|
||||
{
|
||||
if ($pageid2 == $objectpageold->fk_page)
|
||||
{
|
||||
foreach ($listofpages as $pageid2 => $objectpageold2) {
|
||||
if ($pageid2 == $objectpageold->fk_page) {
|
||||
$newfk_page = $objectpageold2->newid;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1019,8 +1012,7 @@ class Website extends CommonObject
|
|||
$objectpageold->newfk_page = $newfk_page;
|
||||
$i++;
|
||||
}
|
||||
foreach ($listofpages as $pageid => $objectpageold)
|
||||
{
|
||||
foreach ($listofpages as $pageid => $objectpageold) {
|
||||
$allaliases = $objectpageold->pageurl;
|
||||
$allaliases .= ($objectpageold->aliasalt ? ','.$objectpageold->aliasalt : '');
|
||||
|
||||
|
|
@ -1081,8 +1073,7 @@ class Website extends CommonObject
|
|||
|
||||
// Add line to update home page id during import
|
||||
//var_dump($this->fk_default_home.' - '.$objectpageold->id.' - '.$objectpageold->newid);exit;
|
||||
if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) // This is the record with home page
|
||||
{
|
||||
if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) { // This is the record with home page
|
||||
// Warning: We must keep llx_ here. It is a generic SQL.
|
||||
$line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;";
|
||||
$line .= "\n";
|
||||
|
|
@ -1091,8 +1082,9 @@ class Website extends CommonObject
|
|||
}
|
||||
|
||||
fclose($fp);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
if (!empty($conf->global->MAIN_UMASK)) {
|
||||
@chmod($filesql, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
// Build zip file
|
||||
$filedir = $conf->website->dir_temp.'/'.$website->ref.'/.';
|
||||
|
|
@ -1102,11 +1094,9 @@ class Website extends CommonObject
|
|||
dol_delete_file($fileglob, 0);
|
||||
$result = dol_compress_file($filedir, $filename, 'zip');
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
return $filename;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
global $errormsg;
|
||||
$this->error = $errormsg;
|
||||
return '';
|
||||
|
|
@ -1127,8 +1117,7 @@ class Website extends CommonObject
|
|||
$error = 0;
|
||||
|
||||
$object = $this;
|
||||
if (empty($object->ref))
|
||||
{
|
||||
if (empty($object->ref)) {
|
||||
$this->error = 'Function importWebSite called on object not loaded (object->ref is empty)';
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1137,16 +1126,14 @@ class Website extends CommonObject
|
|||
dol_mkdir($conf->website->dir_temp.'/'.$object->ref);
|
||||
|
||||
$filename = basename($pathtofile);
|
||||
if (!preg_match('/^website_(.*)-(.*)$/', $filename, $reg))
|
||||
{
|
||||
if (!preg_match('/^website_(.*)-(.*)$/', $filename, $reg)) {
|
||||
$this->errors[] = 'Bad format for filename '.$filename.'. Must be website_XXX-VERSION.';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$result = dol_uncompress($pathtofile, $conf->website->dir_temp.'/'.$object->ref);
|
||||
|
||||
if (!empty($result['error']))
|
||||
{
|
||||
if (!empty($result['error'])) {
|
||||
$this->errors[] = 'Failed to unzip file '.$pathtofile.'.';
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1172,8 +1159,7 @@ class Website extends CommonObject
|
|||
// Now generate the master.inc.php page
|
||||
$filemaster = $conf->website->dir_output.'/'.$object->ref.'/master.inc.php';
|
||||
$result = dolSaveMasterFile($filemaster);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
$this->errors[] = 'Failed to write file '.$filemaster;
|
||||
$error++;
|
||||
}
|
||||
|
|
@ -1190,16 +1176,14 @@ class Website extends CommonObject
|
|||
// Search the $maxrowid because we need it later
|
||||
$sqlgetrowid = 'SELECT MAX(rowid) as max from '.MAIN_DB_PREFIX.'website_page';
|
||||
$resql = $this->db->query($sqlgetrowid);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$maxrowid = $obj->max;
|
||||
}
|
||||
|
||||
// Load sql record
|
||||
$runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); // The maxrowid of table is searched into this function two
|
||||
if ($runsql <= 0)
|
||||
{
|
||||
if ($runsql <= 0) {
|
||||
$this->errors[] = 'Failed to load sql file '.$sqlfile;
|
||||
$error++;
|
||||
}
|
||||
|
|
@ -1208,16 +1192,13 @@ class Website extends CommonObject
|
|||
|
||||
// Make replacement of IDs
|
||||
$fp = fopen($sqlfile, "r");
|
||||
if ($fp)
|
||||
{
|
||||
while (!feof($fp))
|
||||
{
|
||||
if ($fp) {
|
||||
while (!feof($fp)) {
|
||||
$reg = array();
|
||||
|
||||
// Warning fgets with second parameter that is null or 0 hang.
|
||||
$buf = fgets($fp, 65000);
|
||||
if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg))
|
||||
{
|
||||
if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) {
|
||||
$oldid = $reg[1];
|
||||
$newid = ($reg[2] + $maxrowid);
|
||||
$aliasesarray = explode(',', $reg[3]);
|
||||
|
|
@ -1237,12 +1218,9 @@ class Website extends CommonObject
|
|||
}
|
||||
|
||||
// Regenerate alternative aliases pages
|
||||
if (is_array($aliasesarray))
|
||||
{
|
||||
foreach ($aliasesarray as $aliasshortcuttocreate)
|
||||
{
|
||||
if (trim($aliasshortcuttocreate))
|
||||
{
|
||||
if (is_array($aliasesarray)) {
|
||||
foreach ($aliasesarray as $aliasshortcuttocreate) {
|
||||
if (trim($aliasshortcuttocreate)) {
|
||||
$filealias = $conf->website->dir_output.'/'.$object->ref.'/'.trim($aliasshortcuttocreate).'.php';
|
||||
$result = dolSavePageAlias($filealias, $object, $objectpagestatic);
|
||||
if (!$result) {
|
||||
|
|
@ -1274,12 +1252,10 @@ class Website extends CommonObject
|
|||
$pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
|
||||
dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php');
|
||||
|
||||
if ($error)
|
||||
{
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
}
|
||||
|
|
@ -1298,8 +1274,7 @@ class Website extends CommonObject
|
|||
$error = 0;
|
||||
|
||||
$object = $this;
|
||||
if (empty($object->ref))
|
||||
{
|
||||
if (empty($object->ref)) {
|
||||
$this->error = 'Function rebuildWebSiteFiles called on object not loaded (object->ref is empty)';
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1386,7 +1361,9 @@ class Website extends CommonObject
|
|||
{
|
||||
global $websitepagefile, $website;
|
||||
|
||||
if (!is_object($weblangs)) return 'ERROR componentSelectLang called with parameter $weblangs not defined';
|
||||
if (!is_object($weblangs)) {
|
||||
return 'ERROR componentSelectLang called with parameter $weblangs not defined';
|
||||
}
|
||||
|
||||
$arrayofspecialmainlanguages = array(
|
||||
'en'=>'en_US',
|
||||
|
|
@ -1419,51 +1396,55 @@ class Website extends CommonObject
|
|||
$tmppage = new WebsitePage($this->db);
|
||||
|
||||
$pageid = 0;
|
||||
if (!empty($websitepagefile))
|
||||
{
|
||||
if (!empty($websitepagefile)) {
|
||||
$websitepagefileshort = basename($websitepagefile);
|
||||
if ($websitepagefileshort == 'index.php') $pageid = $website->fk_default_home;
|
||||
else $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), $websitepagefileshort);
|
||||
if ($pageid > 0)
|
||||
{
|
||||
if ($websitepagefileshort == 'index.php') {
|
||||
$pageid = $website->fk_default_home;
|
||||
} else {
|
||||
$pageid = str_replace(array('.tpl.php', 'page'), array('', ''), $websitepagefileshort);
|
||||
}
|
||||
if ($pageid > 0) {
|
||||
$tmppage->fetch($pageid);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill $languagecodes array with existing translation, nothing if none
|
||||
if (!is_array($languagecodes) && $pageid > 0)
|
||||
{
|
||||
if (!is_array($languagecodes) && $pageid > 0) {
|
||||
$languagecodes = array();
|
||||
|
||||
$sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp";
|
||||
$sql .= " WHERE wp.fk_website = ".$website->id;
|
||||
$sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid;
|
||||
if ($tmppage->fk_page > 0) $sql .= " OR wp.fk_page = ".$tmppage->fk_page." OR wp.rowid = ".$tmppage->fk_page;
|
||||
if ($tmppage->fk_page > 0) {
|
||||
$sql .= " OR wp.fk_page = ".$tmppage->fk_page." OR wp.rowid = ".$tmppage->fk_page;
|
||||
}
|
||||
$sql .= ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$newlang = $obj->lang;
|
||||
if ($obj->rowid == $pageid) $newlang = $obj->lang;
|
||||
if (!in_array($newlang, $languagecodes)) $languagecodes[] = $newlang;
|
||||
if ($obj->rowid == $pageid) {
|
||||
$newlang = $obj->lang;
|
||||
}
|
||||
if (!in_array($newlang, $languagecodes)) {
|
||||
$languagecodes[] = $newlang;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Now $languagecodes is always an array. Example array('en', 'fr', 'es');
|
||||
|
||||
$languagecodeselected = substr($weblangs->defaultlang, 0, 2); // Because we must init with a value, but real value is the lang of main parent container
|
||||
if (!empty($websitepagefile))
|
||||
{
|
||||
if (!empty($websitepagefile)) {
|
||||
$pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile));
|
||||
if ($pageid > 0)
|
||||
{
|
||||
if ($pageid > 0) {
|
||||
$pagelang = substr($tmppage->lang, 0, 2);
|
||||
$languagecodeselected = substr($pagelang, 0, 2);
|
||||
if (!in_array($pagelang, $languagecodes)) $languagecodes[] = $pagelang; // We add language code of page into combo list
|
||||
if (!in_array($pagelang, $languagecodes)) {
|
||||
$languagecodes[] = $pagelang; // We add language code of page into combo list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1474,7 +1455,9 @@ class Website extends CommonObject
|
|||
$url = preg_replace('/(\?|&)l=([a-zA-Z_]*)/', '', $url); // We remove param l from url
|
||||
//$url = preg_replace('/(\?|&)lang=([a-zA-Z_]*)/', '', $url); // We remove param lang from url
|
||||
$url .= (preg_match('/\?/', $url) ? '&' : '?').'l=';
|
||||
if (!preg_match('/^\//', $url)) $url = '/'.$url;
|
||||
if (!preg_match('/^\//', $url)) {
|
||||
$url = '/'.$url;
|
||||
}
|
||||
|
||||
$HEIGHTOPTION = 40;
|
||||
$MAXHEIGHT = 4 * $HEIGHTOPTION;
|
||||
|
|
@ -1504,8 +1487,7 @@ class Website extends CommonObject
|
|||
$out .= '</style>';
|
||||
$out .= '<ul class="componentSelectLang'.$htmlname.($morecss ? ' '.$morecss : '').'">';
|
||||
|
||||
if ($languagecodeselected)
|
||||
{
|
||||
if ($languagecodeselected) {
|
||||
// Convert $languagecodeselected into a long language code
|
||||
if (strlen($languagecodeselected) == 2) {
|
||||
$languagecodeselected = (empty($arrayofspecialmainlanguages[$languagecodeselected]) ? $languagecodeselected.'_'.strtoupper($languagecodeselected) : $arrayofspecialmainlanguages[$languagecodeselected]);
|
||||
|
|
@ -1513,28 +1495,34 @@ class Website extends CommonObject
|
|||
|
||||
$countrycode = strtolower(substr($languagecodeselected, -2));
|
||||
$label = $weblangs->trans("Language_".$languagecodeselected);
|
||||
if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
|
||||
if ($countrycode == 'us') {
|
||||
$label = preg_replace('/\s*\(.*\)/', '', $label);
|
||||
}
|
||||
$out .= '<a href="'.$url.substr($languagecodeselected, 0, 2).'"><li><img height="12px" src="/medias/image/common/flags/'.$countrycode.'.png" style="margin-right: 5px;"/><span class="websitecomponentlilang">'.$label.'</span>';
|
||||
$out .= '<span class="fa fa-caret-down" style="padding-left: 5px;" />';
|
||||
$out .= '</li></a>';
|
||||
}
|
||||
$i = 0;
|
||||
if (is_array($languagecodes))
|
||||
{
|
||||
foreach ($languagecodes as $languagecode)
|
||||
{
|
||||
if (is_array($languagecodes)) {
|
||||
foreach ($languagecodes as $languagecode) {
|
||||
// Convert $languagecode into a long language code
|
||||
if (strlen($languagecode) == 2) {
|
||||
$languagecode = (empty($arrayofspecialmainlanguages[$languagecode]) ? $languagecode.'_'.strtoupper($languagecode) : $arrayofspecialmainlanguages[$languagecode]);
|
||||
}
|
||||
|
||||
if ($languagecode == $languagecodeselected) continue; // Already output
|
||||
if ($languagecode == $languagecodeselected) {
|
||||
continue; // Already output
|
||||
}
|
||||
|
||||
$countrycode = strtolower(substr($languagecode, -2));
|
||||
$label = $weblangs->trans("Language_".$languagecode);
|
||||
if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
|
||||
if ($countrycode == 'us') {
|
||||
$label = preg_replace('/\s*\(.*\)/', '', $label);
|
||||
}
|
||||
$out .= '<a href="'.$url.substr($languagecode, 0, 2).'"><li><img height="12px" src="/medias/image/common/flags/'.$countrycode.'.png" style="margin-right: 5px;"/><span class="websitecomponentlilang">'.$label.'</span>';
|
||||
if (empty($i) && empty($languagecodeselected)) $out .= '<span class="fa fa-caret-down" style="padding-left: 5px;" />';
|
||||
if (empty($i) && empty($languagecodeselected)) {
|
||||
$out .= '<span class="fa fa-caret-down" style="padding-left: 5px;" />';
|
||||
}
|
||||
$out .= '</li></a>';
|
||||
$i++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@ class WebsitePage extends CommonObject
|
|||
*/
|
||||
public $author_alias;
|
||||
|
||||
/**
|
||||
* @var string path of external object
|
||||
*/
|
||||
/**
|
||||
* @var string path of external object
|
||||
*/
|
||||
public $object_type;
|
||||
|
||||
/**
|
||||
|
|
@ -229,7 +229,9 @@ class WebsitePage extends CommonObject
|
|||
{
|
||||
$this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1);
|
||||
$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
|
||||
if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,'
|
||||
if ($this->aliasalt) {
|
||||
$this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,'
|
||||
}
|
||||
|
||||
// Remove spaces and be sure we have main language only
|
||||
$this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
|
||||
|
|
@ -281,12 +283,12 @@ class WebsitePage extends CommonObject
|
|||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
|
||||
$sql .= ' WHERE 1 = 1';
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$sql .= ' AND t.rowid = '.$id;
|
||||
}
|
||||
else {
|
||||
if ($id < 0) $sql .= ' AND t.rowid <> '.abs($id);
|
||||
} else {
|
||||
if ($id < 0) {
|
||||
$sql .= ' AND t.rowid <> '.abs($id);
|
||||
}
|
||||
if (null !== $website_id) {
|
||||
$sql .= " AND t.fk_website = '".$this->db->escape($website_id)."'";
|
||||
if ($page) {
|
||||
|
|
@ -295,12 +297,18 @@ class WebsitePage extends CommonObject
|
|||
$tmppage = explode('/', $page);
|
||||
if (!empty($tmppage[1])) {
|
||||
$pagetouse = $tmppage[1];
|
||||
if (strlen($tmppage[0])) $langtouse = $tmppage[0];
|
||||
if (strlen($tmppage[0])) {
|
||||
$langtouse = $tmppage[0];
|
||||
}
|
||||
}
|
||||
$sql .= " AND t.pageurl = '".$this->db->escape($pagetouse)."'";
|
||||
if ($langtouse) $sql .= " AND t.lang = '".$this->db->escape($langtouse)."'";
|
||||
if ($langtouse) {
|
||||
$sql .= " AND t.lang = '".$this->db->escape($langtouse)."'";
|
||||
}
|
||||
}
|
||||
if ($aliasalt) {
|
||||
$sql .= " AND (t.aliasalt LIKE '%,".$this->db->escape($aliasalt).",%' OR t.aliasalt LIKE '%, ".$this->db->escape($aliasalt).",%')";
|
||||
}
|
||||
if ($aliasalt) $sql .= " AND (t.aliasalt LIKE '%,".$this->db->escape($aliasalt).",%' OR t.aliasalt LIKE '%, ".$this->db->escape($aliasalt).",%')";
|
||||
}
|
||||
}
|
||||
$sql .= $this->db->plimit(1);
|
||||
|
|
@ -419,7 +427,9 @@ class WebsitePage extends CommonObject
|
|||
$listoflang[] = "'".$this->db->escape(substr(str_replace("'", '', $tmpvalue), 0, 2))."'";
|
||||
}
|
||||
$stringtouse = $key." IN (".join(',', $listoflang).")";
|
||||
if ($foundnull) $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)';
|
||||
if ($foundnull) {
|
||||
$stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)';
|
||||
}
|
||||
$sqlwhere[] = $stringtouse;
|
||||
} else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
|
|
@ -441,8 +451,7 @@ class WebsitePage extends CommonObject
|
|||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$record = new self($this->db);
|
||||
|
||||
$record->id = $obj->rowid;
|
||||
|
|
@ -520,7 +529,9 @@ class WebsitePage extends CommonObject
|
|||
$listoflang[] = "'".$this->db->escape(substr(str_replace("'", '', $tmpvalue), 0, 2))."'";
|
||||
}
|
||||
$stringtouse = $key." IN (".join(',', $listoflang).")";
|
||||
if ($foundnull) $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)';
|
||||
if ($foundnull) {
|
||||
$stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)';
|
||||
}
|
||||
$sqlwhere[] = $stringtouse;
|
||||
} else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
|
|
@ -561,7 +572,9 @@ class WebsitePage extends CommonObject
|
|||
{
|
||||
$this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1);
|
||||
$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
|
||||
if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,'
|
||||
if ($this->aliasalt) {
|
||||
$this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,'
|
||||
}
|
||||
|
||||
// Remove spaces and be sure we have main language only
|
||||
$this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
|
||||
|
|
@ -595,8 +608,7 @@ class WebsitePage extends CommonObject
|
|||
|
||||
// Delete all child tables
|
||||
if (!$error) {
|
||||
foreach ($this->childtablesoncascade as $table)
|
||||
{
|
||||
foreach ($this->childtablesoncascade as $table) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$table;
|
||||
$sql .= " WHERE fk_website_page = ".(int) $this->id;
|
||||
|
||||
|
|
@ -611,19 +623,16 @@ class WebsitePage extends CommonObject
|
|||
|
||||
if (!$error) {
|
||||
$result = $this->deleteCommon($user, $trigger);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$websiteobj = new Website($this->db);
|
||||
$result = $websiteobj->fetch($this->fk_website);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
global $dolibarr_main_data_root;
|
||||
$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websiteobj->ref;
|
||||
|
||||
|
|
@ -696,10 +705,17 @@ class WebsitePage extends CommonObject
|
|||
$object->date_creation = $now;
|
||||
$object->title = ($newtitle == '1' ? $object->title : ($newtitle ? $newtitle : $object->title));
|
||||
$object->description = $object->title;
|
||||
if (!empty($newlang)) $object->lang = $newlang;
|
||||
if ($istranslation) $object->fk_page = $fromid;
|
||||
else $object->fk_page = 0;
|
||||
if (!empty($newwebsite)) $object->fk_website = $newwebsite;
|
||||
if (!empty($newlang)) {
|
||||
$object->lang = $newlang;
|
||||
}
|
||||
if ($istranslation) {
|
||||
$object->fk_page = $fromid;
|
||||
} else {
|
||||
$object->fk_page = 0;
|
||||
}
|
||||
if (!empty($newwebsite)) {
|
||||
$object->fk_website = $newwebsite;
|
||||
}
|
||||
$object->import_key = '';
|
||||
|
||||
// Create clone
|
||||
|
|
@ -755,17 +771,16 @@ class WebsitePage extends CommonObject
|
|||
$url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id;
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowMyObject");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
} else {
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart .= $linkclose.'>';
|
||||
|
|
@ -774,8 +789,12 @@ class WebsitePage extends CommonObject
|
|||
//$linkstart = $linkend = '';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_picto(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= $this->ref;
|
||||
if ($withpicto) {
|
||||
$result .= img_picto(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
|
|
@ -805,8 +824,7 @@ class WebsitePage extends CommonObject
|
|||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
|
||||
|
|
@ -816,7 +834,9 @@ class WebsitePage extends CommonObject
|
|||
}
|
||||
|
||||
$statusType = 'status5';
|
||||
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
|
||||
if ($status == self::STATUS_VALIDATED) {
|
||||
$statusType = 'status4';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
// BEGIN PHP File wrapper.php - DO NOT MODIFY - It is just a copy of file website/samples/wrapper.php
|
||||
$websitekey = basename(__DIR__);
|
||||
if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) die("Sample file for website module. Can be called directly.");
|
||||
if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded
|
||||
if (strpos($_SERVER["PHP_SELF"], 'website/samples/wrapper.php')) {
|
||||
die("Sample file for website module. Can be called directly.");
|
||||
}
|
||||
if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) {
|
||||
require_once './master.inc.php';
|
||||
} // Load master if not already loaded
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
|
||||
$encoding = '';
|
||||
|
|
@ -17,42 +21,36 @@ $limit = GETPOST('limit', 'int');
|
|||
|
||||
// Parameters for RSS
|
||||
$rss = GETPOST('rss', 'aZ09');
|
||||
if ($rss) $original_file = 'blog.rss';
|
||||
if ($rss) {
|
||||
$original_file = 'blog.rss';
|
||||
}
|
||||
|
||||
// If we have a hash public (hashp), we guess the original_file.
|
||||
if (!empty($hashp))
|
||||
{
|
||||
if (!empty($hashp)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile = new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', '', '', $hashp);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
|
||||
// filepath can be 'users/X' or 'X/propale/PR11111'
|
||||
if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part.
|
||||
{
|
||||
if (is_numeric($tmp[0])) { // If first tmp is numeric, it is subdir of company for multicompany, we take next part.
|
||||
$tmp = explode('/', $tmp[1], 2);
|
||||
}
|
||||
$moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path
|
||||
|
||||
if ($modulepart) // Not required, so often not defined, for link using public hashp parameter.
|
||||
{
|
||||
if ($moduleparttocheck == $modulepart)
|
||||
{
|
||||
if ($modulepart) { // Not required, so often not defined, for link using public hashp parameter.
|
||||
if ($moduleparttocheck == $modulepart) {
|
||||
// We remove first level of directory
|
||||
$original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir
|
||||
//var_dump($original_file); exit;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print 'Bad link. File is from another module part.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$modulepart = $moduleparttocheck;
|
||||
$original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print "ErrorFileNotFoundWithSharedLink";
|
||||
exit;
|
||||
}
|
||||
|
|
@ -60,21 +58,29 @@ if (!empty($hashp))
|
|||
|
||||
// Define attachment (attachment=true to force choice popup 'open'/'save as')
|
||||
$attachment = true;
|
||||
if (preg_match('/\.(html|htm)$/i', $original_file)) $attachment = false;
|
||||
if (isset($_GET["attachment"])) $attachment = (GETPOST("attachment", 'alphanohtml') ? true : false);
|
||||
if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) $attachment = false;
|
||||
if (preg_match('/\.(html|htm)$/i', $original_file)) {
|
||||
$attachment = false;
|
||||
}
|
||||
if (isset($_GET["attachment"])) {
|
||||
$attachment = (GETPOST("attachment", 'alphanohtml') ? true : false);
|
||||
}
|
||||
if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS_WEBSITE)) {
|
||||
$attachment = false;
|
||||
}
|
||||
|
||||
// Define mime type
|
||||
$type = 'application/octet-stream';
|
||||
if (GETPOSTISSET('type')) $type = GETPOST('type', 'alpha');
|
||||
else $type = dol_mimetype($original_file);
|
||||
if (GETPOSTISSET('type')) {
|
||||
$type = GETPOST('type', 'alpha');
|
||||
} else {
|
||||
$type = dol_mimetype($original_file);
|
||||
}
|
||||
|
||||
// Security: Delete string ../ into $original_file
|
||||
$original_file = str_replace("../", "/", $original_file);
|
||||
|
||||
// Cache or not
|
||||
if (GETPOST("cache", 'aZ09') || image_format_supported($original_file) >= 0)
|
||||
{
|
||||
if (GETPOST("cache", 'aZ09') || image_format_supported($original_file) >= 0) {
|
||||
// Important: Following code is to avoid page request by browser and PHP CPU at
|
||||
// each Dolibarr page access.
|
||||
header('Cache-Control: max-age=3600, public, must-revalidate');
|
||||
|
|
@ -99,7 +105,9 @@ if ($rss) {
|
|||
$website->fetch('', $websitekey);
|
||||
|
||||
$filters = array('type_container'=>'blogpost');
|
||||
if ($l) $filters['lang'] = $l;
|
||||
if ($l) {
|
||||
$filters['lang'] = $l;
|
||||
}
|
||||
|
||||
$MAXNEWS = ($limit ? $limit : 20);
|
||||
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters);
|
||||
|
|
@ -118,8 +126,7 @@ if ($rss) {
|
|||
dol_syslog("build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
|
||||
|
||||
// Clean parameters
|
||||
if (!$filename)
|
||||
{
|
||||
if (!$filename) {
|
||||
$extension = 'rss';
|
||||
$filename = $format.'.'.$extension;
|
||||
}
|
||||
|
|
@ -132,19 +139,16 @@ if ($rss) {
|
|||
|
||||
$buildfile = true;
|
||||
|
||||
if ($cachedelay)
|
||||
{
|
||||
if ($cachedelay) {
|
||||
$nowgmt = dol_now();
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay))
|
||||
{
|
||||
if (dol_filemtime($outputfile) > ($nowgmt - $cachedelay)) {
|
||||
dol_syslog("build_exportfile file ".$outputfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay."). Build is canceled");
|
||||
$buildfile = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($buildfile)
|
||||
{
|
||||
if ($buildfile) {
|
||||
$langs->load("other");
|
||||
$title = $desc = $langs->transnoentities('LatestBlogPosts');
|
||||
|
||||
|
|
@ -155,18 +159,17 @@ if ($rss) {
|
|||
// Write file
|
||||
$result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1;
|
||||
else {
|
||||
if ($result >= 0) {
|
||||
if (dol_move($outputfiletmp, $outputfile, 0, 1)) {
|
||||
$result = 1;
|
||||
} else {
|
||||
$error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile;
|
||||
dol_syslog("build_exportfile ".$error, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
print $error;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dol_syslog("build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR);
|
||||
dol_delete_file($outputfiletmp, 0, 1);
|
||||
$langs->load("errors");
|
||||
|
|
@ -175,56 +178,63 @@ if ($rss) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
$attachment = false;
|
||||
if (isset($_GET["attachment"])) $attachment = $_GET["attachment"];
|
||||
if (isset($_GET["attachment"])) {
|
||||
$attachment = $_GET["attachment"];
|
||||
}
|
||||
//$attachment = false;
|
||||
$contenttype = 'application/rss+xml';
|
||||
if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"];
|
||||
if (isset($_GET["contenttype"])) {
|
||||
$contenttype = $_GET["contenttype"];
|
||||
}
|
||||
//$contenttype='text/plain';
|
||||
$outputencoding = 'UTF-8';
|
||||
|
||||
if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
if ($contenttype) {
|
||||
header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
|
||||
}
|
||||
if ($attachment) {
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
//header('Cache-Control: Public, must-revalidate');
|
||||
//header('Pragma: public');
|
||||
if ($cachedelay) header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate');
|
||||
else header('Cache-Control: private, must-revalidate');
|
||||
if ($cachedelay) {
|
||||
header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate');
|
||||
} else {
|
||||
header('Cache-Control: private, must-revalidate');
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
$outputfile = $dir_temp.'/'.$filename;
|
||||
$result = readfile($outputfile);
|
||||
if (!$result) print 'File '.$outputfile.' was empty.';
|
||||
if (!$result) {
|
||||
print 'File '.$outputfile.' was empty.';
|
||||
}
|
||||
|
||||
// header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// Get logos
|
||||
elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file))
|
||||
{
|
||||
} elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file)) {
|
||||
// Get logos
|
||||
readfile(dol_osencode($conf->mycompany->dir_output."/".$original_file));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Find the subdirectory name as the reference
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname);
|
||||
$accessallowed = $check_access['accessallowed'];
|
||||
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
|
||||
$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name
|
||||
if ($hashp)
|
||||
{
|
||||
if ($hashp) {
|
||||
$accessallowed = 1; // When using hashp, link is public so we force $accessallowed
|
||||
$sqlprotectagainstexternals = '';
|
||||
}
|
||||
|
||||
// Security:
|
||||
// Limit access if permissions are wrong
|
||||
if (!$accessallowed)
|
||||
{
|
||||
if (!$accessallowed) {
|
||||
print 'Access forbidden';
|
||||
exit;
|
||||
}
|
||||
|
|
@ -238,8 +248,7 @@ else {
|
|||
$fullpath_original_file_osencoded = dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset
|
||||
|
||||
// This test if file exists should be useless. We keep it to find bug more easily
|
||||
if (!file_exists($fullpath_original_file_osencoded))
|
||||
{
|
||||
if (!file_exists($fullpath_original_file_osencoded)) {
|
||||
print "ErrorFileDoesNotExists: ".$original_file;
|
||||
exit;
|
||||
}
|
||||
|
|
@ -248,13 +257,20 @@ else {
|
|||
//top_httphead($type);
|
||||
header('Content-Type: '.$type);
|
||||
header('Content-Description: File Transfer');
|
||||
if ($encoding) header('Content-Encoding: '.$encoding);
|
||||
if ($encoding) {
|
||||
header('Content-Encoding: '.$encoding);
|
||||
}
|
||||
// Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open)
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
else header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
if ($attachment) {
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
} else {
|
||||
header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
}
|
||||
header('Content-Length: '.dol_filesize($fullpath_original_file));
|
||||
|
||||
readfile($fullpath_original_file_osencoded);
|
||||
}
|
||||
if (is_object($db)) $db->close();
|
||||
if (is_object($db)) {
|
||||
$db->close();
|
||||
}
|
||||
// END PHP
|
||||
|
|
|
|||
|
|
@ -53,12 +53,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
|
|||
// Initialize array of search criterias
|
||||
$search_all = GETPOST("search_all", 'alpha');
|
||||
$search = array();
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (GETPOST('search_'.$key, 'alpha')) {
|
||||
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
|
||||
if (empty($action) && empty($id) && empty($ref)) {
|
||||
$action = 'view';
|
||||
}
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->socid > 0) accessforbidden();
|
||||
|
|
@ -80,10 +83,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
|||
|
||||
$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');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
$error = 0;
|
||||
|
||||
$permissiontoadd = $user->rights->website->write;
|
||||
|
|
@ -130,8 +134,7 @@ jQuery(document).ready(function() {
|
|||
|
||||
|
||||
// Part to create
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount")));
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
|
@ -163,8 +166,7 @@ if ($action == 'create')
|
|||
}
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit')
|
||||
{
|
||||
if (($id || $ref) && $action == 'edit') {
|
||||
print load_fiche_titre($langs->trans("WebsiteAccount"));
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
|
@ -194,9 +196,10 @@ if (($id || $ref) && $action == 'edit')
|
|||
}
|
||||
|
||||
// Part to show record
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
|
||||
{
|
||||
if ($object->fk_soc > 0 && empty($socid)) $socid = $object->fk_soc;
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
|
||||
if ($object->fk_soc > 0 && empty($socid)) {
|
||||
$socid = $object->fk_soc;
|
||||
}
|
||||
|
||||
$res = $object->fetch_optionals();
|
||||
|
||||
|
|
@ -213,8 +216,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
// Call Hook formConfirm
|
||||
$parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
|
||||
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
|
||||
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
$formconfirm .= $hookmanager->resPrint;
|
||||
} elseif ($reshook > 0) {
|
||||
$formconfirm = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
// Print form confirm
|
||||
print $formconfirm;
|
||||
|
|
@ -223,8 +229,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '';
|
||||
if ($socid) $linkback = '<a href="'.DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToListForThirdParty").'</a>';
|
||||
if ($fk_website) $linkback = '<a href="'.DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
if ($socid) {
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToListForThirdParty").'</a>';
|
||||
}
|
||||
if ($fk_website) {
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
/*
|
||||
|
|
@ -236,41 +246,43 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->website->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
{
|
||||
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->website->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
{
|
||||
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
if ($socid > 0) $object->next_prev_filter = 'te.fk_soc = '.$socid;
|
||||
if ($socid > 0) {
|
||||
$object->next_prev_filter = 'te.fk_soc = '.$socid;
|
||||
}
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
|
||||
|
||||
|
|
@ -301,36 +313,35 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<div class="tabsAction">'."\n";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Send
|
||||
if (empty($user->socid)) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'."\n";
|
||||
}
|
||||
|
||||
if ($user->rights->website->write)
|
||||
{
|
||||
if ($user->rights->website->write) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
}
|
||||
|
||||
/*
|
||||
if ($user->rights->sellyoursaas->create)
|
||||
{
|
||||
if ($object->status == 1)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($user->rights->website->delete)
|
||||
if ($user->rights->sellyoursaas->create)
|
||||
{
|
||||
if ($object->status == 1)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($user->rights->website->delete) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -343,21 +354,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
$action = 'presend';
|
||||
}
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
if ($action != 'presend') {
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
/*
|
||||
$MAXEVENT = 10;
|
||||
$MAXEVENT = 10;
|
||||
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT);
|
||||
*/
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT);
|
||||
*/
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user