$res]; echo json_encode($result); return; } if (get_parameter('remove_source_on_database', 0)) { $res = ($is_users) ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements); $result = ['result' => $res]; echo json_encode($result); return; } if (get_parameter('update_config', 0)) { $element = (string) get_parameter('element', ''); $value = (int) get_parameter('value', 0); // Update the label value. ob_clean(); $res = false; switch ($element) { // All users has other action. case 'all_users': $res = ($value) ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]); break; default: $res = (bool) db_process_sql_update( 'tnotification_source', [$element => $value], ['id' => $source] ); break; } echo json_encode(['result' => $res]); return; } if (get_parameter('check_new_notifications', 0)) { $last_id_ui = (int) get_parameter('last_id', 0); $counters = notifications_get_counters(); if ((int) $last_id_ui === (int) $counters['last_id']) { echo json_encode(['new_notifications' => []]); return; } // If there is new messages, get the info. echo json_encode( [ 'notifications' => $counters['notifications'], 'last_id' => $counters['last_id'], 'new_notifications' => messages_get_overview( 'timestamp', 'ASC', false, true, 0, ['id_mensaje' => '>'.$last_id_ui] ), ] ); return; } // Notification table. It is just a wrapper. $table_content = new StdClass(); $table_content->data = []; $table_content->width = '100%'; $table_content->id = 'notifications-wrapper'; $table_content->class = 'databox filters'; $table_content->size['name'] = '30%'; // Print each source configuration. $table_content->data = array_map( function ($source) { return notifications_print_global_source_configuration($source); }, notifications_get_all_sources() ); html_print_table($table_content); ?>