本文整理汇总了PHP中Audit::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Audit::add方法的具体用法?PHP Audit::add怎么用?PHP Audit::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audit
的用法示例。
在下文中一共展示了Audit::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionList
/**
* Lists local authorities from Commissioning Body Service
*
* @throws CHttpException
*/
public function actionList()
{
\Audit::add('admin-CommissioningBodyService', 'list');
if (!($commissioning_bt = \CommissioningBodyType::model()->findByAttributes(array('shortname' => 'LA')))) {
throw new \CHttpException(500, 'Local Authority Commissioning Body Type is not configured.');
}
$service_type = \CommissioningBodyServiceType::model()->findByAttributes(array('shortname' => 'SSD'));
$data['title'] = 'CVI Social Services Depts.';
$data['commissioning_bt'] = $commissioning_bt;
$data['service_type'] = $service_type;
$data['return_url'] = '/OphCoCvi/localAuthoritiesAdmin/list';
$data['base_data_url'] = 'OphCoCvi/localAuthoritiesAdmin/';
$this->render('//admin/commissioning_body_services', $data);
}
示例2: actionManualAdd
public function actionManualAdd()
{
$worklist = new Worklist();
if (!empty($_POST)) {
$worklist->attributes = $_POST['Worklist'];
if ($this->manager->createWorklistForUser($worklist)) {
Audit::add('Manual-Worklist', 'add', $worklist->id);
$this->redirect('/worklist/manual');
} else {
$errors = $worklist->getErrors();
}
}
$this->render('//worklist/manual/add', array('worklist' => $worklist, 'errors' => @$errors));
}
示例3: actionEditTreatmentDrug
public function actionEditTreatmentDrug($id)
{
if (!($model = OphTrIntravitrealinjection_Treatment_Drug::model()->findByPk((int) $id))) {
throw new Exception('Treatment drug not found with id ' . $id);
}
if (isset($_POST['OphTrIntravitrealinjection_Treatment_Drug'])) {
$model->attributes = $_POST['OphTrIntravitrealinjection_Treatment_Drug'];
if ($model->save()) {
Audit::add('admin', 'update', $model->id, null, array('module' => 'OphTrIntravitrealinjection', 'model' => 'OphTrIntravitrealinjection_Treatment_Drug'));
Yii::app()->user->setFlash('success', 'Treatment drug updated');
$this->redirect(array('ViewTreatmentDrugs'));
}
}
$this->render('update', array('model' => $model, 'title' => 'Treatment Drug', 'cancel_uri' => '/OphTrIntravitrealinjection/admin/viewTreatmentDrugs'));
}
示例4: actionIndex
/**
* Generate a list of current tickets.
*/
public function actionIndex()
{
unset(Yii::app()->session['patientticket_ticket_in_review']);
AutoSaveTicket::clear();
$cat_id = Yii::app()->request->getParam('cat_id', null);
$queueset_id = Yii::app()->request->getParam('queueset_id', null);
$select_queue_set = Yii::app()->request->getParam('select_queue_set', null);
if (!$cat_id) {
throw new \CHttpException(404, 'Category ID required');
}
if ($qs_id = $queueset_id && $select_queue_set) {
$this->redirect(array("/PatientTicketing/default/?queueset_id={$qs_id}&cat_id=" . $cat_id));
}
if ($queueset_id) {
$qs_id = $queueset_id;
}
$qsc_svc = Yii::app()->service->getService(self::$QUEUESETCATEGORY_SERVICE);
if (!($category = $qsc_svc->readActive((int) $cat_id))) {
throw new \CHttpException(404, 'Invalid category id');
}
$queueset = null;
$tickets = null;
$pages = null;
$patient_filter = null;
if ($queuesets = $qsc_svc->getCategoryQueueSetsForUser($category, Yii::app()->user->id)) {
// default to the single queueset if that is all that is available to the user
if (count($queuesets) > 1) {
if ($qs_id) {
foreach ($queuesets as $qs) {
if ($qs->getID() == $qs_id) {
$queueset = $qs;
break;
}
}
}
} else {
$queueset = $queuesets[0];
}
if ($queueset) {
// build the filter
$filter_keys = array('queue-ids', 'priority-ids', 'subspecialty-id', 'firm-id', 'my-tickets', 'closed-tickets');
$filter_options = array();
if (empty($_POST)) {
if (($filter_options = Yii::app()->session['patientticket_filter']) && @$filter_options['category-id'] == $category->getID()) {
foreach ($filter_options as $k => $v) {
$_POST[$k] = $v;
}
}
} else {
foreach ($filter_keys as $k) {
if (isset($_POST[$k])) {
$filter_options[$k] = $_POST[$k];
}
}
$filter_options['category-id'] = $category->getID();
}
Yii::app()->session['patientticket_filter'] = $filter_options;
list($criteria, $patient_filter) = $this->buildTicketFilterCriteria($filter_options, $queueset);
$count = models\Ticket::model()->count($criteria);
$pages = new \CPagination($count);
$pages->pageSize = $this->page_size;
$pages->applyLimit($criteria);
// get tickets that match criteria
$tickets = models\Ticket::model()->findAll($criteria);
\Audit::add('queueset', 'view', $queueset->getId());
}
}
// render
$this->render('index', array('category' => $category, 'queueset' => $queueset, 'tickets' => $tickets, 'patient_filter' => $patient_filter, 'pages' => $pages, 'cat_id' => $cat_id));
}
示例5: actionDelete
public function actionDelete()
{
if (isset($_POST['patientMergeRequestIds'])) {
$criteria = new CDbCriteria();
$criteria->condition = 't.status = ' . PatientMergeRequest::STATUS_NOT_PROCESSED;
$requests = PatientMergeRequest::model()->findAllByPk($_POST['patientMergeRequestIds'], $criteria);
foreach ($requests as $request) {
$request->deleted = 1;
if ($request->save()) {
Audit::add('Patient Merge', 'Patient Merge Request flagged as deleted. id: ' . $request->id);
} else {
throw new Exception('Unable to save Patient Merge Request: ' . print_r($request->getErrors(), true));
}
}
}
echo CJavaScript::jsonEncode(array('success' => 1));
Yii::app()->end();
}
示例6: actionDeleteAnaestheticAgent
public function actionDeleteAnaestheticAgent($id)
{
$agent = AnaestheticAgent::model()->findByPk($id);
if (!$agent) {
throw new CHttpException(404, 'Anaesthetic Agent not found: ' . $id);
}
if (Yii::app()->request->isPostRequest) {
$agent->active = 0;
if (!$agent->save()) {
throw new CHttpException(500, 'Unable to delete Anaesthetic Agent: ' . $agent->name);
}
Audit::add('admin', 'delete', $id, null, array('model' => 'AnaestheticAgent'));
$this->redirect('/admin/viewAnaestheticAgent');
}
Audit::add('admin', 'view', $id, null, array('model' => 'AnaestheticAgent'));
$this->render('/admin/deleteanaestheticagent', array('agent' => $agent));
}
示例7: actionEditEmailRecipient
public function actionEditEmailRecipient($id)
{
$model = OphCoTherapyapplication_Email_Recipient::model()->findByPk((int) $id);
if (isset($_POST['OphCoTherapyapplication_Email_Recipient'])) {
$model->attributes = $_POST['OphCoTherapyapplication_Email_Recipient'];
if ($model->save()) {
Audit::add('admin', 'update', serialize($model->attributes), false, array('module' => 'OphCoTherapyapplication', 'model' => 'OphCoTherapyapplication_Email_Recipient'));
Yii::app()->user->setFlash('success', 'Email recipient updated');
$this->redirect(array('viewEmailRecipients'));
}
}
$this->render('update', array('model' => $model, 'title' => 'Email Recipient', 'cancel_uri' => '/OphCoTherapyapplication/admin/viewEmailRecipients'));
}
示例8: actionSearch
public function actionSearch()
{
// Check that we have a valid set of search criteria
$search_terms = array('hos_num' => null, 'nhs_num' => null, 'first_name' => null, 'last_name' => null);
foreach ($search_terms as $search_term => $search_value) {
if (isset($_GET[$search_term]) && ($search_value = trim($_GET[$search_term]))) {
// Pad hos_num
if ($search_term == 'hos_num') {
$search_value = sprintf('%07s', $search_value);
}
$search_terms[$search_term] = $search_value;
}
}
// if we are on a dev environment, this allows more flexible search terms (i.e. just a first name or surname - useful for testing
// the multiple search results view. If we are live, enforces controls over search terms.
if (!YII_DEBUG && !$search_terms['hos_num'] && !$search_terms['nhs_num'] && !($search_terms['first_name'] && $search_terms['last_name'])) {
Yii::app()->user->setFlash('warning.invalid-search', 'Please enter a valid search.');
$this->redirect(Yii::app()->homeUrl);
}
$search_terms = CHtml::encodeArray($search_terms);
switch (@$_GET['sort_by']) {
case 0:
$sort_by = 'hos_num*1';
break;
case 1:
$sort_by = 'title';
break;
case 2:
$sort_by = 'first_name';
break;
case 3:
$sort_by = 'last_name';
break;
case 4:
$sort_by = 'dob';
break;
case 5:
$sort_by = 'gender';
break;
case 6:
$sort_by = 'nhs_num*1';
break;
default:
$sort_by = 'hos_num*1';
}
$sort_dir = @$_GET['sort_dir'] == 0 ? 'asc' : 'desc';
$page_num = (int) @$_GET['page_num'];
$page_size = 20;
$model = new Patient();
$model->hos_num = $search_terms['hos_num'];
$model->nhs_num = $search_terms['nhs_num'];
$dataProvider = $model->search(array('currentPage' => $page_num, 'pageSize' => $page_size, 'sortBy' => $sort_by, 'sortDir' => $sort_dir, 'first_name' => CHtml::decode($search_terms['first_name']), 'last_name' => CHtml::decode($search_terms['last_name'])));
$nr = $model->search_nr(array('first_name' => CHtml::decode($search_terms['first_name']), 'last_name' => CHtml::decode($search_terms['last_name'])));
if ($nr == 0) {
Audit::add('search', 'search-results', implode(',', $search_terms) . " : No results");
$message = 'Sorry, no results ';
if ($search_terms['hos_num']) {
$message .= 'for Hospital Number <strong>"' . $search_terms['hos_num'] . '"</strong>';
} elseif ($search_terms['nhs_num']) {
$message .= 'for NHS Number <strong>"' . $search_terms['nhs_num'] . '"</strong>';
} elseif ($search_terms['first_name'] && $search_terms['last_name']) {
$message .= 'for Patient Name <strong>"' . $search_terms['first_name'] . ' ' . $search_terms['last_name'] . '"</strong>';
} else {
$message .= 'found for your search.';
}
Yii::app()->user->setFlash('warning.no-results', $message);
$this->redirect(Yii::app()->homeUrl);
} elseif ($nr == 1) {
foreach ($dataProvider->getData() as $item) {
$this->redirect(array('patient/view/' . $item->id));
}
} else {
$this->renderPatientPanel = false;
$pages = ceil($nr / $page_size);
$this->render('results', array('data_provider' => $dataProvider, 'pages' => $pages, 'page_num' => $page_num, 'items_per_page' => $page_size, 'total_items' => $nr, 'search_terms' => $search_terms, 'sort_by' => (int) @$_GET['sort_by'], 'sort_dir' => (int) @$_GET['sort_dir']));
}
}
示例9: actionDeleteCommissioningBodyServiceTypes
public function actionDeleteCommissioningBodyServiceTypes()
{
$criteria = new CDbCriteria();
$criteria->addInCondition('id', @$_POST['commissioning_body_service_type']);
if (!($er = CommissioningBodyServiceType::model()->deleteAll($criteria))) {
throw new Exception("Unable to delete CommissioningBodyServiceTypes: " . print_r($er->getErrors(), true));
}
Audit::add('admin-CommissioningBodyServiceType', 'delete');
echo "1";
}
示例10: audit
/**
* @param $type
* @throws Exception
*/
protected function audit($type, $data = null)
{
Audit::add('admin-' . $this->modelName, $type, $data);
}
示例11: genericAdmin
/**
* Allows generic CRUD operations on models.
*
* @param string $title The title of the form to be rendered
* @param string $model The model for which we are generating a form
* @param array $options An array of options that will configure how the form is generated.
* label_field - Will set which field is displayed as a text input for the model
* extra_fields - An array of arrays for which extra fields to render. Each array should contain
* an attribute of the model in assigned to field. Passing a type and model will allow
* either a dropdown or search box for finding related objects eg:
* array(
* 'field' => 'site_id',
* 'type' => 'lookup',
* 'model' => 'Site'
* ),
* filter_fields - Will allow you to filter results, expects an array the same as extra_fields
* @param int $key - if provided will only generate a single row for a null instance of the $model (for ajax additions)
*/
protected function genericAdmin($title, $model, array $options = array(), $key = null)
{
$options = array_merge(array('label_field' => $model::SELECTION_LABEL_FIELD, 'extra_fields' => array(), 'filter_fields' => array(), 'filters_ready' => true, 'label_extra_field' => false), $options);
$columns = $model::model()->metadata->columns;
foreach ($options['extra_fields'] as $extraKey => $extraField) {
switch ($extraField['type']) {
case 'lookup':
$options['extra_fields'][$extraKey]['allow_null'] = $columns[$extraField['field']]->allowNull;
break;
}
if ($extraField['field'] === $options['label_field']) {
$options['label_extra_field'] = true;
}
}
foreach ($options['filter_fields'] as $filterKey => $filterField) {
$options['filter_fields'][$filterKey]['value'] = null;
if (isset($_GET[$filterField['field']])) {
$options['filter_fields'][$filterKey]['value'] = $_GET[$filterField['field']];
}
if ($options['filter_fields'][$filterKey]['value'] === null && !$columns[$filterField['field']]->allowNull) {
$options['filters_ready'] = false;
}
}
$items = array();
$errors = array();
$options['display_order'] = false;
if ($key !== null) {
$items = array($key => new $model());
$options['get_row'] = true;
if ($model::model()->hasAttribute('display_order')) {
$options['display_order'] = true;
}
$this->renderPartial('//admin/generic_admin', array('title' => $title, 'model' => $model, 'items' => $items, 'errors' => $errors, 'options' => $options), false, true);
} else {
if ($options['filters_ready']) {
if (Yii::app()->request->isPostRequest) {
$tx = Yii::app()->db->beginTransaction();
$j = 0;
foreach ((array) @$_POST['id'] as $i => $id) {
if ($id) {
$item = $model::model()->findByPk($id);
$new = false;
} else {
$item = new $model();
$new = true;
}
$attributes = $item->getAttributes();
if (!empty($_POST[$options['label_field']][$i])) {
$item->{$options['label_field']} = $_POST[$options['label_field']][$i];
if ($item->hasAttribute('display_order')) {
$options['display_order'] = true;
$item->display_order = $j + 1;
}
if (array_key_exists('active', $attributes)) {
$item->active = isset($_POST['active'][$i]) || $item->isNewRecord ? 1 : 0;
}
foreach ($options['extra_fields'] as $field) {
$name = $field['field'];
$item->{$name} = @$_POST[$name][$i];
}
if ($item->hasAttribute('default')) {
if (isset($_POST['default']) && $_POST['default'] !== 'NONE' && $_POST['default'] == $j) {
$item->default = 1;
} else {
$item->default = 0;
}
}
foreach ($options['filter_fields'] as $field) {
$item->{$field['field']} = $field['value'];
}
if ($new || $item->getAttributes() != $attributes) {
if (!$item->save()) {
$errors = $item->getErrors();
foreach ($errors as $error) {
$errors[$i] = $error[0];
}
}
Audit::add('admin', $new ? 'create' : 'update', $item->primaryKey, null, array('module' => is_object($this->module) ? $this->module->id : 'core', 'model' => $model::getShortModelName()));
}
$items[] = $item;
++$j;
}
//.........这里部分代码省略.........
示例12: setPermisssionedUsers
/**
* @param int $queueset_id
* @param int $user_ids[]
*
* @throws \Exception
*/
public function setPermisssionedUsers($queueset_id, $user_ids, $role = null)
{
$qs = $this->readModel($queueset_id);
$users = array();
foreach ($user_ids as $id) {
if (!($user = \User::model()->findByPk($id))) {
throw new \Exception("User not found for id {$id}");
}
$users[] = $user;
}
$role_item = null;
if ($role) {
$role_item = Yii::app()->authManager->getAuthItem($role);
if (!$role_item) {
throw new \Exception("Unrecognised role {$role} for permissioning");
}
}
$transaction = Yii::app()->db->getCurrentTransaction() === null ? Yii::app()->db->beginTransaction() : false;
try {
$qs->permissioned_users = $users;
$qs->save();
\Audit::add('admin', 'set-permissions', $qs->id, null, array('module' => 'PatientTicketing', 'model' => $qs->getShortModelName()));
if ($role_item) {
foreach ($users as $user) {
if (!$role_item->getAssignment($user->id)) {
$role_item->assign($user->id);
\Audit::add('admin-User', 'assign-role', "{$user->id}:{$role_item->name}");
}
}
}
if ($transaction) {
$transaction->commit();
}
} catch (\Exception $e) {
if ($transaction) {
$transaction->rollback();
}
throw $e;
}
}
示例13: deactivateQueue
/**
* Deactivate a Queue, and if $cascade is true, then deactivate it's children.
*
* @param $queue
* @param bool $cascade
*/
protected function deactivateQueue($queue, $cascade = true)
{
$queue->active = false;
if ($cascade) {
foreach ($queue->outcome_queues as $oc) {
$this->deactivateQueue($oc);
}
}
$queue->save();
\Audit::add('admin', 'update', $queue->id, null, array('module' => 'PatientTicketing', 'model' => $queue->getShortModelName()));
}
示例14: updateEventsEpisodeId
/**
* Moving event from one episode to another.
*
* @param int $newEpisodeId
* @param array $events
*
* @return bool
*
* @throws Exception
*/
public function updateEventsEpisodeId($newEpisodeId, $events)
{
foreach ($events as $event) {
$msg = 'Event ' . $event->id . ' moved from Episode ' . $event->episode_id . ' to ' . $newEpisodeId;
$event->episode_id = $newEpisodeId;
if ($event->save()) {
$this->addLog($msg);
Audit::add('Patient Merge', 'Event moved episode', $msg);
} else {
throw new Exception('Failed to save Event: ' . print_r($event->errors, true));
}
}
return true;
}
示例15: actionSwitchEnabledSessionUnavailableReason
/**
* Disable or enable a OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason.
*
* @throws Exception
*/
public function actionSwitchEnabledSessionUnavailableReason()
{
if (!($reason = OphTrOperationbooking_Operation_Session_UnavailableReason::model()->findByPk(@$_POST['id']))) {
throw new Exception('Session Unavailable Reason not found: ' . @$_POST['id']);
}
if ($reason->enabled) {
$reason->enabled = 0;
$action = 'disabled';
} else {
$reason->enabled = 1;
$action = 'enabled';
}
if (!$reason->save()) {
throw new Exception('Unexpected error changing enabled status for Session Unavailable Reason ' . print_r($reason->getErrors(), true));
}
Audit::add('admin', $action, serialize($_POST), false, array('module' => 'OphTrOperationbooking', 'model' => 'OphTrOperationbooking_Operation_Session_UnavailableReason'));
}