grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026deprecated($deprecatedMessage); } else { trigger_error($deprecatedMessage, E_USER_DEPRECATED); } self::__construct(); } public $new_schema = true; public function save($check_notify = false) { if (empty($this->status)) { $this->status = $this->getDefaultStatus(); } return parent::save($check_notify); } public function get_summary_text() { return "$this->name"; } public function create_export_query($order_by, $where, $relate_link_join='') { $custom_join = $this->getCustomJoin(true, true, $where); $custom_join['join'] .= $relate_link_join; $contact_required = stristr($where, "contacts"); if ($contact_required) { $query = "SELECT tasks.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name "; $query .= $custom_join['select']; $query .= " FROM contacts, tasks "; $where_auto = "tasks.contact_id = contacts.id AND tasks.deleted=0 AND contacts.deleted=0"; } else { $query = 'SELECT tasks.*, users.user_name as assigned_user_name '; $query .= $custom_join['select']; $query .= ' FROM tasks '; $where_auto = "tasks.deleted=0"; } $query .= $custom_join['join']; $query .= " LEFT JOIN users ON tasks.assigned_user_id=users.id "; if ($where != "") { $query .= "where $where AND ".$where_auto; } else { $query .= "where ".$where_auto; } $order_by = $this->process_order_by($order_by); if (empty($order_by)) { $order_by = 'tasks.name'; } $query .= ' ORDER BY ' . $order_by; return $query; } public function fill_in_additional_detail_fields() { parent::fill_in_additional_detail_fields(); global $app_strings; if (isset($this->contact_id)) { $contact = new Contact(); $contact->retrieve($this->contact_id); if ($contact->id != "") { $this->contact_name = $contact->full_name; $this->contact_name_owner = $contact->assigned_user_id; $this->contact_name_mod = 'Contacts'; $this->contact_phone = $contact->phone_work; $this->contact_email = $contact->emailAddress->getPrimaryAddress($contact); } else { $this->contact_name_mod = ''; $this->contact_name_owner = ''; $this->contact_name=''; $this->contact_email = ''; $this->contact_id=''; } } $this->fill_in_additional_parent_fields(); } public function fill_in_additional_parent_fields() { $this->parent_name = ''; global $app_strings, $beanFiles, $beanList, $locale; if (! isset($beanList[$this->parent_type])) { $this->parent_name = ''; return; } $beanType = $beanList[$this->parent_type]; require_once($beanFiles[$beanType]); $parent = new $beanType(); if (is_subclass_of($parent, 'Person')) { $query = "SELECT first_name, last_name, assigned_user_id parent_name_owner from $parent->table_name where id = '$this->parent_id'"; } else { if (is_subclass_of($parent, 'File')) { $query = "SELECT document_name, assigned_user_id parent_name_owner from $parent->table_name where id = '$this->parent_id'"; } else { $query = "SELECT name "; if (isset($parent->field_defs['assigned_user_id'])) { $query .= " , assigned_user_id parent_name_owner "; } else { $query .= " , created_by parent_name_owner "; } $query .= " from $parent->table_name where id = '$this->parent_id'"; } } $result = $this->db->query($query, true, " Error filling in additional detail fields: "); // Get the id and the name. $row = $this->db->fetchByAssoc($result); if ($row && !empty($row['parent_name_owner'])) { $this->parent_name_owner = $row['parent_name_owner']; $this->parent_name_mod = $this->parent_type; } if (is_subclass_of($parent, 'Person') and $row != null) { $this->parent_name = $locale->getLocaleFormattedName(stripslashes($row['first_name']), stripslashes($row['last_name'])); } else { if (is_subclass_of($parent, 'File') && $row != null) { $this->parent_name = $row['document_name']; } elseif ($row != null) { $this->parent_name = stripslashes($row['name']); } else { $this->parent_name = ''; } } } protected function formatStartAndDueDates(&$task_fields, $dbtime, $override_date_for_subpanel) { global $timedate; if (empty($dbtime)) { return; } $today = $timedate->nowDbDate(); $task_fields['TIME_DUE'] = $timedate->to_display_time($dbtime); $task_fields['DATE_DUE'] = $timedate->to_display_date($dbtime); $date_due = $task_fields['DATE_DUE']; $dd = $timedate->to_db_date($date_due, false); $taskClass = 'futureTask'; if ($dd < $today) { if ($task_fields['STATUS']=='Completed' || $task_fields['STATUS']=='Deferred') { $taskClass = ''; } else { $taskClass = 'overdueTask'; } } else { if ($dd == $today) { $taskClass = 'todaysTask'; } } $task_fields['DATE_DUE']= "$date_due"; if ($override_date_for_subpanel) { $task_fields['DATE_START']= "$date_due"; } } public function get_list_view_data() { global $action, $currentModule, $focus, $current_module_strings, $app_list_strings, $timedate; $override_date_for_subpanel = false; if (!empty($_REQUEST['module']) && $_REQUEST['module'] !='Calendar' && $_REQUEST['module'] !='Tasks' && $_REQUEST['module'] !='Home') { //this is a subpanel list view, so override the due date with start date so that collections subpanel works as expected $override_date_for_subpanel = true; } $today = $timedate->nowDb(); $task_fields = $this->get_list_view_array(); if (!isset($task_fields['DATE_DUE'])) { LoggerManager::getLogger()->warn('Task get_list_view_data: Undefined index: DATE_DUE'); $taskFieldsDateDue = null; } else { $taskFieldsDateDue = $task_fields['DATE_DUE']; } $dbtime = $timedate->to_db($taskFieldsDateDue); if ($override_date_for_subpanel) { $dbtime = $timedate->to_db($task_fields['DATE_START']); } if (!empty($dbtime)) { $task_fields['TIME_DUE'] = $timedate->to_display_time($dbtime); $task_fields['DATE_DUE'] = $timedate->to_display_date($dbtime); $this->formatStartAndDueDates($task_fields, $dbtime, $override_date_for_subpanel); } if (!empty($this->priority)) { $task_fields['PRIORITY'] = $app_list_strings['task_priority_dom'][$this->priority]; } if (isset($this->parent_type)) { $task_fields['PARENT_MODULE'] = $this->parent_type; } if ($this->status != "Completed" && $this->status != "Deferred") { $setCompleteUrl = ""; $task_fields['SET_COMPLETE'] = $setCompleteUrl . ""; } // make sure we grab the localized version of the contact name, if a contact is provided if (!empty($this->contact_id)) { $contact_temp = BeanFactory::getBean("Contacts", $this->contact_id); if (!empty($contact_temp)) { // Make first name, last name, salutation and title of Contacts respect field level ACLs $contact_temp->_create_proper_name_field(); $this->contact_name = $contact_temp->full_name; $this->contact_phone = $contact_temp->phone_work; } } $task_fields['CONTACT_NAME']= $this->contact_name; $task_fields['CONTACT_PHONE']= $this->contact_phone; $task_fields['TITLE'] = ''; if (!empty($task_fields['CONTACT_NAME'])) { $task_fields['TITLE'] .= $current_module_strings['LBL_LIST_CONTACT'].": ".$task_fields['CONTACT_NAME']; } if (!empty($this->parent_name)) { $task_fields['TITLE'] .= "\n".$app_list_strings['parent_type_display'][$this->parent_type].": ".$this->parent_name; $task_fields['PARENT_NAME']=$this->parent_name; } return $task_fields; } public function set_notification_body($xtpl, $task) { global $app_list_strings; global $timedate; $notifyUser = $task->current_notify_user; $prefDate = $notifyUser->getUserDateTimePreferences(); $xtpl->assign("TASK_SUBJECT", $task->name); //MFH #13507 $xtpl->assign("TASK_PRIORITY", (isset($task->priority)?$app_list_strings['task_priority_dom'][$task->priority]:"")); if (!empty($task->date_due)) { $duedate = $timedate->fromDb($task->date_due); $xtpl->assign("TASK_DUEDATE", $timedate->asUser($duedate, $notifyUser)." ".TimeDate::userTimezoneSuffix($duedate, $notifyUser)); } else { $xtpl->assign("TASK_DUEDATE", ''); } $xtpl->assign("TASK_STATUS", (isset($task->status)?$app_list_strings['task_status_dom'][$task->status]:"")); $xtpl->assign("TASK_DESCRIPTION", $task->description); return $xtpl; } public function bean_implements($interface) { switch ($interface) { case 'ACL':return true; } return false; } public function listviewACLHelper() { $array_assign = parent::listviewACLHelper(); $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->parent_name)) { if (!empty($this->parent_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->parent_name_owner; } /* BEGIN - SECURITY GROUPS */ //parent_name_owner not being set for whatever reason so we need to figure this out else { if (!empty($this->parent_type) && !empty($this->parent_id)) { global $current_user; $parent_bean = BeanFactory::getBean($this->parent_type, $this->parent_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } } require_once("modules/SecurityGroups/SecurityGroup.php"); $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){ */ if (!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['PARENT'] = 'a'; } else { $array_assign['PARENT'] = 'span'; } $is_owner = false; $in_group = false; //SECURITY GROUPS if (!empty($this->contact_name)) { if (!empty($this->contact_name_owner)) { global $current_user; $is_owner = $current_user->id == $this->contact_name_owner; } /* BEGIN - SECURITY GROUPS */ //contact_name_owner not being set for whatever reason so we need to figure this out else { global $current_user; $parent_bean = BeanFactory::getBean('Contacts', $this->contact_id); if ($parent_bean !== false) { $is_owner = $current_user->id == $parent_bean->assigned_user_id; } } require_once("modules/SecurityGroups/SecurityGroup.php"); $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view'); /* END - SECURITY GROUPS */ } /* BEGIN - SECURITY GROUPS */ /** if( ACLController::checkAccess('Contacts', 'view', $is_owner)){ */ if (ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) { /* END - SECURITY GROUPS */ $array_assign['CONTACT'] = 'a'; } else { $array_assign['CONTACT'] = 'span'; } return $array_assign; } public function getDefaultStatus() { $def = $this->field_defs['status']; if (isset($def['default'])) { return $def['default']; } else { $app = return_app_list_strings_language($GLOBALS['current_language']); if (isset($def['options']) && isset($app[$def['options']])) { $keys = array_keys($app[$def['options']]); return $keys[0]; } } return ''; } }