PATH:
home
/
letacommog
/
letaweb
/
protected
/
modules
/
admin
/
models
<?php class PlanForm extends CFormModel { public $id; public $name; public $description; public $monthly_stripe_id; public $yearly_stripe_id; public $monthly_amount; public $yearly_amount; public $currency; public $unit_prefix; public $unit_postfix; public $display; public $priority; public $disk_space; public $blog_post_count; public $page_count; public $contributor_count; public $domain_count; public $footer_text; public $header_text; public function rules() { return array( array('id', 'numerical'), array('name', 'required'), array('name', 'length', 'max' => 255), array('id,description, display,currency,unit_prefix,unit_postfix,name,monthly_stripe_id,yearly_stripe_id,monthly_amount,yearly_amount,priority', 'safe'), array('header_text,footer_text,disk_space,blog_post_count,page_count,contributor_count,domain_count','safe'), ); } public function save($item = null) { if ($this->validate()) { if ($this->scenario === 'create' || !isset($this->id)) { $plan = new Plan(); } else { $plan = Plan::model()->findByPk($this->id); } $plan->name = $this->name; $plan->description = $this->description; $plan->currency = $this->currency; $plan->unit_prefix = $this->unit_prefix; $plan->unit_postfix = $this->unit_postfix; $plan->display = $this->display; $plan->monthly_stripe_id = $this->monthly_stripe_id; $plan->yearly_stripe_id = $this->yearly_stripe_id; $plan->monthly_amount = $this->monthly_amount; $plan->yearly_amount = $this->yearly_amount; $plan->priority = $this->priority; $plan->save(); $planConditions = array('disk_space','blog_post_count','page_count','contributor_count','domain_count'); foreach ($planConditions as $pc) { $this->savePlanCondition($pc, $this->$pc, $plan->id); } $planAdditions = array('header_text','footer_text'); foreach ($planAdditions as $pc) { $this->savePlanAddition($pc, $this->$pc, $plan->id); } return true; } else { return false; } } protected function savePlanCondition($name, $value, $planId) { $pc = PlanCondition::model()->find('name=:name and plan_id=:plan_id', array(':name' => $name, ':plan_id' => $planId)); if (!isset($pc)) { $pc = new PlanCondition(); } $pc->plan_id = $planId; $pc->name = $name; $pc->value = $value; $pc->save(); } protected function savePlanAddition($name, $value, $planId) { $pc = PlanAddition::model()->find('name=:name and plan_id=:plan_id', array(':name' => $name, ':plan_id' => $planId)); if (!isset($pc)) { $pc = new PlanAddition(); } $pc->plan_id = $planId; $pc->name = $name; $pc->value = $value; $pc->save(); } }
[+]
..
[-] DBPageForm.php
[edit]
[-] PlanDescriptionForm.php
[edit]
[-] HostingConfigurationForm.php
[edit]
[-] MailConfigurationForm.php
[edit]
[-] TemplateForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] PageForm.php
[edit]
[-] PaymentConfigurationForm.php
[edit]
[-] CategoryForm.php
[edit]
[-] TermForm.php
[edit]
[-] DbListForm.php
[edit]
[-] ModuleDataForm.php
[edit]
[-] UploadTemplateForm.php
[edit]
[-] PlanConditionForm.php
[edit]
[-] ChangeDomainForm.php
[edit]
[-] LanguageForm.php
[edit]
[-] SkinPresetForm.php
[edit]
[-] PlanForm.php
[edit]
[-] UpgradePageForm.php
[edit]
[-] MailTemplateForm.php
[edit]
[-] ColorForm.php
[edit]
[-] MakeTempleteFromSiteForm.php
[edit]
[-] ResetPassForm.php
[edit]
[-] InterfaceForm.php
[edit]
[-] ContentForm.php
[edit]
[-] UserForm.php
[edit]
[-] ExtendPageForm.php
[edit]
[-] ConfigurationForm.php
[edit]
[-] ModuleCategoryForm.php
[edit]
[-] SocialShareButtonForm.php
[edit]