Skip to content
Snippets Groups Projects
Commit 071dd8e7 authored by Raphaël Doursenaud's avatar Raphaël Doursenaud
Browse files

Make bookmarks module multicompany aware

parent d3d18631
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,7 @@ function printBookmarksList($aDb, $aLangs)
{
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
$sql.= " AND entity = ".$conf->entity;
$sql.= " ORDER BY position";
if ($resql = $db->query($sql) )
{
......
......@@ -57,10 +57,13 @@ class Bookmark
*/
function fetch($id)
{
global $conf;
$sql = "SELECT rowid, fk_user, dateb as datec, url, target,";
$sql.= " title, position, favicon";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
$sql.= " WHERE rowid = ".$id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Bookmark::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
......@@ -96,6 +99,8 @@ class Bookmark
*/
function create()
{
global $conf;
// Clean parameters
$this->url=trim($this->url);
$this->title=trim($this->title);
......@@ -106,13 +111,15 @@ class Bookmark
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target";
$sql.= " ,title,favicon,position";
$sql.= ",title,favicon,position";
$sql.= ",entity";
if ($this->fk_soc) $sql.=",fk_soc";
$sql.= ") VALUES (";
$sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
$sql.= " ".$this->db->idate($now).",";
$sql.= " '".$this->url."', '".$this->target."',";
$sql.= " '".$this->db->escape($this->title)."', '".$this->favicon."', '".$this->position."'";
$sql.= ", '".$conf->entity."'";
if ($this->fk_soc) $sql.=",".$this->fk_soc;
$sql.= ")";
......
......@@ -73,6 +73,7 @@ $sql = "SELECT b.fk_soc as rowid, b.dateb, b.rowid as bid, b.fk_user, b.url, b.t
$sql.= " u.login, u.lastname, u.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid";
$sql.= " WHERE 1=1";
$sql.= " AND b.entity = ".$conf->entity;
if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)";
$sql.= $db->order($sortfield.", position",$sortorder);
$sql.= $db->plimit($limit, $offset);
......
......@@ -47,7 +47,7 @@ class box_bookmarks extends ModeleBoxes
*/
function loadBox($max=5)
{
global $user, $langs, $db;
global $user, $langs, $db, $conf;
$langs->load("boxes");
$this->max=$max;
......@@ -70,6 +70,7 @@ class box_bookmarks extends ModeleBoxes
$sql = "SELECT b.title, b.url, b.target, b.favicon";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b";
$sql.= " WHERE fk_user = ".$user->id;
$sql.= " AND b.entity = ".$conf->entity;
$sql.= $db->order("position","ASC");
$sql.= $db->plimit($max, 0);
......
......@@ -26,5 +26,6 @@ create table llx_bookmark
target varchar(16),
title varchar(64),
favicon varchar(24),
position integer DEFAULT 0
position integer DEFAULT 0,
entity integer DEFAULT 1 NOT NULL -- multicompany ID
)ENGINE=innodb;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment