Lets you access user activities in your enterprise made through various applications.

For more information about this service, see the API Documentation

Author: Google, Inc.
Inheritance: extends Service
Beispiel #1
0
 public function testPrepare()
 {
     $this->_initSequenceTables();
     // test audit first
     $audit = new Audit();
     $audit->_ormPersist = true;
     $audit->objectClass = 'StdClass';
     $audit->persist();
     $this->assertTrue($audit->auditId > 0, 'Audit: Failed to persist');
     if ($audit->auditId > 0) {
         $audit->setPersistMode(WebVista_Model_ORM::DELETE);
         $audit->persist();
     }
     $auditValue = new AuditValue();
     $auditValue->_ormPersist = true;
     $auditValue->key = 'Key';
     $auditValue->value = 'Value';
     $auditValue->persist();
     $this->assertTrue($auditValue->auditValueId > 0, 'AuditValue: Failed to persist');
     if ($auditValue->auditValueId > 0) {
         $auditValue->setPersistMode(WebVista_Model_ORM::DELETE);
         $auditValue->persist();
     }
     if ($this->_autoLoggedIn) {
         $this->_setupAutoLogin();
     }
 }
Beispiel #2
0
 public static function logAudit($entity, $action, $description)
 {
     $audit = new Audit();
     $audit->date = date('Y-m-d');
     $audit->description = $description;
     $audit->user = Confide::user()->username;
     $audit->entity = $entity;
     $audit->action = $action;
     $audit->save();
 }
Beispiel #3
0
 public function action_logs($page = 1)
 {
     if (!$this->getAuth()->hasAccess('maccess.admin')) {
         return $this->redirectToAdmin();
     }
     $this->param_manager->setParam('method_title', [_i('Audit'), _i('Logs')]);
     if ($page < 1 || !ctype_digit((string) $page)) {
         $page = 1;
     }
     $logs = $this->audit->getPagedBy('id', 'desc', $page);
     $this->builder->createPartial('body', 'moderation/audit_log')->getParamManager()->setParams(['logs' => $logs, 'page' => $page, 'page_url' => $this->uri->create('admin/moderation/logs')]);
     return new Response($this->builder->build());
 }
Beispiel #4
0
 function addDbAuditLogEntry($action, $class, $id)
 {
     if ($class != "Audit") {
         $log = new Audit($this->w);
         $log->module = $this->w->currentModule();
         $log->submodule = $this->w->currentSubModule();
         $log->action = $this->w->currentAction();
         $log->path = $_SERVER['REQUEST_URI'];
         $log->ip = $this->w->requestIpAddress();
         $log->db_action = $action;
         $log->db_class = $class;
         $log->db_id = $id;
         $log->insert();
     }
 }
Beispiel #5
0
 public static function hookExpiredSession($sessionContents)
 {
     if (session_decode($sessionContents)) {
         if (Zend_Auth::getInstance()->hasIdentity()) {
             $identity = Zend_Auth::getInstance()->getIdentity();
             $audit = new Audit();
             $audit->objectClass = 'Logout';
             $audit->userId = (int) $identity->personId;
             $audit->message = __('user') . ': ' . $identity->username . ' ' . __('was logged out due to session expiration');
             $audit->dateTime = date('Y-m-d H:i:s');
             $audit->_ormPersist = true;
             $audit->persist();
         }
     }
 }
 public function testUserLoggedOut()
 {
     $this->_objects = GeneralAlertHandler::generateUserLoggedOut();
     $objects = array();
     $db = Zend_Registry::get('dbAdapter');
     $audit = new Audit();
     $audit->_ormPersist = true;
     $audit->objectClass = 'Logout';
     $audit->objectId = 0;
     $audit->dateTime = date('Y-m-d H:i:s');
     $audit->type = WebVista_Model_ORM::REPLACE;
     $audit->userId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $audit->persist();
     $objects['audit'] = $audit;
     $clinicalNote = new ClinicalNote();
     $clinicalNote->personId = $this->_objects['person']->person_id;
     $clinicalNote->visitId = 100;
     $clinicalNote->clinicalNoteDefinitionId = 19;
     $clinicalNote->dateTime = date('Y-m-d H:i:s');
     $clinicalNote->eSignatureId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $clinicalNote->persist();
     $objects['clinicalNote'] = $clinicalNote;
     $eSign = new ESignature();
     // cleanup all generalAlerts
     $db->query('DELETE FROM ' . $eSign->_table);
     $eSign->dateTime = date('Y-m-d H:i:s');
     $eSign->signedDateTime = '0000-00-00 00:00:00';
     $eSign->signingUserId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $eSign->objectId = $clinicalNote->clinicalNoteId;
     $eSign->objectClass = get_class($clinicalNote);
     $eSign->summary = ' **Unsigned**';
     $eSign->persist();
     $objects['eSignature'] = $eSign;
     // cleanup all generalAlerts
     $generalAlert = new GeneralAlert();
     $db->query('DELETE FROM ' . $generalAlert->_table);
     $process = Processingd::getInstance();
     $process->clearProcesses();
     $process->addProcess(new ProcessAlert());
     $process->startProcessing(false);
     $generalAlertIterator = $generalAlert->getIterator();
     $ctr = 0;
     foreach ($generalAlertIterator as $alert) {
         $objects['generalAlert' . $ctr++] = $alert;
     }
     $this->assertEquals($ctr, 1, 'No alert created even with signed items');
     $this->_cleanUpObjects($objects);
 }
Beispiel #7
0
 /**
  * @param Registry $registry
  * @return Audit
  */
 public static function getInstance($registry)
 {
     if (empty(Audit::$instance)) {
         Audit::$instance = new Audit($registry);
     }
     return Audit::$instance;
 }
Beispiel #8
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $save = $this->category->create(Input::all());
     //store the logs
     Audit::store('Settings', 'Added a new category with an id of ' . $save->id);
     return Redirect::to('/categories')->with(['flash_message' => 'Category has been saved.', 'flash_type' => 'alert-success', 'title' => 'Category list', 'categories' => $this->category->all()]);
 }
Beispiel #9
0
 private function addPlugin()
 {
     $audit = \Audit::instance();
     $this->f3->scrub($_POST);
     $this->f3->set('SESSION.flash', array());
     // process form if > 0 plugins have been selected
     if ($this->f3->exists('POST.plugins') && count($this->f3->get('POST.plugins')) > 0) {
         foreach ($this->f3->get('POST.plugins') as $package) {
             // validate plugin
             if ($this->plugins->getPackage($package) !== false) {
                 $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => '"' . $package . '" is already installed. Skipping.'));
             } else {
                 if (!($config = $this->plugins->getRemoteConfig($package))) {
                     $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => '"' . $package . '" could not be installed. (missing mytcg.json config file)'));
                 } else {
                     if (!isset($config['name']) || !isset($config['author']) || !isset($config['version']) || !isset($config['description'])) {
                         $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => '"' . $package . '" could not be installed. (invalid mytcg.json config file)'));
                     }
                 }
             }
             // process install if there are no errors
             if (count($this->f3->get('SESSION.flash')) === 0) {
                 if ($this->plugins->install($package, $this->plugins)) {
                     $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => '"' . $package . '" has been installed successfully!'));
                 } else {
                     $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => '"' . $package . '" could not be installed.'));
                 }
             }
         }
     }
 }
Beispiel #10
0
 function __construct()
 {
     parent::__construct();
     $this->user = new \DB\SQL\Mapper($this->db, 'users');
     $this->audit = \Audit::instance();
     $this->bcrypt = \BCrypt::instance();
 }
 private function audit($markerSite, $action)
 {
     Log::info("Auditing " . $markerSite->id . "for " . $action);
     $data = $this->getAuditData($markerSite);
     $data["action"] = $action;
     Audit::create($data);
 }
Beispiel #12
0
 /**
  * validate email address
  * @param string $val
  * @param string $context
  * @param bool $mx
  * @return bool
  */
 function email($val, $context = null, $mx = true)
 {
     $valid = true;
     if (!$context) {
         $context = 'error.validation.email';
     }
     if (!empty($val)) {
         if (!\Audit::instance()->email($val, false)) {
             $val = NULL;
             if (!$this->f3->exists($context . '.invalid', $errText)) {
                 $errText = 'e-mail is not valid';
             }
             $this->f3->error(400, $errText);
             $valid = false;
         } elseif ($mx && !\Audit::instance()->email($val, true)) {
             $val = NULL;
             if (!$this->f3->exists($context . '.host', $errText)) {
                 $errText = 'unknown mail mx.host';
             }
             $this->f3->error(400, $errText);
             $valid = false;
         }
     }
     if (!$valid) {
         \Flash::instance()->setKey($context, 'has-error');
     }
     return $valid;
 }
Beispiel #13
0
 private function process()
 {
     $this->f3->scrub($_POST);
     $audit = \Audit::instance();
     $this->f3->set('SESSION.flash', array());
     // validate form
     if (!preg_match("/^[\\w\\- ]{2,30}\$/", $this->f3->get('POST.name'))) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid name.'));
     }
     if (!$audit->email($this->f3->get('POST.email'), FALSE)) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid email address'));
     }
     if (!empty($this->f3->get('POST.url')) && !$audit->url($this->f3->get('POST.url'))) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Invalid URL.'));
     }
     if (empty($this->f3->get('POST.message'))) {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please include a message!'));
     }
     // honey pot
     if ($this->f3->get('POST.username') !== '') {
         $this->f3->push('SESSION.flash', array('type' => 'warning', 'msg' => 'Please do not use autofill or similar tools!'));
     }
     // if there are no errors, process the form
     if (count($this->f3->get('SESSION.flash')) === 0) {
         $this->f3->set('POST.level', $this->f3->get('member')->level + 1);
         $mailer = new Mailer();
         $message = $mailer->message()->setSubject($this->f3->get('tcgname') . ': Contact Form')->setFrom(array($this->f3->get('noreplyemail') => 'MyTCG'))->setTo(array($this->f3->get('tcgemail')))->setReplyTo(array($this->f3->get('POST.email')))->setBody(Template::instance()->render('app/templates/emails/contact.htm'), 'text/html');
         if ($mailer->send($message)) {
             $this->f3->push('SESSION.flash', array('type' => 'success', 'msg' => 'Your form has been sent. Thanks for contacting us!'));
         } else {
             $this->f3->push('SESSION.flash', array('type' => 'danger', 'msg' => 'There was a problem processing your request. Please try again or contact us for assistance!'));
         }
     }
 }
Beispiel #14
0
 static function &Instance($type = null)
 {
     static $audit = NULL;
     if (!$audit) {
         $audit = new Audit();
         $result = false;
         $result = $audit->loadBy('sessionid', session_id());
         if ($result === false) {
             $data = array('sessionid' => session_id(), 'username' => '', 'customer_id' => '');
             if (isset($_SESSION['username'])) {
                 $data['username'] = $_SESSION['username'];
             }
             if (isset($_SESSION['customer_id'])) {
                 $data['customer_id'] = $_SESSION['customer_id'];
             }
             $errors = array();
             $audit = Audit::Factory($data, $errors, 'Audit');
             $audit->save();
         }
     }
     if (isset($_SESSION['username']) && $audit->username != $_SESSION['username']) {
         $audit->username = $_SESSION['username'];
         $audit->save();
     }
     return $audit;
 }
Beispiel #15
0
 protected function _populateAudits()
 {
     $audit = new Audit();
     $db = Zend_Registry::get('dbAdapter');
     $dbSelect = $db->select()->from($audit->_table)->where("startProcessing = '0000-00-00 00:00:00'")->orWhere("endProcessing = '0000-00-00 00:00:00'");
     $this->_audits = $audit->getIterator($dbSelect);
 }
Beispiel #16
0
 protected function _createAudit($providerId, $personId, $visitId, $type)
 {
     $providerId = (int) $providerId;
     $personId = (int) $personId;
     $visitId = (int) $visitId;
     $audit = array();
     $audit['objectClass'] = 'GenericAccessAudit';
     $audit['objectId'] = $personId . ';' . $visitId;
     $audit['type'] = (int) $type;
     $audit['userId'] = $providerId;
     $audit['patientId'] = $personId;
     $values = array();
     $provider = new Provider();
     $provider->personId = $audit['userId'];
     $provider->populate();
     $values['provider'] = $provider->toArray();
     $patient = new Patient();
     $patient->personId = $personId;
     $patient->populate();
     $values['patient'] = $patient->toArray();
     $values['personId'] = $patient->personId;
     $visit = new Visit();
     $visit->visitId = $visitId;
     $visit->populate();
     $values['visit'] = $visit->toArray();
     $values['visitId'] = $visit->visitId;
     $audit['auditValues'] = $values;
     Audit::persistManualAuditArray($audit);
 }
Beispiel #17
0
 public static function setActive()
 {
     if (!\Audit::instance()->isbot()) {
         if (class_exists('\\Activity\\Models\\Actors')) {
             $actor = \Activity\Models\Actors::fetch();
             if ($actor->isExcluded()) {
                 return;
             }
         }
         if (\Dsc\System::instance()->get('input')->get('ping', null, 'int') != 1) {
             $fw = \Base::instance();
             $path = $fw->hive()['PATH'];
             switch ($path) {
                 // ignore certain paths, even if they aren't specifically pings
                 case strpos($path, '/minify/') === 0 ? true : false:
                 case "/minify/css":
                 case "/minify/js":
                     break;
                 default:
                     (new \Dsc\Mongo\Collections\Sessions())->store();
                     break;
             }
         }
     }
     \Dsc\Mongo\Collections\Sessions::throttledCleanup();
 }
Beispiel #18
0
 /**
  * validate and set a email address for this user
  * @param $email
  * @return mixed
  */
 public function set_email($email)
 {
     if (\Audit::instance()->email($email) == false) {
         // no valid email address
         $this->throwValidationError('email');
     }
     return $email;
 }
 /**
  * Records an audit trail
  *
  * @param array $desc the associtive array mapping the
  * db field names from the audit_log table to values
  */
 public function audit($desc)
 {
     $audit = Audit::from($desc);
     if (!$audit->validate()) {
         return false;
     }
     return $audit->create();
 }
Beispiel #20
0
 /**
  * Store a newly created resource in storage.
  * POST /employees
  *
  * @return Response
  */
 public function store()
 {
     //add new employee
     $employees = $this->employee->all();
     $save = $this->employee->create(Input::all());
     //store the logs
     Audit::store('Employees', 'Added a new employee with an id of ' . $save->id);
     return Redirect::route('employees.index')->with('employees', $employees)->with('title', 'Employees')->with('flash_message', 'Employee has been added')->with('flash_type', 'alert alert-success');
 }
Beispiel #21
0
 function __construct()
 {
     $f3 = Base::instance();
     $db = new DB\SQL($f3->get('db_dns') . $f3->get('db_name'), $f3->get('db_user'), $f3->get('db_pass'));
     $audit = \Audit::instance();
     $this->f3 = $f3;
     $this->db = $db;
     $this->audit = $audit;
 }
Beispiel #22
0
 /**
  * @covers Audit::getColour
  */
 public function testGetColour()
 {
     //test the error's color
     $audit = new Audit();
     $audit->action = ComponentStubGenerator::generate('AuditAction', array('name' => 'search-error'));
     $result = $audit->getColour();
     $expected = 'Red';
     $this->assertEquals($expected, $result);
 }
 public function addAudit($type, $data)
 {
     $audit = new Audit();
     $audit->user = $this->user->id;
     $audit->ip = $_SERVER['REMOTE_ADDR'];
     $audit->time = date("Y-m-d H:i:s");
     $audit->time = gmdate('Y-m-d H:i:s', strtotime($audit->time));
     $audit->type = $type;
     $audit->details = $data;
     $currentEmpId = $this->getCurrentProfileId();
     if (!empty($currentEmpId)) {
         $employee = $this->baseService->getElement('Employee', $this->getCurrentProfileId(), null, true);
         $audit->employee = $employee->first_name . " " . $employee->last_name . " [EmpId = " . $employee->employee_id . "]";
     }
     $ok = $audit->Save();
     if (!$ok) {
         LogManager::getInstance()->info("Error adding audit:" . $audit->ErrorMsg());
     }
 }
Beispiel #24
0
 public function delete_page($args)
 {
     $page_id = array_shift($args);
     if ($page = R::load('page', $page_id)) {
         $old = clone $page;
         R::trash($page);
         Audit::create($old, NULL, 'Developer deleted page from system');
     }
     $this->redirect(PACKAGE_URL);
 }
Beispiel #25
0
 /**
  * Store a newly created resource in storage.
  * POST /customers
  *
  * @return Response
  */
 public function store()
 {
     //save it
     $save = $this->customer->create(Input::all());
     //grab the customers data
     $customers = $this->customer->all();
     //store the logs
     Audit::store('Customers', 'Added new customer with an id of ' . $save->id);
     return Redirect::to('/customers')->with(['title' => 'Store Customers', 'customers' => $customers, 'flash_message' => 'Customer has been created.', 'flash_type' => 'alert-success']);
 }
Beispiel #26
0
 /**
  * Return the list of items on the main page
  *
  * @return items
  */
 protected function index()
 {
     //enabled Voice Command by default
     Session::put('VC', 'enabled');
     //get the first  most recent 10 logs
     $logs = Audit::orderBy('id', 'desc')->take(10)->get();
     $low_stocks = Ingredient::selectRaw("fposs_ingredients.name,fposs_suppliers.name as supp,\n\t\t\t\t\tfposs_suppliers.resource_person,fposs_ingredients.stocks,\n\t\t\t\t\tfposs_ingredients.alert_level,fposs_ingredients.shipment_unit")->where('stocks', '<=', 'alert_level')->leftJoin('fposs_suppliers', 'fposs_ingredients.supplier_id', '=', 'fposs_suppliers.id')->get();
     // $low_stocks = DB::table('fposs_ingredients')->where('stocks', '<', 'alert_level')->count();
     $items = $this->production_item->getCurrentProduction();
     return View::make('index')->with('title', "Flibbys Point of Sale System")->with('items', $items)->with('ingredients', $low_stocks)->with('logs', $logs);
 }
Beispiel #27
0
function audit($msg)
{
    if (defined('AUDIT') && AUDIT) {
        $db = DB::Instance();
        $debug = $db->debug;
        $db->debug = FALSE;
        $audit = Audit::Instance();
        $audit->write($msg, TRUE, microtime(TRUE) - START_TIME);
        $db->debug($debug);
    }
}
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Audit('search');
     $model->unsetAttributes();
     if (isset($_GET['Audit'])) {
         $model->attributes = $_GET['Audit'];
     }
     $dH = new DateTimeHelper();
     if (isset($_GET["Audit"]["dateTimeFrom"]) && strcmp($_GET["Audit"]["dateTimeFrom"], "") !== 0) {
         $model->dateTimeFrom = $_GET["Audit"]["dateTimeFrom"];
     } else {
         $model->dateTimeFrom = $dH->getDefaultStartRangeFilter("")->format(Yii::app()->params["dateTimeDisplayFormat"]);
     }
     if (isset($_GET["Audit"]["dateTimeTo"]) && strcmp($_GET["Audit"]["dateTimeTo"], "") !== 0) {
         $model->dateTimeTo = $_GET["Audit"]["dateTimeTo"];
     } else {
         $model->dateTimeTo = $dH->getDefaultEndRangeFilter("")->format(Yii::app()->params["dateTimeDisplayFormat"]);
     }
     $this->render('admin', array('model' => $model));
 }
Beispiel #29
0
 /**
  * Display a listing of the resource.
  * GET /audits
  *
  * @return Response
  */
 public function index()
 {
     //check the user privliges
     if (Session::has('log_access')) {
         //show the view
         $sys_logs = Audit::all();
         // $trans_logs = Audit::where('module','=','Sales')->get();
         $trans_logs = TransactionLog::all();
         return View::make('system.logs.index')->with('title', 'System Logs')->with('sys_logs', $sys_logs)->with('trans_logs', $trans_logs);
     }
     return View::make('system.errors.unauthorized')->with('title', 'Unauthorized Access');
 }
 public function processAction()
 {
     $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter'));
     $authAdapter->setTableName('user')->setIdentityColumn('username')->setCredentialColumn('password')->setIdentity($_POST['username'])->setCredential($_POST['password']);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     $audit = new Audit();
     $audit->objectClass = 'Login';
     $audit->objectId = 0;
     $data = array();
     if ($result->isValid()) {
         unset($this->_session->messages);
         $identity = $auth->getIdentity();
         $user = new User();
         $user->username = $identity;
         $user->populateWithUsername();
         Zend_Auth::getInstance()->getStorage()->write($user);
         //$this->_redirect('login/complete');
         //$this->_forward('index','main');
         $data['msg'] = __("Login successful.");
         $data['code'] = 200;
         $audit->message = __('user') . ': ' . $_POST['username'] . ' ' . __('login successful');
         $audit->userId = $user->userId;
     } else {
         $auth->clearIdentity();
         $this->_session->messages = $result->getMessages();
         //$this->_redirect('login');
         $data['err'] = __("Invalid username/password.");
         $data['code'] = 404;
         $audit->message = __('user') . ': ' . $_POST['username'] . ' ' . __('login failed due to bad password');
     }
     $audit->dateTime = date('Y-m-d H:i:s');
     $audit->_ormPersist = true;
     $audit->persist();
     header('Content-Type: application/xml;');
     $this->view->data = $data;
     $this->completeAction();
     //$this->render();
 }