rajout de l'affichage selectif des boutons ajout dans spip/glasnost en fonction de la presence du login adherent dans spip/glasnost
This commit is contained in:
parent
b5977e18f2
commit
17bf68e7b1
@ -678,12 +678,13 @@ class Adherent
|
||||
){
|
||||
$mdpass=md5($this->pass);
|
||||
$htpass=crypt($this->pass,initialiser_sel());
|
||||
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->nom."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
|
||||
$query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->prenom." ".$this->nom."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
|
||||
$mydb=new Db('mysql',MAIN_SPIP_SERVEUR,MAIN_SPIP_USER,MAIN_SPIP_PASS,MAIN_SPIP_DB);
|
||||
$result = $mydb->query($query);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$mydb->close();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -713,6 +714,7 @@ class Adherent
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$mydb->close();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -723,6 +725,44 @@ class Adherent
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* est-ce que cet utilisateur est dans spip
|
||||
*
|
||||
*/
|
||||
Function is_in_spip()
|
||||
{
|
||||
if (defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1 &&
|
||||
defined('MAIN_SPIP_SERVEUR') && MAIN_SPIP_SERVEUR != '' &&
|
||||
defined('MAIN_SPIP_USER') && MAIN_SPIP_USER != '' &&
|
||||
defined('MAIN_SPIP_PASS') && MAIN_SPIP_PASS != '' &&
|
||||
defined('MAIN_SPIP_DB') && MAIN_SPIP_DB != ''
|
||||
){
|
||||
$query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'";
|
||||
$mydb=new Db('mysql',MAIN_SPIP_SERVEUR,MAIN_SPIP_USER,MAIN_SPIP_PASS,MAIN_SPIP_DB);
|
||||
$result = $mydb->query($query);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($mydb->num_rows()){
|
||||
# nous avons au moins une reponse
|
||||
$mydb->close();
|
||||
return 1;
|
||||
}else{
|
||||
# nous n'avons pas de reponse => n'existe pas
|
||||
$mydb->close();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# error
|
||||
$this->errorstr=$mydb->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rajoute cet utilisateur au serveur glasnost
|
||||
*
|
||||
@ -892,6 +932,63 @@ class Adherent
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* efface cet utilisateur du serveur glasnost
|
||||
*
|
||||
*/
|
||||
Function is_in_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'];
|
||||
return 1;
|
||||
}else{
|
||||
$this->errorstr=$response['faultString'];
|
||||
return 0;
|
||||
}
|
||||
}else{
|
||||
$this->errorstr="Constantes de connection non definies";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
||||
@ -559,17 +559,17 @@ if ($rowid > 0)
|
||||
|
||||
if ($adht->vote == 'yes' && defined("MAIN_USE_GLASNOST") && MAIN_USE_GLASNOST ==1){
|
||||
define("XMLRPC_DEBUG", 1);
|
||||
|
||||
/*
|
||||
* Case 1
|
||||
* Case 1 & 2
|
||||
*/
|
||||
print "<td align=\"center\" width=\"25%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=add_glasnost\">Ajout dans Glasnost</a>]</td>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Case 2
|
||||
*/
|
||||
|
||||
print "<td align=\"center\" width=\"25%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=del_glasnost\">Suppression dans Glasnost</a>]</td>\n";
|
||||
if ($adh->is_in_glasnost() == 1){
|
||||
print "<td align=\"center\" width=\"25%\" class=\"bouton\">-</td>\n";
|
||||
print "<td align=\"center\" width=\"25%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=del_glasnost\">Suppression dans Glasnost</a>]</td>\n";
|
||||
}else{
|
||||
print "<td align=\"center\" width=\"25%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=add_glasnost\">Ajout dans Glasnost</a>]</td>\n";
|
||||
print "<td align=\"center\" width=\"25%\" class=\"bouton\">-</td>\n";
|
||||
}
|
||||
}else{
|
||||
/*
|
||||
* Case 1
|
||||
@ -584,16 +584,16 @@ if ($rowid > 0)
|
||||
|
||||
if (defined("MAIN_USE_SPIP") && MAIN_USE_SPIP ==1){
|
||||
/*
|
||||
* Case 3
|
||||
* Case 3 & 4
|
||||
*/
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=add_spip\">Ajout dans Spip</a>]</td>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Case 4
|
||||
*/
|
||||
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=del_spip\">Suppression dans Spip</a>]</td>\n";
|
||||
if ($adh->is_in_spip() == 1){
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">-</td>\n";
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=del_spip\">Suppression dans Spip</a>]</td>\n";
|
||||
}else{
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">[<a href=\"$PHP_SELF?rowid=$adh->id&action=add_spip\">Ajout dans Spip</a>]</td>\n";
|
||||
print "<td align=\"center\" width=\"20%\" class=\"bouton\">-</td>\n";
|
||||
}
|
||||
|
||||
}else{
|
||||
/*
|
||||
* Case 3
|
||||
|
||||
@ -44,7 +44,8 @@ class User {
|
||||
|
||||
$this->db = $DB;
|
||||
$this->id = $id;
|
||||
|
||||
$this->comm = 0;
|
||||
$this->compta = 0;
|
||||
$this->limite_liste = 20;
|
||||
|
||||
return 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user