NEW Add hooks to allow an external module to complete list of events
into calendar views.
This commit is contained in:
parent
276f057acf
commit
57a267a30f
@ -341,11 +341,14 @@ dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
|
||||
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup);
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
// Define the legend/list of calendard to show
|
||||
$s=''; $link='';
|
||||
|
||||
$showextcals=$listofextcals;
|
||||
// Legend
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
|
||||
if (! empty($conf->use_javascript_ajax)) // If javascript on
|
||||
{
|
||||
$s='';
|
||||
$s.='<script type="text/javascript">' . "\n";
|
||||
$s.='jQuery(document).ready(function () {' . "\n";
|
||||
$s.='jQuery("#check_birthday").click(function() { jQuery(".family_birthday").toggle(); });' . "\n";
|
||||
@ -358,7 +361,10 @@ if (! empty($conf->use_javascript_ajax))
|
||||
$s.='});' . "\n";
|
||||
$s.='</script>' . "\n";
|
||||
|
||||
// Local calendar
|
||||
$s.='<div class="nowrap clear float"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>';
|
||||
|
||||
// External calendars
|
||||
if (is_array($showextcals) && count($showextcals) > 0)
|
||||
{
|
||||
$s.='<script type="text/javascript">' . "\n";
|
||||
@ -377,13 +383,23 @@ if (! empty($conf->use_javascript_ajax))
|
||||
$s.='<div class="nowrap float"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val['name'] . ' </div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Birthdays
|
||||
$s.='<div class="nowrap float"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' </div>';
|
||||
|
||||
// Calendars from hooks
|
||||
$parameters=array(); $object=null;
|
||||
$reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action);
|
||||
if (empty($reshook))
|
||||
{
|
||||
$s.= $hookmanager->resPrint;
|
||||
}
|
||||
elseif ($reshook > 1)
|
||||
{
|
||||
$s = $hookmanager->resPrint;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$link='';
|
||||
// Add link to show birthdays
|
||||
if (empty($conf->use_javascript_ajax))
|
||||
else // If javascript off
|
||||
{
|
||||
$newparam=$param; // newparam is for birthday links
|
||||
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
|
||||
@ -396,10 +412,10 @@ if (empty($conf->use_javascript_ajax))
|
||||
$link.='</a>';
|
||||
}
|
||||
|
||||
print_fiche_titre($s,$link.' '.$nav, '');
|
||||
print_fiche_titre($s, $link.' '.$nav, '');
|
||||
|
||||
|
||||
// Get event in an array
|
||||
// Load events from database into $eventarray
|
||||
$eventarray=array();
|
||||
|
||||
$sql = 'SELECT ';
|
||||
@ -470,6 +486,7 @@ if ($filtert > 0 || $usergroup > 0)
|
||||
$sql.= ' ORDER BY datep';
|
||||
//print $sql;
|
||||
|
||||
|
||||
dol_syslog("comm/action/index.php", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -571,6 +588,7 @@ else
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// Complete $eventarray with birthdates
|
||||
if ($showbirthday)
|
||||
{
|
||||
// Add events in array
|
||||
@ -638,6 +656,7 @@ if ($showbirthday)
|
||||
}
|
||||
}
|
||||
|
||||
// Complete $eventarray with external import Ical
|
||||
if (count($listofextcals))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php';
|
||||
@ -878,6 +897,15 @@ if (count($listofextcals))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Complete $eventarray with events coming from external module
|
||||
$parameters=array(); $object=null;
|
||||
$reshook=$hookmanager->executeHooks('getCalendarEvents',$parameters,$object,$action);
|
||||
if (! empty($hookmanager->resArray['eventarray'])) $eventarray=array_merge($eventarray, $hookmanager->resArray['eventarray']);
|
||||
|
||||
|
||||
|
||||
$maxnbofchar=18;
|
||||
$cachethirdparties=array();
|
||||
$cachecontacts=array();
|
||||
|
||||
@ -116,8 +116,8 @@ class HookManager
|
||||
* @param array $parameters Array of parameters
|
||||
* @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 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO.
|
||||
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint.
|
||||
* @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||
* For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results and set into ->resArray.
|
||||
* All types 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.
|
||||
*/
|
||||
@ -128,7 +128,7 @@ class HookManager
|
||||
$parameters['context']=join(':',$this->contextarray);
|
||||
dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']);
|
||||
|
||||
// Define type of hook ('output' or 'addreplace'. 'returnvalue' is deprecated).
|
||||
// Define type of hook ('output' or 'addreplace'. 'returnvalue' is deprecated because a 'addreplace' hook can also return resPrint and resArray).
|
||||
$hooktype='output';
|
||||
if (in_array(
|
||||
$method,
|
||||
@ -146,7 +146,8 @@ class HookManager
|
||||
'paymentsupplierinvoices',
|
||||
'printAddress',
|
||||
'printSearchForm',
|
||||
'formatEvent'
|
||||
'formatEvent',
|
||||
'addCalendarChoice'
|
||||
)
|
||||
)) $hooktype='addreplace';
|
||||
// Deprecated hook types ('returnvalue')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user