Skip to content

Commit

Permalink
Qual: Removed useless function
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 5, 2014
1 parent b4bffb9 commit fa82cbc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 54 deletions.
37 changes: 18 additions & 19 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -3383,33 +3383,32 @@ function __clone()

/**
* Call trigger based on this instance
*
* NB: Error from trigger are stacked in errors
* NB2: if trigger fail, action should be canceled.
* NB: Error from trigger are stacked in interface->errors
* NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction.
*
* @param string $trigger_name trigger's name to execute
* @param User $user Object user
* @return int Result of run_triggers
*/
function call_trigger($trigger_name, $user)
{
global $langs,$conf;

include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
if ($result < 0) {
if (!empty($this->errors))
{
$this->errors=array_merge($this->errors,$interface->errors);
}
else
{
$this->errors=$interface->errors;
}
}
return $result;
global $langs,$conf;

include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
if ($result < 0)
{
if (!empty($this->errors))
{
$this->errors=array_merge($this->errors,$interface->errors);
}
else
{
$this->errors=$interface->errors;
}
}
return $result;
}

}
51 changes: 16 additions & 35 deletions htdocs/user/class/user.class.php
Expand Up @@ -667,7 +667,7 @@ function setstatus($statut)
{
// Call trigger
$result=$this->call_trigger('USER_ENABLEDISABLE',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}

Expand Down Expand Up @@ -756,14 +756,14 @@ function delete()
{
// Call trigger
$result=$this->call_trigger('USER_DELETE',$user);
if ($result < 0)
{
if ($result < 0)
{
$error++;
$this->db->rollback();
return -1;
}
return -1;
}
// End call triggers

$this->db->commit();
return 1;
}
Expand Down Expand Up @@ -866,7 +866,7 @@ function create($user,$notrigger=0)
{
// Call trigger
$result=$this->call_trigger('USER_CREATE',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}

Expand Down Expand Up @@ -949,9 +949,9 @@ function create_from_contact($contact,$login='',$password='')
{
// Call trigger
$result=$this->call_trigger('USER_CREATE_FROM_CONTACT',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers

$this->db->commit();
return $this->id;
}
Expand Down Expand Up @@ -1261,7 +1261,7 @@ function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0)
{
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}

Expand Down Expand Up @@ -1352,7 +1352,7 @@ function setPassword($user, $password='', $changelater=0, $notrigger=0, $nosyncm
if (! is_object($this->oldcopy)) $this->oldcopy=dol_clone($this);

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET pass_crypted = '".$this->db->escape($password_crypted)."',";
$sql.= " pass_temp = null";
Expand Down Expand Up @@ -1408,10 +1408,10 @@ function setPassword($user, $password='', $changelater=0, $notrigger=0, $nosyncm
{
// Call trigger
$result=$this->call_trigger('USER_NEW_PASSWORD',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
}

$this->db->commit();
return $this->pass;
}
Expand Down Expand Up @@ -1666,7 +1666,7 @@ function SetInGroup($group, $entity, $notrigger=0)

// Call trigger
$result=$this->call_trigger('USER_SETINGROUP',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}

Expand Down Expand Up @@ -1720,7 +1720,7 @@ function RemoveFromGroup($group, $entity, $notrigger=0)

// Call trigger
$result=$this->call_trigger('USER_REMOVEFROMGROUP',$user);
if ($result < 0) { $error++; }
if ($result < 0) { $error++; }
// End call triggers
}

Expand Down Expand Up @@ -2281,7 +2281,7 @@ function get_full_tree($markafterid=0)
dol_syslog(get_class($this)."::get_full_tree dol_sort_array", LOG_DEBUG);
$this->users=dol_sort_array($this->users, 'fullname', 'asc', true, false);

//$this->debug_users();
//var_dump($this->users);

return $this->users;
}
Expand Down Expand Up @@ -2322,24 +2322,5 @@ function build_path_from_id_user($id_user,$protection=1000)
return;
}

/**
* Affiche contenu de $this->users
*
* @return void
*/
function debug_users()
{
// Affiche $this->users
foreach($this->users as $key => $val)
{
print 'id: '.$this->users[$key]['id'];
print ' name: '.$this->users[$key]['name'];
print ' parent: '.$this->users[$key]['fk_user'];
print ' fullpath: '.$this->users[$key]['fullpath'];
print ' fullname: '.$this->users[$key]['fullname'];
print "<br>\n";
}
}

}

0 comments on commit fa82cbc

Please sign in to comment.