/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_EmbeddedAuthorizationList($params, &$smarty)
{
    global $current_company, $current_user;
    $object_type_id = $params['object_type_id'];
    $object_id = $params['object_id'];
    $ulf = new UserListFactory();
    $hlf = new HierarchyListFactory();
    $hotlf = new HierarchyObjectTypeListFactory();
    $alf = new AuthorizationListFactory();
    $alf->setObjectType($object_type_id);
    //$authorizing_obj = $alf->getObjectHandler()->getById( $object_id )->getCurrent();
    $tmp_authorizing_obj = $alf->getObjectHandler()->getById($object_id);
    if (is_object($tmp_authorizing_obj)) {
        $authorizing_obj = $tmp_authorizing_obj->getCurrent();
    } else {
        return FALSE;
    }
    //var_dump($authorizing_obj);
    unset($alf);
    $user_id = $authorizing_obj->getUserObject()->getId();
    $alf = new AuthorizationListFactory();
    $alf->getByObjectTypeAndObjectId($object_type_id, $object_id);
    foreach ($alf as $authorization_obj) {
        $authorization_data[] = array('id' => $authorization_obj->getId(), 'created_by_full_name' => $ulf->getById($authorization_obj->getCreatedBy())->getCurrent()->getFullName(), 'authorized' => $authorization_obj->getAuthorized(), 'created_date' => $authorization_obj->getCreatedDate(), 'created_by' => $authorization_obj->getCreatedBy(), 'updated_date' => $authorization_obj->getUpdatedDate(), 'updated_by' => $authorization_obj->getUpdatedBy(), 'deleted_date' => $authorization_obj->getDeletedDate(), 'deleted_by' => $authorization_obj->getDeletedBy());
        $user_id = $authorization_obj->getCreatedBy();
    }
    if ($authorizing_obj->getStatus() == 30) {
        //If the object is still pending authorization, display who its waiting on...
        $hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($current_company->getId(), $object_type_id)->getCurrent()->getHierarchyControl();
        Debug::Text('Hierarchy ID: ' . $hierarchy_id, __FILE__, __LINE__, __METHOD__, 10);
        //Get Parents
        $parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $user_id);
        Debug::Arr($parent_level_user_ids, 'Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10);
        if ($parent_level_user_ids !== FALSE and count($parent_level_user_ids) > 0) {
            Debug::Text('Adding Pending Line: ', __FILE__, __LINE__, __METHOD__, 10);
            foreach ($parent_level_user_ids as $parent_user_id) {
                $created_by_full_name[] = $ulf->getById($parent_user_id)->getCurrent()->getFullName();
            }
            $authorization_data[] = array('id' => NULL, 'created_by_full_name' => implode('<br>', $created_by_full_name), 'authorized' => NULL, 'created_date' => NULL, 'created_by' => NULL);
        }
    }
    $smarty->assign_by_ref('authorization_data', $authorization_data);
    $smarty->display('authorization/EmbeddedAuthorizationList.tpl');
}
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('do', 'page', 'sort_column', 'sort_order', 'filter_data')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page));
if (isset($filter_data['start_date']) and $filter_data['start_date'] != '') {
    $filter_data['start_date'] = TTDate::parseDateTime($filter_data['start_date']);
} else {
    $filter_data['start_date'] = time();
}
if (!isset($filter_data['show_days']) or isset($filter_data['show_days']) and $filter_data['show_days'] == '') {
    $filter_data['show_days'] = 1;
}
$filter_data['show_days'] = $filter_data['show_days'] * 7;
//Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
$hlf = new HierarchyListFactory();
$permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($current_company->getId(), $current_user->getId());
if ($permission->Check('schedule', 'view') == FALSE) {
    if ($permission->Check('schedule', 'view_child') == FALSE) {
        $permission_children_ids = array();
    }
    if ($permission->Check('schedule', 'view_own')) {
        $permission_children_ids[] = $current_user->getId();
    }
    $filter_data['permission_children_ids'] = $permission_children_ids;
}
$do = Misc::findSubmitButton('do');
switch ($do) {
    case 'view_schedule':
    default:
        $user_ids = array();
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by TimeTrex" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by TimeTrex".
 ********************************************************************************/
/*
 * $Revision: 1396 $
 * $Id: AuthorizationNotify.php 1396 2007-11-07 16:49:35Z ipso $
 * $Date: 2007-11-07 08:49:35 -0800 (Wed, 07 Nov 2007) $
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php';
$permission = new Permission();
$hlf = new HierarchyListFactory();
$hotlf = new HierarchyObjectTypeListFactory();
//Get all users
$ulf = new UserListFactory();
$ulf->getByStatus(10, NULL, array('company_id' => 'asc'));
foreach ($ulf as $user) {
    //Check authorize permissions for eact object type.
    if ($permission->Check('default_schedule', 'authorize', $user->getId(), $user->getCompany())) {
        //Get Hierarchy Control ID
        $default_schedule_hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($user->getCompany(), 10)->getCurrent()->getHierarchyControl();
        Debug::Text('Default Schedule Hierarchy ID: ' . $default_schedule_hierarchy_id, __FILE__, __LINE__, __METHOD__, 10);
        //Get all levels below us.
        $default_schedule_levels = $hlf->getLevelsByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $user->getId());
        Debug::Arr($default_schedule_levels, 'Default Schedule Levels', __FILE__, __LINE__, __METHOD__, 10);
        $default_schedule_user_id = $user->getId();
        $default_schedule_node_data = $hlf->getByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id);
 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;
 }
Esempio n. 5
0
                 }
             } else {
                 $redirect++;
             }
         }
     }
     if ($redirect == 0) {
         Redirect::Page(URLBuilder::getURL(array('hierarchy_id' => $hierarchy_id), 'HierarchyList.php'));
         break;
     }
 default:
     //BreadCrumb::setCrumb($title);
     if (isset($id) and !isset($user_data['user_id'])) {
         $user_data['user_id'] = $id;
     }
     $hlf = new HierarchyListFactory();
     //$nodes = $hlf->FormatArray( $hlf->getByHierarchyControlId( $hierarchy_id ), 'TEXT', TRUE);
     //$nodes = FastTree::FormatArray( $hlf->getByHierarchyControlId( $hierarchy_id ), 'TEXT', TRUE);
     $nodes = FastTree::FormatArray($hlf->getByCompanyIdAndHierarchyControlId($current_company->getId(), $hierarchy_id), 'TEXT', TRUE);
     foreach ($nodes as $node) {
         $parent_list_options[$node['id']] = $node['text'];
     }
     //Get include employee list.
     $ulf = new UserListFactory();
     $ulf->getByCompanyId($current_company->getId());
     $raw_user_options = $ulf->getArrayByListFactory($ulf, FALSE, TRUE);
     //$raw_user_list_options = UserListFactory::getByCompanyIdArray( $current_company->getId() );
     //Only allow them to select employees not already in the tree.
     unset($parent_list_options[$id]);
     //If we're editing a single entry, include that user in the list.
     $parent_list_keys = array_keys($parent_list_options);
Esempio n. 6
0
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
if (!$permission->Check('hierarchy', 'enabled') or !($permission->Check('hierarchy', 'view') or $permission->Check('hierarchy', 'view_own'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'View Hierarchy'));
// See index.php
BreadCrumb::setCrumb($title);
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'hierarchy_id', 'id')));
switch ($action) {
    default:
        if (isset($id)) {
            $hlf = new HierarchyListFactory();
            $tmp_id = $id;
            $i = 0;
            do {
                Debug::Text(' Iteration...', __FILE__, __LINE__, __METHOD__, 10);
                $parents = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $tmp_id);
                $level = $hlf->getFastTreeObject()->getLevel($tmp_id) - 1;
                if (is_array($parents) and count($parents) > 0) {
                    $parent_users = array();
                    foreach ($parents as $user_id) {
                        //Get user information
                        $ulf = new UserListFactory();
                        $ulf->getById($user_id);
                        $user = $ulf->getCurrent();
                        unset($ulf);
                        $parent_users[] = array('name' => $user->getFullName());
Esempio n. 7
0
            $delete = FALSE;
        }
        foreach ($ids as $id) {
            Debug::Text(' Deleting ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
            $hf = new HierarchyListFactory();
            $hf->setUser($id);
            $hf->setHierarchyControl($hierarchy_id);
            $hf->Delete();
        }
        //FIXME: Get parent ID of each node we're deleting and clear the cache based on the hierarchy_id and it instead
        if (isset($hf) and is_object($hf)) {
            $hf->removeCache(NULL, $hf->getTable(TRUE));
            //On delete we have to delete the entire group.
        }
        unset($hf);
        Redirect::Page(URLBuilder::getURL(array('hierarchy_id' => $hierarchy_id), 'HierarchyList.php'));
        break;
    default:
        BreadCrumb::setCrumb($title);
        $hlf = new HierarchyListFactory();
        //$nodes = $hlf->FormatArray( $hlf->getByHierarchyControlId( $hierarchy_id ), 'HTML' );
        //$nodes = FastTree::FormatArray( $hlf->getByHierarchyControlId( $hierarchy_id ), 'HTML' );
        $nodes = FastTree::FormatArray($hlf->getByCompanyIdAndHierarchyControlId($current_company->getId(), $hierarchy_id), 'HTML');
        //For some reason smarty prints out a blank row if nodes is false.
        if ($nodes !== FALSE) {
            $smarty->assign_by_ref('users', $nodes);
        }
        break;
}
$smarty->assign_by_ref('hierarchy_id', $hierarchy_id);
$smarty->display('hierarchy/HierarchyList.tpl');
BreadCrumb::setCrumb($title);
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'ids', 'selected_levels')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page));
switch ($action) {
    case 'submit':
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
    default:
        $sort_array = NULL;
        if ($sort_column != '') {
            $sort_array = array(Misc::trimSortPrefix($sort_column) => $sort_order);
        }
        $ulf = new UserListFactory();
        $hlf = new HierarchyListFactory();
        $hllf = new HierarchyLevelListFactory();
        $hotlf = new HierarchyObjectTypeListFactory();
        if ($permission->Check('request', 'authorize')) {
            //Debug::Text('Request: Selected Level: '. $selected_levels['request'], __FILE__, __LINE__, __METHOD__,10);
            $request_levels = $hllf->getLevelsByUserIdAndObjectTypeID($current_user->getId(), 50);
            Debug::Arr($request_levels, 'Request Levels', __FILE__, __LINE__, __METHOD__, 10);
            if (isset($selected_levels['request']) and isset($request_levels[$selected_levels['request']])) {
                $request_selected_level = $request_levels[$selected_levels['request']];
                Debug::Text(' Switching Levels to Level: ' . $request_selected_level, __FILE__, __LINE__, __METHOD__, 10);
            } elseif (isset($request_levels[1])) {
                $request_selected_level = $request_levels[1];
            } else {
                Debug::Text('No Request Levels... Not in hierarchy?', __FILE__, __LINE__, __METHOD__, 10);
                $request_selected_level = 0;
            }
 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 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 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;
 }
Esempio n. 12
0
 function postSave()
 {
     $this->removeCache($this->getId());
     if ($this->getDeleted() == FALSE and $this->getPermissionControl() !== FALSE) {
         Debug::text('Permission Group is set...', __FILE__, __LINE__, __METHOD__, 10);
         $pclf = new PermissionControlListFactory();
         $pclf->getByCompanyIdAndUserID($this->getCompany(), $this->getId());
         if ($pclf->getRecordCount() > 0) {
             Debug::text('Already assigned to a Permission Group...', __FILE__, __LINE__, __METHOD__, 10);
             $pc_obj = $pclf->getCurrent();
             if ($pc_obj->getId() == $this->getPermissionControl()) {
                 $add_permission_control = FALSE;
             } else {
                 Debug::text('Permission Group has changed...', __FILE__, __LINE__, __METHOD__, 10);
                 //Remove user from current schedule.
                 $pulf = new PermissionUserListFactory();
                 $pulf->getByPermissionControlIdAndUserID($pc_obj->getId(), $this->getId());
                 Debug::text('Record Count: ' . $pulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
                 if ($pulf->getRecordCount() > 0) {
                     foreach ($pulf as $pu_obj) {
                         Debug::text('Deleteing from Permission Group: ' . $pu_obj->getPermissionControl(), __FILE__, __LINE__, __METHOD__, 10);
                         $pu_obj->Delete();
                     }
                 }
                 $add_permission_control = TRUE;
             }
         } else {
             Debug::text('NOT Already assigned to a Permission Group...', __FILE__, __LINE__, __METHOD__, 10);
             $add_permission_control = TRUE;
         }
         if ($this->getPermissionControl() !== FALSE and $add_permission_control == TRUE) {
             Debug::text('Adding user to Permission Group...', __FILE__, __LINE__, __METHOD__, 10);
             //Add to new permission group
             $puf = new PermissionUserFactory();
             $puf->setPermissionControl($this->getPermissionControl());
             $puf->setUser($this->getID());
             if ($puf->isValid()) {
                 $puf->Save();
                 //Clear permission class for this employee.
                 $pf = new PermissionFactory();
                 $pf->clearCache($this->getID(), $this->getCompany());
             }
         }
         unset($add_permission_control);
     }
     if ($this->getDeleted() == FALSE and $this->getPayPeriodSchedule() !== FALSE) {
         Debug::text('Pay Period Schedule is set...', __FILE__, __LINE__, __METHOD__, 10);
         $ppslf = new PayPeriodScheduleListFactory();
         $ppslf->getByUserId($this->getId());
         if ($ppslf->getRecordCount() > 0) {
             $pps_obj = $ppslf->getCurrent();
             if ($this->getPayPeriodSchedule() == $pps_obj->getId()) {
                 Debug::text('Already assigned to this Pay Period Schedule...', __FILE__, __LINE__, __METHOD__, 10);
                 $add_pay_period_schedule = FALSE;
             } else {
                 Debug::text('Changing Pay Period Schedule...', __FILE__, __LINE__, __METHOD__, 10);
                 //Remove user from current schedule.
                 $ppsulf = new PayPeriodScheduleUserListFactory();
                 $ppsulf->getByPayPeriodScheduleIdAndUserID($pps_obj->getId(), $this->getId());
                 Debug::text('Record Count: ' . $ppsulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
                 if ($ppsulf->getRecordCount() > 0) {
                     foreach ($ppsulf as $ppsu_obj) {
                         Debug::text('Deleteing from Pay Period Schedule: ' . $ppsu_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10);
                         $ppsu_obj->Delete();
                     }
                 }
                 $add_pay_period_schedule = TRUE;
             }
         } else {
             Debug::text('Not assigned to ANY Pay Period Schedule...', __FILE__, __LINE__, __METHOD__, 10);
             $add_pay_period_schedule = TRUE;
         }
         if ($this->getPayPeriodSchedule() !== FALSE and $add_pay_period_schedule == TRUE) {
             //Add to new pay period schedule
             $ppsuf = new PayPeriodScheduleUserFactory();
             $ppsuf->setPayPeriodSchedule($this->getPayPeriodSchedule());
             $ppsuf->setUser($this->getID());
             if ($ppsuf->isValid()) {
                 $ppsuf->Save();
             }
         }
         unset($add_pay_period_schedule);
     }
     if ($this->getDeleted() == FALSE and $this->getPolicyGroup() !== FALSE) {
         Debug::text('Policy Group is set...', __FILE__, __LINE__, __METHOD__, 10);
         $pglf = new PolicyGroupListFactory();
         $pglf->getByUserIds($this->getId());
         if ($pglf->getRecordCount() > 0) {
             $pg_obj = $pglf->getCurrent();
             if ($this->getPolicyGroup() == $pg_obj->getId()) {
                 Debug::text('Already assigned to this Policy Group...', __FILE__, __LINE__, __METHOD__, 10);
                 $add_policy_group = FALSE;
             } else {
                 Debug::text('Changing Policy Group...', __FILE__, __LINE__, __METHOD__, 10);
                 //Remove user from current schedule.
                 $pgulf = new PolicyGroupUserListFactory();
                 $pgulf->getByPolicyGroupIdAndUserId($pg_obj->getId(), $this->getId());
                 Debug::text('Record Count: ' . $pgulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
                 if ($pgulf->getRecordCount() > 0) {
                     foreach ($pgulf as $pgu_obj) {
                         Debug::text('Deleteing from Policy Group: ' . $pgu_obj->getPolicyGroup(), __FILE__, __LINE__, __METHOD__, 10);
                         $pgu_obj->Delete();
                     }
                 }
                 $add_policy_group = TRUE;
             }
         } else {
             Debug::text('Not assigned to ANY Policy Group...', __FILE__, __LINE__, __METHOD__, 10);
             $add_policy_group = TRUE;
         }
         if ($this->getPolicyGroup() !== FALSE and $add_policy_group == TRUE) {
             //Add to new policy group
             $pguf = new PolicyGroupUserFactory();
             $pguf->setPolicyGroup($this->getPolicyGroup());
             $pguf->setUser($this->getID());
             if ($pguf->isValid()) {
                 $pguf->Save();
             }
         }
         unset($add_policy_group);
     }
     if ($this->getDeleted() == FALSE and $this->getHierarchyControl() !== FALSE) {
         Debug::text('Hierarchies are set...', __FILE__, __LINE__, __METHOD__, 10);
         $hierarchy_control_data = array_unique(array_values((array) $this->getHierarchyControl()));
         //Debug::Arr($hierarchy_control_data, 'Setting hierarchy control data...', __FILE__, __LINE__, __METHOD__, 10);
         if (is_array($hierarchy_control_data)) {
             $hclf = new HierarchyControlListFactory();
             $hclf->getObjectTypeAppendedListByCompanyIDAndUserID($this->getCompany(), $this->getID());
             $existing_hierarchy_control_data = array_unique(array_values((array) $hclf->getArrayByListFactory($hclf, FALSE, TRUE, FALSE)));
             //Debug::Arr($existing_hierarchy_control_data, 'Existing hierarchy control data...', __FILE__, __LINE__, __METHOD__, 10);
             $hierarchy_control_delete_diff = array_diff($existing_hierarchy_control_data, $hierarchy_control_data);
             //Debug::Arr($hierarchy_control_delete_diff, 'Hierarchy control delete diff: ', __FILE__, __LINE__, __METHOD__, 10);
             //Remove user from existing hierarchy control
             if (is_array($hierarchy_control_delete_diff)) {
                 foreach ($hierarchy_control_delete_diff as $hierarchy_control_id) {
                     if ($hierarchy_control_id != 0) {
                         $hulf = new HierarchyUserListFactory();
                         $hulf->getByHierarchyControlAndUserID($hierarchy_control_id, $this->getID());
                         if ($hulf->getRecordCount() > 0) {
                             Debug::text('Deleting user from hierarchy control ID: ' . $hierarchy_control_id, __FILE__, __LINE__, __METHOD__, 10);
                             $hulf->getCurrent()->Delete();
                         }
                     }
                 }
             }
             unset($hierarchy_control_delete_diff, $hulf, $hclf, $hierarchy_control_id);
             $hierarchy_control_add_diff = array_diff($hierarchy_control_data, $existing_hierarchy_control_data);
             //Debug::Arr($hierarchy_control_add_diff, 'Hierarchy control add diff: ', __FILE__, __LINE__, __METHOD__, 10);
             if (is_array($hierarchy_control_add_diff)) {
                 foreach ($hierarchy_control_add_diff as $hierarchy_control_id) {
                     Debug::text('Hierarchy data changed...', __FILE__, __LINE__, __METHOD__, 10);
                     if ($hierarchy_control_id != 0) {
                         $huf = new HierarchyUserFactory();
                         $huf->setHierarchyControl($hierarchy_control_id);
                         $huf->setUser($this->getId());
                         if ($huf->isValid()) {
                             Debug::text('Adding user to hierarchy control ID: ' . $hierarchy_control_id, __FILE__, __LINE__, __METHOD__, 10);
                             $huf->Save();
                         }
                     }
                 }
             }
             unset($hierarchy_control_add, $huf, $hierarchy_control_id);
         }
     }
     if (isset($this->is_new) and $this->is_new == TRUE) {
         $udlf = new UserDefaultListFactory();
         $udlf->getByCompanyId($this->getCompany());
         if ($udlf->getRecordCount() > 0) {
             Debug::Text('Using User Defaults', __FILE__, __LINE__, __METHOD__, 10);
             $udf_obj = $udlf->getCurrent();
             Debug::text('Inserting Default Deductions...', __FILE__, __LINE__, __METHOD__, 10);
             $company_deduction_ids = $udf_obj->getCompanyDeduction();
             if (is_array($company_deduction_ids) and count($company_deduction_ids) > 0) {
                 foreach ($company_deduction_ids as $company_deduction_id) {
                     $udf = new UserDeductionFactory();
                     $udf->setUser($this->getId());
                     $udf->setCompanyDeduction($company_deduction_id);
                     if ($udf->isValid()) {
                         $udf->Save();
                     }
                 }
             }
             unset($company_deduction_ids, $company_deduction_id, $udf);
             Debug::text('Inserting Default Prefs...', __FILE__, __LINE__, __METHOD__, 10);
             $upf = new UserPreferenceFactory();
             $upf->setUser($this->getId());
             $upf->setLanguage($udf_obj->getLanguage());
             $upf->setDateFormat($udf_obj->getDateFormat());
             $upf->setTimeFormat($udf_obj->getTimeFormat());
             $upf->setTimeUnitFormat($udf_obj->getTimeUnitFormat());
             $upf->setTimeZone($udf_obj->getTimeZone());
             $upf->setItemsPerPage($udf_obj->getItemsPerPage());
             $upf->setStartWeekDay($udf_obj->getStartWeekDay());
             $upf->setEnableEmailNotificationException($udf_obj->getEnableEmailNotificationException());
             $upf->setEnableEmailNotificationMessage($udf_obj->getEnableEmailNotificationMessage());
             $upf->setEnableEmailNotificationHome($udf_obj->getEnableEmailNotificationHome());
             if ($upf->isValid()) {
                 $upf->Save();
             }
         }
     }
     if ($this->getDeleted() == TRUE) {
         //Remove them from the authorization hierarchy, policy group, and pay period schedule.
         //Delete any accruals for them as well.
         //Pay Period Schedule
         $ppslf = new PayPeriodScheduleListFactory();
         $ppslf->getByUserId($this->getId());
         if ($ppslf->getRecordCount() > 0) {
             $pps_obj = $ppslf->getCurrent();
             //Remove user from current schedule.
             $ppsulf = new PayPeriodScheduleUserListFactory();
             $ppsulf->getByPayPeriodScheduleIdAndUserID($pps_obj->getId(), $this->getId());
             Debug::text('Record Count: ' . $ppsulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             if ($ppsulf->getRecordCount() > 0) {
                 foreach ($ppsulf as $ppsu_obj) {
                     Debug::text('Deleteing from Pay Period Schedule: ' . $ppsu_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10);
                     $ppsu_obj->Delete();
                 }
             }
         }
         //Policy Group
         $pglf = new PolicyGroupListFactory();
         $pglf->getByUserIds($this->getId());
         if ($pglf->getRecordCount() > 0) {
             $pg_obj = $pglf->getCurrent();
             $pgulf = new PolicyGroupUserListFactory();
             $pgulf->getByPolicyGroupIdAndUserId($pg_obj->getId(), $this->getId());
             Debug::text('Record Count: ' . $pgulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             if ($pgulf->getRecordCount() > 0) {
                 foreach ($pgulf as $pgu_obj) {
                     Debug::text('Deleteing from Policy Group: ' . $pgu_obj->getPolicyGroup(), __FILE__, __LINE__, __METHOD__, 10);
                     $pgu_obj->Delete();
                 }
             }
         }
         //Hierarchy
         $hclf = new HierarchyControlListFactory();
         $hclf->getByCompanyId($this->getCompany());
         if ($hclf->getRecordCount() > 0) {
             foreach ($hclf as $hc_obj) {
                 $hf = new HierarchyListFactory();
                 $hf->setUser($this->getID());
                 $hf->setHierarchyControl($hc_obj->getId());
                 $hf->Delete();
             }
             $hf->removeCache(NULL, $hf->getTable(TRUE));
             //On delete we have to delete the entire group.
             unset($hf);
         }
         //Accrual balances
         $alf = new AccrualListFactory();
         $alf->getByUserIdAndCompanyId($this->getId(), $this->getCompany());
         if ($alf->getRecordCount() > 0) {
             foreach ($alf as $a_obj) {
                 $a_obj->setDeleted(TRUE);
                 if ($a_obj->isValid()) {
                     $a_obj->Save();
                 }
             }
         }
     }
     return TRUE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Go through all pay period schedules and update the annual pay period column
     $ppslf = new PayPeriodScheduleListFactory();
     $ppslf->getAll();
     if ($ppslf->getRecordCount() > 0) {
         foreach ($ppslf as $pps_obj) {
             $pps_obj->setAnnualPayPeriods($pps_obj->calcAnnualPayPeriods());
             if ($pps_obj->isValid()) {
                 $pps_obj->Save();
             }
         }
     }
     //Go through all employee wages and update HourlyRate to the accurate annual hourly rate.
     //**Handle this in 1034A postInstall() instead, as it needs to handle incorrect effective_dates properly.
     /*
     $uwlf = new UserWageListFactory();
     $uwlf->getAll();
     if ( $uwlf->getRecordCount() > 0 ) {
     	foreach( $uwlf as $uw_obj ) {
     		$uw_obj->setHourlyRate( $uw_obj->calcHourlyRate( time(), TRUE ) );
     		if ( $uw_obj->isValid() ) {
     			$uw_obj->Save();
     		}
     	}
     }
     */
     //Upgrade to new hierarchy format.
     $clf = new CompanyListFactory();
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         foreach ($clf as $c_obj) {
             if ($c_obj->getStatus() != 30) {
                 /*
                 					if ( !($c_obj->getId() == 1052) ) { //$c_obj->getId() == 1009 OR $c_obj->getId() == 1087 OR
                 						continue;
                 					}
                 */
                 $company_id = $c_obj->getId();
                 Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
                 $hclf = new HierarchyControlListFactory();
                 $hclf->StartTransaction();
                 $hclf->getByCompanyId($company_id);
                 if ($hclf->getRecordCount() > 0) {
                     foreach ($hclf as $hc_obj) {
                         $paths_to_root = array();
                         $hierarchy_id = $hc_obj->getId();
                         $hlf = new HierarchyListFactory();
                         $hierarchy_users = $hlf->getByCompanyIdAndHierarchyControlId($company_id, $hierarchy_id);
                         if (is_array($hierarchy_users) and count($hierarchy_users) > 0) {
                             $hotlf = new HierarchyObjectTypeListFactory();
                             $hotlf->getByHierarchyControlId($hierarchy_id);
                             if ($hotlf->getRecordCount() > 0) {
                                 foreach ($hotlf as $hot_obj) {
                                     $object_types[$hierarchy_id][] = $hot_obj->getObjectType();
                                 }
                             }
                             foreach ($hierarchy_users as $hierarchy_user_arr) {
                                 Debug::Text(' Checking User ID: ' . $hierarchy_user_arr['id'], __FILE__, __LINE__, __METHOD__, 10);
                                 $id = $hierarchy_user_arr['id'];
                                 $tmp_id = $id;
                                 $i = 0;
                                 do {
                                     Debug::Text(' Iteration...', __FILE__, __LINE__, __METHOD__, 10);
                                     $hlf_b = new HierarchyListFactory();
                                     $parents = $hlf_b->getParentLevelIdArrayByHierarchyControlIdAndUserId($hierarchy_id, $tmp_id);
                                     sort($parents);
                                     $level = $hlf_b->getFastTreeObject()->getLevel($tmp_id) - 1;
                                     if (is_array($parents) and count($parents) > 0) {
                                         $parent_users = array();
                                         foreach ($parents as $user_id) {
                                             $parent_users[] = $user_id;
                                             unset($user);
                                         }
                                         $parent_groups[$level] = $parent_users;
                                         unset($parent_users);
                                     }
                                     if (isset($parents[0])) {
                                         $tmp_id = $parents[0];
                                     }
                                     $i++;
                                 } while (is_array($parents) and count($parents) > 0 and $i < 100);
                                 if (isset($parent_groups)) {
                                     $serialized_path = serialize($parent_groups);
                                     $paths_to_root[$serialized_path][] = $id;
                                     unset($serialized_path);
                                 }
                                 unset($parent_groups, $parents);
                             }
                         }
                         Debug::Arr($paths_to_root, ' Paths To Root: ', __FILE__, __LINE__, __METHOD__, 10);
                         //Decode path_to_root array
                         if (isset($paths_to_root) and count($paths_to_root) > 0) {
                             foreach ($paths_to_root as $serialized_path => $children) {
                                 $path_arr = unserialize($serialized_path);
                                 $decoded_paths[] = array('hierarchy_control_id' => $hierarchy_id, 'path' => $path_arr, 'children' => $children);
                             }
                             unset($path_arr, $children);
                             Debug::Arr($decoded_paths, ' Decoded Paths: ', __FILE__, __LINE__, __METHOD__, 10);
                             if (isset($decoded_paths) and is_array($decoded_paths)) {
                                 foreach ($decoded_paths as $decoded_path) {
                                     Debug::Text(' Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
                                     //Create new hierarchy_control
                                     $hcf = new HierarchyControlFactory();
                                     $hcf->setCompany($company_id);
                                     $hcf->setObjectType($object_types[$decoded_path['hierarchy_control_id']]);
                                     //Generate meaningful name
                                     $name = FALSE;
                                     if (isset($decoded_path['path']) and is_array($decoded_path['path'])) {
                                         ksort($decoded_path['path']);
                                         //Sort by level.
                                         foreach ($decoded_path['path'] as $level => $superior_ids) {
                                             foreach ($superior_ids as $superior_id) {
                                                 $ulf = new UserListFactory();
                                                 $ulf->getById($superior_id);
                                                 if ($ulf->getRecordCount() > 0) {
                                                     $name[] = $level . '. ' . $ulf->getCurrent()->getFullName();
                                                 }
                                             }
                                         }
                                         unset($level, $superior_ids, $superior_id);
                                     }
                                     if (isset($name)) {
                                         $name = $hc_obj->getName() . ' ' . implode(', ', $name) . ' (#' . rand(1000, 9999) . ')';
                                     } else {
                                         $name = $hc_obj->getName() . ' (#' . rand(1000, 9999) . ')';
                                     }
                                     $hcf->setName(substr($name, 0, 249));
                                     $hcf->setDescription(TTi18n::getText('Automatically created by TimeTrex'));
                                     if ($hcf->isValid()) {
                                         $hc_id = $hcf->Save(FALSE);
                                         Debug::Text('Hierarchy Control ID: ' . $hc_id, __FILE__, __LINE__, __METHOD__, 10);
                                         $hcf->setUser($decoded_path['children']);
                                         if (isset($decoded_path['path']) and is_array($decoded_path['path'])) {
                                             foreach ($decoded_path['path'] as $level => $superior_ids) {
                                                 foreach ($superior_ids as $superior_id) {
                                                     $hlf = new HierarchyLevelFactory();
                                                     $hlf->setHierarchyControl($hc_id);
                                                     $hlf->setLevel($level);
                                                     $hlf->setUser($superior_id);
                                                     if ($hlf->isValid()) {
                                                         $hlf->Save();
                                                         Debug::Text('Saving Level Row ID... User ID: ' . $superior_id, __FILE__, __LINE__, __METHOD__, 10);
                                                     }
                                                 }
                                             }
                                             unset($level, $superior_ids, $superior_id);
                                         }
                                     }
                                 }
                             }
                             unset($decoded_paths);
                         }
                         //Delete existing hierarchy control.
                         $hc_obj->setDeleted(TRUE);
                         if ($hc_obj->isValid() == TRUE) {
                             $hc_obj->Save();
                         }
                     }
                 }
                 //$hclf->FailTransaction();
                 $hclf->CommitTransaction();
             }
         }
     }
     //Go through each permission group, and enable break policies for anyone who can see meal policies
     $clf = new CompanyListFactory();
     $clf->getAll();
     if ($clf->getRecordCount() > 0) {
         foreach ($clf as $c_obj) {
             Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
             if ($c_obj->getStatus() != 30) {
                 $pclf = new PermissionControlListFactory();
                 $pclf->getByCompanyId($c_obj->getId());
                 if ($pclf->getRecordCount() > 0) {
                     foreach ($pclf as $pc_obj) {
                         Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9);
                         $plf = new PermissionListFactory();
                         $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'meal_policy', 'enabled');
                         if ($plf->getRecordCount() > 0) {
                             Debug::text('Found permission group with meal policy enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9);
                             $pc_obj->setPermission(array('break_policy' => array('enabled' => TRUE, 'view' => TRUE, 'add' => TRUE, 'edit' => TRUE, 'delete' => TRUE)));
                         } else {
                             Debug::text('Permission group does NOT have meal policy enabled...', __FILE__, __LINE__, __METHOD__, 9);
                         }
                     }
                 }
             }
         }
     }
     //Add MiscDaily cronjob to database.
     $cjf = new CronJobFactory();
     $cjf->setName('MiscDaily');
     $cjf->setMinute(55);
     $cjf->setHour(1);
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand('MiscDaily.php');
     $cjf->Save();
     //Add MiscWeekly cronjob to database.
     $cjf = new CronJobFactory();
     $cjf->setName('MiscWeekly');
     $cjf->setMinute(55);
     $cjf->setHour(1);
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('0');
     //Sunday morning.
     $cjf->setCommand('MiscWeekly.php');
     $cjf->Save();
     return TRUE;
 }
Esempio n. 14
0
        //Get user info
        $ulf = new UserListFactory();
        if ($message->isAck() == FALSE) {
            $require_ack = TRUE;
        }
        if ($message->getRequireAck() == TRUE) {
            $show_ack_column = TRUE;
        }
        $messages[] = array('id' => $message->getId(), 'parent_id' => $message->getParent(), 'object_type_id' => $message->getObjectType(), 'object_type' => $object_name_options[$message->getObjectType()], 'object_id' => $message->getObject(), 'priority' => $message->getPriority(), 'status_id' => $message->getStatus(), 'require_ack' => $message->getRequireAck(), 'ack_date' => $message->getAckDate(), 'subject' => Misc::TruncateString($message->getSubject(), 20), 'body' => $message->getBody(), 'created_date' => $message->getCreatedDate(), 'created_by' => $message->getCreatedBy(), 'created_by_full_name' => $ulf->getById($message->getCreatedBy())->getIterator()->current()->getFullName(), 'updated_date' => $message->getUpdatedDate(), 'updated_by' => $message->getUpdatedBy(), 'deleted_date' => $message->getDeletedDate(), 'deleted_by' => $message->getDeletedBy());
    }
}
$smarty->assign_by_ref('messages', $messages);
//Grab requests pending authorization if they are a supervisor.
if ($permission->Check('authorization', 'enabled') and $permission->Check('authorization', 'view') and $permission->Check('request', 'authorize')) {
    $ulf = new UserListFactory();
    $hlf = new HierarchyListFactory();
    $hllf = new HierarchyLevelListFactory();
    $request_levels = $hllf->getLevelsByUserIdAndObjectTypeID($current_user->getId(), 50);
    //Debug::Arr( $request_levels, 'Request Levels', __FILE__, __LINE__, __METHOD__,10);
    $request_hierarchy_user_ids = $hlf->getByUserIdAndObjectTypeIDAndLevel($current_user->getId(), 50, 1);
    //Debug::Arr( $request_hierarchy_user_ids, 'Request Hierarchy Ids', __FILE__, __LINE__, __METHOD__,10);
    if (is_array($request_hierarchy_user_ids) and isset($request_hierarchy_user_ids['child_level']) and isset($request_hierarchy_user_ids['parent_level']) and isset($request_hierarchy_user_ids['current_level'])) {
        $rlf = new RequestListFactory();
        //$rlf->getByUserIdListAndStatusAndNotAuthorized($request_hierarchy_user_ids['child_level'], 30, $request_hierarchy_user_ids['parent_level'], $request_hierarchy_user_ids['current_level'] );
        $rlf->getByUserIdListAndStatusAndLevelAndMaxLevelAndNotAuthorized($request_hierarchy_user_ids['child_level'], 30, 1, (int) end($request_levels));
        $status_options = $rlf->getOptions('status');
        $type_options = $rlf->getOptions('type');
        foreach ($rlf as $r_obj) {
            //Grab authorizations for this object.
            $pending_requests[] = array('id' => $r_obj->getId(), 'user_date_id' => $r_obj->getId(), 'user_id' => $r_obj->getUserDateObject()->getUser(), 'user_full_name' => $r_obj->getUserDateObject()->getUserObject()->getFullName(), 'date_stamp' => $r_obj->getUserDateObject()->getDateStamp(), 'type_id' => $r_obj->getType(), 'type' => $type_options[$r_obj->getType()], 'status_id' => $r_obj->getStatus(), 'status' => $status_options[$r_obj->getStatus()]);
        }