function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Get all pay period schedules. $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getAll(); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { $user_ids = $pps_obj->getUser(); if (is_array($user_ids)) { $time_zone_arr = array(); foreach ($user_ids as $user_id) { $uplf = new UserPreferenceListFactory(); $uplf->getByUserId($user_id); if ($uplf->getRecordCount() > 0) { if (isset($time_zone_arr[$uplf->getCurrent()->getTimeZone()])) { $time_zone_arr[$uplf->getCurrent()->getTimeZone()]++; } else { $time_zone_arr[$uplf->getCurrent()->getTimeZone()] = 1; } } } arsort($time_zone_arr); //Grab the first time zone, as it is most common foreach ($time_zone_arr as $time_zone => $count) { break; } if ($time_zone != '') { //Set pay period timezone to the timezone of the majority of the users are in. $pps_obj->setTimeZone($time_zone); if ($pps_obj->isValid()) { $pps_obj->Save(); } } } } } Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); return TRUE; }
} } //var_dump($user_deduction); foreach ($ulf as $u_obj) { //Wage data if (isset($user_wage[$u_obj->getId()])) { //Debug::Text('Wage Data found for User ID: '. $u_obj->getId(), __FILE__, __LINE__, __METHOD__,10); $user_wage_data = $user_wage[$u_obj->getId()]; } else { Debug::Text('No Wage Data found for User ID: ' . $u_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); //Dummy array $user_wage_data = array('type_id' => NULL, 'type' => NULL, 'wage' => NULL, 'effective_date_order' => NULL, 'effective_date' => NULL); } //Get user preference data. $uplf = new UserPreferenceListFactory(); $uplf->getByUserId($u_obj->getId()); if ($uplf->getRecordCount() > 0) { $up_obj = $uplf->getCurrent(); $user_pref_data = array('language' => Option::getByKey($up_obj->getLanguage(), $language_options), 'date_format' => Option::getByKey($up_obj->getDateFormat(), $date_format_options), 'time_format' => Option::getByKey($up_obj->getTimeFormat(), $time_format_options), 'time_unit' => Option::getByKey($up_obj->getTimeUnitFormat(), $time_unit_format_options), 'time_zone' => Option::getByKey($up_obj->getTimeZone(), $time_zone_options), 'start_week_day' => Option::getByKey($up_obj->getStartWeekDay(), $start_week_day_options), 'items_per_page' => $up_obj->getItemsPerPage()); } if (isset($permission_control_user_map[$u_obj->getId()])) { $permission_control_id = $permission_control_user_map[$u_obj->getId()]; } else { $permission_control_id = 0; } if (isset($policy_group_user_map[$u_obj->getId()])) { $policy_group_id = $policy_group_user_map[$u_obj->getId()]; } else { $policy_group_id = 0; } if (isset($pay_period_schedule_user_map[$u_obj->getId()])) {
function getEmailMessageAddresses() { $olf = $this->getObjectHandler(); if (is_object($olf)) { $olf->getById($this->getObject()); if ($olf->getRecordCount() > 0) { $obj = $olf->getCurrent(); switch ($this->getObjectType()) { case 5: case 100: Debug::Text('Email Object Type... Parent ID: ' . $this->getParent(), __FILE__, __LINE__, __METHOD__, 10); if ($this->getParent() == 0) { $user_ids[] = $obj->getId(); } else { $mlf = new MessageListFactory(); $mlf->getById($this->getParent()); if ($mlf->getRecordCount() > 0) { $m_obj = $mlf->getCurrent(); $user_ids[] = $m_obj->getCreatedBy(); } Debug::Text('cEmail Object Type... Parent ID: ' . $this->getParent(), __FILE__, __LINE__, __METHOD__, 10); } break; case 40: $user_ids[] = $obj->getId(); break; case 50: //Request //Get all users who have contributed to the thread. $mlf = new MessageListFactory(); $mlf->getMessagesInThreadById($this->getId()); Debug::Text(' Messages In Thread: ' . $mlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($mlf->getRecordCount() > 0) { foreach ($mlf as $m_obj) { $user_ids[] = $m_obj->getCreatedBy(); } } unset($mlf, $m_obj); //Debug::Arr($user_ids, 'User IDs in Thread: ', __FILE__, __LINE__, __METHOD__,10); //Only alert direct supervisor to request at this point. Because we need to take into account //if the request was authorized or not to determine if we should email the next higher level in the hierarchy. if ($this->getParent() == 0) { //Get direct parent in hierarchy. $u_obj = $obj->getUserObject(); //Find proper hierarchy to use for this object $hotlf = new HierarchyObjectTypeListFactory(); $control_id = $hotlf->getByCompanyIdAndObjectTypeId($u_obj->getCompany(), $this->getObjectType())->getCurrent()->getHierarchyControl(); Debug::Text(' Hierarchy Control ID: ' . $control_id, __FILE__, __LINE__, __METHOD__, 10); $hlf = new HierarchyListFactory(); $node_data = $hlf->getByHierarchyControlIdAndUserId($control_id, $u_obj->getId()); if ($node_data['parent_id'] != 0) { $user_ids[] = $node_data['parent_id']; } unset($hotlf, $control_id, $hlf, $node_data); } global $current_user; if (isset($current_user) and is_object($current_user) and isset($user_ids) and is_array($user_ids)) { $user_ids = array_unique($user_ids); $current_user_key = array_search($current_user->getId(), $user_ids); Debug::Text(' Current User Key: ' . $current_user_key, __FILE__, __LINE__, __METHOD__, 10); if ($current_user_key !== FALSE) { Debug::Text(' Removing Current User From Recipient List...' . $current_user->getId(), __FILE__, __LINE__, __METHOD__, 10); unset($user_ids[$current_user_key]); } } else { Debug::Text(' Current User Object not available...', __FILE__, __LINE__, __METHOD__, 10); } unset($current_user, $current_user_key); break; case 90: $user_ids[] = $obj->getUser(); break; } } if (isset($user_ids) and is_array($user_ids)) { //Get user preferences and determine if they accept email notifications. Debug::Arr($user_ids, 'Recipient User Ids: ', __FILE__, __LINE__, __METHOD__, 10); $uplf = new UserPreferenceListFactory(); $uplf->getByUserId($user_ids); if ($uplf->getRecordCount() > 0) { foreach ($uplf as $up_obj) { if ($up_obj->getEnableEmailNotificationMessage() == TRUE and $up_obj->getUserObject()->getStatus() == 10) { if ($up_obj->getUserObject()->getWorkEmail() != '') { $retarr[] = $up_obj->getUserObject()->getWorkEmail(); } if ($up_obj->getEnableEmailNotificationHome() and $up_obj->getUserObject()->getHomeEmail() != '') { $retarr[] = $up_obj->getUserObject()->getHomeEmail(); } } } if (isset($retarr)) { Debug::Arr($retarr, 'Recipient Email Addresses: ', __FILE__, __LINE__, __METHOD__, 10); return $retarr; } } } } return FALSE; }
function getUserPreferenceObject() { if (is_object($this->user_preference_obj)) { return $this->user_preference_obj; } else { $uplf = new UserPreferenceListFactory(); $this->user_preference_obj = $uplf->getByUserId($this->getId())->getCurrent(); return $this->user_preference_obj; } }