mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-12 20:41:26 +01:00
Dbut ajout module "Phenix"
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
//require_once(DOL_DOCUMENT_ROOT.'/lib/webcal.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/lib/phenix.class.php');
|
||||||
|
|
||||||
|
|
||||||
if (!$user->admin)
|
if (!$user->admin)
|
||||||
@@ -74,7 +74,6 @@ if ($actionsave)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
elseif ($actiontest)
|
elseif ($actiontest)
|
||||||
{
|
{
|
||||||
//$resql=$db->query("select count(*) from llx_const");
|
//$resql=$db->query("select count(*) from llx_const");
|
||||||
@@ -95,6 +94,7 @@ elseif ($actiontest)
|
|||||||
if ($phenix->localdb->connected == 1 && $phenix->localdb->database_selected == 1)
|
if ($phenix->localdb->connected == 1 && $phenix->localdb->database_selected == 1)
|
||||||
{
|
{
|
||||||
// V<>rifie si bonne base
|
// V<>rifie si bonne base
|
||||||
|
/*
|
||||||
$sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'";
|
$sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'";
|
||||||
$resql=$phenix->localdb->query($sql);
|
$resql=$phenix->localdb->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@@ -111,39 +111,41 @@ elseif ($actiontest)
|
|||||||
$webcal->version=$obj->cal_value;
|
$webcal->version=$obj->cal_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
$mesg ="<div class=\"ok\">";
|
$mesg ="<div class=\"ok\">";
|
||||||
$mesg.=$langs->trans("WebCalTestOk",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"],$_POST["phpwebcalendar_user"]);
|
$mesg.=$langs->trans("WebCalTestOk",$_POST["phpphenix_host"],$_POST["phpphenix_dbname"],$_POST["phpphenix_user"]);
|
||||||
$mesg.='<br>'.$langs->trans("DetectedVersion").': '.($webcal->version?$webcal->version:$langs->trans("NotAvailable"));
|
//$mesg.='<br>'.$langs->trans("DetectedVersion").': '.($webcal->version?$webcal->version:$langs->trans("NotAvailable"));
|
||||||
$mesg.="</div>";
|
$mesg.="</div>";
|
||||||
|
/*
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$mesg ="<div class=\"error\">";
|
$mesg ="<div class=\"error\">";
|
||||||
$mesg.=$langs->trans("WebCalErrorConnectOkButWrongDatabase");
|
$mesg.=$langs->trans("WebCalErrorConnectOkButWrongDatabase");
|
||||||
$mesg.="</div>";
|
$mesg.="</div>";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Ne pas fermer car la conn de webcal est la meme que dolibarr si
|
// Ne pas fermer car la conn de webcal est la meme que dolibarr si
|
||||||
// parametre host/user/pass identique.
|
// parametre host/user/pass identique.
|
||||||
//$webcal->localdb->close();
|
//$webcal->localdb->close();
|
||||||
}
|
}
|
||||||
elseif ($webcal->connected == 1 && $webcal->database_selected != 1)
|
elseif ($phenix->connected == 1 && $phenix->database_selected != 1)
|
||||||
{
|
{
|
||||||
$mesg ="<div class=\"error\">".$langs->trans("WebCalTestKo1",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"]);
|
$mesg ="<div class=\"error\">".$langs->trans("PhenixTestKo1",$_POST["phpphenix_host"],$_POST["phpphenix_dbname"]);
|
||||||
$mesg.="<br>".$webcal->localdb->error();
|
$mesg.="<br>".$phenix->localdb->error();
|
||||||
$mesg.="</div>";
|
$mesg.="</div>";
|
||||||
//$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
|
//$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg ="<div class=\"error\">".$langs->trans("WebCalTestKo2",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_user"]);
|
$mesg ="<div class=\"error\">".$langs->trans("PhenixTestKo2",$_POST["phpphenix_host"],$_POST["phpphenix_user"]);
|
||||||
$mesg.="<br>".$webcal->localdb->error();
|
$mesg.="<br>".$phenix->localdb->error();
|
||||||
$mesg.="</div>";
|
$mesg.="</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
//$resql=$db->query("select count(*) from llx_const");
|
//$resql=$db->query("select count(*) from llx_const");
|
||||||
//print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n";
|
//print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n";
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Affichage du formulaire de saisie
|
* Affichage du formulaire de saisie
|
||||||
@@ -300,7 +302,7 @@ print "</form>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
if ($mesg) print "<br>$mesg<br>";
|
if ($mesg) print "<br>".$mesg."<br>";
|
||||||
print "<br>";
|
print "<br>";
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@@ -284,6 +284,13 @@ class Conf
|
|||||||
$this->webcal->db->user=defined('PHPWEBCALENDAR_USER')?PHPWEBCALENDAR_USER:'';
|
$this->webcal->db->user=defined('PHPWEBCALENDAR_USER')?PHPWEBCALENDAR_USER:'';
|
||||||
$this->webcal->db->pass=defined('PHPWEBCALENDAR_PASS')?PHPWEBCALENDAR_PASS:'';
|
$this->webcal->db->pass=defined('PHPWEBCALENDAR_PASS')?PHPWEBCALENDAR_PASS:'';
|
||||||
$this->webcal->db->name=defined('PHPWEBCALENDAR_DBNAME')?PHPWEBCALENDAR_DBNAME:'';
|
$this->webcal->db->name=defined('PHPWEBCALENDAR_DBNAME')?PHPWEBCALENDAR_DBNAME:'';
|
||||||
|
// Module phenix
|
||||||
|
$this->phenix->enabled=defined('MAIN_MODULE_PHENIX')?MAIN_MODULE_PHENIX:0;
|
||||||
|
$this->phenix->db->type=defined('PHPPHENIX_TYPE')?PHPPHENIX_TYPE:'__dolibarr_main_db_type__';
|
||||||
|
$this->phenix->db->host=defined('PHPPHENIX_HOST')?PHPPHENIX_HOST:'';
|
||||||
|
$this->phenix->db->user=defined('PHPPHENIX_USER')?PHPPHENIX_USER:'';
|
||||||
|
$this->phenix->db->pass=defined('PHPPHENIX_PASS')?PHPPHENIX_PASS:'';
|
||||||
|
$this->phenix->db->name=defined('PHPPHENIX_DBNAME')?PHPPHENIX_DBNAME:'';
|
||||||
// Module mantis
|
// Module mantis
|
||||||
$this->mantis->enabled=defined('MAIN_MODULE_MANTIS')?MAIN_MODULE_MANTIS:0;
|
$this->mantis->enabled=defined('MAIN_MODULE_MANTIS')?MAIN_MODULE_MANTIS:0;
|
||||||
$this->mantis->db->type=defined('PHPMANTIS_TYPE')?PHPMANTIS_TYPE:'__dolibarr_main_db_type__';
|
$this->mantis->db->type=defined('PHPMANTIS_TYPE')?PHPMANTIS_TYPE:'__dolibarr_main_db_type__';
|
||||||
|
|||||||
180
htdocs/lib/phenix.class.php
Normal file
180
htdocs/lib/phenix.class.php
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* $Source$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\file htdocs/lib/phenix.class.php
|
||||||
|
\ingroup phenix
|
||||||
|
\brief Ensemble des fonctions permettant d'acceder a la database phenix.
|
||||||
|
\author Laurent Destailleur.
|
||||||
|
\author Regis Houssin.
|
||||||
|
\version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\class Phenix
|
||||||
|
\brief Classe permettant d'acceder a la database phenix
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Phenix {
|
||||||
|
|
||||||
|
var $localdb;
|
||||||
|
var $error;
|
||||||
|
var $date;
|
||||||
|
var $duree = 0; /* Secondes */
|
||||||
|
var $texte;
|
||||||
|
var $desc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Constructeur de la classe d'interface <20> Phenix
|
||||||
|
*/
|
||||||
|
function Phenix()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
global $dolibarr_main_db_type,$dolibarr_main_db_host,$dolibarr_main_db_user;
|
||||||
|
global $dolibarr_main_db_pass,$dolibarr_main_db_name;
|
||||||
|
|
||||||
|
// D<>fini parametres phenix (avec substitution eventuelle)
|
||||||
|
$phenixtype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->phenix->db->type);
|
||||||
|
$phenixhost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->phenix->db->host);
|
||||||
|
$phenixuser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->phenix->db->user);
|
||||||
|
$phenixpass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->phenix->db->pass);
|
||||||
|
$phenixname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->phenix->db->name);
|
||||||
|
|
||||||
|
// On initie la connexion <20> la base Phenix
|
||||||
|
require_once (DOL_DOCUMENT_ROOT ."/lib/databases/".$phenixtype.".lib.php");
|
||||||
|
$this->localdb = new DoliDb($phenixtype,$phenixhost,$phenixuser,$phenixpass,$phenixname);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : Modifier la suite....
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Ajoute objet en tant qu'entree dans le calendrier de l'utilisateur
|
||||||
|
\param[in] user Le login de l'utilisateur
|
||||||
|
\return int 1 en cas de succ<63>s, -1,-2,-3 en cas d'erreur, -4 si login webcal non d<>fini
|
||||||
|
*/
|
||||||
|
function add($user)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
dolibarr_syslog("Webcal::add user=".$user->id);
|
||||||
|
|
||||||
|
// Test si login webcal d<>fini pour le user
|
||||||
|
if (! $user->webcal_login)
|
||||||
|
{
|
||||||
|
$langs->load("other");
|
||||||
|
$this->error=$langs->transnoentities("ErrorWebcalLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>");
|
||||||
|
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->localdb->begin();
|
||||||
|
|
||||||
|
// Recup<75>re l'id max+1 dans la base webcalendar
|
||||||
|
$id = $this->get_next_id();
|
||||||
|
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
$cal_id = $id;
|
||||||
|
$cal_create_by = $user->webcal_login;
|
||||||
|
$cal_date = strftime('%Y%m%d', $this->date);
|
||||||
|
$cal_time = strftime('%H%M%S', $this->date);
|
||||||
|
$cal_mod_date = strftime('%Y%m%d', time());
|
||||||
|
$cal_mod_time = strftime('%H%M%S', time());
|
||||||
|
$cal_duration = round($this->duree / 60);
|
||||||
|
$cal_priority = 2; // Medium avec 1.0, Haute avec 1.1
|
||||||
|
// Rem: 1.0: 1=bas, 2=medium, 3=haut
|
||||||
|
// 1.1: 1=haut, 2=haut, 3=haut, 4=medium ... 9=bas
|
||||||
|
$cal_type = "E"; // Evenement de type "intemporel"
|
||||||
|
$cal_access = "P"; // Acces publique
|
||||||
|
$cal_name = $this->texte; // Title for event
|
||||||
|
$cal_description = $this->desc; // Desc for event
|
||||||
|
|
||||||
|
$sql = "INSERT INTO webcal_entry (cal_id, cal_create_by,cal_date,cal_time,cal_mod_date, cal_mod_time,cal_duration,cal_priority,cal_type, cal_access, cal_name,cal_description)";
|
||||||
|
$sql.= " VALUES ($cal_id, '$cal_create_by', '$cal_date', '$cal_time', '$cal_mod_date', '$cal_mod_time', $cal_duration, $cal_priority, '$cal_type', '$cal_access', '$cal_name','$cal_description')";
|
||||||
|
|
||||||
|
dolibarr_syslog("Webcal::add sql=".$sql);
|
||||||
|
$resql=$this->localdb->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO webcal_entry_user (cal_id, cal_login, cal_status)";
|
||||||
|
$sql .= " VALUES ($cal_id, '$cal_create_by', 'A')";
|
||||||
|
|
||||||
|
$resql=$this->localdb->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
// OK
|
||||||
|
$this->localdb->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->localdb->rollback();
|
||||||
|
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||||
|
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->localdb->rollback();
|
||||||
|
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||||
|
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->localdb->rollback();
|
||||||
|
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||||
|
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Obtient l'id suivant dans le webcalendar
|
||||||
|
\return int Retourne l'id suivant dans webcalendar, <0 si ko
|
||||||
|
*/
|
||||||
|
function get_next_id()
|
||||||
|
{
|
||||||
|
$sql = "SELECT max(cal_id) as id FROM webcal_entry";
|
||||||
|
|
||||||
|
$resql=$this->localdb->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$this->localdb->fetch_object($resql);
|
||||||
|
return ($obj->id + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->localdb->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user