class_CompanyDatabaseWrapper.php

Go to the documentation of this file.
00001 <?php
00024 class CompanyDatabaseWrapper extends BaseDatabaseWrapper {
00028         private $companyInstance = null;
00029 
00030         // Constants for database tables
00031         const DB_TABLE_COMPANY_DATA = "company";
00032         const DB_TABLE_COMPANY_USER = "company_user";
00033 
00039         protected function __construct () {
00040                 // Call parent constructor
00041                 parent::__construct(__CLASS__);
00042         }
00043 
00051         public final static function createCompanyDatabaseWrapper (ShippingCompany $companyInstance = null) {
00052                 // Create a new instance
00053                 $wrapperInstance = new CompanyDatabaseWrapper();
00054 
00055                 // Set (primary!) table name
00056                 $wrapperInstance->setTableName(self::DB_TABLE_COMPANY_DATA);
00057 
00058                 // Set the company instance if not null
00059                 if (!is_null($companyInstance)) {
00060                         $wrapperInstance->setCompanyInstance($companyInstance);
00061                 } // END - if
00062 
00063                 // Return the instance
00064                 return $wrapperInstance;
00065         }
00066 
00073         public function ifUserParticipatesInCompany (ManageableAccount $userInstance)  {
00074                 // By default no user owns any company... ;)
00075                 $participates = false;
00076 
00077                 // Get a search criteria class
00078                 $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
00079 
00080                 // Add the user primary key as a search criteria
00081                 $criteriaInstance->addCriteria("participant_id", $userInstance->getPrimaryKey());
00082                 $criteriaInstance->setLimit(1);
00083 
00084                 // Set company->user table
00085                 $this->setTableName(self::DB_TABLE_COMPANY_USER);
00086 
00087                 // Get the result back
00088                 $resultInstance = $this->doSelectByCriteria($criteriaInstance);
00089 
00090                 // Is there a result?
00091                 if ($resultInstance->next()) {
00092                         // Then cache it
00093                         $this->setResultInstance($resultInstance);
00094 
00095                         // Entry found for further analysis/processing
00096                         $participates = true;
00097                 } // END - if
00098 
00099                 // Return the result
00100                 return $participates;
00101         }
00102 
00110         protected final function setCompanyInstance (ShippingCompany $companyInstance) {
00111                 $this->companyInstance = $companyInstance;
00112         }
00113 
00120         public final function getCompanyInstance () {
00121                 return $this->companyInstance;
00122         }
00123 }
00124 
00125 // [EOF]
00126 ?>

Generated on Mon Dec 8 01:06:44 2008 for Ship-Simulator by  doxygen 1.5.6