34 public $element =
'bookmark';
39 public $table_element =
'bookmark';
45 public $ismultientitymanaged = 1;
50 public $picto =
'bookmark';
117 $sql =
"SELECT rowid, fk_user, dateb as datec, url, target,";
118 $sql .=
" title, position, favicon";
119 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bookmark";
120 $sql .=
" WHERE rowid = ".((int) $id);
121 $sql .=
" AND entity = ".$conf->entity;
126 $obj = $this->
db->fetch_object(
$resql);
128 $this->
id = $obj->rowid;
129 $this->
ref = $obj->rowid;
131 $this->fk_user = $obj->fk_user;
132 $this->datec = $this->
db->jdate($obj->datec);
133 $this->url = $obj->url;
134 $this->target = $obj->target;
135 $this->title = $obj->title;
136 $this->position = $obj->position;
137 $this->favicon = $obj->favicon;
157 $this->url = trim($this->url);
158 $this->title = trim($this->title);
159 if (empty($this->position)) {
167 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bookmark (fk_user,dateb,url,target";
168 $sql .=
",title,favicon,position";
170 $sql .=
") VALUES (";
171 $sql .= ($this->fk_user > 0 ? $this->fk_user :
"0").
",";
172 $sql .=
" '".$this->db->idate($now).
"',";
173 $sql .=
" '".$this->db->escape($this->url).
"', '".$this->
db->escape($this->target).
"',";
174 $sql .=
" '".$this->db->escape($this->title).
"', '".$this->
db->escape($this->favicon).
"', ".(int) $this->position;
175 $sql .=
", ".(int) $conf->entity;
181 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"bookmark");
187 $this->error = $this->
db->lasterror();
188 $this->errno = $this->
db->lasterrno();
189 $this->
db->rollback();
193 $this->error = $this->
db->lasterror();
194 $this->errno = $this->
db->lasterrno();
195 $this->
db->rollback();
208 $this->url = trim($this->url);
209 $this->title = trim($this->title);
210 if (empty($this->position)) {
214 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bookmark";
215 $sql .=
" SET fk_user = ".($this->fk_user > 0 ? $this->fk_user :
"0");
216 $sql .=
" ,dateb = '".$this->db->idate($this->datec).
"'";
217 $sql .=
" ,url = '".$this->db->escape($this->url).
"'";
218 $sql .=
" ,target = '".$this->db->escape($this->target).
"'";
219 $sql .=
" ,title = '".$this->db->escape($this->title).
"'";
220 $sql .=
" ,favicon = '".$this->db->escape($this->favicon).
"'";
221 $sql .=
" ,position = ".(int) $this->position;
222 $sql .=
" WHERE rowid = ".((int) $this->
id);
225 if ($this->
db->query($sql)) {
228 $this->error = $this->
db->lasterror();
239 public function delete($user)
241 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bookmark";
242 $sql .=
" WHERE rowid = ".((int) $this->
id);
248 $this->error = $this->
db->lasterror();
291 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
293 global $conf, $langs, $hookmanager;
295 if (!empty($conf->dol_no_mouse_hover)) {
301 $label =
'<u>'.$langs->trans(
"Bookmark").
'</u>';
303 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
305 $url = DOL_URL_ROOT.
'/bookmarks/card.php?id='.$this->id;
307 if ($option !=
'nolink') {
309 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
310 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
311 $add_save_lastsearch_values = 1;
313 if ($add_save_lastsearch_values) {
314 $url .=
'&save_lastsearch_values=1';
319 if (empty($notooltip)) {
320 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
321 $label = $langs->trans(
"ShowBookmark");
322 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
324 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
325 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
327 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
330 $linkstart =
'<a href="'.$url.
'"';
331 $linkstart .= $linkclose.
'>';
334 $result .= $linkstart;
336 $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);
338 if ($withpicto != 2) {
339 $result .= $this->ref;
344 global $action, $hookmanager;
345 $hookmanager->initHooks(array(
'mybookmarkdao'));
346 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
347 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
349 $result = $hookmanager->resPrint;
351 $result .= $hookmanager->resPrint;