|
1
|
|
|
<?php |
|
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3
|
|
|
/********************************************************************************* |
|
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
|
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
|
6
|
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
|
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
|
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
|
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
|
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
|
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
|
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
|
20
|
|
|
* details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
|
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
|
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
25
|
|
|
* 02110-1301 USA. |
|
26
|
|
|
* |
|
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
|
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
|
29
|
|
|
* |
|
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
|
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
|
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
|
33
|
|
|
* |
|
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
|
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
|
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
|
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
|
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
|
39
|
|
|
********************************************************************************/ |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
class TeamDemoData { |
|
45
|
|
|
var $_team; |
|
46
|
|
|
var $_large_scale_test; |
|
47
|
|
|
|
|
48
|
|
|
var $guids = array( |
|
49
|
|
|
'jim' => 'seed_jim_id', |
|
50
|
|
|
'sarah' => 'seed_sarah_id', |
|
51
|
|
|
'sally' => 'seed_sally_id', |
|
52
|
|
|
'max' => 'seed_max_id', |
|
53
|
|
|
'will' => 'seed_will_id', |
|
54
|
|
|
'chris' => 'seed_chris_id', |
|
55
|
|
|
/* |
|
56
|
|
|
* Pending fix of demo data mechanism |
|
57
|
|
|
'jim' => 'jim00000-0000-0000-0000-000000000000', |
|
58
|
|
|
'sarah' => 'sarah000-0000-0000-0000-000000000000', |
|
59
|
|
|
'sally' => 'sally000-0000-0000-0000-000000000000', |
|
60
|
|
|
'max' => 'max00000-0000-0000-0000-000000000000', |
|
61
|
|
|
'will' => 'will0000-0000-0000-0000-000000000000', |
|
62
|
|
|
'chris' => 'chris000-0000-0000-0000-000000000000', |
|
63
|
|
|
*/ |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Constructor for creating demo data for teams |
|
68
|
|
|
*/ |
|
69
|
|
|
function __construct($seed_team, $large_scale_test = false) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->_team = $seed_team; |
|
72
|
|
|
$this->_large_scale_test = $large_scale_test; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
|
77
|
|
|
*/ |
|
78
|
|
|
function TeamDemoData($seed_team, $large_scale_test = false){ |
|
79
|
|
|
$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
|
80
|
|
|
if(isset($GLOBALS['log'])) { |
|
81
|
|
|
$GLOBALS['log']->deprecated($deprecatedMessage); |
|
82
|
|
|
} |
|
83
|
|
|
else { |
|
84
|
|
|
trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
|
85
|
|
|
} |
|
86
|
|
|
self::__construct($seed_team, $large_scale_test); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* |
|
92
|
|
|
*/ |
|
93
|
|
|
function create_demo_data() { |
|
94
|
|
|
global $current_language; |
|
95
|
|
|
global $sugar_demodata; |
|
96
|
|
|
foreach($sugar_demodata['teams'] as $v) |
|
97
|
|
|
{ |
|
98
|
|
|
if (!$this->_team->retrieve($v['team_id'])) |
|
99
|
|
|
$this->_team->create_team($v['name'], $v['description'], $v['team_id']); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
if($this->_large_scale_test) |
|
103
|
|
|
{ |
|
104
|
|
|
$team_list = $this->_seed_data_get_team_list(); |
|
105
|
|
|
foreach($team_list as $team_name) |
|
106
|
|
|
{ |
|
107
|
|
|
$this->_quick_create($team_name); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$this->add_users_to_team(); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
function add_users_to_team() { |
|
115
|
|
|
// Create the west team memberships |
|
116
|
|
|
$this->_team->retrieve("West"); |
|
117
|
|
|
$this->_team->add_user_to_team($this->guids['sarah']); |
|
118
|
|
|
$this->_team->add_user_to_team($this->guids['sally']); |
|
119
|
|
|
$this->_team->add_user_to_team($this->guids["max"]); |
|
120
|
|
|
|
|
121
|
|
|
// Create the east team memberships |
|
122
|
|
|
$this->_team->retrieve("East"); |
|
123
|
|
|
$this->_team->add_user_to_team($this->guids["will"]); |
|
124
|
|
|
$this->_team->add_user_to_team($this->guids['chris']); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* |
|
129
|
|
|
*/ |
|
130
|
|
|
function get_random_team() |
|
131
|
|
|
{ |
|
132
|
|
|
$team_list = $this->_seed_data_get_team_list(); |
|
133
|
|
|
$team_list_size = count($team_list); |
|
134
|
|
|
$random_index = mt_rand(0,$team_list_size-1); |
|
135
|
|
|
|
|
136
|
|
|
return $team_list[$random_index]; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* |
|
141
|
|
|
*/ |
|
142
|
|
|
function get_random_teamset() |
|
143
|
|
|
{ |
|
144
|
|
|
$team_list = $this->_seed_data_get_teamset_list(); |
|
145
|
|
|
$team_list_size = count($team_list); |
|
146
|
|
|
$random_index = mt_rand(0,$team_list_size-1); |
|
147
|
|
|
|
|
148
|
|
|
return $team_list[$random_index]; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* |
|
154
|
|
|
*/ |
|
155
|
|
|
function _seed_data_get_teamset_list() |
|
156
|
|
|
{ |
|
157
|
|
|
$teamsets = Array(); |
|
158
|
|
|
$teamsets[] = array("East", "West"); |
|
159
|
|
|
$teamsets[] = array("East", "West", "1"); |
|
160
|
|
|
$teamsets[] = array("West", "East"); |
|
161
|
|
|
$teamsets[] = array("West", "East", "1"); |
|
162
|
|
|
$teamsets[] = array("1", "East"); |
|
163
|
|
|
$teamsets[] = array("1", "West"); |
|
164
|
|
|
return $teamsets; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* |
|
170
|
|
|
*/ |
|
171
|
|
|
function _seed_data_get_team_list() |
|
172
|
|
|
{ |
|
173
|
|
|
$teams = Array(); |
|
174
|
|
|
//bug 28138 todo |
|
175
|
|
|
$teams[] = "north"; |
|
176
|
|
|
$teams[] = "south"; |
|
177
|
|
|
$teams[] = "left"; |
|
178
|
|
|
$teams[] = "right"; |
|
179
|
|
|
$teams[] = "in"; |
|
180
|
|
|
$teams[] = "out"; |
|
181
|
|
|
$teams[] = "fly"; |
|
182
|
|
|
$teams[] = "walk"; |
|
183
|
|
|
$teams[] = "crawl"; |
|
184
|
|
|
$teams[] = "pivot"; |
|
185
|
|
|
$teams[] = "money"; |
|
186
|
|
|
$teams[] = "dinero"; |
|
187
|
|
|
$teams[] = "shadow"; |
|
188
|
|
|
$teams[] = "roof"; |
|
189
|
|
|
$teams[] = "sales"; |
|
190
|
|
|
$teams[] = "pillow"; |
|
191
|
|
|
$teams[] = "feather"; |
|
192
|
|
|
|
|
193
|
|
|
return $teams; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* |
|
198
|
|
|
*/ |
|
199
|
|
|
function _quick_create($name) |
|
200
|
|
|
{ |
|
201
|
|
|
if (!$this->_team->retrieve($name)) |
|
202
|
|
|
{ |
|
203
|
|
|
$this->_team->create_team($name, $name, $name); |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
|
|
208
|
|
|
} |
|
209
|
|
|
?> |
|
210
|
|
|
|