/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return YdContactUs the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
echo " * @var \$ids int[]\n"; echo " * @var \$task string\n"; echo " */\n"; echo "\n"; echo "\$this->pageTitle = Yii::t('app', ucfirst(\$task)) . ' ' . \$this->getName();\n"; echo "\n"; echo "/** @var YdActiveForm \$form */\n"; echo "\$form = \$this->beginWidget('dressing.widgets.YdActiveForm', array(\n"; echo " 'id' => '" . lcfirst($this->modelClass) . "-' . \$task . '-form',\n"; echo " 'type' => 'horizontal',\n"; echo " 'action' => array('/" . lcfirst($this->modelClass) . "/delete', 'task' => \$task, 'confirm' => 1),\n"; echo "));\n"; echo "echo \$form->getGridIdHiddenFields(\$ids);\n"; echo "echo \$form->beginModalWrap();\n"; echo "\n"; echo "//echo '<fieldset><legend>' . Yii::t('app', 'Selected Records') . '</legend>';\n"; echo "\$" . lcfirst($this->modelClass) . "s = " . $this->modelClass . "::model()->findAll('t." . YdActiveRecord::model($this->modelClass)->tableSchema->primaryKey . " IN (' . implode(',', \$ids) . ')');\n"; echo "if (\$" . lcfirst($this->modelClass) . "s) {\n"; echo "\techo '<ul>';\n"; echo "\tforeach (\$" . lcfirst($this->modelClass) . "s as \$" . lcfirst($this->modelClass) . ") {\n"; echo "\t\techo '<li>';\n"; echo "\t\techo \$" . lcfirst($this->modelClass) . "->getName();\n"; echo "\t\techo '</li>';\n"; echo "\t}\n"; echo "\techo '</ul>';\n"; echo "}\n"; echo "//echo '</fieldset>';\n"; echo "\n"; echo "echo \$form->endModalWrap();\n"; echo "echo \$form->getSubmitButtonRow(Yii::t('app', 'Confirm ' . ucfirst(\$task)));\n"; echo "\$this->endWidget();\n";
/** * Actions to be performed after the model is saved */ protected function afterSave() { parent::afterSave(); // handle the file upload if ($this->isNewRecord && $this->handleFileUpload) { $fileInfo = pathinfo($this->_file->name); $file = $this->getAttachmentPath() . '/' . $this->id . '.' . $fileInfo['extension']; if (!file_exists(dirname($file))) { mkdir(dirname($file), 0777, true); } $this->_file->saveAs($file); } $this->handleFileUpload = true; }
/** * */ public function beforeSave() { if (!parent::beforeSave()) { return false; } // generate an api key if ($this->api_status && empty($this->dbAttributes['api_status'])) { $plainApiKey = $this->getApiKey(); if ($plainApiKey) { $this->api_key = $this->hashPassword($plainApiKey); } } if (!$this->api_status) { $this->api_key = null; } // if they have no password - assign password so that forgot password links work if ($this->isNewRecord && !$this->password) { $this->password = $this->hashPassword(md5(uniqid('', true))); } return true; }