Bookmarks can be publics
This commit is contained in:
parent
a3ba107ced
commit
b4982e450e
@ -61,23 +61,25 @@ class Bookmark
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT rowid, fk_user, ".$this->db->pdate("dateb").", url, target,";
|
||||
$sql = "SELECT rowid, fk_user, ".$this->db->pdate("dateb")." as datec, url, target,";
|
||||
$sql.= " title, favicon";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
dolibarr_syslog("Bookmark::fetch sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query ($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->datec = $obj->datec;
|
||||
$this->url = $obj->url;
|
||||
$this->target = $obj->target;
|
||||
$this->title = stripslashes($obj->title);
|
||||
$this->title = $obj->title;
|
||||
$this->favicon = $obj->favicon;
|
||||
|
||||
$this->db->free($resql);
|
||||
@ -97,7 +99,7 @@ class Bookmark
|
||||
function create()
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target";
|
||||
$sql.= " ,title,favicon";
|
||||
if ($this->fk_soc) $sql.=",fk_soc";
|
||||
@ -170,7 +172,7 @@ class Bookmark
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark";
|
||||
$sql .= " WHERE rowid = ".$id;
|
||||
|
||||
|
||||
$resql=$this->db->query ($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
@ -65,7 +65,7 @@ function printBookmarksList ($aDb, $aLangs)
|
||||
if (! empty($conf->global->BOOKMARKS_SHOW_IN_MENU))
|
||||
{
|
||||
$sql = "SELECT rowid, title, url FROM ".MAIN_DB_PREFIX."bookmark";
|
||||
if (! $user->admin) $sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL)";
|
||||
if (! $user->admin) $sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
||||
if ($resql = $db->query($sql) )
|
||||
{
|
||||
$i=0;
|
||||
|
||||
@ -57,35 +57,6 @@ if ($action == 'add' || $action == 'addproduct')
|
||||
$bookmark->url=$url;
|
||||
$bookmark->target=$target;
|
||||
|
||||
// TODO Remove because this test is now always false
|
||||
if ($action == 'add' && $_GET["socid"]) // Link to third party card
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||
$langs->load("companies");
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($_GET["socid"]);
|
||||
$bookmark->url=DOL_URL_ROOT.'/soc.php?socid='.$societe->id;
|
||||
$bookmark->target='0';
|
||||
$bookmark->title=$langs->trans("ThirdParty").' '.$societe->nom;
|
||||
//$bookmark->title=$societe->nom;
|
||||
$title=$bookmark->title;
|
||||
$url=$bookmark->url;
|
||||
}
|
||||
// TODO Remove because this test is now always false
|
||||
if ($action == 'addproduct' && $_GET["id"]) // Link to product card
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
$langs->load("products");
|
||||
$product=new Product($db);
|
||||
$product->fetch($_GET["id"]);
|
||||
$bookmark->url=DOL_URL_ROOT.'/product/fiche.php?id='.$product->id;
|
||||
$bookmark->target='0';
|
||||
$bookmark->title=($product->type != 1 ?$langs->trans("Product"):$langs->trans("Service")).' '.$product->ref;
|
||||
//$bookmark->title=$product->ref;
|
||||
$title=$bookmark->title;
|
||||
$url=$bookmark->url;
|
||||
}
|
||||
|
||||
if (! $title) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle"));
|
||||
if (! $url) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink"));
|
||||
|
||||
@ -168,9 +139,9 @@ if ($action == 'create')
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
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>';
|
||||
print '<tr><td width="20%">'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" size="50" value="'.$url.'"></td><td>'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("BehaviourOnClick").'</td><td>';
|
||||
print '<tr><td width="25%">'.$langs->trans("BookmarkTitle").'</td><td><input class="flat" name="title" size="30" value="'.$title.'"></td><td>'.$langs->trans("SetHereATitleForLink").'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" size="50" value="'.$url.'"></td><td>'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
|
||||
$liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow"));
|
||||
$html->select_array('target',$liste,1);
|
||||
print '</td><td>'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</td></tr>';
|
||||
@ -199,13 +170,29 @@ if ($_GET["id"] > 0 && ! eregi('^add',$_GET["action"]))
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("BookmarkTitle").'</td><td>'.$bookmark->title.'</td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("UrlOrLink").'</td><td>';
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'.$bookmark->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("BookmarkTitle").'</td><td>'.$bookmark->title.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("UrlOrLink").'</td><td>';
|
||||
print '<a href="'.(eregi('^http',$bookmark->url)?$bookmark->url:DOL_URL_ROOT.$bookmark->url).'" target="'.($bookmark->target?"":"newlink").'">'.$bookmark->url.'</a></td></tr>';
|
||||
print '<tr><td width="20%">'.$langs->trans("BehaviourOnClick").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
|
||||
if ($bookmark->target == 0) print $langs->trans("OpenANewWindow");
|
||||
if ($bookmark->target == 1) print $langs->trans("ReplaceWindow");
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Owner").'</td><td>';
|
||||
if ($bookmark->fk_user)
|
||||
{
|
||||
$fuser=new User($db);
|
||||
$fuser->id=$bookmark->fk_user;
|
||||
$fuser->fetch();
|
||||
//$fuser->nom=$fuser->login; $fuser->prenom='';
|
||||
print $fuser->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Public");
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("DateCreation").'</td><td>'.dolibarr_print_date($bookmark->datec,'dayhour').'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
@ -64,6 +64,8 @@ if ($_GET["action"] == 'delete')
|
||||
* View
|
||||
*/
|
||||
|
||||
$userstatic=new User($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_fiche_titre($langs->trans("Bookmarks"));
|
||||
@ -72,9 +74,9 @@ if ($mesg) print $mesg;
|
||||
|
||||
$sql = "SELECT b.fk_soc as rowid, ".$db->pdate("b.dateb")." as dateb, b.rowid as bid, b.fk_user, b.url, b.target, b.title, b.favicon,";
|
||||
$sql.= " u.login, u.name, u.firstname";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE b.fk_user=u.rowid";
|
||||
if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid";
|
||||
$sql.= " WHERE 1=1";
|
||||
if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)";
|
||||
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
|
||||
|
||||
$resql=$db->query($sql);
|
||||
@ -87,11 +89,11 @@ if ($resql)
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
//print "<td> </td>";
|
||||
print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"],"bid","","",'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"bid","","",'align="left"',$sortfield,$sortorder);
|
||||
print '<td>'.$langs->trans("Title")."</td>";
|
||||
print '<td>'.$langs->trans("Link")."</td>";
|
||||
print '<td align="center">'.$langs->trans("Target")."</td>";
|
||||
print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.name","","",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Owner"),$_SERVER["PHP_SELF"],"u.name","","",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"b.dateb","","",'align="center"',$sortfield,$sortorder);
|
||||
print "<td> </td>";
|
||||
print "</tr>\n";
|
||||
@ -149,7 +151,18 @@ if ($resql)
|
||||
print "</td>\n";
|
||||
|
||||
// Author
|
||||
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->fk_user.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login."</a></td>\n";
|
||||
print '<td align="center">';
|
||||
if ($obj->fk_user)
|
||||
{
|
||||
$userstatic->id=$obj->fk_user;
|
||||
$userstatic->nom=$obj->login;
|
||||
print $userstatic->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Public");
|
||||
}
|
||||
print "</td>\n";
|
||||
|
||||
// Date creation
|
||||
print '<td align="center">'.dolibarr_print_date($obj->dateb,'day') ."</td>";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user