Skip to content

Commit

Permalink
Merge pull request #2081 from marcosgdf/bookmarks
Browse files Browse the repository at this point in the history
Fixed several problems with bookmarks page
  • Loading branch information
eldy committed Nov 24, 2014
2 parents dc63388 + 496a3fc commit 9b9e640
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 35 deletions.
76 changes: 42 additions & 34 deletions htdocs/bookmarks/card.php
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* 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
Expand Down Expand Up @@ -50,6 +51,13 @@

if ($action == 'add' || $action == 'addproduct' || $action == 'update')
{

if ($action == 'update') {
$invertedaction = 'edit';
} else {
$invertedaction = 'create';
}

$error = 0;

if (GETPOST("cancel"))
Expand All @@ -69,12 +77,12 @@

if (! $title) {
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")), 'errors');
setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("BookmarkTitle")), 'errors');
}

if (! $url) {
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink")), 'errors');
setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("UrlOrLink")), 'errors');
}

if (! $error)
Expand All @@ -95,43 +103,21 @@
if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
setEventMessage($langs->trans("WarningBookmarkAlreadyExists"), 'warnings');
setEventMessage($langs->transnoentities("WarningBookmarkAlreadyExists"), 'warnings');
}
else
{
setEventMessage($bookmark->error, 'errors');
}
$action='create';
$action = $invertedaction;
}
}
else
{
$action='create';
}
}

if ($action == 'delete')
{
$bookmark=new Bookmark($db);
$bookmark->id=$_GET["bid"];
$bookmark->url=$user->id;
$bookmark->target=$user->id;
$bookmark->title='xxx';
$bookmark->favicon='xxx';

$res=$bookmark->remove();
if ($res > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
setEventMessage($bookmark->error, 'errors');
$action = $invertedaction;
}
}


/*
* View
*/
Expand All @@ -153,8 +139,6 @@

print_fiche_titre($langs->trans("NewBookmark"));

dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark');

print '<table class="border" width="100%">';

print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("BookmarkTitle").'</td><td><input class="flat" name="title" size="30" value="'.$title.'"></td><td class="hideonsmartphone">'.$langs->trans("SetHereATitleForLink").'</td></tr>';
Expand Down Expand Up @@ -183,8 +167,6 @@
print '</div>';

print '</form>';

dol_fiche_end();
}


Expand All @@ -196,8 +178,15 @@
$bookmark=new Bookmark($db);
$bookmark->fetch($id);

$head = array(
array(
'',
$langs->trans('Card'),
'card'
)
);

dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark');
dol_fiche_head($head, 'card', $langs->trans("Bookmark"),0,'bookmark');

if ($action == 'edit')
{
Expand All @@ -213,12 +202,31 @@

print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'.$bookmark->ref.'</td></tr>';

print '<tr><td>'.$langs->trans("BookmarkTitle").'</td><td>';
print '<tr><td>';
if ($action == 'edit') {
print '<span class="fieldrequired">';
}

print $langs->trans("BookmarkTitle");

if ($action == 'edit') {
print '</span>';
}

print '</td><td>';
if ($action == 'edit') print '<input class="flat" name="title" size="30" value="'.(isset($_POST["title"])?$_POST["title"]:$bookmark->title).'">';
else print $bookmark->title;
print '</td></tr>';

print '<tr><td>'.$langs->trans("UrlOrLink").'</td><td>';
print '<tr><td>';
if ($action == 'edit') {
print '<span class="fieldrequired">';
}
print $langs->trans("UrlOrLink");
if ($action == 'edit') {
print '</span>';
}
print '</td><td>';
if ($action == 'edit') print '<input class="flat" name="url" size="80" value="'.(isset($_POST["url"])?$_POST["url"]:$bookmark->url).'">';
else print '<a href="'.(preg_match('/^http/i',$bookmark->url)?$bookmark->url:DOL_URL_ROOT.$bookmark->url).'"'.($bookmark->target?' target="_blank"':'').'>'.$bookmark->url.'</a>';
print '</td></tr>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/bookmarks/list.php
Expand Up @@ -59,7 +59,7 @@
}
else
{
$setEventMessage($bookmark->error, 'errors');
setEventMessage($bookmark->error, 'errors');
}
}

Expand Down

0 comments on commit 9b9e640

Please sign in to comment.