Inheritance: extends CActiveRecord
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $this->layout = '//layouts/login';
     if (@Yii::app()->user->id) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $model = new LoginFormAdmin();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginFormAdmin'])) {
         $model->attributes = $_POST['LoginFormAdmin'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             $audit = new AuditTrail();
             $audit->user_id = Yii::app()->user->id;
             $audit->login_time = new CDbExpression('NOW()');
             $audit->user_type = 1;
             $audit->save();
             Yii::app()->user->setFlash('success', 'Welcome in the <strong>' . CHtml::encode(Yii::app()->name) . ' Admin Panel</strong>. Don\'t forget to <strong>Logout</strong> when finish!');
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     // display the login form
     $this->render('login', array('model' => $model));
 }
 public function run()
 {
     $m = new AuditTrail();
     $m->unsetAttributes();
     $m->model = get_class($this->model);
     $m->model_id = $this->model->getPrimaryKey();
     $this->renderpartial('history', array('model' => $m, 'id' => $this->id));
 }
Exemple #3
0
 public function actionAdmin()
 {
     $model = new AuditTrail('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['AuditTrail'])) {
         $model->attributes = $_GET['AuditTrail'];
     }
     $this->render('admin', array('model' => $model));
 }
Exemple #4
0
 public function logAudit($action)
 {
     $model = new AuditTrail();
     if (Yii::app()->user->id) {
         $model->user_id = Yii::app()->user->id;
     }
     $model->details = $action;
     $model->activity_group = 1;
     $model->save();
 }
 /**
  * show UI Dialog Box with history
  * @param string $model_name
  * @param int $model_id
  */
 public function actionUiDialogBox($model_name, $model_id)
 {
     $model = new AuditTrail();
     $model->unsetAttributes();
     $model->model = $model_name;
     $model->model_id = $model_id;
     //perform only autoload
     class_exists($model_name);
     //import module for translations
     Yii::setPathOfAlias($model_name . 'Module', Yii::getPathOfAlias($model_name) . '/../');
     Yii::import($model_name . 'Module.*');
     $this->renderpartial('ui_dialog', array('model' => $model, 'model_name' => $model_name, 'model_id' => $model_id));
 }
/**
 * Handle the events
 *
 * @param sfEvent $event The event being handled
 * @return bool TRUE if the audit trail for the transaction is saved sucessfully, FALSE otherwise
 */
function auditTransactionEventHandler($event)
{
    $audit_trail = new AuditTrail();
    $audit_trail->processPost($event->getParameters());
    try {
        $audit_trail->save();
    } catch (Exception $e) {
        $logger = Zend_Registry::get("logger");
        $logger->err($e->getMessage());
        return false;
    }
    return true;
}
 /**
  * @dataProvider dataProvider_Search
  */
 public function testSearch_WithValidTerms_ReturnsExpectedResults($searchTerms, $expectedKeys)
 {
     $audit = new AuditTrail();
     $audit->setAttributes($searchTerms);
     $results = $audit->search();
     $data = $results->getData();
     $expectedResults = array();
     if (!empty($expectedKeys)) {
         foreach ($expectedKeys as $key) {
             $expectedResults[] = $this->audittrail($key);
         }
     }
     $this->assertEquals($expectedResults, $data);
 }
Exemple #8
0
 public function afterDelete($event)
 {
     try {
         $username = Yii::app()->user->Name;
         $userid = Yii::app()->user->id;
     } catch (Exception $e) {
         $username = "******";
         $userid = null;
     }
     if (empty($username)) {
         $username = "******";
     }
     if (empty($userid)) {
         $userid = null;
     }
     $log = new AuditTrail();
     $log->old_value = '';
     $log->new_value = '';
     $log->action = 'DELETE';
     $log->model = get_class($this->Owner);
     $log->model_id = $this->Owner->getPrimaryKey();
     $log->field = 'N/A';
     $log->stamp = date('Y-m-d H:i:s');
     $log->user_id = $userid;
     $log->save();
     return parent::afterDelete($event);
 }
 public function actionTrack($t = "view")
 {
     $postdata = file_get_contents("php://input");
     $path = json_decode($postdata, true);
     $tracking = Setting::get('app.auditTrail') == "Enabled";
     if ($tracking != null || $tracking != true) {
         return;
     }
     if ($path['module'] == 'dev' && !in_array($path['ctrl'], ['user', 'role'])) {
         return;
     }
     if (!empty($path)) {
         AuditTrail::savePageInfo($path);
         switch ($t) {
             case "create":
                 AuditTrail::track("", "create", $path);
                 break;
             case "update":
                 AuditTrail::track("", "update", $path);
                 break;
             case "delete":
                 AuditTrail::track("", "delete", $path);
                 break;
             default:
                 AuditTrail::track("", "view", $path);
                 break;
         }
     }
 }
Exemple #10
0
 public static function getAllwodObjectTypes()
 {
     if (!self::$allwodObjectTypes) {
         $reflect = new ReflectionClass('AuditTrailObjectType');
         self::$allwodObjectTypes = $reflect->getConstants();
     }
     return self::$allwodObjectTypes;
 }
 public function loadModel($id)
 {
     $model = AuditTrail::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     //get Audit Trail
     $model_AuditTrail = new AuditTrail('search_user_only');
     $model_AuditTrail->unsetAttributes();
     // clear any default values
     if (isset($_GET['AuditTrail'])) {
         $model_AuditTrail->attributes = $_GET['AuditTrail'];
     }
     //Visitor statistics
     $model_Visitor = new Visitor('search_user_only');
     $model_Visitor->unsetAttributes();
     // clear any default values
     if (isset($_GET['Visitor'])) {
         $model_Visitor->attributes = $_GET['Visitor'];
     }
     $this->render('view', array('model' => $this->loadModel($id), 'model_profile' => $this->loadModelProfile($id), 'model_AuditTrail' => $model_AuditTrail, 'model_Visitor' => $model_Visitor));
 }
Exemple #13
0
 /**
  * generates content of widget the widget.
  * This renders the widget, if it is visible.
  */
 public function renderContent()
 {
     if ($this->visible) {
         $auditTrail = AuditTrail::model()->recently();
         $auditTrail->model = get_class($this->model);
         $auditTrail->model_id = $this->model->primaryKey;
         $columnFormat = $this->getColumnFormat();
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'audit-trail-grid', 'dataProvider' => $auditTrail->search(), 'columns' => $this->getColumnFormat()));
     }
 }
Exemple #14
0
 public function set($key, $value, User $user = null)
 {
     $receipt = null;
     $this->record[$key] = $value;
     Database::update('albums', array($key => $value), 'id=' . $this->record['id']);
     if (isset($user)) {
         $receipt = AuditTrail::createAuditTrailForChange($user, 'album', $this->record['id'], $key, $this->record[$key], $value);
     }
     return $receipt;
 }
 public function down()
 {
     if (!isset(Yii::app()->getDb()->tablePrefix)) {
         Yii::app()->getDb()->tablePrefix = '';
     }
     Yii::import('audittrail.models.AuditTrail');
     $table = AuditTrail::model()->tableName();
     $sql = "DROP TABLE `{$table}`";
     $this->execute($sql);
 }
Exemple #16
0
 /**
  * @return int unique id per request
  */
 public function getUniqueRequestId()
 {
     if (!is_null(self::$uniqueRequestId)) {
         return self::$uniqueRequestId;
     }
     $dcId = kDataCenterMgr::getCurrentDcId();
     for ($i = 0; $i < 10; ++$i) {
         $requestId = $dcId . '_' . kString::generateStringId();
         $exists = AuditTrailPeer::retrieveByRequestId($requestId);
         if (!$exists) {
             self::$uniqueRequestId = $requestId;
             return self::$uniqueRequestId;
         }
     }
     throw new kAuditTrailException('Unable to generate unique id', kAuditTrailException::UNIQUE_ID_NOT_GENERATED);
 }
<?php

//class for get the interested session holders.
require_once './global.inc.php';
verify_oauth_session_exists();
if (HttpSession::currentUser()->getOrganization()->access_level > 2) {
    $sessionId = $_POST["sessionId"];
    $orgId = $_POST["orgId"];
    $respName = $_POST["resp_name"];
    $respContact = $_POST["resp_contact"];
    $comment = $_POST["comment"];
    $idUser = $_POST["idUser"];
    $queryString = $_POST["queryString"];
    $session = new Session($_POST);
    //echo $sessionId . $orgId . $respName . $respContact;
    Session::addInterest($sessionId, $orgId, $respName, $respContact, $comment);
    $mailTakeSession = AuditTrail::takeSession('session', $sessionId, 'take session', $idUser, false);
    header("Location: sessions.php" . $queryString);
    die;
}
Exemple #18
0
 public function save($isNew = false)
 {
     $idUser = $_POST["idUser"];
     //create a new database object.
     $db = new DB();
     $data = array("title" => $db->stringify($this->title), "description" => $db->stringify($this->description), "pic_url" => $db->stringify($this->pic_url), "date" => $db->stringify($this->date), "start_time" => $db->stringify($this->start_time), "duration" => $this->numeric($this->duration), "resp_name" => $db->stringify($this->resp_name), "resp_contact" => $db->stringify($this->resp_contact), "org_id" => $this->numeric($this->org_id), "proposed_org_id" => $this->numeric($this->proposed_org_id));
     //if object is already registered and we're
     //just updating their info.
     if (!$isNew) {
         //update the row in the database
         $db->update($data, 'sessions', 'id = ' . $this->id);
     } else {
         //if the user is being registered for the first time.
         $this->id = $db->insert($data, 'sessions');
         $mailSession = AuditTrail::createSession('session', $this->id, 'add new', $idUser, false);
     }
     return true;
 }
 public function leaveTrail($action, $name = null, $value = null, $old_value = null)
 {
     $log = new AuditTrail();
     $log->old_value = $old_value;
     $log->new_value = $value;
     $log->action = $action;
     $log->model = get_class($this->getOwner());
     // Gets a plain text version of the model name
     $log->model_id = $this->getNormalizedPk();
     $log->field = $name;
     $log->stamp = $this->storeTimestamp ? time() : date($this->dateFormat);
     // If we are storing a timestamp lets get one else lets get the date
     $log->user_id = $this->getUserId();
     // Lets get the user id
     return $log->save();
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      AuditTrail $value A AuditTrail object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(AuditTrail $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 /**
  * @param BaseObject $object
  * @return AuditTrail
  */
 public function createAuditTrail(BaseObject $object, $action)
 {
     $partnerId = kCurrentContext::$master_partner_id;
     if (!$this->traceEnabled($partnerId)) {
         return null;
     }
     if (!method_exists($object, 'getPeer') || !method_exists($object, 'getId')) {
         return null;
     }
     $peer = $object->getPeer();
     try {
         $objectType = $peer->getOMClass(false, null);
     } catch (Exception $e) {
         KalturaLog::err("Error creating audit trail for object id[" . $object->getId() . "] type[{$objectType}] " . $e->getMessage());
         $auditTrail = null;
         return null;
     }
     if (!in_array($objectType, AuditTrail::getAllwodObjectTypes())) {
         return null;
     }
     try {
         $auditTrail = new AuditTrail();
         $auditTrail->setAction($action);
         $auditTrail->setPartnerId($partnerId);
         $auditTrail->setObjectType($objectType);
         $auditTrail->setStatus(AuditTrail::AUDIT_TRAIL_STATUS_READY);
         $auditTrail->setObjectId($object->getId());
         $auditTrail->setEntryId($this->getEntryId($object));
         self::setRelatedObject($auditTrail, $object);
     } catch (kAuditTrailException $e) {
         KalturaLog::err("Error creating audit trail for object id[" . $object->getId() . "] type[{$objectType}] " . $e->getMessage());
         $auditTrail = null;
     }
     return $auditTrail;
 }
Exemple #22
0
;
        $scope.renderParams = <?php 
echo @json_encode($renderParams);
?>
;
        $scope.getParams = <?php 
echo @json_encode($_GET);
?>
;
        $scope.params = angular.extend({}, $scope.renderParams, $scope.getParams);
        $scope.pageUrl = "<?php 
echo @Yii::app()->request->url;
?>
";
        $scope.pageInfo = <?php 
echo json_encode(AuditTrail::getPathInfo());
?>
;
        $scope.formClass = "<?php 
echo $modelClass;
?>
";
        $scope.formClassPath = "<?php 
echo $modelClassPath;
?>
";
        $scope.modelBaseClass = "<?php 
echo ActiveRecord::baseClass($this->model);
?>
";
        $scope.lastModified = "<?php 
 public function getAuditTrail()
 {
     $audits = AuditTrail::orderBy('created_at', 'desc')->paginate(10);
     return View::make('admin.audit-trail')->with('audits', $audits);
 }
<?php

//class for get the interested project holders
require_once './global.inc.php';
verify_oauth_session_exists();
if (HttpSession::currentUser()->getOrganization()->access_level == 2) {
    $projectId = $_POST["projectId"];
    $linkedinId = $_POST["linkedinId"];
    $stu_phone = $_POST["stu_phone"];
    $stu_comment = $_POST["stu_comment"];
    $idUser = $_POST["idUser"];
    $queryString = $_POST["queryString"];
    //echo $projectId . $studentId . $stu_phone . $stu_comment;
    Project::addInterestStudents($projectId, $linkedinId, $stu_phone, $stu_comment);
    AuditTrail::takeProject('project', $projectId, 'take project', $idUser, false);
    header("Location: projects.php");
    die;
}
Exemple #25
0
     continue;
 }
 if ($ref_model_name == 'yii_t_message') {
     continue;
 }
 $rm = new $ref_model_name();
 $rm_primary_key_field = $rm->tableSchema->primaryKey;
 if (!is_array($ref_field)) {
     //get ref table pk values
     $criteria = new CDbCriteria();
     $criteria->distinct = true;
     $criteria->compare('model', $ref_model_name);
     $criteria->compare('field', $ref_field);
     $criteria->compare('new_value', $model_id);
     $criteria->compare('action', 'SET');
     $audit_trail = AuditTrail::model()->findAll($criteria);
     if (empty($audit_trail)) {
         continue;
     }
     $rm_pk = array();
     foreach ($audit_trail as $at_row) {
         $rm_pk[] = $at_row->model_id;
     }
 } else {
     $criteria = new CDbCriteria();
     $criteria->distinct = true;
     foreach ($ref_field['compare'] as $rmfn => $rmfv) {
         if ($rmfv == 'pk_value') {
             $criteria->compare($rmfn, $model_id);
             continue;
         }
 /**
  * retourne tous les utilisateurs
  * @return type
  */
 public function getAllUsers()
 {
     $result = array();
     $users = AuditTrail::model()->findAll();
     if ($users != null) {
         foreach ($users as $user) {
             if (!in_array($user->user_id, $result)) {
                 array_push($result, $user->user_id);
             }
         }
     }
     return $result;
 }
Exemple #27
0
require_once 'modules/Users/Users.php';
require_once 'include/logging.php';
require_once 'include/utils/utils.php';
global $app_strings;
global $mod_strings;
global $app_list_strings;
global $current_language, $current_user, $adb;
$current_module_strings = return_module_language($current_language, 'Settings');
global $list_max_entries_per_page;
global $urlPrefix;
$log = LoggerManager::getLogger('audit_trial');
global $currentModule;
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$focus = new AuditTrail();
$smarty = new vtigerCRM_Smarty();
$category = getParenttab();
$userid = vtlib_purify($_REQUEST['userid']);
$qry = "select * from vtiger_audit_trial where userid = ? ";
$qry_result = $adb->pquery($qry, array($userid));
$no_of_rows = $adb->num_rows($qry_result);
//Retreiving the start value from request
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
    $start = vtlib_purify($_REQUEST['start']);
} else {
    $start = 1;
}
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $no_of_rows, '100');
$start_rec = $navigation_array['start'];
Exemple #28
0
 /**
  * Logs out the current user and redirect to homepage.
  */
 public function actionLogout()
 {
     ## audit trail tracker
     AuditTrail::logout();
     ## logout user
     Yii::app()->user->logout();
     $this->redirect(Yii::app()->homeUrl);
 }
<h3>Log View Activity</h3><hr>
<?php 
$this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'user_id', 'type' => 'raw', 'value' => array($this, 'user')), 'action', 'model', 'model_id', array('name' => 'stamp', 'value' => date("d-m-Y H:i:s", strtotime($model->stamp))))));
$audit = new AuditTrail('search');
$stamp = $model->stamp;
$criteria = array('condition' => "(action='SET' OR action='CHANGE') AND stamp='{$stamp}'", 'order' => 't.id');
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'title-grid', 'dataProvider' => $audit->recently()->mergeCriteria($criteria)->search(), 'columns' => array(array('name' => 'action', 'type' => 'raw', 'value' => array($this, 'action')), 'model', array('name' => 'field', 'value' => '$data->getParent()->getAttributeLabel($data->field)'), 'old_value', 'new_value', array('name' => 'stamp', 'value' => 'date("d-m-Y H:i:s", strtotime($data->stamp))'))));
?>
 
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      AuditTrail $value A AuditTrail object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(AuditTrail $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('AuditTrailPeer');
         }
     }
 }