function form_category($text, $name) { global $ALBUM_DATA, $CAT_LIST, $USER_DATA, $lang_modifyalb_php, $CONFIG, $icon_array, $LINEBREAK; //check if users are allowed to move their albums if (!GALLERY_ADMIN_MODE && $CONFIG['allow_user_move_album'] == 0) { //get category name $cat_name = $lang_modifyalb_php['user_gal']; if ($ALBUM_DATA['category'] != FIRST_USER_CAT + USER_ID) { $result = cpg_db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '" . $ALBUM_DATA['category'] . "' LIMIT 1"); $cat_name = cpg_db_fetch_row($result); mysql_free_result($result); $cat_name = $cat_name['name']; } echo <<<EOT <tr> <td> {$text} </td> <td valign="top"> <em>{$cat_name}</em> <input type="hidden" name="{$name}" value="{$ALBUM_DATA['category']}" /> </td> </tr> EOT; return; } $CAT_LIST = array(); //only add 'no category' when user is admin if (GALLERY_ADMIN_MODE) { $CAT_LIST[] = array(0, $lang_modifyalb_php['no_cat']); } //add user catergory $CAT_LIST[] = array(FIRST_USER_CAT + USER_ID, $lang_modifyalb_php['my_gal']); get_cat_data(); echo <<<EOT <tr> <td> {$text} </td> <td valign="top"> {$icon_array['move']}<select name="{$name}" class="listbox"> EOT; foreach ($CAT_LIST as $category) { echo ' <option value="' . $category[0] . '"' . ($ALBUM_DATA['category'] == $category[0] ? ' selected="selected"' : '') . ($category[0] == USER_GAL_CAT ? ' disabled="disabled"' : '') . ">" . $category[1] . '</option>' . $LINEBREAK; } echo <<<EOT </select> </td> </tr> EOT; }
} return TRUE; } } } function obtener_precio_dolar() { $query = "SELECT precio_dolar from DolarHoy where id_dolar=(SELECT max(id_dolar) FROM DolarHoy)"; $result = mysql_query($query); $row = mysql_fetch_array($result); //Devuelvo el precio del dolar actual return $row[0]; } //Fin Funciones if ($formname == "categoria_modificacion") { get_cat_data($datos, $id_categoria); $grupo = get_group_opt($datos[1]); $unidades = get_units_opt($datos[4]); $scan = get_scan_opt($datos[2]); //if (mensaje != "") $mensaje = "<script type=\"text/javascript\">alert(\"$mensaje\")</script>"; $var = array("mensaje" => $mensaje, "categoria" => $datos[0], "id_categoria" => $id_categoria, "grupo" => $grupo, "scan" => $scan, "stock_minimo" => $datos[3], "unidades" => $unidades, "porcentaje" => $datos[5], "focus" => $focus); eval_html('categoria_datosmodificar.html', $var); } elseif ($formname == "categoria_datosmodificar") { if (update_categoria($mensaje, $categoria, $id_grupo, $scan, $stock_minimo, $unidad, $id_categoria, $porcentaje)) { if (mensaje != "") { $mensaje = "<script type=\"text/javascript\">alert(\"{$mensaje}\")</script>"; } } $focus = "forms[0].id_categoria"; $categoria = get_categoria_opt(0); $var = array("mensaje" => $mensaje, "categoria" => $categoria, "focus" => $focus);
function repairTree() { $tbl_mdb_names = claro_sql_get_main_tbl(); $tbl_category = $tbl_mdb_names['category']; // get list of all node $sql = " SELECT code, code_P, treePos, name, nb_childs\n FROM `" . $tbl_category . "`\n ORDER BY `treePos`"; $catList = claro_sql_query_fetch_all($sql); $newTreePos = 1; $listSize = count($catList); // foreach node check code_parent, treepos and nbchilds foreach ($catList as $cat) { $newCatList[$cat['code']] = $cat; $parentCatData = get_cat_data(get_cat_id_from_code($cat['code_P'])); if ($cat['treePos'] < $parentCatData['treePos']) { $newCatList[$cat['code']]['newCode_P'] = ' root '; $newCatList[$cat['code']]['newTreePos'] = $listSize--; } else { if (!is_null($cat['code_P']) && !get_cat_id_from_code($cat['code_P'])) { $newCatList[$cat['code']]['newCode_P'] = ' root '; $newCatList[$cat['code']]['newTreePos'] = $listSize--; } else { $newCatList[$cat['code']]['newTreePos'] = $newTreePos++; $newCatList[$cat['code']]['newNb_childs'] = countChild($cat['code']); } } } reset($newCatList); $node_moved = false; // rescan node list and update data if difference was detected. foreach ($newCatList as $cat) { if (isset($cat['newCode_P']) && $cat['code_P'] != $cat['newCode_P']) { $sql = "UPDATE `" . $tbl_category . "` " . ($cat['newCode_P'] == ' root ' ? " SET code_P = null " : " SET code_P = " . (int) $cat['newCode_P']) . " WHERE code = '" . claro_sql_escape($cat['code']) . "'"; $node_moved = true; // repair ownance but brok countchild claro_sql_query($sql); } if (isset($cat['newNb_childs']) && $cat['nb_childs'] != $cat['newNb_childs']) { $sql = "UPDATE `" . $tbl_category . "` " . " SET nb_childs = " . (int) $cat['newNb_childs'] . " WHERE code = '" . claro_sql_escape($cat['code']) . "'"; claro_sql_query($sql); } if ($cat['treePos'] != $cat['newTreePos']) { $sql = "UPDATE `" . $tbl_category . "` " . " SET treePos = " . (int) $cat['newTreePos'] . " WHERE code = '" . claro_sql_escape($cat['code']) . "'"; claro_sql_query($sql); } } if ($node_moved) { return claro_failure::set_failure('node_moved'); } else { return true; } }
function html_cat_list() { global $CONFIG, $CAT_LIST; global $lang_albmgr_php; $CAT_LIST = array(); if (USER_CAN_CREATE_ALBUMS) { $CAT_LIST[] = array(FIRST_USER_CAT + USER_ID, $lang_albmgr_php['my_gallery']); } $CAT_LIST[] = array(0, $lang_albmgr_php['no_category']); get_cat_data(); $html = $LINEBREAK; foreach ($CAT_LIST as $category) { $html .= ' <option value="' . $category[0] . '">' . $category[1] . '</option>' . $LINEBREAK; } return $html; }
// The treePos max $maxTree = search_max_tree_pos(); // The treePos of her and his childeren = max(treePos)+i $i = 1; while ($i <= $facultyEdit['nb_childs'] + 1) { $sql_TempTree = " UPDATE `" . $tbl_course_node . "`\n SET treePos=" . $maxTree . "+" . $i . "\n WHERE treePos = " . (int) $facultyEdit['treePos'] . "+" . $i . " - 1"; claro_sql_query($sql_TempTree); $i++; } // Change treePos of the faculty they have a treePos > treePos of the last child $sql_ChangeTree = " UPDATE `" . $tbl_course_node . "`\n SET treePos = treePos - " . (int) $facultyEdit['nb_childs'] . "-1\n WHERE treePos > " . (int) $treePosLastChild . " AND treePos <= " . (int) $maxTree; claro_sql_query($sql_ChangeTree); // if the father isn't root if ($_REQUEST['fatherCat'] != 'NULL') { // Search treePos of the new father $newFather = get_cat_data(get_cat_id_from_code($_REQUEST['fatherCat'])); //Ajoute a tous les treePos apres le nouveau pere le nombre d enfant + 1 de celui qu on deplace $sql_ChangeTree = " UPDATE `" . $tbl_course_node . "`\n SET treePos=treePos + " . (int) $facultyEdit['nb_childs'] . " + 1\n WHERE treePos > " . (int) $newFather['treePos'] . " and treePos <= " . (int) $maxTree; claro_sql_query($sql_ChangeTree); // the new treePos is the treePos of the new father+1 $newTree = $newFather['treePos'] + 1; } else { // The new treePos is the last treePos exist $newTree = $maxTree; } // Change the treePos of her and his childeren $i = 0; while ($i <= $facultyEdit['nb_childs']) { $sql_ChangeTree = " UPDATE `" . $tbl_course_node . "`\n SET treePos=" . $newTree . "+" . $i . "\n WHERE treePos=" . $maxTree . "+" . $i . "+1"; claro_sql_query($sql_ChangeTree); $i++;