18 |
* |
* |
19 |
* $Id$ |
* $Id$ |
20 |
* $Source$ |
* $Source$ |
|
* |
|
21 |
*/ |
*/ |
22 |
|
|
23 |
/** |
/** |
24 |
\file htdocs/comm/bookmark.php |
\file htdocs/bookmarks/fiche.php |
25 |
\brief Page affichage des bookmarks |
\brief Page affichage/creation des bookmarks |
26 |
|
\ingroup bookmark |
27 |
\version $Revision$ |
\version $Revision$ |
28 |
*/ |
*/ |
29 |
|
|
31 |
require("./pre.inc.php"); |
require("./pre.inc.php"); |
32 |
require_once(DOL_DOCUMENT_ROOT."/bookmarks/bookmark.class.php"); |
require_once(DOL_DOCUMENT_ROOT."/bookmarks/bookmark.class.php"); |
33 |
|
|
34 |
|
$langs->load("other"); |
35 |
|
|
36 |
|
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; |
37 |
|
$title=isset($_GET["title"])?$_GET["title"]:$_POST["title"]; |
38 |
|
$url=isset($_GET["url"])?$_GET["url"]:$_POST["url"]; |
39 |
|
$target=isset($_GET["target"])?$_GET["target"]:$_POST["target"]; |
40 |
|
|
41 |
|
|
42 |
/* |
/* |
43 |
* Actions |
* Actions |
44 |
*/ |
*/ |
45 |
|
|
46 |
if ($_GET["action"] == 'add') |
if ($action == 'add') |
47 |
{ |
{ |
48 |
|
$mesg=''; |
49 |
|
|
50 |
$bookmark=new Bookmark($db); |
$bookmark=new Bookmark($db); |
51 |
$bookmark->fk_user=$user->id; |
$bookmark->fk_user=$user->id; |
52 |
if ($_GET["socid"]) // Lien vers fiche comm société |
if ($_GET["socid"]) // Lien vers fiche comm société |
56 |
$societe->fetch($_GET["socid"]); |
$societe->fetch($_GET["socid"]); |
57 |
$bookmark->fk_soc=$societe->id; |
$bookmark->fk_soc=$societe->id; |
58 |
$bookmark->url=DOL_URL_ROOT.'/comm/fiche.php?socidp='.$societe->id; |
$bookmark->url=DOL_URL_ROOT.'/comm/fiche.php?socidp='.$societe->id; |
59 |
$bookmark->target=''; |
$bookmark->target='0'; |
60 |
$bookmark->title=$societe->nom; |
$bookmark->title=$societe->nom; |
61 |
} |
} |
62 |
else |
else |
63 |
{ |
{ |
64 |
$bookmark->url=$_GET["url"]; |
if (! $title) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")); |
65 |
$bookmark->target=$_GET["target"]; |
if (! $url) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink")); |
66 |
$bookmark->title=$_GET["title"]; |
|
67 |
} |
$bookmark->title=$title; |
68 |
$bookmark->favicon='xxx'; |
$bookmark->url=$url; |
69 |
|
$bookmark->target=$target; |
70 |
$res=$bookmark->create(); |
} |
71 |
if ($res > 0) |
|
72 |
{ |
if (! $mesg) |
73 |
$urlsource=isset($_GET["urlsource"])?$_GET["urlsource"]:$_SERVER["PHP_SELF"]; |
{ |
74 |
header("Location: ".$urlsource); |
$bookmark->favicon='xxx'; |
75 |
|
|
76 |
|
$res=$bookmark->create(); |
77 |
|
if ($res > 0) |
78 |
|
{ |
79 |
|
$urlsource=isset($_GET["urlsource"])?$_GET["urlsource"]:DOL_URL_ROOT.'/bookmarks/liste.php'; |
80 |
|
header("Location: ".$urlsource); |
81 |
|
} |
82 |
|
else |
83 |
|
{ |
84 |
|
$mesg='<div class="error">'.$bookmark->error.'</div>'; |
85 |
|
$action='create'; |
86 |
|
} |
87 |
} |
} |
88 |
else |
else |
89 |
{ |
{ |
90 |
$mesg='<div class="error">'.$bookmark->error.'</div>'; |
$mesg='<div class="error">'.$mesg.'</div>'; |
91 |
|
$action='create'; |
92 |
} |
} |
93 |
|
|
94 |
} |
} |
95 |
|
|
96 |
if ($_GET["action"] == 'delete') |
if ($_GET["action"] == 'delete') |
117 |
|
|
118 |
llxHeader(); |
llxHeader(); |
119 |
|
|
120 |
print_fiche_titre($langs->trans("Bookmarks")); |
$html=new Form($db); |
121 |
|
|
122 |
|
|
123 |
|
if ($action == 'create') |
124 |
|
{ |
125 |
|
/* |
126 |
|
* Fiche bookmark en mode creation |
127 |
|
*/ |
128 |
|
|
129 |
|
print '<form action="fiche.php" method="post">'."\n"; |
130 |
|
print '<input type="hidden" name="action" value="add">'; |
131 |
|
|
132 |
|
print_fiche_titre($langs->trans("NewBookmark")); |
133 |
|
|
134 |
|
if ($mesg) print "$mesg<br>"; |
135 |
|
|
136 |
|
print '<table class="border" width="100%">'; |
137 |
|
|
138 |
|
print '<tr><td width="20%">'.$langs->trans("BookmarkTitle").'</td><td><input class="flat" name="title" size="30" value="'.$title.'"></td><td>'.$langs->trans("SetHereATitleForLink").'</td></tr>'; |
139 |
|
print '<tr><td width="20%">'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" size="50" value=""></td><td>'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>'; |
140 |
|
print '<tr><td width="20%">'.$langs->trans("BehaviourOnClick").'</td><td>'; |
141 |
|
$liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow")); |
142 |
|
$html->select_array('target',$liste,1); |
143 |
|
print '</td><td>'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</td></tr>'; |
144 |
|
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("CreateBookmark").'"></td></tr>'; |
145 |
|
print '</table>'; |
146 |
|
|
147 |
|
print '</form>'; |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
|
if ($_GET["id"] > 0) |
152 |
|
{ |
153 |
|
/* |
154 |
|
* Fiche bookmark en mode edition |
155 |
|
*/ |
156 |
|
$bookmark=new Bookmark($db); |
157 |
|
$bookmark->fetch($_GET["id"]); |
158 |
|
|
159 |
|
|
160 |
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Bookmark")); |
161 |
|
|
162 |
|
print '<table class="border" width="100%">'; |
163 |
|
|
164 |
print 'En construction'; |
print '<tr><td width="20%">'.$langs->trans("BookmarkTitle").'</td><td>'.$bookmark->title.'</td></tr>'; |
165 |
|
print '<tr><td width="20%">'.$langs->trans("UrlOrLink").'</td><td>'; |
166 |
|
print '<a href="'.(eregi('^http',$bookmark->url)?$bookmark->url:DOL_URL_ROOT.$bookmark->url).'" target="'.($bookmark->target?"":"newlink").'">'.$bookmark->url.'</a></td></tr>'; |
167 |
|
print '<tr><td width="20%">'.$langs->trans("BehaviourOnClick").'</td><td>'; |
168 |
|
if ($bookmark->target == 0) print $langs->trans("OpenANewWindow"); |
169 |
|
if ($bookmark->target == 1) print $langs->trans("ReplaceWindow"); |
170 |
|
print '</td></tr>'; |
171 |
|
print '</table>'; |
172 |
|
|
173 |
|
print "</div>\n"; |
174 |
|
|
175 |
|
print "<div class=\"tabsAction\">\n"; |
176 |
|
|
177 |
|
// Supprimer |
178 |
|
if ($user->rights->bookmark->supprimer) |
179 |
|
{ |
180 |
|
print " <a class=\"butActionDelete\" href=\"liste.php?bid=".$bookmark->id."&action=delete\">".$langs->trans("Delete")."</a>\n"; |
181 |
|
} |
182 |
|
|
183 |
|
print '</div>'; |
184 |
|
|
185 |
|
} |
186 |
|
|
187 |
$db->close(); |
$db->close(); |
188 |
|
|
189 |
|
|
190 |
llxFooter('$Date$ - $Revision$'); |
llxFooter('$Date$ - $Revision$'); |
191 |
|
|
192 |
?> |
?> |