From e433812994d5f9a15d2be01b271c3a46bda729ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 28 Jun 2008 15:46:07 +0000 Subject: [PATCH] Company stubs now finished, output of 'company_status' added --- .gitattributes | 1 + .../main/companies/class_ShippingCompany.php | 66 +++++++++++++++++++ .../templates/de/code/block_company_data.ctp | 7 ++ .../templates/de/code/block_persona_data.ctp | 2 +- .../templates/de/code/login_main.ctp | 16 +++-- .../web/blocks/class_WebBlockHelper.php | 26 ++++++++ 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 application/ship-simu/templates/de/code/block_company_data.ctp diff --git a/.gitattributes b/.gitattributes index 9598bc1..ba30777 100644 --- a/.gitattributes +++ b/.gitattributes @@ -136,6 +136,7 @@ application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php -text application/ship-simu/starter.php -text application/ship-simu/templates/.htaccess -text application/ship-simu/templates/de/.htaccess -text +application/ship-simu/templates/de/code/block_company_data.ctp -text application/ship-simu/templates/de/code/block_persona_data.ctp -text application/ship-simu/templates/de/code/captch_graphic_code.ctp -text application/ship-simu/templates/de/code/footer.ctp -text diff --git a/application/ship-simu/main/companies/class_ShippingCompany.php b/application/ship-simu/main/companies/class_ShippingCompany.php index e3bd591..841be84 100644 --- a/application/ship-simu/main/companies/class_ShippingCompany.php +++ b/application/ship-simu/main/companies/class_ShippingCompany.php @@ -138,6 +138,72 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner return $participates; } + /** + * Checks wether the current user in registry is the company founder + * + * @return $isFounder Wether the current user is the company founder + */ + public function ifUserIsFounder () { + // Default is not the founder + $isFounder = false; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is it set? + if ($resultInstance instanceof SearchableResult) { + // Result found so analyse it + $this->partialStub("Check if user is company founder."); + } // END - if + + // Return result + return $isFounder; + } + + /** + * Checks wether the current user in registry is the company owner + * + * @return $isOwner Wether the current user is the company owner + */ + public function ifUserIsOwner () { + // Default is not the owner + $isOwner = false; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is it set? + if ($resultInstance instanceof SearchableResult) { + // Result found so analyse it + $this->partialStub("Check if user is company owner."); + } // END - if + + // Return result + return $isOwner; + } + + /** + * Checks wether the current user in registry is an employee in this company + * + * @return $isOwner Wether the current user is an employee in this company + */ + public function ifUserIsEmployee () { + // Default is no employee + $isEmployee = false; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is it set? + if ($resultInstance instanceof SearchableResult) { + // Result found so he is employee + $isEmployee = true; + } // END - if + + // Return result + return $isEmployee; + } + //---------------------------------------------------------------------------- // From here is very old code which needs to be translated and changed heavily //---------------------------------------------------------------------------- diff --git a/application/ship-simu/templates/de/code/block_company_data.ctp b/application/ship-simu/templates/de/code/block_company_data.ctp new file mode 100644 index 0000000..7a6037e --- /dev/null +++ b/application/ship-simu/templates/de/code/block_company_data.ctp @@ -0,0 +1,7 @@ +
+ Firmenstatus: {?company_status?} +
+
+ {?company_link_text?} +
diff --git a/application/ship-simu/templates/de/code/block_persona_data.ctp b/application/ship-simu/templates/de/code/block_persona_data.ctp index 02a84d9..6b01149 100644 --- a/application/ship-simu/templates/de/code/block_persona_data.ctp +++ b/application/ship-simu/templates/de/code/block_persona_data.ctp @@ -6,7 +6,7 @@ $helperInstance = WebLinkHelper::createWebLinkHelper($this, 'profile_link'); $helperInstance->prefetchValueInstance('user'); // Flush the content out -$helperInstance->flushContent(); +//$helperInstance->flushContent(); // End of PHP commands ?> diff --git a/application/ship-simu/templates/de/code/login_main.ctp b/application/ship-simu/templates/de/code/login_main.ctp index 97fbbd3..3b8ef41 100644 --- a/application/ship-simu/templates/de/code/login_main.ctp +++ b/application/ship-simu/templates/de/code/login_main.ctp @@ -34,20 +34,28 @@ $blockInstance->prefetchValueInstance('company', 'user'); // Assign the company name if ($blockInstance->getValueInstance()->ifUserIsFounder()) { // User is the founder of the company - $blockInstance->assignMessageField('company_stats', "user_is_company_founder"); + $blockInstance->assignMessageField('company_status', "user_is_company_founder"); $blockInstance->assignLinkFieldWithAction('company_link' , "company_overview"); + $blockInstance->assignMessageField('company_link_text', "link_text_company_overview"); + $blockInstance->assignMessageField('company_link_title', "link_title_company_overview"); } elseif ($blockInstance->getValueInstance()->ifUserIsOwner()) { // User owns the company - $blockInstance->assignMessageField('company_stats', "user_is_company_owner"); + $blockInstance->assignMessageField('company_status', "user_is_company_owner"); $blockInstance->assignLinkFieldWithAction('company_link' , "company_overview"); + $blockInstance->assignMessageField('company_link_text', "link_text_company_overview"); + $blockInstance->assignMessageField('company_link_title', "link_title_company_overview"); } elseif ($blockInstance->getValueInstance()->ifUserIsEmployee()) { // User is employed in company - $blockInstance->assignMessageField('company_stats', "user_is_employed_in_company"); + $blockInstance->assignMessageField('company_status', "user_is_employed_in_company"); $blockInstance->assignLinkFieldWithAction('company_link' , "employee_overview"); + $blockInstance->assignMessageField('company_link_text', "link_text_employee_overview"); + $blockInstance->assignMessageField('company_link_title', "link_title_employee_overview"); } else { // No company participation! - $blockInstance->assignMessageField('company_stats', "user_not_assigned_company"); + $blockInstance->assignMessageField('company_status', "user_not_assigned_company"); $blockInstance->assignLinkFieldWithAction('company_link' , "found_new_company"); + $blockInstance->assignMessageField('company_link_text', "link_text_new_company"); + $blockInstance->assignMessageField('company_link_title', "link_title_new_company"); } // Flush the content out to a template variable diff --git a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php index a71b36d..d8a33eb 100644 --- a/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php +++ b/inc/classes/main/helper/web/blocks/class_WebBlockHelper.php @@ -90,6 +90,32 @@ class WebBlockHelper extends BaseWebHelper implements HelpableTemplate { return $withRegistration; } + /** + * Assignes a template variable with a message from a given message id + * + * @param $templateVariable Template variable to assign + * @param $messageId Message id to load an assign + * @return void + */ + public function assignMessageField ($templateVariable, $messageId) { + // Get message + $message = $this->getLanguageInstance()->getMessage($messageId); + + // And assign it + $this->getTemplateInstance()->assignVariable($templateVariable, $message); + } + + /** + * Assigns a link field with a given value + * + * @param $linkField "Link field" (variable) to assign + * @param $actionValue Action value to assign + * @return void + */ + public function assignLinkFieldWithAction ($linkField, $actionValue) { + $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); + } + /** * Flush the content out,e g. to a template variable * -- 2.30.2