debut de gestion de glasnost dans dolibarr (xml-rpc .. heu rulez :-))
This commit is contained in:
parent
19f975cd0e
commit
db8ddc3967
@ -592,6 +592,12 @@ class Adherent
|
||||
$err+=1;
|
||||
}
|
||||
}
|
||||
if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1)
|
||||
{
|
||||
if(!$this->add_to_glasnost()){
|
||||
$err+=1;
|
||||
}
|
||||
}
|
||||
if ($err>0){
|
||||
// error
|
||||
return 0;
|
||||
@ -615,6 +621,12 @@ class Adherent
|
||||
$err+=1;
|
||||
}
|
||||
}
|
||||
if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1)
|
||||
{
|
||||
if(!$this->del_to_glasnost()){
|
||||
$err+=1;
|
||||
}
|
||||
}
|
||||
if ($err>0){
|
||||
// error
|
||||
return 0;
|
||||
@ -623,6 +635,168 @@ class Adherent
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rajoute cet utilisateur au serveur glasnost
|
||||
*
|
||||
*/
|
||||
Function add_to_glasnost()
|
||||
{
|
||||
if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 &&
|
||||
defined('MAIN_GLASNOST_SERVEUR') && MAIN_GLASNOST_SERVEUR != '' &&
|
||||
defined('MAIN_GLASNOST_USER') && MAIN_GLASNOST_USER != '' &&
|
||||
defined('MAIN_GLASNOST_PASS') && MAIN_GLASNOST_PASS != ''
|
||||
){
|
||||
// application token is not useful here
|
||||
$applicationtoken='';
|
||||
list($success, $response) =
|
||||
XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001',
|
||||
'/RPC2',
|
||||
'callGateway',
|
||||
array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication"),
|
||||
XMLRPC_prepare('getUserIdAndToken'),
|
||||
XMLRPC_prepare(array("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication","$applicationtoken",MAIN_GLASNOST_USER,MAIN_GLASNOST_PASS))
|
||||
)
|
||||
);
|
||||
if ($success){
|
||||
$userid=$response[0];
|
||||
$usertoken=$response[1];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
list($success,$response)=
|
||||
XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001',
|
||||
'/RPC2',
|
||||
'callGateway',
|
||||
array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/people"),
|
||||
XMLRPC_prepare('addObject'),
|
||||
XMLRPC_prepare(array(
|
||||
"glasnost://".MAIN_GLASNOST_SERVEUR."/people",
|
||||
"$applicationtoken",
|
||||
$usertoken,
|
||||
array(
|
||||
'__thingCategory__'=>'object',
|
||||
'__thingName__'=> 'Person',
|
||||
'firstName'=>$this->prenom,
|
||||
'lastName'=>$this->nom,
|
||||
'login'=>$this->login,
|
||||
'email'=>$this->email
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($success){
|
||||
$personid=$response[0];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* efface cet utilisateur du serveur glasnost
|
||||
*
|
||||
*/
|
||||
Function del_to_glasnost()
|
||||
{
|
||||
if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1 &&
|
||||
defined('MAIN_GLASNOST_SERVEUR') && MAIN_GLASNOST_SERVEUR != '' &&
|
||||
defined('MAIN_GLASNOST_USER') && MAIN_GLASNOST_USER != '' &&
|
||||
defined('MAIN_GLASNOST_PASS') && MAIN_GLASNOST_PASS != ''
|
||||
){
|
||||
// application token is not useful here
|
||||
$applicationtoken='';
|
||||
list($success, $response) =
|
||||
XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001',
|
||||
'/RPC2',
|
||||
'callGateway',
|
||||
array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication"),
|
||||
XMLRPC_prepare('getUserIdAndToken'),
|
||||
XMLRPC_prepare(array("glasnost://".MAIN_GLASNOST_SERVEUR."/authentication","$applicationtoken",MAIN_GLASNOST_USER,MAIN_GLASNOST_PASS))
|
||||
)
|
||||
);
|
||||
if ($success){
|
||||
$userid=$response[0];
|
||||
$usertoken=$response[1];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
// recuperation du personID
|
||||
list($success,$response)=
|
||||
XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001',
|
||||
'/RPC2',
|
||||
'callGateway',
|
||||
array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/people"),
|
||||
XMLRPC_prepare('getObjectByLogin'),
|
||||
XMLRPC_prepare(array(
|
||||
"glasnost://".MAIN_GLASNOST_SERVEUR."/people",
|
||||
"$applicationtoken",
|
||||
$usertoken,
|
||||
$this->login
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($success){
|
||||
$personid=$response['id'];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
if (defined('MAIN_GLASNOST_DEFAULT_GROUPID') && MAIN_GLASNOST_DEFAULT_GROUPID != ''){
|
||||
// recuperation des personne de ce groupe
|
||||
list($success,$response)=
|
||||
XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001',
|
||||
'/RPC2',
|
||||
'callGateway',
|
||||
array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/groups"),
|
||||
XMLRPC_prepare('getObject'),
|
||||
XMLRPC_prepare(array(
|
||||
"glasnost://".MAIN_GLASNOST_SERVEUR."/groups",
|
||||
"$applicationtoken",
|
||||
$usertoken,
|
||||
MAIN_GLASNOST_DEFAULT_GROUPID
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($success){
|
||||
$groupids=$response['membersSet'];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
// TODO faire la verification que le user n'est pas dans ce
|
||||
// groupe par defaut. si il y ai il faut l'effacer et
|
||||
// modifier le groupe
|
||||
}
|
||||
// suppression du personID
|
||||
list($success,$response)=
|
||||
XMLRPC_request(MAIN_GLASNOST_SERVEUR.':8001',
|
||||
'/RPC2',
|
||||
'callGateway',
|
||||
array(XMLRPC_prepare("glasnost://".MAIN_GLASNOST_SERVEUR."/people"),
|
||||
XMLRPC_prepare('deleteObject'),
|
||||
XMLRPC_prepare(array(
|
||||
"glasnost://".MAIN_GLASNOST_SERVEUR."/people",
|
||||
"$applicationtoken",
|
||||
$usertoken,
|
||||
$personid
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($success){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
||||
@ -26,7 +26,7 @@ require($GLOBALS["DOCUMENT_ROOT"]."/adherent_type.class.php");
|
||||
require($GLOBALS["DOCUMENT_ROOT"]."/adherents/adherent_options.class.php");
|
||||
require($GLOBALS["DOCUMENT_ROOT"]."/cotisation.class.php");
|
||||
require($GLOBALS["DOCUMENT_ROOT"]."/paiement.class.php");
|
||||
|
||||
require($GLOBALS["DOCUMENT_ROOT"]."/adherents/XML-RPC.functions.php");
|
||||
|
||||
$db = new Db();
|
||||
$adho = new AdherentOptions($db);
|
||||
@ -137,21 +137,31 @@ if ($HTTP_POST_VARS["action"] == 'confirm_resign' && $HTTP_POST_VARS["confirm"]
|
||||
// error
|
||||
$errmsg="echec du rajout de l'utilisateur aux mailing-lists";
|
||||
}
|
||||
|
||||
/*
|
||||
if ($conf->adherent->use_mailman == 1)
|
||||
{
|
||||
foreach ($conf->adherent->mailman_lists as $key)
|
||||
{
|
||||
$adh->del_to_mailman($adh->email,$key,$conf->adherent->mailman_dir);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'confirm_add_glasnost' && $HTTP_POST_VARS["confirm"] == yes)
|
||||
{
|
||||
$adh = new Adherent($db, $rowid);
|
||||
$adh->fetch($rowid);
|
||||
define("XMLRPC_DEBUG", 1);
|
||||
$adh->add_to_glasnost();
|
||||
if(defined('MAIN_DEBUG') && MAIN_DEBUG == 1){
|
||||
XMLRPC_debug_print();
|
||||
}
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'confirm_del_glasnost' && $HTTP_POST_VARS["confirm"] == yes)
|
||||
{
|
||||
$adh = new Adherent($db, $rowid);
|
||||
$adh->fetch($rowid);
|
||||
define("XMLRPC_DEBUG", 1);
|
||||
$adh->del_to_glasnost();
|
||||
if(defined('MAIN_DEBUG') && MAIN_DEBUG == 1){
|
||||
XMLRPC_debug_print();
|
||||
}
|
||||
}
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Création d'une fiche */
|
||||
@ -170,6 +180,7 @@ if ($errmsg != ''){
|
||||
$adho->fetch_optionals();
|
||||
if ($action == 'create') {
|
||||
|
||||
/*
|
||||
$sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber";
|
||||
$sql .= " FROM societe as s, llx_facture as f WHERE f.fk_soc = s.idp";
|
||||
$sql .= " AND f.rowid = $facid";
|
||||
@ -183,6 +194,7 @@ if ($action == 'create') {
|
||||
$total = $obj->total;
|
||||
}
|
||||
}
|
||||
*/
|
||||
// $adho = new AdherentOptions($db);
|
||||
|
||||
//$myattr=$adho->fetch_name_optionals();
|
||||
@ -344,6 +356,55 @@ if ($rowid > 0)
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de l'ajout dans glasnost
|
||||
*
|
||||
*/
|
||||
|
||||
if ($action == 'add_glasnost')
|
||||
{
|
||||
|
||||
print '<form method="post" action="'.$PHP_SELF.'?rowid='.$rowid.'">';
|
||||
print '<input type="hidden" name="action" value="confirm_add_glasnost">';
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
|
||||
print '<tr><td colspan="3">Valider un adhérent</td></tr>';
|
||||
|
||||
print '<tr><td class="valid">Etes-vous sur de vouloir ajouter cet adhérent dans glasnost ?</td><td class="valid">';
|
||||
$htmls = new Form($db);
|
||||
|
||||
$htmls->selectyesno("confirm","no");
|
||||
|
||||
print "</td>\n";
|
||||
print '<td class="valid" align="center"><input type="submit" value="Confirmer"</td></tr>';
|
||||
print '</table>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression dans glasnost
|
||||
*
|
||||
*/
|
||||
|
||||
if ($action == 'del_glasnost')
|
||||
{
|
||||
|
||||
print '<form method="post" action="'.$PHP_SELF.'?rowid='.$rowid.'">';
|
||||
print '<input type="hidden" name="action" value="confirm_del_glasnost">';
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
|
||||
print '<tr><td colspan="3">Valider un adhérent</td></tr>';
|
||||
|
||||
print '<tr><td class="delete">Etes-vous sur de vouloir effacer cet adhérent de glasnost ?</td><td class="delete">';
|
||||
$htmls = new Form($db);
|
||||
|
||||
$htmls->selectyesno("confirm","no");
|
||||
|
||||
print "</td>\n";
|
||||
print '<td class="delete" align="center"><input type="submit" value="Confirmer"</td></tr>';
|
||||
print '</table>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
print "<form action=\"$PHP_SELF\" method=\"post\">\n";
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
@ -390,13 +451,13 @@ if ($rowid > 0)
|
||||
if ($user->admin)
|
||||
{
|
||||
|
||||
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>\n";
|
||||
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr class=\"barreBouton\">\n";
|
||||
|
||||
/*
|
||||
* Case 1
|
||||
*/
|
||||
|
||||
print '<td align="center" width="25%">[<a href="edit.php?rowid='.$adh->id.'">Editer</a>]</td>';
|
||||
print '<td align="center" width="15%" class=\"bouton\">[<a href="edit.php?rowid='.$adh->id.'">Editer</a>]</td>';
|
||||
|
||||
/*
|
||||
* Case 2
|
||||
@ -404,29 +465,45 @@ if ($rowid > 0)
|
||||
|
||||
if ($adh->statut < 1)
|
||||
{
|
||||
print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?rowid=$rowid&action=valid\">Valider l'adhésion</a>]</td>\n";
|
||||
print "<td align=\"center\" width=\"15%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$rowid&action=valid\">Valider l'adhésion</a>]</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\" width=\"25%\">-</td>\n";
|
||||
print "<td align=\"center\" width=\"15%\" class=\"bouton\">-</td>\n";
|
||||
}
|
||||
/*
|
||||
* Case 3
|
||||
*/
|
||||
if ($adh->statut == 1)
|
||||
{
|
||||
print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?rowid=$rowid&action=resign\">Résilier l'adhésion</a>]</td>\n";
|
||||
print "<td align=\"center\" width=\"15%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$rowid&action=resign\">Résilier l'adhésion</a>]</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\" width=\"25%\">-</td>\n";
|
||||
print "<td align=\"center\" width=\"15%\" class=\"bouton\">-</td>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Case 4
|
||||
*/
|
||||
|
||||
print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=delete\">Supprimer</a>]</td>\n";
|
||||
print "<td align=\"center\" width=\"15%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=delete\">Supprimer</a>]</td>\n";
|
||||
|
||||
if (defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1){
|
||||
define("XMLRPC_DEBUG", 1);
|
||||
/*
|
||||
* Case 5
|
||||
*/
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=add_glasnost\">Ajout dans Glasnost</a>]</td>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Case 6
|
||||
*/
|
||||
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=del_glasnost\">Suppression dans Glasnost</a>]</td>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
print "</tr></table></form><p>\n";
|
||||
|
||||
@ -113,6 +113,18 @@ TR.impair
|
||||
font-family: Helvetica, Verdana; font-size: 12px;
|
||||
text-decoration: none }
|
||||
|
||||
TR.barreBouton
|
||||
{
|
||||
background: #cceeee;
|
||||
font-family: Helvetica, Verdana; font-size: 12px;
|
||||
text-decoration: none
|
||||
}
|
||||
|
||||
td.bouton
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td.valeur
|
||||
{
|
||||
font-weight: bold;
|
||||
|
||||
@ -56,6 +56,10 @@ INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_UNSUB_URL'
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_URL','http://lists.ipsyn.net/cgi-bin/mailman/subscribe/%LISTE%/?email=%EMAIL%&pw=%PASS%&pw-conf=%PASS%','chaine','url pour les inscriptions mailman');
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_MAILMAN_LISTS','test-test,test-test2','chaine','Listes auxquelles inscrire les nouveaux adherents');
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_DEBUG','1','yesno','Debug ..');
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_USE_GLASNOST','0','yesno','utilisation de glasnost ?');
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_GLASNOST_SERVEUR','glasnost.j1b.org','chaine','serveur glasnost');
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_GLASNOST_USER','user','chaine','Administrateur glasnost');
|
||||
INSERT INTO llx_const (name, value, type, note) VALUES ('MAIN_GLASNOST_PASS','password','chaine','password de l\'administrateur');
|
||||
|
||||
--
|
||||
-- Constantes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user