From e7a9447d940d5de862d5d2fc44a2288b23be9e2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Oct 2014 15:58:08 +0200 Subject: [PATCH] Add hook formatEvent and fix bug into per user view. --- htdocs/comm/action/card.php | 31 ++++++------ htdocs/comm/action/class/actioncomm.class.php | 13 +++-- htdocs/comm/action/peruser.php | 11 ++++- htdocs/core/class/hookmanager.class.php | 7 +-- htdocs/theme/eldy/style.css.php | 49 +++---------------- 5 files changed, 46 insertions(+), 65 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index e92dacc5dc9..772e3e05622 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -68,7 +68,7 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions| if ($user->societe_id && $socid) $result = restrictedArea($user,'societe',$socid); $error=GETPOST("error"); -$donotclearsession=0; +$donotclearsession=GETPOST('donotclearsession')?GETPOST('donotclearsession'):0; $cactioncomm = new CActionComm($db); $object = new ActionComm($db); @@ -358,22 +358,22 @@ if ($action == 'update') $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); $object->fk_action = dol_getIdFromCode($db, $_POST["actioncode"], 'c_actioncomm'); - $object->label = $_POST["label"]; + $object->label = GETPOST("label"); $object->datep = $datep; $object->datef = $datef; $object->percentage = $percentage; - $object->priority = $_POST["priority"]; - $object->fulldayevent= $_POST["fullday"]?1:0; + $object->priority = GETPOST("priority"); + $object->fulldayevent= GETPOST("fullday")?1:0; $object->location = GETPOST('location'); - $object->socid = $_POST["socid"]; - $object->contactid = $_POST["contactid"]; + $object->socid = GETPOST("socid"); + $object->contactid = GETPOST("contactid"); //$object->societe->id = $_POST["socid"]; // deprecated //$object->contact->id = $_POST["contactid"]; // deprecated - $object->fk_project = $_POST["projectid"]; - $object->note = $_POST["note"]; - $object->pnote = $_POST["note"]; - $object->fk_element = $_POST["fk_element"]; - $object->elementtype = $_POST["elementtype"]; + $object->fk_project = GETPOST("projectid"); + $object->note = GETPOST("note"); + $object->pnote = GETPOST("note"); + $object->fk_element = GETPOST("fk_element"); + $object->elementtype = GETPOST("elementtype"); if (! $datef && $percentage == 100) { @@ -603,6 +603,7 @@ if ($action == 'create') print '
'; print ''; print ''; + print ''; if ($backtopage) print ''; if (GETPOST("actioncode") == 'AC_RDV') print_fiche_titre($langs->trans("AddActionRendezVous")); @@ -1225,7 +1226,7 @@ if ($id > 0) // Link to agenda views print '
'; - print ''; + print ''; print ''; print ''; print ''; @@ -1234,7 +1235,7 @@ if ($id > 0) //print ''; print img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone"').' '; print ''."\n"; - print '
'; + print ''; print ''; print ''; print ''; @@ -1243,7 +1244,7 @@ if ($id > 0) //print ''; print img_picto($langs->trans("ViewCal"),'object_calendarweek','class="hideonsmartphone"').' '; print '
'."\n"; - print '
'; + print ''; print ''; print ''; print ''; @@ -1252,7 +1253,7 @@ if ($id > 0) //print ''; print img_picto($langs->trans("ViewCal"),'object_calendarday','class="hideonsmartphone"').' '; print '
'."\n"; - print '
'; + print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fc75488ee3d..01ebadceb2e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -95,14 +95,16 @@ class ActionComm extends CommonObject */ function __construct($db) { + global $langs; + $this->db = $db; //$this->author = new stdClass(); //$this->usermod = new stdClass(); //$this->usertodo = new stdClass(); //$this->userdone = new stdClass(); - $this->societe = new stdClass(); - $this->contact = new stdClass(); + $this->societe = new stdClass(); // deprecated + $this->contact = new stdClass(); // deprecated } /** @@ -524,6 +526,9 @@ class ActionComm extends CommonObject return -1; } + $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)); + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; @@ -534,9 +539,9 @@ class ActionComm extends CommonObject $sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null'); $sql.= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null"); // deprecated $sql.= ", note = ".($this->note ? "'".$this->db->escape($this->note)."'":"null"); - $sql.= ", fk_soc =". ($this->societe->id > 0 ? "'".$this->societe->id."'":"null"); + $sql.= ", fk_soc =". ($this->socid > 0 ? "'".$this->socid."'":"null"); $sql.= ", fk_project =". ($this->fk_project > 0 ? "'".$this->fk_project."'":"null"); - $sql.= ", fk_contact =". ($this->contact->id > 0 ? "'".$this->contact->id."'":"null"); + $sql.= ", fk_contact =". ($contactid > 0 ? "'".$this->contactid."'":"null"); $sql.= ", priority = '".$this->priority."'"; $sql.= ", fulldayevent = '".$this->fulldayevent."'"; $sql.= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'":"null"); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index ad3bfddd2ef..4452351d8c2 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -320,7 +320,7 @@ $sql.= ' a.datea2,'; $sql.= ' a.percent,'; $sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql.= ' a.fk_soc, a.fk_contact,'; +$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,'; $sql.= ' ca.code, ca.color'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -415,6 +415,9 @@ if ($resql) //$event->societe->id=$obj->fk_soc; // deprecated //$event->contact->id=$obj->fk_contact; // deprecated + $event->fk_element=$obj->fk_element; + $event->elementtype=$obj->elementtype; + // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. if ($event->percentage <= 0) @@ -709,7 +712,7 @@ $db->close(); function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $showheader=false) { global $db; - global $user, $conf, $langs; + global $user, $conf, $langs, $hookmanager, $action; global $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form global $theme_datacolor; global $cachethirdparties, $cachecontacts, $colorindexused; @@ -743,6 +746,10 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if (! in_array($username->id,$keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show + $parameters=array(); + $reshook=$hookmanager->executeHooks('formatEvent',$parameters,$event,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); // Define $color (Hex string like '0088FF') and $cssclass of event diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index c402353e8d7..babddd9a2fe 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -114,8 +114,8 @@ class HookManager * * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) * @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'...) + * @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,pdf_xxx: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints. * Can also return some values into an array ->results. @@ -144,7 +144,8 @@ class HookManager 'moveUploadedFile', 'pdf_writelinedesc', 'paymentsupplierinvoices', - 'printSearchForm' + 'printSearchForm', + 'formatEvent' ) )) $hooktype='addreplace'; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 53169c94755..5b0e64525f6 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -989,10 +989,10 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks background-position:top; background-repeat:repeat-x; - border-left: 1px solid #CCCCCC; - border-right: 1px solid #D0D0D0; - border-bottom: 1px solid #DDDDDD; - border-top: 1px solid #DDDDDD; + border-left: 1px solid #AAA; + border-right: 1px solid #CCC; + border-bottom: 1px solid #CCC; + border-top: 1px solid #CCC; border-radius: 5px; -moz-border-radius: 5px; -moz-box-shadow: 3px 3px 4px #DDD; @@ -1021,10 +1021,10 @@ div.blockvmenusearch background-image: linear-gradient(bottom, rgb() 90%, rgb() 100%); - border-left: 1px solid #DDDDDD; - border-right: 1px solid #CCCCCC; - border-bottom: 1px solid #CCCCCC; - border-top: 1px solid #E8E8E8; + border-left: 1px solid #AAA; + border-right: 1px solid #CCC; + border-bottom: 1px solid #CCC; + border-top: 1px solid #CCC; border-radius: 5px; -moz-border-radius: 5px; -moz-box-shadow: 3px 3px 4px #DDD; @@ -1032,39 +1032,6 @@ div.blockvmenusearch box-shadow: 3px 3px 4px #DDD; } -div.blockvmenubookmarksold -{ - border-right: 1px solid #555555; - border-bottom: 1px solid #555555; - font-family: ; - color: #000000; - text-align: ; - text-decoration: none; - padding-left: 5px; - padding-right: 1px; - padding-top: 3px; - padding-bottom: 3px; - margin: 6px 0px 8px 2px; - background: #E3E6E8; - - - background-image: -o-linear-gradient(bottom, rgb() 90%, rgb() 100%); - background-image: -moz-linear-gradient(bottom, rgb() 90%, rgb() 100%); - background-image: -webkit-linear-gradient(bottom, rgb() 90%, rgb() 100%); - background-image: -ms-linear-gradient(bottom, rgb() 90%, rgb() 100%); - background-image: linear-gradient(bottom, rgb() 90%, rgb() 100%); - - - border-left: 1px solid #CCCCCC; - border-right: 1px solid #BBBBBB; - border-bottom: 1px solid #BBBBBB; - border-radius: 5px; - -moz-border-radius: 5px; - -moz-box-shadow: 3px 3px 4px #DDD; - -webkit-box-shadow: 3px 3px 4px #DDD; - box-shadow: 3px 3px 4px #DDD; -} - div.blockvmenuhelp { dol_optimize_smallscreen)) { ?>