00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 Yii::import('application.modules.gamification.controllers.DefaultController', true);
00038 class GamificationDemoController extends GamificationDefaultController
00039 {
00043 public function actionLoadGameNotificationsSampler()
00044 {
00045 if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel))
00046 {
00047 throw new NotSupportedException();
00048 }
00049
00050 $coinsValue = GameCoinRules::getCoinsByLevel(2);
00051 $gameNotification = new GameNotification();
00052 $gameNotification->user = Yii::app()->user->userModel;
00053 $gameNotification->setLevelChangeByNextLevelValue(2, $coinsValue);
00054 $saved = $gameNotification->save();
00055
00056
00057 $gameNotification = new GameNotification();
00058 $gameNotification->user = Yii::app()->user->userModel;
00059 $gameNotification->setNewBadgeByType('LoginUser');
00060 $saved = $gameNotification->save();
00061
00062
00063 $gameNotification = new GameNotification();
00064 $gameNotification->user = Yii::app()->user->userModel;
00065 $gameNotification->setBadgeGradeChangeByTypeAndNewGrade('LoginUser', 5);
00066 $saved = $gameNotification->save();
00067
00068
00069 GameCollection::processRandomReceivingCollectionItemByUser(Yii::app()->user->userModel);
00070
00071 echo "Demo data has been loaded. Go back to the application.";
00072 }
00073
00074 public function actionLoadCollectionItems()
00075 {
00076 if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel))
00077 {
00078 throw new NotSupportedException();
00079 }
00080 $collectionData = GameCollection::resolvePersonAndAvailableTypes(Yii::app()->user->userModel, GameCollection::getAvailableTypes());
00081 foreach ($collectionData as $collection)
00082 {
00083 $itemsData = $collection->getItemsData();
00084 foreach ($itemsData as $type => $quantity)
00085 {
00086 $itemsData[$type] = $quantity + 1;
00087 }
00088 $collection->setItemsData($itemsData);
00089 $saved = $collection->save();
00090 if (!$saved)
00091 {
00092 throw new FailedToSaveModelException();
00093 }
00094 }
00095 }
00096 }
00097 ?>