本文整理匯總了PHP中Logs::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Logs::model方法的具體用法?PHP Logs::model怎麽用?PHP Logs::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Logs
的用法示例。
在下文中一共展示了Logs::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadModel
public function loadModel($id)
{
$model = Logs::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: getActivity
/**
* Get all project activity
* @param string $moduleName
* @return model list of log activity
*/
public function getActivity($moduleName)
{
$project_idSelected = Yii::app()->user->getState('project_selected');
if (empty($project_idSelected)) {
$projectList = array();
$Projects = Yii::app()->user->getProjects();
foreach ($Projects as $project) {
array_push($projectList, $project->project_id);
}
}
return Logs::model()->findActivity($moduleName, !empty($project_idSelected) ? array($project_idSelected) : $projectList);
}
示例3: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate()
{
if (Yii::app()->user->checkAccess('updateDiagrams')) {
$model = $this->loadModel();
if (isset($_POST['Diagrams'])) {
$model->attributes = $_POST['Diagrams'];
if ($model->save()) {
// Guardar log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'DiagramUpdated', 'log_resourceid' => $model->diagram_id, 'log_type' => 'updated', 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
$this->redirect(array('view', 'id' => $model->diagram_id));
}
}
$this->render('update', array('model' => $model));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例4: feignDeleteLogs
/**
* 假刪除日誌
*/
public function feignDeleteLogs($userId, $type = '')
{
$criteria = new CDbCriteria();
$criteria->condition = 'user_id=:user_id';
$criteria->params = array(':user_id' => $userId);
$attributes = array('is_deleted' => 1);
if ($type == '0') {
$criteria->addCondition("type =:type", "and");
$criteria->params[':type'] = $type;
}
Logs::model()->updateAll($attributes, $criteria);
if ($this->hasCache === true) {
$this->cleanCache($userId);
}
}
示例5: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate()
{
if (Yii::app()->user->checkAccess('updateUsers')) {
$allowEdit = false;
$model = $this->loadModel();
$tmppw = $model->user_password;
if (!empty($model->address_id)) {
$address = Address::model()->findByPk($model->address_id);
} else {
$address = new Address();
}
$userManager = Yii::app()->user->IsManager;
if ($model->user_id == Yii::app()->user->id || $userManager || Yii::app()->user->IsAdministrator) {
$allowEdit = true;
}
if (isset($_POST['Users']) && isset($_POST['Address'])) {
$model->attributes = $_POST['Users'];
$address->attributes = $_POST['Address'];
if (isset($_POST['Users']['user_password'])) {
$model->user_password = md5($model->user_password);
}
$valid = $address->validate();
$valid = $model->validate() && $valid;
if ($valid) {
$address->save(false);
$model->address_id = $address->primaryKey;
if ($model->save(false)) {
// Guardar log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'UserUpdated', 'log_resourceid' => $model->user_id, 'log_type' => 'updated', 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id);
Logs::model()->saveLog($attributes);
$this->redirect(array('view', 'id' => $model->user_id));
}
}
}
$this->render('update', array('model' => $model, 'allowEdit' => $allowEdit, 'userManager' => $userManager, 'address' => $address));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例6: array
*/
$this->pageTitle = Yii::app()->name . ' :: Админцентр - Системный лог';
$this->breadcrumbs = array('Админцентр' => array('/admin/index'), 'Системный лог');
$this->menu = array(array('label' => 'Удалить все записи', 'url' => '#', 'linkOptions' => array('id' => 'clearLog')));
Yii::app()->clientScript->registerScript('', '
$("a#clearLog").click(function(){
if(!confirm("Удалить все записи лога?"))
return false;
var ret = "";
$.post("", {"clearlog": 1}, function(data){
jQuery("#logs-grid").yiiGridView("update");
alert("Лог очищен");
});
return false;
});
function reinstallDatePicker(id, data) {
$("#timestamp").datepicker(jQuery.extend({showMonthAfterYear:false},jQuery.datepicker.regional["ru"],{"showAnim":"fold"}));
}
');
$this->renderPartial('/admin/mainmenu', array('active' => 'site', 'activebtn' => 'logs'));
?>
<h2>Системный лог</h2>
<?php
$criteria = new CDbCriteria();
$criteria->group = 'username';
$this->widget('bootstrap3.widgets.BsGridView', array('id' => 'logs-grid', 'type' => 'bordered', 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => array(array('name' => 'timestamp', 'type' => 'datetime', 'value' => '$data->timestamp', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'id' => 'timestamp', 'attribute' => 'timestamp', 'language' => 'ru', 'i18nScriptFile' => 'jquery-ui-i18n.min.js', 'htmlOptions' => array('id' => 'timestamp', 'size' => '10', 'class' => 'form-control'), 'options' => array('showAnim' => 'fold')), true)), array('name' => 'username', 'filter' => CHtml::listData(Logs::model()->findAll($criteria), 'username', 'username')), array('name' => 'action', 'value' => 'Logs::getLogType($data->action)', 'filter' => Logs::getLogType(FALSE, TRUE)), array('class' => 'bootstrap3.widgets.BsButtonColumn', 'template' => '{view} {delete}'))));
示例7: actionCreateProject
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreateProject()
{
// check if user has permissions to createProjects
if (Yii::app()->user->checkAccess('createProjects') && Yii::app()->user->checkAccess('permissionsConfiguration') && Yii::app()->user->IsAdministrator) {
// create Projects Object
$model = new Projects();
// if Projects form exist
if (isset($_POST['Projects'])) {
// set form elements to Projects model attributes
$model->attributes = $_POST['Projects'];
// validate and save
if ($model->save()) {
// Create relation between user and project (this user will be first manager)
$modelForm = new ProjectsHasUsersForm();
$modelForm->project_id = $model->primaryKey;
$modelForm->user_id = Yii::app()->user->id;
$modelForm->isManager = 1;
$modelForm->saveUser();
// Select current project has default selection project
Yii::app()->user->setState('project_selected', $model->primaryKey);
Yii::app()->user->setState('project_selectedName', $model->project_name);
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ProjectCreated', 'log_resourceid' => $model->primaryKey, 'log_type' => Logs::LOG_ASSIGNED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->primaryKey);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to create page
Yii::app()->controller->redirect(Yii::app()->createUrl('projects/view', array('id' => $model->primaryKey)));
}
}
$this->layout = 'column2';
// output create page
$this->render('../projects/create', array('model' => $model, 'companies' => Companies::model()->findCompanyList(Yii::app()->user->id), 'currencies' => Currencies::model()->findAll()));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例8: actionCreate
/**
* Creates a new model.
*/
public function actionCreate()
{
// create Comments Object
$model = new Comments();
// if Comments form exist
if (isset($_POST['Comments'])) {
// set form elements to Comments model attributes
$model->attributes = $_POST['Comments'];
$module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
// set module_id finded to model
$model->module_id = $module->module_id;
$project = Yii::app()->user->getState('project_selected');
$model->project_id = $project;
// validate and save
if ($model->save()) {
// create an instance of file uploaded
$image = CUploadedFile::getInstancesByName('Comment');
// if file upload exist
if (count($image > 0)) {
// for each file uploaded
for ($i = 0; $i < count($image); $i++) {
// create an Document object
$modeldocs = new Documents();
$modeldocs->image = $image[$i];
if (!$modeldocs->image->getError()) {
// name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
$this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
// set the extension file uploaded
$extension = $modeldocs->image->getExtensionName();
// if no error saving file
if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
$modeldocs->project_id = $project;
$modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30);
$modeldocs->document_description = $model->comment_text;
$modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
$modeldocs->document_revision = '1';
$modeldocs->document_uploadDate = date("Y-m-d");
$modeldocs->document_type = $modeldocs->image->getType();
$modeldocs->document_baseRevision = date('dmYHis');
$modeldocs->user_id = Yii::app()->user->id;
$modeldocs->comment_id = $model->primaryKey;
// save file uploaded as document
if ($modeldocs->save()) {
Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk'));
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors());
}
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError'));
}
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors'));
}
}
}
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project);
Logs::model()->saveLog($attributes);
// find project managers to sent comment via mail
$recipientsList = array();
$ProjectManagers = Projects::model()->findManagersByProject($project);
$managersArray = array();
foreach ($ProjectManagers as $manager) {
$managersArray['email'] = $manager->user_email;
$managersArray['name'] = $manager->CompleteName;
array_push($recipientsList, $managersArray);
}
// find task owners to send comment via mail
if ($module->module_name == 'tasks') {
$collaborators = Projects::model()->findAllUsersByProject($project);
$ColaboratorsArray = array();
foreach ($collaborators as $colaborator) {
$ColaboratorsArray['email'] = $colaborator->user_email;
$ColaboratorsArray['name'] = $colaborator->CompleteName;
// avoid to repeat email address
if (!in_array($ColaboratorsArray, $recipientsList)) {
array_push($recipientsList, $ColaboratorsArray);
}
}
}
// finding resource title
switch ($module->module_name) {
case "budgets":
$resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title;
break;
case "invoices":
$resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number;
break;
case "expenses":
$resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name;
break;
case "documents":
$resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name;
break;
case "milestones":
$resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title;
break;
//.........這裏部分代碼省略.........
示例9: actionUpdate
/**
* Updates a particular model.
* @param integer $_GET['id'] the ID of the model to be updated
* @return update view
*/
public function actionUpdate()
{
// check if user has permissions to updateClients
if (Yii::app()->user->checkAccess('updateClients')) {
// get Clients object from $id parameter
$model = $this->loadModel();
// find client user data
$modelUsers = Users::model()->together()->findByPk($model->user_id);
// current user password
$tmppw = $modelUsers->user_password;
// if client hasn't address create an Address object, else load
if (!empty($model->address_id)) {
$address = Address::model()->findByPk($modelUsers->address_id);
} else {
$address = new Address();
}
// only users with administration rights or own user can update his profiles
if ($modelUsers->user_id == Yii::app()->user->id || Yii::app()->user->IsAdministrator) {
// if Users and Address form exist
if (isset($_POST['Users']) && isset($_POST['Address'])) {
// set form elements to Users model attributes
$modelUsers->attributes = $_POST['Users'];
// set form elements to Address model attributes
$address->attributes = $_POST['Address'];
// if current password is different to new password
if (isset($_POST['Users']['user_password'])) {
$modelUsers->user_password = md5($modelUsers->user_password);
}
// validate both models
$valid = $address->validate();
$valid = $modelUsers->validate() && $valid;
if ($valid) {
// save address
$address->save(false);
$modelUsers->address_id = $address->primaryKey;
// save user
if ($modelUsers->save(false)) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ClientUpdated', 'log_resourceid' => $model->client_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to view page
$this->redirect(array('view', 'id' => $model->client_id));
}
}
}
$this->render('update', array('model' => $modelUsers, 'address' => $address));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例10: actionUpdate
/**
* Updates a particular model.
* @return update view
*/
public function actionUpdate()
{
// check if user has permissions to updateCompanies
if (Yii::app()->user->checkAccess('updateCompanies')) {
// get Company object from $id parameter
$model = $this->loadModel();
// if company hasn't address create an Address object, else load
if (!empty($model->address_id)) {
$address = Address::model()->findByPk($model->address_id);
} else {
$address = new Address();
}
// only users with administration rights or own user can update his profiles
if (Yii::app()->user->IsAdministrator) {
// if Company form exist
if (isset($_POST['Companies'])) {
// set form elements to Companies model attributes
$model->attributes = $_POST['Companies'];
// set form elements to Address model attributes
$address->attributes = $_POST['Address'];
// validate both models
$valid = $address->validate();
$valid = $model->validate() && $valid;
if ($valid) {
// save address
$address->save(false);
$model->address_id = $address->primaryKey;
// save company
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CompanyUpdated', 'log_resourceid' => $model->company_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to view page
$this->redirect(array('view', 'id' => $model->company_id));
}
}
}
}
$this->render('update', array('model' => $model, 'address' => $address));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例11: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
// check if user has permissions to updateSecuences
if (Yii::app()->user->checkAccess('updateSecuences')) {
// get Projects object from id parameter
$model = $this->loadModel($id);
// verify Secuences form was used
if (isset($_POST['Secuences'])) {
// set form elements to secuences model attributes
$model->attributes = $_POST['Secuences'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'SecuenceUpdated', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => 'cases', 'project_id' => $model->Cases->project_id);
Logs::model()->saveLog($attributes);
// redirect to prevent F5 keypress
$this->redirect(array('cases/view', 'id' => $model->case_id));
}
}
// output update view
$this->render('update', array('model' => $model, 'types' => SecuenceTypes::model()->findAll()));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例12: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionUpdate()
{
// check if user has permissions to updateProjects
if (Yii::app()->user->checkAccess('updateProjects')) {
if (Yii::app()->user->isManager) {
// get Projects object from $_GET[id] parameter
$model = $this->loadModel();
// if Projects form exist
if (isset($_POST['Projects'])) {
// set form elements to Projects model attributes
$model->attributes = $_POST['Projects'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ProjectUpdated', 'log_resourceid' => $model->project_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to create page
$this->redirect(array('view', 'id' => $model->project_id));
}
}
// output update page
$this->render('update', array('model' => $model, 'companies' => Companies::model()->findCompanyList(Yii::app()->user->id), 'currencies' => Currencies::model()->findAll()));
} else {
Yii::app()->controller->redirect(array("projects/view", 'id' => $_GET['id']));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例13: actionUpdate
/**
* Updates a particular model.
* @return update view
*/
public function actionUpdate()
{
// check if user has permissions to updateInvoices
if (Yii::app()->user->checkAccess('updateInvoices')) {
// get Invoices object from $_GET['id'] parameter
$model = $this->loadModel();
// find all budgets relateds to current project
$Budgets = Budgets::model()->findBudgetsByProjects(Yii::app()->user->getState('project_selected'));
// check if invoice hasn�t status cancelled, accepted or closed
if ($model->status_id != Status::STATUS_CANCELLED && $model->status_id != Status::STATUS_ACCEPTED && $model->status_id != Status::STATUS_CLOSED) {
// only managers can update budgets
if (Yii::app()->user->IsManager) {
// if Invoices form exist
if (isset($_POST['Invoices'])) {
// set form elements to Invoices model attributes
$model->attributes = $_POST['Invoices'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'InvoiceUpdated', 'log_resourceid' => $model->invoice_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to view page
$this->redirect(array('view', 'id' => $model->invoice_id));
}
}
$this->render('update', array('invoice' => $model, 'budgets' => $Budgets));
} else {
Yii::app()->controller->redirect(array("invoices/view", 'id' => $model->invoice_id));
}
} else {
Yii::app()->controller->redirect(array("invoices/view", 'id' => $model->invoice_id));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例14: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
if (Yii::app()->user->checkAccess('updateTasks')) {
$allowEdit = false;
$model = $this->loadModel($id);
if ($model->status_id != Status::STATUS_CANCELLED && $model->status_id != Status::STATUS_ACCEPTED && $model->status_id != Status::STATUS_CLOSED) {
if ($model->user_id == Yii::app()->user->id) {
$allowEdit = true;
}
$Milestones = Milestones::model()->findMilestonesByProject($model->project_id);
$Cases = Cases::model()->findCasesByProject($model->project_id);
if (isset($_POST['Tasks'])) {
$model->attributes = $_POST['Tasks'];
$model->user_id = Yii::app()->user->id;
$model->task_startDate = date("Y-m-d");
//new CDbExpression('NOW()');
if ($model->save()) {
// Guardar log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'TaskUpdated', 'log_resourceid' => $model->task_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
$this->redirect(array('view', 'id' => $model->task_id));
}
}
$this->render('update', array('model' => $model, 'status' => Status::model()->findAll(), 'types' => TaskTypes::model()->findAll(), 'stages' => TaskStages::model()->findAll(), 'milestones' => $Milestones, 'cases' => $Cases, 'allowEdit' => $allowEdit));
} else {
Yii::app()->controller->redirect(array("tasks/view", 'id' => $model->task_id));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例15: actionUpdate
/**
* Updates a particular model.
* @param integer $id the ID of the model to be updated
* @return update view
*/
public function actionUpdate($id)
{
// check if user has permissions to updateCases
if (Yii::app()->user->checkAccess('updateCases')) {
// get Cases object from $_GET[id] parameter
$model = $this->loadModel($id);
// only managers can update Cases
if (Yii::app()->user->IsManager) {
// if Cases form exist
if (isset($_POST['Cases'])) {
// set form elements to Cases model attributes
$model->attributes = $_POST['Cases'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CaseUpdated', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
// to prevent F5 keypress, redirect to view page
$this->redirect(array('view', 'id' => $model->case_id));
}
}
$this->render('update', array('model' => $model));
} else {
Yii::app()->controller->redirect(array("cases/view", 'id' => $model->case_id));
}
} else {
throw new CHttpException(403, Yii::t('cases', '403_ErrorCase'));
}
}