function update_queue($id, $title, $descr, $tags, $slug, $authorID, $position, $old_position, $parent, $qLength, $pnum = 0) { global $wpdb; PhotoQHelper::debug('enter update_queue()'); if ($position < 1) { $position = 1; } if ($position > $qLength) { $position = $qLength; } if ($position < $old_position) { $wpdb->query("UPDATE {$this->QUEUE_TABLE} SET q_position = q_position+1 WHERE q_position >= '{$position}' AND q_position < '{$old_position}'"); } if ($position > $old_position) { $wpdb->query("UPDATE {$this->QUEUE_TABLE} SET q_position = q_position-1 WHERE q_position <= '{$position}' AND q_position > '{$old_position}'"); } $wpdb->query("UPDATE {$this->QUEUE_TABLE} SET q_position = '{$position}', q_title = '{$title}', q_descr = '{$descr}', q_tags = '{$tags}', q_slug = '{$slug}', q_fk_author_id = '{$authorID}', q_edited = 1 WHERE q_img_id = {$id}"); /*update categories*/ //$q_id = preg_replace('/\./','_',$id); //. in post vars become _ // Now it's category time! // Check to make sure there is a category, if not just set it to some default $post_categories = $_POST['post_category'][$id]; if (!$post_categories) { $post_categories[] = $this->_oc->getValue('qPostDefaultCat'); } $post_categories = apply_filters('category_save_pre', PhotoQHelper::arrayAttributeEscape($post_categories)); // First the old categories $old_categories = $this->_db->getCategoriesByImgId($id); // Delete any? foreach ($old_categories as $old_cat) { if (!is_array($post_categories) || !in_array($old_cat, $post_categories)) { // If a category was there before but isn't now $wpdb->query("DELETE FROM {$this->QCAT_TABLE} WHERE q_fk_img_id = {$id} AND category_id = {$old_cat} LIMIT 1"); } } // Add any? if (is_array($post_categories)) { foreach ($post_categories as $new_cat) { if (!in_array($new_cat, $old_categories)) { $this->_db->insertCategory($id, $new_cat); } } } //handle the fields $results = $wpdb->get_results("\n\t\tSELECT\n\t\t*\n\t\tFROM\n\t\t{$this->QFIELDS_TABLE}\n\t\tWHERE 1"); if ($results) { foreach ($results as $field_entry) { $update_meta_query = "UPDATE {$this->QUEUEMETA_TABLE} SET q_field_value = '" . $_POST["{$field_entry->q_field_name}"][$pnum] . "'\n\t\t\t\tWHERE q_fk_img_id = {$id} && q_fk_field_id = {$field_entry->q_field_id}"; $wpdb->query($update_meta_query); } } PhotoQHelper::debug('leave update_queue()'); }