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; }