diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 0cb132d23c6..26d54111098 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -221,14 +221,16 @@ abstract class CommonObject
* @param int $rowid Id of line contact-element
* @param int $statut New status of link
* @param int $type_contact_id Id of contact type (not modified if 0)
+ * @param int $fk_socpeople Id of soc_people to update (not modified if 0)
* @return int <0 if KO, >= 0 if OK
*/
- function update_contact($rowid, $statut, $type_contact_id=0)
+ function update_contact($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
{
// Insertion dans la base
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
$sql.= " statut = ".$statut;
if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'";
+ if ($fk_socpeople) $sql.= ", fk_socpeople = '".$fk_socpeople ."'";
$sql.= " where rowid = ".$rowid;
$resql=$this->db->query($sql);
if ($resql)
@@ -3035,4 +3037,4 @@ abstract class CommonObject
}
}
-?>
+?>
\ No newline at end of file
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 136d034a0ec..cf3c7b8ba96 100755
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -115,7 +115,8 @@ class HookManager
* @param Object &$object Object to use hooks on
* @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @return mixed For doActions,formObjectOptions: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO.
- * For printSearchForm,printLeftBlock,printTopRightMenu,...: Return HTML string.
+ * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints.
+ * Can also return some values into an array ->results.
* $this->error or this->errors are also defined by class called by this function if error.
*/
function executeHooks($method, $parameters=false, &$object='', &$action='')
@@ -127,45 +128,58 @@ class HookManager
// Loop on each hook to qualify modules that declared context
$modulealreadyexecuted=array();
- $resaction=0; $resprint='';
+ $resaction=0; $error=0;
+ $this->resPrint=''; $this->resArray=array();
foreach($this->hooks as $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context
{
if (! empty($modules))
{
foreach($modules as $module => $actionclassinstance)
{
- // test to avoid to run twice a hook, when a module implements several active contexts
+ // jump to next class if method does not exists
+ if (! method_exists($actionclassinstance,$method)) continue;
+ // test to avoid to run twice a hook, when a module implements several active contexts
if (in_array($module,$modulealreadyexecuted)) continue;
$modulealreadyexecuted[$module]=$module;
// Hooks that return int
- if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actionclassinstance,$method))
+ if (($method == 'doActions' || $method == 'formObjectOptions'))
{
- $resaction+=$actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
- if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
- {
- $this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
- if ($method == 'doActions')
- {
- if ($action=='add') $action='create'; // TODO this change must be inside the doActions
- if ($action=='update') $action='edit'; // TODO this change must be inside the doActions
- }
- }
+ $resaction+=$actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
+ if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
+ {
+ $error++;
+ $this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
+ // TODO remove this. Change must be inside the method if required
+ if ($method == 'doActions')
+ {
+ if ($action=='add') $action='create';
+ if ($action=='update') $action='edit';
+ }
+ }
}
- // Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...)
- else if (method_exists($actionclassinstance,$method))
+ // Generic hooks that return a string (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...)
+ else
{
- if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
+ // TODO. this should be done into the method by returning nothing
+ if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
+
$result = $actionclassinstance->$method($parameters, $object, $action, $this);
- if (is_array($result)) $this->resArray = array_merge($this->resArray, $result);
- else $resprint.=$result;
+
+ if (is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results);
+ if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints;
+
+ // TODO. remove this. array result must be set into $actionclassinstance->results
+ if (is_array($result)) $this->resArray = array_merge($this->resArray, $result);
+ // TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string
+ if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result;
}
}
}
}
- if ($method == 'doActions' || $method == 'formObjectOptions') return $resaction;
- return $resprint;
+ if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled.
+ return ($error?-1:$resaction);
}
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 2cce0fcbdfa..945a65fb820 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -165,6 +165,10 @@ class Form
{
$ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname);
}
+ else if ($typeofdata == 'datehourpicker')
+ {
+ $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname,1,1);
+ }
else if (preg_match('/^select;/',$typeofdata))
{
$arraydata=explode(',',preg_replace('/^select;/','',$typeofdata));
@@ -183,7 +187,7 @@ class Form
$ret.=$doleditor->Create(1);
}
$ret.='';
- if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.='