Exemple #1
0
 /**
  * Loads a personna infos and update its AP if needed
  *
  * @param int $id ID of the personna to load
  */
 public function load($id)
 {
     $this->_db->beginTransaction();
     try {
         $personna = $this->_db->fetchFirstRequest('getPersonna', array(':id' => $id));
         if (empty($personna)) {
             throw new Exception('Personna not found');
         }
         // Update personna AP
         $updatedAP = APHelpers::update($this->_ruleset->get('personna.maxAp'), $this->_ruleset->get('game.period'), $this->_ruleset->get('personna.apGain'), $personna['AP'], $personna['time_from_last_regen']);
         if ($updatedAP['ap'] != $personna['AP']) {
             $this->_db->executeRequest('updatePersonna', array(':id' => $id, ':ap' => $updatedAP['ap'], ':toRemove' => $updatedAP['toRemove']));
             $personna['AP'] = $updatedAP['ap'];
         }
         // Get logs
         $personna['logs'] = array();
         $logs = $this->_db->fetchAllRequest('getPersonnaLogs', array(':userId' => $personna['user_id'], ':battlefieldId' => $personna['battlefield_id'], ':currentItemId' => $personna['current_item_id']));
         if (!empty($logs)) {
             foreach ($logs as $log) {
                 $actionLog = new ActionLog($this->_DI);
                 $actionLog->loadFromArray($log);
                 $personna['logs'][] = $actionLog;
             }
         }
         if ($personna['is_soldier']) {
             $personna['item'] = new Soldier($personna['current_item_id'], $this->_DI);
             $personna['item']->setRuleset($this->_ruleset);
             $personna['item']->updateAP();
         } else {
             $personna['item'] = new Headquarter($personna['current_item_id'], $this->_DI);
         }
         $this->_data = $personna;
     } catch (Exception $e) {
         $this->_db->rollBack();
         throw $e;
     }
     $this->_db->commit();
 }
 /**
  * Delete products
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = ActionLog::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $page) {
                 $page->delete();
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
 /**
  * @param $model
  * @param $event string event name. e.g: create/update/delete
  */
 protected function saveEvent($model, $event)
 {
     if (in_array(spl_object_hash($model), $this->processedObjects)) {
         return;
     }
     $className = get_class($model);
     $modelTitleAttr = $this->logClasses[$className]['title_attribute'];
     $log = new ActionLog();
     $log->username = Yii::app()->user->username;
     $log->event = $event;
     $log->model_name = $className;
     $log->model_title = $model->{$modelTitleAttr};
     $log->datetime = date('Y-m-d H:i:s');
     $log->save();
     array_push($this->processedObjects, spl_object_hash($model));
 }
/**
 * Log the Users Action
 *
 * Wrapper function for the Log Action Class
 *
 * @param $action string
 * @param $type int (1=Normal, 2=Issue, 3=Security)
 * @return BOOL
 */
function LogAction($action, $type, $area = 0)
{
    global $myUser;
    // If logging is enabled
    if (LOGGING == true) {
        // Create the Action Log Class
        $myLog = new ActionLog();
        // Set all the Available Information
        if (is_object($myUser)) {
            $myLog->SetValue('user_id', $myUser->GetPrimary());
        }
        $myLog->SetValue('ip', $_SERVER['REMOTE_ADDR']);
        $myLog->SetValue('user_agent', $_SERVER['HTTP_USER_AGENT']);
        $myLog->SetValue('type', (int) $type);
        $myLog->SetValue('is_viewed', 0);
        $myLog->SetValue('action', stripslashes($action));
        // Save the log
        return $myLog->Save();
    }
    return false;
}
Exemple #5
0
	'columns'=>array(
		/*array(
			'class'=>'CCheckBoxColumn',
		),*/
	//	array('name'=>'id'),
		array(
			'name'=>'search_user',
			'value'=>function($data) {
                 return ($data->userid)?$data->userid->username:"";
            },
		),
		array(
			'name'=>'event',
			'type'=>'raw',
			'value'=>'$data->actionTitle',
			'filter'=>ActionLog::getEventNames()
		),
		array(
			'name'=>'model_name',
			'type'=>'raw',
			'value'=>'$data->getHumanModelName()',
			'filter'=>$model->getModelNameFilter()
		),
		array(
			'name'=>'model_id',
			'type'=>'raw',
			'value'=>function($data) {
				 if($data->model_name == 'Orgs')
				 {
				 	$ret = $data->org?CHtml::link($data->model_id, Yii::app()->createAbsoluteUrl('catalog/admin/company/update', array("id"=>$data->model_id)), array('target'=>'_blank')):$data->model_id;
				 }
Exemple #6
0
function do_actionlog($login, $object, $action, $subaction)
{
    global $gbl, $sgbl, $login, $ghtml;
    if ($subaction === 'customermode') {
        return;
    }
    if (csb($subaction, 'boxpos')) {
        return;
    }
    if (!$object->is__table('domain') && !$object->is__table('client') && !$object->is__table('vps')) {
        return;
    }
    $d = microtime(true);
    $alog = new ActionLog(null, null, $d);
    $res['login'] = $login->nname;
    $res['loginclname'] = $login->getClName();
    $aux = $login->getAuxiliaryId();
    $res['auxiliary_id'] = $aux;
    $res['ipaddress'] = $gbl->c_session->ip_address;
    $res['class'] = $object->get__table();
    $res['objectname'] = $object->nname;
    $res['action'] = $action;
    $res['subaction'] = $subaction;
    $res['ddate'] = time();
    $alog->create($res);
    $alog->write();
}
	/**
	 * @param $model
	 * @param $event string event name. e.g: create/update/delete
	 */
	protected function saveEvent($model, $event)
	{
		if(in_array(spl_object_hash($model),$this->processedObjects))
			return;

		$className = get_class($model);
		$modelTitleAttr = $this->logClasses[$className]['title_attribute'];

		$log = new ActionLog;
		$log->user_id = Yii::app()->user->id;
		$log->event = $event;
		$log->model_name = $className;
		$log->model_title = $model->$modelTitleAttr;
		$log->datetime = date('Y-m-d H:i:s');
		$log->model_id = $model->id;
		if(!$log->save()){
			// VarDumper::dump($log->errors); die(); // Ctrl + X	Delete line
		}

		array_push($this->processedObjects, spl_object_hash($model));
	}
Exemple #8
0
<?php

/**
 * Display logs
 **/
$this->pageHeader = Yii::t('LoggerModule.admin', 'Журнал действий');
$this->breadcrumbs = array('Home' => $this->createUrl('/admin'), Yii::t('LoggerModule.admin', 'Модули') => Yii::app()->createUrl('/core/admin/systemModules'), Yii::t('LoggerModule.admin', 'Журнал действий'));
$this->widget('ext.sgridview.SGridView', array('dataProvider' => $dataProvider, 'id' => 'loggerListGrid', 'afterAjaxUpdate' => "function(){registerFilterDatePickers()}", 'filter' => $model, 'enableHistory' => true, 'columns' => array(array('class' => 'CCheckBoxColumn'), array('class' => 'SGridIdColumn', 'name' => 'id'), array('name' => 'username'), array('name' => 'event', 'type' => 'raw', 'value' => '$data->actionTitle', 'filter' => ActionLog::getEventNames()), array('name' => 'model_name', 'type' => 'raw', 'value' => '$data->getHumanModelName()', 'filter' => $model->getModelNameFilter()), array('name' => 'model_title'), 'datetime', array('class' => 'CButtonColumn', 'template' => '{delete}'))));
Yii::app()->clientScript->registerScript("pageDatepickers", "\n\tfunction registerFilterDatePickers(id, data){\n\t\tjQuery('input[name=\"ActionLog[datetime]\"]').datepicker({\n\t\t\tdateFormat:'yy-mm-dd',\n\t\t\tconstrainInput: false\n\t\t});\n\t}\n\tregisterFilterDatePickers();\n");