Qual: Removed codesniffer errors

This commit is contained in:
Laurent Destailleur 2011-09-14 21:29:04 +00:00
parent 3e394189e7
commit 5a22b01468
4 changed files with 178 additions and 174 deletions

View File

@ -2,4 +2,8 @@ README (English)
-------------------------------- --------------------------------
This directory contains ruleset files to use to This directory contains ruleset files to use to
develop Dolibarr EPR & CRM with Eclipse. develop Dolibarr EPR & CRM with Eclipse.
Note: You must setup the PTI plugin of Eclipse into PHPCodeSniffer menu with:
* tab value to 4
* path of code sniffer standard to dev/codesniffer

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.org> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -28,7 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action=GETPOST("action"); $action=GETPOST("action");
@ -36,18 +36,18 @@ if ($action == 'setvalue')
{ {
$showmenu = GETPOST("BOOKMARKS_SHOW_IN_MENU"); $showmenu = GETPOST("BOOKMARKS_SHOW_IN_MENU");
$res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU",$showmenu,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU",$showmenu,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
if (! $error) if (! $error)
{ {
$db->commit(); $db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
} }
else else
{ {
$db->rollback(); $db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
} }
} }

View File

@ -24,11 +24,11 @@
/** /**
* Add area with bookmarks in menu * Add area with bookmarks in menu
* *
* @param DoliDb $aDb Database handler * @param DoliDb $aDb Database handler
* @param Translate $aLangs Object lang * @param Translate $aLangs Object lang
* @return string * @return string
*/ */
function printBookmarksList ($aDb, $aLangs) function printBookmarksList($aDb, $aLangs)
{ {
global $conf, $user; global $conf, $user;

View File

@ -45,76 +45,76 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
if ($_POST["cancel"]) if ($_POST["cancel"])
{ {
$urlsource=(! empty($_REQUEST["urlsource"]))?$_REQUEST["urlsource"]:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/liste.php'); $urlsource=(! empty($_REQUEST["urlsource"]))?$_REQUEST["urlsource"]:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/liste.php');
header("Location: ".$urlsource); header("Location: ".$urlsource);
exit; exit;
} }
$mesg=''; $mesg='';
$bookmark=new Bookmark($db); $bookmark=new Bookmark($db);
if ($action == 'update') $bookmark->fetch($_POST["id"]); if ($action == 'update') $bookmark->fetch($_POST["id"]);
$bookmark->fk_user=$userid; $bookmark->fk_user=$userid;
$bookmark->title=$title; $bookmark->title=$title;
$bookmark->url=$url; $bookmark->url=$url;
$bookmark->target=$target; $bookmark->target=$target;
$bookmark->position=$position; $bookmark->position=$position;
if (! $title) $mesg.=($mesg?'<br>':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")); 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) if (! $mesg)
{ {
$bookmark->favicon='none'; $bookmark->favicon='none';
if ($action == 'update') $res=$bookmark->update(); if ($action == 'update') $res=$bookmark->update();
else $res=$bookmark->create(); else $res=$bookmark->create();
if ($res > 0) if ($res > 0)
{ {
$urlsource=! empty($_REQUEST["urlsource"])?urldecode($_REQUEST["urlsource"]):DOL_URL_ROOT.'/bookmarks/liste.php'; $urlsource=! empty($_REQUEST["urlsource"])?urldecode($_REQUEST["urlsource"]):DOL_URL_ROOT.'/bookmarks/liste.php';
header("Location: ".$urlsource); header("Location: ".$urlsource);
exit; exit;
} }
else else
{ {
if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg='<div class="warning">'.$langs->trans("WarningBookmarkAlreadyExists").'</div>'; $mesg='<div class="warning">'.$langs->trans("WarningBookmarkAlreadyExists").'</div>';
} }
else else
{ {
$mesg='<div class="error">'.$bookmark->error.'</div>'; $mesg='<div class="error">'.$bookmark->error.'</div>';
} }
$action='create'; $action='create';
} }
} }
else else
{ {
$mesg='<div class="error">'.$mesg.'</div>'; $mesg='<div class="error">'.$mesg.'</div>';
$action='create'; $action='create';
} }
} }
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
$bookmark=new Bookmark($db); $bookmark=new Bookmark($db);
$bookmark->id=$_GET["bid"]; $bookmark->id=$_GET["bid"];
$bookmark->url=$user->id; $bookmark->url=$user->id;
$bookmark->target=$user->id; $bookmark->target=$user->id;
$bookmark->title='xxx'; $bookmark->title='xxx';
$bookmark->favicon='xxx'; $bookmark->favicon='xxx';
$res=$bookmark->remove(); $res=$bookmark->remove();
if ($res > 0) if ($res > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
else else
{ {
$mesg='<div class="error">'.$bookmark->error.'</div>'; $mesg='<div class="error">'.$bookmark->error.'</div>';
} }
} }
@ -129,154 +129,154 @@ $html=new Form($db);
if ($action == 'create') if ($action == 'create')
{ {
/* /*
* Fact bookmark creation mode * Fact bookmark creation mode
*/ */
print '<form action="fiche.php" method="post" enctype="multipart/form-data">'."\n"; print '<form action="fiche.php" method="post" enctype="multipart/form-data">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print_fiche_titre($langs->trans("NewBookmark")); print_fiche_titre($langs->trans("NewBookmark"));
if ($mesg) print "$mesg<br>"; if ($mesg) print "$mesg<br>";
print '<table class="border" width="100%">'; 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>'.$langs->trans("SetHereATitleForLink").'</td></tr>'; print '<tr><td width="25%" class="fieldrequired">'.$langs->trans("BookmarkTitle").'</td><td><input class="flat" name="title" size="30" value="'.$title.'"></td><td>'.$langs->trans("SetHereATitleForLink").'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("UrlOrLink").'</td><td><input class="flat" name="url" size="50" value="'.$url.'"></td><td>'.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'</td></tr>'; print '<tr><td class="fieldrequired">'.$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>'; print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
$liste=array(0=>$langs->trans("ReplaceWindow"),1=>$langs->trans("OpenANewWindow")); $liste=array(0=>$langs->trans("ReplaceWindow"),1=>$langs->trans("OpenANewWindow"));
print $html->selectarray('target',$liste,1); print $html->selectarray('target',$liste,1);
print '</td><td>'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</td></tr>'; print '</td><td>'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</td></tr>';
print '<tr><td>'.$langs->trans("Owner").'</td><td>'; print '<tr><td>'.$langs->trans("Owner").'</td><td>';
$html->select_users(isset($_POST['userid'])?$_POST['userid']:$user->id,'userid',1); $html->select_users(isset($_POST['userid'])?$_POST['userid']:$user->id,'userid',1);
print '</td><td>&nbsp;</td></tr>'; print '</td><td>&nbsp;</td></tr>';
// Position // Position
print '<tr><td>'.$langs->trans("Position").'</td><td>'; print '<tr><td>'.$langs->trans("Position").'</td><td>';
print '<input class="flat" name="position" size="5" value="'.(isset($_POST["position"])?$_POST["position"]:$bookmark->position).'">'; print '<input class="flat" name="position" size="5" value="'.(isset($_POST["position"])?$_POST["position"]:$bookmark->position).'">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td colspan="3" align="center">'; print '<tr><td colspan="3" align="center">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateBookmark").'" name="create"> &nbsp; '; print '<input type="submit" class="button" value="'.$langs->trans("CreateBookmark").'" name="create"> &nbsp; ';
print '<input type="submit" class="button" value="'.$langs->trans("Cancel").'" name="cancel">'; print '<input type="submit" class="button" value="'.$langs->trans("Cancel").'" name="cancel">';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} }
if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"]))
{ {
/* /*
* Fact bookmark mode or visually edition * Fact bookmark mode or visually edition
*/ */
$bookmark=new Bookmark($db); $bookmark=new Bookmark($db);
$bookmark->fetch($_GET["id"]); $bookmark->fetch($_GET["id"]);
dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark'); dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark');
if ($_GET["action"] == 'edit') if ($_GET["action"] == 'edit')
{ {
print '<form name="edit" method="POST" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data">'; print '<form name="edit" method="POST" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$bookmark->id.'">'; print '<input type="hidden" name="id" value="'.$bookmark->id.'">';
print '<input type="hidden" name="urlsource" value="'.DOL_URL_ROOT.'/bookmarks/fiche.php?id='.$bookmark->id.'">'; print '<input type="hidden" name="urlsource" value="'.DOL_URL_ROOT.'/bookmarks/fiche.php?id='.$bookmark->id.'">';
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'.$bookmark->ref.'</td></tr>'; 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>'.$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).'">'; if ($_GET["action"] == 'edit') print '<input class="flat" name="title" size="30" value="'.(isset($_POST["title"])?$_POST["title"]:$bookmark->title).'">';
else print $bookmark->title; else print $bookmark->title;
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("UrlOrLink").'</td><td>'; print '<tr><td>'.$langs->trans("UrlOrLink").'</td><td>';
if ($_GET["action"] == 'edit') print '<input class="flat" name="url" size="80" value="'.(isset($_POST["url"])?$_POST["url"]:$bookmark->url).'">'; if ($_GET["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>'; 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>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>'; print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
if ($_GET["action"] == 'edit') if ($_GET["action"] == 'edit')
{ {
$liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow")); $liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow"));
print $html->selectarray('target',$liste,isset($_POST["target"])?$_POST["target"]:$bookmark->target); print $html->selectarray('target',$liste,isset($_POST["target"])?$_POST["target"]:$bookmark->target);
} }
else else
{ {
if ($bookmark->target == 0) print $langs->trans("ReplaceWindow"); if ($bookmark->target == 0) print $langs->trans("ReplaceWindow");
if ($bookmark->target == 1) print $langs->trans("OpenANewWindow"); if ($bookmark->target == 1) print $langs->trans("OpenANewWindow");
} }
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Owner").'</td><td>'; print '<tr><td>'.$langs->trans("Owner").'</td><td>';
if ($_GET["action"] == 'edit' && $user->admin) if ($_GET["action"] == 'edit' && $user->admin)
{ {
$html->select_users(isset($_POST['userid'])?$_POST['userid']:($bookmark->fk_user?$bookmark->fk_user:''),'userid',1); $html->select_users(isset($_POST['userid'])?$_POST['userid']:($bookmark->fk_user?$bookmark->fk_user:''),'userid',1);
} }
else else
{ {
if ($bookmark->fk_user) if ($bookmark->fk_user)
{ {
$fuser=new User($db); $fuser=new User($db);
$fuser->fetch($bookmark->fk_user); $fuser->fetch($bookmark->fk_user);
//$fuser->nom=$fuser->login; $fuser->prenom=''; //$fuser->nom=$fuser->login; $fuser->prenom='';
print $fuser->getNomUrl(1); print $fuser->getNomUrl(1);
} }
else else
{ {
print $langs->trans("Public"); print $langs->trans("Public");
} }
} }
print '</td></tr>'; print '</td></tr>';
// Position // Position
print '<tr><td>'.$langs->trans("Position").'</td><td>'; print '<tr><td>'.$langs->trans("Position").'</td><td>';
if ($_GET["action"] == 'edit') print '<input class="flat" name="position" size="5" value="'.(isset($_POST["position"])?$_POST["position"]:$bookmark->position).'">'; if ($_GET["action"] == 'edit') print '<input class="flat" name="position" size="5" value="'.(isset($_POST["position"])?$_POST["position"]:$bookmark->position).'">';
else print $bookmark->position; else print $bookmark->position;
print '</td></tr>'; print '</td></tr>';
// Date creation // Date creation
print '<tr><td>'.$langs->trans("DateCreation").'</td><td>'.dol_print_date($bookmark->datec,'dayhour').'</td></tr>'; print '<tr><td>'.$langs->trans("DateCreation").'</td><td>'.dol_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").'"> &nbsp; &nbsp; <input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; if ($_GET["action"] == 'edit') print '<tr><td colspan="2" align="center"><input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; <input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>'; print '</table>';
if ($_GET["action"] == 'edit') print '</form>'; if ($_GET["action"] == 'edit') print '</form>';
print "</div>\n"; print "</div>\n";
print "<div class=\"tabsAction\">\n"; print "<div class=\"tabsAction\">\n";
// Edit // Edit
if ($user->rights->bookmark->creer && $_GET["action"] != 'edit') if ($user->rights->bookmark->creer && $_GET["action"] != 'edit')
{ {
print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?id=".$bookmark->id."&amp;action=edit\">".$langs->trans("Edit")."</a>\n"; print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?id=".$bookmark->id."&amp;action=edit\">".$langs->trans("Edit")."</a>\n";
} }
// Remove // Remove
if ($user->rights->bookmark->supprimer && $_GET["action"] != 'edit') if ($user->rights->bookmark->supprimer && $_GET["action"] != 'edit')
{ {
print " <a class=\"butActionDelete\" href=\"liste.php?bid=".$bookmark->id."&amp;action=delete\">".$langs->trans("Delete")."</a>\n"; print " <a class=\"butActionDelete\" href=\"liste.php?bid=".$bookmark->id."&amp;action=delete\">".$langs->trans("Delete")."</a>\n";
} }
print '</div>'; print '</div>';
} }