Added system_data nodesettings class
This commit is contained in:
parent
86fd183c8f
commit
99899f5722
@ -93,6 +93,13 @@ define ('DATA_ACCES_TABLE_LANGUAGE', DATA_ACCES_TABLE_PREFIX ."langue");
|
|||||||
define ('DATA_ACCES_MANAGER_NODE', "db");
|
define ('DATA_ACCES_MANAGER_NODE', "db");
|
||||||
define ('DATA_ACCES_TABLE_NODE', DATA_ACCES_TABLE_PREFIX ."node");
|
define ('DATA_ACCES_TABLE_NODE', DATA_ACCES_TABLE_PREFIX ."node");
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Configuration des paramètres des noeuds
|
||||||
|
##########################################################################################
|
||||||
|
/* Défini la ressource utilisée par la classe NodeSettings */
|
||||||
|
define ('DATA_ACCES_MANAGER_NODE', "db");
|
||||||
|
define ('DATA_ACCES_TABLE_NODESETTINGS', DATA_ACCES_TABLE_PREFIX ."nodesettings");
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Configuration des USER
|
# Configuration des USER
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
@ -263,6 +263,22 @@ CREATE TABLE `{_PREFIX_}node` (
|
|||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
#-- --------------------------------------------------------
|
#-- --------------------------------------------------------
|
||||||
#--
|
#--
|
||||||
|
#-- Structure de la table `nodesettings`
|
||||||
|
#--
|
||||||
|
|
||||||
|
CREATE TABLE `{_PREFIX_}nodesettings` (
|
||||||
|
`node_id` int(4) NOT NULL,
|
||||||
|
`node_email` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
`node_mastodon` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`node_mobilizon` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`node_matrix` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`node_peertube` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`node_nextcloud` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`node_twitter` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`node_facebook` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
#-- --------------------------------------------------------
|
||||||
|
#--
|
||||||
#-- Structure de la table `node_group_user`
|
#-- Structure de la table `node_group_user`
|
||||||
#--
|
#--
|
||||||
CREATE TABLE `{_PREFIX_}node_group_user` (
|
CREATE TABLE `{_PREFIX_}node_group_user` (
|
||||||
|
@ -110,6 +110,8 @@ include($CONF_LIB_PATH."lib/system/system_data/userpreference/userpreferencemana
|
|||||||
include($CONF_LIB_PATH."lib/system/system_data/group/groupmanagerfactory.php");
|
include($CONF_LIB_PATH."lib/system/system_data/group/groupmanagerfactory.php");
|
||||||
/* Ce fichier contient la classe Node */
|
/* Ce fichier contient la classe Node */
|
||||||
include($CONF_LIB_PATH."lib/system/system_data/node/nodemanagerfactory.php");
|
include($CONF_LIB_PATH."lib/system/system_data/node/nodemanagerfactory.php");
|
||||||
|
/* Ce fichier contient la classe NodeSettings */
|
||||||
|
include($CONF_LIB_PATH."lib/system/system_data/nodesettings/nodesettingsmanagerfactory.php");
|
||||||
/* Classe GroupUser (Liaison entre un groupe et un utilisateur) */
|
/* Classe GroupUser (Liaison entre un groupe et un utilisateur) */
|
||||||
include($CONF_LIB_PATH."lib/system/system_data/right/rightmanagerfactory.php");
|
include($CONF_LIB_PATH."lib/system/system_data/right/rightmanagerfactory.php");
|
||||||
/* Classe GroupUser (Liaison entre un groupe et un utilisateur) */
|
/* Classe GroupUser (Liaison entre un groupe et un utilisateur) */
|
||||||
|
@ -976,9 +976,12 @@ var $currentCoordinationObject=null;
|
|||||||
/* Creation du Manager groupe */
|
/* Creation du Manager groupe */
|
||||||
$GLOBALS["SYSTEM_MANAGER"]["GROUP"]=GroupManagerFactory::createInstance( DATA_ACCES_MANAGER_GROUP );
|
$GLOBALS["SYSTEM_MANAGER"]["GROUP"]=GroupManagerFactory::createInstance( DATA_ACCES_MANAGER_GROUP );
|
||||||
|
|
||||||
/* Creation du Manager Noeud */
|
/* Creation du Manager Node */
|
||||||
$GLOBALS["SYSTEM_MANAGER"]["NODE"]=NodeManagerFactory::createInstance( DATA_ACCES_MANAGER_NODE );
|
$GLOBALS["SYSTEM_MANAGER"]["NODE"]=NodeManagerFactory::createInstance( DATA_ACCES_MANAGER_NODE );
|
||||||
|
|
||||||
|
/* Creation du Manager NodSettings */
|
||||||
|
$GLOBALS["SYSTEM_MANAGER"]["NODESETTINGS"]=NodeSettingsManagerFactory::createInstance( DATA_ACCES_MANAGER_NODESETTINGS );
|
||||||
|
|
||||||
/* Creation du Manager Langue */
|
/* Creation du Manager Langue */
|
||||||
$GLOBALS["SYSTEM_MANAGER"]["LANGUAGE"]=LanguageManagerFactory::createInstance( DATA_ACCES_MANAGER_LANGUAGE );
|
$GLOBALS["SYSTEM_MANAGER"]["LANGUAGE"]=LanguageManagerFactory::createInstance( DATA_ACCES_MANAGER_LANGUAGE );
|
||||||
|
|
||||||
|
385
lib/system/system_data/nodesettings/nodesettings.php
Executable file
385
lib/system/system_data/nodesettings/nodesettings.php
Executable file
@ -0,0 +1,385 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**------------------------------------------------
|
||||||
|
*
|
||||||
|
* Rooty, 2021 <rooty@rooty.me>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is protected by copyright, please
|
||||||
|
* read the file COPYRIGHT.
|
||||||
|
* 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. Please
|
||||||
|
* read the file LICENCE.
|
||||||
|
*
|
||||||
|
* Fichier NodeSettings.php
|
||||||
|
*
|
||||||
|
*Ce fichier contient la classe NodeSettings
|
||||||
|
*
|
||||||
|
* @author Rooty <www.rooty.me|rooty@rooty.me>
|
||||||
|
* @link www.rooty.me
|
||||||
|
* @since 2021/04/19
|
||||||
|
* @version 0.1
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
* @copyright Copyright © 2021, Rooty
|
||||||
|
*/
|
||||||
|
|
||||||
|
#####################################################################################################
|
||||||
|
################################# Parametrage
|
||||||
|
#####################################################################################################
|
||||||
|
/**
|
||||||
|
* declaration du system... si cette variable n'est pas définie, les fichier inclus ne marche pas...
|
||||||
|
* cette variable est déclarée sur la page d'execution du script.
|
||||||
|
* <p> if ( !defined('SYSTEM_IN') )
|
||||||
|
* {
|
||||||
|
* die("Hacking attempt");
|
||||||
|
* }</p>
|
||||||
|
*/
|
||||||
|
if ( !defined('SYSTEM_IN') )
|
||||||
|
{
|
||||||
|
die("Hacking attempt");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe NodeSettings
|
||||||
|
*
|
||||||
|
* <P>Classe de gestion des Noeuds de l'arborescence</P>
|
||||||
|
*
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
*/
|
||||||
|
class NodeSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
/**#@+
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var entier
|
||||||
|
* @desc contient l'id numerique du Noeud
|
||||||
|
*/
|
||||||
|
var $id = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine email
|
||||||
|
*/
|
||||||
|
var $email = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine mastodon
|
||||||
|
*/
|
||||||
|
var $mastodon= null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine mobilizon
|
||||||
|
*/
|
||||||
|
var $mobilizon= null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine matrix
|
||||||
|
*/
|
||||||
|
var $matrix= null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine peertube
|
||||||
|
*/
|
||||||
|
var $peertube= null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine nextcloud
|
||||||
|
*/
|
||||||
|
var $nextcloud= null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine twitter
|
||||||
|
*/
|
||||||
|
var $twitter= null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @desc chaine facebook
|
||||||
|
*/
|
||||||
|
var $facebook= null;
|
||||||
|
|
||||||
|
/**#@-*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur de la classe NodeSettings PHP5
|
||||||
|
* <p>Initialise la classe NodeSettings</p>
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->id =null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut Id.
|
||||||
|
* @access public
|
||||||
|
* @return entier Id du Noeud
|
||||||
|
*/
|
||||||
|
function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut Id.
|
||||||
|
* @access public
|
||||||
|
* @param entier Id du Noeud
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setId($id)
|
||||||
|
{
|
||||||
|
if (!is_numeric($id))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->id=$id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut email
|
||||||
|
* @access public
|
||||||
|
* @return chaine email
|
||||||
|
*/
|
||||||
|
function getEmail()
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut email
|
||||||
|
* @access public
|
||||||
|
* @param chaine email
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setEmail($email)
|
||||||
|
{
|
||||||
|
if (!is_string($email))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->email=$email;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut Mastodon.
|
||||||
|
* @access public
|
||||||
|
* @return chaine Mastodon
|
||||||
|
*/
|
||||||
|
function getMastodon()
|
||||||
|
{
|
||||||
|
return $this->mastodon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut Mastodon.
|
||||||
|
* @access public
|
||||||
|
* @param entier mastodon
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setMastodon($mastodon)
|
||||||
|
{
|
||||||
|
if (!is_string($mastodon))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->mastodon=$mastodon;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut Mobolizon.
|
||||||
|
* @access public
|
||||||
|
* @return chaine Mobilizon
|
||||||
|
*/
|
||||||
|
function getMobilizon()
|
||||||
|
{
|
||||||
|
return $this->mobilizon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut Mobilizon.
|
||||||
|
* @access public
|
||||||
|
* @param chaine mobilizon
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setMobilizon($mobilizon)
|
||||||
|
{
|
||||||
|
if (!is_string($mobilizon))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->mobilizon=$mobilizon;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut matrix.
|
||||||
|
* @access public
|
||||||
|
* @param chaine matrix
|
||||||
|
* @return chaine matrix
|
||||||
|
*/
|
||||||
|
function getMatrix()
|
||||||
|
{
|
||||||
|
return $this->matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut matrix.
|
||||||
|
* @access public
|
||||||
|
* @param chaine matrix
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setMatrix($matrix)
|
||||||
|
{
|
||||||
|
if (!is_string($mobilizon))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->matrix=$matrix;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut peertube.
|
||||||
|
* @access public
|
||||||
|
* @return chaine peertube
|
||||||
|
*/
|
||||||
|
function getPeertube()
|
||||||
|
{
|
||||||
|
return $this->peertube;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut peertube.
|
||||||
|
* @access public
|
||||||
|
* @param chaine peertube
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setPeertube($peertube)
|
||||||
|
{
|
||||||
|
if (!is_string($peertube))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->peertube=$peertube;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut nextcloud.
|
||||||
|
* @access public
|
||||||
|
* @return chaine nextcloud
|
||||||
|
*/
|
||||||
|
function getNextcloud()
|
||||||
|
{
|
||||||
|
return $this->nextcloud;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut nextcloud.
|
||||||
|
* @access public
|
||||||
|
* @param chaine nextcloud
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setNextcloud($nextcloud)
|
||||||
|
{
|
||||||
|
if (!is_string($nextcloud))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->nextcloud=$nextcloud;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut twitter.
|
||||||
|
* @access public
|
||||||
|
* @return chaine twitter
|
||||||
|
*/
|
||||||
|
function getTwitter()
|
||||||
|
{
|
||||||
|
return $this->twitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut twitter.
|
||||||
|
* @access public
|
||||||
|
* @param chaine twitter
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setTwitter($twitter)
|
||||||
|
{
|
||||||
|
if (!is_string($twitter))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->twitter=$twitter;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "getteur" de l'attribut facebook.
|
||||||
|
* @access public
|
||||||
|
* @return chaine facebook
|
||||||
|
*/
|
||||||
|
function getFacebook()
|
||||||
|
{
|
||||||
|
return $this->facebook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "setteur" de l'attribut facebook.
|
||||||
|
* @access public
|
||||||
|
* @param chaine facebook
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function setFacebook($facebook)
|
||||||
|
{
|
||||||
|
if (!is_string($facebook))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->facebook=$facebook;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doload : load de l'objet de l'objet NodeSettings.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param entier identifiant numérique du Node
|
||||||
|
* @param chaine libelle du NodeSettings
|
||||||
|
*/
|
||||||
|
function doLoad($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
$this->setId($id);
|
||||||
|
$this->setEmail($email);
|
||||||
|
$this->setMastodon($mastodon);
|
||||||
|
$this->setMobilizon($mobilizon);
|
||||||
|
$this->setMatrix($matrix);
|
||||||
|
$this->setPeertube($peertube);
|
||||||
|
$this->setNextcloud($nextcloud);
|
||||||
|
$this->setTwitter($twitter);
|
||||||
|
$this->setFacebook($facebook);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isLoaded: Verifie que l'ID est affecté
|
||||||
|
*
|
||||||
|
* <P> après un load depuis la base, l'id de l'objet est affecté, cette fonction le verifie</P>
|
||||||
|
* @access public
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function isLoaded()
|
||||||
|
{
|
||||||
|
return (is_numeric($this->id) && ($this->id != 0) ) ?true:false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
423
lib/system/system_data/nodesettings/nodesettingsmanager.php
Executable file
423
lib/system/system_data/nodesettings/nodesettingsmanager.php
Executable file
@ -0,0 +1,423 @@
|
|||||||
|
<?php
|
||||||
|
/**------------------------------------------------
|
||||||
|
*
|
||||||
|
* Rooty, 2021 <rooty@rooty.me>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is protected by copyright, please
|
||||||
|
* read the file COPYRIGHT.
|
||||||
|
* 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. Please
|
||||||
|
* read the file LICENCE.
|
||||||
|
*
|
||||||
|
* Fichier NodeSettingsManager.php
|
||||||
|
*
|
||||||
|
* Ce fichier contient la classe NodeSettingsManager
|
||||||
|
*
|
||||||
|
* @author Rooty <www.rooty.me|rooty@rooty.me>
|
||||||
|
* @link www.rooty.me
|
||||||
|
* @since 2021/04/19
|
||||||
|
* @version 0.1
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
* @copyright Copyright © 2021, Rooty
|
||||||
|
*/
|
||||||
|
|
||||||
|
#####################################################################################################
|
||||||
|
################################# Parametrage
|
||||||
|
#####################################################################################################
|
||||||
|
|
||||||
|
/**
|
||||||
|
* declaration du system... si cette variable n'est pas définie, les fichier inclus ne marche pas...
|
||||||
|
* cette variable est déclarée sur la page d'execution du script.
|
||||||
|
*<p> if ( !defined('SYSTEM_IN') )
|
||||||
|
* {
|
||||||
|
* die("Hacking attempt");
|
||||||
|
* }</p>
|
||||||
|
*/
|
||||||
|
if ( !defined('SYSTEM_IN') )
|
||||||
|
{
|
||||||
|
die("Hacking attempt");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appel à la classe Node...
|
||||||
|
*/
|
||||||
|
require ($CONF_LIB_PATH."lib/system/system_data/nodesettings/nodesettings.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe NodeSettingsManager
|
||||||
|
*
|
||||||
|
* <P>Classe de gestion des instances de Nodes <br>
|
||||||
|
* (permet de fabriquer, detruire, mettre à jour des objet Nodes)<br>
|
||||||
|
* Cette classe se sert des ressources à sa disposition (dans ./ressource)<br>
|
||||||
|
* Les Classes de ressource doivent avoir toutes les methodes correspondantes <br>
|
||||||
|
* aux methodes de la classe intitulés sourceXXX</P>
|
||||||
|
*
|
||||||
|
* <p>Est configuré dans data_acces.php : <br>
|
||||||
|
* - La Source d'information (Db)<br>
|
||||||
|
* l'objet ressource se sert lui-même des classes d'accés aux données(lib/data_source/...)<br>
|
||||||
|
* </p>
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
*/
|
||||||
|
class NodeSettingsManager extends Manager
|
||||||
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor
|
||||||
|
//
|
||||||
|
/**
|
||||||
|
* Constructeur de la classe NodeSettingsManager PHP5
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#### Méthodes abstraites
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doLoadFromId : charge les paramètres du Noeud
|
||||||
|
*
|
||||||
|
* <P>Chargement depuis la source de données</P>
|
||||||
|
* <P>Cette méthode a pour but d'être surchargée et de gérer les accés aux données</P>
|
||||||
|
* @param entier identifiant de du noeud
|
||||||
|
* @access public
|
||||||
|
* @abstract
|
||||||
|
* @return tableau tableau des éléments de paramètres d'un Noeud
|
||||||
|
*/
|
||||||
|
function doLoadFromId($id)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doUpdate : Update des paramètres du Noeud
|
||||||
|
*
|
||||||
|
* <P>Insertion dans la source de données</P>
|
||||||
|
* <P>Cette méthode a pour but d'être surchargée et de gérer les accés aux données</P>
|
||||||
|
* @param entier identifiant du Noeud père
|
||||||
|
* @param chaine libelle du Noeud
|
||||||
|
* @param chaine icone du Noeud
|
||||||
|
* @access public
|
||||||
|
* @abstract
|
||||||
|
* @return entier
|
||||||
|
*/
|
||||||
|
function doUpdate($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
return 0; /* entier */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doInsert : Insert des paramètres du Noeud
|
||||||
|
*
|
||||||
|
* <P>Insertion dans la source de données</P>
|
||||||
|
* <P>Cette méthode a pour but d'être surchargée et de gérer les accés aux données</P>
|
||||||
|
* @param entier identifiant du Noeud père
|
||||||
|
* @param chaine libelle du Noeud
|
||||||
|
* @param chaine icone du Noeud
|
||||||
|
* @access public
|
||||||
|
* @abstract
|
||||||
|
* @return entier
|
||||||
|
*/
|
||||||
|
function doInsert($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doDelete : Detruit les paramètres du Noeud
|
||||||
|
*
|
||||||
|
* <P>Suppression de l'objet à partir de son identifiant et dans la source de données</P>
|
||||||
|
* <P>Cette méthode a pour but d'être surchargée et de gérer les accés aux données</P>
|
||||||
|
* @param entier identifiant de du noeud
|
||||||
|
* @access public
|
||||||
|
* @abstract
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function doDelete($id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#### Methodes privee
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sourceLoadFromId: charge à partir d'un identifiant
|
||||||
|
*
|
||||||
|
* <p>Permet le récupération des infos d'un objet Node à partir de son identifiant</p>
|
||||||
|
* <P> Cette méthode gére le formatage des données avant leur passage à la source de données (methode doXXX equivalente)</P>
|
||||||
|
* <p>Retourne un tableau contenant les infos de l'objet<br>
|
||||||
|
* <br>ou faux si n'existe pas</p>
|
||||||
|
* @param identifiant du Noeud
|
||||||
|
* @access private
|
||||||
|
* @return tableau
|
||||||
|
*/
|
||||||
|
function sourceLoadFromId($id)
|
||||||
|
{
|
||||||
|
$tab=$this->doLoadFromId($id);
|
||||||
|
# Gestion d'un tableau intermediaire avec la reprise des elements
|
||||||
|
if (!is_array($tab))
|
||||||
|
{
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=1;
|
||||||
|
$classe="Node";
|
||||||
|
$message="Erreur dans NodeSettingsManager";
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return array();
|
||||||
|
}else{
|
||||||
|
if (!Is_numeric($tab["id"]))
|
||||||
|
{
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=1;
|
||||||
|
$classe="Node";
|
||||||
|
$message="Erreur dans NodeSettingsManager";
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return array();
|
||||||
|
}else{
|
||||||
|
return $tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sourceInsert: Insert le Noeud
|
||||||
|
*
|
||||||
|
* <p>Insertion de l'objet Noeud dans la source de données<br>
|
||||||
|
* indifférement du type de cette source</p>
|
||||||
|
* <P> Cette méthode gére le formatage des données avant leur passage à la source de données (methode doXXX equivalente)</P>
|
||||||
|
* <p>Retourne L'identifiant de l'objet inséré</p>
|
||||||
|
* @param entier identifiant du Noeud père
|
||||||
|
* @param chaine libelle du Noeud
|
||||||
|
* @param chaine icone du Noeud
|
||||||
|
* @access private
|
||||||
|
* @return entier
|
||||||
|
*/
|
||||||
|
function sourceInsert($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
# Gestion d'un tableau intermediaire avec la reprise des elements
|
||||||
|
if (!is_numeric($id))
|
||||||
|
{
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=1;
|
||||||
|
$classe="Node";
|
||||||
|
$message="Erreur dans NodeSettingsManager";
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->doInsert($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sourceUpdate: Met à jour le Noeud
|
||||||
|
*
|
||||||
|
* <P>Mise à jour de l'objet indifferemment de la source de données</P>
|
||||||
|
* <P> Cette méthode gére le formatage des données avant leur passage à la source de données (methode doXXX equivalente)</P>
|
||||||
|
* @param entier identifiant du Noeud père
|
||||||
|
* @param chaine libelle du Noeud
|
||||||
|
* @param chaine icone du Noeud
|
||||||
|
* @access private
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function sourceUpdate($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
# Gestion d'un tableau intermediaire avec la reprise des elements
|
||||||
|
if (!Is_numeric($id))
|
||||||
|
{
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=1;
|
||||||
|
$classe="Node";
|
||||||
|
$message="Erreur dans NodeSettingsManager";
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->doUpdate($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sourceDelete: Detruit le Noeud
|
||||||
|
*
|
||||||
|
*<p>Suppression de l'objet à partir de son identifiant</p>
|
||||||
|
*<P> Cette méthode gére le formatage des données avant leur passage à la source de données (methode doXXX equivalente)</P>
|
||||||
|
* @param entier identifiant de du noeud
|
||||||
|
* @access private
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function sourceDelete($id)
|
||||||
|
{
|
||||||
|
return $this->doDelete($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
#### Methodes public
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
/**
|
||||||
|
* createNewInstance : créer un objet vierge
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return objet
|
||||||
|
*/
|
||||||
|
function createNewInstance()
|
||||||
|
{
|
||||||
|
return new NodeSettings();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* createInstance : récupere l'objet avec l'identifiant $id
|
||||||
|
*
|
||||||
|
* @param entier identifiant de l'association Node
|
||||||
|
* @access public
|
||||||
|
* @return object retourne un objet de type Node
|
||||||
|
*/
|
||||||
|
function createInstance($id)
|
||||||
|
{
|
||||||
|
$return = new NodeSettings();
|
||||||
|
if (is_numeric($id))
|
||||||
|
{
|
||||||
|
/* Récupération des infos */
|
||||||
|
$tab=$this->sourceLoadFromId($id);
|
||||||
|
if (is_array($tab) && isset($tab["id"]) && is_numeric($tab["id"]))
|
||||||
|
{
|
||||||
|
/* création et alimentation de l'objet */
|
||||||
|
$return->doLoad($tab["id"], $tab["email"], $tab["mastodon"], $tab["mobilizon"], $tab["matrix"], $tab["peertube"], $tab["nextcloud"], $tab["twitter"], $tab["facebook"]);
|
||||||
|
}else{
|
||||||
|
$systemError=3;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur id inexistant ".$id;
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$systemError=3;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur id invalide ".$id;
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteInstance : detruit l'objet physique
|
||||||
|
*
|
||||||
|
* @param object objet Node à effacer
|
||||||
|
* @access public
|
||||||
|
* @return object objetNode mis à jour
|
||||||
|
*/
|
||||||
|
function deleteInstance($obj)
|
||||||
|
{
|
||||||
|
$return = false;
|
||||||
|
if ( strtolower(get_class($obj))=="nodesettings" )
|
||||||
|
{
|
||||||
|
if($obj->isLoaded()==true)
|
||||||
|
{
|
||||||
|
/* Récupération des infos */
|
||||||
|
$this->CallSystemPlugin("__deleteNodeSettings", $obj);
|
||||||
|
$return=$this->sourceDelete($obj->getId());
|
||||||
|
$obj->setId(0);
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=3;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur objet invalide ";
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateInstance : met à jour l'objet
|
||||||
|
*
|
||||||
|
* @param object objet Node à modifier
|
||||||
|
* @access public
|
||||||
|
* @return object objetNode mis à jour
|
||||||
|
*/
|
||||||
|
function updateInstance($obj)
|
||||||
|
{
|
||||||
|
$return = false;
|
||||||
|
if ((strtolower(get_class($obj))=="nodesettings") && ($obj->isLoaded()==true))
|
||||||
|
{
|
||||||
|
/* Récupération des infos */
|
||||||
|
$id=$this->sourceUpdate($obj->getId(), $obj->getEmail(), $obj->getMastodon(), $obj->Mobilizon(), $obj->getMatrix(), $obj->getPeertube(), $obj->getNextcloud(), $obj->getTwitter(), $obj->getFacebook());
|
||||||
|
$this->CallSystemPlugin("__updateNodeSettings", $obj);
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=3;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur objet invalide ";
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* insertInstance : créer enregistre l'objet
|
||||||
|
*
|
||||||
|
* <p>affecte l'id de l'objet si nécessaire</p>
|
||||||
|
* @param object objet Node à inserer
|
||||||
|
* @access public
|
||||||
|
* @return object objetNode mis à jour
|
||||||
|
*/
|
||||||
|
function insertInstance($obj)
|
||||||
|
{
|
||||||
|
if ((strtolower(get_class($obj))==strtolower("NodeSettings")))
|
||||||
|
{
|
||||||
|
if ($obj->isLoaded()==false)
|
||||||
|
{
|
||||||
|
/* Récupération des infos */
|
||||||
|
$id=$this->sourceInsert($obj->getEmail(), $obj->getMastodon(), $obj->Mobilizon(), $obj->getMatrix(), $obj->getPeertube(), $obj->getNextcloud(), $obj->getTwitter(), $obj->getFacebook());
|
||||||
|
$obj->setId($id);
|
||||||
|
$this->CallSystemPlugin("__insertNodeSettings", $obj);
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=3;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur objet invalide ";
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* saveInstance : créer enregistre l'objet
|
||||||
|
*
|
||||||
|
* @param object objet Node à sauvegarder
|
||||||
|
* @access public
|
||||||
|
* @return object objetNode mis à jour
|
||||||
|
*/
|
||||||
|
function saveInstance($obj)
|
||||||
|
{
|
||||||
|
if ((strtolower(get_class($obj))==strtolower("NodeSettings")))
|
||||||
|
{
|
||||||
|
if ($obj->isLoaded()==false)
|
||||||
|
{
|
||||||
|
$return=$this->insertInstance($obj);
|
||||||
|
}else{
|
||||||
|
$return=$this->updateInstance($obj);
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=3;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur objet invalide ";
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
$return=$obj;
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
99
lib/system/system_data/nodesettings/nodesettingsmanagerfactory.php
Executable file
99
lib/system/system_data/nodesettings/nodesettingsmanagerfactory.php
Executable file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**------------------------------------------------
|
||||||
|
*
|
||||||
|
* Rooty, 2021 <rooty@rooty.me>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is protected by copyright, please
|
||||||
|
* read the file COPYRIGHT.
|
||||||
|
* 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. Please
|
||||||
|
* read the file LICENCE.
|
||||||
|
*
|
||||||
|
* Fichier NodeSettingsManagerFactory.php
|
||||||
|
*
|
||||||
|
*Ce fichier contient la classe NodeSettingsManagerFactory
|
||||||
|
*
|
||||||
|
* @author Rooty <www.rooty.me|rooty@rooty.me>
|
||||||
|
* @link www.rooty.me
|
||||||
|
* @since 2021/04/19
|
||||||
|
* @version 0.1
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage Node
|
||||||
|
* @copyright Copyright © 2021, Rooty
|
||||||
|
*/
|
||||||
|
|
||||||
|
#####################################################################################################
|
||||||
|
################################# Parametrage
|
||||||
|
#####################################################################################################
|
||||||
|
/**
|
||||||
|
* declaration du system... si cette variable n'est pas définie, les fichier inclus ne marche pas...
|
||||||
|
* cette variable est déclarée sur la page d'execution du script.
|
||||||
|
*<p> if ( !defined('SYSTEM_IN') )
|
||||||
|
* {
|
||||||
|
* die("Hacking attempt");
|
||||||
|
* }</p>
|
||||||
|
*/
|
||||||
|
if ( !defined('SYSTEM_IN') )
|
||||||
|
{
|
||||||
|
die("Hacking attempt");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appel à la classe Node...
|
||||||
|
*/
|
||||||
|
require ($CONF_LIB_PATH."lib/system/system_data/nodesettings/nodesettingsmanager.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe NodeSettingsManagerFactory
|
||||||
|
*
|
||||||
|
* <P>Permet la creation du bon Manager</P>
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
*/
|
||||||
|
class NodeSettingsManagerFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* createInstance : créer l'instance du gestionnaire de Noeud et renvoi celle-ci
|
||||||
|
*
|
||||||
|
* @param chaine type de ressource...
|
||||||
|
* @access public
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function createInstance($type)
|
||||||
|
{
|
||||||
|
global $CONF_LIB_PATH;
|
||||||
|
if (NodeSettingsManagerFactory::isValidType($type))
|
||||||
|
{
|
||||||
|
/* inclusion de la lib corresspondante (utilisation du include_once pour que celle-ci ne soit chargé qu'une seule fois) */
|
||||||
|
include_once($CONF_LIB_PATH."lib/system/system_data/nodesettings/ressource/nodesettingsmanager".$type.".php");
|
||||||
|
$className="NodeSettingsManager".$type;
|
||||||
|
$Tmp= new $className();
|
||||||
|
return $Tmp;
|
||||||
|
}else{
|
||||||
|
/* Erreur */
|
||||||
|
$systemError=1;
|
||||||
|
$classe="NodeSettingsManager";
|
||||||
|
$message="Erreur objet invalide ";
|
||||||
|
addError($systemError, $classe, $message, __line__, __file__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isValidType : test si le type est valide ou non
|
||||||
|
*
|
||||||
|
* @param chaine type de ressource...
|
||||||
|
* @access private
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function isValidType($type)
|
||||||
|
{
|
||||||
|
global $CONF_LIB_PATH;
|
||||||
|
return (file_exists($CONF_LIB_PATH."lib/system/system_data/nodesettings/ressource/nodesettingsmanager".$type.".php"))? true:false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
365
lib/system/system_data/nodesettings/ressource/nodesettingsmanagerdb.php
Executable file
365
lib/system/system_data/nodesettings/ressource/nodesettingsmanagerdb.php
Executable file
@ -0,0 +1,365 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**------------------------------------------------
|
||||||
|
*
|
||||||
|
* Rooty, 2021 <rooty@rooty.me>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is protected by copyright, please
|
||||||
|
* read the file COPYRIGHT.
|
||||||
|
* 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. Please
|
||||||
|
* read the file LICENCE.
|
||||||
|
*
|
||||||
|
* Fichier NodeSettingsManagerDb.php
|
||||||
|
*
|
||||||
|
* Ce fichier contient la classe NodeSettingsManagerDb
|
||||||
|
*
|
||||||
|
* @author Rooty <www.rooty.me|rooty@rooty.me>
|
||||||
|
* @link www.rooty.me
|
||||||
|
* @since 2021/04/19
|
||||||
|
* @version 0.1
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
* @copyright Copyright © 2021, Rooty
|
||||||
|
*/
|
||||||
|
|
||||||
|
#####################################################################################################
|
||||||
|
################################# Parametrage
|
||||||
|
#####################################################################################################
|
||||||
|
/**
|
||||||
|
* declaration du system... si cette variable n'est pas définie, les fichier inclus ne marche pas...
|
||||||
|
* cette variable est déclarée sur la page d'execution du script.
|
||||||
|
*<p> if ( !defined('SYSTEM_IN') )
|
||||||
|
* {
|
||||||
|
* die("Hacking attempt");
|
||||||
|
* }</p>
|
||||||
|
*/
|
||||||
|
if ( !defined('SYSTEM_IN') )
|
||||||
|
{
|
||||||
|
die("Hacking attempt");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe NodeSettingsManagerDb
|
||||||
|
*
|
||||||
|
* classe de gestion des Nodes pour une do de données database (type gérés par database)<br><br>
|
||||||
|
* Sont configuré dans config_data_acces.php:<br>
|
||||||
|
* - La do d'information <br>
|
||||||
|
* (actuellement seul DB possible->Pour ajouter une do reproduire NodeNodeSettingsManagerDb)<br>
|
||||||
|
* - Le Nom de la Table<br>
|
||||||
|
* - La configuration (Paramétrage des dos de do de données) est faite dans config_data_do.php<br>
|
||||||
|
* - La declaration de la connexion est faite à partir de config_system.php
|
||||||
|
*
|
||||||
|
* @package system_data
|
||||||
|
* @subpackage NodeSettings
|
||||||
|
*/
|
||||||
|
class NodeSettingsManagerDb extends NodeManager
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var chaine
|
||||||
|
* @access private
|
||||||
|
* @desc ID de la Node
|
||||||
|
*/
|
||||||
|
var $table = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object
|
||||||
|
* @access private
|
||||||
|
* @desc objet database
|
||||||
|
*/
|
||||||
|
var $conn = null;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur de la classe NodeSettingsManagerDb PHP4
|
||||||
|
*
|
||||||
|
* <p>Initialise la NodeSettingsManagerDb</p>
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function NodeSettingsManagerDb()
|
||||||
|
{
|
||||||
|
$this->__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur de la classe NodeSettingsManagerDb PHP5
|
||||||
|
*
|
||||||
|
* <p>Initialise la NodeSettingsManagerDb</p>
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->setTable( DATA_ACCES_TABLE_NODESETTINGS ); /* Appel à la constant correspondant */
|
||||||
|
$this->initSqlAttribut(); /* initialisation des noms de champs */
|
||||||
|
$this->setConn($GLOBALS['SYSTEM_DATABASE_CONN']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getTable : recupere le nom de la table utilisée
|
||||||
|
* @access public
|
||||||
|
* @return chaine
|
||||||
|
*/
|
||||||
|
function getTable()
|
||||||
|
{
|
||||||
|
return $this->table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setTable : recupere le nom de la table utilisée
|
||||||
|
* @access public
|
||||||
|
* @param chaine nom de la table
|
||||||
|
* @return chaine
|
||||||
|
*/
|
||||||
|
function setTable($chaine)
|
||||||
|
{
|
||||||
|
if (!is_string($chaine))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->table=$chaine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getTable : recupere le nom de la table utilisée
|
||||||
|
* @access public
|
||||||
|
* @return chaine
|
||||||
|
*/
|
||||||
|
function getConn()
|
||||||
|
{
|
||||||
|
return $this->conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setTable : recupere le nom de la table utilisée
|
||||||
|
* @access public
|
||||||
|
* @param object objet classe "database"
|
||||||
|
* @return chaine
|
||||||
|
*/
|
||||||
|
function setConn(&$obj)
|
||||||
|
{
|
||||||
|
if (!is_object($obj))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->conn=&$obj;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doLoadFromId: Charge le Noeud depuis la BD
|
||||||
|
*
|
||||||
|
* <p>Retourne un tableau contenant les infos de l'objet</p>
|
||||||
|
* @access private
|
||||||
|
* @param entier identifiant du Noeud
|
||||||
|
* @return tableau
|
||||||
|
*/
|
||||||
|
function doLoadFromId($id)
|
||||||
|
{
|
||||||
|
$sql = "SELECT * FROM ".$this->getTable()." WHERE ".$this->getSqlName("id")."=".$id;
|
||||||
|
// $sql.= " AND ".$this->getSqlName("domain")."=".$_SERVER["SERVER_NAME"];
|
||||||
|
|
||||||
|
# Requete
|
||||||
|
$result=$this->conn->sql_query($sql);
|
||||||
|
|
||||||
|
if ($this->conn->sql_numrows()==0)
|
||||||
|
{
|
||||||
|
$systemError=1;
|
||||||
|
$classe="NodeSettings";
|
||||||
|
$message="Erreur du load from id dans l'objet FetchNodeSettingsManagerDb LoadFromId, avec l'id=".$id;
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$tab=$this->conn->sql_fetchrow();
|
||||||
|
$tab=$this->translateArray($tab);
|
||||||
|
|
||||||
|
# Destruction des éléments
|
||||||
|
$this->conn->sql_freeresult();
|
||||||
|
return $tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doInsert: Insert le Noeud dans la BD
|
||||||
|
*
|
||||||
|
* <P>Insertion dans la Bd</P>
|
||||||
|
* @param entier identifiant du pére
|
||||||
|
* @param chaine libelle de du noeud
|
||||||
|
* @param chaine icone de du noeud
|
||||||
|
* @access private
|
||||||
|
* @return entier
|
||||||
|
*/
|
||||||
|
function doInsert($email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
$sql="INSERT INTO ".$this->getTable()." ("
|
||||||
|
.$this->getSqlName("email").", "
|
||||||
|
.$this->getSqlName("mastodon").", "
|
||||||
|
.$this->getSqlName("mobilizon").", "
|
||||||
|
.$this->getSqlName("matrix").", "
|
||||||
|
.$this->getSqlName("peertube").", "
|
||||||
|
.$this->getSqlName("nextcloud").", "
|
||||||
|
.$this->getSqlName("twitter").", "
|
||||||
|
.$this->getSqlName("facebook").") VALUES (";
|
||||||
|
$sql.="'".$email."', '".$mastodon."', '".$mobilizon."', '".$matrix."', '".$peertube."', '".$nextcloud."', '".$twitter."', '".$facebook."')";
|
||||||
|
|
||||||
|
# Requete
|
||||||
|
$result=$this->conn->sql_query($sql);
|
||||||
|
|
||||||
|
if ($this->conn->sql_affectedrows()==0)
|
||||||
|
{
|
||||||
|
$systemError=1;
|
||||||
|
$classe="NodeSettings";
|
||||||
|
$message="Erreur d'INSERTION dans FetchNodeSettingsManagerDb avec le courriel".$email."\n".$sql;
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$retour=$this->conn->sql_nextid();
|
||||||
|
return $retour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doUpdate : Modifie le Noeud dans la BD
|
||||||
|
*
|
||||||
|
* <P>Mise à jour de la Node</P>
|
||||||
|
* @param entier identifiant
|
||||||
|
* @param entier identifiant du pére
|
||||||
|
* @param chaine libelle de du noeud
|
||||||
|
* @param chaine icone de du noeud
|
||||||
|
* @access private
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function doUpdate($id, $email, $mastodon, $mobilizon, $matrix, $peertube, $nextcloud, $twitter, $facebook)
|
||||||
|
{
|
||||||
|
$sql="UPDATE ".$this->getTable()." SET "
|
||||||
|
.$this->getSqlName("id")."='".$id."', "
|
||||||
|
.$this->getSqlName("email")."='".$email."', "
|
||||||
|
.$this->getSqlName("mastodon")."='".$mastodon."', "
|
||||||
|
.$this->getSqlName("mobilizon")."='".$mobilizon."', "
|
||||||
|
.$this->getSqlName("matrix")."='".$matrix."', "
|
||||||
|
.$this->getSqlName("peertube")."='".$peertube."', "
|
||||||
|
.$this->getSqlName("nextcloud")."='".$nextcloud."', "
|
||||||
|
.$this->getSqlName("twitter")."='".$twitter."', "
|
||||||
|
.$this->getSqlName("facebook")."='".$facebook."' WHERE ";
|
||||||
|
$sql.=$this->getSqlName("id")."=".$id;
|
||||||
|
|
||||||
|
# Requete
|
||||||
|
$result=$this->conn->sql_query($sql);
|
||||||
|
$retour=$id;
|
||||||
|
return $retour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doDelete : Detruit le Noeud dans la BD
|
||||||
|
*
|
||||||
|
* <p>Suppression du noeud à partir de son identifiant</p>
|
||||||
|
* @param entier identifiant du Noeud
|
||||||
|
* @access private
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function doDelete($id)
|
||||||
|
{
|
||||||
|
$sql="DELETE FROM ".$this->getTable()." WHERE ".$this->getSqlName("id")."=".$id;
|
||||||
|
|
||||||
|
# Requete
|
||||||
|
$result=$this->conn->sql_query($sql);
|
||||||
|
|
||||||
|
if ($this->conn->sql_affectedrows()==0)
|
||||||
|
{
|
||||||
|
$systemError=1;
|
||||||
|
$classe="Node";
|
||||||
|
$message="Erreur de SUPPRESSION dans FetchNodeSettingsManagerDb avec l'id ".$id;
|
||||||
|
addError($systemError,$classe,$message, __line__, __file__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Utilitaires pour la gestion des compatibilités BD
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
/**
|
||||||
|
* translateKey : change les cles du tableau resultant d'une requete en tableau de données pour l'objet
|
||||||
|
*
|
||||||
|
* <p>Supprime le nom de la table dans les noms de champs renvoyés par la BD<br/>
|
||||||
|
* garde la compatibilité avec les version précédentes</p>
|
||||||
|
* @param array tableau sql
|
||||||
|
* @access private
|
||||||
|
* @return array tableau des attributs
|
||||||
|
*/
|
||||||
|
function translateArray($sqlArray)
|
||||||
|
{
|
||||||
|
/* Cas nouvelle BD systeme */
|
||||||
|
$result["id"] =$sqlArray[$this->getSqlName('id')];
|
||||||
|
$result["email"] =$sqlArray[$this->getSqlName("email")];
|
||||||
|
$result["mastodon"] =$sqlArray[$this->getSqlName("mastodon")];
|
||||||
|
$result["mobilizon"] =$sqlArray[$this->getSqlName("mobilizon")];
|
||||||
|
$result["matrix"] =$sqlArray[$this->getSqlName("matrix")];
|
||||||
|
$result["peertube"] =$sqlArray[$this->getSqlName("peertube")];
|
||||||
|
$result["nextcloud"] =$sqlArray[$this->getSqlName("nextcloud")];
|
||||||
|
$result["twitter"] =$sqlArray[$this->getSqlName("twitter")];
|
||||||
|
$result["facebook"] =$sqlArray[$this->getSqlName("facebook")];
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initSqlAttributName : recupere le nom d'un attribut a partir d'une cle
|
||||||
|
*
|
||||||
|
* <p>En fonction de la version sql, on trouvera ici la correspondance entre le nom attribut de l'objet et son nom en BD<br/>
|
||||||
|
* cette methode permet de garder la compatibilité avec les version précédentes</p>
|
||||||
|
* @param chaine nom de l'attribut recherche
|
||||||
|
* @access private
|
||||||
|
* @return booleen
|
||||||
|
*/
|
||||||
|
function initSqlAttribut()
|
||||||
|
{
|
||||||
|
if(defined('DATA_ACCES_TABLE_VERSION'))
|
||||||
|
{
|
||||||
|
if( DATA_ACCES_TABLE_VERSION == 1)
|
||||||
|
{
|
||||||
|
$this->sqlAttributArray["id"] ="node_id";
|
||||||
|
$this->sqlAttributArray["email"] ="node_email";
|
||||||
|
$this->sqlAttributArray["mastodon"] ="node_mastodon";
|
||||||
|
$this->sqlAttributArray["mobilizon"] ="node_mobilizon";
|
||||||
|
$this->sqlAttributArray["matrix"] ="node_matrix";
|
||||||
|
$this->sqlAttributArray["peertube"] ="node_peertube";
|
||||||
|
$this->sqlAttributArray["nextcloud"] ="node_nextcloud";
|
||||||
|
$this->sqlAttributArray["twitter"] ="node_twitter";
|
||||||
|
$this->sqlAttributArray["facebook"] ="node_facebook";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->sqlAttributArray["id"] ="id";
|
||||||
|
$this->sqlAttributArray["email"] ="email";
|
||||||
|
$this->sqlAttributArray["mastodon"] ="mastodon";
|
||||||
|
$this->sqlAttributArray["mobilizon"] ="mobilizon";
|
||||||
|
$this->sqlAttributArray["matrix"] ="matrix";
|
||||||
|
$this->sqlAttributArray["peertube"] ="peertube";
|
||||||
|
$this->sqlAttributArray["nextcloud"] ="nextcloud";
|
||||||
|
$this->sqlAttributArray["twitter"] ="twitter";
|
||||||
|
$this->sqlAttributArray["facebook"] ="facebook";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getSqlName : recupere le nom du champ a partir d'une cle
|
||||||
|
*
|
||||||
|
* <p>En fonction de la version sql, on trouvera ici la correspondance entre le nom attribut de l'objet et son nom en BD<br/>
|
||||||
|
* Cette methode permet de garder la compatibilite avec les version précédentes<br/>
|
||||||
|
* Elle s'appuie sur le tableau associatif $this->sqlAttributArray genere par initSqlAttributArray</p>
|
||||||
|
* @param chaine nom de l'attribut recherche
|
||||||
|
* @access private
|
||||||
|
* @return chaine nom du champ sql
|
||||||
|
*/
|
||||||
|
function getSqlName($attribut)
|
||||||
|
{
|
||||||
|
return ( (isset($this->sqlAttributArray[$attribut]))?$this->sqlAttributArray[$attribut]:$attribut );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user