00001 <?php 00025 class SimplifiedGovernment extends BaseFrameworkSystem implements Registerable { 00026 // Constants 00027 const STATUS_STARTER_HELP = "STARTER_HELP"; 00028 00034 protected function __construct () { 00035 // Call parent constructor 00036 parent::__construct(__CLASS__); 00037 00038 // Clean up a little 00039 $this->removeSystemArray(); 00040 $this->removeNumberFormaters(); 00041 } 00042 00049 public final static function createSimplifiedGovernment (ManageableAccount $userInstance) { 00050 // Get a new instance 00051 $governmentInstance = new SimplifiedGovernment(); 00052 00053 // Set the user instance 00054 $governmentInstance->setUserInstance($userInstance); 00055 00056 // Return the prepared instance 00057 return $governmentInstance; 00058 } 00059 00066 public function ifGovernmentAlreadyPayedTraining () { 00067 // Default is not payed 00068 $alreadyPayed = false; 00069 00070 // Now get a search criteria and set the user's name as criteria 00071 $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); 00072 $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserId()); 00073 $criteriaInstance->addCriteria("gov_activity_status", self::STATUS_STARTER_HELP); 00074 $criteriaInstance->setLimit(1); 00075 00076 // Get a wrapper instance 00077 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_gov_wrapper_class'); 00078 00079 // Get result back 00080 $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); 00081 00082 // Was the query fine? 00083 if ($resultInstance->getAffectedRows() === 1) { 00084 // Entry was found so the government can no more pay a training 00085 $alreadyPayed = true; 00086 } // END - if 00087 00088 // Return the result 00089 return $alreadyPayed; 00090 } 00091 00098 public function ifGovernmentPayedMaxmimumStartupHelp () { 00099 // Default is not payed 00100 $maximumPayed = false; 00101 00102 // Cache startup help limit 00103 $helpLimit = $this->getConfigInstance()->readConfig('government_startup_help_limit'); 00104 00105 // Now get a search criteria and set the user's name as criteria 00106 $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); 00107 $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserId()); 00108 $criteriaInstance->addCriteria("gov_activity_status", self::STATUS_STARTER_HELP); 00109 $criteriaInstance->setLimit($helpLimit); 00110 00111 // Get a wrapper instance 00112 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_gov_wrapper_class'); 00113 00114 // Get result back 00115 $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); 00116 00117 // Was the query fine? 00118 if ($resultInstance->getAffectedRows() === $helpLimit) { 00119 // Entry found, so lets have a look if this government wants to again... 00120 $maximumPayed = true; 00121 } // END - if 00122 00123 // Return the result 00124 return $maximumPayed; 00125 } 00126 } 00127 00128 // [EOF] 00129 ?>
1.5.6