Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-maxime committed Jul 6, 2014
2 parents 0c99e1d + 823e976 commit 9ed659f
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 97 deletions.
6 changes: 5 additions & 1 deletion ChangeLog
Expand Up @@ -23,14 +23,18 @@ For users:
- Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action
- Fix: [ bug #1505, #1504] Project trigger problem


For translators:
- Update language files.

For developers:
- New: Add hook "searchAgendaFrom".
- New: Add trigger DON_UPDATE, DON_DELETE

WARNING: Following change may create regression for some external modules, but was necessary to make
Dolibarr better:

- Change the way parameters are provides to scripts sync_xxx_ldap2dolibarr.php


***** ChangeLog for 3.6 compared to 3.5.* *****
For users:
Expand Down
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;
}

}
31 changes: 15 additions & 16 deletions htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
Expand Up @@ -293,29 +293,28 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
// setVars failed, probably because key not found
}
}


// Replace tags of lines for contacts
$contact_arrray=array();

$sql = "SELECT p.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$object->id;

dol_syslog('doc_generic_odt ::', LOG_DEBUG);

$result = $this->db->query($sql);
$num = $this->db->num_rows($result);

$var=true;
if ($num)
{
$i=0;
$contactstatic = new Contact($this->db);

while($i < $num)
{
$obj = $this->db->fetch_object($result);

$contact_arrray[$i] = $obj->rowid;
$i++;
}
Expand All @@ -325,7 +324,7 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
try
{
$listlines = $odfHandler->setSegment('companycontacts');

foreach($contact_arrray as $array_key => $contact_id)
{
$res_contact = $contactstatic->fetch($contact_id);
Expand Down Expand Up @@ -354,11 +353,16 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
//return -1;
}
}


// Make substitutions into odt of thirdparty + external modules
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);

// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
//var_dump($object->id); exit;

// Replace variables into document
foreach($tmparray as $key=>$value)
{
try {
Expand Down Expand Up @@ -389,11 +393,6 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
{
}
}


// Make substitutions into odt of thirdparty + external modules
$tmparray=$this->get_substitutionarray_thirdparty($object,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);

// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
Expand Down
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";
}
}

}

1 change: 1 addition & 0 deletions scripts/members/sync_members_dolibarr2ldap.php
Expand Up @@ -82,6 +82,7 @@
$input = trim(fgets(STDIN));
print "Warning, this operation may result in data loss if it failed.\n";
print "Be sure to have a backup of your LDAP database (With OpenLDAP: slapcat > save.ldif).\n";

print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));

Expand Down
15 changes: 7 additions & 8 deletions scripts/members/sync_members_ldap2dolibarr.php
Expand Up @@ -93,16 +93,17 @@
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));


if ($argv[3]) $conf->global->LDAP_SERVER_HOST=$argv[2];

print "***** $script_file ($version) *****\n";

if (! isset($argv[2]) || ! is_numeric($argv[2])) {
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [ldapserverhost]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost]\n";
exit(-1);
}

$typeid=$argv[2];
if ($argv[1] == 'commitiferror') $forcecommit=1;
foreach($argv as $key => $val)
{
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
}

print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
Expand Down Expand Up @@ -138,8 +139,6 @@
}


print "Press a key to confirm...";
$input = trim(fgets(STDIN));
print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));

Expand Down
16 changes: 8 additions & 8 deletions scripts/user/sync_groups_ldap2dolibarr.php
Expand Up @@ -70,18 +70,19 @@
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));

if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2];

print "***** $script_file ($version) *****\n";

if (! isset($argv[1])) {
//print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [ldapserverhost]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...]\n";
exit(-1);
}
$groupid=$argv[3];
if ($argv[1] == 'commitiferror') $forcecommit=1;

foreach($argv as $key => $val)
{
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
}

print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
Expand All @@ -103,8 +104,7 @@
print "commitiferror=".$forcecommit."\n";
print "Mapped LDAP fields=".join(',',$required_fields)."\n";
print "\n";
print "Press a key to confirm...";
$input = trim(fgets(STDIN));

print "Hit Enter to continue or CTRL+C to stop...\n";
$input = trim(fgets(STDIN));

Expand Down

0 comments on commit 9ed659f

Please sign in to comment.