function jw_activity_log_prune($last_run_date) { include_once 'JwActivityLog_Actions.class.php'; include_once 'JwActivityLog_Action.class.php'; $API = new PerchAPI(1.0, 'jw_activity_log'); $Settings = $API->get('Settings'); $Actions = new JwActivityLog_Actions($API); $total_pruned = $Actions->prune_logs((int) $Settings->get('jw_activity_log_prune_time')->settingValue()); return array('result' => 'OK', 'message' => $total_pruned . ' logs pruned'); }
<?php include_once 'JwActivityLog_Actions.class.php'; include_once 'JwActivityLog_Action.class.php'; $API = new PerchAPI(1.0, 'jw_activity_log'); $Actions = new JwActivityLog_Actions($API); /** * Regions */ $API->on('region.add_item', function (PerchSystemEvent $Event) use($Actions) { $data = array(); $user = $Event->user->to_array(); $subject = $Event->subject->to_array(); $data['actionKey'] = $Event->event; $data['userAccountID'] = $user['userID']; $data['userAccountData'] = $user; $data['resourceType'] = LOG_REGION_TYPE; $data['resourceID'] = $subject['regionID']; $data['resourceTitle'] = $subject['regionKey']; $data['resourceModification'] = $subject['regionHTML']; // Save $Actions->create($data); // Debug PerchUtil::debug('Inserting new action log data:'); PerchUtil::debug($data); }); $API->on('region.publish', function (PerchSystemEvent $Event) use($Actions) { $data = array(); $user = $Event->user->to_array(); $subject = $Event->subject->to_array(); $data['actionKey'] = $Event->event;
<?php if (!$CurrentUser->has_priv('jw_activity_log')) { PerchUtil::redirect(PERCH_LOGINPATH); } // Diff library require_once '../lib/Diff.php'; require_once '../lib/Diff/Renderer/Html/SideBySide.php'; require_once '../lib/Diff/Renderer/Html/Inline.php'; $Actions = new JwActivityLog_Actions($API); $result = false; $message = false; $HTML = $API->get('HTML'); // Setup data $historical_logs = array(); $user = array(); $resource = array(); if (isset($_GET['id']) && $_GET['id'] != '') { $actionID = (int) $_GET['id']; $Action = $Actions->find($actionID); $historical_logs = $Actions->return_instances($Action->history()); $user = $Action->userData(array('userLastLogin', 'userCreated', 'userUpdated', 'roleID', 'roleSlug', 'userEnabled', 'userMasterAdmin', 'roleMasterAdmin')); $heading1 = 'View Log #' . $actionID; }
<?php if (!$CurrentUser->has_priv('jw_activity_log')) { PerchUtil::redirect(PERCH_LOGINPATH); } $HTML = $API->get('HTML'); $Form = $API->get('Form'); $Paging = $API->get('Paging'); $Paging->set_per_page(20); $Actions = new JwActivityLog_Actions($API); $filter_icons = array(); $filter_icons = $Actions->icons(); $filter_users = array(); $filter_users_opts = array(); $filter_users = $Actions->get_stored_users_unique(); if (PerchUtil::count($filter_users)) { foreach ($filter_users as $filter_user) { $filter_users_opts[] = array('label' => $filter_user['userUsername'], 'value' => $filter_user['userID']); } } $action_logs = array(); $filter = '*'; if (isset($_GET['type']) && $_GET['type']) { $filter = 'type'; $type = $_GET['type']; } if (isset($_GET['user']) && $_GET['user']) { $filter = 'user'; $userID = $_GET['user']; } switch ($filter) {