diff --git a/htdocs/bookmarks/bookmark.class.php b/htdocs/bookmarks/bookmark.class.php
index 2a8453d6057..2d8a2b30af9 100644
--- a/htdocs/bookmarks/bookmark.class.php
+++ b/htdocs/bookmarks/bookmark.class.php
@@ -40,10 +40,11 @@ class Bookmark
var $fk_user;
var $datec;
var $url;
- var $target;
+ var $target; // 0=replace, 1=new window
var $title;
var $favicon;
+
/**
* \brief Constructeur
* \param db Handler d'accès base de données
@@ -61,7 +62,7 @@ class Bookmark
*/
function fetch($id)
{
- $sql = "SELECT rowid, fk_user, ".$this->db->pdate("dateb")." as datec, url, target,";
+ $sql = "SELECT rowid, fk_user, dateb as datec, url, target,";
$sql.= " title, favicon";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
$sql.= " WHERE rowid = ".$id;
@@ -76,7 +77,7 @@ class Bookmark
$this->ref = $obj->rowid;
$this->fk_user = $obj->fk_user;
- $this->datec = $obj->datec;
+ $this->datec = $this->db->jdate($obj->datec);
$this->url = $obj->url;
$this->target = $obj->target;
$this->title = $obj->title;
@@ -87,7 +88,7 @@ class Bookmark
}
else
{
- dolibarr_print_error ($this->db);
+ dolibarr_print_error($this->db);
return -1;
}
}
@@ -98,19 +99,25 @@ class Bookmark
*/
function create()
{
+ // Clean parameters
+ $this->url=trim($this->url);
+ $this->title=trim($this->title);
+
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target";
$sql.= " ,title,favicon";
if ($this->fk_soc) $sql.=",fk_soc";
- $sql.= ")";
- $sql.= " VALUES ('".$this->fk_user."', ".$this->db->idate(mktime()).",";
+ $sql.= ") VALUES (";
+ $sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
+ $sql.= " ".$this->db->idate(gmmktime()).",";
$sql.= " '".$this->url."', '".$this->target."',";
$sql.= " '".addslashes($this->title)."', '".$this->favicon."'";
if ($this->fk_soc) $sql.=",".$this->fk_soc;
$sql.= ")";
- $resql = $this->db->query ($sql);
+ dolibarr_syslog("Bookmark::update sql=".$sql, LOG_DEBUG);
+ $resql = $this->db->query ($sql);
if ($resql)
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark");
@@ -143,22 +150,27 @@ class Bookmark
*/
function update()
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
- $sql.= " SET fk_user = '".$this->fk_user."'";
- $sql.= " ,dateb = '".$this->datec."'";
- $sql.= " ,url = '".$this->url."'";
+ // Clean parameters
+ $this->url=trim($this->url);
+ $this->title=trim($this->title);
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
+ $sql.= " SET fk_user = ".($this->fk_user > 0?"'".$this->fk_user."'":"0");
+ $sql.= " ,dateb = '".$this->db->idate($this->datec)."'";
+ $sql.= " ,url = '".addslashes($this->url)."'";
$sql.= " ,target = '".$this->target."'";
- $sql.= " ,title = '".$this->title."'";
+ $sql.= " ,title = '".addslashes($this->title)."'";
$sql.= " ,favicon = '".$this->favicon."'";
$sql.= " WHERE rowid = ".$this->id;
+ dolibarr_syslog("Bookmark::update sql=".$sql, LOG_DEBUG);
if ($this->db->query ($sql))
{
return 1;
}
else
{
- $this->error=$this->db->error();
+ $this->error=$this->db->lasterror();
return -1;
}
}
@@ -173,6 +185,7 @@ class Bookmark
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark";
$sql .= " WHERE rowid = ".$id;
+ dolibarr_syslog("Bookmark::remove sql=".$sql, LOG_DEBUG);
$resql=$this->db->query ($sql);
if ($resql)
{
@@ -180,7 +193,7 @@ class Bookmark
}
else
{
- $this->error=$this->db->error();
+ $this->error=$this->db->lasterror();
return -1;
}
diff --git a/htdocs/bookmarks/fiche.php b/htdocs/bookmarks/fiche.php
index 8ae0fbafdfc..b7d2c8073dc 100644
--- a/htdocs/bookmarks/fiche.php
+++ b/htdocs/bookmarks/fiche.php
@@ -34,17 +34,18 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
$title=isset($_GET["title"])?$_GET["title"]:$_POST["title"];
$url=isset($_GET["url"])?$_GET["url"]:$_POST["url"];
$target=isset($_GET["target"])?$_GET["target"]:$_POST["target"];
+$userid=isset($_GET["userid"])?$_GET["userid"]:$_POST["userid"];
/*
* Actions
*/
-if ($action == 'add' || $action == 'addproduct')
+if ($action == 'add' || $action == 'addproduct' || $action == 'update')
{
if ($_POST["cancel"])
{
- $urlsource=(! empty($_GET["urlsource"]))?$_GET["urlsource"]:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/liste.php');
+ $urlsource=(! empty($_REQUEST["urlsource"]))?urldecode($_REQUEST["urlsource"]):((! empty($url))?urldecode($url):DOL_URL_ROOT.'/bookmarks/liste.php');
header("Location: ".$urlsource);
exit;
}
@@ -52,22 +53,25 @@ if ($action == 'add' || $action == 'addproduct')
$mesg='';
$bookmark=new Bookmark($db);
- $bookmark->fk_user=$user->id;
+ if ($action == 'update') $bookmark->fetch($_POST["id"]);
+ $bookmark->fk_user=$userid;
$bookmark->title=$title;
$bookmark->url=$url;
$bookmark->target=$target;
if (! $title) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle"));
- if (! $url) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink"));
+ if (! $url) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink"));
if (! $mesg)
{
$bookmark->favicon='none';
- $res=$bookmark->create();
+ if ($action == 'update') $res=$bookmark->update();
+ else $res=$bookmark->create();
+
if ($res > 0)
{
- $urlsource=isset($_GET["urlsource"])?$_GET["urlsource"]:DOL_URL_ROOT.'/bookmarks/liste.php';
+ $urlsource=isset($_REQUEST["urlsource"])?urldecode($_REQUEST["urlsource"]):DOL_URL_ROOT.'/bookmarks/liste.php';
header("Location: ".$urlsource);
exit;
}
@@ -90,7 +94,6 @@ if ($action == 'add' || $action == 'addproduct')
$mesg='
| '.$langs->trans("BookmarkTitle").' | '.$langs->trans("SetHereATitleForLink").' | |||||||||||||
| '.$langs->trans("UrlOrLink").' | '.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").' | |||||||||||||
| '.$langs->trans("BehaviourOnClick").' | '; - $liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow")); + $liste=array(0=>$langs->trans("ReplaceWindow"),1=>$langs->trans("OpenANewWindow")); $html->select_array('target',$liste,1); print ' | '.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").' | ||||||||||||
| '.$langs->trans("Owner").' | '; + $html->select_users(isset($_POST['userid'])?$_POST['userid']:$user->id,'userid',1); + print ' | |||||||||||||
| ';
print ' ';
print '';
@@ -160,7 +169,7 @@ if ($action == 'create')
if ($_GET["id"] > 0 && ! eregi('^add',$_GET["action"]))
{
/*
- * Fiche bookmark en mode edition
+ * Fiche bookmark en mode visu ou edition
*/
$bookmark=new Bookmark($db);
$bookmark->fetch($_GET["id"]);
@@ -168,39 +177,86 @@ if ($_GET["id"] > 0 && ! eregi('^add',$_GET["action"]))
dolibarr_fiche_head($head, $hselected, $langs->trans("Bookmark"));
+ if ($_GET["action"] == 'edit')
+ {
+ print '';
+
print "\n";
+
+
print " \n";
- // Supprimer
- if ($user->rights->bookmark->supprimer)
+ // Edit
+ if ($user->rights->bookmark->creer && $_GET["action"] != 'edit')
+ {
+ print " id."&action=edit\">".$langs->trans("Edit")."\n";
+ }
+
+ // Remove
+ if ($user->rights->bookmark->supprimer && $_GET["action"] != 'edit')
{
print " id."&action=delete\">".$langs->trans("Delete")."\n";
}
diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php
index 8108ee698d6..7454e2c4750 100644
--- a/htdocs/user/group/fiche.php
+++ b/htdocs/user/group/fiche.php
@@ -167,7 +167,7 @@ if ($action == 'create')
if ($message) { print $message." "; } - print ''."\n"; print ' '; } - + /* * Membres du groupe */ @@ -328,13 +328,13 @@ else $sql.= " WHERE ug.fk_user = u.rowid"; $sql.= " AND ug.fk_usergroup = ".$group->id; $sql.= " ORDER BY u.name"; - + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - + print '
"; @@ -416,7 +416,7 @@ else print ' | ||||||||||||||