<?php

class UploadStoreData extends PhonalisaRecord
{

    public $commonName;
    public $fileContent;
    public $useCase;
    public $errorAttribute;
    public $errorMsg;

    public static function myAttributes()
    {
        return array(
            'commonName' => 'commonName',
            'fileContent' => 'fileContent',
            'useCase' => 'useCase',
            'errorAttribute' => 'errorAttribute',
            'errorMsg' => 'errorMsg'
        );
    }

    /**
     * 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('commonName, fileContent, useCase, errorAttribute, errorMsg', 'safe'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'data' => __('NETWORK_CERTIFICATE_SETTINGS_UPLOAD_STORE_DATA')
        );
    }

    public function getUseCaseAsArray()
    {
        $useCases = array_keys(CertUseCase::getCertUseCaseArray());
        $result = array();
        if (!empty($this->useCase)) {
            foreach ($useCases as $useCase) {
                $result[] = $useCase & $this->useCase;
            }
        }
        return $result;
    }
}
