Ejemplo n.º 1
0
 public function populateModel(&$model)
 {
     assert('$model instanceof Contact');
     parent::populateModel($model);
     $accountRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('AccountsModule', 'Account');
     $name = RandomDataUtil::getRandomValueFromArray($accountRandomData['names']);
     $model->companyName = $name;
 }
 /**
  * @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]);
 }