2005-09-11 22:35:09 +00:00
|
|
|
<?php
|
2009-08-26 09:37:54 +00:00
|
|
|
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
2005-09-11 22:35:09 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-09-11 22:35:09 +00:00
|
|
|
* (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
|
2011-07-31 23:24:38 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-09-11 22:35:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2011-10-24 12:11:49 +00:00
|
|
|
* \file htdocs/core/boxes/box_bookmarks.php
|
2009-08-26 09:37:54 +00:00
|
|
|
* \ingroup bookmark
|
2010-07-21 11:57:52 +00:00
|
|
|
* \brief Module to generate box of bookmarks list
|
2009-08-26 09:37:54 +00:00
|
|
|
*/
|
2012-08-23 00:04:35 +00:00
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
|
2005-09-11 22:35:09 +00:00
|
|
|
|
2012-01-26 12:49:15 +00:00
|
|
|
/**
|
|
|
|
|
* Class to manage the box to show bookmarks
|
|
|
|
|
*/
|
2012-01-28 16:22:02 +00:00
|
|
|
class box_bookmarks extends ModeleBoxes
|
|
|
|
|
{
|
2009-08-26 09:37:54 +00:00
|
|
|
var $boxcode="bookmarks";
|
|
|
|
|
var $boximg="object_bookmark";
|
2013-01-15 16:06:53 +00:00
|
|
|
var $boxlabel="BoxMyLastBookmarks";
|
2009-08-26 09:37:54 +00:00
|
|
|
var $depends = array("bookmark");
|
2005-09-11 22:35:09 +00:00
|
|
|
|
2006-06-18 01:34:15 +00:00
|
|
|
var $db;
|
|
|
|
|
var $param;
|
|
|
|
|
|
2009-08-26 09:37:54 +00:00
|
|
|
var $info_box_head = array();
|
|
|
|
|
var $info_box_contents = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-11-23 17:28:14 +00:00
|
|
|
* Load data for box to show them later
|
|
|
|
|
*
|
|
|
|
|
* @param int $max Maximum number of records to load
|
|
|
|
|
* @return void
|
2009-08-26 09:37:54 +00:00
|
|
|
*/
|
|
|
|
|
function loadBox($max=5)
|
|
|
|
|
{
|
|
|
|
|
global $user, $langs, $db;
|
|
|
|
|
$langs->load("boxes");
|
2011-06-17 19:14:47 +00:00
|
|
|
|
2009-08-26 09:37:54 +00:00
|
|
|
$this->max=$max;
|
|
|
|
|
|
|
|
|
|
$this->info_box_head = array('text' => $langs->trans("BoxMyLastBookmarks",$max),
|
2005-10-03 10:48:38 +00:00
|
|
|
'sublink' => DOL_URL_ROOT.'/bookmarks/liste.php');
|
2009-08-26 09:37:54 +00:00
|
|
|
if ($user->rights->bookmark->creer)
|
|
|
|
|
{
|
|
|
|
|
$this->info_box_head['subpicto']='object_bookmark';
|
|
|
|
|
$this->info_box_head['subtext']=$langs->trans("BookmarksManagement");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$this->info_box_head['subpicto']='object_bookmark';
|
|
|
|
|
$this->info_box_head['subtext']=$langs->trans("ListOfBookmark");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($user->rights->bookmark->lire)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT b.title, b.url, b.target, b.favicon";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b";
|
|
|
|
|
$sql.= " WHERE fk_user = ".$user->id;
|
2010-06-08 08:55:48 +00:00
|
|
|
$sql.= $db->order("position","ASC");
|
|
|
|
|
$sql.= $db->plimit($max, 0);
|
2009-08-26 09:37:54 +00:00
|
|
|
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
if ($result)
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows($result);
|
|
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$objp = $db->fetch_object($result);
|
|
|
|
|
|
|
|
|
|
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
|
2005-09-11 22:35:09 +00:00
|
|
|
'logo' => $this->boximg,
|
2008-12-07 15:55:40 +00:00
|
|
|
'url' => $objp->url,
|
|
|
|
|
'target' => $objp->target?'newtab':'');
|
2009-08-26 09:37:54 +00:00
|
|
|
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
|
2008-12-07 15:55:40 +00:00
|
|
|
'text' => $objp->title,
|
2005-09-11 22:35:09 +00:00
|
|
|
'url' => $objp->url,
|
|
|
|
|
'target' => $objp->target?'newtab':'');
|
2009-08-26 09:37:54 +00:00
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-19 18:05:38 +00:00
|
|
|
if ($num==0)
|
|
|
|
|
{
|
|
|
|
|
$mytxt=$langs->trans("NoRecordedBookmarks");
|
2010-12-19 18:19:54 +00:00
|
|
|
if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
|
2010-12-19 18:05:38 +00:00
|
|
|
$this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$mytxt);
|
|
|
|
|
}
|
2013-06-07 22:52:02 +00:00
|
|
|
|
|
|
|
|
$db->free($result);
|
2009-08-26 09:37:54 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-08-29 06:37:12 +00:00
|
|
|
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
|
|
|
|
|
'maxlength'=>500,
|
|
|
|
|
'text' => ($db->error().' sql='.$sql));
|
2009-08-26 09:37:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$this->info_box_contents[0][0] = array('align' => 'left',
|
2005-09-11 22:35:09 +00:00
|
|
|
'text' => $langs->trans("ReadPermissionNotAllowed"));
|
2009-08-26 09:37:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-09-11 22:35:09 +00:00
|
|
|
|
2011-11-23 17:28:14 +00:00
|
|
|
/**
|
|
|
|
|
* Method to show box
|
|
|
|
|
*
|
|
|
|
|
* @param array $head Array with properties of box title
|
|
|
|
|
* @param array $contents Array with properties of box lines
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2011-06-17 19:14:47 +00:00
|
|
|
function showBox($head = null, $contents = null)
|
2009-08-26 09:37:54 +00:00
|
|
|
{
|
|
|
|
|
parent::showBox($this->info_box_head, $this->info_box_contents);
|
|
|
|
|
}
|
2005-09-11 22:35:09 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|