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