Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DBConfigurationsController.php
- <----------------
- public function actionSmtp()
- {
- $model = new SmtpNustatymai;
- if(isset($_POST['ajax']) && $_POST['ajax']==='smtp-nustatymai-smtp-form')
- {
- echo CActiveForm::validate($model);
- Yii::app()->end();
- }
- if(isset($_POST['SmtpNustatymai']))
- {
- $model->attributes=$_POST['SmtpNustatymai'];
- if($model->validate())
- {
- $model->save();
- $this->redirect(array('Smtp'));
- }
- }
- $this->render('Smtp',array('model'=>$model));
- }
- ---------->
- Model/smtpNustatymai.php
- <-------------
- <?php
- /**
- * This is the model class for table "base_smtp_nustatymai".
- *
- * The followings are the available columns in table 'base_smtp_nustatymai':
- * @property integer $id
- * @property string $host
- * @property integer $auth
- * @property integer $port
- * @property string $username
- * @property string $password
- * @property string $ts
- */
- class SmtpNustatymai extends CActiveRecord
- {
- /**
- * @return string the associated database table name
- */
- public function tableName()
- {
- return 'base_smtp_nustatymai';
- }
- /**
- * @return array validation rules for model attributes.
- */
- public function rules()
- {
- // NOTE: you should only define rules for those attributes that
- // will receive user inputs.
- return array(
- array('auth, username, password, host, port', 'required'),
- array('auth, port', 'numerical', 'integerOnly'=>true),
- array('host, username', 'length', 'max'=>100),
- array('password', 'length', 'max'=>30),
- array('ts', 'safe'),
- // The following rule is used by search().
- // @todo Please remove those attributes that should not be searched.
- array('id, host, auth, port, username, password, ts', 'safe', 'on'=>'search'),
- );
- }
- /**
- * @return array relational rules.
- */
- public function relations()
- {
- // NOTE: you may need to adjust the relation name and the related
- // class name for the relations automatically generated below.
- return array(
- );
- }
- /**
- * @return array customized attribute labels (name=>label)
- */
- public function attributeLabels()
- {
- return array(
- 'id' => 'Įrašo ID',
- 'host' => 'Pašto serverio adresas',
- 'auth' => 'Smtp autorizacija (įjugta/išjungta)',
- 'port' => 'SMTP Prievadas',
- 'username' => 'Vartotojo vardas (gali būti el. paštas)',
- 'password' => 'Slaptaždis',
- 'ts' => 'Įrašo įvesties data ir laikas',
- );
- }
- /**
- * Retrieves a list of models based on the current search/filter conditions.
- *
- * Typical usecase:
- * - Initialize the model fields with values from filter form.
- * - Execute this method to get CActiveDataProvider instance which will filter
- * models according to data in model fields.
- * - Pass data provider to CGridView, CListView or any similar widget.
- *
- * @return CActiveDataProvider the data provider that can return the models
- * based on the search/filter conditions.
- */
- public function search()
- {
- // @todo Please modify the following code to remove attributes that should not be searched.
- $criteria=new CDbCriteria;
- $criteria->compare('id',$this->id);
- $criteria->compare('host',$this->host,true);
- $criteria->compare('auth',$this->auth);
- $criteria->compare('port',$this->port);
- $criteria->compare('username',$this->username,true);
- $criteria->compare('password',$this->password,true);
- $criteria->compare('ts',$this->ts,true);
- return new CActiveDataProvider($this, array(
- 'criteria'=>$criteria,
- ));
- }
- /**
- * Returns the static model of the specified AR class.
- * Please note that you should have this exact method in all your CActiveRecord descendants!
- * @param string $className active record class name.
- * @return SmtpNustatymai the static model class
- */
- public static function model($className=__CLASS__)
- {
- return parent::model($className);
- }
- }
- ------->
- view/dbconfigurations/smtp.php
- <-------------
- <?php
- $this->breadcrumbs=array(
- 'Sistemos administravimas'=>array('index'),
- 'SMTP Nustatymai'
- );
- $this->menu=array(
- array('label'=>'Redaguoti duomenų bazės prisijungimo duomenis', 'url'=>array('/dbconfiguration/update','id'=>1)),
- array('label'=>'Nustatyti tolerancija', 'url'=>array('/dbconfiguration/settolerancija','id'=>1)),
- array('label'=>'Nustatyti duris', 'url'=>array('/dbconfiguration/setdoor')),
- array('label'=>'Nustatyti respondentą', 'url'=>array('/dbconfiguration/emaillist')),
- array('label'=>'SMTP Nustatymai', 'url'=>array('/dbconfiguration/smtp')),
- );
- ?>
- <div class="form">
- <?php $form=$this->beginWidget('CActiveForm', array(
- 'id'=>'smtp-nustatymai-smtp-form',
- // Please note: When you enable ajax validation, make sure the corresponding
- // controller action is handling ajax validation correctly.
- // See class documentation of CActiveForm for details on this,
- // you need to use the performAjaxValidation()-method described there.
- 'enableAjaxValidation'=>true,
- )); ?>
- <p class="note">Fields with <span class="required">*</span> are required.</p>
- <?php echo $form->errorSummary($model); ?>
- <div class="row">
- <?php echo $form->labelEx($model,'auth'); ?>
- <?php echo $form->checkBox($model,'auth'); ?>
- <?php echo $form->error($model,'auth'); ?>
- </div>
- <div class="row">
- <?php echo $form->labelEx($model,'host'); ?>
- <?php echo $form->textField($model,'host'); ?>
- <?php echo $form->error($model,'host'); ?>
- </div>
- <div class="row">
- <?php echo $form->labelEx($model,'port'); ?>
- <?php echo $form->textField($model,'port'); ?>
- <?php echo $form->error($model,'port'); ?>
- </div>
- <div class="row">
- <?php echo $form->labelEx($model,'username'); ?>
- <?php echo $form->textField($model,'username'); ?>
- <?php echo $form->error($model,'username'); ?>
- </div>
- <div class="row">
- <?php echo $form->labelEx($model,'password'); ?>
- <?php echo $form->passwordField($model,'password'); ?>
- <?php echo $form->error($model,'password'); ?>
- </div>
- <div class="row buttons">
- <?php echo CHtml::submitButton('Submit'); ?>
- </div>
- <?php $this->endWidget(); ?>
- </div><!-- form -->
- ----->
Advertisement
Add Comment
Please, Sign In to add comment