本文整理汇总了PHP中API::User方法的典型用法代码示例。如果您正苦于以下问题:PHP API::User方法的具体用法?PHP API::User怎么用?PHP API::User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API::User方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAuthentication
public static function checkAuthentication($sessionid)
{
try {
if ($sessionid !== null) {
self::$data = API::User()->checkAuthentication($sessionid);
}
if ($sessionid === null || empty(self::$data)) {
self::setDefault();
self::$data = API::User()->login(array('user' => ZBX_GUEST_USER, 'password' => '', 'userData' => true));
if (empty(self::$data)) {
clear_messages(1);
throw new Exception();
}
$sessionid = self::$data['sessionid'];
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
error(_('GUI access disabled.'));
throw new Exception();
}
zbx_setcookie('zbx_sessionid', $sessionid, self::$data['autologin'] ? time() + SEC_PER_DAY * 31 : 0);
return true;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
示例2: checkAuthentication
public static function checkAuthentication($sessionId)
{
try {
if ($sessionId !== null) {
self::$data = API::User()->checkAuthentication(array($sessionId));
}
if ($sessionId === null || empty(self::$data)) {
self::setDefault();
self::$data = API::User()->login(array('user' => ZBX_GUEST_USER, 'password' => '', 'userData' => true));
if (empty(self::$data)) {
clear_messages(1);
throw new Exception();
}
$sessionId = self::$data['sessionid'];
}
if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
throw new Exception();
}
self::setSessionCookie($sessionId);
return $sessionId;
} catch (Exception $e) {
self::setDefault();
return false;
}
}
示例3: init
/**
* Init class
* @return true
*/
public static function init()
{
global $zbp;
// Set Z-BlogPHP Enviroment
$zbp->option['ZC_RUNINFO_DISPLAY'] = false;
self::$Route = API_Route::getInstance();
self::$IO = API_IO::getInstance(isset($_SERVER['ACCEPT']) ? $_SERVER['ACCEPT'] : 'application/json');
self::$User = API_User::getInstance();
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(API_PATH . '/route'), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $path) {
$fileName = $path->__toString();
if ($path->isFile()) {
include $fileName;
}
}
return true;
}
示例4: getActionMessages
/**
* Get action messages.
*
* @param array $alerts
* @param string $alerts[n]['alertid']
* @param string $alerts[n]['userid']
* @param int $alerts[n]['alerttype']
* @param array $alerts[n]['mediatypes']
* @param string $alerts[n]['clock']
* @param int $alerts[n]['esc_step']
* @param int $alerts[n]['status']
* @param int $alerts[n]['retries']
* @param string $alerts[n]['subject']
* @param string $alerts[n]['sendto']
* @param string $alerts[n]['message']
* @param string $alerts[n]['error']
*
* @return CTableInfo
*/
function getActionMessages(array $alerts)
{
$dbUsers = API::User()->get(array('output' => array('userid', 'alias', 'name', 'surname'), 'userids' => zbx_objectValues($alerts, 'userid'), 'preservekeys' => true));
$table = new CTableInfo(_('No actions found.'));
$table->setHeader(array(_('Time'), _('Type'), _('Status'), _('Retries left'), _('Recipient(s)'), _('Message'), _('Info')));
foreach ($alerts as $alert) {
if ($alert['alerttype'] != ALERT_TYPE_MESSAGE) {
continue;
}
$mediaType = array_pop($alert['mediatypes']);
$time = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']);
if ($alert['esc_step'] > 0) {
$time = array(bold(_('Step') . NAME_DELIMITER), $alert['esc_step'], br(), bold(_('Time') . NAME_DELIMITER), br(), $time);
}
if ($alert['status'] == ALERT_STATUS_SENT) {
$status = new CSpan(_('sent'), 'green');
$retries = new CSpan(SPACE, 'green');
} elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) {
$status = new CSpan(_('In progress'), 'orange');
$retries = new CSpan(ALERT_MAX_RETRIES - $alert['retries'], 'orange');
} else {
$status = new CSpan(_('not sent'), 'red');
$retries = new CSpan(0, 'red');
}
$recipient = $alert['userid'] ? array(bold(getUserFullname($dbUsers[$alert['userid']])), BR(), $alert['sendto']) : $alert['sendto'];
$message = array(bold(_('Subject') . NAME_DELIMITER), br(), $alert['subject'], br(), br(), bold(_('Message') . NAME_DELIMITER));
array_push($message, BR(), zbx_nl2br($alert['message']));
if (zbx_empty($alert['error'])) {
$info = '';
} else {
$info = new CDiv(SPACE, 'status_icon iconerror');
$info->setHint($alert['error'], 'on');
}
$table->addRow(array(new CCol($time, 'top'), new CCol(isset($mediaType['description']) ? $mediaType['description'] : '', 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($recipient, 'top'), new CCol($message, 'wraptext top'), new CCol($info, 'wraptext top')));
}
return $table;
}
示例5: access_deny
} else {
access_deny(ACCESS_DENY_PAGE);
}
}
// login via form
if (isset($_REQUEST['enter']) && $_REQUEST['enter'] == _('Sign in')) {
// try to login
$autoLogin = getRequest('autologin', 0);
DBstart();
$loginSuccess = CWebUser::login(getRequest('name', ''), getRequest('password', ''));
DBend(true);
if ($loginSuccess) {
// save remember login preference
$user = array('autologin' => $autoLogin);
if (CWebUser::$data['autologin'] != $autoLogin) {
API::User()->updateProfile($user);
}
$request = getRequest('request');
$url = zbx_empty($request) ? CWebUser::$data['url'] : $request;
if (zbx_empty($url) || $url == $page['file']) {
$url = 'dashboard.php';
}
redirect($url);
exit;
} else {
CWebUser::checkAuthentication(null);
}
} else {
// login the user from the session, if the session id is empty - login as a guest
CWebUser::checkAuthentication(CWebUser::getSessionCookie());
}
示例6: addRelatedObjects
protected function addRelatedObjects(array $options, array $result)
{
$result = parent::addRelatedObjects($options, $result);
// adding users
if ($options['selectUsers'] !== null && $options['selectUsers'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'usrgrpid', 'userid', 'users_groups');
$dbUsers = API::User()->get(['output' => $options['selectUsers'], 'userids' => $relationMap->getRelatedIds(), 'getAccess' => $options['selectUsers'] == API_OUTPUT_EXTEND ? true : null, 'preservekeys' => true]);
$result = $relationMap->mapMany($result, $dbUsers, 'users');
}
// adding usergroup rights
if ($options['selectRights'] !== null && $options['selectRights'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'groupid', 'rightid', 'rights');
if (is_array($options['selectRights'])) {
$pk_field = $this->pk('rights');
$output_fields = [$pk_field => $this->fieldId($pk_field, 'r')];
foreach ($options['selectRights'] as $field) {
if ($this->hasField($field, 'rights')) {
$output_fields[$field] = $this->fieldId($field, 'r');
}
}
$output_fields = implode(',', $output_fields);
} else {
$output_fields = 'r.*';
}
$db_rights = DBfetchArray(DBselect('SELECT ' . $output_fields . ' FROM rights r' . ' WHERE ' . dbConditionInt('r.rightid', $relationMap->getRelatedIds()) . (self::$userData['type'] == USER_TYPE_SUPER_ADMIN ? '' : ' AND r.permission>' . PERM_DENY)));
$db_rights = zbx_toHash($db_rights, 'rightid');
foreach ($db_rights as &$db_right) {
unset($db_right['rightid'], $db_right['groupid']);
}
unset($db_right);
$result = $relationMap->mapMany($result, $db_rights, 'rights');
}
return $result;
}
示例7: CButton
$addUsrgrpBtn = new CButton('add', _('Add'), 'return PopUp("popup.php?dstfrm=action.edit&srctbl=usrgrp&srcfld1=usrgrpid&srcfld2=name&multiselect=1", 450, 450)', 'link_menu');
$addUsrgrpBtn->attr('id', 'addusrgrpbtn');
$usrgrpList->addRow(new CRow(new CCol($addUsrgrpBtn, null, 2), null, 'opmsgUsrgrpListFooter'));
$userList = new CTable(null, 'formElementTable');
$userList->setHeader(array(_('User'), _('Action')));
$userList->attr('style', 'min-width: 310px;');
$userList->setAttribute('id', 'opmsgUserList');
$addUserBtn = new CButton('add', _('Add'), 'return PopUp("popup.php?dstfrm=action.edit&srctbl=users&srcfld1=userid&srcfld2=fullname&multiselect=1", 450, 450)', 'link_menu');
$addUserBtn->attr('id', 'adduserbtn');
$userList->addRow(new CRow(new CCol($addUserBtn, null, 2), null, 'opmsgUserListFooter'));
// add participations
$usrgrpids = isset($this->data['new_operation']['opmessage_grp']) ? zbx_objectValues($this->data['new_operation']['opmessage_grp'], 'usrgrpid') : array();
$userids = isset($this->data['new_operation']['opmessage_usr']) ? zbx_objectValues($this->data['new_operation']['opmessage_usr'], 'userid') : array();
$usrgrps = API::UserGroup()->get(array('usrgrpids' => $usrgrpids, 'output' => array('name')));
order_result($usrgrps, 'name');
$users = API::User()->get(array('userids' => $userids, 'output' => array('alias', 'name', 'surname')));
order_result($users, 'alias');
foreach ($users as &$user) {
$user['fullname'] = getUserFullname($user);
}
unset($user);
$jsInsert = 'addPopupValues(' . zbx_jsvalue(array('object' => 'usrgrpid', 'values' => $usrgrps)) . ');';
$jsInsert .= 'addPopupValues(' . zbx_jsvalue(array('object' => 'userid', 'values' => $users)) . ');';
zbx_add_post_js($jsInsert);
$newOperationsTable->addRow(array(_('Send to User groups'), new CDiv($usrgrpList, 'objectgroup inlineblock border_dotted ui-corner-all')));
$newOperationsTable->addRow(array(_('Send to Users'), new CDiv($userList, 'objectgroup inlineblock border_dotted ui-corner-all')));
$mediaTypeComboBox = new CComboBox('new_operation[opmessage][mediatypeid]', $this->data['new_operation']['opmessage']['mediatypeid']);
$mediaTypeComboBox->addItem(0, '- ' . _('All') . ' -');
$dbMediaTypes = DBfetchArray(DBselect('SELECT mt.mediatypeid,mt.description' . ' FROM media_type mt' . whereDbNode('mt.mediatypeid')));
order_result($dbMediaTypes, 'description');
foreach ($dbMediaTypes as $dbMediaType) {
示例8: getUserFormData
function getUserFormData($userid, $isProfile = false)
{
$config = select_config();
$data = array('is_profile' => $isProfile);
if (isset($userid)) {
$users = API::User()->get(array('userids' => $userid, 'output' => API_OUTPUT_EXTEND));
$user = reset($users);
}
if (isset($userid) && (!isset($_REQUEST['form_refresh']) || isset($_REQUEST['register']))) {
$data['alias'] = $user['alias'];
$data['name'] = $user['name'];
$data['surname'] = $user['surname'];
$data['password1'] = null;
$data['password2'] = null;
$data['url'] = $user['url'];
$data['autologin'] = $user['autologin'];
$data['autologout'] = $user['autologout'];
$data['lang'] = $user['lang'];
$data['theme'] = $user['theme'];
$data['refresh'] = $user['refresh'];
$data['rows_per_page'] = $user['rows_per_page'];
$data['user_type'] = $user['type'];
$data['messages'] = getMessageSettings();
$userGroups = API::UserGroup()->get(array('userids' => $userid, 'output' => array('usrgrpid')));
$userGroup = zbx_objectValues($userGroups, 'usrgrpid');
$data['user_groups'] = zbx_toHash($userGroup);
$data['user_medias'] = array();
$dbMedia = DBselect('SELECT m.mediaid,m.mediatypeid,m.period,m.sendto,m.severity,m.active' . ' FROM media m' . ' WHERE m.userid=' . zbx_dbstr($userid));
while ($dbMedium = DBfetch($dbMedia)) {
$data['user_medias'][] = $dbMedium;
}
if ($data['autologout'] > 0) {
$_REQUEST['autologout'] = $data['autologout'];
}
} else {
$data['alias'] = getRequest('alias', '');
$data['name'] = getRequest('name', '');
$data['surname'] = getRequest('surname', '');
$data['password1'] = getRequest('password1', '');
$data['password2'] = getRequest('password2', '');
$data['url'] = getRequest('url', '');
$data['autologin'] = getRequest('autologin', 0);
$data['autologout'] = getRequest('autologout', 900);
$data['lang'] = getRequest('lang', 'en_gb');
$data['theme'] = getRequest('theme', THEME_DEFAULT);
$data['refresh'] = getRequest('refresh', 30);
$data['rows_per_page'] = getRequest('rows_per_page', 50);
$data['user_type'] = getRequest('user_type', USER_TYPE_ZABBIX_USER);
$data['user_groups'] = getRequest('user_groups', array());
$data['change_password'] = getRequest('change_password');
$data['user_medias'] = getRequest('user_medias', array());
// set messages
$data['messages'] = getRequest('messages', array());
if (!isset($data['messages']['enabled'])) {
$data['messages']['enabled'] = 0;
}
if (!isset($data['messages']['sounds.recovery'])) {
$data['messages']['sounds.recovery'] = 'alarm_ok.wav';
}
if (!isset($data['messages']['triggers.recovery'])) {
$data['messages']['triggers.recovery'] = 0;
}
if (!isset($data['messages']['triggers.severities'])) {
$data['messages']['triggers.severities'] = array();
}
$data['messages'] = array_merge(getMessageSettings(), $data['messages']);
}
// authentication type
if ($data['user_groups']) {
$data['auth_type'] = getGroupAuthenticationType($data['user_groups'], GROUP_GUI_ACCESS_INTERNAL);
} else {
$data['auth_type'] = $userid === null ? $config['authentication_type'] : getUserAuthenticationType($userid, GROUP_GUI_ACCESS_INTERNAL);
}
// set autologout
if ($data['autologin'] || !isset($data['autologout'])) {
$data['autologout'] = 0;
}
// set media types
if (!empty($data['user_medias'])) {
$mediaTypeDescriptions = array();
$dbMediaTypes = DBselect('SELECT mt.mediatypeid,mt.description FROM media_type mt WHERE ' . dbConditionInt('mt.mediatypeid', zbx_objectValues($data['user_medias'], 'mediatypeid')));
while ($dbMediaType = DBfetch($dbMediaTypes)) {
$mediaTypeDescriptions[$dbMediaType['mediatypeid']] = $dbMediaType['description'];
}
foreach ($data['user_medias'] as &$media) {
$media['description'] = $mediaTypeDescriptions[$media['mediatypeid']];
}
unset($media);
CArrayHelper::sort($data['user_medias'], array('description', 'sendto'));
}
// set user rights
if (!$data['is_profile']) {
$data['groups'] = API::UserGroup()->get(array('usrgrpids' => $data['user_groups'], 'output' => array('usrgrpid', 'name')));
order_result($data['groups'], 'name');
$group_ids = array_values($data['user_groups']);
if (count($group_ids) == 0) {
$group_ids = array(-1);
}
$db_rights = DBselect('SELECT r.* FROM rights r WHERE ' . dbConditionInt('r.groupid', $group_ids));
// deny beat all, read-write beat read
//.........这里部分代码省略.........
示例9: addRelatedObjects
protected function addRelatedObjects(array $options, array $result)
{
$result = parent::addRelatedObjects($options, $result);
// adding users
if ($options['selectUsers'] !== null && $options['selectUsers'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'usrgrpid', 'userid', 'users_groups');
$users = API::User()->get(array('output' => $options['selectUsers'], 'userids' => $relationMap->getRelatedIds(), 'getAccess' => $options['selectUsers'] == API_OUTPUT_EXTEND ? true : null, 'preservekeys' => true));
$result = $relationMap->mapMany($result, $users, 'users');
}
return $result;
}
示例10: getRequest
$data['autologout'] = getRequest('autologout');
// render view
$usersView = new CView('administration.users.edit', $data);
$usersView->render();
$usersView->show();
} else {
$sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'alias'));
$sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP));
CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
$data = array('config' => $config, 'sort' => $sortField, 'sortorder' => $sortOrder);
// get user groups
$data['userGroups'] = API::UserGroup()->get(array('output' => API_OUTPUT_EXTEND));
order_result($data['userGroups'], 'name');
// get users
$data['users'] = API::User()->get(array('usrgrpids' => $_REQUEST['filter_usrgrpid'] > 0 ? $_REQUEST['filter_usrgrpid'] : null, 'output' => API_OUTPUT_EXTEND, 'selectUsrgrps' => API_OUTPUT_EXTEND, 'getAccess' => 1, 'limit' => $config['search_limit'] + 1));
// sorting & paging
order_result($data['users'], $sortField, $sortOrder);
$data['paging'] = getPagingLine($data['users'], $sortOrder);
// set default lastaccess time to 0
foreach ($data['users'] as $user) {
$data['usersSessions'][$user['userid']] = array('lastaccess' => 0);
}
$dbSessions = DBselect('SELECT s.userid,MAX(s.lastaccess) AS lastaccess,s.status' . ' FROM sessions s' . ' WHERE ' . dbConditionInt('s.userid', zbx_objectValues($data['users'], 'userid')) . ' GROUP BY s.userid,s.status');
while ($session = DBfetch($dbSessions)) {
if ($data['usersSessions'][$session['userid']]['lastaccess'] < $session['lastaccess']) {
$data['usersSessions'][$session['userid']] = $session;
}
}
// render view
$usersView = new CView('administration.users.list', $data);
示例11: insert_js
insert_js('var popupReference = ' . zbx_jsvalue($userGroups, true) . ';');
}
zbx_add_post_js('chkbxRange.pageGoName = "usrgrps";');
$form->addItem($table);
$form->show();
} elseif ($srctbl == 'users') {
$form = new CForm();
$form->setName('userform');
$form->setAttribute('id', 'users');
$table = new CTableInfo(_('No users found.'));
$table->setHeader(array($multiselect ? new CCheckBox('all_users', null, "javascript: checkAll('" . $form->getName() . "', 'all_users', 'users');") : null, _('Alias'), _('Name'), _('Surname')));
$options = array('nodeids' => $nodeId, 'output' => array('alias', 'name', 'surname', 'type', 'theme', 'lang'), 'preservekeys' => true);
if (!is_null($writeonly)) {
$options['editable'] = true;
}
$users = API::User()->get($options);
order_result($users, 'alias');
foreach ($users as &$user) {
$alias = new CSpan($user['alias'], 'link');
$alias->attr('id', 'spanid' . $user['userid']);
if (isset($srcfld2) && $srcfld2 == 'fullname') {
$user[$srcfld2] = getUserFullname($user);
}
if ($multiselect) {
$js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($user['userid']) . ');';
} else {
$values = array($dstfld1 => $user[$srcfld1]);
if (isset($srcfld2)) {
$values[$dstfld2] = $user[$srcfld2];
}
$js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;';
示例12: get
/**
* Get Media types data
*
* @param array $options
* @param array $options['nodeids'] filter by Node IDs
* @param array $options['mediatypeids'] filter by Mediatype IDs
* @param boolean $options['type'] filter by Mediatype type [ USER_TYPE_ZABBIX_USER: 1, USER_TYPE_ZABBIX_ADMIN: 2, USER_TYPE_SUPER_ADMIN: 3 ]
* @param boolean $options['output'] output only Mediatype IDs if not set.
* @param boolean $options['count'] output only count of objects in result. ( result returned in property 'rowscount' )
* @param string $options['pattern'] filter by Host name containing only give pattern
* @param int $options['limit'] output will be limited to given number
* @param string $options['sortfield'] output will be sorted by given property [ 'mediatypeid', 'alias' ]
* @param string $options['sortorder'] output will be sorted in given order [ 'ASC', 'DESC' ]
* @return array
*/
public function get($options = array())
{
$result = array();
$nodeCheck = false;
$userType = self::$userData['type'];
$userid = self::$userData['userid'];
// allowed columns for sorting
$sortColumns = array('mediatypeid');
// allowed output options for [ select_* ] params
$subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
$sqlParts = array('select' => array('media_type' => 'mt.mediatypeid'), 'from' => array('media_type' => 'media_type mt'), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
$defOptions = array('nodeids' => null, 'mediatypeids' => null, 'mediaids' => null, 'userids' => null, 'editable' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectUsers' => null, 'selectMedias' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
$options = zbx_array_merge($defOptions, $options);
// permission check
if (USER_TYPE_SUPER_ADMIN == $userType) {
} elseif (is_null($options['editable']) && self::$userData['type'] == USER_TYPE_ZABBIX_ADMIN) {
} elseif (!is_null($options['editable']) || self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
return array();
}
// output
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
// nodeids
$nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
// mediatypeids
if (!is_null($options['mediatypeids'])) {
zbx_value2array($options['mediatypeids']);
$sqlParts['where'][] = dbConditionInt('mt.mediatypeid', $options['mediatypeids']);
if (!$nodeCheck) {
$nodeCheck = true;
$sqlParts['where'][] = DBin_node('mt.mediatypeid', $nodeids);
}
}
// mediaids
if (!is_null($options['mediaids'])) {
zbx_value2array($options['mediaids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sqlParts['select']['mediaid'] = 'm.mediaid';
}
$sqlParts['from']['media'] = 'media m';
$sqlParts['where'][] = dbConditionInt('m.mediaid', $options['mediaids']);
$sqlParts['where']['mmt'] = 'm.mediatypeid=mt.mediatypeid';
if (!$nodeCheck) {
$nodeCheck = true;
$sqlParts['where'][] = DBin_node('m.mediaid', $nodeids);
}
}
// userids
if (!is_null($options['userids'])) {
zbx_value2array($options['userids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sqlParts['select']['userid'] = 'm.userid';
}
$sqlParts['from']['media'] = 'media m';
$sqlParts['where'][] = dbConditionInt('m.userid', $options['userids']);
$sqlParts['where']['mmt'] = 'm.mediatypeid=mt.mediatypeid';
if (!$nodeCheck) {
$nodeCheck = true;
$sqlParts['where'][] = DBin_node('m.userid', $nodeids);
}
}
// should last, after all ****IDS checks
if (!$nodeCheck) {
$nodeCheck = true;
$sqlParts['where'][] = DBin_node('mt.mediatypeid', $nodeids);
}
// filter
if (is_array($options['filter'])) {
$this->dbFilter('media_type mt', $options, $sqlParts);
}
// search
if (is_array($options['search'])) {
zbx_db_search('media_type mt', $options, $sqlParts);
}
// countOutput
if (!is_null($options['countOutput'])) {
$options['sortfield'] = '';
if (!is_null($options['groupCount'])) {
foreach ($sqlParts['group'] as $key => $fields) {
$sqlParts['select'][$key] = $fields;
}
}
}
// sorting
zbx_db_sorting($sqlParts, $options, $sortColumns, 'mt');
// limit
//.........这里部分代码省略.........
示例13: addRelatedObjects
protected function addRelatedObjects(array $options, array $result)
{
$result = parent::addRelatedObjects($options, $result);
// adding users
if ($options['selectUsers'] !== null && $options['selectUsers'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'mediatypeid', 'userid', 'media');
$users = API::User()->get(['output' => $options['selectUsers'], 'userids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
$result = $relationMap->mapMany($result, $users, 'users');
}
return $result;
}
示例14: zbxDateToTime
}
}
if (!$data['alias'] || $data['users']) {
$from = zbxDateToTime($data['stime']);
$till = $from + $effectivePeriod;
// fetch alerts for different objects and sources and combine them in a single stream
foreach (eventSourceObjects() as $eventSource) {
$data['alerts'] = array_merge($data['alerts'], API::Alert()->get(array('output' => API_OUTPUT_EXTEND, 'selectMediatypes' => API_OUTPUT_EXTEND, 'userids' => $userId, 'time_from' => $from, 'time_till' => $till, 'eventsource' => $eventSource['source'], 'eventobject' => $eventSource['object'], 'limit' => $config['search_limit'] + 1)));
}
CArrayHelper::sort($data['alerts'], array(array('field' => 'alertid', 'order' => ZBX_SORT_DOWN)));
$data['alerts'] = array_slice($data['alerts'], 0, $config['search_limit'] + 1);
// paging
$data['paging'] = getPagingLine($data['alerts']);
// get users
if (!$data['alias']) {
$data['users'] = API::User()->get(array('output' => array('userid', 'alias', 'name', 'surname'), 'userids' => zbx_objectValues($data['alerts'], 'userid'), 'preservekeys' => true));
}
}
// get first alert clock
$firstAlert = null;
if ($userId) {
$firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock' . ' FROM alerts a' . ' WHERE a.userid=' . zbx_dbstr($userId)));
} elseif ($data['alias'] === '') {
$firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock FROM alerts a'));
}
$minStartTime = $firstAlert ? $firstAlert['clock'] : null;
// get actions names
if ($data['alerts']) {
$data['actions'] = API::Action()->get(array('output' => array('actionid', 'name'), 'actionids' => array_unique(zbx_objectValues($data['alerts'], 'actionid')), 'preservekeys' => true));
}
// timeline
示例15: get_request
}
$_REQUEST['alias'] = get_request('alias', CProfile::get('web.auditacts.filter.alias', ''));
if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) {
CProfile::update('web.auditacts.filter.alias', $_REQUEST['alias'], PROFILE_TYPE_STR);
}
/*
* Display
*/
$effectivePeriod = navigation_bar_calc('web.auditacts.timeline', 0, true);
$data = array('stime' => get_request('stime'), 'alias' => get_request('alias'), 'alerts' => array());
$from = zbxDateToTime($data['stime']);
$till = $from + $effectivePeriod;
// get alerts
$options = array('time_from' => $from, 'time_till' => $till, 'output' => API_OUTPUT_EXTEND, 'selectMediatypes' => API_OUTPUT_EXTEND, 'sortfield' => 'alertid', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $config['search_limit'] + 1);
if (!empty($data['alias'])) {
$users = API::User()->get(array('filter' => array('alias' => $data['alias'])));
$options['userids'] = zbx_objectValues($users, 'userid');
}
$data['alerts'] = API::Alert()->get($options);
// get paging
$data['paging'] = getPagingLine($data['alerts']);
// get timeline
unset($options['userids'], $options['time_from'], $options['time_till'], $options['selectMediatypes']);
$options['limit'] = 1;
$options['sortorder'] = ZBX_SORT_UP;
$firstAlert = API::Alert()->get($options);
$firstAlert = reset($firstAlert);
$data['timeline'] = array('period' => $effectivePeriod, 'starttime' => date('YmdHis', !empty($firstAlert) ? $firstAlert['clock'] : time() - SEC_PER_HOUR), 'usertime' => isset($data['stime']) ? date('YmdHis', zbxDateToTime($data['stime']) + $effectivePeriod) : null);
// render view
$auditView = new CView('administration.auditacts.list', $data);
$auditView->render();