Merge pull request #2456 from marcosgdf/refactor-1

Refactor 1
This commit is contained in:
Laurent Destailleur
2015-03-22 12:47:05 +01:00
20 changed files with 449 additions and 208 deletions

View File

@@ -2685,10 +2685,9 @@ abstract class CommonObject
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param int $dateSelector 1=Show also date range input fields
* @param int $permtoedit Permission to edit line
* @return void
*/
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $permtoedit=0)
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
{
global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user;
@@ -2781,7 +2780,7 @@ abstract class CommonObject
}
else
{
$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline,$permtoedit);
$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline);
}
$i++;
@@ -2793,7 +2792,7 @@ abstract class CommonObject
* TODO Move this into an output class file (htmlline.class.php)
*
* @param string $action GET/POST action
* @param array $line Selected object line to output
* @param CommonObjectLine $line Selected object line to output
* @param string $var Is it a an odd line (true)
* @param int $num Number of line (0)
* @param int $i I
@@ -2802,13 +2801,14 @@ abstract class CommonObject
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param object $extrafieldsline Object of extrafield line attribute
* @param int $permtoedit Permission to edit
* @return void
*/
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0,$permtoedit=0)
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
{
global $conf,$langs,$user,$object,$hookmanager;
global $form,$bc,$bcdd;
global $form,$bc,$bcdd, $object_rights;
$object_rights = $this->getRights();
$element=$this->element;
@@ -2821,7 +2821,7 @@ abstract class CommonObject
if (! empty($line->date_end)) $type=1; // deprecated
// Ligne en mode visu
if ($action != 'editline' || $selected != $line->id)
if ($action != 'editline' || $selected != $line->rowid)
{
// Product
if ($line->fk_product > 0)
@@ -2879,7 +2879,7 @@ abstract class CommonObject
}
// Ligne en mode update
if ($this->statut == 0 && $action == 'editline' && $selected == $line->id)
if ($this->statut == 0 && $action == 'editline' && $selected == $line->rowid)
{
$label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : ''));
if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"';
@@ -3883,4 +3883,16 @@ abstract class CommonObject
return $out;
}
/**
* Returns the rights used for this class
* @return stdClass
*/
public function getRights()
{
global $user;
return $user->rights->{$this->element};
}
}