Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
SocialItemsDemoDataMaker.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
42  protected $ratioToLoad = 1;
43 
44  public static function getDependencies()
45  {
46  return array('users', 'groups', 'accounts');
47  }
48 
52  public function makeAll(& $demoDataHelper)
53  {
54  assert('$demoDataHelper instanceof DemoDataHelper');
55  assert('$demoDataHelper->isSetRange("User")');
56  assert('$demoDataHelper->isSetRange("Account")');
57 
58  $socialItems = array();
59  $data = self::getSocialItemData();
60  shuffle($data);
61  foreach ($data as $randomSocialItemData)
62  {
63  $postData = array();
64  $socialItem = new SocialItem();
65  $socialItem->setScenario('importModel');
66  $socialItem->owner = $demoDataHelper->getRandomByModelName('User');
67  $socialItem->createdByUser = $socialItem->owner;
68  //check if we should connect to a note
69  if (isset($randomSocialItemData['noteDescription']))
70  {
71  $note = new Note();
72  $account = $demoDataHelper->getRandomByModelName('Account');
73  $note->description = $randomSocialItemData['noteDescription'];
74  $note->owner = $socialItem->owner;
75  $note->activityItems->add($account);
76  $this->populateModel($note);
77  $saved = $note->save();
78  assert('$saved');
79  $socialItem->note = $note;
80  }
81  else
82  {
83  $socialItem->description = $randomSocialItemData['description'];
84  }
85  //Add some comments
86  foreach ($randomSocialItemData['comments'] as $commentDescription)
87  {
88  $comment = new Comment();
89  $comment->setScenario('importModel');
90  $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
91  $comment->description = $commentDescription;
92  $socialItem->comments->add($comment);
93  }
94  $socialItem->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME),
95  Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
96  $saved = $socialItem->save();
97  assert('$saved');
98  $socialItems[] = $socialItem->id;
99  }
100  $demoDataHelper->setRangeByModelName('SocialItem', $socialItems[0], $socialItems[count($socialItems) - 1]);
101  }
102 
103  protected static function getSocialItemData()
104  {
105  $data = array(
106  array('description' => 'Where should we have the Christmas party?',
107  'comments' => array(
108  'How about at a museum?',
109  'I am going to be out of town, so I can\'t attend.',
110  'I guess i can take this on.',
111  )),
112  array('description' => 'Golf time',
113  'comments' => array(
114  'I wish i was in sales..',
115  'Dude, IT just twiddles their thumbs most of the time anyways :)',
116  'Yeah whatever..',
117  'I am in for golf, primarly drinking and riding the cart.'
118  )),
119  array('description' => 'Anyone interested in going to San Diego for the trade show?',
120  'comments' => array()),
121  array('description' => 'Just stubbed my toe. Ouch!',
122  'comments' => array()),
123  array('description' => 'Ask Barry why we can\'t use our cell phones in the conference room',
124  'comments' => array()),
125  array('description' => 'I love fridays!',
126  'comments' => array(
127  'Dude, get to work',
128  'Lets get some beers',
129  )),
130  array('noteDescription' => 'Bam. Closed another deal!',
131  'comments' => array(
132  'Awesome!',
133  'I second that.',
134  'You are buying drinks tonight'
135  )),
136  array('noteDescription' => 'This account is heating up!',
137  'comments' => array(
138  'I would love us to get this guy as a customer',
139  'I second that.',
140  'Would be an amazing case study'
141  )),
142  array('noteDescription' => 'Why is this customer having so many problems. Sigh',
143  'comments' => array(
144  'Did you contact Sarah in client services yet?',
145  'That is probably a good idea',
146  'Only if sarah is having a good day',
147  )),
148  array('description' => 'Game on! I received a new badge: For being awesome',
149  'comments' => array()),
150  array('description' => 'Game on! I reached level 2',
151  'comments' => array()),
152  array('description' => 'Game on! I received a new badge: 15 accounts created',
153  'comments' => array()),
154  array('description' => 'Game on! I reached level 3',
155  'comments' => array()),
156  array('description' => 'Game on! I received a new badge: 5 opportunities searched',
157  'comments' => array()),
158  array('description' => 'Game on! I reached level 4',
159  'comments' => array()),
160  array('description' => 'Game on! I received a new badge: Logged in 5 times at night',
161  'comments' => array()),
162  array('description' => 'Game on! I reached level 5',
163  'comments' => array()),
164  );
165  return $data;
166  }
167  }
168 ?>
populateModel(&$model)
Definition: Note.php:37
static getByName($name)
Definition: Group.php:57
Generated on Tue Jul 14 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.