public static function resolveCustomMetadataAndLoad()
 {
     $shouldSaveZurmoModuleMetadata = false;
     $metadata = ZurmoModule::getMetadata();
     //Add Material to Menu if it doesn't exist
     if (!in_array('costbook', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'costbook';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if (!in_array('departmentReferences', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'departmentReferences';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if (!in_array('agreements', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'agreements';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if (!in_array('agreementProducts', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'agreementProducts';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if (!in_array('opportunityProducts', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'opportunityProducts';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if (!in_array('categories', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'categories';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if ($shouldSaveZurmoModuleMetadata) {
         ZurmoModule::setMetadata($metadata);
         GeneralCache::forgetAll();
     }
     Yii::import('application.extensions.zurmoinc.framework.data.*');
     $defaultDataMaker = new AgreementsDefaultDataMaker();
     $defaultDataMaker->make();
     $defaultDataMaker = new CostbooksDefaultDataMaker();
     $defaultDataMaker->make();
     $defaultDataMaker = new OpportunitiesDefaultDataMaker();
     $defaultDataMaker->make();
 }
 public function testGetAndSetByCurrentUserByModuleName()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $this->assertNull(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
     ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'aKey', 'aValue');
     Yii::app()->user->userModel = User::getByUsername('billy');
     $this->assertNull(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
     ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'aKey', 'bValue');
     Yii::app()->user->userModel = User::getByUsername('sally');
     $this->assertNull(ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
     ZurmoConfigurationUtil::setForCurrentUserByModuleName('ZurmoModule', 'aKey', 'cValue');
     //now retrieve again.
     Yii::app()->user->userModel = User::getByUsername('super');
     $this->assertEquals('aValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
     Yii::app()->user->userModel = User::getByUsername('billy');
     $this->assertEquals('bValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
     Yii::app()->user->userModel = User::getByUsername('sally');
     $this->assertEquals('cValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'aKey'));
     //Test retrieving a generic value that is set globally on ZurmoModule. The value returned should be the
     //same for all users.
     $metadata = ZurmoModule::getMetadata();
     $this->assertTrue(!isset($metadata['global']['bKey']));
     $metadata['global']['bKey'] = 'GlobalValue';
     ZurmoModule::setMetadata($metadata);
     Yii::app()->user->userModel = User::getByUsername('super');
     $this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
     Yii::app()->user->userModel = User::getByUsername('billy');
     $this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
     Yii::app()->user->userModel = User::getByUsername('sally');
     $this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
     //Now change the bKey value, just for billy and retrieve again for all users. Only billy's bKey value
     //should be different.
     ZurmoConfigurationUtil::setByUserAndModuleName(User::getByUsername('billy'), 'ZurmoModule', 'bKey', 'BillyBKey');
     Yii::app()->user->userModel = User::getByUsername('super');
     $this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
     Yii::app()->user->userModel = User::getByUsername('billy');
     $this->assertEquals('BillyBKey', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
     Yii::app()->user->userModel = User::getByUsername('sally');
     $this->assertEquals('GlobalValue', ZurmoConfigurationUtil::getForCurrentUserByModuleName('ZurmoModule', 'bKey'));
 }
Esempio n. 3
0
 public static function resolveCustomMetadataAndLoad()
 {
     $shouldSaveZurmoModuleMetadata = false;
     $metadata = ZurmoModule::getMetadata();
     if (!in_array('animals', $metadata['global']['tabMenuItemsModuleOrdering'])) {
         $metadata['global']['tabMenuItemsModuleOrdering'][] = 'animals';
         $shouldSaveZurmoModuleMetadata = true;
     }
     if ($shouldSaveZurmoModuleMetadata) {
         ZurmoModule::setMetadata($metadata);
         GeneralCache::forgetAll();
     }
     $metadata = Activity::getMetadata();
     if (!in_array('Animal', $metadata['Activity']['activityItemsModelClassNames'])) {
         $metadata['Activity']['activityItemsModelClassNames'][] = 'Animal';
         Activity::setMetadata($metadata);
         GeneralCache::forgetAll();
     }
     Yii::import('application.extensions.zurmoinc.framework.data.*');
     Yii::import('application.modules.animals.data.*');
     $defaultDataMaker = new AnimalsDefaultDataMaker();
     $defaultDataMaker->make();
 }