Esempio n. 1
0
 public function tearDown()
 {
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestTrackerUtility::removeAllTrackerEntries();
     unset($GLOBALS['current_user']);
     unset($GLOBALS['app_strings']);
 }
 public static function insertTrackerEntry($bean, $action)
 {
     require_once 'modules/Trackers/TrackerManager.php';
     $trackerManager = TrackerManager::getInstance();
     $timeStamp = gmdate($GLOBALS['timedate']->get_db_date_time_format());
     $_REQUEST['action'] = $action;
     if ($monitor = $trackerManager->getMonitor('tracker')) {
         $monitor->setValue('action', $action);
         $monitor->setValue('user_id', $GLOBALS['current_user']->id);
         $monitor->setValue('module_name', $bean->module_dir);
         $monitor->setValue('date_modified', $timeStamp);
         $monitor->setValue('visible', $action == 'detailview' || $action == 'editview' ? 1 : 0);
         if (!empty($bean->id)) {
             $monitor->setValue('item_id', $bean->id);
             $monitor->setValue('item_summary', $bean->get_summary_text());
         }
         //If visible is true, but there is no bean, do not track (invalid/unauthorized reference)
         //Also, do not track save actions where there is no bean id
         if ($monitor->visible && empty($bean->id)) {
             $trackerManager->unsetMonitor($monitor);
             return false;
         }
         $trackerManager->saveMonitor($monitor, true, true);
         if (empty(self::$_monitorId)) {
             self::$_monitorId = $monitor->monitor_id;
         }
     }
 }