print_submit_row($vbphrase['photoplog_save']); } else { if ($_REQUEST['do'] == 'review') { print_submit_row($vbphrase['photoplog_approve'], '', 2, $vbphrase['photoplog_go_back']); } } } } if ($_REQUEST['do'] == 'doedit') { $vbulletin->input->clean_array_gpc('p', array('catid' => TYPE_UINT, 'photoplog_category' => TYPE_ARRAY)); $photoplog_catid = $vbulletin->GPC['catid']; $photoplog_category = $vbulletin->GPC['photoplog_category']; $photoplog_category_parentid = intval(trim(strval($photoplog_category['parentid']))); $photoplog_list_children = array(); $photoplog_list_relatives = array(); photoplog_relative_list($photoplog_list_children, $photoplog_list_relatives); $photoplog_list_relatives_array = $photoplog_list_relatives[$photoplog_catid]; if ($photoplog_catid == $photoplog_category_parentid || in_array($photoplog_category_parentid, $photoplog_list_relatives_array)) { print_stop_message('generic_error_x', $vbphrase['photoplog_bad_parent']); } $photoplog_category_info = $db->query_first("SELECT parentid\r\n\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_categories\r\n\t\tWHERE catid = " . intval($photoplog_catid) . "\r\n\t"); $photoplog_original_parentid = 0; if (!$photoplog_category_info) { print_stop_message(no_results_matched_your_query); } else { $photoplog_original_parentid = intval($photoplog_category_info['parentid']); } $photoplog_category_title = trim(strval($photoplog_category['title'])); $photoplog_category_description = trim(strval($photoplog_category['description'])); $photoplog_category_displayorder = intval(trim(strval($photoplog_category['displayorder']))); $photoplog_category_options = $photoplog_category['options'];
function photoplog_move_custom_fields($catid, $old_parentid, $new_parentid) { global $vbulletin; $list_immediate_children = array(); $list_all_children = array(); photoplog_relative_list($list_immediate_children, $list_all_children); $child_list = $list_all_children[$catid]; $catid = intval($catid); $family_list = array_merge(array($catid), $child_list); foreach ($family_list as $family_catid) { $fields = $vbulletin->db->query_read("SELECT parentid,groupid\r\n\t\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\t\tWHERE catid = " . intval($family_catid) . "\r\n\t\t\tAND inherited = 1\r\n\t\t\tAND parentid > -1\r\n\t\t"); while ($field = $vbulletin->db->fetch_array($fields)) { $field_parentid = intval($field['parentid']); if (!in_array($family_catid, $list_all_children[$field_parentid])) { $family_child_list = array($family_catid); if (isset($list_all_children[$family_catid])) { $family_child_list = array_merge($family_child_list, $list_all_children[$family_catid]); } $group_id = intval($field['groupid']); $vbulletin->db->query_write("DELETE FROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\t\t\t\tWHERE catid IN (" . implode(",", $family_child_list) . ")\r\n\t\t\t\t\tAND inherited = 1\r\n\t\t\t\t\tAND parentid > -1\r\n\t\t\t\t\tAND groupid = " . intval($group_id) . "\r\n\t\t\t\t"); } } $vbulletin->db->free_result($fields); } $substitute_displayorders = array(); $displayorder_query = $vbulletin->db->query_read("SELECT catid, MAX(displayorder) AS mdo\r\n\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\tWHERE catid IN (" . implode(",", $family_list) . ")\r\n\t\tGROUP BY catid\r\n\t"); while ($displayorder_read = $vbulletin->db->fetch_array($displayorder_query)) { $displayorder_read['catid'] = intval($displayorder_read['catid']); $substitute_displayorders[$displayorder_read['catid']] = intval($displayorder_read['mdo']); } $vbulletin->db->free_result($displayorder_query); $parents = $vbulletin->db->query_read("SELECT groupid,\r\n\t\t\tparentid, displayorder, hidden, active\r\n\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\tWHERE catid = " . intval($new_parentid) . "\r\n\t\tAND inherited != 0\r\n\t\tAND parentid > -1\r\n\t"); while ($parent = $vbulletin->db->fetch_array($parents)) { $parent_group_id = intval($parent['groupid']); $parent_parentid = intval($parent['parentid']); $vbulletin->db->query_write("DELETE FROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\t\tWHERE catid IN (" . implode(",", $family_list) . ")\r\n\t\t\tAND inherited < 1\r\n\t\t\tAND parentid > -1\r\n\t\t\tAND groupid = " . intval($parent_group_id) . "\r\n\t\t"); $check_cats = $vbulletin->db->query_read("SELECT catid, COUNT(*) as cnt\r\n\t\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\t\tWHERE catid IN (" . implode(",", $family_list) . ")\r\n\t\t\tAND inherited = 1\r\n\t\t\tAND parentid > -1\r\n\t\t\tAND groupid = " . intval($parent_group_id) . "\r\n\t\t\tGROUP BY catid\r\n\t\t"); while ($check_one = $vbulletin->db->fetch_array($check_cats)) { if ($check_one['cnt'] == 0) { $vbulletin->db->query_write("DELETE FROM " . PHOTOPLOG_PREFIX . "photoplog_customfields\r\n\t\t\t\t\tWHERE catid = " . intval($check_one['catid']) . "\r\n\t\t\t\t\tAND groupid = " . intval($parent_group_id) . "\r\n\t\t\t\t"); $new_displayorder = isset($substitute_displayorders[$check_one['catid']]) ? $substitute_displayorders[$check_one['catid']] + 10 : $parent['displayorder']; photoplog_insert_custom_field($check_one['catid'], $parent_group_id, $new_displayorder, $parent['hidden'], $parent['active'], 1, 1, $parent_parentid, ''); } } $vbulletin->db->free_result($check_cats); } $vbulletin->db->free_result($parents); }