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.
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.
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
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
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.
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.
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 ********************************************************************************/
43 var $_large_scale_test;
45 'jim' => 'seed_jim_id',
46 'sarah' => 'seed_sarah_id',
47 'sally' => 'seed_sally_id',
48 'max' => 'seed_max_id',
49 'will' => 'seed_will_id',
50 'chris' => 'seed_chris_id',
52 * Pending fix of demo data mechanism
53 'jim' => 'jim00000-0000-0000-0000-000000000000',
54 'sarah' => 'sarah000-0000-0000-0000-000000000000',
55 'sally' => 'sally000-0000-0000-0000-000000000000',
56 'max' => 'max00000-0000-0000-0000-000000000000',
57 'will' => 'will0000-0000-0000-0000-000000000000',
58 'chris' => 'chris000-0000-0000-0000-000000000000',
63 * Constructor for creating user demo data
65 function UserDemoData($seed_user, $large_scale_test = false)
67 // use a seed user so it does not have to be known which file to
68 // include the User class from
69 $this->_user = $seed_user;
70 $this->_large_scale_test = $large_scale_test;
76 function create_demo_data()
78 global $current_language;
79 global $sugar_demodata;
80 foreach($sugar_demodata['users'] as $v)
82 $this->_create_seed_user($v['id'], $v['last_name'], $v['first_name'], $v['user_name'], $v['title'], $v['is_admin'], $v['reports_to'], $v['reports_to_name'], $v['email']);
85 if($this->_large_scale_test) {
86 $user_list = $this->_seed_data_get_user_list();
87 foreach($user_list as $user_name)
89 $this->_quick_create_user($user_name);
96 * Create a user in the seed data.
98 function _create_seed_user($id, $last_name, $first_name, $user_name,
99 $title, $is_admin, $reports_to, $reports_to_name, $email)
104 $u->new_with_id = true;
105 $u->last_name = $last_name;
106 $u->first_name = $first_name;
107 $u->user_name = $user_name;
109 $u->status = 'Active';
110 $u->employee_status = 'Active';
111 $u->is_admin = $is_admin;
112 //$u->user_password = $u->encrypt_password($user_name);
113 $u->user_hash = User::getPasswordHash($user_name);
114 $u->reports_to_id = $reports_to;
115 $u->reports_to_name = $reports_to_name;
116 //$u->email1 = $email;
117 $u->emailAddress->addAddress($email, true);
118 $u->emailAddress->addAddress("reply.".$email, false, true);
119 $u->emailAddress->addAddress("alias.".$email);
121 // bug 15371 tyoung set a user preference so that Users/DetailView.php can find something without repeatedly querying the db in vain
122 $u->setPreference('max_tabs','7');
123 $u->savePreferencesToDB();
126 $u->picture = $this->_copy_user_image($id);
134 function _seed_data_get_user_list()
156 $users[] = "feather";
164 function _quick_create_user($name)
166 global $sugar_demodata;
167 if (!$this->_user->retrieve($name.'_id'))
169 $this->_create_seed_user("{$name}_id", $name, $name, $name,
170 $sugar_demodata['users'][0]['title'], $sugar_demodata['users'][0]['is_admin'], "seed_jim_id", $sugar_demodata['users'][0]['last_name'].", ".$sugar_demodata['users'][0]['first_name'], $sugar_demodata['users'][0]['email']);
174 function _copy_user_image($id) {
175 global $sugar_config;
176 $picture_file = create_guid();
177 $file = "include/images/".$id.".gif";
178 $newfile = "upload://$picture_file";
179 if (!copy($file, $newfile)) {
181 $GLOBALS['log']->fatal(string_format($app_strings['ERR_FILE_NOT_FOUND'], array($file)));
184 return $picture_file;