Nouveau fichier
This commit is contained in:
parent
59ed1d48ff
commit
0bbb14815c
158
htdocs/bookmark4u.class.php
Normal file
158
htdocs/bookmark4u.class.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (c) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* 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/bookmark4u.class.php
|
||||||
|
\brief Fichier de la classe bookmark4u
|
||||||
|
\author Rodolphe Quiedeville
|
||||||
|
\version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Bookmark4u
|
||||||
|
{
|
||||||
|
var $db;
|
||||||
|
|
||||||
|
var $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Constructeur de la classe
|
||||||
|
* \param $DB handler accès base de données
|
||||||
|
* \param $id id de l'utilisateur (0 par défaut)
|
||||||
|
*/
|
||||||
|
function Bookmark4u($DB, $id=0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->db = $DB;
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function get_bk4u_uid($user)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT bk4u_uid FROM ".MAIN_DB_PREFIX."bookmark4u_login";
|
||||||
|
$sql .= " WHERE fk_user =".$user->id;
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
|
||||||
|
if ($num == 0)
|
||||||
|
{
|
||||||
|
$this->uid = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row(0);
|
||||||
|
|
||||||
|
$this->uid = $row[0];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->free();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function get_bk4u_login()
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT user FROM bookmark4u.bk4u_passwd";
|
||||||
|
$sql .= " WHERE uid =".$this->uid;
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
|
||||||
|
if ($num == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row(0);
|
||||||
|
|
||||||
|
$this->login = $row[0];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->free();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Créé un compte
|
||||||
|
* \param user Objet du user
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function create_account_from_user($user)
|
||||||
|
{
|
||||||
|
// TODO rendre la base et la table générique
|
||||||
|
|
||||||
|
$sql = "INSERT INTO bookmark4u.bk4u_passwd (user, passwd, name, email)";
|
||||||
|
$sql .= " VALUES ('$user->login',password('$user->pass'),'$user->firstname $user->name','$user->email');";
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
if ($this->db->affected_rows())
|
||||||
|
{
|
||||||
|
$this->uid = $this->db->last_insert_id();
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark4u_login";
|
||||||
|
$sql .= " (fk_user, bk4u_uid)";
|
||||||
|
$sql .= " VALUES ($user->id, $this->uid)";
|
||||||
|
|
||||||
|
$this->db->query($sql);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Bookmark4u::Create_account_from_user INSERT 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Bookmark4u::Create_account_from_user INSERT 1");
|
||||||
|
print $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
151
htdocs/user/addon.php
Normal file
151
htdocs/user/addon.php
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<?PHP
|
||||||
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* 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$
|
||||||
|
*/
|
||||||
|
|
||||||
|
require("./pre.inc.php");
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/bookmark4u.class.php";
|
||||||
|
|
||||||
|
$langs->load("users");
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
if ($_GET["action"] == 'create_bk4u_login')
|
||||||
|
{
|
||||||
|
$edituser = new User($db, $_GET["id"]);
|
||||||
|
$edituser->fetch($_GET["id"]);
|
||||||
|
|
||||||
|
$bk4u = new Bookmark4u($db);
|
||||||
|
$bk4u->get_bk4u_uid($fuser);
|
||||||
|
$bk4u->create_account_from_user($edituser);
|
||||||
|
|
||||||
|
Header("Location: addon.php?id=".$_GET["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
llxHeader("","Addon Utilisateur");
|
||||||
|
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Nouvel utilisateur */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
if ($_GET["id"])
|
||||||
|
{
|
||||||
|
$fuser = new User($db, $_GET["id"]);
|
||||||
|
$fuser->fetch();
|
||||||
|
|
||||||
|
$bk4u = new Bookmark4u($db);
|
||||||
|
$bk4u->get_bk4u_uid($fuser);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Affichage onglets
|
||||||
|
*/
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
|
||||||
|
$head[$h][1] = $langs->trans("UserCard");
|
||||||
|
if ($_GET["action"] != 'perms') { $hselected=$h; }
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
if ($user->admin)
|
||||||
|
{
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?action=perms&id='.$fuser->id;
|
||||||
|
$head[$h][1] = $langs->trans("Permissions");
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
|
||||||
|
$head[$h][1] = $langs->trans("Addons");
|
||||||
|
$hselected=$h;
|
||||||
|
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
dolibarr_fiche_head($head, $hselected, $fuser->nom." ".$fuser->prenom);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fiche en mode visu
|
||||||
|
*/
|
||||||
|
|
||||||
|
print '<table class="border" width="100%" cellpadding="3" cellspacing="0">';
|
||||||
|
|
||||||
|
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("LastName").'</td>';
|
||||||
|
print '<td width="25%" class="valeur">'.$fuser->nom.'</td>';
|
||||||
|
print '<td width="25%" valign="top">'.$langs->trans("FirstName").'</td>';
|
||||||
|
print '<td width="25%" class="valeur">'.$fuser->prenom.'</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Login").'</td>';
|
||||||
|
print '<td width="25%" class="valeur">'.$fuser->login.'</td>';
|
||||||
|
print '<td width="25%" valign="top">'.$langs->trans("EMail").'</td>';
|
||||||
|
print '<td width="25%" class="valeur"><a href="mailto:'.$fuser->email.'">'.$fuser->email.'</a></td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
|
print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Login Boobkmark4u").'</td>';
|
||||||
|
print '<td width="25%" class="valeur">';
|
||||||
|
|
||||||
|
if ($bk4u->uid == 0)
|
||||||
|
{
|
||||||
|
print "Pas de login";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$bk4u->get_bk4u_login();
|
||||||
|
print $bk4u->login;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td>';
|
||||||
|
print '<td width="25%" valign="top"> </td>';
|
||||||
|
print '<td width="25%" class="valeur"> </td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
|
print "</table>\n";
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
print "</div>\n";
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Barre d'actions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if ($user->admin)
|
||||||
|
{
|
||||||
|
print '<a class="tabAction" href="addon.php?id='.$fuser->id.'&action=create_bk4u_login">'.$langs->trans("Créer login Bookmark4u").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</div>\n";
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user