Clean deprecated code.

This commit is contained in:
Laurent Destailleur 2014-10-11 15:04:42 +02:00
parent 0dc82cddf1
commit cd8936a224
7 changed files with 41 additions and 62 deletions

View File

@ -218,13 +218,7 @@ if ($action == 'add')
{ {
if ($i == 0) // First entry if ($i == 0) // First entry
{ {
$usertodo=new User($db); if ($value['id'] > 0) $usertodo->fetch($value['id']);
if ($value['id'] > 0)
{
$usertodo->fetch($value['id']);
$object->userownerid = $usertodo->id;
}
$object->usertodo = $usertodo;
$object->transparency = (GETPOST("transparency")=='on'?1:0); $object->transparency = (GETPOST("transparency")=='on'?1:0);
} }
@ -236,13 +230,7 @@ if ($action == 'add')
if (! $error && ! empty($conf->global->AGENDA_ENABLE_DONEBY)) if (! $error && ! empty($conf->global->AGENDA_ENABLE_DONEBY))
{ {
$userdone=new User($db); if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby","int");
if ($_POST["doneby"] > 0)
{
$userdone->fetch($_POST["doneby"]);
$object->userdoneid = $userdone->id;
}
$object->userdone = $userdone;
} }
$object->note = trim($_POST["note"]); $object->note = trim($_POST["note"]);
@ -263,7 +251,7 @@ if ($action == 'add')
if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $object->use_phenix=1; if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $object->use_phenix=1;
// Check parameters // Check parameters
if (empty($object->usertodo)) if (empty($object->userownerid))
{ {
$error++; $donotclearsession=1; $error++; $donotclearsession=1;
$action = 'create'; $action = 'create';
@ -409,12 +397,7 @@ if ($action == 'update')
if (! empty($conf->global->AGENDA_ENABLE_DONEBY)) if (! empty($conf->global->AGENDA_ENABLE_DONEBY))
{ {
$userdone=new User($db); if (GETPOST("doneby")) $object->userdoneid=GETPOST("doneby","int");
if ($_POST["doneby"])
{
$userdone->fetch($_POST["doneby"]);
}
$object->userdone = $userdone;
} }
// Check parameters // Check parameters
@ -428,7 +411,7 @@ if ($action == 'update')
{ {
$result=$cactioncomm->fetch(GETPOST('actioncode')); $result=$cactioncomm->fetch(GETPOST('actioncode'));
} }
if (empty($object->usertodo)) if (empty($object->userownerid))
{ {
$error++; $donotclearsession=1; $error++; $donotclearsession=1;
$action = 'edit'; $action = 'edit';
@ -812,9 +795,6 @@ if ($id > 0)
if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; } if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; }
if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; } if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; }
if ($object->userownerid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->userownerid); $object->usertodo=$tmpuser; }
if ($object->userdoneid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->userdoneid); $object->userdone=$tmpuser; }
/* /*
* Show tabs * Show tabs
@ -1088,7 +1068,7 @@ if ($id > 0)
$listofuserid=array(); $listofuserid=array();
if (empty($donotclearsession)) if (empty($donotclearsession))
{ {
if (is_object($object->usertodo)) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first if (is_object($object->userownerid)) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first
if (! empty($object->userassigned)) // Now concat assigned users if (! empty($object->userassigned)) // Now concat assigned users
{ {
// Restore array with key with same value than param 'id' // Restore array with key with same value than param 'id'
@ -1115,7 +1095,12 @@ if ($id > 0)
if ($conf->global->AGENDA_ENABLE_DONEBY) if ($conf->global->AGENDA_ENABLE_DONEBY)
{ {
print '<tr><td class="nowrap">'.$langs->trans("ActionDoneBy").'</td><td colspan="3">'; print '<tr><td class="nowrap">'.$langs->trans("ActionDoneBy").'</td><td colspan="3">';
if ($object->userdoneid > 0) print $object->userdone->getNomUrl(1); if ($object->userdoneid > 0)
{
$tmpuser=new User($db);
$tmpuser->fetch($object->userdoneid);
print $tmpuser->getNomUrl(1);
}
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -99,10 +99,6 @@ class ActionComm extends CommonObject
$this->db = $db; $this->db = $db;
//$this->author = new stdClass();
//$this->usermod = new stdClass();
//$this->usertodo = new stdClass();
//$this->userdone = new stdClass();
$this->societe = new stdClass(); // deprecated $this->societe = new stdClass(); // deprecated
$this->contact = new stdClass(); // deprecated $this->contact = new stdClass(); // deprecated
} }
@ -142,8 +138,8 @@ class ActionComm extends CommonObject
if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='commande') $this->elementtype='order';
if ($this->elementtype=='contrat') $this->elementtype='contract'; if ($this->elementtype=='contrat') $this->elementtype='contract';
$userownerid=isset($this->usertodo->id)?$this->usertodo->id:$this->userownerid; // For backward compatibility $userownerid=$this->userownerid;
$userdoneid=isset($this->userdone->id)?$this->userdone->id:$this->userdoneid; // For backward compatibility $userdoneid=$this->userdoneid;
if (! $this->type_id || ! $this->type_code) if (! $this->type_id || ! $this->type_code)
{ {
@ -371,10 +367,6 @@ class ActionComm extends CommonObject
$this->userownerid = $obj->fk_user_action; $this->userownerid = $obj->fk_user_action;
$this->userdoneid = $obj->fk_user_done; $this->userdoneid = $obj->fk_user_done;
if (!is_object($this->usertodo)) $this->usertodo = new stdClass(); // For avoid warning
$this->usertodo->id = $obj->fk_user_action; // deprecated
if (!is_object($this->userdone)) $this->userdone = new stdClass(); // For avoid warning
$this->userdone->id = $obj->fk_user_done; // deprecated
$this->priority = $obj->priority; $this->priority = $obj->priority;
$this->fulldayevent = $obj->fulldayevent; $this->fulldayevent = $obj->fulldayevent;
$this->location = $obj->location; $this->location = $obj->location;
@ -530,7 +522,7 @@ class ActionComm extends CommonObject
if ($this->fk_project < 0) $this->fk_project = 0; if ($this->fk_project < 0) $this->fk_project = 0;
// Check parameters // Check parameters
if ($this->percentage == 0 && $this->userdone->id > 0) if ($this->percentage == 0 && $this->userdoneid > 0)
{ {
$this->error="ErrorCantSaveADoneUserWithZeroPercentage"; $this->error="ErrorCantSaveADoneUserWithZeroPercentage";
return -1; return -1;
@ -538,8 +530,8 @@ class ActionComm extends CommonObject
$socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0)); $socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0));
$contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0)); $contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0));
$userownerid=($this->userownerid?$this->userownerid:((isset($this->usertodo->id) && $this->usertodo->id > 0) ? $this->usertodo->id : 0)); $userownerid=($this->userownerid?$this->userownerid:0);
$userdoneid=($this->userdoneid?$this->userdoneid:((isset($this->userdone->id) && $this->userdone->id > 0) ? $this->userdone->id : 0)); $userdoneid=($this->userdoneid?$this->userdoneid:0);
$this->db->begin(); $this->db->begin();

View File

@ -100,8 +100,7 @@ if ($object->id > 0)
$author->fetch($object->author->id); $author->fetch($object->author->id);
$object->author=$author; $object->author=$author;
if ($object->contact->id > 0) $object->fetch_contact($object->contact->id); $object->fetch_contact();
if ($object->usertodo->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usertodo->id); $object->usertodo=$tmpuser; }
$head=actions_prepare_head($object); $head=actions_prepare_head($object);
@ -195,7 +194,11 @@ if ($object->id > 0)
// Assigned to // Assigned to
print '<tr><td width="30%" class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>'; print '<tr><td width="30%" class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td>';
if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1); if ($object->userownerid > 0)
{
$tmpuser=new User($object->userownerid);
print $tmpuser->getNomUrl(1);
}
print '</td></tr>'; print '</td></tr>';
print '</table><br><br><table class="border" width="100%">'; print '</table><br><br><table class="border" width="100%">';

View File

@ -491,12 +491,9 @@ if ($resql)
$event->type_code=$obj->code; $event->type_code=$obj->code;
$event->libelle=$obj->label; $event->libelle=$obj->label;
$event->percentage=$obj->percent; $event->percentage=$obj->percent;
//$event->author->id=$obj->fk_user_author; // user id of creator
$event->authorid=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator
$event->userownerid=$obj->fk_user_action; // user id of owner $event->userownerid=$obj->fk_user_action; // user id of owner
$event->fetch_userassigned(); // This load $event->userassigned $event->fetch_userassigned(); // This load $event->userassigned
//$event->usertodo->id=$obj->fk_user_action; // user id of owner
//$event->userdone->id=$obj->fk_user_done; // deprecated
$event->priority=$obj->priority; $event->priority=$obj->priority;
$event->fulldayevent=$obj->fulldayevent; $event->fulldayevent=$obj->fulldayevent;
$event->location=$obj->location; $event->location=$obj->location;

View File

@ -409,7 +409,6 @@ if ($resql)
$event->authorid=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator
$event->userownerid=$obj->fk_user_action; // user id of owner $event->userownerid=$obj->fk_user_action; // user id of owner
$event->fetch_userassigned(); // This load $event->userassigned $event->fetch_userassigned(); // This load $event->userassigned
//$event->userdone->id=$obj->fk_user_done; // deprecated
$event->priority=$obj->priority; $event->priority=$obj->priority;
$event->fulldayevent=$obj->fulldayevent; $event->fulldayevent=$obj->fulldayevent;
$event->location=$obj->location; $event->location=$obj->location;

View File

@ -580,11 +580,14 @@ class InterfaceActionsAuto extends DolibarrTriggers
$actioncomm->durationp = 0; $actioncomm->durationp = 0;
$actioncomm->punctual = 1; $actioncomm->punctual = 1;
$actioncomm->percentage = -1; // Not applicable $actioncomm->percentage = -1; // Not applicable
$actioncomm->contact = $contactforaction;
$actioncomm->societe = $societeforaction; $actioncomm->societe = $societeforaction;
$actioncomm->author = $user; // User saving action $actioncomm->contact = $contactforaction;
$actioncomm->usertodo = $user; // User action is assigned to (owner of action) $actioncomm->socid = $societeforaction->id;
//$actioncomm->userdone = $user; // User doing action (deprecated, not used anymore) $actioncomm->contactid = $contactforaction->id;
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
//$actioncomm->userdone = $user; // User doing action (not used anymore)
//$actioncomm->userdoneid = $user->id; // User doing action (not used anymore)
$actioncomm->fk_element = $object->id; $actioncomm->fk_element = $object->id;
$actioncomm->elementtype = $object->element; $actioncomm->elementtype = $object->element;

View File

@ -289,15 +289,15 @@ function getActionComm($authentication,$id)
'datem'=> dol_print_date($actioncomm->datem,'dayhourrfc'), 'datem'=> dol_print_date($actioncomm->datem,'dayhourrfc'),
'note'=> $actioncomm->note, 'note'=> $actioncomm->note,
'percentage'=> $actioncomm->percentage, 'percentage'=> $actioncomm->percentage,
'author'=> $actioncomm->author->id, 'author'=> $actioncomm->authorid,
'usermod'=> $actioncomm->usermod->id, 'usermod'=> $actioncomm->usermodid,
'usertodo'=> $actioncomm->usertodo->id, 'usertodo'=> $actioncomm->userownerid,
'userdone'=> $actioncomm->userdone->id, 'userdone'=> $actioncomm->userdoneid,
'priority'=> $actioncomm->priority, 'priority'=> $actioncomm->priority,
'fulldayevent'=> $actioncomm->fulldayevent, 'fulldayevent'=> $actioncomm->fulldayevent,
'location'=> $actioncomm->location, 'location'=> $actioncomm->location,
'socid'=> $actioncomm->societe->id, 'socid'=> $actioncomm->socid,
'contactid'=> $actioncomm->contact->id, 'contactid'=> $actioncomm->contactid,
'projectid'=> $actioncomm->fk_project, 'projectid'=> $actioncomm->fk_project,
'fk_element'=> $actioncomm->fk_element, 'fk_element'=> $actioncomm->fk_element,
'elementtype'=> $actioncomm->elementtype); 'elementtype'=> $actioncomm->elementtype);
@ -437,8 +437,8 @@ function createActionComm($authentication,$actioncomm)
$newobject->fk_project=$actioncomm['projectid']; $newobject->fk_project=$actioncomm['projectid'];
$newobject->note=$actioncomm['note']; $newobject->note=$actioncomm['note'];
$newobject->contactid=$actioncomm['contactid']; $newobject->contactid=$actioncomm['contactid'];
$newobject->usertodo->id=$actioncomm['usertodo']; $newobject->userownerid=$actioncomm['usertodo'];
$newobject->userdone->id=$actioncomm['userdone']; $newobject->userdoneid=$actioncomm['userdone'];
$newobject->label=$actioncomm['label']; $newobject->label=$actioncomm['label'];
$newobject->percentage=$actioncomm['percentage']; $newobject->percentage=$actioncomm['percentage'];
$newobject->priority=$actioncomm['priority']; $newobject->priority=$actioncomm['priority'];
@ -532,8 +532,8 @@ function updateActionComm($authentication,$actioncomm)
$object->contactid=$actioncomm['contactid']; $object->contactid=$actioncomm['contactid'];
$object->fk_project=$actioncomm['projectid']; $object->fk_project=$actioncomm['projectid'];
$object->note=$actioncomm['note']; $object->note=$actioncomm['note'];
$object->usertodo->id=$actioncomm['usertodo']; $object->userownerid=$actioncomm['usertodo'];
$object->userdone->id=$actioncomm['userdone']; $object->userdoneid=$actioncomm['userdone'];
$object->label=$actioncomm['label']; $object->label=$actioncomm['label'];
$object->percentage=$actioncomm['percentage']; $object->percentage=$actioncomm['percentage'];
$object->priority=$actioncomm['priority']; $object->priority=$actioncomm['priority'];