linccce

Smtp params

Jun 5th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.32 KB | None | 0 0
  1. DBConfigurationsController.php
  2.  
  3. <----------------
  4.     public function actionSmtp()
  5.     {
  6.         $model = new SmtpNustatymai;
  7.        
  8.         if(isset($_POST['ajax']) && $_POST['ajax']==='smtp-nustatymai-smtp-form')
  9.         {
  10.                 echo CActiveForm::validate($model);
  11.                 Yii::app()->end();
  12.         }
  13.  
  14.         if(isset($_POST['SmtpNustatymai']))
  15.         {
  16.             $model->attributes=$_POST['SmtpNustatymai'];
  17.            
  18.                 if($model->validate())
  19.                 {
  20.                     $model->save();
  21.                     $this->redirect(array('Smtp'));
  22.                 }
  23.         }
  24.         $this->render('Smtp',array('model'=>$model));
  25.     }
  26. ---------->
  27.  
  28. Model/smtpNustatymai.php
  29.  
  30. <-------------
  31.  
  32. <?php
  33.  
  34. /**
  35.  * This is the model class for table "base_smtp_nustatymai".
  36.  *
  37.  * The followings are the available columns in table 'base_smtp_nustatymai':
  38.  * @property integer $id
  39.  * @property string $host
  40.  * @property integer $auth
  41.  * @property integer $port
  42.  * @property string $username
  43.  * @property string $password
  44.  * @property string $ts
  45.  */
  46. class SmtpNustatymai extends CActiveRecord
  47. {
  48.     /**
  49.      * @return string the associated database table name
  50.      */
  51.     public function tableName()
  52.     {
  53.         return 'base_smtp_nustatymai';
  54.     }
  55.     /**
  56.      * @return array validation rules for model attributes.
  57.      */
  58.     public function rules()
  59.     {
  60.         // NOTE: you should only define rules for those attributes that
  61.         // will receive user inputs.
  62.  
  63.         return array(
  64.             array('auth, username, password, host, port', 'required'),
  65.             array('auth, port', 'numerical', 'integerOnly'=>true),
  66.             array('host, username', 'length', 'max'=>100),
  67.             array('password', 'length', 'max'=>30),
  68.             array('ts', 'safe'),
  69.             // The following rule is used by search().
  70.             // @todo Please remove those attributes that should not be searched.
  71.             array('id, host, auth, port, username, password, ts', 'safe', 'on'=>'search'),
  72.                 );
  73.     }
  74.  
  75.     /**
  76.      * @return array relational rules.
  77.      */
  78.     public function relations()
  79.     {
  80.         // NOTE: you may need to adjust the relation name and the related
  81.         // class name for the relations automatically generated below.
  82.         return array(
  83.         );
  84.     }
  85.  
  86.     /**
  87.      * @return array customized attribute labels (name=>label)
  88.      */
  89.     public function attributeLabels()
  90.     {
  91.         return array(
  92.             'id' => 'Įrašo ID',
  93.             'host' => 'Pašto serverio adresas',
  94.             'auth' => 'Smtp autorizacija (įjugta/išjungta)',
  95.             'port' => 'SMTP Prievadas',
  96.             'username' => 'Vartotojo vardas (gali būti el. paštas)',
  97.             'password' => 'Slaptaždis',
  98.             'ts' => 'Įrašo įvesties data ir laikas',
  99.         );
  100.     }
  101.  
  102.     /**
  103.      * Retrieves a list of models based on the current search/filter conditions.
  104.      *
  105.      * Typical usecase:
  106.      * - Initialize the model fields with values from filter form.
  107.      * - Execute this method to get CActiveDataProvider instance which will filter
  108.      * models according to data in model fields.
  109.      * - Pass data provider to CGridView, CListView or any similar widget.
  110.      *
  111.      * @return CActiveDataProvider the data provider that can return the models
  112.      * based on the search/filter conditions.
  113.      */
  114.     public function search()
  115.     {
  116.         // @todo Please modify the following code to remove attributes that should not be searched.
  117.  
  118.         $criteria=new CDbCriteria;
  119.  
  120.         $criteria->compare('id',$this->id);
  121.         $criteria->compare('host',$this->host,true);
  122.         $criteria->compare('auth',$this->auth);
  123.         $criteria->compare('port',$this->port);
  124.         $criteria->compare('username',$this->username,true);
  125.         $criteria->compare('password',$this->password,true);
  126.         $criteria->compare('ts',$this->ts,true);
  127.  
  128.         return new CActiveDataProvider($this, array(
  129.             'criteria'=>$criteria,
  130.         ));
  131.     }
  132.  
  133.     /**
  134.      * Returns the static model of the specified AR class.
  135.      * Please note that you should have this exact method in all your CActiveRecord descendants!
  136.      * @param string $className active record class name.
  137.      * @return SmtpNustatymai the static model class
  138.      */
  139.     public static function model($className=__CLASS__)
  140.     {
  141.         return parent::model($className);
  142.     }
  143. }
  144.  
  145. ------->
  146.  
  147. view/dbconfigurations/smtp.php
  148.  
  149. <-------------
  150.  
  151. <?php
  152. $this->breadcrumbs=array(
  153.     'Sistemos administravimas'=>array('index'),
  154.         'SMTP Nustatymai'
  155. );
  156.  
  157. $this->menu=array(
  158.     array('label'=>'Redaguoti duomenų bazės prisijungimo duomenis', 'url'=>array('/dbconfiguration/update','id'=>1)),
  159.     array('label'=>'Nustatyti tolerancija', 'url'=>array('/dbconfiguration/settolerancija','id'=>1)),
  160.         array('label'=>'Nustatyti duris', 'url'=>array('/dbconfiguration/setdoor')),
  161.         array('label'=>'Nustatyti respondentą', 'url'=>array('/dbconfiguration/emaillist')),
  162.         array('label'=>'SMTP Nustatymai', 'url'=>array('/dbconfiguration/smtp')),
  163. );
  164. ?>
  165.  
  166. <div class="form">
  167.  
  168. <?php $form=$this->beginWidget('CActiveForm', array(
  169.     'id'=>'smtp-nustatymai-smtp-form',
  170.     // Please note: When you enable ajax validation, make sure the corresponding
  171.     // controller action is handling ajax validation correctly.
  172.     // See class documentation of CActiveForm for details on this,
  173.     // you need to use the performAjaxValidation()-method described there.
  174.     'enableAjaxValidation'=>true,
  175. )); ?>
  176.  
  177.     <p class="note">Fields with <span class="required">*</span> are required.</p>
  178.  
  179.     <?php echo $form->errorSummary($model); ?>
  180.  
  181.     <div class="row">
  182.         <?php echo $form->labelEx($model,'auth'); ?>
  183.         <?php echo $form->checkBox($model,'auth'); ?>
  184.         <?php echo $form->error($model,'auth'); ?>
  185.     </div>
  186.        
  187.     <div class="row">
  188.         <?php echo $form->labelEx($model,'host'); ?>
  189.         <?php echo $form->textField($model,'host'); ?>
  190.         <?php echo $form->error($model,'host'); ?>
  191.     </div>
  192.        
  193.     <div class="row">
  194.         <?php echo $form->labelEx($model,'port'); ?>
  195.         <?php echo $form->textField($model,'port'); ?>
  196.         <?php echo $form->error($model,'port'); ?>
  197.     </div>
  198.  
  199.     <div class="row">
  200.         <?php echo $form->labelEx($model,'username'); ?>
  201.         <?php echo $form->textField($model,'username'); ?>
  202.         <?php echo $form->error($model,'username'); ?>
  203.     </div>
  204.  
  205.     <div class="row">
  206.         <?php echo $form->labelEx($model,'password'); ?>
  207.         <?php echo $form->passwordField($model,'password'); ?>
  208.         <?php echo $form->error($model,'password'); ?>
  209.     </div>
  210.  
  211.     <div class="row buttons">
  212.         <?php echo CHtml::submitButton('Submit'); ?>
  213.     </div>
  214.  
  215. <?php $this->endWidget(); ?>
  216.  
  217. </div><!-- form -->
  218.  
  219. ----->
Advertisement
Add Comment
Please, Sign In to add comment