本文整理汇总了PHP中CFormModel类的典型用法代码示例。如果您正苦于以下问题:PHP CFormModel类的具体用法?PHP CFormModel怎么用?PHP CFormModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFormModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
public function import(CFormModel $source)
{
$data = $source->getData();
$markIds = array();
$isFirstRow = true;
foreach ($data as $row) {
if ($isFirstRow) {
// это первая строка - в не идентификаторы оценок
$isFirstRow = false;
$markIds = $row;
} else {
// это все остальные строки - здесь уже студенты
$student = CStaffManager::getStudent($row[0]);
if (!is_null($student)) {
$isFirstCol = true;
foreach ($row as $id => $cell) {
if (!$isFirstCol) {
if ($cell != "") {
// если не пустая, то берем дисциплину
$subjectId = $markIds[$id];
$subject = CTaxonomyManager::getDiscipline($subjectId);
if (!is_null($subject)) {
// если дисциплина есть, то происходит маппинг оценок
$marks = array("2" => "4", "3" => "3", "4" => "2", "5" => "1");
// создаем запись об оценке
$activity = new CStudentActivity();
$activity->subject_id = $subject->getId();
$activity->kadri_id = $source->person;
$activity->student_id = $student->getId();
$activity->date_act = date("Y-m-d", strtotime($source->created));
if (mb_strlen($cell) == 2 || strlen($cell) == 2) {
// это курсовой
$cell = mb_substr($cell, 0, 1);
$activity->study_act_id = 43;
if (array_key_exists($cell, $marks)) {
$activity->study_mark = $marks[$cell];
}
} elseif (array_key_exists($cell, $marks)) {
// это экзамен
$activity->study_act_id = 1;
$activity->study_mark = $marks[$cell];
} else {
// это зачет
$activity->study_act_id = 2;
$activity->study_mark = 5;
}
$activity->save();
}
}
} else {
// пропускаем первую ячейку - в ней идентификатор студента
$isFirstCol = false;
}
}
}
}
}
return true;
}
示例2: sendEmail
/**
* Sends out an email containing instructions and link to the email verification
* or password recovery page, containing an activation key.
* @param CFormModel $model it must have a getIdentity() method
* @param strign $mode 'recovery', 'verify' or 'oneTimePassword'
* @return boolean if sending the email succeeded
*/
public function sendEmail(CFormModel $model, $mode)
{
$mail = $this->module->mailer;
$mail->AddAddress($model->getIdentity()->getEmail(), $model->getIdentity()->getName());
$params = array('siteUrl' => $this->createAbsoluteUrl('/'), 'usuario' => $model->getIdentity()->usuario, 'correo' => $model->getIdentity()->correo);
switch ($mode) {
default:
return false;
case 'recovery':
case 'verify':
$mail->Subject = $mode == 'recovery' ? Yii::t('UsrModule.usr', 'Recuperar la contraseña') : Yii::t('UsrModule.usr', 'Verificación de la dirección de correo electrónico');
$params['actionUrl'] = $this->createAbsoluteUrl('default/' . $mode, array('llave_activacion' => $model->getIdentity()->getActivationKey(), 'usuario' => $model->getIdentity()->getName()));
break;
case 'oneTimePassword':
$mail->Subject = Yii::t('UsrModule.usr', 'One Time Password');
$params['code'] = $model->getNewCode();
break;
}
$body = $this->renderPartial($mail->getPathViews() . '.' . $mode, $params, true);
$full = $this->renderPartial($mail->getPathLayouts() . '.email', array('content' => $body), true);
$mail->MsgHTML($full);
if ($mail->Send()) {
return true;
} else {
Yii::log($mail->ErrorInfo, 'error');
return false;
}
}
示例3: rules
/**
* Validation rules
*
* @see CModel::rules()
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
$rules[] = array('email', 'email');
$rules[] = array('email', 'unique');
return $rules;
}
示例4: init
public function init()
{
$this->folderFiles = Yii::app()->getModule('exchange1c')->folderFiles;
$this->readFileProducts = Yii::app()->getModule('exchange1c')->readFileProducts;
$this->readFileCategory = Yii::app()->getModule('exchange1c')->readFileCategory;
return parent::init();
}
示例5: init
public function init()
{
parent::init();
$this->GAD_728x90 = SiteVariable::model()->findByPk('GAD_728x90')->value;
$this->GAD_336x280 = SiteVariable::model()->findByPk('GAD_336x280')->value;
$this->GAD_728x15 = SiteVariable::model()->findByPk('GAD_728x15')->value;
}
示例6: renderProperties
/**
* Renders form properties utilizing the appropriate
* @param CActiveForm $form The form we're working with
* @param Property Name $property The property name from Reflection
*/
private function renderProperties(&$form, $property)
{
$htmlOptions = array('class' => 'pure-input-2-3');
$validators = $this->model->getValidators($property->name);
$stringValidators = $this->model->getStringValidator($property->name, $validators);
if (in_array('required', $stringValidators)) {
$htmlOptions['required'] = true;
}
echo CHtml::openTag('div', array('class' => 'pure-control-group'));
if (in_array('boolean', $stringValidators)) {
$form->toggleButtonRow($this->model, $property->name, $htmlOptions, $validators);
} else {
if (in_array('number', $stringValidators) && isset($validators[0]->max) && isset($validators[0]->min)) {
$form->rangeFieldRow($this->model, $property->name, $htmlOptions, $validators);
} else {
if (in_array('number', $stringValidators) && (isset($validators[0]->max) || isset($validators[0]->min))) {
$form->numberFieldRow($this->model, $property->name, $htmlOptions, $validators);
} else {
if (in_array('password', $stringValidators)) {
echo $form->passwordFieldRow($this->model, $property->name, $htmlOptions, $validators);
} else {
echo $form->textFieldRow($this->model, $property->name, $htmlOptions, $validators);
}
}
}
}
echo CHtml::closeTag('div');
}
示例7: __construct
public function __construct()
{
$this->object_id = isset($_REQUEST['object_id']) ? $_REQUEST['object_id'] : parent::addError("ObjectId", "Object ID should not be null");
$this->benutzer_id = isset($_REQUEST['benutzer_id']) ? $_REQUEST['benutzer_id'] : parent::addError("benutzer_id", "User ID should not be null");
$this->agentSine = Yii::app()->params['agentSine'];
$this->agentDutyCode = Yii::app()->params['agentDutyCode'];
}
示例8: init
public function init() {
if (file_exists(Yii::app()->basePath . '/data/version'))
$this->_sversion = file_get_contents(Yii::app()->basePath . '/data/version');
else
$this->_sversion = "3.0";
return parent::init();
}
示例9: init
public function init()
{
if (file_exists($this->getSavePath() . $this->fileName)) {
$this->setAttributes(unserialize(file_get_contents($this->getSavePath() . $this->fileName)));
}
return parent::init();
}
示例10: beforeValidate
public function beforeValidate()
{
if (parent::beforeValidate()) {
return true;
}
return false;
}
示例11: rules
/**
* Validation rules
*
* @see CModel::rules()
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
$rules[] = array('amount', 'in', 'range' => range(0, 10000));
$rules[] = array('id_bank', 'safe');
return $rules;
}
示例12: __set
public function __set($name, $value)
{
if (isset($this->_data[$name])) {
return $this->_data[$name] = $value;
}
parent::__set($name, $value);
}
示例13: init
public function init()
{
foreach ($this->getConfig() as $config) {
$this->config[$config->key] = $config->value;
}
parent::init();
}
示例14: beforeValidate
public function beforeValidate()
{
if (parent::beforeValidate()) {
$cams = array_map('trim', explode(',', $this->hcams));
$c = count($cams);
foreach ($cams as $cam) {
$this->camBuff[] = Cams::model()->findByPK(Cams::model()->getRealId($cam));
}
$this->camBuff = array_filter($this->camBuff);
if (empty($this->camBuff) || count($this->camBuff) != $c) {
$this->addError('cams', $c > 1 ? Yii::t('errors', 'One of cam is wrong') : Yii::t('errors', 'There is no such cam'));
return false;
}
if (!is_array($this->emails)) {
$emails = array_map('trim', explode(',', $this->emails));
} else {
$emails = array_map('trim', $this->emails);
}
$c = count($emails);
$this->emailBuff = Users::model()->findAllByAttributes(array('email' => $emails));
if (empty($this->emailBuff) || count($this->emailBuff) != $c) {
$this->addError('emails', $c > 1 ? Yii::t('errors', 'One of user is wrong') : Yii::t('errors', 'There is no such user'));
return false;
}
return true;
}
return false;
}
示例15: __get
public function __get($name)
{
if (Yii::app()->user->data->hasAttribute($name)) {
return Yii::app()->user->data->{$name};
}
return parent::__get($name);
}