26include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
42 $this->numero = 10000;
46 $this->family =
"portal";
47 $this->module_position =
'50';
49 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
50 $this->
description =
"Enable to build and serve public web sites with CMS features";
52 $this->version =
'dolibarr';
54 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
56 $this->picto =
'website';
59 $this->dirs = array(
"/website/temp");
62 $this->config_page_url = array(
'website.php');
66 $this->depends = array(
'modFckeditor');
67 $this->requiredby = array();
68 $this->conflictwith = array();
69 $this->phpmin = array(7, 0);
70 $this->langfiles = array(
"website");
73 $this->
const = array();
79 $this->boxes = array();
82 $this->rights = array();
83 $this->rights_class =
'website';
86 $this->rights[$r][0] = 10001;
87 $this->rights[$r][1] =
'Read website content';
88 $this->rights[$r][3] = 0;
89 $this->rights[$r][4] =
'read';
92 $this->rights[$r][0] = 10002;
93 $this->rights[$r][1] =
'Create/modify website content (html and javascript content)';
94 $this->rights[$r][3] = 0;
95 $this->rights[$r][4] =
'write';
98 $this->rights[$r][0] = 10003;
99 $this->rights[$r][1] =
'Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.';
100 $this->rights[$r][3] = 0;
101 $this->rights[$r][4] =
'writephp';
104 $this->rights[$r][0] = 10005;
105 $this->rights[$r][1] =
'Delete website content';
106 $this->rights[$r][3] = 0;
107 $this->rights[$r][4] =
'delete';
110 $this->rights[$r][0] = 10008;
111 $this->rights[$r][1] =
'Export website content';
112 $this->rights[$r][3] = 0;
113 $this->rights[$r][4] =
'export';
118 $this->menu[$r] = array(
'fk_menu'=>
'0',
121 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth em092"'),
122 'mainmenu'=>
'website',
123 'url'=>
'/website/index.php',
126 'enabled'=>
'$conf->website->enabled',
127 'perms'=>
'$user->rights->website->read',
135 $this->export_code[$r] = $this->rights_class.
'_'.$r;
136 $this->export_label[$r] =
'MyWebsitePages';
137 $this->export_permission[$r] = array(array(
"website",
"export"));
138 $this->export_icon[$r] =
'globe';
139 $keyforclass =
'WebsitePage';
140 $keyforclassfile =
'/website/class/websitepage.class.php';
141 $keyforelement =
'Website';
142 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
145 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
146 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'website_page as t, '.MAIN_DB_PREFIX.
'website as p';
147 $this->export_sql_end[$r] .=
' WHERE t.fk_website = p.rowid';
148 $this->export_sql_end[$r] .=
' AND p.entity IN ('.getEntity(
'website').
')';
161 public function init($options =
'')
167 $result = $this->
_load_tables(
'/install/mysql/',
'website');
173 $this->
remove($options);
176 $dirarray = array(
'common/flags'=>
'flags',
'common/octicons/build/svg'=>
'octicons');
177 foreach ($dirarray as $dirfrom => $dirtarget) {
178 $src = DOL_DOCUMENT_ROOT.
'/theme/'.$dirfrom;
179 $dest = DOL_DATA_ROOT.
'/medias/image/'.$dirtarget;
182 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
186 $langs->load(
"errors");
187 $this->error = $langs->trans(
'ErrorFailToCopyDir', $src, $dest);
188 $this->errors[] = $langs->trans(
'ErrorFailToCopyDir', $src, $dest);
199 $srcroot = DOL_DOCUMENT_ROOT.
'/install/doctemplates/websites';
200 $destroot = DOL_DATA_ROOT.
'/doctemplates/websites';
205 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*(\.zip|\.jpg)$');
206 foreach ($docs as $cursorfile) {
207 $src = $srcroot.
'/'.$cursorfile[
'name'];
208 $dest = $destroot.
'/'.$cursorfile[
'name'];
210 $result =
dol_copy($src, $dest,
'0', 1);
212 $langs->load(
"errors");
213 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
214 $this->errors[] = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
220 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
221 foreach ($docs as $cursorfile) {
222 $src = $srcroot.
'/'.$cursorfile[
'name'];
223 $dest = $destroot.
'/'.$cursorfile[
'name'];
228 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
231 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
232 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
242 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.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null, $excludearchivefiles=0)
Copy a dir to another dir.
dol_dir_list($utf8_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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int 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.