diff --git a/www/protected/components/HistorialWidget.php b/www/protected/components/HistorialWidget.php new file mode 100644 index 0000000..c46a57d --- /dev/null +++ b/www/protected/components/HistorialWidget.php @@ -0,0 +1,124 @@ +visible) { + $auditTrail = AuditTrail::model()->recently(); + $auditTrail->model = get_class($this->model); + $auditTrail->model_id = $this->model->primaryKey; + $columnFormat = $this->getColumnFormat(); + + $dataProvider = $auditTrail->search(); + $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']); + $dataProvider->getPagination()->setPageSize($pageSize); + + $this->widget('application.extensions.SelGridView', array( + 'id'=>'audit-trail-grid', + 'dataProvider'=>$dataProvider, + 'columns'=>$this->getColumnFormat(), + 'filter'=>$this->model, + 'filterPosition' => 'footer', + 'cssFile' => Yii::app()->baseUrl . '/css/gridview2.css', + 'itemsCssClass' => 'display', + 'pagerCssClass' => 'dataTables_paginate', + 'template' => '{items}{summary}{pager}', + 'emptyText' => Yii::t('intranet', 'Este candidato no tiene cambios'), + 'summaryCssClass' => 'dataTables_info', + 'summaryText' => 'Mostrando registros del {start} al {end} de {count} en total.', + 'selectableRows' => 1, + )); + + } + } + + /** + * Gets final column format. Starts with default column format (specified in this method + * and checks $this->dataGridColumnsOverride array to see if any columns need to use a + * user specified format. + * @return array The final format array, with any user specified formats taking precedent over defaults + */ + protected function getColumnFormat() { + $evalUserLabel = $this->getEvalUserLabelCode(); + $columnFormat = array(); + $defaultColumnFormat = array( + 'stamp' => array( + 'name' => 'stamp', + 'header' => Yii::t('intranet','Stamp'), + 'filter' => '', + 'headerHtmlOptions'=>array( + 'class' => 'head0 sorting', + ), + 'cssClassExpression' => '"con0"', + + ), + 'new_value' => array( + 'name' => 'new_value', + 'header' => Yii::t('intranet','Nuevo valor'), + 'filter' => '', + 'headerHtmlOptions'=>array( + 'class' => 'head1 sorting', + ), + 'cssClassExpression' => '"con1"', + ), + 'old_value' => array( + 'name' => 'old_value', + 'header' => Yii::t('intranet','Valor anterior'), + 'filter' => '', + 'headerHtmlOptions'=>array( + 'class' => 'head0 sorting', + ), + 'cssClassExpression' => '"con0"', + ), + 'action' => array( + 'name' => 'action', + 'header' => Yii::t('intranet','Acción'), + 'filter'=> '', + 'headerHtmlOptions'=>array( + 'class' => 'head1 sorting', + ), + 'cssClassExpression' => '"con1"', + ), + 'field' => array( + 'name' => 'field', + 'header' => Yii::t('intranet','Campo'), + 'filter' => '', + 'headerHtmlOptions'=>array( + 'class' => 'head0 sorting', + ), + 'cssClassExpression' => '"con0"', + ), + 'user_id' => array( + 'name' => 'user_id', + 'header' => Yii::t('intranet','ID usuario'), + 'value'=>$evalUserLabel, + 'filter'=> '', + 'headerHtmlOptions'=>array( + 'class' => 'head1 sorting', + ), + 'cssClassExpression' => '"con1"', + ), + ); + + foreach($defaultColumnFormat as $key => $format) { + $columnFormat[] = isset($this->dataGridColumnsOverride[$key]) ? $this->dataGridColumnsOverride[$key] : $defaultColumnFormat[$key]; + } + + return $columnFormat; + } + + protected function renderDecoration() + { + $this->title = null; + parent::renderDecoration(); + } +} +?> + diff --git a/www/protected/config/main.php b/www/protected/config/main.php index e169ec6..c40d1ae 100644 --- a/www/protected/config/main.php +++ b/www/protected/config/main.php @@ -18,12 +18,19 @@ $config = array( // autoloading model and component classes 'import'=>array( - 'application.models.*', - 'application.components.*', - 'ext.PageSize.*', + 'application.models.*', + 'application.components.*', + 'ext.PageSize.*', + 'application.modules.auditTrail.models.AuditTrail', ), + 'modules'=>array( + 'auditTrail'=>array( + 'userClass' => 'Usuario', // the class name for the user object + 'userIdColumn' => 'id', // the column name of the primary key for the user + 'userNameColumn' => 'username', // the column name of the primary key for the user + ), ), // application components diff --git a/www/protected/controllers/CandidatoController.php b/www/protected/controllers/CandidatoController.php index 3f4c6d3..92a0b18 100644 --- a/www/protected/controllers/CandidatoController.php +++ b/www/protected/controllers/CandidatoController.php @@ -230,6 +230,15 @@ class CandidatoController extends Controller 'model'=>$model)); } + public function actionHistorial($id) + { + $this->layout='//layouts/candidato'; + $this->render('historial',array( + 'model'=>$this->loadModel($id), + )); + } + + /** * Manages all models. */ diff --git a/www/protected/models/Candidato.php b/www/protected/models/Candidato.php index f853373..5f0567d 100644 --- a/www/protected/models/Candidato.php +++ b/www/protected/models/Candidato.php @@ -318,4 +318,10 @@ class Candidato extends CActiveRecord parent::afterFind(); return true; } + + public function behaviors() { + return array( + 'LoggableBehavior'=> 'application.modules.auditTrail.behaviors.LoggableBehavior', + ); + } } \ No newline at end of file diff --git a/www/protected/modules/auditTrail/AuditTrailModule.php b/www/protected/modules/auditTrail/AuditTrailModule.php new file mode 100644 index 0000000..56d2d25 --- /dev/null +++ b/www/protected/modules/auditTrail/AuditTrailModule.php @@ -0,0 +1,74 @@ +setImport(array( + 'auditTrail.models.*', + 'auditTrail.components.*', + )); + } + + public function beforeControllerAction($controller, $action) + { + if(parent::beforeControllerAction($controller, $action)) + { + // this method is called before any module controller action is performed + // you may place customized code here + return true; + } + else + return false; + } + + + /** + * Returns the value you want to look up, either from the config file or a user's override + * @var value The name of the value you would like to look up + * @return the config value you need + */ + public static function getFromConfigOrObject($value) { + $at = Yii::app()->modules['auditTrail']; + + //If we can get the value from the config, do that to save overhead + if( isset( $at[$value]) && !empty($at[$value] ) ) { + return $at[$value]; + } + + //If we cannot get the config value from the config file, get it from the + //instantiated object. Only instantiate it once though, its probably + //expensive to do. PS I feel this is a dirty trick and I don't like it + //but I don't know a better way + if(!is_object(self::$__auditTrailModule)) { + self::$__auditTrailModule = new AuditTrailModule(microtime(), null); + } + + return self::$__auditTrailModule->$value; + } + +} \ No newline at end of file diff --git a/www/protected/modules/auditTrail/README.txt b/www/protected/modules/auditTrail/README.txt new file mode 100644 index 0000000..0ebb757 --- /dev/null +++ b/www/protected/modules/auditTrail/README.txt @@ -0,0 +1,19 @@ +In your main.php config file, add the follow line in your modules section: + + + 'modules'=>array( + .. + 'auditTrail'=>array(), + .. + + +Then go to + +http://myapp.com/index.php?r=auditTrail + + +and view the instructions for setup! + +For a more detailed walkthrough, please see the instructions at + +http://www.yiiframework.com/extension/audittrail \ No newline at end of file diff --git a/www/protected/modules/auditTrail/behaviors/LoggableBehavior.php b/www/protected/modules/auditTrail/behaviors/LoggableBehavior.php new file mode 100644 index 0000000..ff28507 --- /dev/null +++ b/www/protected/modules/auditTrail/behaviors/LoggableBehavior.php @@ -0,0 +1,133 @@ +user->Name; + $userid = Yii::app()->user->id; + } catch(Exception $e) { //If we have no user object, this must be a command line program + $username = "NO_USER"; + $userid = null; + } + + if(empty($username)) { + $username = "NO_USER"; + } + + if(empty($userid)) { + $userid = null; + } + + $newattributes = $this->Owner->getAttributes(); + $oldattributes = $this->getOldAttributes(); + + if (!$this->Owner->isNewRecord) { + // compare old and new + foreach ($newattributes as $name => $value) { + if (!empty($oldattributes)) { + $old = $oldattributes[$name]; + } else { + $old = ''; + } + + if ($value != $old) { + $log=new AuditTrail(); + $log->old_value = $old; + $log->new_value = $value; + $log->action = 'CHANGE'; + $log->model = get_class($this->Owner); + $log->model_id = $this->Owner->getPrimaryKey(); + $log->field = $name; + $log->stamp = date('Y-m-d H:i:s'); + $log->user_id = $userid; + + $log->save(); + } + } + } else { + $log=new AuditTrail(); + $log->old_value = ''; + $log->new_value = ''; + $log->action= 'CREATE'; + $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(); + + + foreach ($newattributes as $name => $value) { + $log=new AuditTrail(); + $log->old_value = ''; + $log->new_value = $value; + $log->action= 'SET'; + $log->model= get_class($this->Owner); + $log->model_id= $this->Owner->getPrimaryKey(); + $log->field= $name; + $log->stamp= date('Y-m-d H:i:s'); + $log->user_id= $userid; + $log->save(); + } + + + + } + return parent::afterSave($event); + } + + public function afterDelete($event) + { + + try { + $username = Yii::app()->user->Name; + $userid = Yii::app()->user->id; + } catch(Exception $e) { + $username = "NO_USER"; + $userid = null; + } + + if(empty($username)) { + $username = "NO_USER"; + } + + 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 afterFind($event) + { + // Save old values + $this->setOldAttributes($this->Owner->getAttributes()); + + return parent::afterFind($event); + } + + public function getOldAttributes() + { + return $this->_oldattributes; + } + + public function setOldAttributes($value) + { + $this->_oldattributes=$value; + } +} +?> \ No newline at end of file diff --git a/www/protected/modules/auditTrail/controllers/AdminController.php b/www/protected/modules/auditTrail/controllers/AdminController.php new file mode 100644 index 0000000..12d9841 --- /dev/null +++ b/www/protected/modules/auditTrail/controllers/AdminController.php @@ -0,0 +1,19 @@ +unsetAttributes(); // clear any default values + if(isset($_GET['AuditTrail'])) { + $model->attributes=$_GET['AuditTrail']; + } + $this->render('admin',array( + 'model'=>$model, + )); + } +} \ No newline at end of file diff --git a/www/protected/modules/auditTrail/controllers/DefaultController.php b/www/protected/modules/auditTrail/controllers/DefaultController.php new file mode 100644 index 0000000..957551e --- /dev/null +++ b/www/protected/modules/auditTrail/controllers/DefaultController.php @@ -0,0 +1,9 @@ +render('index'); + } +} \ No newline at end of file diff --git a/www/protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php b/www/protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php new file mode 100644 index 0000000..f546b7a --- /dev/null +++ b/www/protected/modules/auditTrail/migrations/m110517_155003_create_tables_audit_trail.php @@ -0,0 +1,68 @@ +createTable( 'tbl_audit_trail', + array( + 'id' => 'pk', + 'old_value' => 'text', + 'new_value' => 'text', + 'action' => 'string NOT NULL', + 'model' => 'string NOT NULL', + 'field' => 'string NOT NULL', + 'stamp' => 'datetime NOT NULL', + 'user_id' => 'string', + 'model_id' => 'string NOT NULL', + ) + ); + + //Index these bad boys for speedy lookups + $this->createIndex( 'idx_audit_trail_user_id', 'tbl_audit_trail', 'user_id'); + $this->createIndex( 'idx_audit_trail_model_id', 'tbl_audit_trail', 'model_id'); + $this->createIndex( 'idx_audit_trail_model', 'tbl_audit_trail', 'model'); + $this->createIndex( 'idx_audit_trail_field', 'tbl_audit_trail', 'field'); + //$this->createIndex( 'idx_audit_trail_old_value', 'tbl_audit_trail', 'old_value'); + //$this->createIndex( 'idx_audit_trail_new_value', 'tbl_audit_trail', 'new_value'); + $this->createIndex( 'idx_audit_trail_action', 'tbl_audit_trail', 'action'); + } + + /** + * Drops the audit trail table + */ + public function down() + { + $this->dropTable( 'tbl_audit_trail' ); + } + + /** + * Creates initial version of the audit trail table in a transaction-safe way. + * Uses $this->up to not duplicate code. + */ + public function safeUp() + { + $this->up(); + } + + /** + * Drops the audit trail table in a transaction-safe way. + * Uses $this->down to not duplicate code. + */ + public function safeDown() + { + $this->down(); + } + + +} \ No newline at end of file diff --git a/www/protected/modules/auditTrail/models/AuditTrail.php b/www/protected/modules/auditTrail/models/AuditTrail.php new file mode 100644 index 0000000..e21a283 --- /dev/null +++ b/www/protected/modules/auditTrail/models/AuditTrail.php @@ -0,0 +1,125 @@ +255), + array('model', 'length', 'max'=>255), + array('field', 'length', 'max'=>255), + array('model_id', 'length', 'max'=>255), + array('user_id', 'length', 'max'=>255), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, new_value, old_value, action, model, field, stamp, user_id, model_id', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'old_value' => 'Old Value', + 'new_value' => 'New Value', + 'action' => 'Action', + 'model' => 'Model', + 'field' => 'Field', + 'stamp' => 'Stamp', + 'user_id' => 'User', + 'model_id' => 'Model', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search($options = array()) + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + $criteria=new CDbCriteria; + $criteria->compare('id',$this->id); + $criteria->compare('old_value',$this->old_value,true); + $criteria->compare('new_value',$this->new_value,true); + $criteria->compare('action',$this->action,true); + $criteria->compare('model',$this->model); + $criteria->compare('field',$this->field,true); + $criteria->compare('stamp',$this->stamp,true); + $criteria->compare('user_id',$this->user_id); + $criteria->compare('model_id',$this->model_id); + $criteria->mergeWith($this->getDbCriteria()); + return new CActiveDataProvider( + get_class($this), + array_merge( + array( + 'criteria'=>$criteria, + ), + $options + ) + ); + } + + public function scopes() { + return array( + 'recently' => array( + 'order' => ' t.stamp DESC ', + ), + + ); + } +} \ No newline at end of file diff --git a/www/protected/modules/auditTrail/views/admin/_search.php b/www/protected/modules/auditTrail/views/admin/_search.php new file mode 100644 index 0000000..f7d4571 --- /dev/null +++ b/www/protected/modules/auditTrail/views/admin/_search.php @@ -0,0 +1,59 @@ +
+ +beginWidget('CActiveForm', array( + 'action'=>Yii::app()->createUrl($this->route), + 'method'=>'get', +)); ?> + +
+ label($model,'id'); ?> + textField($model,'id',array('size'=>11,'maxlength'=>11)); ?> +
+ +
+ label($model,'old_value'); ?> + textArea($model,'old_value',array('rows'=>6, 'cols'=>50)); ?> +
+ +
+ label($model,'new_value'); ?> + textArea($model,'new_value',array('rows'=>6, 'cols'=>50)); ?> +
+ +
+ label($model,'action'); ?> + textField($model,'action',array('size'=>20,'maxlength'=>20)); ?> +
+ +
+ label($model,'model'); ?> + textField($model,'model',array('size'=>60,'maxlength'=>255)); ?> +
+ +
+ label($model,'field'); ?> + textField($model,'field',array('size'=>60,'maxlength'=>64)); ?> +
+ +
+ label($model,'stamp'); ?> + textField($model,'stamp'); ?> +
+ +
+ label($model,'user_id'); ?> + textField($model,'user_id'); ?> +
+ +
+ label($model,'model_id'); ?> + textField($model,'model_id',array('size'=>60,'maxlength'=>65)); ?> +
+ +
+ +
+ +endWidget(); ?> + +
\ No newline at end of file diff --git a/www/protected/modules/auditTrail/views/admin/admin.php b/www/protected/modules/auditTrail/views/admin/admin.php new file mode 100644 index 0000000..2536b1a --- /dev/null +++ b/www/protected/modules/auditTrail/views/admin/admin.php @@ -0,0 +1,58 @@ +breadcrumbs=array( + 'Audit Trails'=>array('/auditTrail'), + 'Manage', +); +/* +$this->menu=array( + array('label'=>'List AuditTrail', 'url'=>array('index')), + array('label'=>'Create AuditTrail', 'url'=>array('create')), +); +*/ +Yii::app()->clientScript->registerScript('search', " +$('.search-button').click(function(){ + $('.search-form').toggle(); + return false; +}); +$('.search-form form').submit(function(){ + $.fn.yiiGridView.update('audit-trail-grid', { + data: $(this).serialize() + }); + return false; +}); +"); +?> + +

Manage Audit Trails

+ +

+You may optionally enter a comparison operator (<, <=, >, >=, <> +or =) at the beginning of each of your search values to specify how the comparison should be done. +

+ +'search-button')); ?> + + +widget('zii.widgets.grid.CGridView', array( + 'id'=>'audit-trail-grid', + 'dataProvider'=>$model->search(), + 'filter'=>$model, + 'columns'=>array( + 'id', + 'old_value', + 'new_value', + 'action', + 'model', + 'field', + 'stamp', + 'user_id', + 'model_id', +// array( +// 'class'=>'CButtonColumn', +// ), + ), +)); ?> \ No newline at end of file diff --git a/www/protected/modules/auditTrail/views/default/index.php b/www/protected/modules/auditTrail/views/default/index.php new file mode 100644 index 0000000..f9a114f --- /dev/null +++ b/www/protected/modules/auditTrail/views/default/index.php @@ -0,0 +1,95 @@ +breadcrumbs=array( + $this->module->id, +); +?> +

Welcome to Audit Trail!

+

Introduction

+

+ This is the audit trail module. This module provides basic access to any changes performed via active record through any class that has the LoggableBehavior assigned. It is based off of . I've noticed I always do the same things with it, and I hoped to help others who probably do the same thing. +

+

Changes

+

+

+

+

Requirements

+

+ This module requires: +

+

+

Installation

+

+ If you are looking at this page, you at least enabled the module in your main.php config. Good job! Now we can continue with the installation: +

    +
  1. Make sure your components->db is configured in protected/config/main.php
  2. +
  3. Make sure the rest of this module is set up in your protected/config/main.php. See configuration for help with this.
  4. +
  5. + Run the database migrations to create the tables for audit trail. Keep in mind that you will have to use the --migrationPath flag to tell the yiic tool where the migrations are. It should look something like this: +
    prompt:> php ./yiic.php migrate up --migrationPath=application.modules.auditTrail.migrations
    + Keep in mind that you may have to change the mirgrationPath to match where you installed the extension. My examples assumes you put it in MyWebApp/protected/modules +
  6. +
  7. Make sure any active record objects you want to log are using the loggable behavior
  8. +
  9. + Add the audit trail widget to any admin pages you want (optional) +
  10. +
  11. + Build in RBAC rules if using RBAC (optional). This controllers in this module automatically extend the Controller class of the current web app, so any logic you built into your app for RBAC should work fine. You may need to adjust settings in your RBAC management interface, but specific instructions depend on which implementation you are using. If you need a recommendation, I really like Rights by Chris83. +
  12. +
  13. Use the Audit Trail Manager to manage your audit trail!
  14. +
+

+

Parts

+

main.php Configuration

+

+ Please add the AuditTrail model to the import section of your main.php config file so that all models that need it can find the AR model: +

+	'import'=>array(
+		'application.models.*',
+		'application.components.*',
+		'application.modules.auditTrail.models.AuditTrail',
+		.....
+	),
+
+ Here are the following options for your main.php configurations (the defaults for all of them should work, so you may not need to use any of them, but if you need to override them you can) +
+	'modules'=>array(
+		'auditTrail'=>array(
+			'userClass' => 'User', // the class name for the user object
+			'userIdColumn' => 'id', // the column name of the primary key for the user
+			'userNameColumn' => 'username', // the column name of the primary key for the user
+		),
+	.......
+
+

+ +

Loggable Behavior

+

+ You should make sure your ActiveRecord objects use the LoggableBehavior. If you installed AuditTrail to your modules directory, this would typically be referenced by adding this function to your AR model: +public function behaviors() +{ + return array( + 'LoggableBehavior'=> + 'application.modules.auditTrail.behaviors.LoggableBehavior', + ); +} +

+

Audit Trail Widget

+

+ You can easily add the audit trail widget to any page that is specifcally about one row of one thing (ie: one instance of one model, like an update or view page, not like an admin or list page), and it will give you insight into changes for just that object. +$this->widget( + 'application.modules.auditTrail.widgets.portlets.ShowAuditTrail', + array( + 'model' => $model, + ) +); +

+

Audit Trail Manager

+

The manager is just a searchable table of all audits. You can find it here:

diff --git a/www/protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php b/www/protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php new file mode 100644 index 0000000..eb5a94f --- /dev/null +++ b/www/protected/modules/auditTrail/widgets/portlets/ShowAuditTrail.php @@ -0,0 +1,157 @@ + array( + * 'old_value' => array( + * 'name' => 'old_value', + * 'filter' => '', + * ), + * 'new_value' => array( + * 'name' => 'new_value', + * 'filter' => '', + * ), + * ) + * + * Please do not specify a column if you do not wish to override the defaults of that column. + * Also, please be careful when specifying a format for user_id, as special handling exists + * to format the user name + */ + public $dataGridColumnsOverride = array( ); + + /** + * @var AuditTrailModule static variable to hold the module so we don't have to instantiate it a million times to get config values + */ + private static $__auditTrailModule; + + /** + * Sets the title of the portlet + */ + public function init() { + $this->title = "Audit Trail For " . get_class($this->model) . " " . $this->model->id; + parent::init(); + } + + /** + * 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(), + )); + } + } + + /** + * Builds the label code we need to display usernames correctly + * @return The code to be evaled to display the user info correctly + */ + protected function getEvalUserLabelCode() { + $userClass = $this->getFromConfigOrObject('userClass'); + $userNameColumn = $this->getFromConfigOrObject('userNameColumn'); + $userEvalLabel = ' ( ($t = ' + . $userClass + . '::model()->findByPk($data->user_id)) == null ? "": $t->' + . $userNameColumn + . ' ) '; + return $userEvalLabel; + } + + /** + * Returns the value you want to look up, either from the config file or a user's override + * @var value The name of the value you would like to look up + * @return the config value you need + */ + protected function getFromConfigOrObject($value) { + $at = Yii::app()->modules['auditTrail']; + + //If we can get the value from the config, do that to save overhead + if( isset( $at[$value]) && !empty($at[$value] ) ) { + return $at[$value]; + } + + //If we cannot get the config value from the config file, get it from the + //instantiated object. Only instantiate it once though, its probably + //expensive to do. PS I feel this is a dirty trick and I don't like it + //but I don't know a better way + if(!is_object(self::$__auditTrailModule)) { + self::$__auditTrailModule = new AuditTrailModule(microtime(), null); + } + + return self::$__auditTrailModule->$value; + } + + /** + * Gets final column format. Starts with default column format (specified in this method + * and checks $this->dataGridColumnsOverride array to see if any columns need to use a + * user specified format. + * @return array The final format array, with any user specified formats taking precedent over defaults + */ + protected function getColumnFormat() { + $evalUserLabel = $this->getEvalUserLabelCode(); + $columnFormat = array(); + $defaultColumnFormat = array( + 'old_value' => array( + 'name' => 'old_value', + 'filter' => '', + ), + 'new_value' => array( + 'name' => 'new_value', + 'filter' => '', + ), + 'action' => array( + 'name' => 'action', + 'filter'=> '', + ), + 'field' => array( + 'name' => 'field', + 'filter' => '', + ), + 'stamp' => array( + 'name' => 'stamp', + 'filter' => '', + ), + 'user_id' => array( + 'name' => 'user_id', + 'value'=>$evalUserLabel, + 'filter'=> '', + ), + ); + + foreach($defaultColumnFormat as $key => $format) { + $columnFormat[] = isset($this->dataGridColumnsOverride[$key]) ? $this->dataGridColumnsOverride[$key] : $defaultColumnFormat[$key]; + } + + return $columnFormat; + } +} \ No newline at end of file diff --git a/www/protected/views/candidato/index.php b/www/protected/views/candidato/index.php index 2d8c6d8..293a025 100644 --- a/www/protected/views/candidato/index.php +++ b/www/protected/views/candidato/index.php @@ -93,8 +93,11 @@ $('.search-form form').submit(function(){ 'type' => 'raw', //'name' => 'capacidad_funcional_search', 'value'=>array($this, 'gridDataColumnCapacidadFuncional'), - 'header' => 'Capacidad funcional', + 'header' => Yii::t('intranet','Capacidad funcional'), 'filter' => CHtml::listData(PerfilFuncional::model()->findAll(), 'id', 'descripcion'), + 'headerHtmlOptions'=>array( + 'class' => 'head0 sorting', + ), 'cssClassExpression' => '"con1"', ), array( diff --git a/www/protected/views/layouts/candidato.php b/www/protected/views/layouts/candidato.php index d1dc0d6..250f054 100644 --- a/www/protected/views/layouts/candidato.php +++ b/www/protected/views/layouts/candidato.php @@ -36,23 +36,24 @@ $pestañas = array( 'label' => Yii::t('intranet', 'Resumen'), 'url' => $this->createUrl('candidato/view',array('id' => $candidatoId)), 'linkOptions' => array('class'=>'candidatos'), - 'active' => ($this->getId() == 'candidato'), + 'active' => ($this->action->id == 'view'), ), array( 'label' => Yii::t('intranet', 'Capacidades profesionales'), 'url' => $this->createUrl('candidatoCapacidad/index', array('cid'=>$candidatoId)), - 'active' => ($this->getId() == 'candidatoCapacidad'), + 'active' => ($this->id == 'candidatoCapacidad'), ), array( 'label' => Yii::t('intranet', 'Currículums'), 'url' => array('/usuario'), 'linkOptions' => array('class'=>'curriculum'), - 'active' => ($this->getId() == 'curriculum') + 'active' => ($this->id == 'curriculum') ), array( 'label' => Yii::t('intranet', 'Historial'), - 'url' => array('/site/index'), - 'active' => ($this->getId() == 'solicitud'), + 'url' => $this->createUrl('candidato/historial',array('id' => $candidatoId)), + 'linkOptions' => array('class'=>'historial'), + 'active' => ($this->action->id == 'historial'), ), ); diff --git a/www/protected/views/site/tablero.php b/www/protected/views/site/tablero.php index 5a2f547..ddacfa9 100644 --- a/www/protected/views/site/tablero.php +++ b/www/protected/views/site/tablero.php @@ -9,7 +9,7 @@ Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/custom/d
¡¡¡¡ ESTE TABLERO ES UN EJEMPLO !!!! - +