From ab444ce73049adaf09625d0ab33b5f657e51d243 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 16 May 2017 03:02:00 +0200 Subject: [PATCH] Prepare for module collab/pad --- build/rpm/dolibarr_fedora.spec | 5 +- build/rpm/dolibarr_generic.spec | 11 +- build/rpm/dolibarr_mandriva.spec | 4 +- build/rpm/dolibarr_opensuse.spec | 5 +- htdocs/collab/index.php | 507 +++++++++++++++++++++++++++++++ 5 files changed, 521 insertions(+), 11 deletions(-) create mode 100644 htdocs/collab/index.php diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index fb818e285fb..a0f981b8c11 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -18,8 +18,8 @@ License: GPLv3+ #Packager: Laurent Destailleur (Eldy) Vendor: Dolibarr dev team -URL: http://www.dolibarr.org -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_redhat-fedora/%{name}-%{version}.tgz +URL: https://www.dolibarr.org +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_redhat-fedora/%{name}-%{version}.tgz Patch0: %{name}-forrpm.patch BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -165,6 +165,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories +%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/commande %_datadir/dolibarr/htdocs/compta diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 7b12a20eebb..446e0e0d5f7 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -26,17 +26,17 @@ License: GPL-3.0+ #Packager: Laurent Destailleur (Eldy) Vendor: Dolibarr dev team -URL: http://www.dolibarr.org +URL: https://www.dolibarr.org %if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version} -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_redhat-fedora/%{name}-%{version}.tgz +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_redhat-fedora/%{name}-%{version}.tgz %else %if 0%{?mdkversion} -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_mandriva/%{name}-%{version}.tgz +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_mandriva/%{name}-%{version}.tgz %else %if 0%{?suse_version} -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_opensuse/%{name}-%{version}.tgz +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_opensuse/%{name}-%{version}.tgz %else -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_generic/%{name}-%{version}.tgz +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_generic/%{name}-%{version}.tgz %endif %endif %endif @@ -245,6 +245,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories +%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/commande %_datadir/dolibarr/htdocs/compta diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index fd35227a242..1fb1b7fcc75 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -18,8 +18,8 @@ License: GPL-3.0+ #Packager: Laurent Destailleur (Eldy) Vendor: Dolibarr dev team -URL: http://www.dolibarr.org -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_mandriva/%{name}-%{version}.tgz +URL: https://www.dolibarr.org +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_mandriva/%{name}-%{version}.tgz Patch0: %{name}-forrpm.patch BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 02a5f8a1819..1bb7ef061e6 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -18,8 +18,8 @@ License: GPL-3.0+ #Packager: Laurent Destailleur (Eldy) Vendor: Dolibarr dev team -URL: http://www.dolibarr.org -Source0: http://www.dolibarr.org/files/lastbuild/package_rpm_opensuse/%{name}-%{version}.tgz +URL: https://www.dolibarr.org +Source0: https://www.dolibarr.org/files/lastbuild/package_rpm_opensuse/%{name}-%{version}.tgz Patch0: %{name}-forrpm.patch BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -173,6 +173,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/cashdesk %_datadir/dolibarr/htdocs/categories +%_datadir/dolibarr/htdocs/collab %_datadir/dolibarr/htdocs/comm %_datadir/dolibarr/htdocs/commande %_datadir/dolibarr/htdocs/compta diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php new file mode 100644 index 00000000000..0c892c4e776 --- /dev/null +++ b/htdocs/collab/index.php @@ -0,0 +1,507 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/collab/index.php + * \ingroup collab + * \brief Page to work on a shared document (PAD) + */ + +define('NOSCANPOSTFORINJECTION',1); +define('NOSTYLECHECK',1); + + +/** + * Show HTML header HTML + BODY + Top menu + left menu + DIV + * + * @param string $head Optionnal head lines + * @param string $title HTML title + * @param string $help_url Url links to help page + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * For other external page: http://server/url + * @param string $target Target to use on links + * @param int $disablejs More content into html header + * @param int $disablehead More content into html header + * @param array $arrayofjs Array of complementary js files + * @param array $arrayofcss Array of complementary css files + * @param string $morequerystring Query string to add to the link "print" to get same parameters (set this only if autodetect fails) + * @return void + */ +function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') +{ + global $conf; + + // html header + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + + print ''; + + // top menu and left menu area + if (empty($conf->dol_hide_topmenu)) + { + top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); + } + if (empty($conf->dol_hide_leftmenu)) + { + left_menu('', $help_url, '', '', 1, $title, 1); + } + + // main area + //main_area($title); + print ''."\n".'
'."\n"; +} + + + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + +$langs->load("admin"); +$langs->load("other"); +$langs->load("website"); + +if (! $user->admin) accessforbidden(); + +if (! ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) +{ + $conf->dol_hide_leftmenu = 1; // Force hide of left menu. +} + +$error=0; +$website=GETPOST('website', 'alpha'); +$page=GETPOST('page', 'alpha'); +$pageid=GETPOST('pageid', 'int'); +$action=GETPOST('action','alpha'); + +if (GETPOST('delete')) { $action='delete'; } +if (GETPOST('preview')) $action='preview'; +if (GETPOST('create')) { $action='create'; } +if (GETPOST('editmedia')) { $action='editmedia'; } +if (GETPOST('editcss')) { $action='editcss'; } +if (GETPOST('editmenu')) { $action='editmenu'; } +if (GETPOST('setashome')) { $action='setashome'; } +if (GETPOST('editmeta')) { $action='editmeta'; } +if (GETPOST('editcontent')) { $action='editcontent'; } + +if (empty($action)) $action='preview'; + + + + +/* + * Actions + */ + +if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. +if (GETPOST('refreshpage')) $action='preview'; + + +// Add a collab page +if ($action == 'add') +{ + $db->begin(); + + $objectpage->title = GETPOST('WEBSITE_TITLE'); + $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); + $objectpage->keywords = GETPOST('WEBSITE_KEYWORD'); + + if (empty($objectpage->title)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); + $error++; + } + + if (! $error) + { + $res = $objectpage->create($user); + if ($res <= 0) + { + $error++; + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + } + } + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); + $action=''; + } + else + { + $db->rollback(); + } + + $action = 'preview'; + $id = $objectpage->id; +} + +// Update page +if ($action == 'delete') +{ + $db->begin(); + + $res = $object->fetch(0, $website); + + $res = $objectpage->fetch($pageid, $object->fk_website); + + if ($res > 0) + { + $res = $objectpage->delete($user); + if (! $res > 0) + { + $error++; + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); + + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); + exit; + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + } +} + + + +/* + * View + */ + +$form = new Form($db); + +$help_url=''; + +llxHeader('', $langs->trans("WebsiteSetup"), $help_url); + +print "\n".'
'; +print ''; +if ($action == 'create') +{ + print ''; +} + + +// Add a margin under toolbar ? +$style=''; +if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; + +//var_dump($objectpage);exit; +print '
'; + +if (count($object->records) > 0) +{ + // ***** Part for web sites + + print '
'; + print $langs->trans("Website").': '; + print '
'; + + // List of websites + print '
'; + $out=''; + $out.=''; + $out.=ajax_combobox('website'); + print $out; + print ''; + + if ($website) + { + $virtualurl=''; + $dataroot=DOL_DATA_ROOT.'/websites/'.$website; + if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; + } + + if ($website && $action == 'preview') + { + $disabled=''; + if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; + + print '   '; + + //print ''; + print ''; + print ''; + print ''; + } + + print '
'; + + // Button for websites + print '
'; + + if ($action == 'preview') + { + print '
'; + print ''; + //print ''; + $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); + print $form->textwithpicto('', $htmltext); + print '
'; + + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/websites/index.php?website='.$website; + //if (! empty($object->virtualhost)) + //{ + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + //} + + print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); + print ''; + } + + if (in_array($action, array('editcss','editmenu','create'))) + { + if ($action != 'preview') print ''; + if (preg_match('/^create/',$action)) print ''; + if (preg_match('/^edit/',$action)) print ''; + } + + print '
'; + + + // ***** Part for pages + + if ($website) + { + print '
'; + + $array=$objectpage->fetchAll($object->id); + if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + $atleastonepage=(is_array($array) && count($array) > 0); + + print '
'; + print '
'; + print $langs->trans("Page").': '; + print '
'; + print '
'; + + if ($action != 'add') + { + $out=''; + $out.=''; + $out.=ajax_combobox('pageid'); + print $out; + } + else + { + print $langs->trans("New"); + } + + print ''; + //print $form->selectarray('page', $array); + + if ($action == 'preview') + { + $disabled=''; + if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; + + if ($pageid > 0) + { + print '   '; + + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; + else print ''; + print ''; + print ''; + //print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; + //print ''.dol_escape_htmltag($langs->trans("EditPageContent")).''; + print ''; + } + } + + print '
'; + print '
'; + print '
'; + + print '
'; + + if ($website && $pageid > 0 && $action == 'preview') + { + $websitepage = new WebSitePage($db); + $websitepage->fetch($pageid); + + $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; + $pagealias = $websitepage->pageurl; + + print '
'; + print ''; + //print ''; + $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); + print $form->textwithpicto('', $htmltext); + print '
'; + + if (! empty($object->virtualhost)) + { + $urlext=$virtualurl.'/'.$pagealias.'.php'; + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } + else + { + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); + print ''; + } + + print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); + print ''; // View page in new Tab + //print ''; + + // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext + } + if (! in_array($action, array('editcss','editmenu','create'))) + { + if ($action != 'preview') print ''; + if (preg_match('/^create/',$action)) print ''; + if (preg_match('/^edit/',$action)) print ''; + } + + print '
'; + + if ($action == 'preview') + { + // Adding jquery code to change on the fly url of preview ext + if (! empty($conf->use_javascript_ajax)) + { + print ''; + } + } + } +} +else +{ + print '
'; + $langs->load("errors"); + print $langs->trans("ErrorModuleSetupNotComplete"); + print '
'; + $action=''; +} + + +print '
'; + +$head = array(); + +if ($action == 'editcontent') +{ + /* + * Editing global variables not related to a specific theme + */ + + $csscontent = @file_get_contents($filecss); + + $contentforedit = ''; + /*$contentforedit.=''."\n";*/ + $contentforedit .= $objectpage->content; + + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); + $doleditor->Create(0, '', false); +} + +print "
\n\n"; + + + + +llxFooter(); + +$db->close();