<?php
/**
 * IMPORTANT NOTE
 * The code of this system is closed and a private proprietary of Flex Solutions.
 * A written authorization/license from Flex Solutions is required before using or modifying this code.
 * Email: sales@flexsolution.biz, Phone: +962795342585, Website: http://www.flexsolutions.biz
 */
 

/**
 * This is the model class for table "setting".
 *
 * The followings are the available columns in table 'setting':
 * @property integer $id
 * @property string $name
 * @property string $value
 * @property string $description
 */
class Setting extends CActiveRecord
    {

    /**
     * Returns the static model of the specified AR class.
     * @return Setting the static model class
     */


    public $first_ldap_server ,
    $second_ldap_server ,
    $ldap_port ,
    $base_dn ,
    $backup_file_path,
    $non_ldap_persons_number_prefix,
    $authentication_method,
    $authentication_ldap_server;

    

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

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'setting';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        return array(
            array('authentication_ldap_server,first_ldap_server, second_ldap_server, ldap_port, base_dn,backup_file_path,non_ldap_persons_number_prefix,authentication_method', 'required', "on" => "settings"),
            array('id,name,value,first_ldap_server,authentication_ldap_server, second_ldap_server, ldap_port, base_dn,backup_file_path,non_ldap_persons_number_prefix,authentication_method', 'safe'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'first_ldap_server' => Yii::t('default', 'First LDAP server'),
            'second_ldap_server' => Yii::t('default', 'Second LDAP server'),
            'authentication_ldap_server' => Yii::t('default', 'Authentication LDAP server'),
            'ldap_port' => Yii::t('default', 'LDAP Port'),
            'base_dn' => Yii::t('default', 'Base DN'),
            'backup_file_path' => Yii::t('default', 'Backup File Path'),
            'non_ldap_persons_number_prefix' => Yii::t('default', 'Non-LDAP Persons Number Prefix'),
            'authentication_method' => Yii::t('default', 'Authentication Method'),
        );
    }

    public function attributeLabelsPopover()
    {
        return array(
            'first_ldap_server' => Yii::t('default', 'tooltip_first_ldap_server'),
            'second_ldap_server' => Yii::t('default', 'tooltip_second_ldap_server'),
            'authentication_ldap_server' => Yii::t('default', 'tooltip_authentication_ldap_server'),
            'ldap_port' => Yii::t('default', 'tooltip_ldap_port'),
            'base_dn' => Yii::t('default', 'tooltip_base_dn'),
            'backup_file_path' => Yii::t('default', 'tooltip__backup_file_path'),
            'non_ldap_persons_number_prefix' => Yii::t('default', 'tooltip_non-ldap_persons_number_prefix'),
            'authentication_method' => Yii::t('default', 'tooltip__authentication_method'),
        );
    }

    public static function getSettingsArray()
    {
        $settings_array = array();
        foreach (Setting::model()->findAll() as $setting)
        {
            $settings_array[$setting->name] = $setting->value;
        }
        return $settings_array;
    }

    }