diff --git a/htdocs/bookmarks/bookmark.class.php b/htdocs/bookmarks/bookmark.class.php index 2a8453d6057..2d8a2b30af9 100644 --- a/htdocs/bookmarks/bookmark.class.php +++ b/htdocs/bookmarks/bookmark.class.php @@ -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; } diff --git a/htdocs/bookmarks/fiche.php b/htdocs/bookmarks/fiche.php index 8ae0fbafdfc..b7d2c8073dc 100644 --- a/htdocs/bookmarks/fiche.php +++ b/htdocs/bookmarks/fiche.php @@ -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?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")); - if (! $url) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink")); + if (! $url) $mesg.=($mesg?'
':'').$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='
'.$mesg.'
'; $action='create'; } - } if ($_GET["action"] == 'delete') @@ -140,12 +143,18 @@ if ($action == 'create') print ''; print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("BookmarkTitle").''.$langs->trans("SetHereATitleForLink").'
'.$langs->trans("UrlOrLink").''.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'
'.$langs->trans("BehaviourOnClick").''; - $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 ''.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'
'.$langs->trans("Owner").''; + $html->select_users(isset($_POST['userid'])?$_POST['userid']:$user->id,'userid',1); + print ' 
'; print '   '; print ''; @@ -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 '
'; + print ''; + print ''; + print ''; + } + print ''; print ''; - print ''; + + print ''; + print ''; + if ($_GET["action"] == 'edit') print 'url).'">'; + else print 'target?' target="_blank"':'').'>'.$bookmark->url.''; + print ''; + print ''; - print ''; + + print ''; + print ''; + + if ($_GET["action"] == 'edit') print ''; + + print '
'.$langs->trans("Ref").''.$bookmark->ref.'
'.$langs->trans("BookmarkTitle").''.$bookmark->title.'
'.$langs->trans("BookmarkTitle").''; + if ($_GET["action"] == 'edit') print 'title).'">'; + else print $bookmark->title; + print '
'.$langs->trans("UrlOrLink").''; - print ''.$bookmark->url.'
'.$langs->trans("BehaviourOnClick").''; - if ($bookmark->target == 0) print $langs->trans("OpenANewWindow"); - if ($bookmark->target == 1) print $langs->trans("ReplaceWindow"); - print '
'.$langs->trans("Owner").''; - 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 '
'.$langs->trans("Owner").''; + 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 '
'.$langs->trans("DateCreation").''.dolibarr_print_date($bookmark->datec,'dayhour').'
   
'; + if ($_GET["action"] == 'edit') print '
'; + print "\n"; + + print "
\n"; - // Supprimer - if ($user->rights->bookmark->supprimer) + // Edit + if ($user->rights->bookmark->creer && $_GET["action"] != 'edit') + { + print " id."&action=edit\">".$langs->trans("Edit")."\n"; + } + + // Remove + if ($user->rights->bookmark->supprimer && $_GET["action"] != 'edit') { print " id."&action=delete\">".$langs->trans("Delete")."\n"; } diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 8108ee698d6..7454e2c4750 100644 --- a/htdocs/user/group/fiche.php +++ b/htdocs/user/group/fiche.php @@ -167,7 +167,7 @@ if ($action == 'create') if ($message) { print $message."
"; } - print '
'; + print ''; print ''; print ''; @@ -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 '
'; - + // Nom print ''; print ''; print "\n"; - + // Note print ''; print ''; print "\n"; print "
'.$langs->trans("Name").''.$group->nom.'
'.$langs->trans("Note").''.nl2br($group->note).' 
\n"; - + print '
'; - + /* * Barre d'actions */ print '
'; - + if ($caneditperms) { print ''.$langs->trans("Modify").''; } - + if ($candisableperms) { print ''.$langs->trans("DeleteGroup").''; } - + print "
\n"; print "
\n"; - + if ($message) { print $message."
"; } - + /* * 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 '
'."\n"; print '
'; } - + /* * 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 ''; print ''; print ''; @@ -348,7 +348,7 @@ else { $obj = $db->fetch_object($result); $var=!$var; - + print ""; print ''; print ''; print ''; + print ''; } print "
'.$langs->trans("Login").'
'; print ''.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.''; @@ -357,10 +357,10 @@ else print ''.ucfirst(stripslashes($obj->name)).''.ucfirst(stripslashes($obj->firstname)).' '; - + if ($user->admin) { - + print ''; print img_delete($langs->trans("RemoveFromGroup")); } @@ -374,7 +374,7 @@ else } else { - print '
'.$langs->trans("None").'
'.$langs->trans("None").'
"; print "
"; @@ -416,7 +416,7 @@ else print ''; print "\n"; print ''; - + print ''; }