/**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Opportunity")');
     $meetings = array();
     //Future meetings
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $meeting = new Meeting();
         $opportunity = $demoDataHelper->getRandomByModelName('Opportunity');
         $meeting->owner = $opportunity->owner;
         $meeting->activityItems->add($opportunity);
         $meeting->activityItems->add($opportunity->contacts[0]);
         $meeting->activityItems->add($opportunity->account);
         $this->populateModel($meeting);
         $saved = $meeting->save();
         assert('$saved');
         $meetings[] = $meeting->id;
     }
     //Past meetings
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $meeting = new Meeting();
         $opportunity = $demoDataHelper->getRandomByModelName('Opportunity');
         $meeting->owner = $opportunity->owner;
         $meeting->activityItems->add($opportunity);
         $meeting->activityItems->add($opportunity->contacts[0]);
         $meeting->activityItems->add($opportunity->account);
         $this->populateModel($meeting, false);
         $saved = $meeting->save();
         assert('$saved');
         $meetings[] = $meeting->id;
     }
     $demoDataHelper->setRangeByModelName('Meeting', $meetings[0], $meetings[count($meetings) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("Contact")');
     assert('$demoDataHelper->isSetRange("Autoresponder")');
     $items = array();
     if ($this->loadMagnitude >= 100) {
         foreach (Autoresponder::getAll() as $autoresponder) {
             foreach ($autoresponder->marketingList->marketingListMembers as $marketingListMember) {
                 $item = new AutoresponderItem();
                 $item->autoresponder = $autoresponder;
                 $item->contact = $marketingListMember->contact;
                 $this->populateModel($item);
                 $saved = $item->unrestrictedSave();
                 assert('$saved');
                 $items[] = $item->id;
             }
         }
     } else {
         for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
             $item = new AutoresponderItem();
             $item->autoresponder = $demoDataHelper->getRandomByModelName('Autoresponder');
             $item->contact = $demoDataHelper->getRandomByModelName('Contact');
             $this->populateModel($item);
             $saved = $item->unrestrictedSave();
             assert('$saved');
             $items[] = $item->id;
         }
     }
     $demoDataHelper->setRangeByModelName('AutoresponderItem', $items[0], $items[count($items) - 1]);
 }
Ejemplo n.º 3
0
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $missions = array();
     foreach (self::getMissionData() as $randomMissionData) {
         $postData = array();
         $mission = new Mission();
         $mission->setScenario('importModel');
         $mission->status = Mission::STATUS_AVAILABLE;
         $mission->owner = $demoDataHelper->getRandomByModelName('User');
         $mission->createdByUser = $mission->owner;
         $mission->description = $randomMissionData['description'];
         $mission->reward = $randomMissionData['reward'];
         //Add some comments
         foreach ($randomMissionData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $mission->comments->add($comment);
         }
         $mission->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE);
         $saved = $mission->save();
         assert('$saved');
         $mission = Mission::getById($mission->id);
         ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $mission->save();
         $missions[] = $mission->id;
     }
     $demoDataHelper->setRangeByModelName('Mission', $missions[0], $missions[count($missions) - 1]);
 }
Ejemplo n.º 4
0
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Opportunity")');
     $tasks = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $task = new Task();
         $opportunity = $demoDataHelper->getRandomByModelName('Opportunity');
         $task->owner = $opportunity->owner;
         $task->completed = false;
         if ($i % 2 == 0) {
             $task->status = Task::STATUS_NEW;
         } elseif ($i % 3 == 0) {
             $task->status = Task::STATUS_IN_PROGRESS;
         } elseif ($i % 5 == 0) {
             $task->status = Task::STATUS_COMPLETED;
         }
         $task->activityItems->add($opportunity);
         $task->activityItems->add($opportunity->contacts[0]);
         $task->activityItems->add($opportunity->account);
         //Notification subscriber
         $notificationSubscriber = new NotificationSubscriber();
         $notificationSubscriber->person = $demoDataHelper->getRandomByModelName('User');
         $notificationSubscriber->hasReadLatest = false;
         $task->notificationSubscribers->add($notificationSubscriber);
         $this->populateModel($task);
         $saved = $task->save();
         assert('$saved');
         $tasks[] = $task->id;
     }
     $demoDataHelper->setRangeByModelName('Task', $tasks[0], $tasks[count($tasks) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("MarketingList")');
     $autoresponders = array();
     if ($this->loadMagnitude >= 100) {
         foreach (MarketingList::getAll() as $marketingList) {
             for ($this->index = 0; $this->index < 2; $this->index++) {
                 $autoresponder = new Autoresponder();
                 $autoresponder->marketingList = $marketingList;
                 $this->populateModel($autoresponder);
                 $saved = $autoresponder->save();
                 assert('$saved');
                 $autoresponders[] = $autoresponder->id;
             }
         }
     } else {
         for ($this->index = 0; $this->index < 4; $this->index++) {
             $autoresponder = new Autoresponder();
             $autoresponder->marketingList = $demoDataHelper->getRandomByModelName('MarketingList');
             $this->populateModel($autoresponder);
             $saved = $autoresponder->save();
             assert('$saved');
             $autoresponders[] = $autoresponder->id;
         }
     }
     $demoDataHelper->setRangeByModelName('Autoresponder', $autoresponders[0], $autoresponders[count($autoresponders) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     $socialItems = array();
     $data = self::getSocialItemData();
     shuffle($data);
     foreach ($data as $randomSocialItemData) {
         $postData = array();
         $socialItem = new SocialItem();
         $socialItem->setScenario('importModel');
         $socialItem->owner = $demoDataHelper->getRandomByModelName('User');
         $socialItem->createdByUser = $socialItem->owner;
         //check if we should connect to a note
         if (isset($randomSocialItemData['noteDescription'])) {
             $note = new Note();
             $account = $demoDataHelper->getRandomByModelName('Account');
             $note->description = $randomSocialItemData['noteDescription'];
             $note->owner = $socialItem->owner;
             $note->activityItems->add($account);
             $this->populateModel($note);
             $saved = $note->save();
             assert('$saved');
             $socialItem->note = $note;
         } else {
             $socialItem->description = $randomSocialItemData['description'];
         }
         //Add some comments
         foreach ($randomSocialItemData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $socialItem->comments->add($comment);
         }
         $socialItem->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $socialItem->save();
         assert('$saved');
         $socialItems[] = $socialItem->id;
     }
     $demoDataHelper->setRangeByModelName('SocialItem', $socialItems[0], $socialItems[count($socialItems) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     $conversations = array();
     foreach (self::getConversationData() as $randomConversationData) {
         $postData = array();
         $conversation = new Conversation();
         $conversation->setScenario('importModel');
         $conversation->owner = $demoDataHelper->getRandomByModelName('User');
         $conversation->createdByUser = $conversation->owner;
         $conversation->conversationItems->add($demoDataHelper->getRandomByModelName('Account'));
         $conversation->subject = $randomConversationData['subject'];
         $conversation->description = $randomConversationData['description'];
         //Add some comments
         foreach ($randomConversationData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $conversation->comments->add($comment);
             self::addItemIdToPostData($postData, $comment->createdByUser->getClassId('Item'));
         }
         //Add Super user
         $comment = new Comment();
         $comment->description = 'Great idea guys. Keep it coming.';
         $conversation->comments->add($comment);
         self::addItemIdToPostData($postData, Yii::app()->user->userModel->getClassId('Item'));
         $saved = $conversation->save();
         assert('$saved');
         //any user who has made a comment should be added as a participant and resolve permissions
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
         ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$saved');
         $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$success');
         $conversations[] = $conversation->id;
     }
     $demoDataHelper->setRangeByModelName('Conversation', $conversations[0], $conversations[count($conversations) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     $contactWebFormEntries = array();
     for ($this->index = 0; $this->index < 5; $this->index++) {
         $contactWebFormEntry = new ContactWebFormEntry();
         $contactWebFormEntry->contactWebForm = $demoDataHelper->getRandomByModelName('ContactWebForm');
         $this->populateModel($contactWebFormEntry);
         $saved = $contactWebFormEntry->save();
         assert('$saved');
         $contactWebFormEntries[] = $contactWebFormEntry->id;
     }
     $demoDataHelper->setRangeByModelName('ContactWebFormEntry', $contactWebFormEntries[0], $contactWebFormEntries[count($contactWebFormEntries) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $accounts = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $account = new Account();
         $account->owner = $demoDataHelper->getRandomByModelName('User');
         $this->populateModel($account);
         $saved = $account->save();
         assert('$saved');
         $accounts[] = $account->id;
     }
     $demoDataHelper->setRangeByModelName('Account', $accounts[0], $accounts[count($accounts) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     $projects = array();
     $super = User::getByUsername('super');
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $project = new Project();
         $project->owner = $demoDataHelper->getRandomByModelName('User');
         $account = $demoDataHelper->getRandomByModelName('Account');
         $project->accounts->add($account);
         $this->populateModel($project);
         $project->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $project->save();
         assert('$saved');
         $project = Project::getById($project->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($project, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $project->save();
         assert('$saved');
         ProjectAuditEvent::logAuditEvent(ProjectAuditEvent::PROJECT_CREATED, $project, $project->name);
         self::addDemoTasks($project, 3, $demoDataHelper);
         $projects[] = $project->id;
     }
     $demoDataHelper->setRangeByModelName('Project', $projects[0], $projects[count($projects) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("Contact")');
     assert('$demoDataHelper->isSetRange("EmailMessageUrl")');
     assert('$demoDataHelper->isSetRange("AutoresponderItem")');
     $activities = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $activity = new AutoresponderItemActivity();
         $autoresponderItem = $demoDataHelper->getRandomByModelName('AutoresponderItem');
         $activity->autoresponderItem = $autoresponderItem;
         $activity->person = $activity->autoresponderItem->contact;
         if (rand() % 4) {
             $emailMessageUrl = $demoDataHelper->getRandomByModelName('EmailMessageUrl');
             $activity->emailMessageUrl = $emailMessageUrl;
         }
         $this->populateModel($activity);
         $saved = $activity->save();
         assert('$saved');
         $activities[] = $activity->id;
     }
     $demoDataHelper->setRangeByModelName('AutoresponderItemActivity', $activities[0], $activities[count($activities) - 1]);
     $this->populateMarketingItems('AutoresponderItem', $activity->autoresponderItem->autoresponder->subject);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $marketingLists = array();
     for ($this->index = 0; $this->index < 5; $this->index++) {
         $marketingList = new MarketingList();
         $marketingList->owner = $demoDataHelper->getRandomByModelName('User');
         $this->populateModel($marketingList);
         $marketingList->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $marketingList->save();
         assert('$saved');
         $marketingList = MarketingList::getById($marketingList->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($marketingList, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $marketingList->save();
         $marketingLists[] = $marketingList->id;
     }
     $demoDataHelper->setRangeByModelName('MarketingList', $marketingLists[0], $marketingLists[count($marketingLists) - 1]);
 }
Ejemplo n.º 13
0
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $contactStates = ContactState::getAll();
     $statesBeginningWithStartingState = $this->getStatesBeforeOrStartingWithStartingState($contactStates);
     $contacts = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $contact = new Contact();
         $contact->owner = $demoDataHelper->getRandomByModelName('User');
         $contact->state = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
         $this->populateModel($contact);
         $saved = $contact->save();
         assert('$saved');
         $contacts[] = $contact->id;
     }
     //We can use dummy model name here ContactsThatAreLeads, so we can distinct between contacts are leads
     $demoDataHelper->setRangeByModelName('ContactsThatAreLeads', $contacts[0], $contacts[count($contacts) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Opportunity")');
     $notes = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $note = new Note();
         $opportunity = $demoDataHelper->getRandomByModelName('Opportunity');
         $note->owner = $opportunity->owner;
         $note->activityItems->add($opportunity);
         $note->activityItems->add($opportunity->contacts[0]);
         $note->activityItems->add($opportunity->account);
         $this->populateModel($note);
         $saved = $note->save();
         assert('$saved');
         $notes[] = $note->id;
     }
     $demoDataHelper->setRangeByModelName('Note', $notes[0], $notes[count($notes) - 1]);
 }
Ejemplo n.º 15
0
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $emailTemplates = array();
     $types = array_keys(EmailTemplate::getTypeDropDownArray());
     for ($this->index = 0; $this->index < 7; $this->index++) {
         $emailTemplate = new EmailTemplate();
         $emailTemplate->type = $types[$this->index % 2];
         $emailTemplate->owner = $demoDataHelper->getRandomByModelName('User');
         $this->populateModel($emailTemplate);
         $emailTemplate->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $emailTemplate->save();
         assert('$saved');
         $emailTemplate = EmailTemplate::getById($emailTemplate->id);
         ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailTemplate, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $emailTemplate->save();
         $emailTemplates[] = $emailTemplate->id;
     }
     $demoDataHelper->setRangeByModelName('EmailTemplate', $emailTemplates[0], $emailTemplates[count($emailTemplates) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     assert('$demoDataHelper->isSetRange("Contact")');
     $currencies = Currency::getAll('id');
     $opportunities = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $opportunity = new Opportunity();
         $opportunity->contacts->add($demoDataHelper->getRandomByModelName('Contact'));
         $opportunity->account = $opportunity->contacts[0]->account;
         $opportunity->owner = $opportunity->contacts[0]->owner;
         $currencyValue = new CurrencyValue();
         $currencyValue->currency = $currencies[array_rand($currencies)];
         $opportunity->amount = $currencyValue;
         $this->populateModel($opportunity);
         $saved = $opportunity->save();
         assert('$saved');
         $opportunities[] = $opportunity->id;
     }
     $demoDataHelper->setRangeByModelName('Opportunity', $opportunities[0], $opportunities[count($opportunities) - 1]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $contactStates = ContactState::getAll();
     $statesBeginningWithStartingState = ContactsDemoDataMaker::getStatesBeforeOrStartingWithStartingState($contactStates);
     $contactWebForms = array();
     for ($this->index = 0; $this->index < 5; $this->index++) {
         $contactWebForm = new ContactWebForm();
         $contactWebForm->owner = $demoDataHelper->getRandomByModelName('User');
         $contactWebForm->defaultOwner = $contactWebForm->owner;
         $contactWebForm->defaultState = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
         $this->populateModel($contactWebForm);
         $contactWebForm->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $contactWebForm->save();
         assert('$saved');
         $contactWebForm = ContactWebForm::getById($contactWebForm->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($contactWebForm, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $contactWebForm->save();
         $contactWebForms[] = $contactWebForm->id;
     }
     $demoDataHelper->setRangeByModelName('ContactWebForm', $contactWebForms[0], $contactWebForms[count($contactWebForms) - 1]);
 }