if (isset($_POST['formlink']) and $_POST['formlink'] != "none") {
     // select box is not currently linked and user is requesting to link
     if (!$element->isLinked) {
         $form_handler->updateField($element, $element->getVar("ele_handle"), "bigint(20)");
     }
     global $xoopsDB;
     $sql_link = "SELECT ele_caption, id_form, ele_handle FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_id = " . intval($_POST['formlink']);
     $res_link = $xoopsDB->query($sql_link);
     $array_link = $xoopsDB->fetchArray($res_link);
     $processedValues['elements']['ele_value'][2] = $array_link['id_form'] . "#*=:*" . $array_link['ele_handle'];
 } else {
     // a user requests to unlink the select box and select box is currently linked
     if ($_POST['formlink'] == "none" and $element->isLinked) {
         $form_handler->updateField($element, $element->getVar("ele_handle"), "text");
     }
     list($_POST['ele_value'], $processedValues['elements']['ele_uitext']) = formulize_extractUIText($_POST['ele_value']);
     foreach ($_POST['ele_value'] as $id => $text) {
         if ($text !== "") {
             $processedValues['elements']['ele_value'][2][$text] = isset($_POST['defaultoption'][$id]) ? 1 : 0;
         }
     }
 }
 $processedValues['elements']['ele_value'][8] = 0;
 if ($_POST['elements_listordd'] == 2) {
     $processedValues['elements']['ele_value'][0] = 1;
     // rows is 1
     $processedValues['elements']['ele_value'][8] = 1;
     // is autocomplete
     $processedValues['elements']['ele_value'][1] = 0;
     // multiple selections not allowed
 } else {
 function adminSave($element, $ele_value)
 {
     $changed = false;
     if (isset($_POST['formlink']) and $_POST['formlink'] != "none") {
         global $xoopsDB;
         $sql_link = "SELECT ele_caption, id_form, ele_handle FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_id = " . intval($_POST['formlink']);
         $res_link = $xoopsDB->query($sql_link);
         $array_link = $xoopsDB->fetchArray($res_link);
         $ele_value[2] = $array_link['id_form'] . "#*=:*" . $array_link['ele_handle'];
     } else {
         $ele_value[2] = array();
         list($_POST['ele_value'], $ui_text) = formulize_extractUIText($_POST['ele_value']);
         foreach ($_POST['ele_value'] as $id => $text) {
             if ($text !== "") {
                 $ele_value[2][$text] = isset($_POST['defaultoption'][$id]) ? 1 : 0;
             }
         }
         $element->setVar('ui_text', $ui_text);
     }
     $ele_value[8] = 0;
     if ($_POST['elements_listordd'] == 2) {
         $ele_value[0] = 1;
         $ele_value[8] = 1;
     } else {
         if ($_POST['elements_listordd']) {
             $ele_value[0] = $ele_value[0] > 1 ? intval($ele_value[0]) : 1;
         } else {
             $ele_value[0] = 1;
         }
     }
     $ele_value[1] = $_POST['elements_multiple'];
     $ele_value[3] = implode(",", $_POST['element_formlink_scope']);
     // handle conditions
     // grab any conditions for this page too
     // add new ones to what was passed from before
     $filter_key = 'formlinkfilter';
     if ($_POST["new_" . $filter_key . "_term"] != "") {
         $_POST[$filter_key . "_elements"][] = $_POST["new_" . $filter_key . "_element"];
         $_POST[$filter_key . "_ops"][] = $_POST["new_" . $filter_key . "_op"];
         $_POST[$filter_key . "_terms"][] = $_POST["new_" . $filter_key . "_term"];
         $_POST[$filter_key . "_types"][] = "all";
     }
     if ($_POST["new_" . $filter_key . "_oom_term"] != "") {
         $_POST[$filter_key . "_elements"][] = $_POST["new_" . $filter_key . "_oom_element"];
         $_POST[$filter_key . "_ops"][] = $_POST["new_" . $filter_key . "_oom_op"];
         $_POST[$filter_key . "_terms"][] = $_POST["new_" . $filter_key . "_oom_term"];
         $_POST[$filter_key . "_types"][] = "oom";
     }
     // then remove any that we need to
     $conditionsDeleteParts = explode("_", $_POST['optionsconditionsdelete']);
     $deleteTarget = $conditionsDeleteParts[1];
     if ($_POST['optionsconditionsdelete']) {
         // go through the passed filter settings starting from the one we need to remove, and shunt the rest down one space
         // need to do this in a loop, because unsetting and key-sorting will maintain the key associations of the remaining high values above the one that was deleted
         $originalCount = count($_POST[$filter_key . "_elements"]);
         for ($i = $deleteTarget; $i < $originalCount; $i++) {
             // 2 is the X that was clicked for this page
             if ($i > $deleteTarget) {
                 $_POST[$filter_key . "_elements"][$i - 1] = $_POST[$filter_key . "_elements"][$i];
                 $_POST[$filter_key . "_ops"][$i - 1] = $_POST[$filter_key . "_ops"][$i];
                 $_POST[$filter_key . "_terms"][$i - 1] = $_POST[$filter_key . "_terms"][$i];
                 $_POST[$filter_key . "_types"][$i - 1] = $_POST[$filter_key . "_types"][$i];
             }
             if ($i == $deleteTarget or $i + 1 == $originalCount) {
                 // first time through or last time through, unset things
                 unset($_POST[$filter_key . "_elements"][$i]);
                 unset($_POST[$filter_key . "_ops"][$i]);
                 unset($_POST[$filter_key . "_terms"][$i]);
                 unset($_POST[$filter_key . "_types"][$i]);
             }
         }
     }
     if (count($_POST[$filter_key . "_elements"]) > 0) {
         $ele_value[5][0] = $_POST[$filter_key . "_elements"];
         $ele_value[5][1] = $_POST[$filter_key . "_ops"];
         $ele_value[5][2] = $_POST[$filter_key . "_terms"];
         $ele_value[5][3] = $_POST[$filter_key . "_types"];
     } else {
         $ele_value[5] = "";
     }
     $element->setVar('ele_value', $ele_value);
     if (isset($_POST['changeuservalues']) and $_POST['changeuservalues'] == 1) {
         include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
         $fid = $element->getVar('id_form');
         $data_handler = new formulizeDataHandler($fid);
         $newValues = $element->getVar('ele_value');
         $ele_id = $element->getVar('ele_id');
         if (!($changeResult = $data_handler->changeUserSubmittedValues($ele_id, $newValues))) {
             print "Error updating user submitted values for the options in element {$ele_id}";
         }
     }
     return $changed;
 }
 function adminSave($element, $ele_value)
 {
     $changed = false;
     list($indexId, $ele_uitext) = formulize_extractUIText($_POST['ele_value']);
     foreach ($indexId as $id => $text) {
         if ($text !== "") {
             $ele_value[$text] = isset($_POST['defaultoption'][$id]) ? 1 : 0;
         }
     }
     $element->setVar('ele_value', $ele_value);
     if ($_POST['element_delimit']) {
         if ($_POST['element_delimit'] == "custom") {
             $element->setVar('ele_delim', $_POST['element_delim_custom']);
         } else {
             $element->setVar('ele_delim', $_POST['element_delimit']);
         }
     }
     if (isset($_POST['changeuservalues']) and $_POST['changeuservalues'] == 1) {
         include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
         $fid = $element->getVar('id_form');
         $data_handler = new formulizeDataHandler($fid);
         $newValues = $element->getVar('ele_value');
         $ele_id = $element->getVar('ele_id');
         if (!($changeResult = $data_handler->changeUserSubmittedValues($ele_id, $newValues))) {
             print "Error updating user submitted values for the options in element {$ele_id}";
         }
     }
     return $changed;
 }
 function adminSave($ele_value)
 {
     $value = array();
     list($ele_value, $uitext) = formulize_extractUIText($ele_value);
     while ($v = each($ele_value)) {
         if ($v['value'] !== "") {
             $value[$v['value']] = 0;
         }
     }
     return array(0 => $value, 1 => $uitext);
 }