Exemplo n.º 1
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;
 }