Esempio n. 1
0
             $err_trgr = true;
         }
     }
 }
 $rel_main_fields_array = array();
 foreach ($get_another_data as $db_id => $rel_info) {
     if ($rel_info['is_multiple'] == 1) {
         $rel_main_fields_array[] = $rel_info['main_field'];
     }
 }
 foreach ($_POST['data'] as $post_key => $post_val) {
     if (in_array($post_key, $rel_main_fields_array)) {
         $_POST['data'][$post_key] = serialize($_POST['data'][$post_key]);
     }
 }
 $_POST['data'] = remove_empty_locations($_POST['data']);
 if ($err_trgr == false) {
     $last_user_id = $database->update($table_name, $_POST['data'], array($database->getPKID($table_name) => $record_id));
     if ($last_user_id) {
         foreach ($get_another_data as $relation) {
             if ($vars[2] == $relation['main_table'] && $relation['is_multiple'] == 1) {
                 $ids = unserialize($_POST['data'][$relation['main_field']]);
                 $database->delete($relation['main_table'] . "_" . $relation['secondary_table'], array($relation['main_table'] . '_id' => $record_id));
                 foreach ($ids as $multiple_id) {
                     $database->insert($relation['main_table'] . "_" . $relation['secondary_table'], array($relation['main_table'] . '_id' => $record_id, $relation['secondary_table'] . '_id' => $multiple_id));
                 }
             }
         }
         header("Location: " . _admin_url . "/edit/" . $table_name . "/rec:" . $record_id . "/updated");
         exit;
     }
Esempio n. 2
0
function remove_empty_locations($Array)
{
    if (is_array($Array)) {
        $new_array = array();
        foreach ($Array as $k => $v) {
            if (is_array($v)) {
                $v = remove_empty_locations($v);
                $new_array[$k] = $v;
            } elseif ($v == "") {
                unset($Array);
            } else {
                $new_array[$k] = $v;
            }
        }
        return $new_array;
    }
    return;
}
Esempio n. 3
0
             $err_trgr = true;
         }
     }
 }
 $rel_main_fields_array = array();
 foreach ($get_another_data as $db_id => $rel_info) {
     if ($rel_info['is_multiple'] == 1) {
         $rel_main_fields_array[] = $rel_info['main_field'];
     }
 }
 foreach ($_POST['data'] as $post_key => $post_val) {
     if (in_array($post_key, $rel_main_fields_array)) {
         $_POST['data'][$post_key] = serialize($_POST['data'][$post_key]);
     }
 }
 $_POST = remove_empty_locations($_POST);
 if ($err_trgr == false) {
     $last_user_id = $database->insert($table_name, $_POST['data']);
     if ($last_user_id) {
         foreach ($get_another_data as $relation) {
             if ($vars[2] == $relation['main_table'] && $relation['is_multiple'] == 1) {
                 $ids = unserialize($_POST['data'][$relation['main_field']]);
                 foreach ($ids as $multiple_id) {
                     $database->insert($relation['main_table'] . "_" . $relation['secondary_table'], array($relation['main_table'] . '_id' => $last_user_id, $relation['secondary_table'] . '_id' => $multiple_id));
                 }
             }
         }
         header("Location: " . _admin_url . "/edit/" . $table_name . "/rec:" . $last_user_id . "/saved");
         exit;
     }
 }