Again, a commit! ;-)
[shipsimu.git] / application / ship-simu / main / goverment / class_SimplifiedGoverment.php
index ccdc373a7ef3745a6c151dbf8cec99fcc5978477..7f122d415fd6c88f770c44faa8283fcbb33e8bb8 100644 (file)
@@ -58,18 +58,18 @@ class SimplifiedGoverment extends BaseFrameworkSystem implements Registerable {
        }
 
        /**
-        * Checks wether the goverment has already payed a startup help to the
+        * Checks wether the goverment has already payed a training course for te
         * current user
         *
         * @return      $alreadyPayed   Wether the goverment has already payed
         */
-       public function ifGovermentAlreadyPayedStartupHelp () {
+       public function ifGovermentAlreadyPayedTraining () {
                // Default is not payed
                $alreadyPayed = false;
 
                // Now get a search criteria and set the user's name as criteria
                $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-               $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserName());
+               $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserId());
                $criteriaInstance->addCriteria("gov_activity_status", self::STATUS_STARTER_HELP);
                $criteriaInstance->setLimit(1);
 
@@ -81,13 +81,48 @@ class SimplifiedGoverment extends BaseFrameworkSystem implements Registerable {
 
                // Was the query fine?
                if ($resultInstance->getAffectedRows() === 1) {
-                       // Entry found!
+                       // Entry was found so the goverment can no more pay a training
                        $alreadyPayed = true;
                } // END - if
 
                // Return the result
                return $alreadyPayed;
        }
+
+       /**
+        * Checks wether the goverment has payed maximum of startup helps to the
+        * current user
+        *
+        * @return      $maximumPayed   Wether the goverment has already payed
+        */
+       public function ifGovermentPayedMaxmimumStartupHelp () {
+               // Default is not payed
+               $maximumPayed = false;
+
+               // Cache startup help limit
+               $helpLimit = $this->getConfigInstance()->readConfig('goverment_startup_help_limit');
+
+               // Now get a search criteria and set the user's name as criteria
+               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+               $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserId());
+               $criteriaInstance->addCriteria("gov_activity_status", self::STATUS_STARTER_HELP);
+               $criteriaInstance->setLimit($helpLimit);
+
+               // Get a wrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_gov_wrapper_class');
+
+               // Get result back
+               $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+               // Was the query fine?
+               if ($resultInstance->getAffectedRows() === $helpLimit) {
+                       // Entry found, so lets have a look if this goverment wants to again...
+                       $maximumPayed = true;
+               } // END - if
+
+               // Return the result
+               return $maximumPayed;
+       }
 }
 
 // [EOF]