2004-10-19 22:24:10 +00:00
|
|
|
<?php
|
2006-08-19 23:00:53 +00:00
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2007-10-09 23:15:25 +00:00
|
|
|
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-07-23 14:04:32 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-07-23 14:04:32 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 19:55:30 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-07-23 14:04:32 +00:00
|
|
|
*/
|
2004-08-14 12:21:24 +00:00
|
|
|
|
2008-12-05 12:16:33 +00:00
|
|
|
/**
|
|
|
|
|
* \defgroup externalrss Module externalrss
|
|
|
|
|
* \brief Module pour inclure des informations externes RSS
|
2011-10-24 12:11:49 +00:00
|
|
|
* \file htdocs/core/modules/modExternalRss.class.php
|
2008-12-05 12:16:33 +00:00
|
|
|
* \ingroup externalrss
|
2021-03-20 12:55:43 +00:00
|
|
|
* \brief Description and activation file for the module externalrss
|
2008-10-01 19:10:17 +00:00
|
|
|
*/
|
2004-08-14 12:21:24 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
|
2007-10-09 23:15:25 +00:00
|
|
|
|
2003-07-23 14:04:32 +00:00
|
|
|
|
2012-10-02 22:30:50 +00:00
|
|
|
/**
|
2015-09-07 13:55:26 +00:00
|
|
|
* Class to describe and enable module externalrss
|
2008-10-01 19:10:17 +00:00
|
|
|
*/
|
2003-11-13 14:35:32 +00:00
|
|
|
class modExternalRss extends DolibarrModules
|
2003-07-23 14:04:32 +00:00
|
|
|
{
|
|
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
/**
|
2011-09-26 14:22:35 +00:00
|
|
|
* Constructor. Define names, constants, directories, boxes, permissions
|
|
|
|
|
*
|
2012-01-04 20:23:50 +00:00
|
|
|
* @param DoliDB $db Database handler
|
2008-10-01 19:10:17 +00:00
|
|
|
*/
|
2019-02-25 19:35:59 +00:00
|
|
|
public function __construct($db)
|
2006-08-19 23:00:53 +00:00
|
|
|
{
|
|
|
|
|
global $conf;
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2012-01-04 20:23:50 +00:00
|
|
|
$this->db = $db;
|
2006-08-19 23:00:53 +00:00
|
|
|
$this->numero = 320;
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
$this->family = "technic";
|
2008-10-01 19:10:17 +00:00
|
|
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
2019-01-27 10:55:16 +00:00
|
|
|
$this->name = preg_replace('/^mod/i', '', get_class($this));
|
2009-04-28 20:35:01 +00:00
|
|
|
$this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr";
|
2017-08-22 16:34:58 +00:00
|
|
|
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
|
|
|
|
$this->version = 'dolibarr';
|
2008-10-06 07:39:52 +00:00
|
|
|
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
2020-04-10 08:59:32 +00:00
|
|
|
$this->picto = 'rss';
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2009-04-28 20:35:01 +00:00
|
|
|
// Data directories to create when module is enabled
|
2011-04-03 21:29:10 +00:00
|
|
|
$this->dirs = array("/externalrss/temp");
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
// Config pages
|
|
|
|
|
$this->config_page_url = array("external_rss.php");
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2015-09-07 13:29:51 +00:00
|
|
|
// Dependencies
|
2006-08-19 23:00:53 +00:00
|
|
|
$this->depends = array();
|
|
|
|
|
$this->requiredby = array();
|
2020-04-10 08:59:32 +00:00
|
|
|
$this->phpmin = array(4, 2, 0);
|
2006-08-19 23:00:53 +00:00
|
|
|
$this->phpmax = array();
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2015-09-07 13:40:55 +00:00
|
|
|
// Constants
|
2006-08-19 23:00:53 +00:00
|
|
|
$this->const = array();
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
// Boxes
|
|
|
|
|
$this->boxes = array();
|
2009-04-28 09:41:30 +00:00
|
|
|
// Les boites sont ajoutees lors de la configuration des flux
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
// Permissions
|
|
|
|
|
$this->rights = array();
|
|
|
|
|
$this->rights_class = 'externalrss';
|
|
|
|
|
}
|
2003-07-23 14:04:32 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
/**
|
2012-01-04 20:23:50 +00:00
|
|
|
* Function called when module is enabled.
|
|
|
|
|
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
|
|
|
|
* It also creates data directories
|
|
|
|
|
*
|
2020-10-31 13:32:18 +00:00
|
|
|
* @param string $options Options when enabling module ('', 'noboxes')
|
2012-01-04 20:23:50 +00:00
|
|
|
* @return int 1 if OK, 0 if KO
|
2008-10-01 19:10:17 +00:00
|
|
|
*/
|
2019-02-26 20:13:07 +00:00
|
|
|
public function init($options = '')
|
2006-04-24 23:04:52 +00:00
|
|
|
{
|
2009-04-28 20:35:01 +00:00
|
|
|
global $conf;
|
2009-05-04 11:40:00 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
$sql = array();
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
// Recherche configuration de boites
|
2020-04-10 08:59:32 +00:00
|
|
|
$this->boxes = array();
|
|
|
|
|
$sql = "select name, value from ".MAIN_DB_PREFIX."const";
|
|
|
|
|
$sql .= " WHERE name like 'EXTERNAL_RSS_TITLE_%'";
|
|
|
|
|
$sql .= " AND entity = ".$conf->entity;
|
|
|
|
|
$result = $this->db->query($sql);
|
2021-02-23 21:03:23 +00:00
|
|
|
if ($result) {
|
|
|
|
|
while ($obj = $this->db->fetch_object($result)) {
|
2021-04-07 17:38:54 +00:00
|
|
|
$reg = array();
|
2021-02-23 21:03:23 +00:00
|
|
|
if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg)) {
|
2009-04-28 09:41:30 +00:00
|
|
|
// Definie la boite si on a trouvee une ancienne configuration
|
2013-05-31 11:30:24 +00:00
|
|
|
//$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)";
|
|
|
|
|
$this->boxes[$reg[1]]['file'] = "box_external_rss.php";
|
|
|
|
|
$this->boxes[$reg[1]]['note'] = $reg[1]." (".$obj->value.")";
|
2006-08-19 23:00:53 +00:00
|
|
|
}
|
2006-04-24 23:04:52 +00:00
|
|
|
}
|
2006-08-19 23:00:53 +00:00
|
|
|
$this->db->free($result);
|
2006-04-24 23:04:52 +00:00
|
|
|
}
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2006-08-19 23:00:53 +00:00
|
|
|
$sql = array();
|
2008-10-01 19:10:17 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
return $this->_init($sql, $options);
|
2006-04-24 23:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
/**
|
2012-03-03 16:37:45 +00:00
|
|
|
* Function called when module is disabled.
|
|
|
|
|
* Remove from database constants, boxes and permissions from Dolibarr database.
|
|
|
|
|
* Data directories are not deleted
|
|
|
|
|
*
|
2020-10-31 13:32:18 +00:00
|
|
|
* @param string $options Options when enabling module ('', 'noboxes')
|
2012-03-03 16:37:45 +00:00
|
|
|
* @return int 1 if OK, 0 if KO
|
2020-10-31 13:32:18 +00:00
|
|
|
*/
|
|
|
|
|
public function remove($options = '')
|
|
|
|
|
{
|
2006-08-19 23:00:53 +00:00
|
|
|
$sql = array();
|
2012-10-02 22:30:50 +00:00
|
|
|
|
2012-03-03 16:37:45 +00:00
|
|
|
// Delete old declarations of RSS box
|
2013-05-31 11:30:24 +00:00
|
|
|
$this->boxes[0]['file'] = "box_external_rss.php";
|
2012-10-02 22:30:50 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
return $this->_remove($sql, $options);
|
2020-10-31 13:32:18 +00:00
|
|
|
}
|
2003-07-23 14:04:32 +00:00
|
|
|
}
|