Example #1
0
function _xls_insert_conf($key, $title, $value, $helperText, $configType, $options, $sortOrder = NULL, $templateSpecific = 0)
{
    $conf = Configuration::LoadByKey($key);
    if (!$conf) {
        $conf = new Configuration();
    }
    $conf->key_name = $key;
    $conf->title = $title;
    $conf->key_value = $value;
    $conf->helper_text = $helperText;
    $conf->configuration_type_id = $configType;
    $conf->options = $options;
    $query = <<<EOS
\t\tSELECT IFNULL(MAX(sortOrder),0)+1
\t\tFROM xlsws_configuration
\t\tWHERE configuration_type_id = '{$configType}';
EOS;
    if (!$sortOrder) {
        $sortOrder = Configuration::model()->findBySql($query);
    }
    $conf->sort_order = $sortOrder;
    $conf->template_specific = $templateSpecific;
    $conf->created = new CDbExpression('NOW()');
    $conf->modified = new CDbExpression('NOW()');
    if (!$conf->save()) {
        print_r($conf->getErrors());
    }
}