├── img ├── distributionlist.png └── object_distributionlist.png ├── .gitignore ├── .editorconfig ├── .gitattributes ├── sql ├── llx_distributionlist_distributionlist_extrafields.key.sql ├── llx_distributionlist_distributionlistsocpeople_extrafields.key.sql ├── llx_distributionlist_distributionlistsocpeoplefilter_extrafields.key.sql ├── llx_distributionlist_distributionlistsocpeoplefilter.sql ├── llx_distributionlist_distributionlist_extrafields.sql ├── llx_distributionlist_distributionlistsocpeople_extrafields.sql ├── llx_distributionlist_distributionlistsocpeoplefilter_extrafields.sql ├── llx_distributionlist_distributionlistsocpeople.sql ├── llx_distributionlist_distributionlistsocpeoplefilter.key.sql ├── llx_distributionlist_distributionlist.sql ├── llx_distributionlist_distributionlist.key.sql └── llx_distributionlist_distributionlistsocpeople.key.sql ├── class ├── tools_distributionlist.class.php └── actions_distributionlist.class.php ├── backport └── v19 │ └── core │ └── class │ └── commonhookactions.class.php ├── langs ├── en_US │ └── distributionlist.lang └── fr_FR │ └── distributionlist.lang ├── lib ├── distributionlist.lib.php ├── distributionlist_distributionlistsocpeople.lib.php └── distributionlist_distributionlist.lib.php ├── ChangeLog.md ├── README.md ├── admin ├── about.php ├── myobject_extrafields.php └── setup.php ├── core ├── modules │ ├── distributionlist │ │ ├── modules_distributionlist.php │ │ ├── mod_distributionlist_standard.php │ │ └── mod_distributionlist_advanced.php │ ├── mailings │ │ └── distributionlist.modules.php │ └── modDistributionList.class.php └── triggers │ └── interface_99_moddistributionlist_distributionlisttrigger.class.php ├── distributionlist_note.php ├── test └── phpunit │ └── DistributionListFunctionalTest.php ├── distributionlistindex.php ├── distributionlist_document.php ├── distributionlist_agenda.php └── distributionlist_contact.php /img/distributionlist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_distributionlist/main/img/distributionlist.png -------------------------------------------------------------------------------- /img/object_distributionlist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ATM-Consulting/dolibarr_module_distributionlist/main/img/object_distributionlist.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated binaries 2 | /build/*.zip 3 | # Doxygen generated documentation 4 | /build/doxygen/doxygen_warnings.log 5 | /doc/code/doxygen 6 | # Composer managed dependencies 7 | /vendor 8 | /dev/bin 9 | # PHPdocumentor generated files 10 | /build/phpdoc 11 | /doc/code/phpdoc 12 | # Sphinx generated files 13 | /doc/user/build 14 | /.settings/ 15 | /.buildpath 16 | /.project 17 | # Other 18 | *.back -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | charset = utf-8 9 | end_of_line = lf 10 | insert_final_newline = true 11 | 12 | [*.php] 13 | indent_style = tab 14 | indent_size = 4 15 | trim_trailing_whitespace = true 16 | insert_final_newline = true 17 | [*.js] 18 | indent_style = tab 19 | [*.css] 20 | indent_style = tab 21 | [*.xml] 22 | indent_style = tab 23 | [*.md] 24 | trim_trailing_whitespace = false 25 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | 4 | 5 | # Explicitly declare text files we want to always be normalized and converted 6 | # to native line endings on checkout. 7 | *.php text eol=lf 8 | *.sql text eol=lf 9 | *.htm text eol=lf 10 | *.html text eol=lf 11 | *.js text eol=lf 12 | *.css text eol=lf 13 | *.lang text eol=lf 14 | *.txt text eol=lf 15 | *.md text eol=lf 16 | *.bat text eol=lf 17 | 18 | # Denote all files that are truly binary and should not be modified. 19 | *.ico binary 20 | *.png binary 21 | *.jpg binary 22 | *.odt binary 23 | *.odf binary 24 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlist_extrafields.key.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | -- BEGIN MODULEBUILDER INDEXES 18 | ALTER TABLE llx_distributionlist_distributionlist_extrafields ADD INDEX idx_fk_object(fk_object); 19 | -- END MODULEBUILDER INDEXES 20 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeople_extrafields.key.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | -- BEGIN MODULEBUILDER INDEXES 18 | ALTER TABLE llx_distributionlist_distributionlistsocpeople_extrafields ADD INDEX idx_fk_object(fk_object); 19 | -- END MODULEBUILDER INDEXES 20 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeoplefilter_extrafields.key.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | -- BEGIN MODULEBUILDER INDEXES 18 | ALTER TABLE llx_distributionlist_distributionlistsocpeoplefilter_extrafields ADD INDEX idx_fk_object(fk_object); 19 | -- END MODULEBUILDER INDEXES 20 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeoplefilter.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software: you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation, either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | CREATE TABLE llx_distributionlist_distributionlistsocpeoplefilter( 18 | -- BEGIN MODULEBUILDER FIELDS 19 | rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, 20 | label varchar(255), 21 | date_creation datetime NOT NULL, 22 | url_params text NOT NULL 23 | -- END MODULEBUILDER FIELDS 24 | ) ENGINE=innodb; 25 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlist_extrafields.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | create table llx_distributionlist_distributionlist_extrafields 17 | ( 18 | rowid integer AUTO_INCREMENT PRIMARY KEY, 19 | tms timestamp, 20 | fk_object integer NOT NULL, 21 | import_key varchar(14) -- import key 22 | ) ENGINE=innodb; 23 | 24 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeople_extrafields.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | create table llx_distributionlist_distributionlistsocpeople_extrafields 17 | ( 18 | rowid integer AUTO_INCREMENT PRIMARY KEY, 19 | tms timestamp, 20 | fk_object integer NOT NULL, 21 | import_key varchar(14) -- import key 22 | ) ENGINE=innodb; 23 | 24 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeoplefilter_extrafields.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | create table llx_distributionlist_distributionlistsocpeoplefilter_extrafields 17 | ( 18 | rowid integer AUTO_INCREMENT PRIMARY KEY, 19 | tms timestamp, 20 | fk_object integer NOT NULL, 21 | import_key varchar(14) -- import key 22 | ) ENGINE=innodb; 23 | 24 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeople.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software: you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation, either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | CREATE TABLE llx_distributionlist_distributionlistsocpeople( 18 | -- BEGIN MODULEBUILDER FIELDS 19 | rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, 20 | fk_socpeople integer, 21 | fk_distributionlist integer, 22 | date_creation datetime NOT NULL, 23 | fk_user_creat integer NOT NULL, 24 | import_key varchar(14) 25 | -- END MODULEBUILDER FIELDS 26 | ) ENGINE=innodb; 27 | -------------------------------------------------------------------------------- /class/tools_distributionlist.class.php: -------------------------------------------------------------------------------- 1 | escape($label) . "'"; 18 | 19 | $resql = $db->query($sql); 20 | 21 | if($resql){ 22 | if($db->num_rows($resql) > 0){ 23 | $obj = $db->fetch_object($resql); 24 | return $obj->id; 25 | } else { 26 | return 0; 27 | } 28 | 29 | } else { 30 | return -1; 31 | } 32 | } 33 | 34 | /** 35 | * Fonction qui permet de vérifier si un filtre de contacts avec ce label existe déjà 36 | * 37 | * @param string $label 38 | * @return int -1 if KO, 0 if not exist, positiv int id if exist 39 | */ 40 | static function distributionlistsocpeoplefilter_alreadyexist($label) 41 | { 42 | global $db; 43 | 44 | $sql = "SELECT rowid as id FROM " . MAIN_DB_PREFIX . "distributionlist_distributionlistsocpeoplefilter"; 45 | $sql .= " WHERE label = '" . $label . "'"; 46 | 47 | $resql = $db->query($sql); 48 | 49 | if($resql){ 50 | if($db->num_rows($resql) > 0){ 51 | $obj = $db->fetch_object($resql); 52 | return $obj->id; 53 | } else { 54 | return 0; 55 | } 56 | 57 | } else { 58 | return -1; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeoplefilter.key.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software: you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation, either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | -- BEGIN MODULEBUILDER INDEXES 18 | ALTER TABLE llx_distributionlist_distributionlistsocpeoplefilter ADD INDEX idx_distributionlist_distributionlistsocpeoplefilter_rowid (rowid); 19 | ALTER TABLE llx_distributionlist_distributionlistsocpeoplefilter ADD INDEX idx_distributionlist_distributionlistsocpeoplefilter_fk_distributionlist (fk_distributionlist); 20 | -- END MODULEBUILDER INDEXES 21 | 22 | --ALTER TABLE llx_distributionlist_distributionlistsocpeoplefilter ADD UNIQUE INDEX uk_distributionlist_distributionlistsocpeoplefilter_fieldxy(fieldx, fieldy); 23 | 24 | --ALTER TABLE llx_distributionlist_distributionlistsocpeoplefilter ADD CONSTRAINT llx_distributionlist_distributionlistsocpeoplefilter_fk_field FOREIGN KEY (fk_field) REFERENCES llx_distributionlist_myotherobject(rowid); 25 | 26 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlist.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software: you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation, either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | CREATE TABLE llx_distributionlist_distributionlist( 18 | -- BEGIN MODULEBUILDER FIELDS 19 | rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, 20 | ref varchar(128) DEFAULT '(PROV)' NOT NULL, 21 | entity integer DEFAULT 1 NOT NULL, -- multi company id 22 | label varchar(255), 23 | description text, 24 | note_public text, 25 | note_private text, 26 | date_creation datetime NOT NULL, 27 | date_valid datetime, 28 | tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 29 | fk_user_creat integer NOT NULL, 30 | fk_user_modif integer, 31 | fk_user_cloture integer, 32 | fk_user_valid integer, 33 | nb_contacts integer NOT NULL DEFAULT 0, 34 | import_key varchar(14), 35 | status smallint NOT NULL, 36 | date_cloture date 37 | -- END MODULEBUILDER FIELDS 38 | ) ENGINE=innodb; 39 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlist.key.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software: you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation, either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | -- BEGIN MODULEBUILDER INDEXES 18 | ALTER TABLE llx_distributionlist_distributionlist ADD INDEX idx_distributionlist_distributionlist_rowid (rowid); 19 | ALTER TABLE llx_distributionlist_distributionlist ADD INDEX idx_distributionlist_distributionlist_ref (ref); 20 | ALTER TABLE llx_distributionlist_distributionlist ADD CONSTRAINT llx_distributionlist_distributionlist_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); 21 | ALTER TABLE llx_distributionlist_distributionlist ADD INDEX idx_distributionlist_distributionlist_status (status); 22 | -- END MODULEBUILDER INDEXES 23 | 24 | --ALTER TABLE llx_distributionlist_distributionlist ADD UNIQUE INDEX uk_distributionlist_distributionlist_fieldxy(fieldx, fieldy); 25 | 26 | --ALTER TABLE llx_distributionlist_distributionlist ADD CONSTRAINT llx_distributionlist_distributionlist_fk_field FOREIGN KEY (fk_field) REFERENCES llx_distributionlist_myotherobject(rowid); 27 | 28 | -------------------------------------------------------------------------------- /backport/v19/core/class/commonhookactions.class.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | /** 22 | * \file htdocs/core/class/commonhookactions.class.php 23 | * \ingroup core 24 | * \brief File of parent class of all other hook actions classes 25 | */ 26 | 27 | 28 | if (file_exists(DOL_DOCUMENT_ROOT . '/core/class/commonhookactions.class.php')){ 29 | 30 | require_once DOL_DOCUMENT_ROOT . '/core/class/commonhookactions.class.php'; 31 | /** 32 | * Parent class of all other hook actions classes 33 | */ 34 | abstract class RetroCompatCommonHookActions extends \CommonHookActions 35 | { 36 | 37 | } 38 | }else{ 39 | /** 40 | * Parent class of all other hook actions classes 41 | */ 42 | abstract class RetroCompatCommonHookActions 43 | { 44 | /** 45 | * @var string String of results. 46 | */ 47 | public $resprints; 48 | 49 | /** 50 | * @var array Array of results. 51 | */ 52 | public $results = array(); 53 | } 54 | 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /sql/llx_distributionlist_distributionlistsocpeople.key.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (C) ---Put here your own copyright and developer email--- 2 | -- 3 | -- This program is free software: you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation, either version 3 of the License, or 6 | -- (at your option) any later version. 7 | -- 8 | -- This program is distributed in the hope that it will be useful, 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | -- GNU General Public License for more details. 12 | -- 13 | -- You should have received a copy of the GNU General Public License 14 | -- along with this program. If not, see https://www.gnu.org/licenses/. 15 | 16 | 17 | -- BEGIN MODULEBUILDER INDEXES 18 | ALTER TABLE llx_distributionlist_distributionlistsocpeople ADD INDEX idx_distributionlist_distributionlistsocpeople_rowid (rowid); 19 | ALTER TABLE llx_distributionlist_distributionlistsocpeople ADD INDEX idx_distributionlist_distributionlistsocpeople_fk_socpeople (fk_socpeople); 20 | ALTER TABLE llx_distributionlist_distributionlistsocpeople ADD INDEX idx_distributionlist_distributionlistsocpeople_fk_distributionlist (fk_distributionlist); 21 | ALTER TABLE llx_distributionlist_distributionlistsocpeople ADD CONSTRAINT llx_distributionlist_distributionlistsocpeople_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); 22 | -- END MODULEBUILDER INDEXES 23 | 24 | --ALTER TABLE llx_distributionlist_distributionlistsocpeople ADD UNIQUE INDEX uk_distributionlist_distributionlistsocpeople_fieldxy(fieldx, fieldy); 25 | 26 | --ALTER TABLE llx_distributionlist_distributionlistsocpeople ADD CONSTRAINT llx_distributionlist_distributionlistsocpeople_fk_field FOREIGN KEY (fk_field) REFERENCES llx_distributionlist_myotherobject(rowid); 27 | 28 | -------------------------------------------------------------------------------- /langs/en_US/distributionlist.lang: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 SuperAdmin 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | # 17 | # Generic 18 | # 19 | 20 | # Module label 'ModuleDistributionListName' 21 | ModuleDistributionListName = DistributionList 22 | # Module description 'ModuleDistributionListDesc' 23 | ModuleDistributionListDesc = DistributionList description 24 | 25 | # 26 | # Admin page 27 | # 28 | DistributionListSetup = DistributionList setup 29 | Settings = Settings 30 | DistributionListSetupPage = DistributionList setup page 31 | DISTRIBUTIONLIST_MYPARAM1 = My param 1 32 | DISTRIBUTIONLIST_MYPARAM1Tooltip = My param 1 tooltip 33 | DISTRIBUTIONLIST_MYPARAM2=My param 2 34 | DISTRIBUTIONLIST_MYPARAM2Tooltip=My param 2 tooltip 35 | 36 | 37 | # 38 | # About page 39 | # 40 | About = About 41 | DistributionListAbout = About DistributionList 42 | DistributionListAboutPage = DistributionList about page 43 | 44 | # 45 | # Sample page 46 | # 47 | MyPageName = My page name 48 | 49 | # 50 | # Sample widget 51 | # 52 | MyWidget = My widget 53 | MyWidgetDescription = My widget description 54 | 55 | 56 | # 57 | # Permissions 58 | # 59 | DistributionListPermRead = read/show distribution lists 60 | DistributionListPermCreate = create distribution lists 61 | DistributionListPermUpdate = modify/update distribution lists 62 | DistributionListPermDelete = delete distribution lists 63 | -------------------------------------------------------------------------------- /lib/distributionlist.lib.php: -------------------------------------------------------------------------------- 1 | . 16 | */ 17 | 18 | /** 19 | * \file distributionlist/lib/distributionlist.lib.php 20 | * \ingroup distributionlist 21 | * \brief Library files with common functions for DistributionList 22 | */ 23 | 24 | /** 25 | * Prepare admin pages header 26 | * 27 | * @return array 28 | */ 29 | function distributionlistAdminPrepareHead() 30 | { 31 | global $langs, $conf; 32 | 33 | $langs->load("distributionlist@distributionlist"); 34 | 35 | $h = 0; 36 | $head = array(); 37 | 38 | $head[$h][0] = dol_buildpath("/distributionlist/admin/setup.php", 1); 39 | $head[$h][1] = $langs->trans("Settings"); 40 | $head[$h][2] = 'settings'; 41 | $h++; 42 | 43 | /* 44 | $head[$h][0] = dol_buildpath("/distributionlist/admin/myobject_extrafields.php", 1); 45 | $head[$h][1] = $langs->trans("ExtraFields"); 46 | $head[$h][2] = 'myobject_extrafields'; 47 | $h++; 48 | */ 49 | 50 | $head[$h][0] = dol_buildpath("/distributionlist/admin/about.php", 1); 51 | $head[$h][1] = $langs->trans("About"); 52 | $head[$h][2] = 'about'; 53 | $h++; 54 | 55 | // Show more tabs from modules 56 | // Entries must be declared in modules descriptor with line 57 | //$this->tabs = array( 58 | // 'entity:+tabname:Title:@distributionlist:/distributionlist/mypage.php?id=__ID__' 59 | //); // to add new tab 60 | //$this->tabs = array( 61 | // 'entity:-tabname:Title:@distributionlist:/distributionlist/mypage.php?id=__ID__' 62 | //); // to remove a tab 63 | complete_head_from_modules($conf, $langs, null, $head, $h, 'distributionlist'); 64 | 65 | return $head; 66 | } 67 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG DISTRIBUTIONLIST FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) 2 | 3 | ## Unreleased 4 | 5 | 6 | 7 | ## 1.3 8 | 9 | - FIX : lors de la suppression d'un contact, il faut aussi supprimer le contact de toutes les listes de diffusion - *05/05/2022* - 1.3.4 10 | - FIX : lors de la suppression d'un contact, il faut décrémenter le nombre de contact dans les listes de diffusion concernés - *05/05/2022* - 1.3.3 11 | - FIX : Test d'unicité sur le label était non fonctionnel - *20/04/2022* - 1.3.2 12 | - FIX : Récupération des listes de diffusion au statut clôturé dans le select des listes de diffusions sur l'onglet "Destinataires" d'une campagne - *08/03/2022* - 1.3.1 13 | - FIX : Empêcher les doublons : 14 | - Conf DISTRIBUTIONLISTUNIQUELABEL : Rendre le libellé des listes de diffusion unique + message d'erreur et lien vers la liste existante avec le même nom 15 | - Onglet ajout des destinataires, afficher les filtres personnalisés par ordre alphabétique + empecher les doublons 16 | - Dans Sarbacane, onglet Destinataires, afficher la liste des LDD par ordre alphabétique - *02/02/2021* - 1.3.0 17 | 18 | ## 1.2 19 | 20 | - FIX : Suppression des liste de diffusion au statut brouillon des liste de liste de diffusion - *25/02/2022* - 1.2.4 21 | - FIX : Bouton "Enregistrer filtre" ne faisait pas la bonne action - *21/12/2021* - 1.2.3 22 | - FIX : Correction "Ajouter contacts à la liste" : maintenir le filtre si on change le nombre de contacts à afficher - *08/12/2021* - 1.2.2 23 | - FIX : Correction de l'action d'ajout de tous les contacts sur la liste de diffusion - *06/12/2021* - 1.2.1 24 | - NEW : Bouton action ajouter tous les contacts filtrés - *07/10/2021* - 1.2.0 25 | - FIX : Insertion des contacts en pur sql. Le probleme venait du volume de donnees et du fait qu'on parcourait 2 fois un tableau de 27000 lignes... timeout - *01/09/2021* - 1.1.5 26 | - FIX : Transfert fonctionnalité "Ajout d'une liste de diffusion dans les destinataires d'un mailing" + adaptation de la méthode dolibarr - *21/07/2021* - 1.1.4 27 | - FIX : Suppression du champ date cloture dans popup de confirmation + MAJ date cloture sur cloture - *15/06/2021* - 1.1.3 28 | - FIX : Impossibilité de valider une liste de diffusion lorsqu'elle est vide - *15/06/2021* - 1.1.2 29 | - FIX : Ajout du champ "Date de cloture" sur formulaire de creation - *14/06/2021* - 1.1.1 30 | - NEW : Séparation des permissions de création/modification - *02/06/2021* - 1.1.0 31 | 32 | ## 1.0 33 | 34 | Initial version 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DISTRIBUTIONLIST FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) 2 | 3 | ## Features 4 | 5 | Description... 6 | 7 | 10 | 11 | Other modules are available on [Dolistore.com](https://www.dolistore.com). 12 | 13 | ## Translations 14 | 15 | Translations can be define manually by editing files into directories *langs*. 16 | 17 | 24 | 25 | 77 | 78 | ## Licenses 79 | 80 | ### Main code 81 | 82 | GPLv3 or (at your option) any later version. See file COPYING for more information. 83 | 84 | ### Documentation 85 | 86 | All texts and readmes are licensed under GFDL. 87 | -------------------------------------------------------------------------------- /admin/about.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2021 SuperAdmin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file distributionlist/admin/about.php 21 | * \ingroup distributionlist 22 | * \brief About page of module DistributionList. 23 | */ 24 | 25 | // Load Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 36 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 37 | if (!$res) die("Include of main fails"); 38 | 39 | // Libraries 40 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 41 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 42 | require_once '../lib/distributionlist.lib.php'; 43 | 44 | // Translations 45 | $langs->loadLangs(array("errors", "admin", "distributionlist@distributionlist")); 46 | 47 | // Access control 48 | if (!$user->admin) accessforbidden(); 49 | 50 | // Parameters 51 | $action = GETPOST('action', 'alpha'); 52 | $backtopage = GETPOST('backtopage', 'alpha'); 53 | 54 | 55 | /* 56 | * Actions 57 | */ 58 | 59 | // None 60 | 61 | 62 | /* 63 | * View 64 | */ 65 | 66 | $form = new Form($db); 67 | 68 | $page_name = "DistributionListAbout"; 69 | llxHeader('', $langs->trans($page_name)); 70 | 71 | // Subheader 72 | $linkback = ''.$langs->trans("BackToModuleList").''; 73 | 74 | print load_fiche_titre($langs->trans($page_name), $linkback, 'object_distributionlist@distributionlist'); 75 | 76 | // Configuration header 77 | $head = distributionlistAdminPrepareHead(); 78 | dol_fiche_head($head, 'about', '', 0, 'distributionlist@distributionlist'); 79 | 80 | dol_include_once('/distributionlist/core/modules/modDistributionList.class.php'); 81 | $tmpmodule = new modDistributionList($db); 82 | print $tmpmodule->getDescLong(); 83 | 84 | // Page end 85 | dol_fiche_end(); 86 | llxFooter(); 87 | $db->close(); 88 | -------------------------------------------------------------------------------- /lib/distributionlist_distributionlistsocpeople.lib.php: -------------------------------------------------------------------------------- 1 | . 16 | */ 17 | 18 | /** 19 | * \file lib/distributionlist_distributionlistsocpeople.lib.php 20 | * \ingroup distributionlist 21 | * \brief Library files with common functions for DistributionListSocpeople 22 | */ 23 | 24 | /** 25 | * Prepare array of tabs for DistributionListSocpeople 26 | * 27 | * @param DistributionListSocpeople $object DistributionListSocpeople 28 | * @return array Array of tabs 29 | */ 30 | function distributionlistsocpeoplePrepareHead($object) 31 | { 32 | global $db, $langs, $conf; 33 | 34 | $langs->load("distributionlist@distributionlist"); 35 | 36 | $h = 0; 37 | $head = array(); 38 | 39 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlistsocpeople_card.php", 1).'?id='.$object->id; 40 | $head[$h][1] = $langs->trans("Card"); 41 | $head[$h][2] = 'card'; 42 | $h++; 43 | 44 | if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) 45 | { 46 | $nbNote = 0; 47 | if (!empty($object->note_private)) $nbNote++; 48 | if (!empty($object->note_public)) $nbNote++; 49 | $head[$h][0] = dol_buildpath('/distributionlist/distributionlistsocpeople_note.php', 1).'?id='.$object->id; 50 | $head[$h][1] = $langs->trans('Notes'); 51 | if ($nbNote > 0) $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.$nbNote.'' : ''); 52 | $head[$h][2] = 'note'; 53 | $h++; 54 | } 55 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 57 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; 58 | $upload_dir = $conf->distributionlist->dir_output."/distributionlistsocpeople/".dol_sanitizeFileName($object->ref); 59 | $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); 60 | $nbLinks = Link::count($db, $object->element, $object->id); 61 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlistsocpeople_document.php", 1).'?id='.$object->id; 62 | $head[$h][1] = $langs->trans('Documents'); 63 | if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; 64 | $head[$h][2] = 'document'; 65 | $h++; 66 | 67 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlistsocpeople_agenda.php", 1).'?id='.$object->id; 68 | $head[$h][1] = $langs->trans("Events"); 69 | $head[$h][2] = 'agenda'; 70 | $h++; 71 | 72 | // Show more tabs from modules 73 | // Entries must be declared in modules descriptor with line 74 | //$this->tabs = array( 75 | // 'entity:+tabname:Title:@distributionlist:/distributionlist/mypage.php?id=__ID__' 76 | //); // to add new tab 77 | //$this->tabs = array( 78 | // 'entity:-tabname:Title:@distributionlist:/distributionlist/mypage.php?id=__ID__' 79 | //); // to remove a tab 80 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'distributionlistsocpeople@distributionlist'); 81 | 82 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'distributionlistsocpeople@distributionlist', 'remove'); 83 | 84 | return $head; 85 | } 86 | -------------------------------------------------------------------------------- /admin/myobject_extrafields.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2003 Jean-Louis Bergamo 4 | * Copyright (C) 2004-2011 Laurent Destailleur 5 | * Copyright (C) 2012 Regis Houssin 6 | * Copyright (C) 2014 Florian Henry 7 | * Copyright (C) 2015 Jean-François Ferry 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | /** 24 | * \file htdocs/modulebuilder/tempalte/admin/myobject_extrafields.php 25 | * \ingroup distributionlist 26 | * \brief Page to setup extra fields of myobject 27 | */ 28 | 29 | require '../main.inc.php'; 30 | require_once DOL_DOCUMENT_ROOT.'/core/lib/bom.lib.php'; 31 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; 32 | 33 | // Load translation files required by the page 34 | $langs->loadLangs(array('mrp@mrp', 'admin')); 35 | 36 | $extrafields = new ExtraFields($db); 37 | $form = new Form($db); 38 | 39 | // List of supported format 40 | $tmptype2label = ExtraFields::$type2label; 41 | $type2label = array(''); 42 | foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); 43 | 44 | $action = GETPOST('action', 'alpha'); 45 | $attrname = GETPOST('attrname', 'alpha'); 46 | $elementtype = 'distributionlist_myobject'; //Must be the $table_element of the class that manage extrafield 47 | 48 | if (!$user->admin) accessforbidden(); 49 | 50 | 51 | /* 52 | * Actions 53 | */ 54 | 55 | require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; 56 | 57 | 58 | 59 | /* 60 | * View 61 | */ 62 | 63 | 64 | llxHeader('', $langs->trans("DistributionListSetup"), $help_url); 65 | 66 | 67 | $linkback = ''.$langs->trans("BackToModuleList").''; 68 | print load_fiche_titre($langs->trans("DistributionListSetup"), $linkback, 'title_setup'); 69 | 70 | 71 | $head = distributionlistAdminPrepareHead(); 72 | 73 | dol_fiche_head($head, 'myobject_extrafields', $langs->trans("MyObjectExtraFields"), -1, 'account'); 74 | 75 | require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; 76 | 77 | dol_fiche_end(); 78 | 79 | 80 | // Buttons 81 | if ($action != 'create' && $action != 'edit') 82 | { 83 | print '
'; 84 | print "".$langs->trans("NewAttribute").""; 85 | print "
"; 86 | } 87 | 88 | 89 | /* 90 | * Creation of an optional field 91 | */ 92 | if ($action == 'create') 93 | { 94 | print '
'; 95 | print load_fiche_titre($langs->trans('NewAttribute')); 96 | 97 | require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; 98 | } 99 | 100 | /* 101 | * Edition of an optional field 102 | */ 103 | if ($action == 'edit' && !empty($attrname)) 104 | { 105 | print "
"; 106 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); 107 | 108 | require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; 109 | } 110 | 111 | // End of page 112 | llxFooter(); 113 | $db->close(); 114 | -------------------------------------------------------------------------------- /lib/distributionlist_distributionlist.lib.php: -------------------------------------------------------------------------------- 1 | . 16 | */ 17 | 18 | /** 19 | * \file lib/distributionlist_distributionlist.lib.php 20 | * \ingroup distributionlist 21 | * \brief Library files with common functions for DistributionList 22 | */ 23 | 24 | /** 25 | * Prepare array of tabs for DistributionList 26 | * 27 | * @param DistributionList $object DistributionList 28 | * @return array Array of tabs 29 | */ 30 | function distributionlistPrepareHead($object) 31 | { 32 | global $db, $langs, $conf, $user; 33 | 34 | $langs->load("distributionlist@distributionlist"); 35 | 36 | $h = 0; 37 | $head = array(); 38 | 39 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlist_card.php", 1).'?id='.$object->id; 40 | $head[$h][1] = $langs->trans("Card"); 41 | $head[$h][2] = 'card'; 42 | $h++; 43 | 44 | if ($object->status < DistributionList::STATUS_CLOSED && $user->hasRight('distributionlist', 'distributionlist', 'update')) { 45 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlist_contact.php", 1) . '?id=' . $object->id; 46 | $head[$h][1] = $langs->trans("AddContactToDistributionList"); 47 | $head[$h][2] = 'contact'; 48 | $h++; 49 | } 50 | 51 | if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) 52 | { 53 | $nbNote = 0; 54 | if (!empty($object->note_private)) $nbNote++; 55 | if (!empty($object->note_public)) $nbNote++; 56 | $head[$h][0] = dol_buildpath('/distributionlist/distributionlist_note.php', 1).'?id='.$object->id; 57 | $head[$h][1] = $langs->trans('Notes'); 58 | if ($nbNote > 0) $head[$h][1] .= !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.$nbNote.'' : ''; 59 | $head[$h][2] = 'note'; 60 | $h++; 61 | } 62 | 63 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 64 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; 65 | $upload_dir = $conf->distributionlist->dir_output."/distributionlist/".dol_sanitizeFileName($object->ref); 66 | $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); 67 | $nbLinks = Link::count($db, $object->element, $object->id); 68 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlist_document.php", 1).'?id='.$object->id; 69 | $head[$h][1] = $langs->trans('Documents'); 70 | if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; 71 | $head[$h][2] = 'document'; 72 | $h++; 73 | 74 | $head[$h][0] = dol_buildpath("/distributionlist/distributionlist_agenda.php", 1).'?id='.$object->id; 75 | $head[$h][1] = $langs->trans("Events"); 76 | $head[$h][2] = 'agenda'; 77 | $h++; 78 | 79 | // Show more tabs from modules 80 | // Entries must be declared in modules descriptor with line 81 | //$this->tabs = array( 82 | // 'entity:+tabname:Title:@distributionlist:/distributionlist/mypage.php?id=__ID__' 83 | //); // to add new tab 84 | //$this->tabs = array( 85 | // 'entity:-tabname:Title:@distributionlist:/distributionlist/mypage.php?id=__ID__' 86 | //); // to remove a tab 87 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'distributionlist@distributionlist'); 88 | 89 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'distributionlist@distributionlist', 'remove'); 90 | 91 | return $head; 92 | } 93 | -------------------------------------------------------------------------------- /langs/fr_FR/distributionlist.lang: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 SuperAdmin 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see . 15 | 16 | # 17 | # Générique 18 | # 19 | 20 | DistributionList=Liste de diffusion 21 | EmailFromDistributionList=E-mails à partir d\'une liste de diffusion 22 | DistributionListNew=Nouvelle liste de diffusion 23 | DistributionListList=Voir toutes les listes 24 | DistributionListAllList=Listes de diffusion 25 | ConfirmReopenDistributionList=Êtes-vous sûr(e) de vouloir rouvrir cette liste de diffusion ? 26 | DistributionListValidate=Valider liste de diffusion 27 | DistributionListDelete=Supprimer liste de diffusion 28 | ConfirmValidateDistributionList=Êtes-vous sûr(e) de vouloir valider cette liste de diffusion sous la référence %s ? 29 | ConfirmCloseDistributionList=Êtes-vous sûr(e) de vouloir clôturer cette liste de diffusion ? 30 | ConfirmDeleteDistributionList=Êtes-vous sûr(e) de vouloir supprimer cette liste de diffusion ? 31 | DistributionListSaveCurrentFilter=Enregistrer le filtre actuel 32 | ConfirmDeleteDistributionListFilter=Êtes-vous sûr(e) de vouloir supprimer le filtre %s ? 33 | ConfirmUnvalidateDistributionList=Êtes-vous sûr(e) de vouloir repasser la liste de diffusion %s au statut brouillon ? 34 | DistributionListUnvalidate=Repasser liste de diffusion au statut brouillon 35 | AddContactToDistributionList=Ajout de contacts à la liste 36 | DistributionListAddContacts=Ajouter les contacts sélectionnés à la liste de diffusion 37 | DistributionListNbAddedContacts=%s nouveau(x) contact(s) ajouté(s) à la liste de diffusion 38 | DistributionListNoAddedContacts=Aucun nouveau contact ajouté à la liste 39 | DistributionListDeleteContacts=Supprimer les contacts sélectionnés de la liste de diffusion 40 | DistributionListNbDeletedContacts=%s contact(s) supprimé(s) de la liste de diffusion 41 | ListOfContactsAddressesDistributionList=Liste des contacts/adresses présents dans la liste de diffusion 42 | DistributionListNbContactsInList=Nombre de contacts dans la liste 43 | DistributionListUserWhoAdd=Ajouté à la liste par 44 | ConfirmDeleteAllContactsDistributionList=Etes vous sûr(e) de vouloir supprimer tous les contacts présents dans cette liste de diffusion ? 45 | DistributionListDeleteFilterSuccess=Le filtre %s a été supprimé 46 | DistributionListNeedToSelectFilterForDeletion=Vous devez sélectionner le filtre à supprimer 47 | DistributionListNeedToSelectFilterForSelection=Vous devez sélectionner le filtre à appliquer 48 | DistributionListFilterError=Erreur lors de la récupération du filtre sélectionné 49 | 50 | # Module label 'ModuleDistributionListName' 51 | ModuleDistributionListName = Listes de diffusion 52 | # Module description 'ModuleDistributionListDesc' 53 | ModuleDistributionListDesc = Module de création de listes de diffusion pour application externes (Sarbacane, etc...) 54 | 55 | # 56 | # Page d'administration 57 | # 58 | DistributionListSetup = Configuration du module listes de diffusion 59 | Settings = Réglages 60 | DistributionListSetupPage = Page de configuration du module listes de diffusion 61 | DistributionList_UniqueLabel=Ne pas autoriser les listes de diffusion de même nom 62 | # 63 | # Permissions 64 | # 65 | DistributionListPermRead=Voir les listes de diffusion 66 | DistributionListPermCreate=Créer des listes de diffusion 67 | DistributionListPermUpdate=Modifier des listes de diffusion 68 | DistributionListPermDelete=Supprimer des listes de diffusion 69 | 70 | # 71 | # Page À propos 72 | # 73 | About = À propos 74 | DistributionListAbout = À propos de DistributionList 75 | DistributionListAboutPage = Page à propos de DistributionList 76 | 77 | # 78 | # Page d'exemple 79 | # 80 | MyPageName = Nom de ma page 81 | 82 | # 83 | # Box d'exemple 84 | # 85 | MyWidget = Mon widget 86 | MyWidgetDescription = Description de mon widget 87 | 88 | # 89 | # Erreurs 90 | # 91 | NoContactInDistribListError=Des contacts doivent être ajoutés à la liste de diffusion avant de pouvoir la valider 92 | AddEveryContactWithThisFilter=Ajouter tous les contacts 93 | DistributionListFilterSocPeople_Label_AlreadyExist=Un filtre nommée "%s" existe déjà 94 | DistributionList_Label_AlreadyExist=Une liste de diffusion nommée "%s" existe déjà : %s 95 | -------------------------------------------------------------------------------- /core/modules/distributionlist/modules_distributionlist.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2011 Laurent Destailleur 4 | * Copyright (C) 2004 Eric Seigne 5 | * Copyright (C) 2005-2012 Regis Houssin 6 | * Copyright (C) 2006 Andre Cianfarani 7 | * Copyright (C) 2012 Juanjo Menent 8 | * Copyright (C) 2014 Marcos García 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program. If not, see . 22 | * or see https://www.gnu.org/ 23 | */ 24 | 25 | /** 26 | * \file htdocs/core/modules/distributionlist/modules_distributionlist.php 27 | * \ingroup distributionlist 28 | * \brief File that contains parent class for distributionlists document models and parent class for distributionlists numbering models 29 | */ 30 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; 32 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit 33 | 34 | 35 | /** 36 | * Parent class for documents models 37 | */ 38 | abstract class ModelePDFDistributionList extends CommonDocGenerator 39 | { 40 | 41 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps 42 | /** 43 | * Return list of active generation modules 44 | * 45 | * @param DoliDB $db Database handler 46 | * @param integer $maxfilenamelength Max length of value to show 47 | * @return array List of templates 48 | */ 49 | public static function liste_modeles($db, $maxfilenamelength = 0) 50 | { 51 | // phpcs:enable 52 | global $conf; 53 | 54 | $type = 'distributionlist'; 55 | $list = array(); 56 | 57 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 58 | $list = getListOfModels($db, $type, $maxfilenamelength); 59 | 60 | return $list; 61 | } 62 | } 63 | 64 | 65 | 66 | /** 67 | * Parent class to manage numbering of DistributionList 68 | */ 69 | abstract class ModeleNumRefDistributionList 70 | { 71 | /** 72 | * @var string Error code (or message) 73 | */ 74 | public $error = ''; 75 | 76 | /** 77 | * Return if a module can be used or not 78 | * 79 | * @return boolean true if module can be used 80 | */ 81 | public function isEnabled() 82 | { 83 | return true; 84 | } 85 | 86 | /** 87 | * Returns the default description of the numbering template 88 | * 89 | * @return string Texte descripif 90 | */ 91 | public function info() 92 | { 93 | global $langs; 94 | $langs->load("distributionlist@distributionlist"); 95 | return $langs->trans("NoDescription"); 96 | } 97 | 98 | /** 99 | * Returns an example of numbering 100 | * 101 | * @return string Example 102 | */ 103 | public function getExample() 104 | { 105 | global $langs; 106 | $langs->load("distributionlist@distributionlist"); 107 | return $langs->trans("NoExample"); 108 | } 109 | 110 | /** 111 | * Checks if the numbers already in the database do not 112 | * cause conflicts that would prevent this numbering working. 113 | * 114 | * @param Object $object Object we need next value for 115 | * @return boolean false if conflict, true if ok 116 | */ 117 | public function canBeActivated($object) 118 | { 119 | return true; 120 | } 121 | 122 | /** 123 | * Returns next assigned value 124 | * 125 | * @param Object $object Object we need next value for 126 | * @return string Valeur 127 | */ 128 | public function getNextValue($object) 129 | { 130 | global $langs; 131 | return $langs->trans("NotAvailable"); 132 | } 133 | 134 | /** 135 | * Returns version of numbering module 136 | * 137 | * @return string Valeur 138 | */ 139 | public function getVersion() 140 | { 141 | global $langs; 142 | $langs->load("admin"); 143 | 144 | if ($this->version == 'development') return $langs->trans("VersionDevelopment"); 145 | if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); 146 | if ($this->version == 'dolibarr') return DOL_VERSION; 147 | if ($this->version) return $this->version; 148 | return $langs->trans("NotAvailable"); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /core/modules/distributionlist/mod_distributionlist_standard.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2005-2009 Regis Houssin 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * or see https://www.gnu.org/ 18 | */ 19 | 20 | /** 21 | * \file htdocs/core/modules/distributionlist/mod_distributionlist_standard.php 22 | * \ingroup distributionlist 23 | * \brief File of class to manage DistributionList numbering rules standard 24 | */ 25 | dol_include_once('/distributionlist/core/modules/distributionlist/modules_distributionlist.php'); 26 | 27 | 28 | /** 29 | * Class to manage customer order numbering rules standard 30 | */ 31 | class mod_distributionlist_standard extends ModeleNumRefDistributionList 32 | { 33 | /** 34 | * Dolibarr version of the loaded document 35 | * @var string 36 | */ 37 | public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' 38 | 39 | public $prefix = 'DISTRIBUTIONLIST'; 40 | 41 | /** 42 | * @var string Error code (or message) 43 | */ 44 | public $error = ''; 45 | 46 | /** 47 | * @var string name 48 | */ 49 | public $name = 'standard'; 50 | 51 | 52 | /** 53 | * Return description of numbering module 54 | * 55 | * @return string Text with description 56 | */ 57 | public function info() 58 | { 59 | global $langs; 60 | return $langs->trans("SimpleNumRefModelDesc", $this->prefix); 61 | } 62 | 63 | 64 | /** 65 | * Return an example of numbering 66 | * 67 | * @return string Example 68 | */ 69 | public function getExample() 70 | { 71 | return $this->prefix."0501-0001"; 72 | } 73 | 74 | 75 | /** 76 | * Checks if the numbers already in the database do not 77 | * cause conflicts that would prevent this numbering working. 78 | * 79 | * @param Object $object Object we need next value for 80 | * @return boolean false if conflict, true if ok 81 | */ 82 | public function canBeActivated($object) 83 | { 84 | global $conf, $langs, $db; 85 | 86 | $coyymm = ''; $max = ''; 87 | 88 | $posindice = strlen($this->prefix) + 6; 89 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; 90 | $sql .= " FROM ".MAIN_DB_PREFIX."distributionlist_distributionlist"; 91 | $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; 92 | if ($object->ismultientitymanaged == 1) { 93 | $sql .= " AND entity = ".$conf->entity; 94 | } 95 | elseif ($object->ismultientitymanaged == 2) { 96 | // TODO 97 | } 98 | 99 | $resql = $db->query($sql); 100 | if ($resql) 101 | { 102 | $row = $db->fetch_row($resql); 103 | if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } 104 | } 105 | if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) 106 | { 107 | $langs->load("errors"); 108 | $this->error = $langs->trans('ErrorNumRefModel', $max); 109 | return false; 110 | } 111 | 112 | return true; 113 | } 114 | 115 | /** 116 | * Return next free value 117 | * 118 | * @param Object $object Object we need next value for 119 | * @return string Value if KO, <0 if KO 120 | */ 121 | public function getNextValue($object) 122 | { 123 | global $db, $conf; 124 | 125 | // first we get the max value 126 | $posindice = strlen($this->prefix) + 6; 127 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; 128 | $sql .= " FROM ".MAIN_DB_PREFIX."distributionlist_distributionlist"; 129 | $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; 130 | if ($object->ismultientitymanaged == 1) { 131 | $sql .= " AND entity = ".$conf->entity; 132 | } 133 | elseif ($object->ismultientitymanaged == 2) { 134 | // TODO 135 | } 136 | 137 | $resql = $db->query($sql); 138 | if ($resql) 139 | { 140 | $obj = $db->fetch_object($resql); 141 | if ($obj) $max = intval($obj->max); 142 | else $max = 0; 143 | } 144 | else 145 | { 146 | dol_syslog("mod_distributionlist_standard::getNextValue", LOG_DEBUG); 147 | return -1; 148 | } 149 | 150 | //$date=time(); 151 | $date = $object->date_creation; 152 | $yymm = strftime("%y%m", $date); 153 | 154 | if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is 155 | else $num = sprintf("%04s", $max + 1); 156 | 157 | dol_syslog("mod_distributionlist_standard::getNextValue return ".$this->prefix.$yymm."-".$num); 158 | return $this->prefix.$yymm."-".$num; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /class/actions_distributionlist.class.php: -------------------------------------------------------------------------------- 1 | trans('ListOfContactsAddressesDistributionList'); 17 | 18 | // On retire la permission de créer dans ce contexte pour enlever le lien "Nouveau contact/adresse" 19 | unset($user->rights->societe->contact->creer); 20 | 21 | } 22 | } 23 | } 24 | 25 | function addMoreMassActions($parameters, &$object, &$action, $hookmanager) { 26 | global $langs; 27 | $TContext = explode(':', $parameters['context']); 28 | if(in_array('contactlist', $TContext)) { 29 | $origin_page = GETPOST('origin_page'); 30 | if($origin_page === 'distributionlist_contact') { 31 | 32 | $label = $langs->trans('DistributionListAddContacts'); 33 | $this->resprints = ''; 34 | $this->resprints.= ''; 35 | 36 | return 1; 37 | 38 | } elseif($origin_page === 'distributionlist_card') { 39 | 40 | $label = $langs->trans('DistributionListDeleteContacts'); 41 | $this->resprints = ''; 42 | $this->resprints.= ''; 43 | 44 | return 1; 45 | 46 | } 47 | } 48 | 49 | } 50 | 51 | function printFieldListWhere($parameters, &$object, &$action, $hookmanager) { 52 | 53 | global $db; 54 | 55 | dol_include_once('/distributionlist/class/distributionlistsocpeople.class.php'); 56 | $TContext = explode(':', $parameters['context']); 57 | if(in_array('contactlist', $TContext)) { 58 | $origin_page = GETPOST('origin_page'); 59 | if($origin_page === 'distributionlist_card') { 60 | $o = new DistributionListSocpeople($db); 61 | 62 | $TRes = $o->fetchAll('', '', 0, 0, array('customsql'=>' fk_distributionlist = '.GETPOST('id', 'int'))); 63 | if(!empty($TRes)) { 64 | $TContacts = array(); 65 | foreach ($TRes as $obj) { 66 | $TContacts[] = $obj->fk_socpeople; 67 | } 68 | $this->resprints = ' AND p.rowid IN ('.implode(', ', $TContacts).')'; 69 | } else $this->resprints = ' AND p.rowid = 0 '; 70 | } 71 | } 72 | 73 | } 74 | 75 | function printFieldListOption($parameters, &$object, &$action, $hookmanager) { 76 | 77 | global $db; 78 | 79 | $TContext = explode(':', $parameters['context']); 80 | if(in_array('contactlist', $TContext)) { 81 | $origin_page = GETPOST('origin_page'); 82 | if($origin_page === 'distributionlist_card') $this->resprints = ''; 83 | } 84 | 85 | return 1; 86 | 87 | } 88 | 89 | function printFieldListTitle($parameters, &$object, &$action, $hookmanager) { 90 | 91 | global $langs; 92 | 93 | $TContext = explode(':', $parameters['context']); 94 | if(in_array('contactlist', $TContext)) { 95 | $origin_page = GETPOST('origin_page'); 96 | if ($origin_page === 'distributionlist_card') $this->resprints = print_liste_field_titre($langs->trans('DistributionListUserWhoAdd'), $_SERVER["PHP_SELF"], "", "", $param ?? '', '', $sortfield ?? '', $sortorder ?? '', 'center nowrap '); 97 | } 98 | 99 | return 1; 100 | 101 | } 102 | 103 | function printFieldListValue($parameters, &$object, &$action, $hookmanager) { 104 | 105 | global $db, $TDistributionListLoadedusers; 106 | 107 | if(empty($TDistributionListLoadedusers)) $TDistributionListLoadedusers = array(); 108 | 109 | $TContext = explode(':', $parameters['context']); 110 | if(in_array('contactlist', $TContext)) { 111 | $origin_page = GETPOST('origin_page'); 112 | if ($origin_page === 'distributionlist_card') { 113 | 114 | require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; 115 | require_once __DIR__ . './../class/distributionlistsocpeople.class.php'; 116 | 117 | $contact_id = $parameters['obj']->rowid; 118 | $o = new DistributionListSocpeople($db); 119 | $TRes = $o->fetchAll('', '', 0, 0, array('customsql' => ' fk_distributionlist = ' . GETPOST('id', 'int') . ' AND fk_socpeople = ' . $contact_id)); 120 | if (!empty($TRes)) { 121 | $uid = $TRes[key($TRes)]->fk_user_creat; 122 | if (!empty($TDistributionListLoadedusers[$uid])) $this->resprints = $TDistributionListLoadedusers[$uid]; 123 | else { 124 | $u = new User($db); 125 | $u->fetch($uid); 126 | $TDistributionListLoadedusers[$uid] = '' . $u->getNomUrl(1) . ''; 127 | $this->resprints = $TDistributionListLoadedusers[$uid]; 128 | } 129 | } 130 | } 131 | 132 | } 133 | 134 | return 1; 135 | 136 | } 137 | 138 | // function printFieldListFooter 139 | 140 | } 141 | -------------------------------------------------------------------------------- /core/modules/distributionlist/mod_distributionlist_advanced.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2007 Laurent Destailleur 4 | * Copyright (C) 2005-2009 Regis Houssin 5 | * Copyright (C) 2008 Raphael Bertrand (Resultic) 6 | * Copyright (C) 2019 Frédéric France 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * or see https://www.gnu.org/ 21 | */ 22 | 23 | /** 24 | * \file htdocs/core/modules/distributionlist/mod_distributionlist_advanced.php 25 | * \ingroup distributionlist 26 | * \brief File containing class for advanced numbering model of DistributionList 27 | */ 28 | 29 | dol_include_once('/distributionlist/core/modules/distributionlist/modules_distributionlist.php'); 30 | 31 | 32 | /** 33 | * Class to manage customer Bom numbering rules advanced 34 | */ 35 | class mod_distributionlist_advanced extends ModeleNumRefDistributionList 36 | { 37 | /** 38 | * Dolibarr version of the loaded document 39 | * @var string 40 | */ 41 | public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' 42 | 43 | /** 44 | * @var string Error message 45 | */ 46 | public $error = ''; 47 | 48 | /** 49 | * @var string name 50 | */ 51 | public $name = 'advanced'; 52 | 53 | 54 | /** 55 | * Returns the description of the numbering model 56 | * 57 | * @return string Texte descripif 58 | */ 59 | public function info() 60 | { 61 | global $conf, $langs, $db; 62 | 63 | $langs->load("bills"); 64 | 65 | $form = new Form($db); 66 | 67 | $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; 68 | $texte .= '
'; 69 | $texte .= ''; 70 | $texte .= ''; 71 | $texte .= ''; 72 | $texte .= ''; 73 | 74 | $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("DistributionList"), $langs->transnoentities("DistributionList")); 75 | $tooltip .= $langs->trans("GenericMaskCodes2"); 76 | $tooltip .= $langs->trans("GenericMaskCodes3"); 77 | $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("DistributionList"), $langs->transnoentities("DistributionList")); 78 | $tooltip .= $langs->trans("GenericMaskCodes5"); 79 | 80 | // Parametrage du prefix 81 | $texte .= ''; 82 | $texte .= ''; 83 | 84 | $texte .= ''; 85 | 86 | $texte .= ''; 87 | 88 | $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; 89 | $texte .= '
'; 90 | 91 | return $texte; 92 | } 93 | 94 | /** 95 | * Return an example of numbering 96 | * 97 | * @return string Example 98 | */ 99 | public function getExample() 100 | { 101 | global $conf, $db, $langs, $mysoc; 102 | 103 | $object = new DistributionList($db); 104 | $object->initAsSpecimen(); 105 | 106 | /*$old_code_client = $mysoc->code_client; 107 | $old_code_type = $mysoc->typent_code; 108 | $mysoc->code_client = 'CCCCCCCCCC'; 109 | $mysoc->typent_code = 'TTTTTTTTTT';*/ 110 | 111 | $numExample = $this->getNextValue($object); 112 | 113 | /*$mysoc->code_client = $old_code_client; 114 | $mysoc->typent_code = $old_code_type;*/ 115 | 116 | if (!$numExample) 117 | { 118 | $numExample = $langs->trans('NotConfigured'); 119 | } 120 | return $numExample; 121 | } 122 | 123 | /** 124 | * Return next free value 125 | * 126 | * @param Object $object Object we need next value for 127 | * @return string Value if KO, <0 if KO 128 | */ 129 | public function getNextValue($object) 130 | { 131 | global $db, $conf; 132 | 133 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 134 | 135 | // We get cursor rule 136 | $mask = getDolGlobalString('DISTRIBUTIONLIST_DISTRIBUTIONLIST_ADVANCED_MASK'); 137 | 138 | if (!$mask) 139 | { 140 | $this->error = 'NotConfigured'; 141 | return 0; 142 | } 143 | 144 | $date = $object->date; 145 | 146 | $numFinal = get_next_value($db, $mask, 'distributionlist_distributionlist', 'ref', '', null, $date); 147 | 148 | return $numFinal; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /distributionlist_note.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) ---Put here your own copyright and developer email--- 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file distributionlist_note.php 21 | * \ingroup distributionlist 22 | * \brief Car with notes on DistributionList 23 | */ 24 | 25 | // Load Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; 36 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38 | if (!$res) die("Include of main fails"); 39 | 40 | dol_include_once('/distributionlist/class/distributionlist.class.php'); 41 | dol_include_once('/distributionlist/lib/distributionlist_distributionlist.lib.php'); 42 | 43 | // Load translation files required by the page 44 | $langs->loadLangs(array("distributionlist@distributionlist", "companies")); 45 | 46 | // Get parameters 47 | $id = GETPOST('id', 'int'); 48 | $ref = GETPOST('ref', 'alpha'); 49 | $action = GETPOST('action', 'alpha'); 50 | $cancel = GETPOST('cancel', 'aZ09'); 51 | $backtopage = GETPOST('backtopage', 'alpha'); 52 | 53 | // Initialize technical objects 54 | $object = new DistributionList($db); 55 | $extrafields = new ExtraFields($db); 56 | $diroutputmassaction = $conf->distributionlist->dir_output.'/temp/massgeneration/'.$user->id; 57 | $hookmanager->initHooks(array('distributionlistnote', 'globalcard')); // Note that conf->hooks_modules contains array 58 | // Fetch optionals attributes and labels 59 | $extrafields->fetch_name_optionals_label($object->table_element); 60 | 61 | // Security check - Protection if external user 62 | //if ($user->socid > 0) accessforbidden(); 63 | //if ($user->socid > 0) $socid = $user->socid; 64 | //$result = restrictedArea($user, 'distributionlist', $id); 65 | 66 | // Load object 67 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals 68 | if (array_key_exists($object->entity, $conf->distributionlist->multidir_output) && $id > 0 || !empty($ref)) $upload_dir = $conf->distributionlist->multidir_output[$object->entity]."/".$object->id; 69 | 70 | $permissionnote = $user->hasRight('distributionlist', 'distributionlist', 'create'); // Used by the include of actions_setnotes.inc.php 71 | $permissiontoadd = $user->hasRight('distributionlist', 'distributionlist', 'create'); // Used by the include of actions_addupdatedelete.inc.php 72 | 73 | 74 | 75 | /* 76 | * Actions 77 | */ 78 | 79 | include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once 80 | 81 | 82 | /* 83 | * View 84 | */ 85 | 86 | $form = new Form($db); 87 | 88 | //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; 89 | $help_url = ''; 90 | llxHeader('', $langs->trans('DistributionList'), $help_url); 91 | 92 | if ($id > 0 || !empty($ref)) 93 | { 94 | $object->fetch_thirdparty(); 95 | 96 | $head = distributionlistPrepareHead($object); 97 | 98 | dol_fiche_head($head, 'note', $langs->trans("DistributionList"), -1, $object->picto); 99 | 100 | // Object card 101 | // ------------------------------------------------------------ 102 | $linkback = ''.$langs->trans("BackToList").''; 103 | 104 | $morehtmlref = '
'; 105 | /* 106 | // Ref customer 107 | $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); 108 | $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); 109 | // Thirdparty 110 | $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); 111 | // Project 112 | if (! empty($conf->projet->enabled)) 113 | { 114 | $langs->load("projects"); 115 | $morehtmlref.='
'.$langs->trans('Project') . ' '; 116 | if ($permissiontoadd) 117 | { 118 | if ($action != 'classify') 119 | //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; 120 | $morehtmlref.=' : '; 121 | if ($action == 'classify') { 122 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 123 | $morehtmlref.='
'; 124 | $morehtmlref.=''; 125 | $morehtmlref.=''; 126 | $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 127 | $morehtmlref.=''; 128 | $morehtmlref.='
'; 129 | } else { 130 | $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 131 | } 132 | } else { 133 | if (! empty($object->fk_project)) { 134 | $proj = new Project($db); 135 | $proj->fetch($object->fk_project); 136 | $morehtmlref .= ': '.$proj->getNomUrl(); 137 | } else { 138 | $morehtmlref .= ''; 139 | } 140 | } 141 | }*/ 142 | $morehtmlref .= '
'; 143 | 144 | 145 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 146 | 147 | 148 | print '
'; 149 | print '
'; 150 | 151 | 152 | $cssclass = "titlefield"; 153 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; 154 | 155 | print '
'; 156 | 157 | dol_fiche_end(); 158 | } 159 | 160 | // End of page 161 | llxFooter(); 162 | $db->close(); 163 | -------------------------------------------------------------------------------- /core/modules/mailings/distributionlist.modules.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2005-2010 Laurent Destailleur 4 | * Copyright (C) 2005-2009 Regis Houssin 5 | * 6 | * This file is an example to follow to add your own email selector inside 7 | * the Dolibarr email tool. 8 | * Follow instructions given in README file to know what to change to build 9 | * your own emailing list selector. 10 | * Code that need to be changed in this file are marked by "CHANGE THIS" tag. 11 | */ 12 | 13 | /** 14 | * \file htdocs/core/modules/mailings/distributionlist.modules.php 15 | * \ingroup mailing 16 | * \brief Example file to provide a list of distribution list for mailing module 17 | */ 18 | 19 | include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; 20 | dol_include_once('/distributionlist/class/distributionlist.class.php'); 21 | 22 | 23 | 24 | /** 25 | * Class to manage a list of distribution list for mailing feature 26 | */ 27 | class mailing_distributionlist extends MailingTargets 28 | { 29 | public $name = 'DistributionList'; 30 | // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found 31 | public $desc = "Distribution List"; 32 | public $require_admin = 0; 33 | 34 | public $require_module = array("distributionlist"); // This module allows to select by categories must be also enabled if category module is not activated 35 | 36 | /** 37 | * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png 38 | */ 39 | public $picto = 'distributionlist@distributionlist'; 40 | 41 | /** 42 | * @var DoliDB Database handler. 43 | */ 44 | public $db; 45 | 46 | 47 | /** 48 | * Constructor 49 | * 50 | * @param DoliDB $db Database handler 51 | */ 52 | public function __construct($db) 53 | { 54 | global $conf, $langs; 55 | $langs->load("companies"); 56 | 57 | $this->db = $db; 58 | } 59 | 60 | 61 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps 62 | /** 63 | * This is the main function that returns the array of emails 64 | * 65 | * @param int $mailing_id Id of mailing. No need to use it. 66 | * @return int <0 if error, number of emails added if ok 67 | */ 68 | public function add_to_target($mailing_id) 69 | { 70 | // phpcs:enable 71 | global $conf, $langs; 72 | 73 | $cibles = array(); 74 | $this->db->begin(); 75 | $addDescription = ""; 76 | $num = 0; 77 | 78 | // Select the third parties from category 79 | if (!empty($_POST['filter_distributionlist'])) 80 | { 81 | $sql = "SELECT DISTINCT d.rowid as id, sp.email as email, sp.lastname as name, sp.rowid as fk_contact, sp.firstname as firstname"; 82 | $sql .= " FROM ".MAIN_DB_PREFIX."distributionlist_distributionlistsocpeople as ds"; 83 | $sql .= " JOIN ".MAIN_DB_PREFIX."distributionlist_distributionlist as d ON d.rowid = ds.fk_distributionlist"; 84 | $sql .= " JOIN ".MAIN_DB_PREFIX."socpeople as sp ON ds.fk_socpeople = sp.rowid"; 85 | $sql .= " WHERE sp.email <> ''"; 86 | $sql .= " AND d.entity IN (".getEntity('distributionlist').")"; 87 | $sql .= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; 88 | $sql .= " AND ds.fk_distributionlist =".$_POST["filter_distributionlist"]; 89 | $sql .= " group by email"; 90 | $res = $this->db->query($sql); 91 | if ($res) { 92 | $num = $this->db->num_rows($res); 93 | 94 | $sql = "INSERT INTO llx_mailing_cibles (fk_mailing, fk_contact, lastname, firstname, email, other, source_url, source_id, source_type)"; 95 | $sql .= " SELECT DISTINCT ".$mailing_id.", sp.rowid AS fk_contact, sp.lastname AS lastname, sp.firstname AS firstname, sp.email AS email, '',"; 96 | $sql .= " CONCAT('',sp.firstname, ' ', sp.lastname,'') as source_url,"; 97 | $sql .= " d.rowid AS source_id, 'distributionlist' as source_type"; 98 | $sql .= " FROM ".MAIN_DB_PREFIX."distributionlist_distributionlistsocpeople AS ds"; 99 | $sql .= " JOIN ".MAIN_DB_PREFIX."distributionlist_distributionlist AS d ON d.rowid = ds.fk_distributionlist"; 100 | $sql .= " JOIN ".MAIN_DB_PREFIX."socpeople AS sp ON ds.fk_socpeople = sp.rowid"; 101 | $sql .= " WHERE sp.email <> ''"; 102 | $sql .= " AND d.entity IN(".getEntity('distributionlist').")"; 103 | $sql .= " AND sp.email NOT IN(SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; 104 | $sql .= " AND ds.fk_distributionlist=".$_POST["filter_distributionlist"]; 105 | $sql .= " group by email"; 106 | 107 | $result = $this->db->query($sql); 108 | } 109 | } 110 | 111 | // Stock recipients emails into targets table 112 | if ($result) 113 | { 114 | $this->db->commit(); 115 | return $num; 116 | } 117 | else 118 | { 119 | dol_syslog($this->db->error()); 120 | $this->db->rollback(); 121 | $this->error = $this->db->error(); 122 | return -1; 123 | } 124 | 125 | //return parent::addTargetsToDatabase($mailing_id, $cibles); 126 | } 127 | 128 | 129 | /** 130 | * On the main mailing area, there is a box with statistics. 131 | * If you want to add a line in this report you must provide an 132 | * array of SQL request that returns two field: 133 | * One called "label", One called "nb". 134 | * 135 | * @return array Array with SQL requests 136 | */ 137 | public function getSqlArrayForStats() 138 | { 139 | // CHANGE THIS: Optionnal 140 | 141 | //var $statssql=array(); 142 | //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; 143 | return array(); 144 | } 145 | 146 | 147 | /** 148 | * Return here number of distinct emails returned by your selector. 149 | * For example if this selector is used to extract 500 different 150 | * emails from a text file, this function must return 500. 151 | * 152 | * @param string $sql Requete sql de comptage 153 | * @return int Nb of recipients 154 | */ 155 | public function getNbOfRecipients($sql = '') 156 | { 157 | return ''; 158 | } 159 | 160 | /** 161 | * This is to add a form filter to provide variant of selector 162 | * If used, the HTML select must be called "filter" 163 | * 164 | * @return string A html select zone 165 | */ 166 | public function formFilter() 167 | { 168 | global $conf, $langs; 169 | 170 | $langs->load("DistributionList"); 171 | 172 | $distributionlist = new DistributionList($this->db); 173 | $TDistributionList = $distributionlist->fetchAll('ASC', 'label', 0, 0, array('customsql'=> 'status IN (1,2)')); 174 | 175 | $s = ' '; 184 | 185 | return $s; 186 | } 187 | 188 | 189 | /** 190 | * Can include an URL link on each record provided by selector shown on target page. 191 | * 192 | * @param int $id ID 193 | * @return string Url link 194 | */ 195 | public function url($id, $lastname, $firstname) 196 | { 197 | return ''.$firstname.' '.$lastname .''; 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /test/phpunit/DistributionListFunctionalTest.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2021 SuperAdmin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file test/phpunit/DistributionListFunctionalTest.php 21 | * \ingroup distributionlist 22 | * \brief Example Selenium test. 23 | * 24 | * Put detailed description here. 25 | */ 26 | 27 | namespace test\functional; 28 | 29 | use PHPUnit_Extensions_Selenium2TestCase_WebDriverException; 30 | 31 | /** 32 | * Class DistributionListFunctionalTest 33 | * 34 | * Requires chromedriver for Google Chrome 35 | * Requires geckodriver for Mozilla Firefox 36 | * 37 | * @fixme Firefox (Geckodriver/Marionette) support 38 | * @todo Opera linux support 39 | * @todo Windows support (IE, Google Chrome, Mozilla Firefox, Safari) 40 | * @todo OSX support (Safari, Google Chrome, Mozilla Firefox) 41 | * 42 | * @package Testdistributionlist 43 | */ 44 | class DistributionListFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase 45 | { 46 | // TODO: move to a global configuration file? 47 | /** @var string Base URL of the webserver under test */ 48 | protected static $base_url = 'http://dev.zenfusion.fr'; 49 | /** 50 | * @var string Dolibarr admin username 51 | * @see authenticate 52 | */ 53 | protected static $dol_admin_user = 'admin'; 54 | /** 55 | * @var string Dolibarr admin password 56 | * @see authenticate 57 | */ 58 | protected static $dol_admin_pass = 'admin'; 59 | /** @var int Dolibarr module ID */ 60 | private static $module_id = 500000; // TODO: autodetect? 61 | 62 | /** @var array Browsers to test with */ 63 | public static $browsers = array( 64 | array( 65 | 'browser' => 'Google Chrome on Linux', 66 | 'browserName' => 'chrome', 67 | 'sessionStrategy' => 'shared', 68 | 'desiredCapabilities' => array() 69 | ), 70 | // Geckodriver does not keep the session at the moment?! 71 | // XPath selectors also don't seem to work 72 | //array( 73 | // 'browser' => 'Mozilla Firefox on Linux', 74 | // 'browserName' => 'firefox', 75 | // 'sessionStrategy' => 'shared', 76 | // 'desiredCapabilities' => array( 77 | // 'marionette' => true, 78 | // ), 79 | //) 80 | ); 81 | 82 | /** 83 | * Helper function to select links by href 84 | * 85 | * @param string $value Href 86 | * @return mixed Helper string 87 | */ 88 | protected function byHref($value) 89 | { 90 | $anchor = null; 91 | $anchors = $this->elements($this->using('tag name')->value('a')); 92 | foreach ($anchors as $anchor) { 93 | if (strstr($anchor->attribute('href'), $value)) { 94 | break; 95 | } 96 | } 97 | return $anchor; 98 | } 99 | 100 | /** 101 | * Global test setup 102 | * @return void 103 | */ 104 | public static function setUpBeforeClass() 105 | { 106 | } 107 | 108 | /** 109 | * Unit test setup 110 | * @return void 111 | */ 112 | public function setUp() 113 | { 114 | $this->setSeleniumServerRequestsTimeout(3600); 115 | $this->setBrowserUrl(self::$base_url); 116 | } 117 | 118 | /** 119 | * Verify pre conditions 120 | * @return void 121 | */ 122 | protected function assertPreConditions() 123 | { 124 | } 125 | 126 | /** 127 | * Handle Dolibarr authentication 128 | * @return void 129 | */ 130 | private function authenticate() 131 | { 132 | try { 133 | if ($this->byId('login')) { 134 | $login = $this->byId('username'); 135 | $login->clear(); 136 | $login->value('admin'); 137 | $password = $this->byId('password'); 138 | $password->clear(); 139 | $password->value('admin'); 140 | $this->byId('login')->submit(); 141 | } 142 | } catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { 143 | // Login does not exist. Assume we are already authenticated 144 | } 145 | } 146 | 147 | /** 148 | * Test enabling developer mode 149 | * @return bool 150 | */ 151 | public function testEnableDeveloperMode() 152 | { 153 | $this->url('/admin/const.php'); 154 | $this->authenticate(); 155 | $main_features_level_path = '//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]'; 156 | $main_features_level = $this->byXPath($main_features_level_path); 157 | $main_features_level->clear(); 158 | $main_features_level->value('2'); 159 | $this->byName('update')->click(); 160 | // Page reloaded, we need a new XPath 161 | $main_features_level = $this->byXPath($main_features_level_path); 162 | return $this->assertEquals('2', $main_features_level->value(), "MAIN_FEATURES_LEVEL value is 2"); 163 | } 164 | 165 | /** 166 | * Test enabling the module 167 | * 168 | * @depends testEnableDeveloperMode 169 | * @return bool 170 | */ 171 | public function testModuleEnabled() 172 | { 173 | $this->url('/admin/modules.php'); 174 | $this->authenticate(); 175 | $module_status_image_path = '//a[contains(@href, "'.self::$module_id.'")]/img'; 176 | $module_status_image = $this->byXPath($module_status_image_path); 177 | if (strstr($module_status_image->attribute('src'), 'switch_off.png')) { 178 | // Enable the module 179 | $this->byHref('modDistributionList')->click(); 180 | } else { 181 | // Disable the module 182 | $this->byHref('modDistributionList')->click(); 183 | // Reenable the module 184 | $this->byHref('modDistributionList')->click(); 185 | } 186 | // Page reloaded, we need a new Xpath 187 | $module_status_image = $this->byXPath($module_status_image_path); 188 | return $this->assertContains('switch_on.png', $module_status_image->attribute('src'), "Module enabled"); 189 | } 190 | 191 | /** 192 | * Test access to the configuration page 193 | * 194 | * @depends testModuleEnabled 195 | * @return bool 196 | */ 197 | public function testConfigurationPage() 198 | { 199 | $this->url('/custom/distributionlist/admin/setup.php'); 200 | $this->authenticate(); 201 | return $this->assertContains('distributionlist/admin/setup.php', $this->url(), 'Configuration page'); 202 | } 203 | 204 | /** 205 | * Test access to the about page 206 | * 207 | * @depends testConfigurationPage 208 | * @return bool 209 | */ 210 | public function testAboutPage() 211 | { 212 | $this->url('/custom/distributionlist/admin/about.php'); 213 | $this->authenticate(); 214 | return $this->assertContains('distributionlist/admin/about.php', $this->url(), 'About page'); 215 | } 216 | 217 | /** 218 | * Test about page is rendering Markdown 219 | * 220 | * @depends testAboutPage 221 | * @return bool 222 | */ 223 | public function testAboutPageRendersMarkdownReadme() 224 | { 225 | $this->url('/custom/distributionlist/admin/about.php'); 226 | $this->authenticate(); 227 | return $this->assertEquals( 228 | 'Dolibarr Module Template (aka My Module)', 229 | $this->byTag('h1')->text(), 230 | "Readme title" 231 | ); 232 | } 233 | 234 | /** 235 | * Test box is properly declared 236 | * 237 | * @depends testModuleEnabled 238 | * @return bool 239 | */ 240 | public function testBoxDeclared() 241 | { 242 | $this->url('/admin/boxes.php'); 243 | $this->authenticate(); 244 | return $this->assertContains('distributionlistwidget1', $this->source(), "Box enabled"); 245 | } 246 | 247 | /** 248 | * Test trigger is properly enabled 249 | * 250 | * @depends testModuleEnabled 251 | * @return bool 252 | */ 253 | public function testTriggerDeclared() 254 | { 255 | $this->url('/admin/triggers.php'); 256 | $this->authenticate(); 257 | return $this->assertContains( 258 | 'interface_99_modDistributionList_DistributionListTriggers.class.php', 259 | $this->byTag('body')->text(), 260 | "Trigger declared" 261 | ); 262 | } 263 | 264 | /** 265 | * Test trigger is properly declared 266 | * 267 | * @depends testTriggerDeclared 268 | * @return bool 269 | */ 270 | public function testTriggerEnabled() 271 | { 272 | $this->url('/admin/triggers.php'); 273 | $this->authenticate(); 274 | return $this->assertContains( 275 | 'tick.png', 276 | $this->byXPath('//td[text()="interface_99_modDistributionList_MyTrigger.class.php"]/following::img')->attribute('src'), 277 | "Trigger enabled" 278 | ); 279 | } 280 | 281 | /** 282 | * Verify post conditions 283 | * @return void 284 | */ 285 | protected function assertPostConditions() 286 | { 287 | } 288 | 289 | /** 290 | * Unit test teardown 291 | * @return void 292 | */ 293 | public function tearDown() 294 | { 295 | } 296 | 297 | /** 298 | * Global test teardown 299 | * @return void 300 | */ 301 | public static function tearDownAfterClass() 302 | { 303 | } 304 | } 305 | -------------------------------------------------------------------------------- /distributionlistindex.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2004-2015 Laurent Destailleur 4 | * Copyright (C) 2005-2012 Regis Houssin 5 | * Copyright (C) 2015 Jean-François Ferry 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | /** 22 | * \file distributionlist/distributionlistindex.php 23 | * \ingroup distributionlist 24 | * \brief Home page of distributionlist top menu 25 | */ 26 | 27 | // Load Dolibarr environment 28 | $res = 0; 29 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 30 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 31 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 32 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 33 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 34 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 35 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 36 | // Try main.inc.php using relative path 37 | if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; 38 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 39 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 40 | if (!$res) die("Include of main fails"); 41 | 42 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 43 | 44 | // Load translation files required by the page 45 | $langs->loadLangs(array("distributionlist@distributionlist")); 46 | 47 | $action = GETPOST('action', 'alpha'); 48 | 49 | 50 | // Security check 51 | //if (! $user->rights->distributionlist->myobject->read) accessforbidden(); 52 | $socid = GETPOST('socid', 'int'); 53 | if (isset($user->socid) && $user->socid > 0) 54 | { 55 | $action = ''; 56 | $socid = $user->socid; 57 | } 58 | 59 | $max = 5; 60 | $now = dol_now(); 61 | 62 | 63 | /* 64 | * Actions 65 | */ 66 | 67 | // None 68 | 69 | 70 | /* 71 | * View 72 | */ 73 | 74 | $form = new Form($db); 75 | $formfile = new FormFile($db); 76 | 77 | llxHeader("", $langs->trans("DistributionListArea")); 78 | 79 | print load_fiche_titre($langs->trans("DistributionListArea"), '', 'distributionlist.png@distributionlist'); 80 | 81 | print '
'; 82 | 83 | 84 | /* BEGIN MODULEBUILDER DRAFT MYOBJECT 85 | // Draft MyObject 86 | if (! empty($conf->distributionlist->enabled) && $user->rights->distributionlist->read) 87 | { 88 | $langs->load("orders"); 89 | 90 | $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; 91 | $sql.= ", s.code_client"; 92 | $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; 93 | $sql.= ", ".MAIN_DB_PREFIX."societe as s"; 94 | if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; 95 | $sql.= " WHERE c.fk_soc = s.rowid"; 96 | $sql.= " AND c.fk_statut = 0"; 97 | $sql.= " AND c.entity IN (".getEntity('commande').")"; 98 | if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; 99 | if ($socid) $sql.= " AND c.fk_soc = ".$socid; 100 | 101 | $resql = $db->query($sql); 102 | if ($resql) 103 | { 104 | $total = 0; 105 | $num = $db->num_rows($resql); 106 | 107 | print ''; 108 | print ''; 109 | print ''; 110 | 111 | $var = true; 112 | if ($num > 0) 113 | { 114 | $i = 0; 115 | while ($i < $num) 116 | { 117 | 118 | $obj = $db->fetch_object($resql); 119 | print ''; 128 | print ''; 137 | print ''; 138 | $i++; 139 | $total += $obj->total_ttc; 140 | } 141 | if ($total>0) 142 | { 143 | 144 | print '"; 145 | } 146 | } 147 | else 148 | { 149 | 150 | print ''; 151 | } 152 | print "
'.$langs->trans("DraftOrders").($num?''.$num.'':'').'
'; 120 | $orderstatic->id=$obj->rowid; 121 | $orderstatic->ref=$obj->ref; 122 | $orderstatic->ref_client=$obj->ref_client; 123 | $orderstatic->total_ht = $obj->total_ht; 124 | $orderstatic->total_tva = $obj->total_tva; 125 | $orderstatic->total_ttc = $obj->total_ttc; 126 | print $orderstatic->getNomUrl(1); 127 | print ''; 129 | $companystatic->id=$obj->socid; 130 | $companystatic->name=$obj->name; 131 | $companystatic->client=$obj->client; 132 | $companystatic->code_client = $obj->code_client; 133 | $companystatic->code_fournisseur = $obj->code_fournisseur; 134 | $companystatic->canvas=$obj->canvas; 135 | print $companystatic->getNomUrl(1,'customer',16); 136 | print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoOrder").'

"; 153 | 154 | $db->free($resql); 155 | } 156 | else 157 | { 158 | dol_print_error($db); 159 | } 160 | } 161 | END MODULEBUILDER DRAFT MYOBJECT */ 162 | 163 | 164 | print '
'; 165 | 166 | 167 | $NBMAX = 3; 168 | $max = 3; 169 | 170 | /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT 171 | // Last modified myobject 172 | if (! empty($conf->distributionlist->enabled) && $user->rights->distributionlist->read) 173 | { 174 | $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; 175 | $sql.= ", s.code_client"; 176 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; 177 | if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; 178 | $sql.= " WHERE s.client IN (1, 2, 3)"; 179 | $sql.= " AND s.entity IN (".getEntity($companystatic->element).")"; 180 | if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; 181 | if ($socid) $sql.= " AND s.rowid = $socid"; 182 | $sql .= " ORDER BY s.tms DESC"; 183 | $sql .= $db->plimit($max, 0); 184 | 185 | $resql = $db->query($sql); 186 | if ($resql) 187 | { 188 | $num = $db->num_rows($resql); 189 | $i = 0; 190 | 191 | print ''; 192 | print ''; 193 | print ''; 198 | print ''; 199 | print ''; 200 | if ($num) 201 | { 202 | while ($i < $num) 203 | { 204 | $objp = $db->fetch_object($resql); 205 | $companystatic->id=$objp->rowid; 206 | $companystatic->name=$objp->name; 207 | $companystatic->client=$objp->client; 208 | $companystatic->code_client = $objp->code_client; 209 | $companystatic->code_fournisseur = $objp->code_fournisseur; 210 | $companystatic->canvas=$objp->canvas; 211 | print ''; 212 | print ''; 213 | print '"; 216 | print '"; 217 | print ''; 218 | $i++; 219 | 220 | 221 | } 222 | 223 | $db->free($resql); 224 | } 225 | else 226 | { 227 | print ''; 228 | } 229 | print "
'; 194 | if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max); 195 | else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max); 196 | else print $langs->trans("BoxTitleLastModifiedCustomers",$max); 197 | print ''.$langs->trans("DateModificationShort").'
'.$companystatic->getNomUrl(1,'customer',48).''; 214 | print $companystatic->getLibCustProspStatut(); 215 | print "'.dol_print_date($db->jdate($objp->tms),'day')."
'.$langs->trans("None").'

"; 230 | } 231 | } 232 | */ 233 | 234 | print '
'; 235 | 236 | // End of page 237 | llxFooter(); 238 | $db->close(); 239 | -------------------------------------------------------------------------------- /distributionlist_document.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) ---Put here your own copyright and developer email--- 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file distributionlist_document.php 21 | * \ingroup distributionlist 22 | * \brief Tab for documents linked to DistributionList 23 | */ 24 | 25 | // Load Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; 36 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38 | if (!$res) die("Include of main fails"); 39 | 40 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 41 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 42 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; 43 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 44 | dol_include_once('/distributionlist/class/distributionlist.class.php'); 45 | dol_include_once('/distributionlist/lib/distributionlist_distributionlist.lib.php'); 46 | 47 | // Load translation files required by the page 48 | $langs->loadLangs(array("distributionlist@distributionlist", "companies", "other", "mails")); 49 | 50 | 51 | $action = GETPOST('action', 'aZ09'); 52 | $confirm = GETPOST('confirm'); 53 | $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); 54 | $ref = GETPOST('ref', 'alpha'); 55 | 56 | // Get parameters 57 | $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; 58 | $sortfield = GETPOST("sortfield", 'alpha'); 59 | $sortorder = GETPOST("sortorder", 'alpha'); 60 | $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 61 | if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 62 | if (!empty($liste_limit) && intval($liste_limit) > 0) $offset = $liste_limit * $page; 63 | $pageprev = $page - 1; 64 | $pagenext = $page + 1; 65 | if (!$sortorder) $sortorder = "ASC"; 66 | if (!$sortfield) $sortfield = "name"; 67 | //if (! $sortfield) $sortfield="position_name"; 68 | 69 | // Initialize technical objects 70 | $object = new DistributionList($db); 71 | $extrafields = new ExtraFields($db); 72 | $diroutputmassaction = $conf->distributionlist->dir_output.'/temp/massgeneration/'.$user->id; 73 | $hookmanager->initHooks(array('distributionlistdocument', 'globalcard')); // Note that conf->hooks_modules contains array 74 | // Fetch optionals attributes and labels 75 | $extrafields->fetch_name_optionals_label($object->table_element); 76 | 77 | // Load object 78 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals 79 | 80 | //if ($id > 0 || ! empty($ref)) $upload_dir = $conf->distributionlist->multidir_output[$object->entity?$object->entity:$conf->entity] . "/distributionlist/" . dol_sanitizeFileName($object->id); 81 | if ($id > 0 || !empty($ref)) $upload_dir = $conf->distributionlist->multidir_output[$object->entity ? $object->entity : $conf->entity]."/distributionlist/".dol_sanitizeFileName($object->ref); 82 | 83 | // Security check - Protection if external user 84 | //if ($user->socid > 0) accessforbidden(); 85 | //if ($user->socid > 0) $socid = $user->socid; 86 | //$result = restrictedArea($user, 'distributionlist', $object->id); 87 | 88 | $permissiontoadd = $user->hasRight('distributionlist', 'distributionlist', 'create'); // Used by the include of actions_addupdatedelete.inc.php 89 | 90 | 91 | 92 | /* 93 | * Actions 94 | */ 95 | 96 | include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; 97 | 98 | 99 | /* 100 | * View 101 | */ 102 | 103 | $form = new Form($db); 104 | 105 | $title = $langs->trans("DistributionList").' - '.$langs->trans("Files"); 106 | $help_url = ''; 107 | //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; 108 | llxHeader('', $title, $help_url); 109 | 110 | if ($object->id) 111 | { 112 | /* 113 | * Show tabs 114 | */ 115 | $head = distributionlistPrepareHead($object); 116 | 117 | dol_fiche_head($head, 'document', $langs->trans("DistributionList"), -1, $object->picto); 118 | 119 | 120 | // Build file list 121 | $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); 122 | $totalsize = 0; 123 | foreach ($filearray as $key => $file) 124 | { 125 | $totalsize += $file['size']; 126 | } 127 | 128 | // Object card 129 | // ------------------------------------------------------------ 130 | $linkback = ''.$langs->trans("BackToList").''; 131 | 132 | $morehtmlref = '
'; 133 | /* 134 | // Ref customer 135 | $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); 136 | $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); 137 | // Thirdparty 138 | $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); 139 | // Project 140 | if (! empty($conf->projet->enabled)) 141 | { 142 | $langs->load("projects"); 143 | $morehtmlref.='
'.$langs->trans('Project') . ' '; 144 | if ($permissiontoadd) 145 | { 146 | if ($action != 'classify') 147 | //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; 148 | $morehtmlref.=' : '; 149 | if ($action == 'classify') { 150 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 151 | $morehtmlref.='
'; 152 | $morehtmlref.=''; 153 | $morehtmlref.=''; 154 | $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 155 | $morehtmlref.=''; 156 | $morehtmlref.='
'; 157 | } else { 158 | $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 159 | } 160 | } else { 161 | if (! empty($object->fk_project)) { 162 | $proj = new Project($db); 163 | $proj->fetch($object->fk_project); 164 | $morehtmlref .= ': '.$proj->getNomUrl(); 165 | } else { 166 | $morehtmlref .= ''; 167 | } 168 | } 169 | }*/ 170 | $morehtmlref .= '
'; 171 | 172 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 173 | 174 | print '
'; 175 | 176 | print '
'; 177 | print ''; 178 | 179 | // Number of files 180 | print ''; 181 | 182 | // Total size 183 | print ''; 184 | 185 | print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; 186 | 187 | print '
'; 188 | 189 | dol_fiche_end(); 190 | 191 | $modulepart = 'distributionlist'; 192 | $permission = $user->hasRight('distributionlist', 'distributionlist', 'create'); 193 | // $permission = 1; 194 | $permtoedit = $user->hasRight('distributionlist', 'distributionlist', 'create'); 195 | // $permtoedit = 1; 196 | $param = '&id=' . $object->id; 197 | 198 | 199 | //$relativepathwithnofile='distributionlist/' . dol_sanitizeFileName($object->id).'/'; 200 | $relativepathwithnofile = 'distributionlist/'.dol_sanitizeFileName($object->ref).'/'; 201 | 202 | include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; 203 | } 204 | else 205 | { 206 | accessforbidden('', 0, 1); 207 | } 208 | 209 | // End of page 210 | llxFooter(); 211 | $db->close(); 212 | -------------------------------------------------------------------------------- /core/triggers/interface_99_moddistributionlist_distributionlisttrigger.class.php: -------------------------------------------------------------------------------- 1 | . 16 | */ 17 | 18 | require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; 19 | dol_include_once('/distributionlist/class/distributionlist.class.php'); 20 | dol_include_once('/distributionlist/class/distributionlistsocpeople.class.php'); 21 | 22 | /** 23 | * Class of triggers for Distributionlist module 24 | */ 25 | class InterfaceDistributionlisttrigger extends DolibarrTriggers 26 | { 27 | /** 28 | * Constructor 29 | * 30 | * @param DoliDB $db Database handler 31 | */ 32 | public function __construct($db) 33 | { 34 | $this->db = $db; 35 | 36 | $this->name = preg_replace('/^Interface/i', '', get_class($this)); 37 | $this->family = "demo"; 38 | $this->description = "Distributionlist triggers."; 39 | // 'development', 'experimental', 'dolibarr' or version 40 | $this->version = 'development'; 41 | $this->picto = 'distributionlist@distributionlist'; 42 | } 43 | 44 | /** 45 | * Trigger name 46 | * 47 | * @return string Name of trigger file 48 | */ 49 | public function getName() 50 | { 51 | return $this->name; 52 | } 53 | 54 | /** 55 | * Trigger description 56 | * 57 | * @return string Description of trigger file 58 | */ 59 | public function getDesc() 60 | { 61 | return $this->description; 62 | } 63 | 64 | 65 | /** 66 | * Function called when a Dolibarrr business event is done. 67 | * All functions "runTrigger" are triggered if file 68 | * is inside directory core/triggers 69 | * 70 | * @param string $action Event action code 71 | * @param CommonObject $object Object 72 | * @param User $user Object user 73 | * @param Translate $langs Object langs 74 | * @param Conf $conf Object conf 75 | * @return int <0 if KO, 0 if no triggered ran, >0 if OK 76 | */ 77 | public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) 78 | { 79 | if (empty($conf->distributionlist) || !isModEnabled('distributionlist')) { 80 | return 0; // If module is not enabled, we do nothing 81 | } 82 | 83 | // Put here code you want to execute when a Dolibarr business events occurs. 84 | // Data and type of action are stored into $object and $action 85 | 86 | // You can isolate code for each action in a separate method: this method should be named like the trigger in camelCase. 87 | // For example : COMPANY_CREATE => public function companyCreate($action, $object, User $user, Translate $langs, Conf $conf) 88 | $methodName = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($action))))); 89 | $callback = array($this, $methodName); 90 | if (is_callable($callback)) { 91 | dol_syslog( 92 | "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id 93 | ); 94 | 95 | return call_user_func($callback, $action, $object, $user, $langs, $conf); 96 | }; 97 | 98 | // Or you can execute some code here 99 | switch ($action) { 100 | // Users 101 | //case 'USER_CREATE': 102 | //case 'USER_MODIFY': 103 | //case 'USER_NEW_PASSWORD': 104 | //case 'USER_ENABLEDISABLE': 105 | //case 'USER_DELETE': 106 | 107 | // Actions 108 | //case 'ACTION_MODIFY': 109 | //case 'ACTION_CREATE': 110 | //case 'ACTION_DELETE': 111 | 112 | // Groups 113 | //case 'USERGROUP_CREATE': 114 | //case 'USERGROUP_MODIFY': 115 | //case 'USERGROUP_DELETE': 116 | 117 | // Companies 118 | //case 'COMPANY_CREATE': 119 | //case 'COMPANY_MODIFY': 120 | //case 'COMPANY_DELETE': 121 | 122 | // Contacts 123 | //case 'CONTACT_CREATE': 124 | //case 'CONTACT_MODIFY': 125 | case 'CONTACT_DELETE': 126 | 127 | //Si le contact est dans une ou plusieurs listes de diffusion, alors, lors de sa suppression, on le décompte dans le nombre de contacts 128 | $this->db->begin(); 129 | 130 | $error = 0; 131 | $sql = "SELECT fk_distributionlist FROM ".MAIN_DB_PREFIX."distributionlist_distributionlistsocpeople WHERE fk_socpeople = " .intval($object->id); 132 | $resql = $this->db->query($sql); 133 | if($resql){ 134 | while($obj = $this->db->fetch_object($resql)) { 135 | $distributionList = new DistributionList($this->db); 136 | $res = $distributionList->fetch($obj->fk_distributionlist); 137 | if ($res) { 138 | $distributionList->nb_contacts--; 139 | $distributionList->update($user); 140 | 141 | $distributionListSocpeople = new DistributionListSocpeople($this->db); 142 | $distributionListSocpeople->deleteByContact($object->id); 143 | } 144 | } 145 | } else { 146 | $error++; 147 | } 148 | 149 | if(!$error){ 150 | $this->db->commit(); 151 | } else { 152 | $this->db->rollback(); 153 | } 154 | 155 | //case 'CONTACT_ENABLEDISABLE': 156 | 157 | // Products 158 | //case 'PRODUCT_CREATE': 159 | //case 'PRODUCT_MODIFY': 160 | //case 'PRODUCT_DELETE': 161 | //case 'PRODUCT_PRICE_MODIFY': 162 | //case 'PRODUCT_SET_MULTILANGS': 163 | //case 'PRODUCT_DEL_MULTILANGS': 164 | 165 | //Stock mouvement 166 | //case 'STOCK_MOVEMENT': 167 | 168 | //MYECMDIR 169 | //case 'MYECMDIR_CREATE': 170 | //case 'MYECMDIR_MODIFY': 171 | //case 'MYECMDIR_DELETE': 172 | 173 | // Customer orders 174 | //case 'ORDER_CREATE': 175 | //case 'ORDER_MODIFY': 176 | //case 'ORDER_VALIDATE': 177 | //case 'ORDER_DELETE': 178 | //case 'ORDER_CANCEL': 179 | //case 'ORDER_SENTBYMAIL': 180 | //case 'ORDER_CLASSIFY_BILLED': 181 | //case 'ORDER_SETDRAFT': 182 | //case 'LINEORDER_INSERT': 183 | //case 'LINEORDER_UPDATE': 184 | //case 'LINEORDER_DELETE': 185 | 186 | // Supplier orders 187 | //case 'ORDER_SUPPLIER_CREATE': 188 | //case 'ORDER_SUPPLIER_MODIFY': 189 | //case 'ORDER_SUPPLIER_VALIDATE': 190 | //case 'ORDER_SUPPLIER_DELETE': 191 | //case 'ORDER_SUPPLIER_APPROVE': 192 | //case 'ORDER_SUPPLIER_REFUSE': 193 | //case 'ORDER_SUPPLIER_CANCEL': 194 | //case 'ORDER_SUPPLIER_SENTBYMAIL': 195 | //case 'ORDER_SUPPLIER_DISPATCH': 196 | //case 'LINEORDER_SUPPLIER_DISPATCH': 197 | //case 'LINEORDER_SUPPLIER_CREATE': 198 | //case 'LINEORDER_SUPPLIER_UPDATE': 199 | //case 'LINEORDER_SUPPLIER_DELETE': 200 | 201 | // Proposals 202 | //case 'PROPAL_CREATE': 203 | //case 'PROPAL_MODIFY': 204 | //case 'PROPAL_VALIDATE': 205 | //case 'PROPAL_SENTBYMAIL': 206 | //case 'PROPAL_CLOSE_SIGNED': 207 | //case 'PROPAL_CLOSE_REFUSED': 208 | //case 'PROPAL_DELETE': 209 | //case 'LINEPROPAL_INSERT': 210 | //case 'LINEPROPAL_UPDATE': 211 | //case 'LINEPROPAL_DELETE': 212 | 213 | // SupplierProposal 214 | //case 'SUPPLIER_PROPOSAL_CREATE': 215 | //case 'SUPPLIER_PROPOSAL_MODIFY': 216 | //case 'SUPPLIER_PROPOSAL_VALIDATE': 217 | //case 'SUPPLIER_PROPOSAL_SENTBYMAIL': 218 | //case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED': 219 | //case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED': 220 | //case 'SUPPLIER_PROPOSAL_DELETE': 221 | //case 'LINESUPPLIER_PROPOSAL_INSERT': 222 | //case 'LINESUPPLIER_PROPOSAL_UPDATE': 223 | //case 'LINESUPPLIER_PROPOSAL_DELETE': 224 | 225 | // Contracts 226 | // case 'CONTRACT_CREATE': 227 | 228 | //case 'CONTRACT_MODIFY': 229 | //case 'CONTRACT_ACTIVATE': 230 | //case 'CONTRACT_CANCEL': 231 | //case 'CONTRACT_CLOSE': 232 | // case 'CONTRACT_DELETE': 233 | 234 | 235 | //case 'LINECONTRACT_INSERT': 236 | //case 'LINECONTRACT_UPDATE': 237 | //case 'LINECONTRACT_DELETE': 238 | 239 | // Bills 240 | //case 'BILL_CREATE': 241 | //case 'BILL_MODIFY': 242 | //case 'BILL_VALIDATE': 243 | //case 'BILL_UNVALIDATE': 244 | //case 'BILL_SENTBYMAIL': 245 | //case 'BILL_CANCEL': 246 | //case 'BILL_DELETE': 247 | //case 'BILL_PAYED': 248 | //case 'LINEBILL_INSERT': 249 | //case 'LINEBILL_UPDATE': 250 | //case 'LINEBILL_DELETE': 251 | 252 | //Supplier Bill 253 | //case 'BILL_SUPPLIER_CREATE': 254 | //case 'BILL_SUPPLIER_UPDATE': 255 | //case 'BILL_SUPPLIER_DELETE': 256 | //case 'BILL_SUPPLIER_PAYED': 257 | //case 'BILL_SUPPLIER_UNPAYED': 258 | //case 'BILL_SUPPLIER_VALIDATE': 259 | //case 'BILL_SUPPLIER_UNVALIDATE': 260 | //case 'LINEBILL_SUPPLIER_CREATE': 261 | //case 'LINEBILL_SUPPLIER_UPDATE': 262 | //case 'LINEBILL_SUPPLIER_DELETE': 263 | 264 | // Payments 265 | //case 'PAYMENT_CUSTOMER_CREATE': 266 | //case 'PAYMENT_SUPPLIER_CREATE': 267 | //case 'PAYMENT_ADD_TO_BANK': 268 | //case 'PAYMENT_DELETE': 269 | 270 | // Online 271 | //case 'PAYMENT_PAYBOX_OK': 272 | //case 'PAYMENT_PAYPAL_OK': 273 | //case 'PAYMENT_STRIPE_OK': 274 | 275 | // Donation 276 | //case 'DON_CREATE': 277 | //case 'DON_UPDATE': 278 | //case 'DON_DELETE': 279 | 280 | // Interventions 281 | //case 'FICHINTER_CREATE': 282 | //case 'FICHINTER_MODIFY': 283 | //case 'FICHINTER_VALIDATE': 284 | //case 'FICHINTER_DELETE': 285 | //case 'LINEFICHINTER_CREATE': 286 | //case 'LINEFICHINTER_UPDATE': 287 | //case 'LINEFICHINTER_DELETE': 288 | 289 | // Members 290 | //case 'MEMBER_CREATE': 291 | //case 'MEMBER_VALIDATE': 292 | //case 'MEMBER_SUBSCRIPTION': 293 | //case 'MEMBER_MODIFY': 294 | //case 'MEMBER_NEW_PASSWORD': 295 | //case 'MEMBER_RESILIATE': 296 | //case 'MEMBER_DELETE': 297 | 298 | // Categories 299 | //case 'CATEGORY_CREATE': 300 | //case 'CATEGORY_MODIFY': 301 | //case 'CATEGORY_DELETE': 302 | //case 'CATEGORY_SET_MULTILANGS': 303 | 304 | // Projects 305 | //case 'PROJECT_CREATE': 306 | //case 'PROJECT_MODIFY': 307 | //case 'PROJECT_DELETE': 308 | 309 | // Project tasks 310 | //case 'TASK_CREATE': 311 | //case 'TASK_MODIFY': 312 | //case 'TASK_DELETE': 313 | 314 | // Task time spent 315 | //case 'TASK_TIMESPENT_CREATE': 316 | //case 'TASK_TIMESPENT_MODIFY': 317 | //case 'TASK_TIMESPENT_DELETE': 318 | //case 'PROJECT_ADD_CONTACT': 319 | //case 'PROJECT_DELETE_CONTACT': 320 | //case 'PROJECT_DELETE_RESOURCE': 321 | 322 | // Shipping 323 | //case 'SHIPPING_CREATE': 324 | //case 'SHIPPING_MODIFY': 325 | //case 'SHIPPING_VALIDATE': 326 | //case 'SHIPPING_SENTBYMAIL': 327 | //case 'SHIPPING_BILLED': 328 | //case 'SHIPPING_CLOSED': 329 | //case 'SHIPPING_REOPEN': 330 | //case 'SHIPPING_DELETE': 331 | 332 | // and more... 333 | 334 | default: 335 | dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); 336 | break; 337 | } 338 | 339 | return 0; 340 | } 341 | } 342 | -------------------------------------------------------------------------------- /distributionlist_agenda.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) ---Put here your own copyright and developer email--- 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file distributionlist_agenda.php 21 | * \ingroup distributionlist 22 | * \brief Page of DistributionList events 23 | */ 24 | 25 | // Load Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; 36 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38 | if (!$res) die("Include of main fails"); 39 | 40 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; 41 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 42 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 43 | dol_include_once('/distributionlist/class/distributionlist.class.php'); 44 | dol_include_once('/distributionlist/lib/distributionlist_distributionlist.lib.php'); 45 | 46 | 47 | // Load translation files required by the page 48 | $langs->loadLangs(array("distributionlist@distributionlist", "other")); 49 | 50 | // Get parameters 51 | $id = GETPOST('id', 'int'); 52 | $ref = GETPOST('ref', 'alpha'); 53 | $action = GETPOST('action', 'alpha'); 54 | $cancel = GETPOST('cancel', 'aZ09'); 55 | $backtopage = GETPOST('backtopage', 'alpha'); 56 | 57 | if (GETPOST('actioncode', 'array')) { 58 | $actioncode = GETPOST('actioncode', 'array', 3); 59 | if (!count($actioncode)) $actioncode = '0'; 60 | } else { 61 | $postedActionCode = GETPOST("actioncode", "alpha", 3); 62 | $rawActionCode = GETPOST("actioncode", "alpha"); 63 | $defaultFilter = getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'); 64 | if ($postedActionCode !== '') { 65 | $actioncode = $postedActionCode; 66 | } elseif ($rawActionCode === '0') { 67 | $actioncode = '0'; 68 | } elseif ($defaultFilter !== '') { 69 | $actioncode = ''; 70 | } else { 71 | $actioncode = $defaultFilter; 72 | } 73 | } 74 | $search_agenda_label = GETPOST('search_agenda_label', 'alpha'); 75 | 76 | $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; 77 | $sortfield = GETPOST("sortfield", 'alpha'); 78 | $sortorder = GETPOST("sortorder", 'alpha'); 79 | $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 80 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 81 | $offset = $limit * $page; 82 | $pageprev = $page - 1; 83 | $pagenext = $page + 1; 84 | if (!$sortfield) $sortfield = 'a.datep,a.id'; 85 | if (!$sortorder) $sortorder = 'DESC,DESC'; 86 | 87 | // Initialize technical objects 88 | $object = new DistributionList($db); 89 | $extrafields = new ExtraFields($db); 90 | $diroutputmassaction = $conf->distributionlist->dir_output.'/temp/massgeneration/'.$user->id; 91 | $hookmanager->initHooks(array('distributionlistagenda', 'globalcard')); // Note that conf->hooks_modules contains array 92 | // Fetch optionals attributes and labels 93 | $extrafields->fetch_name_optionals_label($object->table_element); 94 | 95 | // Load object 96 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals 97 | if (array_key_exists('$object->entity', $conf->distributionlist->multidir_output) && $id > 0 || !empty($ref)) { 98 | $upload_dir = $conf->distributionlist->multidir_output[$object->entity]."/".$object->id; 99 | } 100 | 101 | // Security check - Protection if external user 102 | //if ($user->socid > 0) accessforbidden(); 103 | //if ($user->socid > 0) $socid = $user->socid; 104 | //$result = restrictedArea($user, 'distributionlist', $object->id); 105 | 106 | $permissiontoadd = $user->hasRight('distributionlist', 'distributionlist', 'create'); // Used by the include of actions_addupdatedelete.inc.php 107 | 108 | 109 | /* 110 | * Actions 111 | */ 112 | 113 | $parameters = array('id'=>$id); 114 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 115 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 116 | 117 | if (empty($reshook)) 118 | { 119 | // Cancel 120 | if (GETPOST('cancel', 'alpha') && !empty($backtopage)) 121 | { 122 | header("Location: ".$backtopage); 123 | exit; 124 | } 125 | 126 | // Purge search criteria 127 | if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers 128 | { 129 | $actioncode = ''; 130 | $search_agenda_label = ''; 131 | } 132 | } 133 | 134 | 135 | 136 | /* 137 | * View 138 | */ 139 | 140 | $form = new Form($db); 141 | 142 | if ($object->id > 0) 143 | { 144 | $title = $langs->trans("Agenda"); 145 | //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; 146 | $help_url = ''; 147 | llxHeader('', $title, $help_url); 148 | 149 | if (isModEnabled('notification')) $langs->load("mails"); 150 | $head = distributionlistPrepareHead($object); 151 | 152 | 153 | dol_fiche_head($head, 'agenda', $langs->trans("DistributionList"), -1, $object->picto); 154 | 155 | // Object card 156 | // ------------------------------------------------------------ 157 | $linkback = ''.$langs->trans("BackToList").''; 158 | 159 | $morehtmlref = '
'; 160 | /* 161 | // Ref customer 162 | $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); 163 | $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); 164 | // Thirdparty 165 | $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); 166 | // Project 167 | if (! empty($conf->projet->enabled)) 168 | { 169 | $langs->load("projects"); 170 | $morehtmlref.='
'.$langs->trans('Project') . ' '; 171 | if ($permissiontoadd) 172 | { 173 | if ($action != 'classify') 174 | //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; 175 | $morehtmlref.=' : '; 176 | if ($action == 'classify') { 177 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 178 | $morehtmlref.='
'; 179 | $morehtmlref.=''; 180 | $morehtmlref.=''; 181 | $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 182 | $morehtmlref.=''; 183 | $morehtmlref.='
'; 184 | } else { 185 | $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 186 | } 187 | } else { 188 | if (! empty($object->fk_project)) { 189 | $proj = new Project($db); 190 | $proj->fetch($object->fk_project); 191 | $morehtmlref .= ': '.$proj->getNomUrl(); 192 | } else { 193 | $morehtmlref .= ''; 194 | } 195 | } 196 | }*/ 197 | $morehtmlref .= '
'; 198 | 199 | 200 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 201 | 202 | print '
'; 203 | print '
'; 204 | 205 | $object->info($object->id); 206 | dol_print_object_info($object, 1); 207 | 208 | print '
'; 209 | 210 | dol_fiche_end(); 211 | 212 | 213 | 214 | // Actions buttons 215 | 216 | $objthirdparty = $object; 217 | $objcon = new stdClass(); 218 | 219 | $out = '&origin='.$object->element.'&originid='.$object->id; 220 | $permok = $user->hasRight('agenda', 'myactions', 'create'); 221 | if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) 222 | { 223 | //$out.='trans("AddAnAction"),'filenew'); 228 | //$out.=""; 229 | } 230 | 231 | 232 | print '
'; 233 | 234 | if (isModEnabled('agenda')) 235 | { 236 | if ( $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) 237 | { 238 | print ''.$langs->trans("AddAction").''; 239 | } 240 | else 241 | { 242 | print ''.$langs->trans("AddAction").''; 243 | } 244 | } 245 | 246 | print '
'; 247 | 248 | if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) 249 | { 250 | $param = '&id='.$object->id; 251 | $param .= !empty($socid) ?'&socid='.$socid : ''; 252 | if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); 253 | if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); 254 | 255 | 256 | //print load_fiche_titre($langs->trans("ActionsOnDistributionList"), '', ''); 257 | 258 | // List of all actions 259 | $filters = array(); 260 | $filters['search_agenda_label'] = $search_agenda_label; 261 | 262 | // TODO Replace this with same code than into list.php 263 | show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, ''); 264 | } 265 | } 266 | 267 | // End of page 268 | llxFooter(); 269 | $db->close(); 270 | -------------------------------------------------------------------------------- /distributionlist_contact.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) ---Put here your own copyright and developer email--- 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file distributionlist_note.php 21 | * \ingroup distributionlist 22 | * \brief Car with notes on DistributionList 23 | */ 24 | 25 | // Load Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; 36 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 37 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 38 | if (!$res) die("Include of main fails"); 39 | 40 | dol_include_once('/distributionlist/class/distributionlist.class.php'); 41 | dol_include_once('/distributionlist/class/tools_distributionlist.class.php'); 42 | dol_include_once('/distributionlist/class/distributionlistsocpeople.class.php'); 43 | dol_include_once('/distributionlist/class/distributionlistsocpeoplefilter.class.php'); 44 | dol_include_once('/distributionlist/lib/distributionlist_distributionlist.lib.php'); 45 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; 46 | 47 | // Load translation files required by the page 48 | $langs->loadLangs(array("distributionlist@distributionlist", "companies", "mails", "main")); 49 | 50 | // Get parameters 51 | $id = GETPOST('id', 'int'); 52 | $filter_id = GETPOST('filter', 'int'); 53 | $ref = GETPOST('ref', 'alpha'); 54 | $action = GETPOST('action', 'alpha'); 55 | $massaction = GETPOST('massaction', 'alpha'); 56 | $cancel = GETPOST('cancel', 'aZ09'); 57 | $backtopage = GETPOST('backtopage', 'alpha'); 58 | $label = GETPOST('label', 'alpha'); 59 | $contacts = GETPOST('toselect'); 60 | $confirm = GETPOST('confirm', 'alpha'); 61 | $msg_to_display = GETPOST('msg_to_display', 'alpha'); 62 | $style_msg_to_display = GETPOST('style_msg_to_display', 'alpha'); 63 | 64 | // Initialize technical objects 65 | $object = new DistributionList($db); 66 | $extrafields = new ExtraFields($db); 67 | $diroutputmassaction = $conf->distributionlist->dir_output.'/temp/massgeneration/'.$user->id; 68 | $hookmanager->initHooks(array('distributionlistcontact', 'globalcard')); // Note that conf->hooks_modules contains array 69 | // Fetch optionals attributes and labels 70 | $extrafields->fetch_name_optionals_label($object->table_element); 71 | 72 | // Security check - Protection if external user 73 | //if ($user->socid > 0) accessforbidden(); 74 | //if ($user->socid > 0) $socid = $user->socid; 75 | //$result = restrictedArea($user, 'distributionlist', $id); 76 | 77 | // Load object 78 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals 79 | if (array_key_exists('$object->entity', $conf->distributionlist->multidir_output) && $id > 0 || !empty($ref)) $upload_dir = $conf->distributionlist->multidir_output[$object->entity]."/".$object->id; 80 | 81 | $permissionnote = $user->hasRight('distributionlist', 'distributionlist', 'create'); // Used by the include of actions_setnotes.inc.php 82 | $permissiontoadd = $user->hasRight('distributionlist', 'distributionlist', 'update'); // Used by the include of actions_addupdatedelete.inc.php 83 | 84 | $form = new Form($db); 85 | 86 | // Retrait des droits network car ici il n'y pas lieu d'effectuer ce type d'action 87 | unset($user->rights->network); 88 | 89 | /* 90 | * Actions 91 | */ 92 | 93 | //include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; 94 | 95 | // Si la liste est clôturée, on renvoie vers l'onlet fiche 96 | if($object->status > 1 || empty($permissiontoadd)) { 97 | header('Location: '.dol_buildpath('/distributionlist/distributionlist_card.php', 1).'?id='.$object->id); 98 | exit; 99 | } 100 | 101 | 102 | $TParamURL = $_REQUEST; 103 | 104 | // Suppression de la liste des contacts sélectionnés si existante pour ne pas remplir inutilement l'url lors de l'appel à la liste standard des contacts (sinon bug) 105 | unset($TParamURL['toselect']); 106 | 107 | // Pour l'enregistrement du filtre, on retire l'information de la page car au moment de l'application du filtre c'est bizarre de tomber sur une page > à la première 108 | if($action === 'confirm_add_filter' && $confirm === 'yes') { 109 | unset($TParamURL['page']); 110 | unset($TParamURL['pageplusone']); 111 | unset($TParamURL['limit']); 112 | } 113 | 114 | $TParamURL_HTTP_build_query = http_build_query($TParamURL); 115 | 116 | if($action === 'add_filter') { 117 | 118 | // Create an array for form 119 | $formquestion = array( 120 | // 'text' => $langs->trans("ConfirmClone"), 121 | // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), 122 | // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), 123 | array('type' => 'text', 'name' => 'label', 'label' => $langs->trans('AdvTgtOrCreateNewFilter'), 'value'=>(empty($label)) ? $langs->trans('Filter').' '.date('d/m/Y H:i:s') : $label) 124 | ); 125 | $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&'.$TParamURL_HTTP_build_query, $langs->trans('AdvTgtCreateFilter'), '', 'confirm_add_filter', $formquestion, 'yes', 1); 126 | 127 | } elseif ($action === 'confirm_add_filter' && $confirm === 'yes') { 128 | 129 | if($id_doubledistributionlistfilter = ToolsDistributionlist::distributionlistsocpeoplefilter_alreadyexist($label)){ 130 | setEventMessage($langs->trans('DistributionListFilterSocPeople_Label_AlreadyExist', $label), 'errors'); 131 | header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&action=add_filter&label='.$label); 132 | exit; 133 | } else { 134 | $filter = new DistributionListSocpeopleFilter($db); 135 | $filter->url_params = $TParamURL_HTTP_build_query; 136 | $filter->fk_distributionlist = $id; 137 | $filter->label = $label; 138 | $filter->create($user); 139 | // Pour éviter de réenregistrer le filtre en cas de réactualisation de la page 140 | header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&set_filter=1&filter=' . $filter->id); 141 | exit; 142 | } 143 | 144 | } elseif(GETPOSTISSET('delete_filter')) { 145 | 146 | 147 | if($filter_id > 0) { 148 | // pour conserver le filtre si l'utilisateur dit finalement non pour la suppression 149 | $f = new DistributionListSocpeopleFilter($db); 150 | $f->fetch($filter_id); 151 | 152 | // Create an array for form 153 | $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&filter='.$filter_id, $langs->trans('RemoveFilter'), $langs->trans('ConfirmDeleteDistributionListFilter', $f->label), 'confirm_remove_filter', '', 'yes', 1); 154 | 155 | $TParamURL_HTTP_build_query = $f->url_params; 156 | } else setEventMessage($langs->trans('DistributionListNeedToSelectFilterForDeletion'), 'warnings'); 157 | 158 | 159 | } elseif($action === 'confirm_remove_filter' && $confirm === 'yes' && $filter_id > 0) { 160 | 161 | $filter = new DistributionListSocpeopleFilter($db); 162 | $filter->fetch($filter_id); 163 | $filter->delete($user); 164 | 165 | header('Location: '.$_SERVER['PHP_SELF'].'?id='.$id.'&msg_to_display=DistributionListDeleteFilterSuccess'); 166 | exit; 167 | 168 | } elseif(GETPOSTISSET('set_filter')) { 169 | 170 | if($filter_id > 0) { 171 | $f = new DistributionListSocpeopleFilter($db); 172 | $f->fetch($filter_id); 173 | $TParamURL_HTTP_build_query = $f->url_params; 174 | 175 | } else setEventMessage($langs->trans('DistributionListNeedToSelectFilterForSelection'), 'warnings'); 176 | } 177 | //maintient le filtre si on change le nombre de contacts à afficher 178 | elseif(!empty($filter_id) && GETPOSTISSET('limit')){ 179 | $f = new DistributionListSocpeopleFilter($db); 180 | $res = $f->fetch($filter_id); 181 | 182 | /*Vieux hack pour faire marcher l'ajout ou la suppression de colonnes : je supprimme certains éléments des params du filtre pour éviter qu'ils écrasent les paramètres définis de base */ 183 | parse_str($f->url_params,$TParamURL_Filter); 184 | unset($TParamURL_Filter['selectedfields']); 185 | unset($TParamURL_Filter['formfilteraction']); 186 | $f->url_params = http_build_query($TParamURL_Filter); 187 | 188 | if($res > 0) $TParamURL_HTTP_build_query .= '&' . $f->url_params; 189 | else setEventMessage($langs->trans('DistributionListFilterError'), 'errors'); 190 | } 191 | 192 | if($action === 'add_all_filtered_contacts') { 193 | $contacts = $object->getAllContactIds(); 194 | $massaction = 'distributionlist_add_contacts'; 195 | } 196 | 197 | // Ajout des contacts à la liste de diffusion 198 | if($massaction === 'distributionlist_add_contacts') { 199 | 200 | if(!empty($contacts) && $object->status < DistributionList::STATUS_CLOSED) { 201 | 202 | $nb_add = 0; 203 | foreach ($contacts as $id_contact) $nb_add += $object->addContact($user, $id_contact, false, false); 204 | 205 | if(!empty($nb_add)) { 206 | setEventMessage($langs->trans('DistributionListNbAddedContacts', $nb_add)); 207 | $object->nb_contacts += $nb_add; 208 | $object->update($user); 209 | } else setEventMessage($langs->trans('DistributionListNoAddedContacts'), 'warnings'); 210 | } 211 | 212 | } 213 | 214 | $hookmanager->executeHooks('doActions', $parameters, $object, $action); 215 | 216 | /* 217 | * View 218 | */ 219 | 220 | if(!empty($msg_to_display)) setEventMessage($langs->trans($msg_to_display, $style_msg_to_display)); 221 | 222 | 223 | $help_url = ''; 224 | 225 | llxHeader('', $langs->trans('DistributionList'), $help_url); 226 | 227 | ?> 228 | 229 | 265 | 266 | 0 || !empty($ref)) { 269 | 270 | // Print form confirm 271 | print $formconfirm ?? ''; 272 | 273 | $object->fetch_thirdparty(); 274 | 275 | $head = distributionlistPrepareHead($object); 276 | 277 | dol_fiche_head($head, 'contact', $langs->trans("DistributionList"), -1, $object->picto); 278 | 279 | // Object card 280 | // ------------------------------------------------------------ 281 | $linkback = '' . $langs->trans("BackToList") . ''; 282 | 283 | $morehtmlref = '
'; 284 | /* 285 | // Ref customer 286 | $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); 287 | $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); 288 | // Thirdparty 289 | $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); 290 | // Project 291 | if (! empty($conf->projet->enabled)) 292 | { 293 | $langs->load("projects"); 294 | $morehtmlref.='
'.$langs->trans('Project') . ' '; 295 | if ($permissiontoadd) 296 | { 297 | if ($action != 'classify') 298 | //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; 299 | $morehtmlref.=' : '; 300 | if ($action == 'classify') { 301 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 302 | $morehtmlref.='
'; 303 | $morehtmlref.=''; 304 | $morehtmlref.=''; 305 | $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 306 | $morehtmlref.=''; 307 | $morehtmlref.='
'; 308 | } else { 309 | $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 310 | } 311 | } else { 312 | if (! empty($object->fk_project)) { 313 | $proj = new Project($db); 314 | $proj->fetch($object->fk_project); 315 | $morehtmlref .= ': '.$proj->getNomUrl(); 316 | } else { 317 | $morehtmlref .= ''; 318 | } 319 | } 320 | }*/ 321 | $morehtmlref .= '
'; 322 | 323 | 324 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 325 | 326 | 327 | print '
'; 328 | print '

'; 329 | 330 | $filter = new DistributionListSocpeopleFilter($db); 331 | $TFilters = $filter->fetchAll('ASC', 'label', 0, 0, array()); 332 | 333 | print '
'; 334 | print '
'; 335 | 336 | if(!empty($TFilters)) { 337 | 338 | $TFilterDisplay=array(); 339 | foreach ($TFilters as $obj) $TFilterDisplay[$obj->id] = $obj->label; 340 | if(!empty(GETPOST('button_removefilter', 'alpha')) || !empty(GETPOST('button_removefilter.x', 'alpha')) || !empty(GETPOST('button_removefilter_x', 'alpha'))) { 341 | $default_val = ''; 342 | } else $default_val = $filter_id; 343 | 344 | print Form::selectarray('filter', $TFilterDisplay, $default_val, 1); 345 | print ' '; 346 | print ''; 347 | 348 | } 349 | 350 | // Le preg_grep('/^search_/', array_keys($_REQUEST)) set à vérifier si le formulaire de recherche a été soumis 351 | // Si j'utilise un !empty(GETPOST('button_search') c'est pas bon car l'input n'est pas transmis en cas d'appui sur la touche "Entrée" 352 | // if (count(preg_grep('/^search_/', array_keys($_REQUEST))) > 0 353 | // && empty(GETPOST('button_removefilter', 'alpha')) 354 | // && empty(GETPOST('button_removefilter.x', 'alpha')) 355 | // && empty(GETPOST('button_removefilter_x', 'alpha')) 356 | // && $action !== 'set_filter') { // All tests are required to be compatible with all browsers 357 | print ''.$langs->trans('DistributionListSaveCurrentFilter').''; 358 | if($object->status < DistributionList::STATUS_CLOSED) print ''.$langs->trans('AddEveryContactWithThisFilter').''; 359 | 360 | // } 361 | 362 | print '
'; 363 | print '
'; 364 | 365 | $cssclass = "titlefield"; 366 | 367 | //print '
'; 368 | print '
'; 369 | //print '
'; 370 | 371 | print '
'; 372 | 373 | dol_fiche_end(); 374 | } 375 | 376 | // End of page 377 | llxFooter(); 378 | $db->close(); 379 | -------------------------------------------------------------------------------- /admin/setup.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2021 SuperAdmin 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | /** 20 | * \file distributionlist/admin/setup.php 21 | * \ingroup distributionlist 22 | * \brief DistributionList setup page. 23 | */ 24 | 25 | // Load Dolibarr environment 26 | $res = 0; 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) 28 | if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; 29 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME 30 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; 31 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } 32 | if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; 33 | if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; 34 | // Try main.inc.php using relative path 35 | if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; 36 | if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; 37 | if (!$res) die("Include of main fails"); 38 | 39 | global $langs, $user; 40 | 41 | // Libraries 42 | require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; 43 | require_once '../lib/distributionlist.lib.php'; 44 | //require_once "../class/myclass.class.php"; 45 | 46 | // Translations 47 | $langs->loadLangs(array("admin", "distributionlist@distributionlist")); 48 | 49 | // Access control 50 | if (!$user->admin) accessforbidden(); 51 | 52 | // Parameters 53 | $action = GETPOST('action', 'alpha'); 54 | $backtopage = GETPOST('backtopage', 'alpha'); 55 | 56 | $value = GETPOST('value', 'alpha'); 57 | 58 | /*$arrayofparameters = array( 59 | 'DISTRIBUTIONLIST_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), 60 | 'DISTRIBUTIONLIST_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) 61 | );*/ 62 | 63 | $error = 0; 64 | $setupnotempty = 0; 65 | 66 | 67 | /* 68 | * Actions 69 | */ 70 | include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; 71 | 72 | if ($action == 'updateMask') 73 | { 74 | $maskconstorder = GETPOST('maskConstDistributionList', 'alpha'); 75 | $maskorder = GETPOST('maskDistributionList', 'alpha'); 76 | 77 | if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); 78 | 79 | if (!$res > 0) $error++; 80 | 81 | if (!$error) 82 | { 83 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 84 | } else { 85 | setEventMessages($langs->trans("Error"), null, 'errors'); 86 | } 87 | } elseif ($action == 'specimen') 88 | { 89 | $modele = GETPOST('module', 'alpha'); 90 | $tmpobjectkey = GETPOST('object'); 91 | 92 | $tmpobject = new $tmpobjectkey($db); 93 | $tmpobject->initAsSpecimen(); 94 | 95 | // Search template files 96 | $file = ''; $classname = ''; $filefound = 0; 97 | $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); 98 | foreach ($dirmodels as $reldir) 99 | { 100 | $file = dol_buildpath($reldir."core/modules/distributionlist/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); 101 | if (file_exists($file)) 102 | { 103 | $filefound = 1; 104 | $classname = "pdf_".$modele; 105 | break; 106 | } 107 | } 108 | 109 | if ($filefound) 110 | { 111 | require_once $file; 112 | 113 | $module = new $classname($db); 114 | 115 | if ($module->write_file($tmpobject, $langs) > 0) 116 | { 117 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); 118 | return; 119 | } else { 120 | setEventMessages($module->error, null, 'errors'); 121 | dol_syslog($module->error, LOG_ERR); 122 | } 123 | } else { 124 | setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); 125 | dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); 126 | } 127 | } 128 | 129 | // Activate a model 130 | elseif ($action == 'set') 131 | { 132 | $ret = addDocumentModel($value, $type, $label, $scandir); 133 | } elseif ($action == 'del') 134 | { 135 | $tmpobjectkey = GETPOST('object'); 136 | 137 | $ret = delDocumentModel($value, $type); 138 | if ($ret > 0) 139 | { 140 | $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; 141 | if (getDolGlobalString($constforval) == "$value") dolibarr_del_const($db, $constforval, $conf->entity); 142 | } 143 | } 144 | 145 | // Set default model 146 | elseif ($action == 'setdoc') 147 | { 148 | $tmpobjectkey = GETPOST('object'); 149 | $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; 150 | if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) 151 | { 152 | // The constant that was read before the new set 153 | // We therefore requires a variable to have a coherent view 154 | $conf->global->$constforval = $value; 155 | } 156 | 157 | // On active le modele 158 | $ret = delDocumentModel($value, $type); 159 | if ($ret > 0) 160 | { 161 | $ret = addDocumentModel($value, $type, $label, $scandir); 162 | } 163 | } elseif ($action == 'setmod') 164 | { 165 | // TODO Check if numbering module chosen can be activated 166 | // by calling method canBeActivated 167 | $tmpobjectkey = GETPOST('object'); 168 | $constforval = 'DISTRIBUTIONLIST_'.strtoupper($tmpobjectkey)."_ADDON"; 169 | dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); 170 | } 171 | 172 | 173 | 174 | /* 175 | * View 176 | */ 177 | 178 | $form = new Form($db); 179 | 180 | $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); 181 | 182 | $page_name = "DistributionListSetup"; 183 | llxHeader('', $langs->trans($page_name)); 184 | 185 | // Subheader 186 | $linkback = ''.$langs->trans("BackToModuleList").''; 187 | 188 | print load_fiche_titre($langs->trans($page_name), $linkback, 'object_distributionlist@distributionlist'); 189 | 190 | // Configuration header 191 | $head = distributionlistAdminPrepareHead(); 192 | dol_fiche_head($head, 'settings', '', -1, "distributionlist@distributionlist"); 193 | 194 | // Setup page goes here 195 | echo ''.$langs->trans("DistributionListSetupPage").''; 196 | 197 | //Partie "Paramètres" en général 198 | 199 | print load_fiche_titre($langs->trans("Parameters"), '', ''); 200 | 201 | print ''; 202 | 203 | print ''; 204 | print ''; 205 | print ''; 206 | print ''."\n"; 207 | 208 | print ''; 209 | print ''; 210 | print '\n\n"; 213 | 214 | print '
'.$langs->trans("Description").''.$langs->trans("Value").'
'.$langs->trans("DistributionList_UniqueLabel").''; 211 | print ajax_constantonoff('DISTRIBUTIONLISTUNIQUELABEL'); 212 | print "
'; 215 | 216 | 217 | if ($action == 'edit') 218 | { 219 | print '
'; 220 | print ''; 221 | print ''; 222 | 223 | print ''; 224 | print ''; 225 | 226 | foreach ($arrayofparameters as $key => $val) 227 | { 228 | print ''; 232 | } 233 | print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; 229 | $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); 230 | print $form->textwithpicto($langs->trans($key), $tooltiphelp); 231 | print '
'; 234 | 235 | print '
'; 236 | print ''; 237 | print '
'; 238 | 239 | print '
'; 240 | print '
'; 241 | } else { 242 | if (!empty($arrayofparameters)) 243 | { 244 | print ''; 245 | print ''; 246 | 247 | foreach ($arrayofparameters as $key => $val) 248 | { 249 | $setupnotempty++; 250 | 251 | print ''; 255 | } 256 | 257 | print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; 252 | $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); 253 | print $form->textwithpicto($langs->trans($key), $tooltiphelp); 254 | print ''.getDolGlobalString($key).'
'; 258 | 259 | print '
'; 260 | print ''.$langs->trans("Modify").''; 261 | print '
'; 262 | } 263 | /*else 264 | { 265 | print '
'.$langs->trans("NothingToSetup"); 266 | }*/ 267 | } 268 | 269 | 270 | $moduledir = 'distributionlist'; 271 | $myTmpObjects = array(); 272 | $myTmpObjects['DistributionList']=array('includerefgeneration'=>1, 'includedocgeneration'=>0); 273 | 274 | 275 | foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { 276 | 277 | if ($myTmpObjectKey == 'MyObject') continue; 278 | if ($myTmpObjectArray['includerefgeneration']) { 279 | /* 280 | * Orders Numbering model 281 | */ 282 | $setupnotempty++; 283 | 284 | print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); 285 | 286 | print ''; 287 | print ''; 288 | print ''; 289 | print ''; 290 | print ''; 291 | print ''; 292 | print ''; 293 | print ''."\n"; 294 | 295 | clearstatcache(); 296 | 297 | foreach ($dirmodels as $reldir) 298 | { 299 | $dir = dol_buildpath($reldir."core/modules/".$moduledir); 300 | 301 | if (is_dir($dir)) 302 | { 303 | $handle = opendir($dir); 304 | if (is_resource($handle)) 305 | { 306 | while (($file = readdir($handle)) !== false) 307 | { 308 | if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') 309 | { 310 | $file = substr($file, 0, dol_strlen($file) - 4); 311 | 312 | require_once $dir.'/'.$file.'.php'; 313 | 314 | $module = new $file($db); 315 | 316 | // Show modules according to features level 317 | if ($module->version == 'development' && getDolGlobalString('MAIN_FEATURES_LEVEL') < 2) continue; 318 | if ($module->version == 'experimental' && getDolGlobalString('MAIN_FEATURES_LEVEL') < 1) continue; 319 | 320 | if ($module->isEnabled()) 321 | { 322 | dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php'); 323 | 324 | print ''; 327 | 328 | // Show example of numbering model 329 | print ''."\n"; 335 | 336 | print ''; 347 | 348 | $mytmpinstance = new $myTmpObjectKey($db); 349 | $mytmpinstance->initAsSpecimen(); 350 | 351 | // Info 352 | $htmltooltip = ''; 353 | $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; 354 | 355 | $nextval = $module->getNextValue($mytmpinstance); 356 | if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval 357 | $htmltooltip .= ''.$langs->trans("NextValue").': '; 358 | if ($nextval) { 359 | if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') 360 | $nextval = $langs->trans($nextval); 361 | $htmltooltip .= $nextval.'
'; 362 | } else { 363 | $htmltooltip .= $langs->trans($module->error).'
'; 364 | } 365 | } 366 | 367 | print ''; 370 | 371 | print "\n"; 372 | } 373 | } 374 | } 375 | closedir($handle); 376 | } 377 | } 378 | } 379 | print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->name."\n"; 325 | print $module->info(); 326 | print ''; 330 | $tmp = $module->getExample(); 331 | if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; 332 | elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); 333 | else print $tmp; 334 | print '
'; 337 | $constforvar = 'DISTRIBUTIONLIST_'.strtoupper($myTmpObjectKey).'_ADDON'; 338 | if (getDolGlobalString($constforvar) == $file) 339 | { 340 | print img_picto($langs->trans("Activated"), 'switch_on'); 341 | } else { 342 | print ''; 343 | print img_picto($langs->trans("Disabled"), 'switch_off'); 344 | print ''; 345 | } 346 | print ''; 368 | print $form->textwithpicto('', $htmltooltip, 1, 0); 369 | print '

\n"; 380 | } 381 | 382 | if ($myTmpObjectArray['includedocgeneration']) { 383 | /* 384 | * Document templates generators 385 | */ 386 | $setupnotempty++; 387 | $type = strtolower($myTmpObjectKey); 388 | 389 | print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', ''); 390 | 391 | // Load array def with activated templates 392 | $def = array(); 393 | $sql = "SELECT nom"; 394 | $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; 395 | $sql .= " WHERE type = '".$type."'"; 396 | $sql .= " AND entity = ".$conf->entity; 397 | $resql = $db->query($sql); 398 | if ($resql) 399 | { 400 | $i = 0; 401 | $num_rows = $db->num_rows($resql); 402 | while ($i < $num_rows) 403 | { 404 | $array = $db->fetch_array($resql); 405 | array_push($def, $array[0]); 406 | $i++; 407 | } 408 | } else { 409 | dol_print_error($db); 410 | } 411 | 412 | print "\n"; 413 | print "\n"; 414 | print ''; 415 | print ''; 416 | print '\n"; 417 | print '\n"; 418 | print ''; 419 | print ''; 420 | print "\n"; 421 | 422 | clearstatcache(); 423 | 424 | foreach ($dirmodels as $reldir) 425 | { 426 | foreach (array('', '/doc') as $valdir) 427 | { 428 | $realpath = $reldir."core/modules/".$moduledir.$valdir; 429 | $dir = dol_buildpath($realpath); 430 | 431 | if (is_dir($dir)) 432 | { 433 | $handle = opendir($dir); 434 | if (is_resource($handle)) 435 | { 436 | while (($file = readdir($handle)) !== false) 437 | { 438 | $filelist[] = $file; 439 | } 440 | closedir($handle); 441 | arsort($filelist); 442 | 443 | foreach ($filelist as $file) 444 | { 445 | if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) 446 | { 447 | if (file_exists($dir.'/'.$file)) 448 | { 449 | $name = substr($file, 4, dol_strlen($file) - 16); 450 | $classname = substr($file, 0, dol_strlen($file) - 12); 451 | 452 | require_once $dir.'/'.$file; 453 | $module = new $classname($db); 454 | 455 | $modulequalified = 1; 456 | if ($module->version == 'development' && getDolGlobalString('MAIN_FEATURES_LEVEL') < 2) $modulequalified = 0; 457 | if ($module->version == 'experimental' && getDolGlobalString('MAIN_FEATURES_LEVEL') < 1) $modulequalified = 0; 458 | 459 | if ($modulequalified) 460 | { 461 | print ''; 467 | 468 | // Active 469 | if (in_array($name, $def)) 470 | { 471 | print ''; 476 | } else { 477 | print '"; 480 | } 481 | 482 | // Default 483 | print ''; 492 | 493 | // Info 494 | $htmltooltip = ''.$langs->trans("Name").': '.$module->name; 495 | $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); 496 | if ($module->type == 'pdf') 497 | { 498 | $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; 499 | } 500 | $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; 501 | 502 | $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; 503 | $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); 504 | $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); 505 | 506 | print ''; 509 | 510 | // Preview 511 | print ''; 519 | 520 | print "\n"; 521 | } 522 | } 523 | } 524 | } 525 | } 526 | } 527 | } 528 | } 529 | 530 | print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; 462 | print (empty($module->name) ? $name : $module->name); 463 | print "\n"; 464 | if (method_exists($module, 'info')) print $module->info($langs); 465 | else print $module->description; 466 | print ''."\n"; 472 | print ''; 473 | print img_picto($langs->trans("Enabled"), 'switch_on'); 474 | print ''; 475 | print ''."\n"; 478 | print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; 479 | print "'; 484 | $constforvar = 'DISTRIBUTIONLIST_'.strtoupper($myTmpObjectKey).'_ADDON'; 485 | if (getDolGlobalString($constforvar) == $name) 486 | { 487 | print img_picto($langs->trans("Default"), 'on'); 488 | } else { 489 | print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; 490 | } 491 | print ''; 507 | print $form->textwithpicto('', $htmltooltip, 1, 0); 508 | print ''; 512 | if ($module->type == 'pdf') 513 | { 514 | print ''.img_object($langs->trans("Preview"), 'generic').''; 515 | } else { 516 | print img_object($langs->trans("PreviewNotAvailable"), 'generic'); 517 | } 518 | print '
'; 531 | } 532 | } 533 | 534 | /*if (empty($setupnotempty)) { 535 | print '
'.$langs->trans("NothingToSetup"); 536 | }*/ 537 | 538 | // Page end 539 | dol_fiche_end(); 540 | 541 | llxFooter(); 542 | $db->close(); 543 | -------------------------------------------------------------------------------- /core/modules/modDistributionList.class.php: -------------------------------------------------------------------------------- 1 | 3 | * Copyright (C) 2018-2019 Nicolas ZABOURI 4 | * Copyright (C) 2019-2020 Frédéric France 5 | * Copyright (C) 2021 SuperAdmin 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | /** 22 | * \defgroup distributionlist Module DistributionList 23 | * \brief DistributionList module descriptor. 24 | * 25 | * \file htdocs/distributionlist/core/modules/modDistributionList.class.php 26 | * \ingroup distributionlist 27 | * \brief Description and activation file for module DistributionList 28 | */ 29 | include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; 30 | 31 | /** 32 | * Description and activation class for module DistributionList 33 | */ 34 | class modDistributionList extends DolibarrModules 35 | { 36 | /** 37 | * Constructor. Define names, constants, directories, boxes, permissions 38 | * 39 | * @param DoliDB $db Database handler 40 | */ 41 | public function __construct($db) 42 | { 43 | global $langs, $conf; 44 | $this->db = $db; 45 | 46 | // Id for module (must be unique). 47 | // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). 48 | $this->numero = 104943; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module 49 | // Key text used to identify module (for permissions, menus, etc...) 50 | $this->rights_class = 'distributionlist'; 51 | // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' 52 | // It is used to group modules by family in module setup page 53 | $this->family = "other"; 54 | // Module position in the family on 2 digits ('01', '10', '20', ...) 55 | $this->module_position = '90'; 56 | // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) 57 | //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); 58 | // Module label (no space allowed), used if translation string 'ModuleDistributionListName' not found (DistributionList is name of module). 59 | $this->name = preg_replace('/^mod/i', '', get_class($this)); 60 | // Module description, used if translation string 'ModuleDistributionListDesc' not found (DistributionList is name of module). 61 | $this->description = "DistributionListDescription"; 62 | // Used only if file README.md and README-LL.md not found. 63 | $this->descriptionlong = "DistributionList description (Long)"; 64 | $this->editor_name = 'Editor name'; 65 | $this->editor_url = 'https://www.example.com'; 66 | // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' 67 | $this->version = '1.3.4'; 68 | // Url to the file with your last numberversion of this module 69 | //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; 70 | 71 | // Key used in llx_const table to save module status enabled/disabled (where DISTRIBUTIONLIST is value of property name of module in uppercase) 72 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); 73 | // Name of image file used for this module. 74 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' 75 | // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' 76 | $this->picto = 'distributionlist@distributionlist'; 77 | // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) 78 | $this->module_parts = array( 79 | // Set this to 1 if module has its own trigger directory (core/triggers) 80 | 'triggers' => 1, 81 | // Set this to 1 if module has its own login method file (core/login) 82 | 'login' => 0, 83 | // Set this to 1 if module has its own substitution function file (core/substitutions) 84 | 'substitutions' => 0, 85 | // Set this to 1 if module has its own menus handler directory (core/menus) 86 | 'menus' => 0, 87 | // Set this to 1 if module overwrite template dir (core/tpl) 88 | 'tpl' => 0, 89 | // Set this to 1 if module has its own barcode directory (core/modules/barcode) 90 | 'barcode' => 0, 91 | // Set this to 1 if module has its own models directory (core/modules/xxx) 92 | 'models' => 1, 93 | // Set this to 1 if module has its own theme directory (theme) 94 | 'theme' => 0, 95 | // Set this to relative path of css file if module has its own css file 96 | 'css' => array( 97 | // '/distributionlist/css/distributionlist.css.php', 98 | ), 99 | // Set this to relative path of js file if module must load a js on all pages 100 | 'js' => array( 101 | // '/distributionlist/js/distributionlist.js.php', 102 | ), 103 | // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all' 104 | 'hooks' => array('contactlist' 105 | // 'data' => array( 106 | // 'hookcontext1', 107 | // 'hookcontext2', 108 | // ), 109 | // 'entity' => '0', 110 | ), 111 | // Set this to 1 if features of module are opened to external users 112 | 'moduleforexternal' => 0, 113 | ); 114 | // Data directories to create when module is enabled. 115 | // Example: this->dirs = array("/distributionlist/temp","/distributionlist/subdir"); 116 | $this->dirs = array("/distributionlist/temp"); 117 | // Config pages. Put here list of php page, stored into distributionlist/admin directory, to use to setup module. 118 | $this->config_page_url = array("setup.php@distributionlist"); 119 | // Dependencies 120 | // A condition to hide module 121 | $this->hidden = false; 122 | // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) 123 | $this->depends = array(); 124 | $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) 125 | $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) 126 | $this->langfiles = array("distributionlist@distributionlist"); 127 | $this->phpmin = array(7, 0); // Minimum version of PHP required by module 128 | $this->need_dolibarr_version = array(16, 0); // Minimum version of Dolibarr required by module 129 | $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) 130 | $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) 131 | //$this->automatic_activation = array('FR'=>'DistributionListWasAutomaticallyActivatedBecauseOfYourCountryChoice'); 132 | //$this->always_enabled = true; // If true, can't be disabled 133 | 134 | // Constants 135 | // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) 136 | // Example: $this->const=array(1 => array('DISTRIBUTIONLIST_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), 137 | // 2 => array('DISTRIBUTIONLIST_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) 138 | // ); 139 | $this->const = array(); 140 | 141 | // Some keys to add into the overwriting translation tables 142 | /*$this->overwrite_translation = array( 143 | 'en_US:ParentCompany'=>'Parent company or reseller', 144 | 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' 145 | )*/ 146 | if (!isset($conf->distributionlist) || !isModEnabled('distributionlist')) { 147 | $conf->distributionlist = new stdClass(); 148 | $conf->distributionlist->enabled = 0; 149 | } 150 | 151 | // Array to add new pages in new tabs 152 | $this->tabs = array(); 153 | // Example: 154 | // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@distributionlist:$user->rights->distributionlist->read:/distributionlist/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 155 | // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@distributionlist:$user->rights->othermodule->read:/distributionlist/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. 156 | // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname 157 | // 158 | // Where objecttype can be 159 | // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) 160 | // 'contact' to add a tab in contact view 161 | // 'contract' to add a tab in contract view 162 | // 'group' to add a tab in group view 163 | // 'intervention' to add a tab in intervention view 164 | // 'invoice' to add a tab in customer invoice view 165 | // 'invoice_supplier' to add a tab in supplier invoice view 166 | // 'member' to add a tab in fundation member view 167 | // 'opensurveypoll' to add a tab in opensurvey poll view 168 | // 'order' to add a tab in customer order view 169 | // 'order_supplier' to add a tab in supplier order view 170 | // 'payment' to add a tab in payment view 171 | // 'payment_supplier' to add a tab in supplier payment view 172 | // 'product' to add a tab in product view 173 | // 'propal' to add a tab in propal view 174 | // 'project' to add a tab in project view 175 | // 'stock' to add a tab in stock view 176 | // 'thirdparty' to add a tab in third party view 177 | // 'user' to add a tab in user view 178 | 179 | // Dictionaries 180 | $this->dictionaries = array(); 181 | /* Example: 182 | $this->dictionaries=array( 183 | 'langs'=>'distributionlist@distributionlist', 184 | // List of tables we want to see into dictonnary editor 185 | 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"), 186 | // Label of tables 187 | 'tablib'=>array("Table1", "Table2", "Table3"), 188 | // Request to select fields 189 | 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), 190 | // Sort order 191 | 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), 192 | // List of fields (result of select to show dictionary) 193 | 'tabfield'=>array("code,label", "code,label", "code,label"), 194 | // List of fields (list of fields to edit a record) 195 | 'tabfieldvalue'=>array("code,label", "code,label", "code,label"), 196 | // List of fields (list of fields for insert) 197 | 'tabfieldinsert'=>array("code,label", "code,label", "code,label"), 198 | // Name of columns with primary key (try to always name it 'rowid') 199 | 'tabrowid'=>array("rowid", "rowid", "rowid"), 200 | // Condition to show each dictionary 201 | 'tabcond'=>array($conf->distributionlist->enabled, $conf->distributionlist->enabled, $conf->distributionlist->enabled) 202 | ); 203 | */ 204 | 205 | // Boxes/Widgets 206 | // Add here list of php file(s) stored in distributionlist/core/boxes that contains a class to show a widget. 207 | $this->boxes = array( 208 | // 0 => array( 209 | // 'file' => 'distributionlistwidget1.php@distributionlist', 210 | // 'note' => 'Widget provided by DistributionList', 211 | // 'enabledbydefaulton' => 'Home', 212 | // ), 213 | // ... 214 | ); 215 | 216 | // Cronjobs (List of cron jobs entries to add when module is enabled) 217 | // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week 218 | $this->cronjobs = array( 219 | // 0 => array( 220 | // 'label' => 'MyJob label', 221 | // 'jobtype' => 'method', 222 | // 'class' => '/distributionlist/class/distributionlist.class.php', 223 | // 'objectname' => 'DistributionList', 224 | // 'method' => 'doScheduledJob', 225 | // 'parameters' => '', 226 | // 'comment' => 'Comment', 227 | // 'frequency' => 2, 228 | // 'unitfrequency' => 3600, 229 | // 'status' => 0, 230 | // 'test' => '$conf->distributionlist->enabled', 231 | // 'priority' => 50, 232 | // ), 233 | ); 234 | // Example: $this->cronjobs=array( 235 | // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->distributionlist->enabled', 'priority'=>50), 236 | // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->distributionlist->enabled', 'priority'=>50) 237 | // ); 238 | 239 | // Permissions provided by this module 240 | $this->rights = array(); 241 | $r = 0; 242 | // Add here entries to declare new permissions 243 | /* BEGIN MODULEBUILDER PERMISSIONS */ 244 | $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) 245 | $this->rights[$r][1] = 'DistributionListPermRead'; // Permission label 246 | $this->rights[$r][4] = 'distributionlist'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 247 | $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 248 | $r++; 249 | $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) 250 | $this->rights[$r][1] = 'DistributionListPermCreate'; // Permission label 251 | $this->rights[$r][4] = 'distributionlist'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 252 | $this->rights[$r][5] = 'create'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 253 | $r++; 254 | $this->rights[$r][0] = $this->numero . $r; // Permission id (must not be already used) 255 | $this->rights[$r][1] = 'DistributionListPermUpdate'; // Permission label 256 | $this->rights[$r][4] = 'distributionlist'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 257 | $this->rights[$r][5] = 'update'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 258 | $r++; 259 | $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) 260 | $this->rights[$r][1] = 'DistributionListPermDelete'; // Permission label 261 | $this->rights[$r][4] = 'distributionlist'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 262 | $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->distributionlist->level1->level2) 263 | $r++; 264 | /* END MODULEBUILDER PERMISSIONS */ 265 | 266 | // Main menu entries to add 267 | $this->menu = array(); 268 | $r = 0; 269 | // Add here entries to declare new menus 270 | /* BEGIN MODULEBUILDER TOPMENU */ 271 | $this->menu[$r++] = array( 272 | 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 273 | 'type'=>'top', // This is a Top menu entry 274 | 'titre'=>$langs->trans('ModuleDistributionListName'), 275 | 'mainmenu'=>'distributionlist', 276 | 'leftmenu'=>'', 277 | 'url'=>'/distributionlist/distributionlist_list.php', 278 | 'langs'=>'distributionlist@distributionlist', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 279 | 'position'=>1000 + $r, 280 | 'enabled'=>'$conf->distributionlist->enabled', // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. 281 | 'perms'=>'1', // Use 'perms'=>'$user->rights->distributionlist->distributionlist->read' if you want your menu with a permission rules 282 | 'target'=>'', 283 | 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 284 | ); 285 | /* END MODULEBUILDER TOPMENU */ 286 | /* BEGIN MODULEBUILDER LEFTMENU DISTRIBUTIONLIST 287 | $this->menu[$r++]=array( 288 | 'fk_menu'=>'fk_mainmenu=distributionlist', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 289 | 'type'=>'left', // This is a Top menu entry 290 | 'titre'=>'DistributionList', 291 | 'mainmenu'=>'distributionlist', 292 | 'leftmenu'=>'distributionlist', 293 | 'url'=>'/distributionlist/distributionlistindex.php', 294 | 'langs'=>'distributionlist@distributionlist', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 295 | 'position'=>1000+$r, 296 | 'enabled'=>'$conf->distributionlist->enabled', // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. 297 | 'perms'=>'$user->rights->distributionlist->distributionlist->read', // Use 'perms'=>'$user->rights->distributionlist->level1->level2' if you want your menu with a permission rules 298 | 'target'=>'', 299 | 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 300 | ); 301 | $this->menu[$r++]=array( 302 | 'fk_menu'=>'fk_mainmenu=distributionlist,fk_leftmenu=distributionlist', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 303 | 'type'=>'left', // This is a Left menu entry 304 | 'titre'=>'List DistributionList', 305 | 'mainmenu'=>'distributionlist', 306 | 'leftmenu'=>'distributionlist_distributionlist_list', 307 | 'url'=>'/distributionlist/distributionlist_list.php', 308 | 'langs'=>'distributionlist@distributionlist', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 309 | 'position'=>1000+$r, 310 | 'enabled'=>'$conf->distributionlist->enabled', // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 311 | 'perms'=>'$user->rights->distributionlist->distributionlist->read', // Use 'perms'=>'$user->rights->distributionlist->level1->level2' if you want your menu with a permission rules 312 | 'target'=>'', 313 | 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 314 | ); 315 | $this->menu[$r++]=array( 316 | 'fk_menu'=>'fk_mainmenu=distributionlist,fk_leftmenu=distributionlist', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 317 | 'type'=>'left', // This is a Left menu entry 318 | 'titre'=>'New DistributionList', 319 | 'mainmenu'=>'distributionlist', 320 | 'leftmenu'=>'distributionlist_distributionlist_new', 321 | 'url'=>'/distributionlist/distributionlist_card.php?action=create', 322 | 'langs'=>'distributionlist@distributionlist', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 323 | 'position'=>1000+$r, 324 | 'enabled'=>'$conf->distributionlist->enabled', // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 325 | 'perms'=>'$user->rights->distributionlist->distributionlist->write', // Use 'perms'=>'$user->rights->distributionlist->level1->level2' if you want your menu with a permission rules 326 | 'target'=>'', 327 | 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 328 | ); 329 | */ 330 | 331 | $this->menu[$r++]=array( 332 | // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 333 | 'fk_menu'=>'fk_mainmenu=distributionlist', 334 | // This is a Left menu entry 335 | 'type'=>'left', 336 | 'titre'=>$langs->trans('ModuleDistributionListName'), 337 | 'mainmenu'=>'distributionlist', 338 | 'leftmenu'=>'distributionlist_distributionlist', 339 | 'url'=>'/distributionlist/distributionlist_list.php', 340 | // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 341 | 'langs'=>'distributionlist@distributionlist', 342 | 'position'=>1100+$r, 343 | // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 344 | 'enabled'=>'$conf->distributionlist->enabled', 345 | // Use 'perms'=>'$user->rights->distributionlist->level1->level2' if you want your menu with a permission rules 346 | 'perms'=>'1', 347 | 'target'=>'', 348 | // 0=Menu for internal users, 1=external users, 2=both 349 | 'user'=>2, 350 | ); 351 | $this->menu[$r++]=array( 352 | // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 353 | 'fk_menu'=>'fk_mainmenu=distributionlist,fk_leftmenu=distributionlist_distributionlist', 354 | // This is a Left menu entry 355 | 'type'=>'left', 356 | 'titre'=>$langs->trans('DistributionListNew'), 357 | 'mainmenu'=>'distributionlist', 358 | 'leftmenu'=>'distributionlist_distributioncreate', 359 | 'url'=>'/distributionlist/distributionlist_card.php?action=create', 360 | // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 361 | 'langs'=>'distributionlist@distributionlist', 362 | 'position'=>1100+$r, 363 | // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 364 | 'enabled'=>'$conf->distributionlist->enabled', 365 | // Use 'perms'=>'$user->rights->distributionlist->level1->level2' if you want your menu with a permission rules 366 | 'perms'=>'$user->rights->distributionlist->distributionlist->create', 367 | 'target'=>'', 368 | // 0=Menu for internal users, 1=external users, 2=both 369 | 'user'=>2 370 | ); 371 | $this->menu[$r++]=array( 372 | // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 373 | 'fk_menu'=>'fk_mainmenu=distributionlist,fk_leftmenu=distributionlist_distributionlist', 374 | // This is a Left menu entry 375 | 'type'=>'left', 376 | 'titre'=>$langs->trans('DistributionListList'), 377 | 'mainmenu'=>'distributionlist', 378 | 'leftmenu'=>'distributionlist_distributionlist', 379 | 'url'=>'/distributionlist/distributionlist_list.php', 380 | // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 381 | 'langs'=>'distributionlist@distributionlist', 382 | 'position'=>1100+$r, 383 | // Define condition to show or hide menu entry. Use '$conf->distributionlist->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 384 | 'enabled'=>'$conf->distributionlist->enabled', 385 | // Use 'perms'=>'$user->rights->distributionlist->level1->level2' if you want your menu with a permission rules 386 | 'perms'=>'1', 387 | 'target'=>'', 388 | // 0=Menu for internal users, 1=external users, 2=both 389 | 'user'=>2 390 | ); 391 | 392 | /* END MODULEBUILDER LEFTMENU DISTRIBUTIONLIST */ 393 | 394 | // Exports profiles provided by this module 395 | $r = 1; 396 | /* BEGIN MODULEBUILDER EXPORT DISTRIBUTIONLIST */ 397 | /* 398 | $langs->load("distributionlist@distributionlist"); 399 | $this->export_code[$r]=$this->rights_class.'_'.$r; 400 | $this->export_label[$r]='DistributionListLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 401 | $this->export_icon[$r]='distributionlist@distributionlist'; 402 | // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array 403 | $keyforclass = 'DistributionList'; $keyforclassfile='/distributionlist/class/distributionlist.class.php'; $keyforelement='distributionlist@distributionlist'; 404 | include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; 405 | //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; 406 | //unset($this->export_fields_array[$r]['t.fieldtoremove']); 407 | //$keyforclass = 'DistributionListLine'; $keyforclassfile='/distributionlist/class/distributionlist.class.php'; $keyforelement='distributionlistline@distributionlist'; $keyforalias='tl'; 408 | //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; 409 | $keyforselect='distributionlist'; $keyforaliasextra='extra'; $keyforelement='distributionlist@distributionlist'; 410 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 411 | //$keyforselect='distributionlistline'; $keyforaliasextra='extraline'; $keyforelement='distributionlistline@distributionlist'; 412 | //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 413 | //$this->export_dependencies_array[$r] = array('distributionlistline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) 414 | //$this->export_special_array[$r] = array('t.field'=>'...'); 415 | //$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); 416 | //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); 417 | $this->export_sql_start[$r]='SELECT DISTINCT '; 418 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'distributionlist as t'; 419 | //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'distributionlist_line as tl ON tl.fk_distributionlist = t.rowid'; 420 | $this->export_sql_end[$r] .=' WHERE 1 = 1'; 421 | $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('distributionlist').')'; 422 | $r++; */ 423 | /* END MODULEBUILDER EXPORT DISTRIBUTIONLIST */ 424 | 425 | // Imports profiles provided by this module 426 | $r = 1; 427 | /* BEGIN MODULEBUILDER IMPORT DISTRIBUTIONLIST */ 428 | /* 429 | $langs->load("distributionlist@distributionlist"); 430 | $this->export_code[$r]=$this->rights_class.'_'.$r; 431 | $this->export_label[$r]='DistributionListLines'; // Translation key (used only if key ExportDataset_xxx_z not found) 432 | $this->export_icon[$r]='distributionlist@distributionlist'; 433 | $keyforclass = 'DistributionList'; $keyforclassfile='/distributionlist/class/distributionlist.class.php'; $keyforelement='distributionlist@distributionlist'; 434 | include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; 435 | $keyforselect='distributionlist'; $keyforaliasextra='extra'; $keyforelement='distributionlist@distributionlist'; 436 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 437 | //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) 438 | $this->export_sql_start[$r]='SELECT DISTINCT '; 439 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'distributionlist as t'; 440 | $this->export_sql_end[$r] .=' WHERE 1 = 1'; 441 | $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('distributionlist').')'; 442 | $r++; */ 443 | /* END MODULEBUILDER IMPORT DISTRIBUTIONLIST */ 444 | } 445 | 446 | /** 447 | * Function called when module is enabled. 448 | * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. 449 | * It also creates data directories 450 | * 451 | * @param string $options Options when enabling module ('', 'noboxes') 452 | * @return int 1 if OK, 0 if KO 453 | */ 454 | public function init($options = '') 455 | { 456 | global $conf, $langs; 457 | 458 | $result = $this->_load_tables('/distributionlist/sql/'); 459 | if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') 460 | 461 | // Create extrafields during init 462 | //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; 463 | //$extrafields = new ExtraFields($this->db); 464 | //$result1=$extrafields->addExtraField('distributionlist_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'distributionlist@distributionlist', '$conf->distributionlist->enabled'); 465 | //$result2=$extrafields->addExtraField('distributionlist_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'distributionlist@distributionlist', '$conf->distributionlist->enabled'); 466 | //$result3=$extrafields->addExtraField('distributionlist_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'distributionlist@distributionlist', '$conf->distributionlist->enabled'); 467 | //$result4=$extrafields->addExtraField('distributionlist_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'distributionlist@distributionlist', '$conf->distributionlist->enabled'); 468 | //$result5=$extrafields->addExtraField('distributionlist_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'distributionlist@distributionlist', '$conf->distributionlist->enabled'); 469 | 470 | // Permissions 471 | $this->remove($options); 472 | 473 | $sql = array(); 474 | 475 | // Document templates 476 | $moduledir = 'distributionlist'; 477 | $myTmpObjects = array(); 478 | $myTmpObjects['DistributionList']=array('includerefgeneration'=>0, 'includedocgeneration'=>0); 479 | 480 | foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { 481 | if ($myTmpObjectKey == 'DistributionList') continue; 482 | if ($myTmpObjectArray['includerefgeneration']) { 483 | $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/distributionlist/template_distributionlists.odt'; 484 | $dirodt=DOL_DATA_ROOT.'/doctemplates/distributionlist'; 485 | $dest=$dirodt.'/template_distributionlists.odt'; 486 | 487 | if (file_exists($src) && ! file_exists($dest)) 488 | { 489 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 490 | dol_mkdir($dirodt); 491 | $result=dol_copy($src, $dest, 0, 0); 492 | if ($result < 0) 493 | { 494 | $langs->load("errors"); 495 | $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); 496 | return 0; 497 | } 498 | } 499 | 500 | $sql = array_merge($sql, array( 501 | "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity, 502 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")", 503 | "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity, 504 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")" 505 | )); 506 | } 507 | } 508 | 509 | return $this->_init($sql, $options); 510 | } 511 | 512 | /** 513 | * Function called when module is disabled. 514 | * Remove from database constants, boxes and permissions from Dolibarr database. 515 | * Data directories are not deleted 516 | * 517 | * @param string $options Options when enabling module ('', 'noboxes') 518 | * @return int 1 if OK, 0 if KO 519 | */ 520 | public function remove($options = '') 521 | { 522 | $sql = array(); 523 | return $this->_remove($sql, $options); 524 | } 525 | } 526 | --------------------------------------------------------------------------------