mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Bookmarks can be publics
This commit is contained in:
parent
a6c856b4b8
commit
971a470dde
|
|
@ -40,10 +40,11 @@ class Bookmark
|
|||
var $fk_user;
|
||||
var $datec;
|
||||
var $url;
|
||||
var $target;
|
||||
var $target; // 0=replace, 1=new window
|
||||
var $title;
|
||||
var $favicon;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur
|
||||
* \param db Handler d'accès base de données
|
||||
|
|
@ -61,7 +62,7 @@ class Bookmark
|
|||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
$sql = "SELECT rowid, fk_user, ".$this->db->pdate("dateb")." as datec, url, target,";
|
||||
$sql = "SELECT rowid, fk_user, dateb as datec, url, target,";
|
||||
$sql.= " title, favicon";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
|
@ -76,7 +77,7 @@ class Bookmark
|
|||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->datec = $obj->datec;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->url = $obj->url;
|
||||
$this->target = $obj->target;
|
||||
$this->title = $obj->title;
|
||||
|
|
@ -87,7 +88,7 @@ class Bookmark
|
|||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error ($this->db);
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -98,19 +99,25 @@ class Bookmark
|
|||
*/
|
||||
function create()
|
||||
{
|
||||
// Clean parameters
|
||||
$this->url=trim($this->url);
|
||||
$this->title=trim($this->title);
|
||||
|
||||
$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";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES ('".$this->fk_user."', ".$this->db->idate(mktime()).",";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= ($this->fk_user > 0?"'".$this->fk_user."'":"0").",";
|
||||
$sql.= " ".$this->db->idate(gmmktime()).",";
|
||||
$sql.= " '".$this->url."', '".$this->target."',";
|
||||
$sql.= " '".addslashes($this->title)."', '".$this->favicon."'";
|
||||
if ($this->fk_soc) $sql.=",".$this->fk_soc;
|
||||
$sql.= ")";
|
||||
$resql = $this->db->query ($sql);
|
||||
|
||||
dolibarr_syslog("Bookmark::update sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query ($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark");
|
||||
|
|
@ -143,22 +150,27 @@ class Bookmark
|
|||
*/
|
||||
function update()
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
|
||||
$sql.= " SET fk_user = '".$this->fk_user."'";
|
||||
$sql.= " ,dateb = '".$this->datec."'";
|
||||
$sql.= " ,url = '".$this->url."'";
|
||||
// Clean parameters
|
||||
$this->url=trim($this->url);
|
||||
$this->title=trim($this->title);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
|
||||
$sql.= " SET fk_user = ".($this->fk_user > 0?"'".$this->fk_user."'":"0");
|
||||
$sql.= " ,dateb = '".$this->db->idate($this->datec)."'";
|
||||
$sql.= " ,url = '".addslashes($this->url)."'";
|
||||
$sql.= " ,target = '".$this->target."'";
|
||||
$sql.= " ,title = '".$this->title."'";
|
||||
$sql.= " ,title = '".addslashes($this->title)."'";
|
||||
$sql.= " ,favicon = '".$this->favicon."'";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dolibarr_syslog("Bookmark::update sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query ($sql))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -173,6 +185,7 @@ class Bookmark
|
|||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark";
|
||||
$sql .= " WHERE rowid = ".$id;
|
||||
|
||||
dolibarr_syslog("Bookmark::remove sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query ($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
|
@ -180,7 +193,7 @@ class Bookmark
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,17 +34,18 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
|||
$title=isset($_GET["title"])?$_GET["title"]:$_POST["title"];
|
||||
$url=isset($_GET["url"])?$_GET["url"]:$_POST["url"];
|
||||
$target=isset($_GET["target"])?$_GET["target"]:$_POST["target"];
|
||||
$userid=isset($_GET["userid"])?$_GET["userid"]:$_POST["userid"];
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'add' || $action == 'addproduct')
|
||||
if ($action == 'add' || $action == 'addproduct' || $action == 'update')
|
||||
{
|
||||
if ($_POST["cancel"])
|
||||
{
|
||||
$urlsource=(! empty($_GET["urlsource"]))?$_GET["urlsource"]:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/liste.php');
|
||||
$urlsource=(! empty($_REQUEST["urlsource"]))?urldecode($_REQUEST["urlsource"]):((! empty($url))?urldecode($url):DOL_URL_ROOT.'/bookmarks/liste.php');
|
||||
header("Location: ".$urlsource);
|
||||
exit;
|
||||
}
|
||||
|
|
@ -52,22 +53,25 @@ if ($action == 'add' || $action == 'addproduct')
|
|||
$mesg='';
|
||||
|
||||
$bookmark=new Bookmark($db);
|
||||
$bookmark->fk_user=$user->id;
|
||||
if ($action == 'update') $bookmark->fetch($_POST["id"]);
|
||||
$bookmark->fk_user=$userid;
|
||||
$bookmark->title=$title;
|
||||
$bookmark->url=$url;
|
||||
$bookmark->target=$target;
|
||||
|
||||
if (! $title) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle"));
|
||||
if (! $url) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink"));
|
||||
if (! $url) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink"));
|
||||
|
||||
if (! $mesg)
|
||||
{
|
||||
$bookmark->favicon='none';
|
||||
|
||||
$res=$bookmark->create();
|
||||
if ($action == 'update') $res=$bookmark->update();
|
||||
else $res=$bookmark->create();
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
$urlsource=isset($_GET["urlsource"])?$_GET["urlsource"]:DOL_URL_ROOT.'/bookmarks/liste.php';
|
||||
$urlsource=isset($_REQUEST["urlsource"])?urldecode($_REQUEST["urlsource"]):DOL_URL_ROOT.'/bookmarks/liste.php';
|
||||
header("Location: ".$urlsource);
|
||||
exit;
|
||||
}
|
||||
|
|
@ -90,7 +94,6 @@ if ($action == 'add' || $action == 'addproduct')
|
|||
$mesg='<div class="error">'.$mesg.'</div>';
|
||||
$action='create';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'delete')
|
||||
|
|
@ -140,12 +143,18 @@ if ($action == 'create')
|
|||
print '<table class="border" width="100%">';
|
||||
|
||||
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"));
|
||||
$liste=array(0=>$langs->trans("ReplaceWindow"),1=>$langs->trans("OpenANewWindow"));
|
||||
$html->select_array('target',$liste,1);
|
||||
print '</td><td>'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Owner").'</td><td>';
|
||||
$html->select_users(isset($_POST['userid'])?$_POST['userid']:$user->id,'userid',1);
|
||||
print '</td><td> </td></tr>';
|
||||
|
||||
print '<tr><td colspan="3" align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("CreateBookmark").'" name="create"> ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Cancel").'" name="cancel">';
|
||||
|
|
@ -160,7 +169,7 @@ if ($action == 'create')
|
|||
if ($_GET["id"] > 0 && ! eregi('^add',$_GET["action"]))
|
||||
{
|
||||
/*
|
||||
* Fiche bookmark en mode edition
|
||||
* Fiche bookmark en mode visu ou edition
|
||||
*/
|
||||
$bookmark=new Bookmark($db);
|
||||
$bookmark->fetch($_GET["id"]);
|
||||
|
|
@ -168,39 +177,86 @@ if ($_GET["id"] > 0 && ! eregi('^add',$_GET["action"]))
|
|||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Bookmark"));
|
||||
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form name="edit" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$bookmark->id.'">';
|
||||
print '<input type="hidden" name="urlsource" value="'.urlencode(DOL_URL_ROOT.'/bookmarks/fiche.php?id='.$bookmark->id).'">';
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
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("BookmarkTitle").'</td><td>';
|
||||
if ($_GET["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 '<a href="'.(eregi('^http',$bookmark->url)?$bookmark->url:DOL_URL_ROOT.$bookmark->url).'" target="'.($bookmark->target?"":"newlink").'">'.$bookmark->url.'</a></td></tr>';
|
||||
if ($_GET["action"] == 'edit') print '<input class="flat" name="url" size="80" value="'.(isset($_POST["url"])?$_POST["url"]:$bookmark->url).'">';
|
||||
else print '<a href="'.(eregi('^http',$bookmark->url)?$bookmark->url:DOL_URL_ROOT.$bookmark->url).'"'.($bookmark->target?' target="_blank"':'').'>'.$bookmark->url.'</a>';
|
||||
print '</td></tr>';
|
||||
|
||||
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)
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
$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");
|
||||
}
|
||||
$liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow"));
|
||||
$html->select_array('target',$liste,isset($_POST["target"])?$_POST["target"]:$bookmark->target);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($bookmark->target == 0) print $langs->trans("ReplaceWindow");
|
||||
if ($bookmark->target == 1) print $langs->trans("OpenANewWindow");
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Owner").'</td><td>';
|
||||
if ($_GET["action"] == 'edit' && $user->admin)
|
||||
{
|
||||
$html->select_users(isset($_POST['userid'])?$_POST['userid']:($bookmark->fk_user?$bookmark->fk_user:$user->id),'userid',1);
|
||||
}
|
||||
else
|
||||
{
|
||||
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>';
|
||||
|
||||
if ($_GET["action"] == 'edit') print '<tr><td colspan="2" align="center"><input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"> <input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
if ($_GET["action"] == 'edit') print '</form>';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
|
||||
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
|
||||
// Supprimer
|
||||
if ($user->rights->bookmark->supprimer)
|
||||
// Edit
|
||||
if ($user->rights->bookmark->creer && $_GET["action"] != 'edit')
|
||||
{
|
||||
print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?id=".$bookmark->id."&action=edit\">".$langs->trans("Edit")."</a>\n";
|
||||
}
|
||||
|
||||
// Remove
|
||||
if ($user->rights->bookmark->supprimer && $_GET["action"] != 'edit')
|
||||
{
|
||||
print " <a class=\"butActionDelete\" href=\"liste.php?bid=".$bookmark->id."&action=delete\">".$langs->trans("Delete")."</a>\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ if ($action == 'create')
|
|||
|
||||
if ($message) { print $message."<br>"; }
|
||||
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
|
@ -211,7 +211,7 @@ else
|
|||
* Affichage onglets
|
||||
*/
|
||||
$head = group_prepare_head($group);
|
||||
|
||||
|
||||
dolibarr_fiche_head($head, 'group', $langs->trans("Group").": ".$group->nom);
|
||||
|
||||
|
||||
|
|
@ -232,67 +232,67 @@ else
|
|||
if ($action != 'edit')
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
// Nom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
|
||||
print '<td width="75%" class="valeur">'.$group->nom.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
// Note
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
||||
print '<td class="valeur">'.nl2br($group->note).' </td>';
|
||||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$group->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
||||
}
|
||||
|
||||
|
||||
if ($candisableperms)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$group->id.'">'.$langs->trans("DeleteGroup").'</a>';
|
||||
}
|
||||
|
||||
|
||||
print "</div>\n";
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
|
||||
if ($message) { print $message."<br>"; }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Liste des utilisateurs dans le groupe
|
||||
*/
|
||||
|
||||
|
||||
print_fiche_titre($langs->trans("ListOfUsersInGroup"),'','');
|
||||
|
||||
|
||||
// On sélectionne les users qui ne sont pas déjà dans le groupe
|
||||
$uss = array();
|
||||
|
||||
|
||||
$sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.admin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
# $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
|
||||
# $sql .= " WHERE ug.fk_usergroup IS NULL";
|
||||
$sql .= " ORDER BY u.name";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
|
||||
$uss[$obj->rowid] = ucfirst(stripslashes($obj->name)).' '.ucfirst(stripslashes($obj->firstname));
|
||||
if ($obj->login) $uss[$obj->rowid].=' ('.$obj->login.')';
|
||||
$i++;
|
||||
|
|
@ -301,7 +301,7 @@ else
|
|||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
if ($caneditperms)
|
||||
{
|
||||
$form = new Form($db);
|
||||
|
|
@ -318,7 +318,7 @@ else
|
|||
print '</table></form>'."\n";
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Membres du groupe
|
||||
*/
|
||||
|
|
@ -328,13 +328,13 @@ else
|
|||
$sql.= " WHERE ug.fk_user = u.rowid";
|
||||
$sql.= " AND ug.fk_usergroup = ".$group->id;
|
||||
$sql.= " ORDER BY u.name";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" width="25%">'.$langs->trans("Login").'</td>';
|
||||
|
|
@ -348,7 +348,7 @@ else
|
|||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>';
|
||||
|
|
@ -357,10 +357,10 @@ else
|
|||
print '<td>'.ucfirst(stripslashes($obj->name)).'</td>';
|
||||
print '<td>'.ucfirst(stripslashes($obj->firstname)).'</td>';
|
||||
print '<td> </td><td>';
|
||||
|
||||
|
||||
if ($user->admin)
|
||||
{
|
||||
|
||||
|
||||
print '<a href="fiche.php?id='.$group->id.'&action=removeuser&user='.$obj->rowid.'">';
|
||||
print img_delete($langs->trans("RemoveFromGroup"));
|
||||
}
|
||||
|
|
@ -374,7 +374,7 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan=2>'.$langs->trans("None").'</td></tr>';
|
||||
print '<tr><td colspan=2>'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
|
|
@ -416,7 +416,7 @@ else
|
|||
print '<tr><td align="center" colspan="2"><input class="button" value="'.$langs->trans("Save").'" type="submit"></td></tr>';
|
||||
print "</table>\n";
|
||||
print '</form>';
|
||||
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user