34 public $element =
'bookmark';
39 public $table_element =
'bookmark';
45 public $ismultientitymanaged = 1;
50 public $picto =
'bookmark';
118 $sql =
"SELECT rowid, fk_user, dateb as datec, url, target,";
119 $sql .=
" title, position, favicon";
120 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookmark";
121 $sql .=
" WHERE rowid = ".((int) $id);
122 $sql .=
" AND entity = ".$conf->entity;
125 $resql = $this->db->query($sql);
127 $obj = $this->db->fetch_object($resql);
129 $this->
id = $obj->rowid;
130 $this->
ref = $obj->rowid;
132 $this->fk_user = $obj->fk_user;
133 $this->datec = $this->db->jdate($obj->datec);
134 $this->url = $obj->url;
135 $this->target = $obj->target;
136 $this->title = $obj->title;
138 $this->favicon = $obj->favicon;
140 $this->db->free($resql);
158 $this->url = trim($this->url);
159 $this->title = trim($this->title);
168 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bookmark (fk_user,dateb,url,target";
169 $sql .=
",title,favicon,position";
171 $sql .=
") VALUES (";
172 $sql .= ($this->fk_user > 0 ? $this->fk_user :
"0").
",";
173 $sql .=
" '".$this->db->idate($now).
"',";
174 $sql .=
" '".$this->db->escape($this->url).
"', '".$this->db->escape($this->target).
"',";
175 $sql .=
" '".$this->db->escape($this->title).
"', '".$this->db->escape($this->favicon).
"', ".(int) $this->
position;
176 $sql .=
", ".(int) $conf->entity;
180 $resql = $this->db->query($sql);
182 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"bookmark");
188 $this->error = $this->db->lasterror();
189 $this->errno = $this->db->lasterrno();
190 $this->db->rollback();
194 $this->error = $this->db->lasterror();
195 $this->errno = $this->db->lasterrno();
196 $this->db->rollback();
209 $this->url = trim($this->url);
210 $this->title = trim($this->title);
215 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bookmark";
216 $sql .=
" SET fk_user = ".($this->fk_user > 0 ? $this->fk_user :
"0");
217 $sql .=
" ,dateb = '".$this->db->idate($this->datec).
"'";
218 $sql .=
" ,url = '".$this->db->escape($this->url).
"'";
219 $sql .=
" ,target = '".$this->db->escape($this->target).
"'";
220 $sql .=
" ,title = '".$this->db->escape($this->title).
"'";
221 $sql .=
" ,favicon = '".$this->db->escape($this->favicon).
"'";
222 $sql .=
" ,position = ".(int) $this->
position;
223 $sql .=
" WHERE rowid = ".((int) $this->
id);
226 if ($this->db->query($sql)) {
229 $this->error = $this->db->lasterror();
240 public function delete($user)
242 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bookmark";
243 $sql .=
" WHERE rowid = ".((int) $this->
id);
245 $resql = $this->db->query($sql);
249 $this->error = $this->db->lasterror();
292 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
294 global $conf, $langs, $hookmanager;
296 if (!empty($conf->dol_no_mouse_hover)) {
302 $label =
'<u>'.$langs->trans(
"Bookmark").
'</u>';
304 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
306 $url = DOL_URL_ROOT.
'/bookmarks/card.php?id='.$this->id;
308 if ($option !=
'nolink') {
310 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
311 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
312 $add_save_lastsearch_values = 1;
314 if ($add_save_lastsearch_values) {
315 $url .=
'&save_lastsearch_values=1';
320 if (empty($notooltip)) {
322 $label = $langs->trans(
"ShowBookmark");
323 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
325 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
326 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
328 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
331 $linkstart =
'<a href="'.$url.
'"';
332 $linkstart .= $linkclose.
'>';
335 $result .= $linkstart;
337 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
339 if ($withpicto != 2) {
340 $result .= $this->ref;
345 global $action, $hookmanager;
346 $hookmanager->initHooks(array(
'mybookmarkdao'));
347 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
348 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
350 $result = $hookmanager->resPrint;
352 $result .= $hookmanager->resPrint;
Class to manage bookmarks.
create()
Insert bookmark into database.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
update()
Update bookmark record.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
fetch($id)
Directs the bookmark.
__construct($db)
Constructor.
getLibStatut($mode)
Return the label of the status.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
Class to manage Dolibarr database access.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.