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 = ".((int)
$conf->entity);
125 $resql = $this->db->query($sql);
127 $obj = $this->db->fetch_object($resql);
130 $this->db->free($resql);
134 $this->
id = $obj->rowid;
135 $this->
ref = $obj->rowid;
137 $this->fk_user = $obj->fk_user;
138 $this->datec = $this->db->jdate($obj->datec);
139 $this->url = $obj->url;
140 $this->target = $obj->target;
141 $this->title = $obj->title;
143 $this->favicon = $obj->favicon;
145 $this->db->free($resql);
148 dol_print_error($this->db);
163 $this->url = trim($this->url);
164 $this->title = trim($this->title);
173 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bookmark (fk_user,dateb,url,target";
174 $sql .=
",title,favicon,position";
176 $sql .=
") VALUES (";
177 $sql .= ($this->fk_user > 0 ? ((int) $this->fk_user) :
"0").
",";
178 $sql .=
" '".$this->db->idate($now).
"',";
179 $sql .=
" '".$this->db->escape($this->url).
"', '".$this->db->escape($this->target).
"',";
180 $sql .=
" '".$this->db->escape($this->title).
"', '".$this->db->escape($this->favicon).
"', ".(int) $this->
position;
181 $sql .=
", ".(int)
$conf->entity;
185 $resql = $this->db->query($sql);
187 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"bookmark");
193 $this->error = $this->db->lasterror();
194 $this->errno = $this->db->lasterrno();
195 $this->db->rollback();
199 $this->error = $this->db->lasterror();
200 $this->errno = $this->db->lasterrno();
201 $this->db->rollback();
214 $this->url = trim($this->url);
215 $this->title = trim($this->title);
220 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bookmark";
221 $sql .=
" SET fk_user = ".($this->fk_user > 0 ? ((int) $this->fk_user) :
"0");
222 $sql .=
" ,dateb = '".$this->db->idate($this->datec).
"'";
223 $sql .=
" ,url = '".$this->db->escape($this->url).
"'";
224 $sql .=
" ,target = '".$this->db->escape($this->target).
"'";
225 $sql .=
" ,title = '".$this->db->escape($this->title).
"'";
226 $sql .=
" ,favicon = '".$this->db->escape($this->favicon).
"'";
227 $sql .=
" ,position = ".(int) $this->
position;
228 $sql .=
" WHERE rowid = ".((int) $this->
id);
231 if ($this->db->query($sql)) {
234 $this->error = $this->db->lasterror();
280 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
282 global
$conf, $langs, $hookmanager;
284 if (!empty(
$conf->dol_no_mouse_hover)) {
290 $label =
'<u>'.$langs->trans(
"Bookmark").
'</u>';
292 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
294 $url = DOL_URL_ROOT.
'/bookmarks/card.php?id='.$this->id;
296 if ($option !=
'nolink') {
298 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
299 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
300 $add_save_lastsearch_values = 1;
302 if ($add_save_lastsearch_values) {
303 $url .=
'&save_lastsearch_values=1';
308 if (empty($notooltip)) {
310 $label = $langs->trans(
"ShowBookmark");
311 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
313 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
314 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
316 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
319 $linkstart =
'<a href="'.$url.
'"';
320 $linkstart .= $linkclose.
'>';
323 $result .= $linkstart;
325 $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);
327 if ($withpicto != 2) {
328 $result .= $this->ref;
333 global $action, $hookmanager;
334 $hookmanager->initHooks(array(
'mybookmarkdao'));
335 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
336 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
338 $result = $hookmanager->resPrint;
340 $result .= $hookmanager->resPrint;