/**
 * Smarty {userlistcontrol} function plugin
 *
 * Type:     function<br>
 * Name:     userlistcontrol<br>
 * Purpose:  display a list control of users
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_userlistcontrol($params, &$smarty)
{
    echo '<script src="' . PATH_RELATIVE . 'framework/core/subsystems/forms/controls/listbuildercontrol.js" language="javascript"></script>';
    global $db;
    $users = $db->selectObjects("user", null, "username");
    foreach ($users as $user) {
        $allusers[$user->id] = "{$user->lastname}, {$user->firstname}({$user->username})";
    }
    $control = new listbuildercontrol(null, $allusers, 5);
    $name = isset($params['name']) ? $params['name'] : "userlist";
    echo $control->controlToHTML($name);
}
 function update($values, $object)
 {
     global $db;
     // $object->enable_categories = (isset($values['enable_categories']) ? 1 : 0);
     $object->enable_feedback = isset($values['enable_feedback']) ? 1 : 0;
     //		$object->reminder_notify = serialize(listbuildercontrol::parseData($values,'reminder_notify'));
     $object->email_title_reminder = $values['email_title_reminder'];
     $object->email_from_reminder = $values['email_from_reminder'];
     $object->email_address_reminder = $values['email_address_reminder'];
     $object->email_reply_reminder = $values['email_reply_reminder'];
     $object->email_showdetail = isset($values['email_showdetail']) ? 1 : 0;
     $object->email_signature = $values['email_signature'];
     $object->aggregate = serialize(listbuildercontrol::parseData($values, 'aggregate'));
     $object->enable_rss = isset($values['enable_rss']) ? 1 : 0;
     $object->enable_ical = isset($values['enable_ical']) ? 1 : 0;
     $object->feed_title = $values['feed_title'];
     $object->feed_desc = $values['feed_desc'];
     $object->rss_cachetime = $values['rss_cachetime'];
     $object->rss_limit = $values['rss_limit'];
     // $object->enable_tags = (isset($values['enable_tags']) ? 1 : 0);
     // $object->collections = serialize(listbuildercontrol::parseData($values,'collections'));
     // $object->group_by_tags = (isset($values['group_by_tags']) ? 1 : 0);
     // $object->show_tags = serialize(listbuildercontrol::parseData($values,'show_tags'));
     //Deal with addresses by first deleting All addresses as we will be rebuilding it.
     $db->delete('calendar_reminder_address', 'calendar_id=' . $object->id);
     $data->group_id = 0;
     $data->user_id = 0;
     $data->email = '';
     $data->calendar_id = $object->id;
     if (isset($values['groups'])) {
         foreach (listbuildercontrol::parseData($values, 'groups') as $group_id) {
             $data->group_id = $group_id;
             $db->insertObject($data, 'calendar_reminder_address');
         }
         $data->group_id = 0;
     }
     if (isset($values['users'])) {
         foreach (listbuildercontrol::parseData($values, 'users') as $user_id) {
             $data->user_id = $user_id;
             $db->insertObject($data, 'calendar_reminder_address');
         }
         $data->user_id = 0;
     }
     if (isset($values['addresses'])) {
         foreach (listbuildercontrol::parseData($values, 'addresses') as $email) {
             $data->email = $email;
             $db->insertObject($data, 'calendar_reminder_address');
         }
     }
     return $object;
 }
Example #3
0
 function update($values, $object)
 {
     if ($values['identifier'] == "") {
         $post = $_POST;
         $post['_formError'] = gt('Identifier is required.');
         expSession::set("last_POST", $post);
         return null;
     }
     if ($object == null) {
         $object = new dropdowncontrol();
     }
     $object->identifier = $values['identifier'];
     $object->caption = $values['caption'];
     $object->default = $values['default'];
     $object->items = listbuildercontrol::parseData($values, 'items', true);
     $object->size = intval($values['size']) <= 0 ? 1 : intval($values['size']);
     $object->required = isset($values['required']);
     return $object;
 }
        $rpt->description = $i18n['auto_generated'];
        $rpt->location_data = $f->location_data;
        $rpt->text = '';
        $rpt->column_names = '';
        $rpt->form_id = $f->id;
        $db->insertObject($rpt, 'formbuilder_report');
    }
    //Delete All addresses as we will be rebuilding it.
    $db->delete('formbuilder_address', 'form_id=' . $f->id);
    $data->group_id = 0;
    $data->user_id = 0;
    $data->email = '';
    $data->form_id = $f->id;
    foreach (listbuildercontrol::parseData($_POST, 'groups') as $group_id) {
        $data->group_id = $group_id;
        $db->insertObject($data, 'formbuilder_address');
    }
    $data->group_id = 0;
    foreach (listbuildercontrol::parseData($_POST, 'users') as $user_id) {
        $data->user_id = $user_id;
        $db->insertObject($data, 'formbuilder_address');
    }
    $data->user_id = 0;
    foreach (listbuildercontrol::parseData($_POST, 'addresses') as $email) {
        $data->email = $email;
        $db->insertObject($data, 'formbuilder_address');
    }
    exponent_flow_redirect();
} else {
    echo SITE_403_HTML;
}
 public function update()
 {
     $product_types = ecomconfig::getConfig('product_types');
     foreach ($product_types as $key => $value) {
         $this->params["{$value}s"] = listbuildercontrol::parseData($this->params, "{$value}s_list");
     }
     $curcat = new storeCategory($this->params);
     $children = $curcat->getChildren();
     foreach ($children as $key => $child) {
         $chldcat = new storeCategory($child->id);
         $chldcat->is_active = $this->params['is_active'];
         $chldcat->save();
     }
     foreach ($product_types as $key => $value) {
         $type = $value . 's';
         $product_type = new $type();
         $product_type->saveCategories($this->params["{$type}"], $curcat->id, $type);
     }
     parent::update();
 }
 function update($values, $object)
 {
     if (!defined('SYS_FORMS')) {
         require_once BASE . 'subsystems/forms.php';
     }
     exponent_forms_initialize();
     $object->name = $values['name'];
     $object->description = $values['description'];
     $object->_members = listbuildercontrol::parseData($values, 'members');
     return $object;
 }
 function update($values, $object)
 {
     if ($object == null) {
         $object = new radiogroupcontrol();
     }
     if ($values['identifier'] == "") {
         $i18n = exponent_lang_loadFile('subsystems/forms/controls/radiogroupcontrol.php');
         $post = $_POST;
         $post['_formError'] = $i18n['id_req'];
         exponent_sessions_set("last_POST", $post);
         return null;
     }
     if (!defined("SYS_FORMS")) {
         require_once BASE . "subsystems/forms.php";
     }
     exponent_forms_initialize();
     $object->identifier = $values['identifier'];
     $object->caption = $values['caption'];
     $object->default = $values['default'];
     $object->items = listbuildercontrol::parseData($values, 'items', true);
     $object->flip = isset($values['flip']);
     $object->cols = intval($values['cols']);
     $object->spacing = intval($values['spacing']);
     $object->required = isset($values['required']);
     return $object;
 }
Example #8
0
 // Process recipients first, so that we can save the built list in the last_POST var in case we need to return
 $recipients = listbuildercontrol::parseData($_POST, 'recipients');
 $banned = array();
 foreach ($db->selectObjects('inbox_contactbanned', 'owner=' . $user->id . ' OR user_id=' . $user->id) as $b) {
     if ($b->owner == $user->id) {
         $banned[$b->user_id] = $b->user_id;
     } else {
         $banned[$b->user_id] = $b->owner;
     }
 }
 if (isset($_POST['replyto'])) {
     $recipients[] = $_POST['replyto'];
 }
 $gr = array();
 if (isset($_POST['group_recipients'])) {
     $gr = listbuildercontrol::parseData($_POST, 'group_recipients');
     foreach ($gr as $ginfo) {
         $toks = explode('_', $ginfo);
         $gid = $toks[1];
         if ($toks[0] == 'group') {
             foreach (exponent_users_getUsersInGroup(exponent_users_getGroupById($gid)) as $u) {
                 if (!in_array($u->id, $banned)) {
                     $recipients[] = $u->id;
                 }
             }
         } else {
             $list = $db->selectObject('inbox_contactlist', 'id=' . $gid);
             if ($list->owner == $user->id) {
                 foreach ($db->selectObjects('inbox_contactlist_member', 'list_id=' . $list->id) as $m) {
                     if (!in_array($u->id, $banned)) {
                         $recipients[] = $m->user_id;
Example #9
0
 function update($values, $object)
 {
     if ($object == null) {
         $object = new radiogroupcontrol();
     }
     if ($values['identifier'] == "") {
         pathos_lang_loadDictionary('standard', 'formcontrols');
         $post = $_POST;
         $post['_formError'] = TR_FORMCONTROLS_IDENTIFIER_REQUIRED;
         pathos_sessions_set("last_POST", $post);
         return null;
     }
     if (!defined("SYS_FORMS")) {
         require_once BASE . "subsystems/forms.php";
     }
     pathos_forms_initialize();
     $object->identifier = $values['identifier'];
     $object->caption = $values['caption'];
     $object->default = $values['default'];
     $object->items = listbuildercontrol::parseData($values, 'items', true);
     $object->flip = isset($values['flip']);
     $object->cols = intval($values['cols']);
     $object->spacing = intval($values['spacing']);
     $object->required = isset($values['required']);
     return $object;
 }
Example #10
0
 function update($values, $object)
 {
     if ($values['identifier'] == "") {
         $post = $_POST;
         $post['_formError'] = "Identifier is required.";
         pathos_sessions_set("last_POST", $post);
         return null;
     }
     if (!defined("SYS_FORMS")) {
         require_once BASE . "subsystems/forms.php";
     }
     pathos_forms_initialize();
     if ($object == null) {
         $object = new dropdowncontrol();
     }
     $object->identifier = $values['identifier'];
     $object->caption = $values['caption'];
     $object->default = $values['default'];
     $object->items = listbuildercontrol::parseData($values, 'items', true);
     $object->size = intval($values['size']) <= 0 ? 1 : intval($values['size']);
     $object->required = isset($values['required']);
     return $object;
 }
Example #11
0
/**
 * Smarty {control} function plugin
 *
 * Type:     function<br>
 * Name:     control<br>
 * Purpose:  create a form control
 *
 * @param         $params
 * @param \Smarty $smarty
 */
function smarty_function_control($params, &$smarty)
{
    global $db, $user;
    if (isset($params['type']) && isset($params['name']) || $params['type'] == 'buttongroup' || $params['type'] == 'antispam') {
        //    || $params['type'] == 'captcha' || $params['type'] == 'recaptcha' || $params['type'] == 'antispam') {
        //	  || $params['type'] == 'recaptcha' || $params['type'] == 'antispam') {
        // if a label wasn't passed in then we need to set one.
        //if (empty($params['label'])) $params['label'] = $params['name'];
        //Figure out which type of control to use. Also, some controls need some special setup.  We handle that here.
        if ($params['type'] == 'popupdatetimecontrol') {
            //FIXME this control does not exist due ot missing library files
            $control = new popupdatetimecontrol(null, "", false);
        } elseif ($params['type'] == 'yuidatetimecontrol') {
            $edittext = isset($params['edit_text']) ? $params['edit_text'] : 'Change Date/Time';
            $showdate = true;
            if (isset($params['show_date']) && $params['show_date'] == false) {
                $showdate = false;
            }
            $showtime = true;
            if (isset($params['show_time']) && $params['show_time'] == false) {
                $showtime = false;
            }
            $control = new yuidatetimecontrol($params['value'], $edittext, $showdate, $showtime);
            if (empty($params['value'])) {
                $params['value'] = time();
            }
        } elseif ($params['type'] == 'yuicalendarcontrol') {
            $control = new yuicalendarcontrol($params['value']);
            if (empty($params['value'])) {
                $params['value'] = time();
            }
        } elseif ($params['type'] == 'datetimecontrol' || $params['type'] == 'datetime') {
            if (empty($params['value'])) {
                $params['value'] = time();
            }
            $showdate = isset($params['showdate']) ? $params['showdate'] : true;
            $showtime = isset($params['showtime']) ? $params['showtime'] : true;
            $control = new datetimecontrol($params['value'], $showdate, $showtime);
        } elseif ($params['type'] == 'monthyear') {
            $control = new monthyearcontrol($params['month'], $params['year']);
        } elseif ($params['type'] == 'buttongroup') {
            $submit = isset($params['submit']) ? $params['submit'] : null;
            $reset = isset($params['reset']) ? $params['reset'] : null;
            $cancel = isset($params['cancel']) ? $params['cancel'] : null;
            $returntype = isset($params['returntype']) ? $params['returntype'] : null;
            $control = new buttongroupcontrol($submit, $reset, $cancel, null, $returntype);
        } elseif ($params['type'] == 'files') {
            if (!empty($params['olduploader'])) {
                $control = new uploadcontrol();
            } else {
                $subtype = isset($params['subtype']) ? $params['subtype'] : null;
                $control = new filemanagercontrol($subtype);
                $control->limit = isset($params['limit']) ? $params['limit'] : 10;
                $control->value = $params['value'];
            }
        } elseif ($params['type'] == 'tags') {
            $collections = isset($params['collections']) ? $params['collections'] : array();
            $subtype = isset($params['subtype']) ? $params['subtype'] : null;
            $control = new tagpickercontrol($collections, $subtype);
        } elseif ($params['type'] == 'dropdown') {
            $control = new dropdowncontrol($params['default']);
            $control->type = "select";
            $control->default = $params['default'];
            $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
            $control->multiple = isset($params['multiple']) ? true : false;
            if (isset($params['from']) && isset($params['to'])) {
                for ($i = $params['from']; $i <= $params['to']; $i++) {
                    $control->items[$i] = isset($params['zeropad']) ? sprintf("%02d", $i) : $i;
                }
            } elseif (isset($params['frommodel']) || isset($params['items']) && isset($params['key'])) {
                $key = isset($params['key']) ? $params['key'] : 'id';
                $display = isset($params['display']) ? $params['display'] : 'title';
                $order = isset($params['orderby']) ? $params['orderby'] : $display;
                $dir = isset($params['dir']) ? $params['dir'] : 'ASC';
                if (isset($params['frommodel'])) {
                    $model = new $params['frommodel']();
                    $where = empty($params['where']) ? null : $params['where'];
                    $params['items'] = $db->selectObjects($model->tablename, $where, $order . ' ' . $dir);
                }
                foreach ($params['items'] as $item) {
                    $control->items[$item->{$key}] = $item->{$display};
                }
                $noitems = gt("-- No items found --");
                if (count($control->items) < 1) {
                    $control->items = array(0 => $noitems);
                }
            } else {
                if (is_array($params['items'])) {
                    $control->items = $params['items'];
                    if (!empty($params['values'])) {
                        $control->items = array_combine($params['values'], $control->items);
                    }
                } elseif (is_string($params['items'])) {
                    $delimiter = isset($params['delimiter']) ? $params['delimiter'] : ',';
                    $items = explode($delimiter, $params['items']);
                    if (!empty($params['values'])) {
                        $values = is_array($params['values']) ? $params['values'] : explode($delimiter, $params['values']);
                    } else {
                        $values = $items;
                    }
                    $control->items = array_combine($values, $items);
                } else {
                    $control->items = array();
                }
            }
        } elseif ($params['type'] == 'radiogroup') {
            $control = new radiogroupcontrol();
            // differentiate it from the old school forms
            $control->newschool = true;
            $control->default = $params['default'];
            $control->cols = $params['columns'];
            // get the items to use as the radio button labels
            $items = is_array($params['items']) ? $params['items'] : explode(',', $params['items']);
            // check if we have a list of values.  if not we can assume they are passed in via the items
            // array as the keys.
            if (isset($params['values'])) {
                $values = is_array($params['values']) ? $params['values'] : explode(',', $params['values']);
                $control->items = array_combine($values, $items);
            } else {
                $control->items = $items;
                //array_combine($items, $items);
            }
        } elseif ($params['type'] == 'radio') {
            $control = new radiocontrol();
            $control->value = $params['value'];
            $control->newschool = true;
        } elseif ($params['type'] == 'textarea') {
            $control = new texteditorcontrol();
            if (isset($params['module'])) {
                $control->module = $params['module'];
            }
            if (isset($params['rows'])) {
                $control->rows = $params['rows'];
            }
            if (isset($params['cols'])) {
                $control->cols = $params['cols'];
            }
            //if (isset($params['toolbar'])) $control->toolbar = $params['toolbar'];
        } elseif ($params['type'] == 'editor' || $params['type'] == 'html') {
            if (SITE_WYSIWYG_EDITOR == "ckeditor") {
                $control = new ckeditorcontrol();
                $control->toolbar = empty($params['toolbar']) ? '' : $params['toolbar'];
            } else {
                $control = new htmleditorcontrol();
                if (isset($params['module'])) {
                    $control->module = $params['module'];
                }
                if (isset($params['rows'])) {
                    $control->rows = $params['rows'];
                }
                if (isset($params['cols'])) {
                    $control->cols = $params['cols'];
                }
                $control->height = $params['height'] ? $params['height'] : "600px";
                if (isset($params['toolbar'])) {
                    $control->toolbar = $params['toolbar'];
                }
            }
        } elseif ($params['type'] == 'listbuilder') {
            $default = isset($params['default']) ? $params['default'] : array();
            $source = isset($params['source']) ? $params['source'] : array();
            $control = new listbuildercontrol($default, $source);
            echo $control->controlToHTML($params['name']);
            return;
        } elseif ($params['type'] == 'list') {
            $control = new listcontrol();
        } elseif ($params['type'] == 'antispam') {
            //eDebug(ANTI_SPAM_CONTROL, true);
            if (SITE_USE_ANTI_SPAM && ANTI_SPAM_CONTROL == 'recaptcha') {
                // make sure we have the proper config.
                if (!defined('RECAPTCHA_PUB_KEY')) {
                    echo '<h2 style="color:red">' . gt('reCaptcha configuration is missing the public key.') . '</h2>';
                    return;
                }
                if ($user->isLoggedIn() && ANTI_SPAM_USERS_SKIP == 1) {
                    // skip it for logged on users based on config
                } else {
                    // include the library and show the form control
                    require_once BASE . 'external/recaptchalib.php';
                    echo recaptcha_get_html(RECAPTCHA_PUB_KEY, $error);
                    echo '<p>' . gt('Fill out the above security question to submit your form.') . '</p>';
                }
                return;
            } elseif (ANTI_SPAM_CONTROL == 0) {
                return;
            }
        } elseif ($params['type'] == 'user') {
            $control = new dropdowncontrol();
            $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
            $control->items = $db->selectDropdown('user', 'username');
        } elseif ($params['type'] == 'state') {
            //old use:  if (empty($params['all_us_territories'])) {
            /*$regions = $db->select
                  $not_states = array(3,6,7,8,9,10,11,17,20,30,46,50,52,60);
              } else {
                  $not_states = array();
              }*/
            //if(!empty($params['exclude'])) $not_states = array_merge($not_states,explode(',',$params['exclude']));
            if ($db->tableExists('geo_region')) {
                $c = $db->selectObject('geo_country', 'is_default=1');
                if (empty($c->id)) {
                    $country = 223;
                } else {
                    $country = $c->id;
                }
                $control = new dropdowncontrol();
                if (isset($params['multiple'])) {
                    $control->multiple = true;
                    $control->items[-1] = 'ALL United States';
                }
                /*if (isset($params['add_other'])) {                   
                      $control->items[-2] = '-- Specify State Below --';
                  }*/
                $states = $db->selectObjects('geo_region', 'country_id=' . $country . ' AND active=1 ORDER BY rank, name ASC');
                foreach ($states as $state) {
                    // only show the US states unless the theme says to show all us territories
                    //if (!in_array($state->id, $not_states)) {
                    $control->items[$state->id] = isset($params['abbv']) ? $state->code : $state->name;
                    //}
                }
                //if(!count($states)) $control->items[-2] = '-- Specify State Below --';
                if (isset($params['add_other'])) {
                    $control->items[-2] = '-- Specify State Below --';
                } else {
                    $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
                }
                // sanitize the default value. can accept as id, code abbrv or full name,
                if (!empty($params['value']) && !is_numeric($params['value']) && !is_array($params['value'])) {
                    $params['value'] = $db->selectValue('geo_region', 'id', 'name="' . $params['value'] . '" OR code="' . $params['value'] . '"');
                }
            } else {
                echo "NO TABLE";
                exit;
            }
        } elseif ($params['type'] == 'country') {
            //old - pre address configuration
            //if(!empty($params['exclude'])) $not_countries = explode(',',$params['exclude']);
            //else $not_countries = array();
            if ($db->tableExists('geo_country')) {
                $control = new dropdowncontrol();
                $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
                if (isset($params['multiple'])) {
                    $control->multiple = true;
                    //$control->items[-1] = 'ALL United States';
                }
                if ($params['show_all']) {
                    $countries = $db->selectObjects('geo_country', null, 'name ASC');
                } else {
                    $countries = $db->selectObjects('geo_country', 'active=1', 'name ASC');
                }
                foreach ($countries as $country) {
                    //if (!in_array($country->id, $not_countries)) {
                    $control->items[$country->id] = isset($params['abbv']) ? $country->iso_code_3letter : $country->name;
                    //}
                }
                // sanitize the default value. can accept as id, code abbrv or full name,
                if (!empty($params['value']) && !is_numeric($params['value']) && !is_array($params['value'])) {
                    $params['value'] = $db->selectValue('geo_country', 'id', 'name="' . $params['value'] . '" OR code="' . $params['value'] . '"');
                }
            } else {
                echo "NO TABLE";
                exit;
            }
        } elseif ($params['type'] == 'quantity') {
            $value = isset($params['value']) ? $params['value'] : null;
            $min = isset($params['min']) ? $params['min'] : 0;
            $max = isset($params['max']) ? $params['max'] : 99999;
            $control = new quantitycontrol($value, $min, $max);
        } elseif ($params['type'] == 'checkbox') {
            $value = isset($params['value']) ? $params['value'] : null;
            $control = new checkboxcontrol($value);
            $control->postfalse = isset($params['postfalse']) ? 1 : 0;
            $control->newschool = true;
            $control->value = isset($params['value']) ? $params['value'] : 1;
        } elseif ($params['type'] == 'tagtree') {
            $control = new tagtreecontrol($params);
        } elseif ($params['type'] == 'filedisplay-types') {
            $control = new dropdowncontrol();
            $control->include_blank = '-- This modules does not use files --';
            $control->items = get_filedisplay_views();
        } elseif ($params['type'] == 'calendar') {
            $control = new calendarcontrol();
        } elseif ($params['type'] == 'text') {
            $control = new genericcontrol($params['type']);
            $control->size = $params['size'] ? $params['size'] : "40";
        } elseif ($params['type'] == 'autocomplete') {
            $control = new autocompletecontrol();
            $control->schema = "'" . str_replace(",", "','", $params['schema']) . "'";
            $control->value = $params['value'];
            $control->controller = empty($params['controller']) ? "search" : $params['controller'];
            $control->action = empty($params['action']) ? "autocomplete" : $params['action'];
            $control->searchmodel = empty($params['searchmodel']) ? "text" : $params['searchmodel'];
            $control->searchoncol = empty($params['searchoncol']) ? "title" : $params['searchoncol'];
            $control->jsinject = empty($params['jsinject']) ? "" : $params['jsinject'];
        } else {
            $control = new genericcontrol($params['type']);
        }
        //eDebug($smarty->getTemplateVars('formError'));
        //Add the optional params in specified
        if (isset($params['class'])) {
            $control->class = $params['class'];
        }
        if (isset($params['required'])) {
            $control->required = true;
        }
        // Let see if this control should be checked
        if (isset($params['checked'])) {
            // if we have a control group the values will probably be coming in an array
            if (is_array($params['checked'])) {
                // check if its in the array
                if (in_array($params['value'], $params['checked'])) {
                    $control->checked = true;
                } elseif (is_object(current($params['checked']))) {
                    foreach ($params['checked'] as $obj) {
                        if ($obj->id == $params['value']) {
                            $control->checked = true;
                        }
                    }
                }
            } elseif ($params['value'] == $params['checked']) {
                $control->checked = true;
            } elseif (is_bool($params['checked'])) {
                $control->checked = $params['checked'];
            } elseif ($params['checked'] == 1) {
                $control->checked = 1;
            }
        }
        if (expSession::is_set('last_POST')) {
            $post = expSession::get('last_POST');
            $post_errors = expSession::get('last_post_errors');
            // flag this field as having errors if it failed validation
            if (is_array($post_errors) && in_array($params['name'], $post_errors)) {
                $control->class .= ' field-error';
            }
            if ($params['type'] == 'checkbox') {
                $realname = str_replace('[]', '', $params['name']);
                $control->default = $params['value'];
                if (!empty($post[$realname])) {
                    if (is_array($post[$realname])) {
                        if (in_array($params['value'], $post[$realname])) {
                            $control->checked = true;
                        }
                    } else {
                        $control->checked = true;
                    }
                }
            } elseif (isset($params['multiple'])) {
                $realname = str_replace('[]', '', $params['name']);
                if (!empty($post[$realname])) {
                    $control->default = $post[$realname];
                }
            } else {
                if (!empty($post[$params['name']])) {
                    $control->default = $post[$params['name']];
                }
            }
        } elseif (isset($params['value'])) {
            // if this field is filtered than lets go ahead and format the data before we stick it in the field.
            if ($params['filter'] == 'money') {
                $params['value'] = expCore::getCurrencySymbol('USD') . number_format($params['value'], 2, '.', ',');
            } elseif ($params['filter'] == 'integer') {
                $params['value'] = number_format($params['value'], 0, '.', ',');
            }
            $control->default = $params['value'];
        }
        //if (isset($params['value'])) $control->default = $params['value'];
        if (isset($params['caption'])) {
            $control->caption = $params['caption'];
        }
        if (isset($params['size'])) {
            $control->size = $params['size'];
        }
        if (isset($params['nowrap'])) {
            $control->nowrap = "nowrap";
        }
        if (isset($params['flip'])) {
            $control->flip = $params['flip'];
        }
        if (isset($params['disabled']) && $params['disabled'] != false) {
            $control->disabled = true;
        }
        if (isset($params['maxlength'])) {
            $control->maxlength = $params['maxlength'];
        }
        if (isset($params['tabindex'])) {
            $control->tabindex = $params['tabindex'];
        }
        if (isset($params['accesskey'])) {
            $control->accesskey = $params['accesskey'];
        }
        if (isset($params['filter'])) {
            $control->filter = $params['filter'];
        }
        if (isset($params['onclick'])) {
            $control->onclick = $params['onclick'];
        }
        if (isset($params['onchange'])) {
            $control->onchange = $params['onchange'];
        }
        if (isset($params['readonly']) && $params['readonly'] != false) {
            $control->readonly = true;
        }
        if (isset($params['ajaxaction'])) {
            $control->ajaxaction = $params['ajaxaction'];
        }
        if (isset($params['loadjsfile'])) {
            $control->loadjsfile = $params['loadjsfile'];
        }
        if (isset($params['default_date'])) {
            $control->default_date = $params['default_date'];
        }
        if (isset($params['default_hour'])) {
            $control->default_hour = $params['default_hour'];
        }
        if (isset($params['default_min'])) {
            $control->default_min = $params['default_min'];
        }
        if (isset($params['default_ampm'])) {
            $control->default_ampm = $params['default_ampm'];
        }
        $control->name = $params['name'];
        $badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}");
        //$newid = str_replace($badvals, "", $params['name']);
        $control->id = isset($params['id']) && $params['id'] != "" ? $params['id'] : "";
        //echo $control->id;
        /*$labelclass = isset($params['labelclass']) ? ' '.$params['labelclass'] : '';
                
                //container for the controll set, including labelSpan and input
                if($params['type']!='hidden') echo '<label id="'.$control->id.'Control" class="control">'; 
        
        
                //Write out the label for this control if the user specified a label and there is no label position or position is set to left
                if ( (isset($params['label'])) && (!isset($params['labelpos']) || $params['labelpos'] == 'left') ) {
                    echo '<span class="label'.$labelclass.'">'.$params['label'].'</span>';
                }
                */
        // attempt to translate the label
        if (!empty($params['label'])) {
            $params['label'] = gt($params['label']);
        }
        //write out the control itself...and then we're done.
        if (isset($params['model'])) {
            echo $control->toHTML($params['label'], $params['model'] . '[' . $params['name'] . ']');
        } else {
            echo $control->toHTML($params['label'], $params['name']);
        }
        /*
        //Write out the label for this control if the user specified a label and position is set to right
        if (isset($params['label']) && $params['labelpos'] == 'right') {
            echo '<span class="label'.$labelclass.'">'.$params['label'].'</span>';
        }
        
        //close the control container div
        if($params['type']!='hidden'){ echo '</label>'; }
        */
    } else {
        echo "Both the 'type' and 'name' parameters are required for the control plugin to function";
    }
}