<?php

class FirewallWhitelist extends PhonalisaRecord
{

    public $source;
    public $active = 1;
    public $comment;

    public static function myAttributes()
    {
        return array(
            'source' => 'source',
            'active' => 'active',
            'comment' => 'comment'
        );
    }

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Job the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @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(
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('active, comment, source', 'safe'),
            array('active, source', 'required')
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'source' => __('NETWORK_FIREWALL_MODEL_SOURCE'),
            'active' => __('NETWORK_FIREWALL_MODEL_ACTIVE'),
            'comment' => __('NETWORK_FIREWALL_MODEL_COMMENT'),
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CPhonalisaDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search($order = 'id')
    {
        $arrayModels = FirewallWhitelist::model()->findAll();
        $newModel = new FirewallWhitelist();
        $newModel->id = "new";
        $arrayModels[] = $newModel;

        $dataProvider = new CArrayDataProvider($arrayModels, array(
            'id' => 'key',
            'sort' => array('defaultOrder' => "$order ASC",
            ),
            'pagination' => false
        ));
        return $dataProvider;
    }
}
