1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) { 9 header('location: index.php'); 10 exit; 11} 12 13$ratingconfiglib = TikiLib::lib('ratingconfig'); 14$ratinglib = TikiLib::lib('rating'); 15$access = TikiLib::lib('access'); 16 17//don't see an input "test" in the forms at include_rating.tpl 18if (isset($_REQUEST['test']) && $access->is_machine_request()) { 19 $message = $ratinglib->test_formula($_REQUEST['test'], [ 'type', 'object-id' ]); 20 21 $access->output_serialized( 22 [ 23 'valid' => empty($message), 24 'message' => $message, 25 ] 26 ); 27 exit; 28} 29 30//*** begin state-changing actions 31if (isset($_POST['create']) && ! empty($jitPost->name->text()) && $access->checkCsrf()) { 32 $id = $ratingconfiglib->create_configuration($jitPost->name->text()); 33 Feedback::success(tr('New rating configuration %0 created', '<em>' . $jitPost->name->text() . '</em>')); 34} 35 36if (isset($_POST['edit']) && $access->checkCsrf()) { 37 $ratingconfiglib->update_configuration( 38 $jitPost->config->digits(), 39 $jitPost->name->text(), 40 $jitPost->expiry->digits(), 41 $jitPost->formula->xss() 42 ); 43 Feedback::success(tr('Rating configuration updated for %0', '<em>' . $jitPost->name->text() . '</em>')); 44} 45//*** end state-changing actions 46 47$configurations = $ratingconfiglib->get_configurations(); 48 49$smarty->assign('configurations', $configurations); 50