/** * Track a view for a particular bean. * * @param SugarBean $seed * @param string $current_view */ function trackView($seed, $current_view) { $trackerManager = TrackerManager::getInstance(); if ($monitor = $trackerManager->getMonitor('tracker')) { $monitor->setValue('date_modified', TimeDate::getInstance()->nowDb()); $monitor->setValue('user_id', $GLOBALS['current_user']->id); $monitor->setValue('module_name', $seed->module_dir); $monitor->setValue('action', $current_view); $monitor->setValue('item_id', $seed->id); $monitor->setValue('item_summary', $seed->get_summary_text()); $monitor->setValue('visible', true); $trackerManager->saveMonitor($monitor, TRUE, TRUE); } }
/** * Returns an array composing of the breadcrumbs to use for the module title * * @param bool $browserTitle true if the returned string is being used for the browser title, meaning * there should be no HTML in the string * * @return array */ protected function _getModuleTitleParams($browserTitle = false) { $params = [$this->_getModuleTitleListParam($browserTitle)]; if (isset($this->action)) { switch ($this->action) { case 'EditView': if (!empty($this->bean->id) && (empty($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] === 'false')) { $params[] = "<a href='index.php?module={$this->module}&action=DetailView&record={$this->bean->id}'>" . $this->bean->get_summary_text() . "</a>"; $params[] = $GLOBALS['app_strings']['LBL_EDIT_BUTTON_LABEL']; } else { $params[] = $GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']; } break; case 'DetailView': $beanName = $this->bean->get_summary_text(); $params[] = $beanName; break; } } return $params; }
/** * Adds an entry in the tracker table noting that this record was touched * * @param SugarBean $bean The bean to record in the tracker table */ public function trackAction(SugarBean $bean) { $manager = $this->getTrackerManager(); $monitor = $manager->getMonitor('tracker'); if (!$monitor) { // This tracker is disabled. return; } if (empty($bean->id) || isset($bean->new_with_id) && $bean->new_with_id) { // It's a new bean, don't record it. // Tracking bean saves/creates happens in the SugarBean so it is always recorded return; } $monitor->setValue('team_id', $this->api->user->getPrivateTeamID()); $monitor->setValue('action', $this->action); $monitor->setValue('user_id', $this->api->user->id); $monitor->setValue('module_name', $bean->module_dir); $monitor->setValue('date_modified', TimeDate::getInstance()->nowDb()); $monitor->setValue('visible', 1); $monitor->setValue('item_id', $bean->id); $monitor->setValue('item_summary', $bean->get_summary_text()); $manager->saveMonitor($monitor, true, true); }
function getRecordSummary(SugarBean $bean) { global $listViewDefs; if (!isset($listViewDefs) || !isset($listViewDefs[$bean->module_dir])) { if (file_exists('custom/modules/' . $bean->module_dir . '/metadata/listviewdefs.php')) { require 'custom/modules/' . $bean->module_dir . '/metadata/listviewdefs.php'; } else { if (file_exists('modules/' . $bean->module_dir . '/metadata/listviewdefs.php')) { require 'modules/' . $bean->module_dir . '/metadata/listviewdefs.php'; } } } if (!isset($listViewDefs) || !isset($listViewDefs[$bean->module_dir])) { return $bean->get_summary_text(); } $summary = array(); foreach ($listViewDefs[$bean->module_dir] as $key => $entry) { if (!$entry['default']) { continue; } $key = strtolower($key); if (in_array($key, array('date_entered', 'date_modified', 'name'))) { continue; } $summary[] = $bean->{$key}; } $summary = array_filter($summary); return implode(' || ', $summary); }
/** * Helper to denormalize critical bean attributes. * * @param SugarBean $bean * * @return array Contains name, type, module and ID of the bean. */ public static function getBeanAttributes(SugarBean $bean) { return array('name' => $bean->get_summary_text(), 'type' => $bean->object_name, 'module' => $bean->module_name, 'id' => $bean->id); }
public function getSummaryText() { if ($this->bean !== FALSE) { return $this->bean->get_summary_text(); } }