function wh_trigger_exit($db, $table, $event, $data) { denies_with_json(); if (!in_array($event, array('update', 'refresh'))) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'invalid event type')); } if (wh_event($db, $table, $event, $data) === true) { jsonp_nocache_exit(array('status' => 'ok')); } else { jsonp_nocache_exit(array('status' => 'error')); } }
<?php require_once 'functions.php'; require_once 'crontab.php'; denies_with_json(); $req = get_param(); switch ($req['cmd']) { case 'combo2check': combobox_to_checkbox_exit($req); case 'combo2radio': combobox_to_radiobox_exit($req); case 'update_fields': update_fields_exit($req); default: jsonp_nocache_exit(array('status' => 'error', 'error' => 'unknow command.')); } function update_fields_exit($req) { $db_name = @$req['db_name']; $table_name = @$req['table_name']; $table_root = table_root($db_name, $table_name); $schema_file = "{$table_root}/schema.json"; $schema = object_read($schema_file); $listview_req = @$req['listview']; $listview = $schema['listview']; $diff1 = array_diff($listview_req, $listview); $diff2 = array_diff($listview, $listview_req); $is_same = empty($diff1) && empty($diff2); $schema['listview'] = $listview_req; $schema['fields'] = isset($req['fields']) ? $req['fields'] : null; $schema['initials'] = isset($req['initials']) ? $req['initials'] : array();