function getEmailExceptionAddresses($u_obj = NULL, $ep_obj = NULL)
 {
     Debug::text(' Attempting to Email Notification...', __FILE__, __LINE__, __METHOD__, 10);
     //Make sure type is not pre-mature.
     if ($this->getType() > 5) {
         if (!is_object($ep_obj)) {
             $ep_obj = $this->getExceptionPolicyObject();
         }
         //Make sure exception policy email notifications are enabled.
         if ($ep_obj->getEmailNotification() > 0) {
             if (!is_object($u_obj)) {
                 $u_obj = $this->getUserDateObject()->getUserObject();
             }
             $up_obj = $this->getUserDateObject()->getUserObject()->getUserPreferenceObject();
             //Make sure user email notifications are enabled.
             if (($ep_obj->getEmailNotification() == 10 or $ep_obj->getEmailNotification() == 100) and $up_obj->getEnableEmailNotificationException() == TRUE) {
                 Debug::Text(' Emailing exception to user!', __FILE__, __LINE__, __METHOD__, 10);
                 if ($u_obj->getWorkEmail() != '') {
                     $retarr[] = $u_obj->getWorkEmail();
                 }
                 if ($up_obj->getEnableEmailNotificationHome() == TRUE and $u_obj->getHomeEmail() != '') {
                     $retarr[] = $u_obj->getHomeEmail();
                 }
             } else {
                 Debug::Text(' Skipping email to user.', __FILE__, __LINE__, __METHOD__, 10);
             }
             //Make sure supervisor email notifcations are enabled
             if ($ep_obj->getEmailNotification() == 20 or $ep_obj->getEmailNotification() == 100) {
                 //Find supervisor
                 $hlf = new HierarchyListFactory();
                 $parent_user_id = $hlf->getHierarchyParentByCompanyIdAndUserIdAndObjectTypeID($u_obj->getCompany(), $u_obj->getId(), 80);
                 if ($parent_user_id != FALSE) {
                     $ulf = new UserListFactory();
                     $ulf->getById($parent_user_id);
                     if ($ulf->getRecordCount() > 0) {
                         $parent_user_obj = $ulf->getCurrent();
                         if (is_object($parent_user_obj->getUserPreferenceObject()) and $parent_user_obj->getUserPreferenceObject()->getEnableEmailNotificationException() == TRUE) {
                             Debug::Text(' Emailing exception to supervisor!', __FILE__, __LINE__, __METHOD__, 10);
                             if ($parent_user_obj->getWorkEmail() != '') {
                                 $retarr[] = $parent_user_obj->getWorkEmail();
                             }
                             if ($up_obj->getEnableEmailNotificationHome() == TRUE and $parent_user_obj->getHomeEmail() != '') {
                                 $retarr[] = $parent_user_obj->getHomeEmail();
                             }
                         } else {
                             Debug::Text(' Skipping email to supervisor.', __FILE__, __LINE__, __METHOD__, 10);
                         }
                     }
                 } else {
                     Debug::Text(' No Hierarchy Parent Found, skipping email to supervisor.', __FILE__, __LINE__, __METHOD__, 10);
                 }
             }
             if (isset($retarr) and is_array($retarr)) {
                 return $retarr;
             } else {
                 Debug::text(' No user objects to email too...', __FILE__, __LINE__, __METHOD__, 10);
             }
         } else {
             Debug::text(' Exception Policy Email Exceptions are disabled, skipping email...', __FILE__, __LINE__, __METHOD__, 10);
         }
     } else {
         Debug::text(' Pre-Mature exception, or not in production mode, skipping email...', __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
 function preSave()
 {
     //If this is a new request, find the current authorization level to assign to it.
     if ($this->isNew() == TRUE) {
         $hlf = new HierarchyListFactory();
         $hierarchy_arr = $hlf->getHierarchyParentByCompanyIdAndUserIdAndObjectTypeID($this->getUserObject()->getCompany(), $this->getUserObject()->getID(), 50, FALSE);
         $hierarchy_highest_level = 99;
         if (is_array($hierarchy_arr)) {
             Debug::Arr($hierarchy_arr, ' Hierarchy Array: ', __FILE__, __LINE__, __METHOD__, 10);
             $hierarchy_highest_level = end(array_keys($hierarchy_arr));
             Debug::Text(' Setting hierarchy level to: ' . $hierarchy_highest_level, __FILE__, __LINE__, __METHOD__, 10);
         }
         $this->setAuthorizationLevel($hierarchy_highest_level);
     }
     if ($this->getAuthorized() == TRUE) {
         $this->setAuthorizationLevel(0);
     }
     return TRUE;
 }
 function getHierarchyParentArray($user_id = NULL)
 {
     if (is_array($this->hierarchy_parent_arr)) {
         return $this->hierarchy_parent_arr;
     } else {
         $user_id = $this->getCurrentUserID($user_id);
         $this->getObjectHandler()->getByID($this->getObject());
         $current_obj = $this->getObjectHandler()->getCurrent();
         $object_user_id = $current_obj->getUser();
         if ($object_user_id > 0) {
             Debug::Text(' Authorizing User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text(' Object User ID: ' . $object_user_id, __FILE__, __LINE__, __METHOD__, 10);
             $ulf = new UserListFactory();
             $company_id = $ulf->getById($object_user_id)->getCurrent()->getCompany();
             Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
             $hlf = new HierarchyListFactory();
             $this->hierarchy_parent_arr = $hlf->getHierarchyParentByCompanyIdAndUserIdAndObjectTypeID($company_id, $object_user_id, $this->getObjectType(), FALSE);
             Debug::Arr($this->hierarchy_parent_arr, ' Parent Arr: ', __FILE__, __LINE__, __METHOD__, 10);
             return $this->hierarchy_parent_arr;
         } else {
             Debug::Text(' Could not find Object User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
         }
     }
     return FALSE;
 }