Add php files
This commit is contained in:
253
modules/Trackers/BreadCrumbStack.php
Executable file
253
modules/Trackers/BreadCrumbStack.php
Executable file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
class BreadCrumbStack {
|
||||
|
||||
/**
|
||||
* Maintain an ordered list of items in the breadcrumbs
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
private $stack;
|
||||
/**
|
||||
* Maps an item_id to the position index in stack
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
private $stackMap;
|
||||
/**
|
||||
* Boolean flag to determine whether or not entries not visible should be removed
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
private $deleteInvisible = false;
|
||||
|
||||
|
||||
/**
|
||||
* BreadCrumbStack
|
||||
* Constructor for BreadCrumbStack that builds list of breadcrumbs using tracker table
|
||||
*
|
||||
* @param $user_id String value of user id to get bread crumb items for
|
||||
* @param $modules mixed value of module name(s) to provide extra filtering
|
||||
*/
|
||||
public function BreadCrumbStack($user_id, $modules='') {
|
||||
$this->stack = array();
|
||||
$this->stackMap = array();
|
||||
|
||||
$admin = new Administration();
|
||||
$admin->retrieveSettings('tracker');
|
||||
|
||||
$this->deleteInvisible = !empty($admin->settings['tracker_Tracker']);
|
||||
$db = DBManagerFactory::getInstance();
|
||||
|
||||
$module_query = '';
|
||||
if(!empty($modules)) {
|
||||
$history_max_viewed = 10;
|
||||
$module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','" , $modules) . '\')' : ' AND module_name = \'' . $modules . '\'';
|
||||
} else {
|
||||
$history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50;
|
||||
}
|
||||
|
||||
$query = 'SELECT distinct item_id AS item_id, id, item_summary, module_name, monitor_id, date_modified FROM tracker WHERE user_id = \'' . $user_id . '\' AND visible = 1 ' . $module_query . ' ORDER BY date_modified DESC';
|
||||
$result = $db->limitQuery($query, 0, $history_max_viewed);
|
||||
$items = array();
|
||||
while(($row = $db->fetchByAssoc($result))) {
|
||||
$items[] = $row;
|
||||
}
|
||||
$items = array_reverse($items);
|
||||
foreach($items as $item) {
|
||||
$this->push($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* contains
|
||||
* Returns true if the stack contains the specified item_id, false otherwise.
|
||||
*
|
||||
* @param item_id the item id to search for
|
||||
* @return id of the first item on the stack
|
||||
*/
|
||||
public function contains($item_id) {
|
||||
if(!empty($this->stackMap)){
|
||||
return array_key_exists($item_id, $this->stackMap);
|
||||
}else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push an element onto the stack.
|
||||
* This will only maintain a list of unique item_ids, if an item_id is found to
|
||||
* already exist in the stack, we want to remove it and update the database to reflect it's
|
||||
* visibility.
|
||||
*
|
||||
* @param array $row - a trackable item to store in memory
|
||||
*/
|
||||
public function push($row) {
|
||||
if(is_array($row) && !empty($row['item_id'])) {
|
||||
if($this->contains($row['item_id'])) {
|
||||
//if this item already exists in the stack then update the found items
|
||||
//to visible = 0 and add our new item to the stack
|
||||
$item = $this->stack[$this->stackMap[$row['item_id']]];
|
||||
if(!empty($item['id']) && $row['id'] != $item['id']){
|
||||
$this->makeItemInvisible($item['id'], 0);
|
||||
}
|
||||
$this->popItem($item['item_id']);
|
||||
}
|
||||
//If we reach the max count, shift the first element off the stack
|
||||
$history_max_viewed = (!empty($GLOBALS['sugar_config']['history_max_viewed']))? $GLOBALS['sugar_config']['history_max_viewed'] : 50;
|
||||
|
||||
if($this->length() >= $history_max_viewed) {
|
||||
$this->pop();
|
||||
}
|
||||
//Push the element into the stack
|
||||
$this->addItem($row);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an item off the stack
|
||||
*
|
||||
*/
|
||||
public function pop(){
|
||||
$item = array_shift($this->stack);
|
||||
if(!empty($item['item_id']) && isset($this->stackMap[$item['item_id']])){
|
||||
unset($this->stackMap[$item['item_id']]);
|
||||
$this->heal();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the visibility of an item
|
||||
*
|
||||
* @param int $id
|
||||
*/
|
||||
private function makeItemInvisible($id){
|
||||
if($this->deleteInvisible) {
|
||||
$query = "DELETE FROM tracker where id = '{$id}'";
|
||||
} else {
|
||||
$query = "UPDATE tracker SET visible = 0 WHERE id = '{$id}'";
|
||||
}
|
||||
$GLOBALS['db']->query($query, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an Item off the stack. Call heal to reconstruct the indices properly
|
||||
*
|
||||
* @param string $item_id - the item id to remove from the stack
|
||||
*/
|
||||
public function popItem($item_id){
|
||||
if(isset($this->stackMap[$item_id])){
|
||||
$idx = $this->stackMap[$item_id];
|
||||
unset($this->stack[$idx]);
|
||||
unset($this->stackMap[$item_id]);
|
||||
$this->heal();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the stack
|
||||
*
|
||||
* @param array $row - the row from the db query
|
||||
*/
|
||||
private function addItem($row){
|
||||
$this->stack[] = $row;
|
||||
$this->stackMap[$row['item_id']] = ($this->length() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Once we have removed an item from the stack we need to be sure to have the
|
||||
* ids and indices match up properly. Heal takes care of that. This method should only
|
||||
* be called when an item_id is already in the stack and needs to be removed
|
||||
*
|
||||
*/
|
||||
private function heal(){
|
||||
$vals = array_values($this->stack);
|
||||
$this->stack = array();
|
||||
$this->stackMap = array();
|
||||
foreach($vals as $key => $val){
|
||||
$this->addItem($val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of elements in the stack
|
||||
*
|
||||
* @return int - the number of elements in the stack
|
||||
*/
|
||||
public function length(){
|
||||
return count($this->stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of breadcrubmbs currently in memory
|
||||
*
|
||||
* @return array of breadcrumbs
|
||||
*/
|
||||
public function getBreadCrumbList($filter_module='') {
|
||||
if(!empty($filter_module)) {
|
||||
$s2 = array();
|
||||
if(is_array($filter_module)) {
|
||||
foreach($this->stack as $entry) {
|
||||
if(in_array($entry['module_name'], $filter_module)) {
|
||||
$s2[$entry['item_id']] = $entry;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($this->stack as $entry) {
|
||||
if($entry['module_name'] == $filter_module) {
|
||||
$s2[$entry['item_id']] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$s2 = array_reverse($s2);
|
||||
if(count($s2) > 10) {
|
||||
$s2 = array_slice($s2, 0, 10);
|
||||
}
|
||||
return $s2;
|
||||
}
|
||||
|
||||
$s = $this->stack;
|
||||
$s = array_reverse($s);
|
||||
if(count($s) > 10) {
|
||||
$s = array_slice($s, 0, 10);
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
59
modules/Trackers/Metric.php
Executable file
59
modules/Trackers/Metric.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
class Metric {
|
||||
|
||||
function Metric($type, $name) {
|
||||
$this->_name = $name;
|
||||
$this->_type = $type;
|
||||
$this->_mutable = $name == 'monitor_id' ? false : true;
|
||||
}
|
||||
|
||||
function type() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
function name() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
function isMutable() {
|
||||
return $this->_mutable;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
42
modules/Trackers/Trackable.php
Executable file
42
modules/Trackers/Trackable.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
interface Trackable {
|
||||
public function getMetrics();
|
||||
public function getStores();
|
||||
}
|
||||
?>
|
||||
139
modules/Trackers/Tracker.php
Executable file
139
modules/Trackers/Tracker.php
Executable file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
if(!class_exists('Tracker')){
|
||||
|
||||
|
||||
|
||||
class Tracker extends SugarBean
|
||||
{
|
||||
var $module_dir = 'Trackers';
|
||||
var $table_name = 'tracker';
|
||||
var $object_name = 'Tracker';
|
||||
var $disable_var_defs = true;
|
||||
var $acltype = 'Tracker';
|
||||
|
||||
var $column_fields = Array(
|
||||
"id",
|
||||
"monitor_id",
|
||||
"user_id",
|
||||
"module_name",
|
||||
"item_id",
|
||||
"item_summary",
|
||||
"date_modified",
|
||||
"action",
|
||||
"session_id",
|
||||
"visible"
|
||||
);
|
||||
|
||||
function Tracker()
|
||||
{
|
||||
global $dictionary;
|
||||
if(isset($this->module_dir) && isset($this->object_name) && !isset($GLOBALS['dictionary'][$this->object_name])){
|
||||
$path = 'modules/Trackers/vardefs.php';
|
||||
if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path);
|
||||
require_once($path);
|
||||
}
|
||||
parent::SugarBean();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the most recently viewed items for this user.
|
||||
* The number of items to return is specified in sugar_config['history_max_viewed']
|
||||
* @param uid user_id
|
||||
* @param mixed module_name Optional - return only items from this module, a string of the module or array of modules
|
||||
* @return array list
|
||||
*/
|
||||
function get_recently_viewed($user_id, $modules = '')
|
||||
{
|
||||
$path = 'modules/Trackers/BreadCrumbStack.php';
|
||||
if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path);
|
||||
require_once($path);
|
||||
if(empty($_SESSION['breadCrumbs'])) {
|
||||
$breadCrumb = new BreadCrumbStack($user_id, $modules);
|
||||
$_SESSION['breadCrumbs'] = $breadCrumb;
|
||||
$GLOBALS['log']->info(string_format($GLOBALS['app_strings']['LBL_BREADCRUMBSTACK_CREATED'], array($user_id)));
|
||||
} else {
|
||||
$breadCrumb = $_SESSION['breadCrumbs'];
|
||||
$module_query = '';
|
||||
if(!empty($modules)) {
|
||||
$module_query = is_array($modules) ? ' AND module_name IN (\'' . implode("','" , $modules) . '\')' : ' AND module_name = \'' . $modules . '\'';
|
||||
}
|
||||
|
||||
$query = 'SELECT item_id, item_summary, module_name, id FROM ' . $this->table_name . ' WHERE id = (SELECT MAX(id) as id FROM ' . $this->table_name . ' WHERE user_id = \'' . $user_id . '\' AND visible = 1' . $module_query . ')';
|
||||
$result = $this->db->limitQuery($query,0,10,true,$query);
|
||||
while(($row = $this->db->fetchByAssoc($result))) {
|
||||
$breadCrumb->push($row);
|
||||
}
|
||||
}
|
||||
$list = $breadCrumb->getBreadCrumbList($modules);
|
||||
$GLOBALS['log']->info("Tracker: retrieving ".count($list)." items");
|
||||
return $list;
|
||||
}
|
||||
|
||||
function makeInvisibleForAll($item_id)
|
||||
{
|
||||
$query = "UPDATE $this->table_name SET visible = 0 WHERE item_id = '$item_id' AND visible = 1";
|
||||
$this->db->query($query, true);
|
||||
$path = 'modules/Trackers/BreadCrumbStack.php';
|
||||
if(defined('TEMPLATE_URL'))$path = SugarTemplateUtilities::getFilePath($path);
|
||||
require_once($path);
|
||||
if(!empty($_SESSION['breadCrumbs'])){
|
||||
$breadCrumbs = $_SESSION['breadCrumbs'];
|
||||
$breadCrumbs->popItem($item_id);
|
||||
}
|
||||
}
|
||||
|
||||
function logPage(){
|
||||
$time_on_last_page = 0;
|
||||
//no need to calculate it if it is a redirection page
|
||||
if(empty($GLOBALS['app']->headerDisplayed ))return;
|
||||
if(!empty($_SESSION['lpage']))$time_on_last_page = time() - $_SESSION['lpage'];
|
||||
$_SESSION['lpage']=time();
|
||||
echo "\x3c\x64\x69\x76\x20\x61\x6c\x69\x67\x6e\x3d\x27\x63\x65\x6e\x74\x65\x72\x27\x3e\x3c\x69\x6d\x67\x20\x73\x72\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x75\x70\x64\x61\x74\x65\x73\x2e\x73\x75\x67\x61\x72\x63\x72\x6d\x2e\x63\x6f\x6d\x2f\x6c\x6f\x67\x6f\x2e\x70\x68\x70\x3f\x61\x6b\x3d". $GLOBALS['sugar_config']['unique_key'] . "\x22\x20\x61\x6c\x74\x3d\x22\x50\x6f\x77\x65\x72\x65\x64\x20\x42\x79\x20\x53\x75\x67\x61\x72\x43\x52\x4d\x22\x3e\x3c\x2f\x64\x69\x76\x3e";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bean_implements
|
||||
* Override method to support ACL roles
|
||||
*/
|
||||
function bean_implements($interface){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
293
modules/Trackers/TrackerManager.php
Executable file
293
modules/Trackers/TrackerManager.php
Executable file
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('modules/Trackers/monitor/Monitor.php');
|
||||
|
||||
|
||||
|
||||
class TrackerManager {
|
||||
|
||||
private static $instance;
|
||||
private static $monitor_id;
|
||||
private $metadata = array();
|
||||
private $monitors = array();
|
||||
private $disabledMonitors = array();
|
||||
private static $paused = false;
|
||||
|
||||
/**
|
||||
* Constructor for TrackerManager. Declared private for singleton pattern.
|
||||
*
|
||||
*/
|
||||
private function TrackerManager() {
|
||||
require('modules/Trackers/config.php');
|
||||
$this->metadata = $tracker_config;
|
||||
self::$monitor_id = create_guid();
|
||||
}
|
||||
|
||||
/**
|
||||
* setup
|
||||
* This is a private method used to load the configuration settings whereby
|
||||
* monitors may be disabled via the Admin settings interface
|
||||
*
|
||||
*/
|
||||
private function setup() {
|
||||
if(!empty($this->metadata) && empty($GLOBALS['installing'])) {
|
||||
|
||||
$admin = new Administration();
|
||||
$admin->retrieveSettings('tracker');
|
||||
foreach($this->metadata as $key=>$entry) {
|
||||
if(isset($entry['bean'])) {
|
||||
if(!empty($admin->settings['tracker_'. $entry['name']])) {
|
||||
$this->disabledMonitors[$entry['name']] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMonitorId($id) {
|
||||
self::$monitor_id = $id;
|
||||
foreach($this->monitors as $monitor) {
|
||||
$monitor->monitor_id = self::$monitor_id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getMonitorId
|
||||
* Returns the monitor id associated with this TrackerManager instance
|
||||
* @returns String id value
|
||||
*/
|
||||
public function getMonitorId() {
|
||||
return self::$monitor_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* getInstance
|
||||
* Singleton method to return static instance of TrackerManager
|
||||
* @returns static TrackerManager instance
|
||||
*/
|
||||
static function getInstance(){
|
||||
if (!isset(self::$instance)) {
|
||||
self::$instance = new TrackerManager();
|
||||
//Set global variable for tracker monitor instances that are disabled
|
||||
self::$instance->setup();
|
||||
} // if
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* getMonitor
|
||||
* This method returns a Monitor instance based on the monitor name.
|
||||
* @param $name The String value of the monitor's name to retrieve
|
||||
* @return Monitor instance corresponding to name or a BlankMonitor instance if one could not be found
|
||||
*/
|
||||
public function getMonitor($name) {
|
||||
//don't waste our time on disabled monitors
|
||||
if($name!='tracker_sessions' && !empty($this->disabledMonitors[$name]))return false;
|
||||
if(isset($this->monitors[$name])) {
|
||||
return $this->monitors[$name];
|
||||
}
|
||||
|
||||
if(isset($this->metadata) && isset($this->metadata[$name])) {
|
||||
|
||||
|
||||
try {
|
||||
$instance = $this->_getMonitor($this->metadata[$name]['name'], //name
|
||||
self::$monitor_id, //monitor_id
|
||||
$this->metadata[$name]['metadata'],
|
||||
$this->metadata[$name]['store'] //store
|
||||
);
|
||||
$this->monitors[$name] = $instance;
|
||||
return $this->monitors[$name];
|
||||
} catch (Exception $ex) {
|
||||
$GLOBALS['log']->error($ex->getMessage());
|
||||
$GLOBALS['log']->error($ex->getTraceAsString());
|
||||
require_once('modules/Trackers/monitor/BlankMonitor.php');
|
||||
$this->monitors[$name] = new BlankMonitor();
|
||||
return $this->monitors[$name];
|
||||
}
|
||||
|
||||
} else {
|
||||
$GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_NOT_CONFIGURED'] . "($name)");
|
||||
require_once('modules/Trackers/monitor/BlankMonitor.php');
|
||||
$this->monitors[$name] = new BlankMonitor();
|
||||
return $this->monitors[$name];
|
||||
}
|
||||
}
|
||||
|
||||
private function _getMonitor($name='', $monitorId='', $metadata='', $store=''){
|
||||
$class = strtolower($name.'_monitor');
|
||||
$monitor = null;
|
||||
if(file_exists('custom/modules/Trackers/monitor/'.$class.'.php')){
|
||||
require_once('custom/modules/Trackers/monitor/'.$class.'.php');
|
||||
if(class_exists($class)){
|
||||
$monitor = new $class($name, $monitorId, $metadata, $store);
|
||||
}
|
||||
}elseif(file_exists('modules/Trackers/monitor/'.$class.'.php')){
|
||||
require_once('modules/Trackers/monitor/'.$class.'.php');
|
||||
if(class_exists($class)){
|
||||
$monitor = new $class($name, $monitorId, $metadata, $store);
|
||||
}
|
||||
}else{
|
||||
$monitor = new Monitor($name, $monitorId, $metadata, $store);
|
||||
}
|
||||
|
||||
|
||||
$monitor->setEnabled(empty($this->disabledMonitors[$monitor->name]));
|
||||
return $monitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* save
|
||||
* This method handles saving the monitors and their metrics to the mapped Store implementations
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
// Session tracker always saves.
|
||||
if ( isset($this->monitors['tracker_sessions']) ) {
|
||||
$this->monitors['tracker_sessions']->save();
|
||||
unset($this->monitors['tracker_sessions']);
|
||||
}
|
||||
|
||||
if(!$this->isPaused()){
|
||||
foreach($this->monitors as $monitor) {
|
||||
if(array_key_exists('Trackable', class_implements($monitor))) {
|
||||
$monitor->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* saveMonitor
|
||||
* Saves the monitor instance and then clears it
|
||||
* If ignoreDisabled is set the ignore the fact of this monitor being disabled
|
||||
*/
|
||||
public function saveMonitor($monitor, $flush=true, $ignoreDisabled = false) {
|
||||
|
||||
if(!$this->isPaused() && !empty($monitor)){
|
||||
|
||||
if((empty($this->disabledMonitors[$monitor->name]) || $ignoreDisabled) && array_key_exists('Trackable', class_implements($monitor))) {
|
||||
|
||||
$monitor->save($flush);
|
||||
|
||||
if($flush) {
|
||||
$monitor->clear();
|
||||
unset($this->monitors[strtolower($monitor->name)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* unsetMonitor
|
||||
* Method to unset the monitor so that it will not be saved
|
||||
*/
|
||||
public function unsetMonitor($monitor) {
|
||||
if(!empty($monitor)) {
|
||||
unset($this->monitors[strtolower($monitor->name)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pause
|
||||
* This function is to be called by a client in order to pause tracking through the lifetime of a Request.
|
||||
* Tracking can be started again by calling unPauseTracking
|
||||
*
|
||||
* Usage: TrackerManager::getInstance()->pauseTracking();
|
||||
*/
|
||||
public function pause(){
|
||||
self::$paused = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* unPause
|
||||
* This function is to be called by a client in order to unPause tracking through the lifetime of a Request.
|
||||
* Tracking can be paused by calling pauseTracking
|
||||
*
|
||||
* * Usage: TrackerManager::getInstance()->unPauseTracking();
|
||||
*/
|
||||
public function unPause(){
|
||||
self::$paused = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* isPaused
|
||||
* This function returns the current value of the private paused variable.
|
||||
* The result indicates whether or not the TrackerManager is paused.
|
||||
*
|
||||
* @return boolean value indicating whether or not TrackerManager instance is paused.
|
||||
*/
|
||||
public function isPaused() {
|
||||
return self::$paused;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDisabledMonitors
|
||||
* Returns an Array of Monitor's name(s) that hhave been set to disabled in the
|
||||
* Administration section.
|
||||
*
|
||||
* @return Array of disabled Monitor's name(s) that hhave been set to disabled in the
|
||||
* Administration section.
|
||||
*/
|
||||
public function getDisabledMonitors() {
|
||||
return $this->disabledMonitors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disabled monitors
|
||||
*
|
||||
* @param array $disabledMonitors
|
||||
*/
|
||||
public function setDisabledMonitors($disabledMonitors) {
|
||||
$this->disabledMonitors = $disabledMonitors;
|
||||
}
|
||||
|
||||
/**
|
||||
* unsetMonitors
|
||||
* Function to unset all Monitors loaded for a TrackerManager instance
|
||||
*
|
||||
*/
|
||||
public function unsetMonitors() {
|
||||
$mons = $this->monitors;
|
||||
foreach($mons as $key=>$m) {
|
||||
$this->unsetMonitor($m);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
57
modules/Trackers/config.php
Executable file
57
modules/Trackers/config.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
$tracker_config =
|
||||
array (
|
||||
'tracker' =>
|
||||
array (
|
||||
'bean' => 'Tracker',
|
||||
'name' => 'Tracker',
|
||||
'metadata' => 'modules/Trackers/vardefs.php',
|
||||
'store' =>
|
||||
array (
|
||||
0 => 'DatabaseStore',
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
91
modules/Trackers/language/en_us.lang.php
Executable file
91
modules/Trackers/language/en_us.lang.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: Defines the English language pack for the base application.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
//Labels for methods in the TrackerReporter.php file that are shown in TrackerDashlet
|
||||
'ShowActiveUsers' => 'Show Active Users',
|
||||
'ShowLastModifiedRecords' => 'Last 10 Modified Records',
|
||||
'ShowTopUser' => 'Top User',
|
||||
'ShowMyModuleUsage' => 'My Module Usage',
|
||||
'ShowMyWeeklyActivities' => 'My Weekly Activity',
|
||||
'ShowTop3ModulesUsed' => 'My Top 3 Modules Used',
|
||||
'ShowLoggedInUserCount' => 'Active User Count',
|
||||
'ShowMyCumulativeLoggedInTime' => 'My Cumulative Login Time (This Week)',
|
||||
'ShowUsersCumulativeLoggedInTime' => 'Users Cumulative Login Time (This Week)',
|
||||
|
||||
//Column header mapping
|
||||
'action' => 'Action',
|
||||
'active_users' => 'Active User Count',
|
||||
'date_modified' => 'Date of Last Action',
|
||||
'different_modules_accessed' => 'Number Of Modules Accessed',
|
||||
'first_name' => 'First Name',
|
||||
'item_id' => 'ID',
|
||||
'item_summary' => 'Name',
|
||||
'last_action' => 'Last Action Date/Time',
|
||||
'last_name' => 'Last Name',
|
||||
'module_name' => 'Module Name',
|
||||
'records_modified' => 'Total Records Modified',
|
||||
'top_module' => 'Top Module Accessed',
|
||||
'total_count' => 'Total Page Views',
|
||||
'total_login_time' => 'Time (hh:mm:ss)',
|
||||
'user_name' => 'Username',
|
||||
'users' => 'Users',
|
||||
|
||||
//Administration related labels
|
||||
'LBL_ENABLE' => 'Enabled',
|
||||
'LBL_MODULE_NAME_TITLE' => 'Trackers',
|
||||
'LBL_MODULE_NAME' => 'Trackers',
|
||||
'LBL_TRACKER_SETTINGS' => 'Tracker Settings',
|
||||
'LBL_TRACKER_QUERIES_DESC' => 'Tracker Queries',
|
||||
'LBL_TRACKER_QUERIES_HELP' => 'Track SQL statements when "Log slow queries" is enabled and the query execution time exceeds the "Slow query time threshold" value',
|
||||
'LBL_TRACKER_PERF_DESC' => 'Tracker Performance',
|
||||
'LBL_TRACKER_PERF_HELP' => 'Track database roundtrips, files accessed and memory usage',
|
||||
'LBL_TRACKER_SESSIONS_DESC' => 'Tracker Sessions',
|
||||
'LBL_TRACKER_SESSIONS_HELP' => 'Track active users and users’ session information',
|
||||
'LBL_TRACKER_DESC' => 'Tracker Actions',
|
||||
'LBL_TRACKER_HELP' => 'Track user’s page views (modules and records accessed) and record saves',
|
||||
'LBL_TRACKER_PRUNE_INTERVAL' => 'Number of days of Tracker data to store when Scheduler prunes the tables',
|
||||
'LBL_TRACKER_PRUNE_RANGE' => 'Number of days',
|
||||
);
|
||||
?>
|
||||
114
modules/Trackers/monitor/BlankMonitor.php
Executable file
114
modules/Trackers/monitor/BlankMonitor.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/monitor/Monitor.php');
|
||||
require_once('modules/Trackers/Metric.php');
|
||||
require_once('modules/Trackers/Trackable.php');
|
||||
|
||||
class BlankMonitor extends Monitor implements Trackable {
|
||||
|
||||
/**
|
||||
* BlankMonitor constructor
|
||||
*/
|
||||
function BlankMonitor() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* setValue
|
||||
* Sets the value defined in the monitor's metrics for the given name
|
||||
* @param $name String value of metric name
|
||||
* @param $value Mixed value
|
||||
* @throws Exception Thrown if metric name is not configured for monitor instance
|
||||
*/
|
||||
function setValue($name, $value) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getStores
|
||||
* Returns Array of store names defined for monitor instance
|
||||
* @return Array of store names defined for monitor instance
|
||||
*/
|
||||
function getStores() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* getMetrics
|
||||
* Returns Array of metric instances defined for monitor instance
|
||||
* @return Array of metric instances defined for monitor instance
|
||||
*/
|
||||
function getMetrics() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* save
|
||||
* This method retrieves the Store instances associated with monitor and calls
|
||||
* the flush method passing with the montior ($this) instance.
|
||||
*
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getStore
|
||||
* This method checks if the Store implementation has already been instantiated and
|
||||
* will return the one stored; otherwise it will create the Store implementation and
|
||||
* save it to the Array of Stores.
|
||||
* @param $store The name of the store as defined in the 'modules/Trackers/config.php' settings
|
||||
* @return An instance of a Store implementation
|
||||
* @throws Exception Thrown if $store class cannot be loaded
|
||||
*/
|
||||
protected function getStore($store) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* clear
|
||||
* This function clears the metrics data in the monitor instance
|
||||
*/
|
||||
public function clear() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
243
modules/Trackers/monitor/Monitor.php
Executable file
243
modules/Trackers/monitor/Monitor.php
Executable file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/Metric.php');
|
||||
require_once('modules/Trackers/Trackable.php');
|
||||
|
||||
define('MAX_SESSION_LENGTH', 36);
|
||||
|
||||
class Monitor implements Trackable {
|
||||
|
||||
var $metricsFile;
|
||||
var $name;
|
||||
protected static $metrics;
|
||||
protected static $cachedStores;
|
||||
var $stores;
|
||||
var $monitor_id;
|
||||
var $table_name;
|
||||
protected $enabled = true;
|
||||
protected $dirty = false;
|
||||
|
||||
var $date_start;
|
||||
var $date_end;
|
||||
var $active;
|
||||
var $round_trips;
|
||||
var $seconds;
|
||||
var $session_id;
|
||||
|
||||
/**
|
||||
* Monitor constructor
|
||||
*/
|
||||
function Monitor($name='', $monitorId='', $metadata='', $store='') {
|
||||
|
||||
if(empty($metadata) || !file_exists($metadata)) {
|
||||
$GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)");
|
||||
throw new Exception($GLOBALS['app_strings']['ERR_MONITOR_FILE_MISSING'] . "($metadata)");
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->metricsFile = $metadata;
|
||||
|
||||
require($this->metricsFile);
|
||||
$fields = $dictionary[$this->name]['fields'];
|
||||
$this->table_name = !empty($dictionary[$this->name]['table']) ? $dictionary[$this->name]['table'] : $this->name;
|
||||
$this->metrics = array();
|
||||
foreach($fields as $field) {
|
||||
|
||||
//We need to skip auto_increment fields; they are not real metrics
|
||||
//since they are generated by the database.
|
||||
if(isset($field['auto_increment'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = isset($field['dbType']) ? $field['dbType'] : $field['type'];
|
||||
$name = $field['name'];
|
||||
$this->metrics[$name] = new Metric($type, $name);
|
||||
}
|
||||
|
||||
$this->monitor_id = $monitorId;
|
||||
$this->stores = $store;
|
||||
|
||||
if(isset($this->metrics['session_id'])) {
|
||||
//set the value of the session id for 2 reasons:
|
||||
//1) it is the same value no matter where it is set
|
||||
//2) ensure it follows some filter rules.
|
||||
$this->setValue('session_id', $this->getSessionId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setValue
|
||||
* Sets the value defined in the monitor's metrics for the given name
|
||||
* @param $name String value of metric name
|
||||
* @param $value Mixed value
|
||||
* @throws Exception Thrown if metric name is not configured for monitor instance
|
||||
*/
|
||||
public function setValue($name, $value) {
|
||||
if(!isset($this->metrics[$name])) {
|
||||
$GLOBALS['log']->error($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)");
|
||||
throw new Exception($GLOBALS['app_strings']['ERR_UNDEFINED_METRIC'] . "($name)");
|
||||
} else if($this->metrics[$name]->isMutable()) {
|
||||
$this->$name = is_object($value) ? get_class($value) : $value;
|
||||
$this->dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getValue($name){
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/**
|
||||
* getStores
|
||||
* Returns Array of store names defined for monitor instance
|
||||
* @return Array of store names defined for monitor instance
|
||||
*/
|
||||
function getStores() {
|
||||
return $this->stores;
|
||||
}
|
||||
|
||||
/**
|
||||
* getMetrics
|
||||
* Returns Array of metric instances defined for monitor instance
|
||||
* @return Array of metric instances defined for monitor instance
|
||||
*/
|
||||
function getMetrics() {
|
||||
return $this->metrics;
|
||||
}
|
||||
|
||||
/**
|
||||
* isDirty
|
||||
* Returns if the monitor has data that needs to be saved
|
||||
* @return $dirty boolean
|
||||
*/
|
||||
function isDirty(){
|
||||
return $this->dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* save
|
||||
* This method retrieves the Store instances associated with monitor and calls
|
||||
* the flush method passing with the montior ($this) instance.
|
||||
* @param $flush boolean parameter indicating whether or not to flush the instance data to store or possibly cache
|
||||
*/
|
||||
public function save($flush=true) {
|
||||
//If the monitor is not enabled, do not save
|
||||
if(!$this->isEnabled()&&$this->name!='tracker_sessions')return false;
|
||||
|
||||
//if the monitor does not have values set no need to do the work saving.
|
||||
if(!$this->dirty)return false;
|
||||
|
||||
if(empty($GLOBALS['tracker_' . $this->table_name])) {
|
||||
foreach($this->stores as $s) {
|
||||
$store = $this->getStore($s);
|
||||
$store->flush($this);
|
||||
}
|
||||
}
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* clear
|
||||
* This function clears the metrics data in the monitor instance
|
||||
*/
|
||||
public function clear() {
|
||||
$metrics = $this->getMetrics();
|
||||
foreach($metrics as $name=>$metric) {
|
||||
if($metric->isMutable()) {
|
||||
$this->$name = '';
|
||||
}
|
||||
}
|
||||
$this->dirty = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* getStore
|
||||
* This method checks if the Store implementation has already been instantiated and
|
||||
* will return the one stored; otherwise it will create the Store implementation and
|
||||
* save it to the Array of Stores.
|
||||
* @param $store The name of the store as defined in the 'modules/Trackers/config.php' settings
|
||||
* @return An instance of a Store implementation
|
||||
* @throws Exception Thrown if $store class cannot be loaded
|
||||
*/
|
||||
protected function getStore($store) {
|
||||
|
||||
if(isset($this->cachedStores[$store])) {
|
||||
return $this->cachedStores[$store];
|
||||
}
|
||||
|
||||
if(!file_exists("modules/Trackers/store/$store.php")) {
|
||||
$GLOBALS['log']->error($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)");
|
||||
throw new Exception($GLOBALS['app_strings']['ERR_STORE_FILE_MISSING'] . "($store)");
|
||||
}
|
||||
|
||||
require_once("modules/Trackers/store/$store.php");
|
||||
$s = new $store();
|
||||
$this->cachedStores[$store] = $s;
|
||||
return $s;
|
||||
}
|
||||
|
||||
public function getSessionId(){
|
||||
$sessionid = session_id();
|
||||
if(!empty($sessionid) && strlen($sessionid) > MAX_SESSION_LENGTH) {
|
||||
$sessionid = md5($sessionid);
|
||||
}
|
||||
return $sessionid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the monitor's metrics/values as an Array
|
||||
* @return An Array of data for the monitor's corresponding metrics
|
||||
*/
|
||||
public function toArray() {
|
||||
$to_arr = array();
|
||||
$metrics = $this->getMetrics();
|
||||
foreach($metrics as $name=>$metric) {
|
||||
$to_arr[$name] = isset($this->$name) ? $this->$name : null;
|
||||
}
|
||||
return $to_arr;
|
||||
}
|
||||
|
||||
public function setEnabled($enable=true) {
|
||||
$this->enabled = $enable;
|
||||
}
|
||||
|
||||
public function isEnabled() {
|
||||
return $this->enabled;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
75
modules/Trackers/monitor/tracker_monitor.php
Executable file
75
modules/Trackers/monitor/tracker_monitor.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/monitor/Monitor.php');
|
||||
|
||||
class tracker_monitor extends Monitor {
|
||||
|
||||
/**
|
||||
* Monitor constructor
|
||||
*/
|
||||
function tracker_monitor($name='', $monitorId='', $metadata='', $store='') {
|
||||
parent::Monitor($name, $monitorId, $metadata, $store);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* save
|
||||
* This method retrieves the Store instances associated with monitor and calls
|
||||
* the flush method passing with the montior ($this) instance.
|
||||
* @param $flush boolean parameter indicating whether or not to flush the instance data to store or possibly cache
|
||||
*/
|
||||
public function save($flush=true) {
|
||||
//if the monitor does not have values set no need to do the work saving.
|
||||
if(!$this->dirty)return false;
|
||||
|
||||
if(!$this->isEnabled() && (isset($this->visible) && !$this->getValue('visible'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($GLOBALS['tracker_' . $this->table_name])) {
|
||||
foreach($this->stores as $s) {
|
||||
$store = $this->getStore($s);
|
||||
$store->flush($this);
|
||||
}
|
||||
}
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
85
modules/Trackers/pl_pl.lang.php
Executable file
85
modules/Trackers/pl_pl.lang.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* The contents of this file are subject to the SugarCRM Professional Subscription
|
||||
* Agreement ("License") which can be viewed at
|
||||
* http://www.sugarcrm.com/crm/products/sugar-professional-eula.html
|
||||
* By installing or using this file, You have unconditionally agreed to the
|
||||
* terms and conditions of the License, and You may not use this file except in
|
||||
* compliance with the License. Under the terms of the license, You shall not,
|
||||
* among other things: 1) sublicense, resell, rent, lease, redistribute, assign
|
||||
* or otherwise transfer Your rights to the Software, and 2) use the Software
|
||||
* for timesharing or service bureau purposes such as hosting the Software for
|
||||
* commercial gain and/or for the benefit of a third party. Use of the Software
|
||||
* may be subject to applicable fees and any use of the Software without first
|
||||
* paying applicable fees is strictly prohibited. You do not have the right to
|
||||
* remove SugarCRM copyrights from the source code or user interface.
|
||||
*
|
||||
* All copies of the Covered Code must include on each user interface screen:
|
||||
* (i) the "Powered by SugarCRM" logo and
|
||||
* (ii) the SugarCRM copyright notice
|
||||
* in the same form as they appear in the distribution. See full license for
|
||||
* requirements.
|
||||
*
|
||||
* Your Warranty, Limitations of liability and Indemnity are expressly stated
|
||||
* in the License. Please refer to the License for the specific language
|
||||
* governing these rights and limitations under the License. Portions created
|
||||
* by SugarCRM are Copyright (C) 2004-2007 SugarCRM, Inc.; All Rights Reserved.
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
* pl_pl.lang.php,v for SugarCRM 4.5-->>
|
||||
* Translator: Krzysztof Morawski
|
||||
* All Rights Reserved.
|
||||
* Any bugs report welcome: krzysiek<at>mojsklepik<dot>net
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
//Labels for methods in the TrackerReporter.php file that are shown in TrackerDashlet
|
||||
'ShowActiveUsers' => 'Pokaż aktywnych użytkowników',
|
||||
'ShowLastModifiedRecords' => '10 ostatnio modyfikowanych rekordów',
|
||||
'ShowTopUser' => 'Najaktywniejsi użytkownicy',
|
||||
'ShowMyModuleUsage' => 'Wykorzystanie mojego modułu',
|
||||
'ShowMyWeeklyActivities' => 'Moja tygodniowa aktywność',
|
||||
'ShowTop3ModulesUsed' => 'Moje trzy najbardziej aktywne moduły',
|
||||
'ShowLoggedInUserCount' => 'Licznik aktywnych użytkowników',
|
||||
'ShowMyCumulativeLoggedInTime' => 'Rzeczywisty pełny czas mojego zalogowania (w tym tygodniu)',
|
||||
'ShowUsersCumulativeLoggedInTime' => 'Rzeczywisty pełny czas zalogowania wszystkich użytkowników (w tym tygodniu)',
|
||||
|
||||
//Column header mapping
|
||||
'action' => 'Akcja',
|
||||
'active_users' => 'Licznik aktywności użytkowników',
|
||||
'date_modified' => 'Data ostatniego działania',
|
||||
'different_modules_accessed' => 'Licza używanych modułów',
|
||||
'first_name' => 'Imię',
|
||||
'item_id' => 'ID',
|
||||
'item_summary' => 'Nazwa',
|
||||
'last_action' => 'Data i czas ostatniej aktywności',
|
||||
'last_name' => 'Nazwisko',
|
||||
'module_name' => 'Nazwa modułu',
|
||||
'records_modified' => 'Wszystkie zmodyfikowane rekordy',
|
||||
'top_module' => 'Najbardziej aktywne moduły',
|
||||
'total_count' => 'Wszystkie oglądane strony',
|
||||
'total_login_time' => 'Czas (hh:mm:ss)',
|
||||
'user_name' => 'Nazwa użytkownika',
|
||||
'users' => 'Użytkownicy',
|
||||
|
||||
//Administration related labels
|
||||
'LBL_ENABLE' => 'Włączone',
|
||||
'LBL_MODULE_NAME_TITLE' => 'Śledzenie',
|
||||
'LBL_TRACKER_SETTINGS' => 'Ustawienia śledzenia',
|
||||
'LBL_TRACKER_QUERIES_DESC' => 'Śledzenie wyrażeń',
|
||||
'LBL_TRACKER_QUERIES_HELP' => 'Śledź wyrażenia SQL, gdy jest włączona funkcja "Śledź powolne zapytania", a wartość wykonania zapytania przekracza, wartość funkcji "Przekroczenie wartości czasu powolnego zapytania" w config.php',
|
||||
'LBL_TRACKER_PERF_DESC' => 'Śledzenie wydajności',
|
||||
'LBL_TRACKER_PERF_DESC' => 'Śledzenie osiągów wykonywania zapytań bazy danych, lczby otwartych plików i wykorzystania pamięci)',
|
||||
'LBL_TRACKER_SESSIONS_DESC' => 'Śledzenie sesji',
|
||||
'LBL_TRACKER_SESSIONS_HELP' => 'Informacje o śledzeniu sesji aktywnego użytkownika(ów)',
|
||||
'LBL_TRACKER_DESC' => 'Śledzenie działań',
|
||||
'LBL_TRACKER_HELP' => 'Strona widoku sledzenie dla użytkownika(ów) (modułów i dostępu do plików) i zachowanych rekordów',
|
||||
'LBL_TRACKER_PRUNE_INTERVAL' => 'Interwał liczby dni dla harmonogramu oczyszczania tabeli bazy z danych przechowywania danych śledzenia',
|
||||
'LBL_TRACKER_PRUNE_RANGE' => 'Liczba dni',
|
||||
|
||||
//
|
||||
|
||||
);
|
||||
?>
|
||||
120
modules/Trackers/populateSeedData.php
Executable file
120
modules/Trackers/populateSeedData.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
|
||||
|
||||
require_once('modules/Trackers/TrackerUtility.php');
|
||||
|
||||
require_once('install/UserDemoData.php');
|
||||
|
||||
class populateSeedData {
|
||||
|
||||
var $monitorIds = 500;
|
||||
var $user = 1;
|
||||
var $userDemoData;
|
||||
var $modules = array('Accounts', 'Calls', 'Contacts', 'Leads', 'Meetings', 'Notes', 'Opportunities', 'Users');
|
||||
var $actions = array('authenticate', 'detailview', 'editview', 'index', 'save', 'settimezone');
|
||||
var $db;
|
||||
var $beanIdMap = array();
|
||||
var $userSessions = array();
|
||||
var $trackerManager;
|
||||
|
||||
function start() {
|
||||
$this->db = DBManagerFactory::getInstance();
|
||||
$this->userDemoData = new UserDemoData($this->user, false);
|
||||
$this->trackerManager = TrackerManager::getInstance();
|
||||
|
||||
foreach($this->modules as $mod) {
|
||||
$query = "select id from $mod";
|
||||
$result = $this->db->limitQuery($query, 0, 50);
|
||||
$ids = array();
|
||||
while(($row = $this->db->fetchByAssoc($result))) {
|
||||
$ids[] = $row['id'];
|
||||
} //while
|
||||
$this->beanIdMap[$mod] = $ids;
|
||||
}
|
||||
|
||||
while($this->monitorIds-- > 0) {
|
||||
$this->monitorId = create_guid();
|
||||
$this->trackerManager->setMonitorId($this->monitorId);
|
||||
$this->user = $this->userDemoData->guids[array_rand($this->userDemoData->guids)];
|
||||
$this->module = $this->modules[array_rand($this->modules)];
|
||||
$this->action = $this->actions[array_rand($this->actions)];
|
||||
$this->date = $this->randomTimestamp();
|
||||
$this->populate_tracker();
|
||||
$this->trackerManager->save();
|
||||
}
|
||||
}
|
||||
|
||||
function populate_tracker() {
|
||||
if($monitor = $this->trackerManager->getMonitor('tracker')){
|
||||
$monitor->setValue('user_id', $this->user);
|
||||
$monitor->setValue('module_name', $this->module);
|
||||
$monitor->setValue('action', $this->action);
|
||||
$monitor->setValue('visible', (($monitor->action == 'detailview') || ($monitor->action == 'editview')) ? 1 : 0);
|
||||
$monitor->setValue('date_modified', $this->randomTimestamp());
|
||||
$monitor->setValue('session_id', $this->getSessionId());
|
||||
if($this->action != 'settimezone' && isset($this->beanIdMap[$this->module][array_rand($this->beanIdMap[$this->module])])) {
|
||||
$monitor->setValue('item_id', $this->beanIdMap[$this->module][array_rand($this->beanIdMap[$this->module])]);
|
||||
$monitor->setValue('item_summary', 'random stuff'); //don't really need this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function randomTimestamp() {
|
||||
$now = strtotime(date('D M Y'));
|
||||
$lastYear = strtotime('01 February 2008');
|
||||
return gmdate("Y-m-d H:i:s", rand($lastYear, $now));
|
||||
}
|
||||
|
||||
function getSessionId() {
|
||||
if(isset($this->userSessions[$this->user])) {
|
||||
return $this->userSessions[$this->user];
|
||||
}
|
||||
$this->userSessions[$this->user] = $this->monitorId;
|
||||
return $this->monitorId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$test = new populateSeedData();
|
||||
$test->start();
|
||||
|
||||
?>
|
||||
82
modules/Trackers/store/DatabaseStore.php
Executable file
82
modules/Trackers/store/DatabaseStore.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/store/Store.php');
|
||||
|
||||
/**
|
||||
* Database
|
||||
* This is an implementation of the Store interface where the storage uses
|
||||
* the configured database instance as defined in DBManagerFactory::getInstance() method
|
||||
*
|
||||
*/
|
||||
class DatabaseStore implements Store {
|
||||
|
||||
public function flush($monitor) {
|
||||
|
||||
$metrics = $monitor->getMetrics();
|
||||
$columns = array();
|
||||
$values = array();
|
||||
foreach($metrics as $name=>$metric) {
|
||||
if(!empty($monitor->$name)) {
|
||||
$columns[] = $name;
|
||||
if($metrics[$name]->_type == 'int' || $metrics[$name]->_type == 'double') {
|
||||
$values[] = $GLOBALS['db']->quote($monitor->$name);
|
||||
} else if ($metrics[$name]->_type == 'datetime') {
|
||||
$values[] = ($GLOBALS['db']->dbType == 'oci8') ? db_convert("'".$monitor->$name."'",'datetime') : "'".$monitor->$name."'";
|
||||
} else {
|
||||
$values[] = "'".$GLOBALS['db']->quote($monitor->$name)."'";
|
||||
}
|
||||
}
|
||||
} //foreach
|
||||
|
||||
if(empty($values)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$query = "INSERT INTO $monitor->table_name (" .implode("," , $columns). " ) VALUES ( ". implode("," , $values). ')';
|
||||
$GLOBALS['db']->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
55
modules/Trackers/store/Store.php
Executable file
55
modules/Trackers/store/Store.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
interface Store {
|
||||
|
||||
/**
|
||||
* flush
|
||||
* This is the method implementations need to provide to store a monitor instance
|
||||
* @param $monitor An instance of Monitor
|
||||
*/
|
||||
public function flush($monitor);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
65
modules/Trackers/store/SugarLogStore.php
Executable file
65
modules/Trackers/store/SugarLogStore.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/store/Store.php');
|
||||
|
||||
class SugarLogStore implements Store {
|
||||
|
||||
public function flush($monitor) {
|
||||
$metrics = $monitor->getMetrics();
|
||||
$values = array();
|
||||
foreach($metrics as $name=>$metric) {
|
||||
if(!empty($monitor->$name)) {
|
||||
$values[$name] = $monitor->$name;
|
||||
}
|
||||
} //foreach
|
||||
|
||||
if(empty($values)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GLOBALS['log']->info("---- metrics for $monitor->name ----");
|
||||
$GLOBALS['log']->info(var_export($values, true));
|
||||
}
|
||||
}
|
||||
?>
|
||||
84
modules/Trackers/store/TrackerQueriesDatabaseStore.php
Executable file
84
modules/Trackers/store/TrackerQueriesDatabaseStore.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/store/Store.php');
|
||||
|
||||
class TrackerQueriesDatabaseStore implements Store {
|
||||
|
||||
public function flush($monitor) {
|
||||
|
||||
$metrics = $monitor->getMetrics();
|
||||
$columns = array();
|
||||
$values = array();
|
||||
foreach($metrics as $name=>$metric) {
|
||||
if(!empty($monitor->$name)) {
|
||||
$columns[] = $name;
|
||||
if($metrics[$name]->_type == 'int' || $metrics[$name]->_type == 'double') {
|
||||
$values[] = $GLOBALS['db']->quote($monitor->$name);
|
||||
} else if ($metrics[$name]->_type == 'datetime') {
|
||||
$values[] = ($GLOBALS['db']->dbType == 'oci8') ? db_convert("'".$monitor->$name."'",'datetime') : "'".$monitor->$name."'";
|
||||
} else {
|
||||
$values[] = "'".$GLOBALS['db']->quote($monitor->$name)."'";
|
||||
}
|
||||
}
|
||||
} //foreach
|
||||
|
||||
if(empty($values)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if($monitor->run_count == 1) {
|
||||
if($GLOBALS['db']->dbType == 'oci8') {
|
||||
} else {
|
||||
$query = "INSERT INTO $monitor->table_name (" .implode("," , $columns). " ) VALUES ( ". implode("," , $values). ')';
|
||||
$GLOBALS['db']->query($query);
|
||||
}
|
||||
} else {
|
||||
$query = "UPDATE $monitor->table_name set run_count={$monitor->run_count}, sec_avg={$monitor->sec_avg}, sec_total={$monitor->sec_total}, date_modified='{$monitor->date_modified}' where query_hash = '{$monitor->query_hash}'";
|
||||
$GLOBALS['db']->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
81
modules/Trackers/store/TrackerSessionsDatabaseStore.php
Executable file
81
modules/Trackers/store/TrackerSessionsDatabaseStore.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/Trackers/store/Store.php');
|
||||
class TrackerSessionsDatabaseStore implements Store {
|
||||
|
||||
public function flush($monitor) {
|
||||
|
||||
$metrics = $monitor->getMetrics();
|
||||
$columns = array();
|
||||
$values = array();
|
||||
foreach($metrics as $name=>$metric) {
|
||||
if(!empty($monitor->$name)) {
|
||||
$columns[] = $name;
|
||||
if($metrics[$name]->_type == 'int' || $metrics[$name]->_type == 'double') {
|
||||
$values[] = $GLOBALS['db']->quote($monitor->$name);
|
||||
} else if ($metrics[$name]->_type == 'datetime') {
|
||||
$values[] = ($GLOBALS['db']->dbType == 'oci8') ? db_convert("'".$monitor->$name."'",'datetime') : "'".$monitor->$name."'";
|
||||
} else {
|
||||
$values[] = "'".$GLOBALS['db']->quote($monitor->$name)."'";
|
||||
}
|
||||
}
|
||||
} //foreach
|
||||
|
||||
if(empty($values)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isset($monitor->round_trips) ) $monitor->round_trips = 0;
|
||||
if ( !isset($monitor->active) ) $monitor->active = 1;
|
||||
if($monitor->round_trips == 1) {
|
||||
$query = "INSERT INTO $monitor->table_name (" .implode("," , $columns). " ) VALUES ( ". implode("," , $values). ')';
|
||||
$GLOBALS['db']->query($query);
|
||||
} else {
|
||||
$query = "UPDATE $monitor->table_name SET date_end = '{$monitor->date_end}' , seconds = {$monitor->seconds}, active = '{$monitor->active}', round_trips = $monitor->round_trips WHERE session_id = '{$monitor->session_id}'";
|
||||
$GLOBALS['db']->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
202
modules/Trackers/vardefs.php
Executable file
202
modules/Trackers/vardefs.php
Executable file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* 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
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$dictionary['Tracker'] = array(
|
||||
'table' => 'tracker',
|
||||
'fields' => array(
|
||||
'id'=>array(
|
||||
'name' => 'id',
|
||||
'vname' => 'LBL_ID',
|
||||
'type' => 'int',
|
||||
'len' => '11',
|
||||
'isnull' => 'false',
|
||||
'auto_increment' => true,
|
||||
'reportable'=>true,
|
||||
),
|
||||
'monitor_id'=>array (
|
||||
'name' => 'monitor_id',
|
||||
'vname' => 'LBL_MONITOR_ID',
|
||||
'type' => 'id',
|
||||
'required'=>true,
|
||||
'reportable'=>false,
|
||||
),
|
||||
'user_id'=>array(
|
||||
'name' => 'user_id',
|
||||
'vname' => 'LBL_USER_ID',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'isnull' => 'false',
|
||||
),
|
||||
'module_name'=>array(
|
||||
'name' => 'module_name',
|
||||
'vname' => 'LBL_MODULE_NAME',
|
||||
'type' => 'varchar',
|
||||
'len' => '255',
|
||||
'isnull' => 'false',
|
||||
),
|
||||
'item_id'=>array(
|
||||
'name' => 'item_id',
|
||||
'vname' => 'LBL_ITEM_ID',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'isnull' => 'false',
|
||||
),
|
||||
'item_summary'=>array(
|
||||
'name' => 'item_summary',
|
||||
'vname' => 'LBL_ITEM_SUMMARY',
|
||||
'type' => 'varchar',
|
||||
'len' => '255',
|
||||
'isnull' => 'false',
|
||||
),
|
||||
'date_modified'=>array(
|
||||
'name' => 'date_modified',
|
||||
'vname' => 'LBL_DATE_LAST_ACTION',
|
||||
'type' => 'datetime',
|
||||
'isnull' => 'false',
|
||||
),
|
||||
'action'=>array(
|
||||
'name' => 'action',
|
||||
'vname' => 'LBL_ACTION',
|
||||
'type' => 'varchar',
|
||||
'len' => '255',
|
||||
'isnull' => 'false',
|
||||
),
|
||||
'session_id'=>array(
|
||||
'name' => 'session_id',
|
||||
'vname' => 'LBL_SESSION_ID',
|
||||
'type' => 'varchar',
|
||||
'len' => '36',
|
||||
'isnull' => 'true',
|
||||
),
|
||||
'visible'=>array(
|
||||
'name' => 'visible',
|
||||
'vname' => 'LBL_VISIBLE',
|
||||
'type' => 'bool',
|
||||
'len' => '1',
|
||||
'default' => '0',
|
||||
),
|
||||
'deleted' =>array (
|
||||
'name' => 'deleted',
|
||||
'vname' => 'LBL_DELETED',
|
||||
'type' => 'bool',
|
||||
'default' => '0',
|
||||
'reportable'=>false,
|
||||
'comment' => 'Record deletion indicator'
|
||||
),
|
||||
'assigned_user_link'=>array (
|
||||
'name' => 'assigned_user_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'tracker_user_id',
|
||||
'vname' => 'LBL_ASSIGNED_TO_USER',
|
||||
'link_type' => 'one',
|
||||
'module'=>'Users',
|
||||
'bean_name'=>'User',
|
||||
'source'=>'non-db',
|
||||
),
|
||||
'monitor_id_link'=>array (
|
||||
'name' => 'monitor_id_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'tracker_monitor_id',
|
||||
'vname' => 'LBL_MONITOR_ID',
|
||||
'link_type' => 'one',
|
||||
'module'=>'TrackerPerfs',
|
||||
'bean_name'=>'TrackerPerf',
|
||||
'source'=>'non-db',
|
||||
),
|
||||
) ,
|
||||
|
||||
//indices
|
||||
'indices' => array(
|
||||
array(
|
||||
'name' => 'tracker_pk',
|
||||
'type' => 'primary',
|
||||
'fields' => array(
|
||||
'id'
|
||||
)
|
||||
) ,
|
||||
array(
|
||||
'name' => 'idx_tracker_iid',
|
||||
'type' => 'index',
|
||||
'fields' => array(
|
||||
'item_id',
|
||||
),
|
||||
),
|
||||
array(
|
||||
// shortened name to comply with Oracle length restriction
|
||||
'name' => 'idx_tracker_userid_vis_id',
|
||||
'type' => 'index',
|
||||
'fields' => array(
|
||||
'user_id',
|
||||
'visible',
|
||||
'id',
|
||||
),
|
||||
),
|
||||
array(
|
||||
// shortened name to comply with Oracle length restriction
|
||||
'name' => 'idx_tracker_userid_itemid_vis',
|
||||
'type' => 'index',
|
||||
'fields' => array(
|
||||
'user_id',
|
||||
'item_id',
|
||||
'visible'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'name' => 'idx_tracker_monitor_id',
|
||||
'type' => 'index',
|
||||
'fields' => array(
|
||||
'monitor_id',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'name' => 'idx_tracker_date_modified',
|
||||
'type' => 'index',
|
||||
'fields' => array(
|
||||
'date_modified',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
//relationships
|
||||
'relationships' => array (
|
||||
'tracker_monitor_id' =>
|
||||
array(
|
||||
'lhs_module'=> 'TrackerPerfs', 'lhs_table'=> 'tracker_perf', 'lhs_key' => 'monitor_id',
|
||||
'rhs_module'=> 'Trackers', 'rhs_table'=> 'tracker', 'rhs_key' => 'monitor_id',
|
||||
'relationship_type'=>'one-to-one'
|
||||
)
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user