Exemplo n.º 1
0
 public function actionLoadCollectionItems()
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         throw new NotSupportedException();
     }
     $collectionData = GameCollection::resolvePersonAndAvailableTypes(Yii::app()->user->userModel, GameCollection::getAvailableTypes());
     foreach ($collectionData as $collection) {
         $itemsData = $collection->getItemsData();
         foreach ($itemsData as $type => $quantity) {
             $itemsData[$type] = $quantity + 1;
         }
         $collection->setItemsData($itemsData);
         $saved = $collection->save();
         if (!$saved) {
             throw new FailedToSaveModelException();
         }
     }
 }
 /**
  * @depends testGetRedemptionCount
  */
 public function testRedeem()
 {
     Yii::app()->user->userModel = User::getByUsername('steven');
     $collections = GameCollection::resolvePersonAndAvailableTypes(Yii::app()->user->userModel, array('Airport'));
     $itemsData = $collections['Airport']->getItemsData();
     $compareData = array('Gate' => 0, 'Passport' => 0, 'Pilot' => 0, 'Luggage' => 0, 'TowTruck' => 0);
     $this->assertEquals($compareData, $itemsData);
     $redeemData = $collections['Airport']->redeem();
     $this->assertEquals(false, $redeemData);
     $itemsData = array('Gate' => 3, 'Passport' => 5, 'Pilot' => 6, 'Luggage' => 8, 'TowTruck' => 7);
     $collections['Airport']->setItemsData($itemsData);
     $this->assertEquals(0, $collections['Airport']->getRedemptionCount());
     $this->assertTrue($collections['Airport']->redeem());
     $this->assertEquals(1, $collections['Airport']->getRedemptionCount());
 }
Exemplo n.º 3
0
 public function actionGameDashboard($id)
 {
     $user = User::getById(intval($id));
     UserAccessUtil::resolveAccessingASystemUser($user);
     $title = Zurmo::t('ZurmoModule', 'Dashboard');
     $badgeData = GameBadge::getAllByPersonIndexedByType($user);
     $generalLevelData = GameLevelUtil::getStatisticsDataForAGivenLevelType($user, GameLevel::TYPE_GENERAL);
     $rankingData = GamePointUtil::getUserRankingData($user);
     $statisticsData = GameLevelUtil::getUserStatisticsData($user);
     $collectionData = GameCollection::resolvePersonAndAvailableTypes($user, GameCollection::getAvailableTypes());
     $dashboardView = new UserGameDashboardView($this, $user, $generalLevelData, $badgeData, $rankingData, $statisticsData, $collectionData);
     $view = new AjaxPageView($dashboardView);
     echo $view->render();
 }