本文整理汇总了PHP中CFormModel类的典型用法代码示例。如果您正苦于以下问题:PHP CFormModel类的具体用法?PHP CFormModel怎么用?PHP CFormModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFormModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:59,代码来源:CImportMarksFromCSV.class.php
示例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;
}
}
开发者ID:EurekaSolutions,项目名称:sistemanc,代码行数:35,代码来源:UsrController.php
示例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;
}
开发者ID:LumbaJack,项目名称:Mercado-BTX,代码行数:14,代码来源:AccountForm.php
示例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();
}
开发者ID:QSODevelopers,项目名称:yupe-storeswap,代码行数:7,代码来源:FileModel.php
示例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;
}
开发者ID:priyranjansingh,项目名称:getleads,代码行数:7,代码来源:GoogleAdsForm.php
示例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');
}
开发者ID:charlesportwoodii,项目名称:cii,代码行数:33,代码来源:CiiSettingsForm.php
示例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'];
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例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();
}
开发者ID:bconduct,项目名称:linet3,代码行数:7,代码来源:Update.php
示例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();
}
开发者ID:arossokha,项目名称:ex-comment,代码行数:7,代码来源:Settings.php
示例10: beforeValidate
public function beforeValidate()
{
if (parent::beforeValidate()) {
return true;
}
return false;
}
开发者ID:jayrulez,项目名称:kcconline,代码行数:7,代码来源:AddCategoryForm.php
示例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;
}
开发者ID:LumbaJack,项目名称:Mercado-BTX,代码行数:14,代码来源:CreateInvoiceForm.php
示例12: __set
public function __set($name, $value)
{
if (isset($this->_data[$name])) {
return $this->_data[$name] = $value;
}
parent::__set($name, $value);
}
开发者ID:Saltly,项目名称:SourceBans,代码行数:7,代码来源:SettingsForm.php
示例13: init
public function init()
{
foreach ($this->getConfig() as $config) {
$this->config[$config->key] = $config->value;
}
parent::init();
}
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:7,代码来源:AWSFormatConfigForm.php
示例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;
}
开发者ID:mrtos,项目名称:OpenNVR,代码行数:28,代码来源:ShareForm.php
示例15: __get
public function __get($name)
{
if (Yii::app()->user->data->hasAttribute($name)) {
return Yii::app()->user->data->{$name};
}
return parent::__get($name);
}
开发者ID:Saltly,项目名称:SourceBans,代码行数:7,代码来源:AccountForm.php
示例16: __construct
public function __construct($scenario = '', $rec_id = null, $user_id = null, $slotid = null)
{
parent::__construct($scenario);
$this->_recId = $rec_id;
$this->_userId = $user_id;
$this->_slotId = $slotid;
}
开发者ID:eneelkant,项目名称:oprecx-project,代码行数:7,代码来源:InterviewSlotForm.php
示例17: beforeValidate
protected function beforeValidate()
{
$this->message = strip_tags($this->message);
$this->name = strip_tags($this->name);
$this->telephone = strip_tags($this->telephone);
return parent::beforeValidate();
}
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:7,代码来源:PublicCareerForm.php
示例18: __get
/**
* Override to handle use case of $name == 'id'.
* As this form does not have an 'id', it will return null;
* @see ModelElement. This form is used by ModelElement for example
* and ModelElement expects the model to have an 'id' value.
*/
public function __get($name)
{
if ($name == 'id') {
return null;
}
return parent::__get($name);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:13,代码来源:ContactPrimaryEmailForm.php
示例19: afterValidate
public function afterValidate()
{
if (!$this->hasErrors()) {
$path = Yii::getPathOfAlias('webroot') . '/../uploads/in/images/' . $this->image;
$pathStore = Yii::getPathOfAlias('webroot') . '/uploads/store/product/' . $this->image;
if (file_exists($path)) {
// Файл доступен по пути
$data = @file_get_contents($path);
$res = @imagecreatefromstring($data);
if (is_resource($res)) {
// Файл коректно открывается
if (copy($path, $pathStore)) {
// Файл скопировался
$this->image = basename($path);
@unlink($path);
// удалить файл
} else {
$this->image = null;
}
}
} else {
$this->image = null;
}
}
return parent::afterValidate();
}
开发者ID:QSODevelopers,项目名称:yupe-storeswap,代码行数:26,代码来源:DProduct.php
示例20: beforeValidate
/**
* Метод выполняется перед валидацией
*
* @return bool
*/
public function beforeValidate()
{
$module = Yii::app()->getModule('user');
if ($module->generateNickName) {
$this->nick_name = 'user' . time();
}
return parent::beforeValidate();
}
开发者ID:alextravin,项目名称:yupe,代码行数:13,代码来源:RegistrationForm.php
注:本文中的CFormModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论