/** * page code function */ function PageCompPageMainCode() { global $site; global $dir; global $tmpl; global $page; global $join_page_check_limit; global $join_pages_num; global $p_arr; global $_page; global $en_aff; global $oTemplConfig; global $newusernotify; $enable_security_image = getParam('enable_security_image'); $autoApproval_ifJoin = isAutoApproval('join'); ob_start(); switch ($page) { // fill inputs with values from precede join pages case $page > 1: $hidden_vals = ''; // inputs with POST values $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('" . (int) $_page['name_index'] . "',show_on_page)) {$join_page_check_limit} ORDER BY `order` ASC"); while ($arrpd = mysql_fetch_array($respd)) { $fname = get_input_name($arrpd); switch ($arrpd['type']) { case 'set': // set of checkboxes $vals = preg_split("/[,\\']+/", $arrpd['extra'], -1, PREG_SPLIT_NO_EMPTY); $p_arr[$fname] = ''; foreach ($vals as $v) { if (strlen(trim($v)) <= 0) { continue; } $hidden_vals .= '<input type="hidden" name="' . ($fname . "_" . $v) . '" value="' . process_pass_data($_POST[$fname . "_" . $v]) . '">'; $p_arr[$fname . "_" . $v] = process_pass_data($_POST[$fname . "_" . $v]); if ($_POST[$fname . "_" . $v] == 'on') { if (strlen($p_arr[$fname])) { $p_arr[$fname] .= ",{$v}"; } else { $p_arr[$fname] .= $v; } } } break; case 'date': $p_arr[$fname] = sprintf("%04d-%02d-%02d", (int) $_POST[$fname . '_year'], (int) $_POST[$fname . '_month'], (int) $_POST[$fname . '_day']); $hidden_vals .= '<input type="hidden" name="' . $fname . '_year" value="' . (int) $_POST[$fname . '_year'] . '" />'; $hidden_vals .= '<input type="hidden" name="' . $fname . '_month" value="' . (int) $_POST[$fname . '_month'] . '" />'; $hidden_vals .= '<input type="hidden" name="' . $fname . '_day" value="' . (int) $_POST[$fname . '_day'] . '">'; break; default: if ($arrpd['get_value']) { $funcbody = $arrpd['get_value']; $func = create_function('$arg0', $funcbody); $hidden_vals .= '<input type="hidden" name="' . $fname . '" value="' . process_pass_data($_POST[$fname]) . '">'; $p_arr[$fname] = process_pass_data($func($_POST)); } else { $hidden_vals .= '<input type="hidden" name="' . $fname . '" value="' . process_pass_data($_POST[$fname]) . '">'; $p_arr[$fname] = process_pass_data($_POST[$fname]); } break; } } // check values $query = "SELECT * FROM ProfilesDesc\n\t\t\t\tWHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('" . (int) $_page['name_index'] . "',show_on_page)) {$join_page_check_limit}\n\t\t\t\tORDER BY `join_page` ASC"; $respd = db_res($query); while ($arrpd = mysql_fetch_array($respd)) { if (!strlen($arrpd['check'])) { continue; } $fname = get_input_name($arrpd); $funcbody = $arrpd[check]; $func = create_function('$arg0', $funcbody); if (!$func($p_arr[$fname])) { $add_on .= report_err(_t($arrpd['because'], $arrpd['min_length'], $arrpd['max_length'])); } } $page = !$add_on ? $page : $page - 1; break; break; case 'done': // fill array with POST values $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('" . (int) $_page['name_index'] . "',show_on_page)) {$join_page_check_limit} ORDER BY `order` ASC"); while ($arrpd = mysql_fetch_array($respd)) { $fname = get_input_name($arrpd); switch ($arrpd['type']) { case 'set': // set of checkboxes $vals = preg_split("/[,\\']+/", $arrpd['extra'], -1, PREG_SPLIT_NO_EMPTY); $p_arr[$fname] = ''; foreach ($vals as $v) { if (strlen(trim($v)) <= 0) { continue; } $hidden_vals .= '<input type="hidden" name="' . ($fname . "_" . $v) . '" value="' . process_pass_data($_POST[$fname . "_" . $v]) . '">'; $p_arr[$fname . "_" . $v] = process_pass_data($_POST[$fname . "_" . $v]); if ($_POST[$fname . "_" . $v] == 'on') { if (strlen($p_arr[$fname])) { $p_arr[$fname] .= ",{$v}"; } else { $p_arr[$fname] .= $v; } } } break; case 'date': $p_arr[$fname] = sprintf("%04d-%02d-%02d", (int) $_POST[$fname . '_year'], (int) $_POST[$fname . '_month'], (int) $_POST[$fname . '_day']); $hidden_vals .= '<input type="hidden" name="' . $fname . '_year" value="' . (int) $_POST[$fname . '_year'] . '" />'; $hidden_vals .= '<input type="hidden" name="' . $fname . '_month" value="' . (int) $_POST[$fname . '_month'] . '" />'; $hidden_vals .= '<input type="hidden" name="' . $fname . '_day" value="' . (int) $_POST[$fname . '_day'] . '">'; break; default: if ($arrpd['get_value']) { $funcbody = $arrpd['get_value']; $func = create_function('$arg0', $funcbody); $hidden_vals .= '<input type="hidden" name="' . $fname . '" value="' . process_pass_data($_POST[$fname]) . '">'; $p_arr[$fname] = process_pass_data($func($_POST)); } else { $hidden_vals .= '<input type="hidden" name="' . $fname . '" value="' . process_pass_data($_POST[$fname]) . '">'; $p_arr[$fname] = process_pass_data($_POST[$fname]); } break; } } // check values if ($enable_security_image) { if (!isset($_POST['securityImageValue']) || !isset($_COOKIE['strSec']) || md5($_POST['securityImageValue']) != $_COOKIE['strSec']) { $page = $join_pages_num; $add_on .= report_err(_t("_SIMG_ERR")); } } $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('" . (int) $_page['name_index'] . "',show_on_page)) {$join_page_check_limit} AND `join_page` > 0 ORDER BY `order` ASC"); while ($arrpd = mysql_fetch_array($respd)) { if (!strlen(trim($arrpd['check']))) { continue; } $fname = get_input_name($arrpd); $funcbody = $arrpd['check']; $func = create_function('$arg0', $funcbody); if (!$func($p_arr[$fname])) { $page = floor($arrpd['join_page'] / 1000); $add_on .= report_err(_t($arrpd['because'], $arrpd['min_length'], $arrpd['max_length'])); } } break; default: break; } switch ($page) { default: global $tmpl; if ($oTemplConfig->customize['join_page']['showPageText']) { $page_text = _t("_JOIN1", $page); } echo $add_on; break; } switch ($page) { case 'done': // new profile creation $cl_values = "INSERT INTO `Profiles` SET "; $cl_first = 0; $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & 2 AND `to_db` = 1 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('" . (int) $_page['name_index'] . "',show_on_page)) {$join_page_check_limit} ORDER BY `order` ASC"); while ($arrpd = mysql_fetch_array($respd)) { $fname = get_input_name($arrpd); $dbname = get_field_name($arrpd); $fval = $p_arr[$fname]; if ($dbname == 'zip') { $fval = strtoupper(str_replace(' ', '', $fval)); } switch ($arrpd['type']) { case 'set': // set of checkboxes // set of checkboxes case 'r': // reference to array for combo box // reference to array for combo box case 'a': // text Area // text Area case 'c': // input box // input box case 'rb': // radio buttons // radio buttons case 'e': // enum combo box // enum combo box case 'en': // enum combo box with numbers // enum combo box with numbers case 'eny': // enum combo box with numbers // enum combo box with numbers case 'date': // date $fval = process_db_input($fval, 0, 1); $cl_values .= " `{$dbname}` = '{$fval}'"; $cl_values .= ", "; break; case 'p': $fval = md5(process_pass_data($fval)); $cl_values .= " `{$dbname}` = '{$fval}'"; $cl_values .= ", "; break; } } $cl_values .= " `LastReg` = NOW()"; db_res($cl_values); $IDnormal = mysql_insert_id(); $IDcrypt = crypt($IDnormal, "secret_string"); // encrypted ID for security purposes setcookie("IDc", $IDcrypt, 0, "/"); $_COOKIE['IDc'] = $IDcrypt; // Affiliate and friend checking if ($en_aff && $_COOKIE['idAff']) { $res = db_res("SELECT `ID` FROM `aff` WHERE `ID` = {$_COOKIE['idAff']} AND `Status` = 'active'"); if (mysql_num_rows($res)) { $res = db_res("INSERT INTO `aff_members` (`idAff`,`idProfile`) VALUES ({$_COOKIE['idAff']}, {$IDnormal})"); } } if ($en_aff && $_COOKIE['idFriend']) { $idFriend = getID($_COOKIE['idFriend']); if ($idFriend) { $res = db_res("UPDATE `Profiles` SET `aff_num` = `aff_num` + 1 WHERE `ID` = '{$idFriend}'"); createUserDataFile($idFriend); } } if (strcmp(crypt($IDnormal, 'secret_string'), $_COOKIE['IDc']) != 0) { ob_end_clean(); $_page['header'] = _t("_Error"); $ret = "<table width=\"100%\" cellpadding=4 cellspacing=4><tr><td align=center class=text2>"; $ret .= _t("_MUST_HAVE_COOKIES"); $ret .= "</td></tr></table>"; return $ret; } if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin')) { db_res("UPDATE `Profiles` SET `Status`='Active' WHERE `ID`='{$IDnormal}'"); $page_text = _t("_USER_ACTIVATION_SUCCEEDED") . $ret . $add_on; $message = getParam("t_Activation"); $subject = getParam('t_Activation_subject'); sendMail($p_arr['Email'], $subject, $message, $IDnormal); } else { db_res("UPDATE `Profiles` SET `Status`='Approval' WHERE `ID`='{$IDnormal}'"); $page_text = _t("_USER_CONF_SUCCEEDED") . $add_on; } if ($newusernotify) { $message = "New user {$p_arr['NickName']} with email {$p_arr['Email']} has been confirmed,\nhis/her ID is {$IDnormal}.\n--\n{$site['title']} mail delivery system\n<Auto-generated e-mail, please, do not reply>\n"; $subject = "New user confirmed"; sendMail($site['email_notify'], $subject, $message); } } else { $page_text = _t("_JOIN3") . $add_on; $page_text .= activation_mail($IDnormal); $page_text .= "<br /><br /><br /><br /><center>" . _t("_UPLOAD_WHILE_WAITING", $site['url']) . "</center>"; } modules_add($IDnormal); if (!$autoApproval_ifJoin) { modules_block($IDnormal); } createUserDataFile($IDnormal); // ---------------------------------------------------------- echo "<div id=\"first_column\">"; echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=center class=text2>"; echo "<div align=justify>{$page_text}</div>"; break; default: echo "<div id=\"first_column\">"; echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=center class=text2>"; //----------------------------------------------------------- do { $join_page_limit = 'done' == $page ? " AND join_page > '" . $join_pages_num * 1000 . "'" : " AND join_page > '" . $page * 1000 . "' AND join_page < '" . ($page + 1) * 1000 . "'"; $query = "SELECT COUNT(*) FROM `ProfilesDesc` WHERE `visible` & 2 {$join_page_limit} AND (FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('3',show_on_page))"; $res = db_res($query); $item_num = mysql_fetch_row($res); if ($item_num[0] <= 0 && $page < $join_pages_num) { $page++; } } while ($item_num[0] <= 0 && $page < $join_pages_num); $join_page_limit = 'done' == $page ? " AND join_page > '" . $join_pages_num * 1000 . "'" : " AND join_page > '" . $page * 1000 . "' AND join_page < '" . ($page + 1) * 1000 . "'"; $hidden_vals .= "<input type=\"hidden\" name=\"page\" value=\"{$page}\" />"; //----------------------------------------------------------- echo "\n\t <form name=\"jform\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" " . ($join_pages_num == $page ? "onSubmit=\"return validateJoinForm();\">" : ">") . "\n\n\t {$hidden_vals}\n\n\t <input type=hidden name=\"ID\" value=\"{$IDnormal}\" />\n\n\t <div align=justify>{$page_text}</div>\n<table width=\"100%\" cellspacing=\"2\" cellpadding=\"0\" border=\"0\">"; $first_row = 1; $respd = db_res("SELECT * FROM ProfilesDesc\n\t\t\t WHERE `visible` & 2 AND ( FIND_IN_SET('0',show_on_page) OR FIND_IN_SET('" . (int) $_page['name_index'] . "',show_on_page)) {$join_page_limit}\n\t\t\t ORDER BY `join_page` ASC"); if ($oTemplConfig->customize['join_page']['show_3rd_col']) { $columns = 3; } else { $columns = 2; } while ($arrpd = mysql_fetch_array($respd)) { $fname = get_input_name($arrpd); if ($arrpd['get_value'] && $arrpd['to_db'] == 0) { $funcbody = $arrpd['get_value']; $func = create_function('$arg0', $funcbody); $p_arr[$fname] = $func($p_arr); } $not_first_row = 0; switch ($arrpd['type']) { case 'set': // set of checkboxes echo print_row_set($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'rb': // radio buttons echo print_row_radio_button($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'r': // reference to array for combo box if ($fname == 'Country') { $onchange = "flagImage = document.getElementById('flagImageId'); flagImage.src = '{$site['flags']}' + this.value.toLowerCase() + '.gif';"; if (strlen($p_arr[$fname]) == 0) { $p_arr[$fname] = getParam('default_country'); } $imagecode = '<img id="flagImageId" src="' . ($site['flags'] . strtolower($p_arr[$fname])) . '.gif" alt="flag" />'; } else { $onchange = ''; $imagecode = ''; } echo print_row_ref($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns, '', 0, $onchange, $imagecode); break; case '0': // divider echo print_row_delim($first_row, $arrpd, "panel", $columns); $not_first_row = 1; $first_row = 1; break; case 'e': // enum combo box echo print_row_enum($first_row, $arrpd, $p_arr[$fname], "table", $javascript, 0); break; case 'en': // enum combo box with numbers echo print_row_enum_n($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'eny': // enum combo box with years echo print_row_enum_years($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'date': //date echo print_row_date($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'a': // text Area echo print_row_area($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'c': // input box echo print_row_edit($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; case 'p': // input box password echo print_row_pwd($first_row, $arrpd, $p_arr[$fname], "table", 0, $columns); break; default: $not_first_row = 1; break; } if (!$not_first_row && $first_row == 1) { $first_row = 0; } } echo "</table>"; // show on the last page of join form if ($join_pages_num == $page) { ?> <script language=javascript> <!-- function validateJoinForm() { if ( document.forms['jform'].elements['i_agree'].checked ) return true; alert('<?php echo _t("_CLICK_AGREE"); ?> '); return false; } --> </script> <?php echo "<br /><div class=\"security_image_block\"><center>\n"; if ($enable_security_image) { echo "\n\t\t <img alt=\"Security Image\" src=\"simg/simg.php\" /><br /><br />" . _t("_Enter what you see:") . "<input name=\"securityImageValue\" type=\"text\" size=\"15\"><br /><br />"; } echo "</center>"; $ret = <<<ID \t\t<script type="text/javascript"> \t\t\tfunction id_registration() \t\t\t{ \t\t\t\toCheckBox = document.getElementById( "boonex_id" ); \t\t\t\tif( oCheckBox.checked ) \t\t\t\t\twindow.open( 'http://www.boonex.com/id/', '', 'width=800, height=600, menubar=yes, status=yes, resizable=yes, scrollbars=yes, toolbar=yes, location=yes') \t\t\t} \t\t</script> ID; echo $ret; echo "\n\t\t <div style=\"text-align:center;\"><input type=checkbox name=i_agree id=i_agree /><label for=i_agree>" . _t("_I AGREE", $site['url']) . "</label> </div>\n"; // BoonEx ID implementation // <div style=\"text-align:center;\"><input type=checkbox name=\"boonex_id\" id=\"boonex_id\" /><label for=boonex_id>" . _t("_ID_CREATE", "http://www.boonex.com/id/" ) . "</label> </div>"; } echo "<br /><center><input onclick=\"id_registration();\" type=\"submit\" value=\"" . _t("_Join") . "\" /></center></form></div>"; break; } global $memberID; echo "</td></tr></table>"; echo "</div>"; echo "<div id=\"second_column\">"; echo "<div class=\"member_login\">"; $action = "login"; $text = _t('_Member Login'); $table = "Profiles"; $login_page = "{$site['url']}member.php"; $join_page = "{$site['url']}join_form.php"; $forgot_page = "{$site['url']}forgot.php"; $template = "{$dir['root']}templates/tmpl_{$tmpl}/join_login_form.html"; echo LoginForm($text, $action, $table, $login_page, $forgot_page, $template); echo "</div>"; if (getParam('enable_get_boonex_id')) { echo "<div class=\"import_boonex_id\">"; $action = "boonex"; $text = '<div class="boonex_id">' . _t('_Import BoonEx ID') . '</div>'; $table = "Profiles"; $login_page = "{$site['url']}member.php"; $join_page = "{$site['url']}join_form.php"; $forgot_page = ''; $template = "{$dir['root']}templates/tmpl_{$tmpl}/join_login_form.html"; echo LoginForm($text, $action, $table, $login_page, $forgot_page, $template); echo "</div>"; } echo "</div>"; $ret = ob_get_clean(); return $ret; }
/** * */ function copy_item_to_http_vars($old_item_r, $new_item_type) { $HTTP_VARS = array(); $results = fetch_item_attribute_type_rs($old_item_r['s_item_type'], 'not_instance_field_types'); if ($results) { $attr_order_no_r = array(); while ($item_attribute_type_r = db_fetch_assoc($results)) { if ($item_attribute_type_r['s_field_type'] == 'TITLE') { $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type']); $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no); $HTTP_VARS[$fieldname] = $old_item_r['title']; } else { $last_order_no = NULL; if (is_numeric($attr_order_no_r[$item_attribute_type_r['s_attribute_type']])) { $last_order_no = $attr_order_no_r[$item_attribute_type_r['s_attribute_type']]; } $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type'], $last_order_no); if ($order_no !== FALSE) { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no); // update with latest order no $attr_order_no_r[$item_attribute_type_r['s_attribute_type']] = $order_no; if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') { $attribute_val_r = fetch_attribute_val_r($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (is_not_empty_array($attribute_val_r)) { $HTTP_VARS[$fieldname] = $attribute_val_r; } } else { $attribute_val = fetch_attribute_val($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (strlen($attribute_val) > 0) { $HTTP_VARS[$fieldname] = $attribute_val; } } } } } db_free_result($results); } return $HTTP_VARS; }
} } // new/update profile $cl_where = ""; if (!$ADMIN && !$exist_arr) { $cl_values = "UPDATE `Profiles` SET "; } elseif ($ADMIN && $_POST['NewProfile'] == 'YES') { $cl_values = "INSERT INTO `Profiles` SET "; } elseif ($ADMIN) { $cl_values = "UPDATE `Profiles` SET "; } $cl_first = 0; $respd = db_res("SELECT * FROM ProfilesDesc WHERE `visible` & {$db_vsbl} AND `editable` & {$db_editbl} AND `to_db` = 1 AND ( FIND_IN_SET('0', `show_on_page`) OR FIND_IN_SET('" . (int) $_page['name_index'] . "', `show_on_page`)) ORDER BY `order` DESC"); while ($arrpd = mysql_fetch_array($respd)) { $fname = get_input_name($arrpd); $dbname = get_field_name($arrpd); $fval = $p_arr_new[$fname]; if ($dbname == "Status" && $fval == 'Active' && $enable_match && $ID > 0) { $send_cupid_mail_id = $ID; } switch ($arrpd['type']) { case 'set': // set of checkboxes // set of checkboxes case 'r': // reference to array for combo box // reference to array for combo box case 'c': // text box // text box case 'p':
/** Add the SELECT and ORDER BY CLAUSES @param $HTTP_VARS @param $column_display_config_rs @param $order_by by should be one of "s_item_type, owner_id, title, update_on" The $order_by value will control which order column is first in the list, the rest will be filled in after with defaults. @param $sortorder will be either "asc" or "desc" if not defined it will default to "asc" @param $index is the LIMIT value to apply. */ function fetch_item_listing_rs($HTTP_VARS, $column_display_config_rs, $order_by, $sortorder, $start_index = NULL, $items_per_page = NULL) { $query .= 'SELECT DISTINCT i.id AS item_id, ii.instance_no, ii.s_status_type, ii.status_comment, ii.owner_id, ii.borrow_duration, i.s_item_type, i.title, UNIX_TIMESTAMP(ii.update_on) AS update_on'; $column_order_by_rs = array(); if (is_array($column_display_config_rs)) { for ($i = 0; $i < count($column_display_config_rs); $i++) { $fieldname = NULL; if ($column_display_config_rs[$i]['column_type'] == 's_attribute_type') { $fieldname = get_field_name($column_display_config_rs[$i]['s_attribute_type'], $column_display_config_rs[$i]['order_no']); // if not an order by column, we want to generate the fields individually in the listings page. if ($column_display_config_rs[$i]['orderby_support_ind'] === 'Y' || $column_display_config_rs[$i]['search_attribute_ind'] === 'y') { if ($column_display_config_rs[$i]['orderby_datatype'] === 'numeric') { $query .= ', (ifnull(ia' . $i . '.attribute_val, ia' . $i . '.lookup_attribute_val)+0) AS \'' . $fieldname . '\''; } else { $query .= ', ifnull(ia' . $i . '.attribute_val, ia' . $i . '.lookup_attribute_val) AS \'' . $fieldname . '\''; } } } else { if ($column_display_config_rs[$i]['column_type'] == 's_field_type') { // TODO - we need to be able to specify the order by which the default order by's are actioned. At the // moment in the code title, instance_no and item_type are hardcoded to be added. When we an order field // for default order by for a listing config we can get rid of the hard coded order by and enable the TITLE // and ITEMTYPE. $field_type_fieldnames_r = array('ITEM_ID' => 'i.id', 'STATUSTYPE' => 'ii.s_status_type', 'OWNER' => 'ii.owner_id'); if ($column_display_config_rs[$i]['s_field_type'] == 'CATEGORY') { $query .= ', catia.lookup_attribute_val AS catia_lookup_attribute_val, catia.s_attribute_type AS catia_s_attribute_type, catia.order_no AS catia_order_no'; $fieldname = 'catia_lookup_attribute_val'; } else { if ($column_display_config_rs[$i]['s_field_type'] == 'INTEREST') { $query .= ', it.level AS interest_level'; $fieldname = 'interest_level'; } else { $fieldname = $field_type_fieldnames_r[$column_display_config_rs[$i]['s_field_type']]; } } } } if (strlen($fieldname) > 0) { if (strlen($order_by) == 0) { if ($column_display_config_rs[$i]['orderby_default_ind'] === 'Y') { $column_order_by_rs[] = array('orderby' => $fieldname, 'sortorder' => strtoupper(ifempty($column_display_config_rs[$i]['orderby_sort_order'], 'ASC'))); } } else { if (strcasecmp($order_by, $fieldname) === 0) { $column_order_by_rs[] = array('orderby' => $fieldname, 'sortorder' => strtoupper(ifempty($sortorder, ifempty($column_display_config_rs[$i]['orderby_sort_order'], 'ASC')))); } } } } } $query .= " " . from_and_where_clause($HTTP_VARS, $column_display_config_rs, 'LISTING'); if (count($column_order_by_rs) > 0) { $orderbyquery = ''; while (list(, $column_order_by_r) = each($column_order_by_rs)) { if (strlen($orderbyquery) > 0) { $orderbyquery .= ', '; } $orderbyquery .= $column_order_by_r['orderby'] . ' ' . $column_order_by_r['sortorder']; } $query .= ' ORDER BY ' . $orderbyquery . ', i.title, ii.instance_no ASC, i.s_item_type'; } else { if ($order_by == 's_item_type') { $query .= ' ORDER BY i.s_item_type ' . $sortorder . ', i.title, ii.instance_no ASC'; } else { if ($order_by == 'category') { $query .= ' ORDER BY catia_lookup_attribute_val ' . $sortorder . ', i.title, ii.instance_no ASC, i.s_item_type'; } else { if ($order_by == 'owner_id') { $query .= ' ORDER BY ii.owner_id ' . $sortorder . ', i.title, ii.instance_no ASC, i.s_item_type'; } else { if ($order_by == 's_status_type') { $query .= ' ORDER BY ii.s_status_type ' . $sortorder . ', i.title, ii.instance_no ASC, i.s_item_type'; } else { if ($order_by == 'update_on') { $query .= ' ORDER BY ii.update_on ' . $sortorder . ', i.title, ii.instance_no ASC, i.s_item_type'; } else { if ($order_by === 'item_id') { $query .= ' ORDER BY i.id ' . $sortorder . ', ii.instance_no ASC, i.s_item_type'; } else { if ($order_by === 'interest') { $query .= ' ORDER BY interest_level ' . $sortorder . ', i.title, ii.instance_no ASC, i.s_item_type'; } else { //if($order_by === 'title') $query .= ' ORDER BY i.title ' . $sortorder . ', ii.instance_no ASC, i.s_item_type'; } } } } } } } } if (is_numeric($start_index) && is_numeric($items_per_page)) { $query .= ' LIMIT ' . $start_index . ', ' . $items_per_page; } //echo "\n<code>Listing Query: $query</code>"; $result = db_query($query); if ($result && db_num_rows($result) > 0) { return $result; } else { return FALSE; } }
function get_vars_controls($with_page = 1, $with_per_page = 1, $with_sort_by = 1, $with_sort_order = 1, $with_gallery_view = 1) { global $affID; $get_inputs = ""; // common parameters if (isset($_REQUEST['ID']) && (int) $_REQUEST['ID'] > 0) { $get_inputs .= '<input type="hidden" name="ID" value="' . (int) $_REQUEST['ID'] . '" />'; } if (isset($_REQUEST['NickName']) && strlen($_REQUEST['NickName']) > 0) { $get_inputs .= '<input type="hidden" name="NickName" value="' . process_pass_data($_REQUEST['NickName']) . '" />'; } if (isset($_REQUEST['gallery_view']) && (int) $_REQUEST['gallery_view'] > 0 && $with_gallery_view) { $get_inputs .= '<input type="hidden" name="gallery_view" value="' . (int) $_REQUEST['gallery_view'] . '" />'; } if (isset($_REQUEST['photos_only']) && strlen($_REQUEST['photos_only']) > 0) { $get_inputs .= $_REQUEST['photos_only'] == 'on' ? '<input type="hidden" name="photos_only" value="on" />' : ''; } if (isset($_REQUEST['online_only']) && strlen($_REQUEST['online_only']) > 0) { $get_inputs .= '<input type="hidden" name="online_only" value="on" />'; } // navigation parameters if (isset($_REQUEST['page']) && (int) $_REQUEST['page'] > 0 && $with_page) { $get_inputs .= '<input type="hidden" name="page" value="' . (int) $_REQUEST['page'] . '" />'; } if (isset($_REQUEST['p_per_page']) && (int) $_REQUEST['p_per_page'] > 0 && $with_per_page) { $get_inputs .= '<input type="hidden" name="p_per_page" value="' . (int) $_REQUEST['p_per_page'] . '" />'; } if (isset($_REQUEST['sortby']) && strlen($_REQUEST['sortby']) > 0 && $with_sort_by) { $get_inputs .= '<input type="hidden" name="sortby" value="' . process_pass_data($_REQUEST['sortby']) . '" />'; } if (isset($_REQUEST['sortorder']) && strlen($_REQUEST['sortorder']) > 0 && $with_sort_order) { $get_inputs .= $_REQUEST['sortorder'] == 'ASC' ? '<input type="hidden" name="sortorder" value="ASC" />' : '<input type="hidden" name="sortorder" value="DESC" />'; } // ZIP search parameters if (isset($_REQUEST['zip']) && strlen($_REQUEST['zip']) > 0) { $get_inputs .= '<input type="hidden" name="zip" value="' . process_pass_data($_REQUEST['zip']) . '" />'; } if (isset($_REQUEST['metric']) && strlen($_REQUEST['metric']) > 0) { $get_inputs .= $_REQUEST['metric'] == 'miles' ? '<input type="hidden" name="metric" value="miles" />' : '<input type="hidden" name="metric" value="km" />'; } if (isset($_REQUEST['distance'])) { $get_inputs .= '<input type="hidden" name="distance" value="' . (int) $_REQUEST['distance'] . '" />'; } // extra parameters if (isset($_REQUEST['profiles']) && strlen($_REQUEST['profiles']) > 0) { $get_inputs .= '<input type="hidden" name="profiles" value="' . process_pass_data($_REQUEST['profiles']) . '" />'; } if (isset($_REQUEST['status']) && strlen($_REQUEST['status']) > 0) { $get_inputs .= '<input type="hidden" name="status" value="' . process_pass_data($_REQUEST['status']) . '" />'; } // admin parameters if (isset($_REQUEST['search']) && strlen($_REQUEST['search']) > 0) { $get_inputs .= '<input type="hidden" name="search" value="' . process_pass_data($_REQUEST['search']) . '" />'; } if (isset($_REQUEST['s_nickname']) && strlen($_REQUEST['s_nickname']) > 0) { $get_inputs .= '<input type="hidden" name="s_nickname" value="' . process_pass_data($_REQUEST['s_nickname']) . '" />'; } // affiliate parameters if (isset($affID) && (int) $affID > 0) { $get_inputs .= '<input type="hidden" name="affID" value="' . (int) $affID . '" />'; } $respd = db_res("SELECT * FROM `ProfilesDesc` WHERE `search_type` <> 'none' ORDER BY `search_order` ASC"); while ($arrpd = mysql_fetch_array($respd)) { $fname = get_field_name($arrpd); switch ($arrpd['search_type']) { case 'radio': case 'text': $fval = process_pass_data($_REQUEST[$fname]); if (isset($_REQUEST[$fname]) && strlen($fval)) { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}\" value=\"{$fval}\" />"; } break; case 'list': $fval = $_REQUEST[$fname]; if (is_array($fval) && count($fval) > 0) { while (list($key, $val) = each($fval)) { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}[]\" value=\"" . process_pass_data($val) . "\" />"; } } break; case 'check': if ($arrpd['type'] == 'r') { $findok = 0; $funcbody = $arrpd['extra']; $func = create_function("", $funcbody); $ar = $func(); foreach ($ar as $key => $value) { if ($_REQUEST["{$fname}_{$key}"] == "on") { $findok = 1; break; } } if ($findok) { foreach ($ar as $key => $value) { if ($_REQUEST["{$fname}_{$key}"] == "on") { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_{$key}\" value=\"on\" />"; } } } } elseif ($arrpd['type'] == 'e') { $findok = 0; $vals = preg_split("/[,\\']+/", $arr['extra'], -1, PREG_SPLIT_NO_EMPTY); foreach ($vals as $key) { if ($_REQUEST["{$fname}_{$key}"] == "on") { $findok = 1; break; } } if ($findok) { foreach ($vals as $key) { if ($_REQUEST["{$fname}_{$key}"] == "on") { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_{$key}\" value=\"on\" />"; } } } } break; case 'check_set': $vals = preg_split("/[,\\']+/", $arrpd['extra'], -1, PREG_SPLIT_NO_EMPTY); $offset = 0; foreach ($vals as $v) { if ($_REQUEST["{$fname}_{$offset}"] == "on") { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_{$offset}\" value=\"on\" />"; } $offset++; } break; case 'daterange': $fval_s = process_pass_data($_REQUEST["{$fname}_start"]); $fval_e = process_pass_data($_REQUEST["{$fname}_end"]); if (isset($_REQUEST["{$fname}_start"]) && strlen($fval_s)) { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_start\" value=\"{$fval_s}\" />"; } if (isset($_REQUEST["{$fname}_end"]) && strlen($fval_e)) { $get_inputs .= "<input type=\"hidden\" name=\"{$fname}_end\" value=\"{$fval_e}\" />"; } break; } } return $get_inputs; }
/** * Display control for selecting 'match field' value. * @param $value Default value. */ function display_match_field($value) { // Generate an array of possible values. $match_field = array('none' => 'None'); $q_str = "SELECT `ID`, `name` FROM `ProfilesDesc` WHERE `type` != '0' ORDER BY `order` ASC"; $res = db_res($q_str); while ($row = mysql_fetch_array($res)) { $fname = get_field_name($row); $field_groups[$fname]['count']++; if ($field_groups[$fname]['count'] == 1) { $match_field[$fname] = $fname; } } // Display values. echo "<td><select name=\"match_f\">\n"; foreach ($match_field as $key => $val) { if ($key == $value) { $selected = 'selected'; } else { $selected = ''; } echo "<option value=\"{$key}\" {$selected}>{$val}</option>\n"; } echo "</select></td></tr>\n"; }
function get_column_display_config(&$HTTP_VARS, $show_owner_column, $show_action_column, $show_interest_column) { $v_column_display_config_rs = get_s_item_listing_column_conf_rs($HTTP_VARS['s_item_type_group'], $HTTP_VARS['s_item_type']); if ($HTTP_VARS['mode'] == 'printable') { $v_column_display_config_rs =& filter_for_printable_list($v_column_display_config_rs); } if ($HTTP_VARS['attr_match'] != 'category' && strlen($HTTP_VARS['attribute_type']) > 0) { // Now we have to merge in search terms, and add them after the 'title' column_id $v_column_display_config_rs =& merge_display_column_config_arrays($v_column_display_config_rs, array(array(column_type => 's_attribute_type', s_attribute_type => $HTTP_VARS['attribute_type'], attribute_val => $HTTP_VARS['attribute_val'], lookup_attribute_val => $HTTP_VARS['lookup_attribute_val'], attr_match => $HTTP_VARS['attr_match'], attr_update_on => $HTTP_VARS['attr_update_on'], orderby_support_ind => 'Y', attr_update_on_days => $HTTP_VARS['attr_update_on_days'], search_attribute_ind => ifempty($HTTP_VARS['search_list'], $HTTP_VARS['attribute_list'])))); } // need to add status_comment to listing if search for status comment enabled. if (strlen($HTTP_VARS['status_comment']) > 0) { $v_column_display_config_rs =& merge_display_column_config_arrays($v_column_display_config_rs, array(array(column_type => 's_field_type', s_field_type => 'STATUSCMNT'))); } if (strlen($HTTP_VARS['rating']) > 0) { $v_column_display_config_rs =& merge_display_column_config_arrays($v_column_display_config_rs, array(array(column_type => 's_field_type', s_field_type => 'RATING'))); } for ($i = 0; $i < count($v_column_display_config_rs); $i++) { $v_column_display_config_rs[$i]['include_in_listing'] = TRUE; if ($v_column_display_config_rs[$i]['column_type'] == 's_attribute_type') { $v_attribute_type_r = fetch_cached_attribute_type_r($v_column_display_config_rs[$i]['s_attribute_type']); if (is_array($v_attribute_type_r)) { if (strlen($HTTP_VARS['s_item_type']) > 0) { $v_column_display_config_rs[$i]['prompt'] = ifempty(fetch_s_item_type_attr_prompt($HTTP_VARS['s_item_type'], $v_column_display_config_rs[$i]['s_attribute_type']), $v_attribute_type_r['prompt']); } else { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], $v_attribute_type_r['prompt']); } // record whether the s_attribute_type is a lookup attribute_type for use while generating the page. if ($v_attribute_type_r['lookup_attribute_ind'] == 'Y') { $v_column_display_config_rs[$i]['lookup_attribute_ind'] = 'Y'; if (strlen($v_column_display_config_rs[$i]['lookup_attribute_val']) == 0 && strlen($v_column_display_config_rs[$i]['attribute_val']) > 0) { $v_column_display_config_rs[$i]['lookup_attribute_val'] = $v_column_display_config_rs[$i]['attribute_val']; $v_column_display_config_rs[$i]['attribute_val'] = NULL; } } else { if ($v_attribute_type_r['multi_attribute_ind'] == 'Y') { $v_column_display_config_rs[$i]['multi_attribute_ind'] = 'Y'; } } if ($v_column_display_config_rs[$i]['orderby_support_ind'] === 'Y') { if ($v_column_display_config_rs[$i]['orderby_datatype'] != 'numeric' && $v_attribute_type_r['input_type'] == 'number') { $v_column_display_config_rs[$i]['orderby_datatype'] = 'numeric'; } } $v_column_display_config_rs[$i]['fieldname'] = get_field_name($v_column_display_config_rs[$i]['s_attribute_type']); // by default we won't include, unless the following is true $v_column_display_config_rs[$i]['include_in_listing'] = FALSE; // TODO - revise to get rid of this reverse logic!!!! if ($v_column_display_config_rs[$i]['search_attribute_ind'] != 'y' || $v_column_display_config_rs[$i]['item_listing_conf_ind'] == 'Y' || $v_column_display_config_rs[$i]['attr_match'] != 'exact' || get_opendb_config_var('listings', 'show_exact_match_search_columns') !== FALSE) { $v_column_display_config_rs[$i]['include_in_listing'] = TRUE; } } else { $v_column_display_config_rs[$i]['include_in_listing'] = FALSE; } } else { if ($v_column_display_config_rs[$i]['column_type'] == 's_field_type') { if ($v_column_display_config_rs[$i]['s_field_type'] == 'RATING') { $v_column_display_config_rs[$i]['s_attribute_type'] = 'S_RATING'; $v_attribute_type_r = fetch_cached_attribute_type_r($v_column_display_config_rs[$i]['s_attribute_type']); $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], $v_attribute_type_r['prompt']); $v_column_display_config_rs[$i]['fieldname'] = 'rating'; $v_column_display_config_rs[$i]['orderby_support_ind'] = 'N'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'ITEM_ID') { $v_column_display_config_rs[$i]['s_attribute_type'] = 'S_ITEM_ID'; $v_attribute_type_r = fetch_cached_attribute_type_r($v_column_display_config_rs[$i]['s_attribute_type']); $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], $v_attribute_type_r['prompt']); $v_column_display_config_rs[$i]['fieldname'] = 'item_id'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'CATEGORY') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('category')); $v_column_display_config_rs[$i]['fieldname'] = 'category'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'STATUSTYPE') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('status')); $v_column_display_config_rs[$i]['fieldname'] = 's_status_type'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'STATUSCMNT') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('status_comment')); $v_column_display_config_rs[$i]['fieldname'] = 'statuscmnt'; $v_column_display_config_rs[$i]['orderby_support_ind'] = 'N'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'TITLE') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('title')); $v_column_display_config_rs[$i]['fieldname'] = 'title'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'ITEMTYPE') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('type')); $v_column_display_config_rs[$i]['fieldname'] = 's_item_type'; } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'OWNER') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('owner')); $v_column_display_config_rs[$i]['fieldname'] = 'owner_id'; if (!$show_owner_column) { $v_column_display_config_rs[$i]['include_in_listing'] = FALSE; } } else { if ($v_column_display_config_rs[$i]['s_field_type'] == 'INTEREST') { if ($show_interest_column) { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('interest')); $v_column_display_config_rs[$i]['fieldname'] = 'interest'; } } } } } } } } } } } else { if ($v_column_display_config_rs[$i]['column_type'] == 'action_links') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('action')); $v_column_display_config_rs[$i]['fieldname'] = 'action_links'; $v_column_display_config_rs[$i]['orderby_support_ind'] = 'N'; if (!$show_action_column) { $v_column_display_config_rs[$i]['include_in_listing'] = FALSE; } } else { if (get_opendb_config_var('borrow', 'enable') !== FALSE && $v_column_display_config_rs[$i]['column_type'] == 'borrow_status') { $v_column_display_config_rs[$i]['prompt'] = ifempty($v_column_display_config_rs[$i]['override_prompt'], get_opendb_lang_var('borrow_status')); $v_column_display_config_rs[$i]['fieldname'] = 'borrow_status'; $v_column_display_config_rs[$i]['orderby_support_ind'] = 'N'; } } } } } return $v_column_display_config_rs; }
function print_row_search_daterange($arr, $val = "", $class = "", $section_hide = 0) { $out = print_row_search_daterange_en($arr, $val, $class); return print_row_search_content(get_field_name($arr), $out, $arr['search_hide'], $class, $section_hide, $arr['namedisp']); }
/** * The $site_plugin_attributes_r will consist of array entries, each identified by a * alphakey. The value may in fact be another array and this has to be handled * appropriately. */ function get_expanded_and_mapped_site_plugin_item_variables_r($site_type, $s_item_type, $site_item_attributes_r) { $query = "SELECT variable, s_attribute_type, lookup_attribute_val_restrict_ind " . "FROM s_site_plugin_s_attribute_type_map " . "WHERE site_type = '" . $site_type . "' "; $query .= "AND (s_item_type = '*' OR s_item_type = '" . $s_item_type . "') AND "; $query .= "(s_item_type_group = '*' "; $item_type_group_arr = fetch_item_type_groups_for_item_type_r($s_item_type); if (is_array($item_type_group_arr)) { $query .= "OR s_item_type_group IN (" . format_sql_in_clause($item_type_group_arr) . ")) "; } else { $query .= ") "; } $query .= "ORDER BY variable, s_attribute_type"; $new_attributes_r = array(); // cache this, so we can check if lookup_attribute_val_restrict_ind = 'Y' $lookup_attribute_val_restrict_ind = array(); $mapped_attributes_r = array(); $results = db_query($query); if ($results && db_num_rows($results) > 0) { $variable = NULL; while ($attribute_type_map_r = db_fetch_assoc($results)) { $value = NULL; $variable = $attribute_type_map_r['variable']; if (isset($site_item_attributes_r[$variable])) { $value = $site_item_attributes_r[$variable]; // at least one direct mapping - title should not be flagged - as there is requirement for multiple mappings if ($variable != 'title') { $mapped_attributes_r[] = $variable; } } $key = strtolower($attribute_type_map_r['s_attribute_type']); if ($value !== NULL) { if (isset($new_attributes_r[$key])) { if (!is_array($new_attributes_r[$key])) { $new_attributes_r[$key] = array($new_attributes_r[$key]); } if (is_array($value)) { $new_attributes_r[$key] = array_merge($new_attributes_r[$key], $value); } else { $new_attributes_r[$key][] = $value; } } else { $new_attributes_r[$key] = $value; } } if ($attribute_type_map_r['lookup_attribute_val_restrict_ind'] == 'Y') { $lookup_attribute_val_restrict_ind_r[$key] = 'Y'; } } db_free_result($results); } // now for any variables that do not have a mapping, add them to the $new_attributes_r reset($site_item_attributes_r); while (list($key, $value) = @each($site_item_attributes_r)) { $key = strtolower($key); if (isset($new_attributes_r[$key])) { $oldValue = NULL; // we want the direct mapping attributes first. if (is_array($new_attributes_r[$key])) { $oldValue = $new_attributes_r[$key]; } else { $oldValue[] = $new_attributes_r[$key]; } unset($new_attributes_r[$key]); if (is_array($value)) { $new_attributes_r[$key] = $value; } else { $new_attributes_r[$key][] = $value; } while (list(, $value) = each($oldValue)) { if (!in_array($value, $new_attributes_r[$key])) { $new_attributes_r[$key][] = $value; } } } else { if (!in_array($key, $mapped_attributes_r)) { $new_attributes_r[$key] = $value; } } } $site_item_attributes_r = NULL; // now we need to check to see if any lookup mappings exist for each // of the attribute values, and update the $value's appropriately. reset($new_attributes_r); while (list($key, $value) = @each($new_attributes_r)) { // temporary UPPER so we can work with actual s_attribute_type records in database $s_attribute_type = strtoupper($key); if (is_lookup_attribute_type($s_attribute_type)) { $values_r = NULL; // if a lookup attribute type, we want to make sure that the $value's // are all arrays anyway, so lets do that check each time. if (is_array($value)) { $values_r = $value; } else { $values_r[] = $value; } $results = fetch_site_plugin_s_attribute_type_lookup_map_rs($site_type, $s_attribute_type); if ($results) { $found_entries_r = array(); $new_values_r = array(); while ($lookup_map_r = db_fetch_assoc($results)) { for ($i = 0; $i < count($values_r); $i++) { if (strcasecmp($values_r[$i], $lookup_map_r['value']) === 0) { $found_entries_r[] = $values_r[$i]; if (!in_array($lookup_map_r['lookup_attribute_val'], $new_values_r)) { $new_values_r[] = $lookup_map_r['lookup_attribute_val']; } } } } db_free_result($results); // now process all back into $values_r for ($i = 0; $i < count($values_r); $i++) { if (!in_array($values_r[$i], $found_entries_r) && !in_array($values_r[$i], $new_values_r)) { $new_values_r[] = $values_r[$i]; } } $values_r = $new_values_r; } //if($results) // now reassign back. $site_item_attributes_r[strtolower($s_attribute_type)] = $values_r; } else { // the next process prefers arrays to deal with, even if single element $site_item_attributes_r[strtolower($s_attribute_type)] = $value; } } // // now that we have expanded mappings, we need to map to s_item_attribute_type order number mappings // $new_attributes_r = $site_item_attributes_r; $site_item_attributes_r = NULL; // now we want to expand the $new_attributes_r, so we have a set of // variables that include the order_no $fieldname type format. $results = fetch_item_attribute_type_rs($s_item_type, NULL, 's_attribute_type'); if ($results) { // this will be set if array encountered, but not lookup value. $processing_s_attribute_type = FALSE; while ($attribute_type_r = db_fetch_assoc($results)) { $variable = strtolower($attribute_type_r['s_attribute_type']); if (isset($new_attributes_r[$variable])) { $fieldname = get_field_name($attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']); if (is_not_empty_array($new_attributes_r[$variable])) { // TODO: Consider adding values not found in the lookup table to the s_attribute_type_lookup. if (is_lookup_attribute_type($attribute_type_r['s_attribute_type'])) { $lookup_attribute_val_restrict_ind = $lookup_attribute_val_restrict_ind_r[strtolower($attribute_type_r['s_attribute_type'])]; // here is where we want some sanity checking of the options $value_r = $new_attributes_r[$variable]; $lookup_value_r = array(); for ($i = 0; $i < count($value_r); $i++) { $raw_value = trim($value_r[$i]); if (strlen($raw_value) > 0) { $value = fetch_attribute_type_lookup_value($attribute_type_r['s_attribute_type'], $raw_value); if ($value !== FALSE) { $lookup_value_r[] = $value; } else { if ($lookup_attribute_val_restrict_ind != 'Y') { // do not include if restricted to lookup values $lookup_value_r[] = $raw_value; } } } } $site_item_attributes_r[$fieldname] = array_unique($lookup_value_r); } else { // This indicates we have a repeated s_attribute_type, and so should act appropriately. if ($processing_s_attribute_type != NULL && $attribute_type_r['s_attribute_type'] == $processing_s_attribute_type) { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable][0]; // remove it array_splice($new_attributes_r[$variable], 0, 1); } else { if (count($new_attributes_r[$variable]) > 1) { // this is the first occurence of the s_attribute_type, so lets see if its repeated at least once. if (is_numeric(fetch_s_item_attribute_type_next_order_no($s_item_type, $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']))) { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable][0]; // remove it array_splice($new_attributes_r[$variable], 0, 1); $processing_s_attribute_type = $attribute_type_r['s_attribute_type']; } else { // otherwise just copy the whole thing. $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable]; unset($new_attributes_r[$variable]); } } else { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable][0]; unset($new_attributes_r[$variable]); } } } } else { if (!is_array($new_attributes_r[$variable])) { $site_item_attributes_r[$fieldname] = $new_attributes_r[$variable]; unset($new_attributes_r[$variable]); } } } else { if ($attribute_type_r['s_field_type'] == 'TITLE' && isset($new_attributes_r['title'])) { // in case developer forgot to setup title mapping. $fieldname = get_field_name($attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']); $site_item_attributes_r[$fieldname] = $new_attributes_r['title']; } } } //while db_free_result($results); } return $site_item_attributes_r; }
function get_row_export_column_form(&$exportPlugin, $HTTP_VARS) { global $PHP_SELF; $buffer .= "\n<form method=\"POST\" action=\"{$PHP_SELF}\">"; $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"export\">"; $buffer .= "\n<input type=\"hidden\" name=\"owner_id\" value=\"" . $HTTP_VARS['owner_id'] . "\">"; $buffer .= "\n<input type=\"hidden\" name=\"s_item_type\" value=\"" . $HTTP_VARS['s_item_type'] . "\">"; $buffer .= "\n<input type=\"hidden\" name=\"plugin\" value=\"" . $HTTP_VARS['plugin'] . "\">"; $buffer .= "\n<ul class=\"checkboxGridOptionsVertical\">"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[item_id]\" value=\"Y\">" . get_opendb_lang_var('item_id') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[instance_no]\" value=\"Y\">" . get_opendb_lang_var('instance_no') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[owner_id]\" value=\"Y\">" . get_opendb_lang_var('owner_id') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[item_id]\" value=\"Y\"" . (strlen($HTTP_VARS['owner_id']) == 0 ? ' CHECKED' : '') . ">" . get_opendb_lang_var('item_id') . "</li>"; $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[s_item_type]\" value=\"Y\">" . get_opendb_lang_var('s_item_type') . "</li>"; if (strlen($HTTP_VARS['s_item_type']) > 0) { $results = fetch_item_attribute_type_rs($HTTP_VARS['s_item_type']); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // Only legal s_field_type's - ignore ITEM_ID!!! if (strlen($item_attribute_type_r['s_field_type']) == 0 || $item_attribute_type_r['s_field_type'] == 'CATEGORY' || $item_attribute_type_r['s_field_type'] == 'TITLE' || $item_attribute_type_r['s_field_type'] == 'DURATION' || $item_attribute_type_r['s_field_type'] == 'STATUSTYPE' || $item_attribute_type_r['s_field_type'] == 'STATUSCMNT' || $item_attribute_type_r['s_field_type'] == 'IMAGE') { $buffer .= '<li><input type="checkbox" class="checkbox" name="export_columns[' . get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']) . ']" value="Y"'; // work out what columns to have checked by default. if ($item_attribute_type_r['s_field_type'] == 'TITLE' || $item_attribute_type_r['s_field_type'] == 'IMAGE' || strlen($item_attribute_type_r['s_field_type']) == 0 && strcasecmp(ifempty($item_attribute_type_r['display_type'], $item_attribute_type_r['input_type']), "hidden") !== 0) { $buffer .= ' CHECKED'; } $buffer .= '>' . $item_attribute_type_r['prompt'] . "</li>"; } } db_free_result($results); } } else { $buffer .= "\n<li><input type=\"checkbox\" class=\"checkbox\" name=\"export_columns[title]\" value=\"Y\">" . get_opendb_lang_var('title') . "</li>"; } if (method_exists($exportPlugin, 'prompt_header') || method_exists($exportPlugin, 'data_header')) { $buffer .= "\n<li id=\"include-header\"><input type=\"checkbox\" class=\"checkbox\" name=\"include_header\" value=\"Y\" CHECKED>" . get_opendb_lang_var('include_header') . "</li>"; } $buffer .= "</ul>"; $buffer .= "\n<ul class=\"actionButtons\">"; $buffer .= "\n<li><input type=\"button\" class=\"button\" value=\"" . get_opendb_lang_var('check_all') . "\" onClick=\"setCheckboxes(this.form, 'export_columns', true);\"></li>" . "\n<li><input type=\"button\" class=\"button\" value=\"" . get_opendb_lang_var('uncheck_all') . "\" onClick=\"setCheckboxes(this.form, 'export_columns', false);\"></li>" . "\n<li><input type=\"reset\" class=\"reset\" value=\"" . get_opendb_lang_var('reset') . "\"></li>" . "\n<li class=\"submitButton\"><input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('export_items') . "\"></li>" . "</ul>"; $buffer .= '</form>'; return $buffer; }
/** */ function get_row_column_mappings_table($s_item_type, $owner_id, $header_row, $field_column_r, $field_default_r, $field_initcap_r) { $buffer = "\n<table>"; $buffer .= "\n<tr class=\"navbar\"><th></th>" . "<th>" . get_opendb_lang_var('field') . "</th>" . "<th>" . get_opendb_lang_var('default') . "</th>" . "<th> " . get_opendb_lang_var('initcap') . "</th></tr>"; // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r['s_item_type'])) { for ($i = 0; $i < count($header_row); $i++) { if ($header_row[$i] == 's_item_type' || $header_row[$i] == get_opendb_lang_var('s_item_type')) { $field_column_r['s_item_type'] = $i; break; } } } // If your data includes the item_type, then specify the column, so we // can ignore records that are not of the chosen item_type. $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . get_opendb_lang_var('s_item_type') . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[s_item_type]", $header_row, $field_column_r['s_item_type']) . "</td>" . "<td class=\"data defaultColumn\"> </td>" . "<td class=\"data initcapColumn\"> </td>" . "</tr>"; // --------- Now the main input fields start.... $results = fetch_item_attribute_type_rs($s_item_type); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // purely readonly if ($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') { $lookup_results = fetch_newitem_status_type_rs(); $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname], FALSE); // do not include 'None' option $initcap_field = NULL; // No initcap for these types of fields. } else { if ($item_attribute_type_r['input_type'] !== "textarea" && $item_attribute_type_r['input_type'] !== "url") { // Check if any lookup values for this field. $lookup_results = fetch_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], 'order_no, value ASC'); if ($lookup_results) { $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname]); $initcap_field = NULL; // No initcap for these types of fields. } else { //use normal input field. if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') { $item_attribute_type_r['multi_attribute_ind'] = 'N'; } $default_field = get_item_input_field("field_default[{$fieldname}]", $item_attribute_type_r, NULL, $field_default_r[$fieldname], FALSE); if ($item_attribute_type_r['input_type'] === 'text') { $initcap_field = get_input_field("field_initcap[{$fieldname}]", NULL, NULL, "checkbox(true,false,)", "N", ifempty($field_initcap_r[$fieldname], get_opendb_config_var('import', 'row_import_default_initcap_checked') ? "true" : "false"), FALSE); } else { //Only for text fields. $initcap_field = NULL; } } } else { $field = NULL; $default_field = NULL; $initcap_field = NULL; } } // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r[$fieldname])) { for ($i = 0; $i < count($header_row); $i++) { // A direct export from CSV Export, so lets match the columns for you. if ($header_row[$i] == $fieldname || $header_row[$i] == $item_attribute_type_r['prompt'] || $item_attribute_type_r['s_field_type'] == 'CATEGORY' && $header_row[$i] == 'Genre') { $field_column_r[$fieldname] = $i; break; } } } $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . $item_attribute_type_r['prompt'] . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[{$fieldname}]", $header_row, $field_column_r[$fieldname]) . "</td>" . "<td class=\"data defaultColumn\">" . $default_field . "</td>" . "<td class=\"data initcapColumn\">" . $initcap_field . "</td>" . "</tr>"; } //if($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') } //while db_free_result($results); } //if($results) $buffer .= "\n</table>"; return $buffer; }
function get_item_form_row($op, $item_r, $item_attribute_type_r, $old_value, $new_value) { if ($item_attribute_type_r['s_field_type'] == 'TITLE') { $fieldname = 'title'; } else { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); } $is_multi_value = is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type']); $refresh_field = FALSE; // Hidden cannot be involved in a refresh operation directly, but refreshed hidden fields, will still be updated. if (strcasecmp($item_attribute_type_r['input_type'], 'hidden') !== 0 && $old_value !== FALSE && (is_not_empty_array($new_value) || !is_array($new_value) && strlen($new_value) > 0) && is_value_refreshed($item_attribute_type_r['s_attribute_type'], $new_value, $old_value) && (is_not_empty_array($old_value) || !is_array($old_value) && strlen($old_value) > 0)) { $refresh_field = TRUE; $new_value = get_array_for_value($new_value); } if ($refresh_field && count($new_value) > 0 || is_array($new_value) && !$is_multi_value) { // ------------- // REFRESH FIELD // ------------- // If we are doing a complete refresh block, and display_type is set to // hidden, overwrite to display it. if ($item_attribute_type_r['display_type'] == 'hidden') { $item_attribute_type_r['display_type'] = 'display(%value%)'; $item_attribute_type_r['display_type_arg1'] = '%value%'; } $field .= "<ul class=\"tabMenu\" id=\"{$fieldname}-tab-menu\">"; if (!$is_multi_value) { $new_value = deduplicate_array($new_value, $old_value); $count = count($new_value) - 1; } else { $count = 0; } $key = array_keys($new_value); for ($i = 0; $i <= $count; $i++) { is_numeric($key[$i]) ? $label_description = "" : ($label_description = " : {$key[$i]}"); $field .= "<li id=\"menu-{$fieldname}_new{$i}\"" . ($i == 0 ? " class=\"first activeTab\"" : "") . ">\n\t\t\t\t\t<label for=\"menu-{$fieldname}_new{$i}-cbox\">" . $item_attribute_type_r['prompt'] . "{$label_description}</label>" . "<input type=\"radio\" class=\"radio\" name=\"" . $fieldname . "\" id=\"menu-{$fieldname}_new{$i}-cbox\" value=\"new{$i}\" onclick=\"return activateTab('{$fieldname}_new{$i}', '{$fieldname}-tab-menu', '{$fieldname}-tab-content');\"" . ($i == 0 ? " CHECKED" : "") . "></li>"; } if ($refresh_field) { $field .= "<li id=\"menu-{$fieldname}_old\" >\n\t\t\t\t<label for=\"menu-{$fieldname}_old-cbox\">" . get_opendb_lang_var('old_prompt', 'prompt', $item_attribute_type_r['prompt']) . "</label>" . "<input type=\"radio\" class=\"radio\" id=\"menu-{$fieldname}_old-cbox\" name=\"" . $fieldname . "\" value=\"old\" onclick=\"return activateTab('{$fieldname}_old', '{$fieldname}-tab-menu', '{$fieldname}-tab-content');\"></li>"; } $field .= "</ul>"; $field .= "<div class=\"tabContentContainer\" id=\"{$fieldname}-tab-content\">"; for ($i = 0; $i <= $count; $i++) { if ($is_multi_value) { $value = $new_value; } else { $value = $new_value[$key[$i]]; } $field .= "<div class=\"tabContent" . ($i > 0 ? "Hidden" : "") . "\" id=\"{$fieldname}_new{$i}\">" . get_item_input_field($fieldname . "_new{$i}", $item_attribute_type_r, $item_r, $value, FALSE) . "</div>"; } if ($refresh_field) { $field .= "<div class=\"tabContentHidden\" id=\"{$fieldname}_old\">" . get_item_input_field($fieldname . "_old", $item_attribute_type_r, $item_r, $old_value, FALSE) . "</div>"; } $field .= "</div>"; $prompt_mask = NULL; if ($refresh_field) { $prompt_mask = theme_image('rs.gif', get_opendb_lang_var('refreshed')) . "%prompt%"; } return format_item_data_field($item_attribute_type_r, $field, $prompt_mask, NULL); // field mask } else { // not a choose attribute if (is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) { // if new_value is empty! if (is_empty_or_not_array($new_value)) { if ($old_value !== FALSE) { $value = $old_value; } else { $value = NULL; } } else { $value =& $new_value; } return get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value); } else { $value = ifempty($new_value, $old_value === FALSE ? NULL : $old_value); // If this is an edit operation - the value must be NOT NULL // for some widgets to work properly. if ($op != 'new' && $op != 'site' && $value === NULL) { $value = ''; } return get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value); } } }
function move_down($ID, $res) { // Make int from ID $ID = (int) $ID; // Collect fields and determine which of them are group $cnt = 0; $total_rows = mysql_num_rows($res); while ($row = mysql_fetch_array($res)) { $rows[$cnt] = $row; $fname = get_field_name($row); $rows[$cnt]['db_name'] = $fname; $field_groups[$fname]['count']++; if ($row['ID'] == $ID) { $field_index = $cnt; } $cnt++; } // Number of fields in current group $src_group_fields_num = $field_groups[$rows[$field_index]['db_name']]['count']; // Number of fields in destination group $dest_group_fields_num = $field_groups[$rows[$field_index + 1]['db_name']]['count']; if ($field_index == $total_rows - 1) { return false; } // Get the order of the given field. $src_jp = $rows[$field_index]['join_page']; $src_id = $rows[$field_index]['ID']; // Get the order of the field preceding the given one. $dest_jp = $rows[$field_index + 1]['join_page']; $dest_id = $rows[$field_index + 1]['ID']; // This is for prevent group intersection if ($src_group_fields_num > 1) { $src_group_char = 'G'; } else { $src_group_char = $rows[$field_index]['group_mark'] == '' ? ' ' : $rows[$field_index]['group_mark']; } if ($dest_group_fields_num > 1) { $dest_group_char = 'G'; } else { $dest_group_char = $rows[$field_index + 1]['group_mark'] == '' ? ' ' : $rows[$field_index + 1]['group_mark']; } if ($src_group_char . $dest_group_char == 'GG' && $rows[$field_index]['db_name'] == $rows[$field_index + 1]['db_name']) { $src_group_char = $rows[$field_index]['group_mark'] == '' ? ' ' : $rows[$field_index]['group_mark']; $dest_group_char = $rows[$field_index + 1]['group_mark'] == '' ? ' ' : $rows[$field_index + 1]['group_mark']; } switch ($src_group_char . $dest_group_char) { case 'GG': $border_info['first_start'] = $field_index - $src_group_fields_num + 1; $border_info['first_end'] = $field_index; $border_info['second_start'] = $field_index + 1; $border_info['second_end'] = $field_index + $dest_group_fields_num; swap_groups_jp($rows, $border_info); break; case 'Gb': $border_info['first_start'] = $field_index - $src_group_fields_num + 1; $border_info['first_end'] = $field_index; $border_info['second_start'] = $field_index + 1; // Determine index of last field in the row $row_end_index = $field_index + 2; while ($rows[$row_end_index]['group_mark'] != 'e' && $rows[$row_end_index]['group_mark'] != '') { $row_end_index++; } if ($rows[$row_end_index]['group_mark'] == '') { $row_end_index--; } $border_info['second_end'] = $row_end_index; swap_groups_jp($rows, $border_info); break; case 'eG': // Determine index of last field in the row $row_start_index = $field_index - 1; while ($rows[$row_start_index]['group_mark'] != 'b' && $rows[$row_start_index]['group_mark'] != '') { $row_start_index--; } if ($rows[$row_start_index]['group_mark'] == '') { $row_start_index++; } $border_info['first_start'] = $row_start_index; $border_info['first_end'] = $field_index; $border_info['second_start'] = $field_index + 1; $border_info['second_end'] = $field_index + $dest_group_fields_num; swap_groups_jp($rows, $border_info); break; case 'G ': // Move lower field up $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$field_index - $src_group_fields_num + 1]['join_page'] . " WHERE `ID` = {$dest_id}"; db_res($query_str); for ($i = $field_index - $src_group_fields_num + 1; $i <= $field_index; $i++) { // Change join page of the current field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$i + 1]['join_page'] . " WHERE `ID` = " . $rows[$i]['ID']; db_res($query_str); } break; case ' G': // Move upper field down $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$field_index + $dest_group_fields_num]['join_page'] . " WHERE `ID` = {$src_id}"; db_res($query_str); for ($i = $field_index + 1; $i <= $field_index + $dest_group_fields_num; $i++) { // Change join page of the current field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$i - 1]['join_page'] . " WHERE `ID` = " . $rows[$i]['ID']; db_res($query_str); } break; case ' b': // Determine index of last field in the row $row_end_index = $field_index + 2; while ($rows[$row_end_index]['group_mark'] != 'e' && $rows[$row_end_index]['group_mark'] != '') { $row_end_index++; } if ($rows[$row_end_index]['group_mark'] == '') { $row_end_index--; } // Move upper field down $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$row_end_index]['join_page'] . " WHERE `ID` = {$src_id}"; db_res($query_str); for ($i = $field_index + 1; $i <= $row_end_index; $i++) { // Change join page of the current field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$i - 1]['join_page'] . " WHERE `ID` = " . $rows[$i]['ID']; db_res($query_str); } break; case 'bc': // Change join page for the given field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$dest_jp}, `group_mark` = 'c' WHERE `ID` = {$src_id}"; db_res($query_str); // Change join page for the following field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$src_jp}, `group_mark` = 'b' WHERE `ID` = {$dest_id}"; db_res($query_str); break; case 'be': // Change join page for the given field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$dest_jp}, `group_mark` = 'e' WHERE `ID` = {$src_id}"; db_res($query_str); // Change join page for the following field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$src_jp}, `group_mark` = 'b' WHERE `ID` = {$dest_id}"; db_res($query_str); break; case 'ce': // Change join page for the given field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$dest_jp}, `group_mark` = 'e' WHERE `ID` = {$src_id}"; db_res($query_str); // Change join page for the following field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$src_jp}, `group_mark` = 'c' WHERE `ID` = {$dest_id}"; db_res($query_str); break; case 'e ': // Determine index of last field in the row $row_start_index = $field_index - 1; while ($rows[$row_start_index]['group_mark'] != 'b' && $rows[$row_start_index]['group_mark'] != '') { $row_start_index--; } if ($rows[$row_start_index]['group_mark'] == '') { $row_start_index++; } // Move lower field up $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$row_start_index]['join_page'] . " WHERE `ID` = {$dest_id}"; db_res($query_str); for ($i = $row_start_index; $i <= $field_index; $i++) { // Change join page of the current field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = " . $rows[$i + 1]['join_page'] . " WHERE `ID` = " . $rows[$i]['ID']; db_res($query_str); } break; case ' ': case 'cc': // Change join page for the given field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$dest_jp} WHERE `ID` = {$src_id}"; db_res($query_str); // Change join page for the following field. $query_str = "UPDATE `ProfilesDesc` SET `join_page` = {$src_jp} WHERE `ID` = {$dest_id}"; db_res($query_str); } return true; }
/** * match profiles * return number ( 0-100 ) in percent, how match this profiles */ function match_profiles($Member, $Profile) { $fields = array(); $extras = array(); $match_fields = array(); $match_types = array(); $match_extras = array(); $i = 0; $res = db_res("SELECT `name`, `match_field`, `extra`, `match_type`, `match_extra` FROM `ProfilesDesc` WHERE `match_type` <> '' AND `match_type` <> 'none'"); while ($arr = mysql_fetch_array($res)) { $fields[$i] = get_field_name($arr); $extras[$i] = $arr['extra']; $match_fields[$i] = $arr['match_field']; $match_types[$i] = $arr['match_type']; $match_extras[$i] = $arr['match_extra']; $i++; } foreach ($match_fields as $n => $m_field) { $m_field = trim($m_field); if (!strlen($m_field)) { continue; } if (!$n) { $sql_add_m .= " {$m_field}"; $sql_add_p .= " {$fields[$n]}"; } else { $sql_add_m .= ", {$m_field}"; $sql_add_p .= ", {$fields[$n]}"; } } $arr_m = db_arr("SELECT {$sql_add_p} FROM Profiles WHERE ID = {$Member}"); $arr_p = db_arr("SELECT {$sql_add_m} FROM Profiles WHERE ID = {$Profile}"); if (!$arr_m || !$arr_p) { return 0; } $ret = 0; foreach ($match_fields as $n => $m_field) { switch ($match_types[$n]) { case "enum": case "enum_ref": if ($arr_m[$fields[$n]] == $arr_p[$match_fields[$n]]) { $ret += $match_extras[$n]; } break; case "set": $vals = preg_split("/[,\\']+/", $extras[$n], -1, PREG_SPLIT_NO_EMPTY); $vals_m = preg_split("/[,\\']+/", $arr_m[$fields[$n]], -1, PREG_SPLIT_NO_EMPTY); $vals_p = preg_split("/[,\\']+/", $arr_p[$match_fields[$n]], -1, PREG_SPLIT_NO_EMPTY); $count = count($vals); $count_m = count($vals_m); $count_p = count($vals_p); if ($count_p + $count_m > 0) { $per = $match_extras[$n] / max($count_p, $count_m); foreach ($vals as $key => $val) { if (strlen(strstr($arr_m[$fields[$n]], $val)) > 0 && strlen(strstr($arr_p[$match_fields[$n]], $val)) > 0) { $ret += $per; } } } break; case "daterange": $rg = split("-", $arr_m[$fields[$n]]); $age = age($arr_p[$match_fields[$n]]); if ($age >= $rg[0] && $age <= $rg[1]) { $ret += $match_extras[$n]; } break; } } return (int) $ret; }
function showProfileFields($aFields) { global $p_arr; global $site; $rd = 1; $first_row = 1; $aRedundantFields = array(); $ret = ''; foreach ($aFields as $arrpd) { $fname = get_input_name($arrpd); $sRealFName = get_field_name($arrpd); if (!in_array($sRealFName, $aRedundantFields)) { if ($arrpd['get_value_db']) { $funcbody = $arrpd['get_value_db']; $func = create_function('$arg0', $funcbody); $p_arr[$fname] = $func($p_arr); } if (!strlen($p_arr[$fname])) { continue; } //if ( !strlen($p_arr[$fname]) ) $p_arr[$fname] = $p_arr[$fname]; $not_first_row = 0; switch ($arrpd['type']) { case 'set': // set of checkboxes $ret .= print_row_set($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%"); break; case 'rb': // radio buttons $ret .= print_row_radio_button($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%"); break; case 'r': // reference to array for combo box if ($fname == 'Country') { $imagecode = '<img src="' . ($site['flags'] . strtolower($p_arr[$fname])) . '.gif" alt="flag" />'; } else { $imagecode = ''; } $ret .= print_row_ref($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%", 0, '', $imagecode); break; case '0': // divider $ret .= print_row_delim($first_row, $arrpd, "panel", 2); $not_first_row = 1; $first_row = 1; break; case 'e': // enum combo box $ret .= print_row_enum($first_row, $arrpd, $p_arr[$fname], "table", '', $rd, 2, "50%"); break; case 'en': // enum combo box with numbers $ret .= print_row_enum_n($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%"); break; case 'eny': // enum combo box with years $ret .= print_row_enum_years($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%", '', $sRealFName); $aRedundantFields[] = $sRealFName; break; case 'date': $ret .= print_row_date($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%", '', $sRealFName); break; case 'a': // memo $p_arr[$fname] = process_line_output($p_arr[$fname]); if (strlen($p_arr[$fname])) { $ret .= print_row_area($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%"); } break; case 'c': // input box $p_arr[$fname] = process_line_output($p_arr[$fname]); if (strlen($p_arr[$fname])) { if ('HomePage' == $fname) { $p_arr[$fname] = '<a href="http://' . $p_arr[$fname] . '">' . $p_arr[$fname] . '</a>'; } $ret .= print_row_edit($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%"); } break; case 'p': // input box password $p_arr[$fname] = process_line_output($p_arr[$fname]); $ret .= print_row_pwd($first_row, $arrpd, $p_arr[$fname], "table", $rd, 2, "50%"); break; default: $not_first_row = 1; } if (!$not_first_row && $first_row == 1) { $first_row = 0; } } } return $ret; }
/** */ function __getItemHTTPVars(&$itemObj) { $attribute_type_rs = $this->__getItemTypeAttribs($itemObj->getItemType()); if (is_array($attribute_type_rs)) { // this will be set if array encountered, but not lookup value. $processing_s_attribute_type = FALSE; $new_attributes_rs = $itemObj->getAttributes(); reset($attribute_type_rs); while (list(, $attribute_type_r) = each($attribute_type_rs)) { if ($attribute_type_r['s_field_type'] != 'DURATION' && $attribute_type_r['s_field_type'] != 'TITLE' && $attribute_type_r['s_field_type'] != 'STATUSTYPE' && $attribute_type_r['s_field_type'] != 'STATUSCMNT' && $attribute_type_r['s_field_type'] != 'ITEM_ID') { $fieldname = get_field_name($attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']); if (isset($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { // TODO: Consider adding values not found in the lookup table to the s_attribute_type_lookup. if ($attribute_type_r['lookup_attribute_ind'] == 'Y') { // reset $value_r = NULL; // here is where we want some sanity checking of the options if (is_not_empty_array($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { $value_r = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } else { $value_r[] = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } $lookup_value_r = array(); for ($i = 0; $i < count($value_r); $i++) { $raw_value = trim($value_r[$i]); if (strlen($raw_value) > 0) { $value = fetch_attribute_type_lookup_value($attribute_type_r['s_attribute_type'], $raw_value); if ($value !== FALSE) { $lookup_value_r[] = $value; } else { $lookup_value_r[] = $raw_value; } } } $item_attributes_rs[$fieldname] = $lookup_value_r; } else { if (is_not_empty_array($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { // This indicates we have a repeated s_attribute_type, and so should act appropriately. if ($processing_s_attribute_type != NULL && $attribute_type_r['s_attribute_type'] == $processing_s_attribute_type) { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']][0]; array_splice($new_attributes_rs[$attribute_type_r['s_attribute_type']], 0, 1); } else { if (count($new_attributes_rs[$attribute_type_r['s_attribute_type']]) > 1) { // this is the first occurence of the s_attribute_type, so lets see if its repeated at least once. if (is_numeric(fetch_s_item_attribute_type_next_order_no($itemObj->getItemType(), $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']))) { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']][0]; array_splice($new_attributes_rs[$attribute_type_r['s_attribute_type']], 0, 1); $processing_s_attribute_type = $attribute_type_r['s_attribute_type']; } else { // otherwise just copy the whole thing. $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } } else { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']][0]; } } } else { if (!is_array($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } } } } } else { // instance class if (strcasecmp(get_class($itemObj), 'ItemInstance') === 0) { if ($attribute_type_r['s_field_type'] == 'DURATION' && is_numeric($itemObj->getBorrowDuration())) { $item_attributes_rs['borrow_duration'] = $itemObj->getBorrowDuration(); } else { if ($attribute_type_r['s_field_type'] == 'STATUSTYPE') { $item_attributes_rs['s_status_type'] = $itemObj->getStatusType(); } else { if ($attribute_type_r['s_field_type'] == 'STATUSCMNT' && strlen($itemObj->getStatusComment()) > 0) { $item_attributes_rs['status_comment'] = $itemObj->getStatusComment(); } } } } else { if ($attribute_type_r['s_field_type'] == 'TITLE') { $item_attributes_rs['title'] = $itemObj->getTitle(); } } } } //while return $item_attributes_rs; } else { return FALSE; } }
/** * page code function */ function PageCompPageMainCode() { global $en_ziploc; global $_page_cont; global $_ni; global $w_ex; global $member_sex; global $logged; global $search_start_age; global $search_end_age; $gl_search_start_age = (int) $search_start_age; $gl_search_end_age = (int) $search_end_age; if ($logged['member']) { //$arr_sex = db_arr("SELECT Sex FROM Profiles WHERE ID = ".(int)$_COOKIE['memberID']); $member_sex = getSex($_COOKIE['memberID']); //$arr_sex['Sex']; } else { $member_sex = 'male'; } $ret = ""; // Get LookingFor profile type $default_looking_for = ''; if (strlen($_GET['LookingFor'])) { $default_looking_for = $_GET['LookingFor']; } elseif ($fname == 'LookingFor') { switch ($member_sex) { case 'male': $default_looking_for = "female"; break; case 'female': $default_looking_for = "male"; break; } } $respd = db_res("SELECT * FROM `ProfilesDesc` WHERE `search_type` <> 'none' ORDER BY `search_order` ASC"); while ($arrpd = mysql_fetch_array($respd)) { $fname = get_field_name($arrpd); if ($fname == "Sex" && !$_GET['LookingFor']) { $arrpd['search_default'] = $member_sex; } if ($fname == 'LookingFor' && strlen($default_looking_for)) { $arrpd['search_default'] = $default_looking_for; } $section_hide = 0; switch ($arrpd['search_type']) { case 'radio': $ret .= print_row_search_radio($arrpd, $arrpd['search_default'], "table", $javascript, $section_hide); break; case 'list': $ret .= print_row_search_list($arrpd, $arrpd['search_default'], "text", $section_hide); break; case 'check': $ret .= print_row_search_check($arrpd, $arrpd['search_default'], "text", $section_hide); break; case 'check_set': $ret .= print_row_search_check_set($arrpd, $arrpd['search_default'], "text", "", $section_hide); break; case 'daterange': $ret .= print_row_search_daterange($arrpd, $arrpd['search_default'], "text", $section_hide); break; case 'text': $ret .= print_row_search_text($arrpd, $arrpd['search_default'], "text", $section_hide); break; } } return $ret; }
function send_signup_info_to_admin($HTTP_VARS, &$errors) { global $PHP_SELF; $role_r = fetch_role_r($HTTP_VARS['user_role']); $user_info_lines = get_opendb_lang_var('userid') . ": " . $HTTP_VARS['user_id'] . "\n" . get_opendb_lang_var('fullname') . ": " . $HTTP_VARS['fullname'] . "\n" . get_opendb_lang_var('user_role') . ": " . $role_r['description'] . "\n" . get_opendb_lang_var('user_theme') . ": " . $HTTP_VARS['uid_theme'] . "\n" . get_opendb_lang_var('email') . ": " . $HTTP_VARS['email_addr']; $addr_results = fetch_address_type_rs(TRUE); if ($addr_results) { while ($address_type_r = db_fetch_assoc($addr_results)) { $address_type = strtolower($address_type_r['s_address_type']); $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'update', TRUE); if ($attr_results) { while ($addr_attribute_type_r = db_fetch_assoc($attr_results)) { $fieldname = get_field_name($addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']); // may have to change this if statement, if fieldname will contain array, instead of scalar value if (is_not_empty_array($HTTP_VARS[$address_type][$fieldname]) || !is_array($HTTP_VARS[$address_type][$fieldname]) && strlen($HTTP_VARS[$address_type][$fieldname]) > 0) { if (is_not_empty_array($HTTP_VARS[$address_type][$fieldname])) { $value = ''; for ($i = 0; $i < count($HTTP_VARS[$address_type][$fieldname]); $i++) { if (strlen($value) > 0) { $value .= ','; } $value .= $HTTP_VARS[$address_type][$fieldname][$i]; } } else { $value = $HTTP_VARS[$address_type][$fieldname]; } $user_info_lines .= "\n" . $addr_attribute_type_r['prompt'] . ": " . $value; } } db_free_result($attr_results); } //if($attr_results) } db_free_result($addr_results); } //if($addr_results) $activate_url = get_site_url() . 'user_admin.php?op=activate&user_id=' . $HTTP_VARS['user_id']; $delete_url = get_site_url() . 'user_admin.php?op=delete&user_id=' . $HTTP_VARS['user_id']; $message = get_opendb_lang_var('new_account_email', array('admin_name' => get_opendb_lang_var('site_administrator', 'site', get_opendb_config_var('site', 'title')), 'user_info' => $user_info_lines, 'site' => get_opendb_config_var('site', 'title'), 'activate_url' => $activate_url, 'delete_url' => $delete_url)); return send_email_to_site_admins(PERM_ADMIN_CREATE_USER, $HTTP_VARS['email_addr'], get_opendb_lang_var('new_account'), $message, $errors); }
function handleImport($include_header_row, $s_item_type) { // skip the header row if appropriate. if ($this->importPlugin->is_header_row() !== TRUE || $include_header_row !== TRUE) { $this->importPlugin->read_header($this->fileHandler, $this->_error); } while (!$this->fileHandler->isEof() && $this->itemImportHandler->isError() != TRUE && ($read_row_r = $this->importPlugin->read_row($this->fileHandler, $this->_error)) !== FALSE) { // ensure we have a array that is not empty, or empty except for first element, which is empty. // Either no s_item_type restriction applies, or the s_item_type column is the same as // the current s_item_type we are processing. if (is_not_empty_array($read_row_r) && (count($read_row_r) > 1 || strlen($read_row_r[0]) > 0) && (!is_numeric($this->field_column_r['s_item_type']) || strlen($read_row_r[$this->field_column_r['s_item_type']]) == 0 || strcasecmp($read_row_r[$this->field_column_r['s_item_type']], $s_item_type) === 0)) { $this->itemImportHandler->startItem($s_item_type); // Now do the title. $title_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'TITLE'); $title = $this->get_field_value(get_field_name($title_attr_type_r['s_attribute_type'], $title_attr_type_r['order_no']), NULL, $read_row_r); $this->itemImportHandler->setTitle($title); $results = fetch_item_attribute_type_rs($s_item_type, NULL, FALSE); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // these field types are references to item_instance values, and not true attribute types. if ($item_attribute_type_r['s_field_type'] != 'TITLE' && $item_attribute_type_r['s_field_type'] != 'STATUSTYPE' && $item_attribute_type_r['s_field_type'] != 'STATUSCMNT' && $item_attribute_type_r['s_field_type'] != 'DURATION' && $item_attribute_type_r['s_field_type'] != 'ITEM_ID') { $value = $this->get_field_value(get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']), $item_attribute_type_r['s_attribute_type'], $read_row_r); if (strlen($value) > 0) { if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') { // row based are comma delimited. $values_r = trim_explode(',', $value); } else { $values_r = $value; } $this->itemImportHandler->addAttribute($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no'], $values_r); } //if(strlen($value)>0) } } db_free_result($results); } //if($results) $status_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'STATUSTYPE'); $s_status_type = $this->get_field_value(get_field_name($status_attr_type_r['s_attribute_type'], $status_attr_type_r['order_no']), $status_attr_type_r['s_attribute_type'], $read_row_r); $status_cmnt_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'STATUSCMNT'); $status_comment = $this->get_field_value(get_field_name($status_cmnt_attr_type_r['s_attribute_type'], $status_cmnt_attr_type_r['order_no']), $status_cmnt_attr_type_r['s_attribute_type'], $read_row_r); $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($s_item_type, 'DURATION'); $borrow_duration = $this->get_field_value(get_field_name($duration_attr_type_r['s_attribute_type'], $duration_attr_type_r['order_no']), $duration_attr_type_r['s_attribute_type'], $read_row_r); $this->itemImportHandler->startItemInstance(); $this->itemImportHandler->setInstanceStatusType($s_status_type); $this->itemImportHandler->setInstanceStatusComment($status_comment); $this->itemImportHandler->setInstanceBorrowDuration($borrow_duration); $this->itemImportHandler->endItemInstance(); $this->itemImportHandler->endItem(); } } if ($this->itemImportHandler->isError()) { // copy the first error in $itemImportHandlerErrors =& $this->itemImportHandler->getRawErrors(); if (is_array($itemImportHandlerErrors)) { $this->_error = $itemImportHandlerErrors[0]['error']; } return FALSE; } else { return TRUE; } }