25include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
43 $this->numero = 10000;
47 $this->family =
"portal";
48 $this->module_position =
'50';
50 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
51 $this->
description =
"Enable to build and serve public web sites with CMS features";
53 $this->version =
'dolibarr';
55 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
57 $this->picto =
'website';
60 $this->dirs = array(
"/website/temp");
63 $this->config_page_url = array(
'website.php');
67 $this->depends = array(
'modFckeditor');
68 $this->requiredby = array();
69 $this->conflictwith = array();
70 $this->phpmin = array(7, 0);
71 $this->langfiles = array(
"website");
74 $this->
const = array();
80 $this->boxes = array();
83 $this->rights = array();
84 $this->rights_class =
'website';
87 $this->rights[$r][0] = 10001;
88 $this->rights[$r][1] =
'Read website content';
89 $this->rights[$r][3] = 0;
90 $this->rights[$r][4] =
'read';
93 $this->rights[$r][0] = 10002;
94 $this->rights[$r][1] =
'Create/modify website content (html and javascript content)';
95 $this->rights[$r][3] = 0;
96 $this->rights[$r][4] =
'write';
99 $this->rights[$r][0] = 10003;
100 $this->rights[$r][1] =
'Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.';
101 $this->rights[$r][3] = 0;
102 $this->rights[$r][4] =
'writephp';
105 $this->rights[$r][0] = 10005;
106 $this->rights[$r][1] =
'Delete website content';
107 $this->rights[$r][3] = 0;
108 $this->rights[$r][4] =
'delete';
111 $this->rights[$r][0] = 10008;
112 $this->rights[$r][1] =
'Export website content';
113 $this->rights[$r][3] = 0;
114 $this->rights[$r][4] =
'export';
119 $this->menu[$r] = array(
'fk_menu'=>
'0',
122 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth em092"'),
123 'mainmenu'=>
'website',
124 'url'=>
'/website/index.php',
127 'enabled'=>
'$conf->website->enabled',
128 'perms'=>
'$user->rights->website->read',
136 $this->export_code[$r] = $this->rights_class.
'_'.$r;
137 $this->export_label[$r] =
'MyWebsitePages';
138 $this->export_permission[$r] = array(array(
"website",
"export"));
139 $this->export_icon[$r] =
'globe';
140 $keyforclass =
'WebsitePage';
141 $keyforclassfile =
'/website/class/websitepage.class.php';
142 $keyforelement =
'Website';
143 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
146 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
147 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'website_page as t, '.MAIN_DB_PREFIX.
'website as p';
148 $this->export_sql_end[$r] .=
' WHERE t.fk_website = p.rowid';
149 $this->export_sql_end[$r] .=
' AND p.entity IN ('.getEntity(
'website').
')';
162 public function init($options =
'')
164 global $conf, $langs;
168 $result = $this->
_load_tables(
'/install/mysql/',
'website');
174 $this->
remove($options);
177 $dirarray = array(
'common/flags'=>
'flags',
'common/octicons/build/svg'=>
'octicons');
178 foreach ($dirarray as $dirfrom => $dirtarget) {
179 $src = DOL_DOCUMENT_ROOT.
'/theme/'.$dirfrom;
180 $dest = DOL_DATA_ROOT.
'/medias/image/'.$dirtarget;
183 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
187 $langs->load(
"errors");
188 $this->error = $langs->trans(
'ErrorFailToCopyDir', $src, $dest);
189 $this->errors[] = $langs->trans(
'ErrorFailToCopyDir', $src, $dest);
200 $srcroot = DOL_DOCUMENT_ROOT.
'/install/doctemplates/websites';
201 $destroot = DOL_DATA_ROOT.
'/doctemplates/websites';
206 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*(\.zip|\.jpg)$');
207 foreach ($docs as $cursorfile) {
208 $src = $srcroot.
'/'.$cursorfile[
'name'];
209 $dest = $destroot.
'/'.$cursorfile[
'name'];
211 $result =
dol_copy($src, $dest, 0, 1);
213 $langs->load(
"errors");
214 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
215 $this->errors[] = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
221 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
223 foreach ($docs as $cursorfile) {
224 $src = $srcroot.
'/'.$cursorfile[
'name'];
225 $dest = $destroot.
'/'.$cursorfile[
'name'];
230 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
233 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
234 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
244 return $this->
_init($sql, $options);
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to describe Websites module.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null)
Copy a dir to another dir.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.