<?php

class Whitelist extends Blacklist
{
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => __('ID'),
            'name' => __('WHITELIST_MODEL_NAME'),
        );
    }

    public function search($order = 'name')
    {
        $criteria = new CDbCriteria;
        $filter = $this->getFilter($criteria, $order);

        $filter['pagination'] = array(
            'pageSize' => getGridPageSize('whitelist-grid'),
        );

        if ($filter != null) {

            $dataprovider = new CPhonalisaDataProvider($this, array(
                'criteria' => $criteria,
            ));

            $routingBlacklistMax = PhonalisaLicenseManager::routingBlacklistMax();
            if ($routingBlacklistMax >= 0) {
                $dataprovider->pagination->pageSize = $dataprovider->pagination->pageSize > $routingBlacklistMax ? $routingBlacklistMax : $dataprovider->pagination->pageSize;
                $dataprovider->totalItemCount = $dataprovider->totalItemCount > $routingBlacklistMax ? $routingBlacklistMax : $dataprovider->totalItemCount;
            }

            return $dataprovider;
        }
    }
}
