Esempio n. 1
0
}
if (isset($config_vars)) {
    $smarty->assign_by_ref('config_vars', $config_vars);
}
if (TTi18n::getLanguage() != '') {
    $smarty->assign('CALENDAR_LANG', TTi18n::getLanguage());
} else {
    $smarty->assign('CALENDAR_LANG', 'en');
}
if (isset($current_user)) {
    $smarty->assign_by_ref('current_user', $current_user);
    $smarty->assign_by_ref('current_user_prefs', $current_user_prefs);
    if (!isset($skip_message_check)) {
        $profiler->startTimer("Interface.inc - Check for UNREAD messages...");
        //CHeck for unread messages
        $mlf = new MessageListFactory();
        $unread_messages = $mlf->getNewMessagesByUserId($current_user->getId());
        Debug::text('UnRead Messages: ' . $unread_messages, __FILE__, __LINE__, __METHOD__, 10);
        $smarty->assign_by_ref('unread_messages', $unread_messages);
        if (isset($_COOKIE['newMailPopUp'])) {
            $smarty->assign_by_ref('newMailPopUp', $_COOKIE['newMailPopUp']);
        }
        unset($mlf);
        $profiler->stopTimer("Interface.inc - Check for UNREAD messages...");
        $profiler->startTimer("Interface.inc - Check for Exceptions");
        $elf = new ExceptionListFactory();
        $elf->getFlaggedExceptionsByUserIdAndPayPeriodStatus($current_user->getId(), 10);
        $display_exception_flag = FALSE;
        if ($elf->getRecordCount() > 0) {
            foreach ($elf as $e_obj) {
                if ($e_obj->getColumn('severity_id') == 30) {
             Redirect::Page(URLBuilder::getURL(array('template' => $template, 'close' => 1, 'object_type_id' => $object_type_id, 'object_id' => $object_id), 'EmbeddedMessageList.php'));
             break;
         }
     }
 default:
     if (isset($object_type_id) and isset($object_id)) {
         $mlf = new MessageListFactory();
         $mlf->getByObjectTypeAndObject($object_type_id, $object_id);
         $i = 0;
         foreach ($mlf as $message) {
             //Get user info
             $ulf = new UserListFactory();
             $messages[] = array('id' => $message->getId(), 'parent_id' => $message->getParent(), 'object_type' => $message->getObjectType(), 'object_id' => $message->getObject(), 'priority' => $message->getPriority(), 'status' => $message->getStatus(), 'subject' => $message->getSubject(), 'body' => $message->getBody(), 'created_date' => $message->getCreatedDate(), 'created_by' => $message->getCreatedBy(), 'created_by_full_name' => $ulf->getById($message->getCreatedBy())->getCurrent()->getFullName(), 'updated_date' => $message->getUpdatedDate(), 'updated_by' => $message->getUpdatedBy(), 'deleted_date' => $message->getDeletedDate(), 'deleted_by' => $message->getDeletedBy());
             //Mark own messages as read.
             if ($message->getCreatedBy() != $current_user->getId()) {
                 $mlf_b = new MessageListFactory();
                 $message_obj = $mlf_b->getById($message->getId())->getCurrent();
                 $message_obj->setStatus(20);
                 $message_obj->Save();
             }
             if ($i == 0) {
                 $parent_id = $message->getId();
                 $default_subject = TTi18n::gettext('Re:') . ' ' . $message->getSubject();
             }
             $i++;
         }
         //Get object data
         $object_name_options = $mlf->getOptions('object_name');
         $smarty->assign_by_ref('object_name', $object_name_options[$object_type_id]);
         $smarty->assign_by_ref('messages', $messages);
         $smarty->assign_by_ref('message_data', $message_data);
 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;
 }
Esempio n. 4
0
         $mlf = new MessageListFactory();
         $mlf->StartTransaction();
         foreach ($ids as $id) {
             //Only allow them to delete message they created.
             $mlf->getByCompanyIdAndUserIdAndId($current_company->getId(), $current_user->getId(), $id);
             foreach ($mlf as $m_obj) {
                 $m_obj->setDeleted($delete);
                 $m_obj->Save();
             }
         }
         $mlf->CommitTransaction();
     }
     Redirect::Page(URLBuilder::getURL(array('filter_folder_id' => $filter_folder_id), 'UserMessageList.php'));
     break;
 default:
     $mlf = new MessageListFactory();
     $folder_options = $mf->getOptions('folder');
     Debug::text('Filter Folder ID: ' . $filter_folder_id, __FILE__, __LINE__, __METHOD__, 9);
     if (!isset($filter_folder_id) or !in_array($filter_folder_id, array_keys($folder_options))) {
         Debug::text('Invalid Folder, using default ', __FILE__, __LINE__, __METHOD__, 9);
         $filter_folder_id = 10;
     }
     //Make sure folder and sort columns stays as we switch pages.
     URLBuilder::setURL(NULL, array('filter_folder_id' => $filter_folder_id, 'sort_column' => $sort_column, 'sort_order' => $sort_order));
     $mlf->getByUserIdAndFolder($current_user->getId(), $filter_folder_id, $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
     $object_name_options = $mlf->getOptions('object_name');
     $pager = new Pager($mlf);
     $require_ack = FALSE;
     foreach ($mlf as $message) {
         //Get user info
         $ulf = new UserListFactory();
Esempio n. 5
0
}
unset($elf, $e_obj);
$smarty->assign_by_ref('exceptions', $exceptions);
//Grab list of recent requests
$rlf = new RequestListFactory();
$rlf->getByUserIDAndCompanyId($current_user->getId(), $current_company->getId(), 5, 1);
if ($rlf->getRecordCount() > 0) {
    $status_options = $rlf->getOptions('status');
    $type_options = $rlf->getOptions('type');
    foreach ($rlf as $r_obj) {
        $requests[] = array('id' => $r_obj->getId(), 'user_date_id' => $r_obj->getUserDateID(), 'date_stamp' => TTDate::strtotime($r_obj->getColumn('date_stamp')), 'status_id' => $r_obj->getStatus(), 'status' => Misc::TruncateString($status_options[$r_obj->getStatus()], 15), 'type_id' => $r_obj->getType(), 'type' => $type_options[$r_obj->getType()], 'created_date' => $r_obj->getCreatedDate(), 'deleted' => $r_obj->getDeleted());
    }
}
$smarty->assign_by_ref('requests', $requests);
//Grab list of unread messages
$mlf = new MessageListFactory();
$mlf->getByUserIdAndFolder($current_user->getId(), 10, 5, 1);
if ($mlf->getRecordCount() > 0) {
    $object_name_options = $mlf->getOptions('object_name');
    $require_ack = FALSE;
    foreach ($mlf as $message) {
        //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());
    }