/**
  * @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_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $mission->save();
         assert('$saved');
         $mission = Mission::getById($mission->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $mission->save();
         $missions[] = $mission->id;
     }
     $demoDataHelper->setRangeByModelName('Mission', $missions[0], $missions[count($missions) - 1]);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     AllPermissionsOptimizationUtil::rebuild();
     SecurityTestHelper::createUsers();
     $billy = User::getByUsername('billy');
     EmailMessageTestHelper::createEmailAccount($billy);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_CREATE_CONTACTS);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_DELETE_CONTACTS);
     assert($billy->save());
     // Not Coding Standard
     $contact = ContactTestHelper::createContactByNameForOwner('sally', Yii::app()->user->userModel);
     $contact->primaryEmail = new Email();
     $contact->primaryEmail->emailAddress = '*****@*****.**';
     $contact->secondaryEmail->emailAddress = '*****@*****.**';
     $contact->addPermissions($billy, Permission::READ);
     $contact->addPermissions($billy, Permission::WRITE);
     $contact->save();
     $molly = ContactTestHelper::createContactByNameForOwner('molly', User::getByUsername('bobby'));
     $molly->primaryEmail = new Email();
     $molly->primaryEmail->emailAddress = '*****@*****.**';
     $molly->secondaryEmail->emailAddress = '*****@*****.**';
     $molly->save();
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($contact, $billy);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     AllPermissionsOptimizationUtil::rebuild();
     SecurityTestHelper::createSuperAdmin();
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     assert($everyoneGroup->save());
     // Not Coding Standard
     $group1 = new Group();
     $group1->name = 'Group1';
     assert($group1->save());
     // Not Coding Standard
     $group2 = new Group();
     $group2->name = 'Group2';
     assert($group2->save());
     // Not Coding Standard
     $group3 = new Group();
     $group3->name = 'Group3';
     assert($group3->save());
     // Not Coding Standard
     $group4 = new Group();
     $group4->name = 'Group4';
     assert($group4->save());
     // Not Coding Standard
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     SecurityTestHelper::createUsers();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     //Setup test data owned by the super user.
     $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
     $account2 = AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
     $contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
     $contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact2', $super, $account2);
     $contact3 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact3', $super, $account);
     $contact4 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact4', $super, $account2);
     $contact5 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact5', $super, $account);
     $marketingList1 = MarketingListTestHelper::createMarketingListByName('MarketingList1', 'MarketingList Description1');
     $marketingList2 = MarketingListTestHelper::createMarketingListByName('MarketingList2', 'MarketingList Description2');
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact1);
     MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList1, $contact2);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact3);
     MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList1, $contact4);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact5);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList2, $contact1);
     MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList2, $contact2);
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     AllPermissionsOptimizationUtil::rebuild();
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $everyoneGroup->save();
     $super = User::getByUsername('super');
     //Steven have access to missions module
     $steven = UserTestHelper::createBasicUser('steven');
     $steven->setRight('MissionsModule', MissionsModule::RIGHT_ACCESS_MISSIONS);
     $steven->save();
     //Jack dont have acess to missions module
     $jack = UserTestHelper::createBasicUser('jack');
     $mission = new Mission();
     $mission->owner = $super;
     $mission->takenByUser = $steven;
     $mission->description = 'My test description';
     $mission->reward = 'My test reward';
     $mission->status = Mission::STATUS_AVAILABLE;
     $mission->addPermissions($everyoneGroup, Permission::READ_WRITE);
     assert($mission->save());
     // Not Coding Standard
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, $everyoneGroup);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $nobody = UserTestHelper::createBasicUser('nobody');
     $nobody->setRight('MarketingListsModule', MarketingListsModule::getAccessRight());
     $saved = $nobody->save();
     static::assertTrue($saved);
     Yii::app()->user->userModel = $nobody;
     //Setup test data owned by the super user.
     $account = AccountTestHelper::createAccountByNameForOwner('nobodyAccount', $nobody);
     $marketingList1 = MarketingListTestHelper::createMarketingListByName('MarketingList1', 'MarketingList Description1');
     $marketingList2 = MarketingListTestHelper::createMarketingListByName('MarketingList2', 'MarketingList Description2');
     for ($i = 0; $i < 17; $i++) {
         if ($i % 2) {
             $unsubscribed = 0;
         } else {
             $unsubscribed = 1;
         }
         $contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('nobodyContact1' . $i, $nobody, $account);
         $contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('nobodyContact2' . $i, $nobody, $account);
         MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList1, $contact1);
         MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList2, $contact2);
     }
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     AllPermissionsOptimizationUtil::rebuild();
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     SecurityTestHelper::createUsers();
     // set up data owned by super
     Yii::app()->user->userModel = User::getByUsername('super');
     $account1 = AccountTestHelper::createAccountByNameForOwner('account1', Yii::app()->user->userModel);
     $contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('contact1', Yii::app()->user->userModel, $account1);
     $contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('contact2', Yii::app()->user->userModel, $account1);
     $contact3 = ContactTestHelper::createContactWithAccountByNameForOwner('contact3', Yii::app()->user->userModel, $account1);
     $marketingList1 = MarketingListTestHelper::createMarketingListByName('MarketingList1');
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact1);
     MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList1, $contact2);
     $member1 = MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList1, $contact3);
     static::$superUserMarketingListId = $marketingList1->id;
     static::$superUserMemberId = $member1->id;
     // set up data owned by nobody
     Yii::app()->user->userModel = UserTestHelper::createBasicUser('nobody');
     $account2 = AccountTestHelper::createAccountByNameForOwner('account2', Yii::app()->user->userModel);
     $contact4 = ContactTestHelper::createContactWithAccountByNameForOwner('contact4', Yii::app()->user->userModel, $account2);
     $contact5 = ContactTestHelper::createContactWithAccountByNameForOwner('contact5', Yii::app()->user->userModel, $account2);
     $contact6 = ContactTestHelper::createContactWithAccountByNameForOwner('contact6', Yii::app()->user->userModel, $account2);
     $marketingList2 = MarketingListTestHelper::createMarketingListByName('MarketingList2');
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList2, $contact4);
     $member2 = MarketingListMemberTestHelper::createMarketingListMember(1, $marketingList2, $contact5);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList2, $contact6);
     static::$regularUserMarketingListId = $marketingList2->id;
     static::$regularUserMemberId = $member2->id;
     AllPermissionsOptimizationUtil::rebuild();
 }
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $gameRewards = array();
     $gameRewardRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('GameRewardsModule', 'GameReward');
     for ($i = 0; $i < 10; $i++) {
         $gameReward = new GameReward();
         $gameReward->name = $gameRewardRandomData['names'][$i];
         $gameReward->owner = $demoDataHelper->getRandomByModelName('User');
         $gameReward->cost = mt_rand(1, 10);
         $gameReward->quantity = mt_rand(1, 20);
         for ($j = 0; $j < 5; $j++) {
             $gameRewardTransaction = new GameRewardTransaction();
             $gameRewardTransaction->person = $demoDataHelper->getRandomByModelName('User');
             $gameRewardTransaction->quantity = mt_rand(1, 3);
             $gameReward->transactions->add($gameRewardTransaction);
         }
         $gameReward->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $gameReward->save();
         if (!$saved) {
             throw new FailedToSaveModelException();
         }
         $gameReward = GameReward::getById($gameReward->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($gameReward, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $gameReward->save();
         $gameRewards[] = $gameReward->id;
     }
     $demoDataHelper->setRangeByModelName('GameReward', $gameRewards[0], $gameRewards[count($gameRewards) - 1]);
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     AllPermissionsOptimizationUtil::rebuild();
     //Add the nobody user to an account, but only read only.
     $nobody = User::getByUsername('nobody');
     $account = AccountTestHelper::createAccountByNameForOwner('superAccountReadableByNobody', Yii::app()->user->userModel);
     $account->addPermissions($nobody, Permission::READ, Permission::ALLOW);
     assert($account->save());
     // Not Coding Standard
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($account, $nobody);
     //Give the nobody user rights to the accounts module.
     $nobody->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
     $nobody->setRight('AccountsModule', AccountsModule::RIGHT_CREATE_ACCOUNTS);
     assert($nobody->save());
     // Not Coding Standard
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     assert($everyoneGroup->save());
     // Not Coding Standard
     $group1 = new Group();
     $group1->name = 'Group1';
     assert($group1->save());
     // Not Coding Standard
 }
Exemplo n.º 11
0
 public function testCreateAndGetMissionById()
 {
     $super = User::getByUsername('super');
     $fileModel = ZurmoTestHelper::createFileModel();
     $steven = UserTestHelper::createBasicUser('steven');
     $steven->setRight('MissionsModule', MissionsModule::RIGHT_ACCESS_MISSIONS);
     $steven->save();
     $dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
     $mission = new Mission();
     $mission->owner = $super;
     $mission->takenByUser = $steven;
     $mission->dueDateTime = $dueStamp;
     $mission->description = 'My test description';
     $mission->reward = 'My test reward';
     $mission->status = Mission::STATUS_AVAILABLE;
     $mission->files->add($fileModel);
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $mission->addPermissions($everyoneGroup, Permission::READ_WRITE);
     $this->assertTrue($mission->save());
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, $everyoneGroup);
     $id = $mission->id;
     $mission->forget();
     unset($mission);
     $mission = Mission::getById($id);
     $this->assertEquals('My test description', $mission->description);
     $this->assertEquals('My test reward', $mission->reward);
     $this->assertEquals(Mission::STATUS_AVAILABLE, $mission->status);
     $this->assertEquals($super, $mission->owner);
     $this->assertEquals($steven, $mission->takenByUser);
     $this->assertEquals(1, $mission->files->count());
     $this->assertEquals($fileModel, $mission->files->offsetGet(0));
     $this->assertEquals($dueStamp, $mission->dueDateTime);
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
 }
 public function actionRebuildMunge()
 {
     AllPermissionsOptimizationUtil::rebuild();
     echo Zurmo::t('ZurmoModule', 'All permissions rebuild complete.') . "<BR>";
     if (SHOW_QUERY_DATA) {
         echo PageView::makeShowQueryDataContent();
     }
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     //Setup test data owned by the super user.
     AllPermissionsOptimizationUtil::rebuild();
     $simpleUser = UserTestHelper::createBasicUser('simpleUser');
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     ZurmoDatabaseCompatibilityUtil::dropStoredFunctionsAndProcedures();
     SecurityTestHelper::createSuperAdmin();
     //do the rebuild to ensure the tables get created properly.
     AllPermissionsOptimizationUtil::rebuild();
     //Manually build the test model munge tables.
     ReadPermissionsOptimizationUtil::recreateTable(ReadPermissionsOptimizationUtil::getMungeTableName('OwnedSecurableTestItem'));
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     UserTestHelper::createBasicUser('nobody');
     static::$listOwnedBySuper = MarketingListTestHelper::createMarketingListByName('MarketingListName', 'MarketingList Description');
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     self::$asynchronousThreshold = ExportModule::$asynchronousThreshold;
     ExportModule::$asynchronousThreshold = 5;
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $super = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $super;
     AllPermissionsOptimizationUtil::rebuild();
     ContactsModule::loadStartingData();
     //Setup test data owned by the super user.
     AccountTestHelper::createAccountByNameForOwner('Dinamite', $super);
     AccountTestHelper::createAccountByNameForOwner('dino', $super);
 }
 public function testGetMungeIdsByUserIncludesEveryoneGroup()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $mungeIds = AllPermissionsOptimizationUtil::getMungeIdsByUser(Yii::app()->user->userModel);
     $this->assertEquals(2, count($mungeIds));
     $group = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $group->save();
     AllPermissionsOptimizationCache::forgetAll();
     $mungeIds = AllPermissionsOptimizationUtil::getMungeIdsByUser(Yii::app()->user->userModel);
     $this->assertEquals(3, count($mungeIds));
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     ZurmoDatabaseCompatibilityUtil::dropStoredFunctionsAndProcedures();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     SecurityTestHelper::createUsers();
     SecurityTestHelper::createGroups();
     SecurityTestHelper::createAccounts();
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     UserTestHelper::createBasicUser('nobody');
     MarketingListTestHelper::createMarketingListByName('MarketingListName', 'MarketingList Description', 'first', '*****@*****.**');
     static::$campaignOwnedBySuper = CampaignTestHelper::createCampaign('campaign01', 'campaign subject 01', 'text content for campaign 01', 'html content for campaign 01', 'fromCampaign', '*****@*****.**');
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $account = AccountTestHelper::createAccountByNameForOwner('account', $super);
     static::$contact = ContactTestHelper::createContactWithAccountByNameForOwner('contact', $super, $account);
     static::$marketingList = MarketingListTestHelper::createMarketingListByName('marketingList', 'description', 'fromName', '*****@*****.**', true);
     static::$marketingListMember = MarketingListMemberTestHelper::createMarketingListMember(1, static::$marketingList, static::$contact);
     AllPermissionsOptimizationUtil::rebuild();
 }
 protected function addReadOptimizationWhereClause(&$where, $whereKey, $tableAliasName)
 {
     assert('is_array($where)');
     assert('is_int($whereKey)');
     assert('is_string($tableAliasName)');
     $q = DatabaseCompatibilityUtil::getQuote();
     $columnWithTableAlias = self::makeColumnNameWithTableAlias($tableAliasName, $this->modelAttributeToDataProviderAdapter->getColumnName());
     $mungeTableName = ReadPermissionsOptimizationUtil::getMungeTableName($this->modelAttributeToDataProviderAdapter->getModelClassName());
     $mungeIds = AllPermissionsOptimizationUtil::getMungeIdsByUser(Yii::app()->user->userModel);
     $whereContent = $columnWithTableAlias . " " . SQLOperatorUtil::getOperatorByType('equals') . " ";
     $whereContent .= "(select securableitem_id from {$q}{$mungeTableName}{$q} " . "where {$q}securableitem_id{$q} = {$columnWithTableAlias} and {$q}munge_id{$q}" . " in ('" . join("', '", $mungeIds) . "') limit 1)";
     $where[$whereKey] = $whereContent;
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     AllPermissionsOptimizationUtil::rebuild();
     $steven = UserTestHelper::createBasicUser('steven');
     //Give user access, create, delete for conversation rights.
     $steven->setRight('ConversationsModule', ConversationsModule::RIGHT_ACCESS_CONVERSATIONS);
     $steven->setRight('ConversationsModule', ConversationsModule::RIGHT_CREATE_CONVERSATIONS);
     $steven->setRight('ConversationsModule', ConversationsModule::RIGHT_DELETE_CONVERSATIONS);
     $steven->save();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     AllPermissionsOptimizationUtil::rebuild();
     $steven = UserTestHelper::createBasicUser('steven');
     $steven->setRight('MissionsModule', MissionsModule::RIGHT_ACCESS_MISSIONS);
     $steven->setRight('MissionsModule', MissionsModule::RIGHT_CREATE_MISSIONS);
     $steven->setRight('MissionsModule', MissionsModule::RIGHT_DELETE_MISSIONS);
     $steven->save();
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $everyoneGroup->save();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     UserTestHelper::createBasicUser('jim');
     AllPermissionsOptimizationUtil::rebuild();
     ContractTestHelper::createContractStagesIfDoesNotExist();
     ContractTestHelper::createContractSourcesIfDoesNotExist();
     $currencies = Currency::getAll();
     //Make Contracts for testing chart data.
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 200;
     $currencyValue->currency = $currencies[0];
     $contract = new Contract();
     $contract->owner = $super;
     $contract->name = 'abc1';
     $contract->amount = $currencyValue;
     $contract->closeDate = '2011-01-01';
     $contract->stage->value = 'Negotiating';
     $contract->source->value = 'Outbound';
     assert($contract->save());
     // Not Coding Standard
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 350;
     $currencyValue->currency = $currencies[0];
     $contract = new Contract();
     $contract->owner = $super;
     $contract->name = 'abc2';
     $contract->amount = $currencyValue;
     $contract->closeDate = '2011-01-01';
     $contract->stage->value = 'Negotiating';
     $contract->source->value = 'Trade Show';
     assert($contract->save());
     // Not Coding Standard
     $currencyValue = new CurrencyValue();
     $currencyValue->value = 100;
     $currencyValue->currency = $currencies[0];
     $contract = new Contract();
     $contract->owner = $super;
     $contract->name = 'abc2';
     $contract->amount = $currencyValue;
     $contract->closeDate = '2011-01-01';
     $contract->stage->value = 'Verbal';
     $contract->source->value = 'Trade Show';
     assert($contract->save());
     // Not Coding Standard
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     $superUserMarketingList = MarketingListTestHelper::createMarketingListByName('superMarketingList');
     static::$superUserMarketingListId = $superUserMarketingList->id;
     $superUserAutoresponder = AutoresponderTestHelper::createAutoresponder('superAutoresponder', 'superText', 'superHtml', 10, Autoresponder::OPERATION_SUBSCRIBE, true, $superUserMarketingList);
     static::$superUserAutoresponderId = $superUserAutoresponder->id;
     Yii::app()->user->userModel = UserTestHelper::createBasicUser('nobody');
     $regularUserMarketingList = MarketingListTestHelper::createMarketingListByName('regularMarketingList');
     static::$regularUserMarketingListId = $regularUserMarketingList->id;
     $regularUserAutoresponder = AutoresponderTestHelper::createAutoresponder('regularAutoresponder', 'regularText', 'regularHtml', 10, Autoresponder::OPERATION_SUBSCRIBE, true, $regularUserMarketingList);
     static::$regularUserAutoresponderId = $regularUserAutoresponder->id;
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     EmailTemplateTestHelper::create('EmailTemplate 01', 'Subject 01', 'Contact', 'Html Content 01', 'Text Content 01');
     EmailTemplateTestHelper::create('EmailTemplate 02', 'Subject 02', 'Contact', 'Html Content 02', 'Text Content 02');
     EmailTemplateTestHelper::create('EmailTemplate 03', 'Subject 03', 'Contact', 'Html Content 03', 'Text Content 03');
     EmailTemplateTestHelper::create('EmailTemplate 04', 'Subject 04', 'Contact', 'Html Content 04', 'Text Content 04');
     EmailTemplateTestHelper::create('EmailTemplate 05', 'Subject 05', 'Contact', 'Html Content 05', 'Text Content 05');
     $marketingList = MarketingListTestHelper::createMarketingListByName('MarketingListName', 'MarketingList Description');
     static::$marketingListId = $marketingList->id;
     AutoresponderTestHelper::createAutoresponder('Subject 01', 'This is text Content 01', 'This is html Content 01', 10, Autoresponder::OPERATION_SUBSCRIBE, true, $marketingList);
     AutoresponderTestHelper::createAutoresponder('Subject 02', 'This is text Content 02', 'This is html Content 02', 5, Autoresponder::OPERATION_UNSUBSCRIBE, false, $marketingList);
     AllPermissionsOptimizationUtil::rebuild();
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $nobody = User::getByUsername('nobody');
     Yii::app()->user->userModel = $nobody;
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     assert($everyoneGroup->save());
     // Not Coding Standard
     $group1 = new Group();
     $group1->name = 'Group1';
     $group1->users->add($nobody);
     assert($group1->save());
     // Not Coding Standard
     AllPermissionsOptimizationUtil::rebuild();
 }
 /**
  * @param string $modelClassName
  * @param null | string $attributeIndexes
  * @param null | string $attributeIndexPrefix
  */
 public static function resolveAttributeIndexes($modelClassName, &$attributeIndexes, $attributeIndexPrefix = null)
 {
     assert('is_string($modelClassName)');
     assert('is_string($attributeIndexPrefix) || $attributeIndexPrefix == null');
     $moduleClassName = $modelClassName::getModuleClassName();
     if (is_subclass_of($modelClassName, 'SecurableItem') && $modelClassName::hasReadPermissionsOptimization() && $moduleClassName != null && is_subclass_of($moduleClassName, 'SecurableModule')) {
         $permission = PermissionsUtil::getActualPermissionDataForReadByModuleNameForUser($moduleClassName);
         if ($permission == Permission::NONE || $permission == Permission::DENY) {
             $indexes = array();
             $indexes[] = 'owner__User';
             $mungeIds = AllPermissionsOptimizationUtil::getMungeIdsByUser(Yii::app()->user->userModel);
             if (count($mungeIds) > 0 && $permission == Permission::NONE) {
                 $indexes[] = 'ReadOptimization';
             }
             $attributeIndexes[$attributeIndexPrefix] = $indexes;
         }
     }
 }