From 53880f8002642369a57b3b584eee194983c5e76a Mon Sep 17 00:00:00 2001 From: e107steved Date: Sun, 17 Aug 2008 11:54:40 +0000 Subject: [PATCH] Add admin logging to poll --- e107_plugins/poll/admin_config.php | 24 ++++++++++++------ e107_plugins/poll/languages/admin/English.php | 14 ++++++++--- e107_plugins/poll/plugin.xml | 3 ++- e107_plugins/poll/poll_class.php | 25 +++++++++++-------- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/e107_plugins/poll/admin_config.php b/e107_plugins/poll/admin_config.php index e3f25372a..ae6d3e814 100644 --- a/e107_plugins/poll/admin_config.php +++ b/e107_plugins/poll/admin_config.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/poll/admin_config.php,v $ -| $Revision: 1.5 $ -| $Date: 2008-08-16 16:25:45 $ +| $Revision: 1.6 $ +| $Date: 2008-08-17 11:54:38 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -31,10 +31,12 @@ require_once(e_PLUGIN."poll/poll_class.php"); require_once(e_HANDLER."form_handler.php"); require_once(e_HANDLER."userclass_class.php"); -if(isset($_POST)) { +if(isset($_POST)) +{ $_POST = strip_if_magic($_POST); } + $rs = new form; $poll = new poll; @@ -42,7 +44,8 @@ if (isset($_POST['reset'])) { unset($poll_id, $_POST['poll_title'], $_POST['poll_option'], $_POST['activate'], $_POST['multipleChoice'], $_POST['showResults'], $_POST['startday'], $_POST['startmonth'], $_POST['startyear'], $_POST['endday'], $_POST['endmonth'], $_POST['endyear']); define("RESET", TRUE); -} else if (e_QUERY) +} +elseif (e_QUERY) { list($action, $id) = explode(".", e_QUERY); define("POLLACTION", $action); @@ -54,14 +57,16 @@ else define("POLLID", FALSE); } -if ($action == "delete") { + +if ($action == "delete") +{ $message = $poll->delete_poll($id); unset($poll_id, $_POST['poll_title'], $_POST['poll_option'], $_POST['activate']); } + if (isset($_POST['submit'])) { - if($_POST['poll_title']) { $message = $poll -> submit_poll(); @@ -73,10 +78,12 @@ if (isset($_POST['submit'])) } } + if (POLLACTION == "edit" && !$_POST['preview'] && !$_POST['submit']) { - if ($sql->db_Select("polls", "*", "poll_id=".POLLID)) { + if ($sql->db_Select("polls", "*", "poll_id=".POLLID)) + { $row = $sql->db_Fetch(); extract($row); @@ -130,7 +137,8 @@ if (isset($message)) $text = "
"; -if ($poll_total = $sql->db_Select("polls", "*", "poll_type=1")) { +if ($poll_total = $sql->db_Select("polls", "*", "poll_type=1")) +{ $text .= "
ID diff --git a/e107_plugins/poll/languages/admin/English.php b/e107_plugins/poll/languages/admin/English.php index f99703103..230ae6e8b 100644 --- a/e107_plugins/poll/languages/admin/English.php +++ b/e107_plugins/poll/languages/admin/English.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/poll/languages/admin/English.php,v $ -| $Revision: 1.1 $ -| $Date: 2008-08-16 16:25:45 $ +| $Revision: 1.2 $ +| $Date: 2008-08-17 11:54:40 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -25,6 +25,7 @@ define("POLL_ADLAN04", "The poll plugin has been successfully installed. To add define("POLL_ADLAN05", "Main Poll: "); define("POLL_ADLAN06", "Forum Thread: "); define("POLL_ADLAN07", "Type"); +define("POLL_ADLAN08", "Poll deleted"); define("POLLAN_MENU_CAPTION", "Poll"); @@ -73,8 +74,15 @@ define("POLLAN_41", "This poll is restricted to members only"); define("POLLAN_42", "This poll is restricted to administrators only"); define("POLLAN_43", "You do not have the required permissions to vote in this poll"); define("POLLAN_44", "Delete this poll?"); -define("POLLAN_45", "Poll successfully updated"); */ +define("POLLAN_45", "Poll successfully updated"); define("POLLAN_46", "Field(s) left blank"); +// Log messages +define('LAN_AL_POLL_01','Poll deleted'); +define('LAN_AL_POLL_02','Poll updated'); +define('LAN_AL_POLL_03','Poll added'); +define('LAN_AL_POLL_04',''); +define('LAN_AL_POLL_05',''); + ?> \ No newline at end of file diff --git a/e107_plugins/poll/plugin.xml b/e107_plugins/poll/plugin.xml index 90fb8ba42..0914752fc 100644 --- a/e107_plugins/poll/plugin.xml +++ b/e107_plugins/poll/plugin.xml @@ -1,6 +1,6 @@ - + POLL_ADLAN01 2.0 Steve Dunstan (jalist) @@ -9,6 +9,7 @@ 0.8 true poll + poll admin_config.php diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index 4a061ff54..fae08aa06 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -11,15 +11,14 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/poll/poll_class.php,v $ -| $Revision: 1.10 $ -| $Date: 2008-08-04 20:31:49 $ +| $Revision: 1.11 $ +| $Date: 2008-08-17 11:54:39 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } -@include_once(e_PLUGIN."poll/languages/".e_LANGUAGE.".php"); -@include_once(e_PLUGIN."poll/languages/English.php"); +@include_lan(e_PLUGIN."poll/languages/".e_LANGUAGE.".php"); define("POLLCLASS", TRUE); define("POLL_MODE_COOKIE", 0); define("POLL_MODE_IP", 1); @@ -33,14 +32,15 @@ class poll function delete_poll($existing) { - global $sql; + global $sql, $admin_log; if ($sql -> db_Delete("polls", " poll_id='".intval($existing)."' ")) { if(function_exists("admin_purge_related")) { admin_purge_related("poll", $existing); } - return "Poll deleted."; + $admin_log->log_event('POLL_01',POLL_ADLAN08.': '.$existing,''); + return POLL_ADLAN08; } } @@ -52,7 +52,7 @@ class poll $mode = 2 :: poll is forum poll */ - global $tp, $sql; + global $tp, $sql, $admin_log; $poll_title = $tp->toDB($_POST['poll_title']); $poll_comment= $tp -> toDB($_POST['poll_comment']); @@ -74,7 +74,7 @@ class poll $sql -> db_Update("polls", "poll_title='{$poll_title}', poll_options='{$poll_options}', poll_comment='{$poll_comment}', - poll_type=$mode, + poll_type={$mode}, poll_allow_multiple={$multipleChoice}, poll_result_type={$showResults}, poll_vote_userclass={$pollUserclass}, @@ -97,9 +97,11 @@ class poll $sql -> db_Update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' "); } + $admin_log->log_event('POLL_02','ID: '.POLLID.' - '.$poll_title,''); $message = POLLAN_45; - } else { - + } + else + { $votes = ""; for($a=1; $a<=count($_POST['poll_option']); $a++) { @@ -117,7 +119,8 @@ class poll $sql -> db_Update("polls", "poll_end_datestamp='".time()."', poll_vote_userclass='255' WHERE poll_id=".$deacpoll['poll_id']); } } - $sql -> db_Insert("polls", "'0', ".time().", ".intval($active_start).", ".intval($active_end).", ".ADMINID.", '$poll_title', '$poll_options', '$votes', '', '1', '".$tp -> toDB($poll_comment)."', '".intval($multipleChoice)."', '".intval($showResults)."', '".intval($pollUserclass)."', '".intval($storageMethod)."'"); + $ret = $sql -> db_Insert("polls", "'0', ".time().", ".intval($active_start).", ".intval($active_end).", ".ADMINID.", '{$poll_title}', '{$poll_options}', '{$votes}', '', '1', '".$tp -> toDB($poll_comment)."', '".intval($multipleChoice)."', '".intval($showResults)."', '".intval($pollUserclass)."', '".intval($storageMethod)."'"); + $admin_log->log_event('POLL_03','ID: '.$ret.' - '.$poll_title,''); // Intentionally only log admin-entered polls } else {