当前位置: 首页>>代码示例>>PHP>>正文


PHP API::Mediatype方法代码示例

本文整理汇总了PHP中API::Mediatype方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Mediatype方法的具体用法?PHP API::Mediatype怎么用?PHP API::Mediatype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::Mediatype方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doAction

 protected function doAction()
 {
     $sortField = $this->getInput('sort', CProfile::get('web.media_types.php.sort', 'description'));
     $sortOrder = $this->getInput('sortorder', CProfile::get('web.media_types.php.sortorder', ZBX_SORT_UP));
     CProfile::update('web.media_type.php.sort', $sortField, PROFILE_TYPE_STR);
     CProfile::update('web.media_types.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
     $config = select_config();
     $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
     // get media types
     $data['mediatypes'] = API::Mediatype()->get(['output' => ['mediatypeid', 'description', 'type', 'smtp_server', 'smtp_helo', 'smtp_email', 'exec_path', 'gsm_modem', 'username', 'status'], 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
     if ($data['mediatypes']) {
         // get media types used in actions
         $actions = API::Action()->get(['output' => ['actionid', 'name'], 'selectOperations' => ['operationtype', 'opmessage'], 'mediatypeids' => array_keys($data['mediatypes'])]);
         foreach ($data['mediatypes'] as &$mediaType) {
             $mediaType['typeid'] = $mediaType['type'];
             $mediaType['type'] = media_type2str($mediaType['type']);
             $mediaType['listOfActions'] = [];
             foreach ($actions as $action) {
                 foreach ($action['operations'] as $operation) {
                     if ($operation['operationtype'] == OPERATION_TYPE_MESSAGE && $operation['opmessage']['mediatypeid'] == $mediaType['mediatypeid']) {
                         $mediaType['listOfActions'][$action['actionid']] = ['actionid' => $action['actionid'], 'name' => $action['name']];
                     }
                 }
             }
             order_result($mediaType['listOfActions'], 'name');
         }
         unset($mediaType);
         order_result($data['mediatypes'], $sortField, $sortOrder);
     }
     $url = (new CUrl('zabbix.php'))->setArgument('action', 'mediatype.list');
     $data['paging'] = getPagingLine($data['mediatypes'], $sortOrder, $url);
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Configuration of media types'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:35,代码来源:CControllerMediatypeList.php

示例2: doAction

 protected function doAction()
 {
     $mediatypeids = $this->getInput('mediatypeids');
     $result = API::Mediatype()->delete($mediatypeids);
     $deleted = count($mediatypeids);
     $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.list&uncheck=1');
     if ($result) {
         $response->setMessageOk(_n('Media type deleted', 'Media types deleted', $deleted));
     } else {
         $response->setMessageError(_n('Cannot delete media type', 'Cannot delete media types', $deleted));
     }
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:13,代码来源:CControllerMediatypeDelete.php

示例3: checkPermissions

 protected function checkPermissions()
 {
     if ($this->getUserType() != USER_TYPE_SUPER_ADMIN) {
         return false;
     }
     if ($this->hasInput('mediatypeid')) {
         $mediatypes = API::Mediatype()->get(['output' => ['mediatypeid', 'type', 'description', 'smtp_server', 'smtp_port', 'smtp_helo', 'smtp_email', 'exec_path', 'gsm_modem', 'username', 'passwd', 'status', 'smtp_security', 'smtp_verify_peer', 'smtp_verify_host', 'smtp_authentication', 'exec_params'], 'mediatypeids' => $this->getInput('mediatypeid'), 'editable' => true]);
         if (!$mediatypes) {
             return false;
         }
         $this->mediatype = $mediatypes[0];
     }
     return true;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:14,代码来源:CControllerMediatypeEdit.php

示例4: doAction

 protected function doAction()
 {
     $mediatypes = [];
     foreach ($this->getInput('mediatypeids') as $mediatypeid) {
         $mediatypes[] = ['mediatypeid' => $mediatypeid, 'status' => MEDIA_TYPE_STATUS_DISABLED];
     }
     $result = API::Mediatype()->update($mediatypes);
     $updated = count($mediatypes);
     $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.list&uncheck=1');
     if ($result) {
         $response->setMessageOk(_n('Media type disabled', 'Media types disabled', $updated));
     } else {
         $response->setMessageError(_n('Cannot disable media type', 'Cannot disable media types', $updated));
     }
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:16,代码来源:CControllerMediatypeDisable.php

示例5: get_operation_descr

/**
 * Generates array with HTML items representing operation with description
 *
 * @param int $type short or long description, use const. SHORT_DESCRIPTION and LONG_DESCRIPTION
 * @param array $data
 * @param int $data['operationtype'] type of operation: OPERATION_TYPE_MESSAGE, OPERATION_TYPE_COMMAND, ...
 * @param int $data['opmessage']['mediatypeid'] type id of message media
 * @param bool $data['opmessage']['default_msg'] should default message be used
 * @param bool $data['opmessage']['operationid'] if true $data['operationid'] will be used to retrieve default messages from DB
 * @param string $data['opmessage']['subject'] subject of message
 * @param string $data['opmessage']['message'] message it self
 * @param array $data['opmessage_usr'] list of user ids if OPERATION_TYPE_MESSAGE
 * @param array $data['opmessage_grp'] list of group ids if OPERATION_TYPE_MESSAGE
 * @param array $data['opcommand_grp'] list of group ids if OPERATION_TYPE_COMMAND
 * @param array $data['opcommand_hst'] list of host ids if OPERATION_TYPE_COMMAND
 * @param array $data['opgroup'] list of group ids if OPERATION_TYPE_GROUP_ADD or OPERATION_TYPE_GROUP_REMOVE
 * @param array $data['optemplate'] list of template ids if OPERATION_TYPE_TEMPLATE_ADD or OPERATION_TYPE_TEMPLATE_REMOVE
 * @param int $data['operationid'] id of operation
 * @param int $data['opcommand']['type'] type of command: ZBX_SCRIPT_TYPE_IPMI, ZBX_SCRIPT_TYPE_SSH, ...
 * @param string $data['opcommand']['command'] actual command
 * @param int $data['opcommand']['scriptid'] script id used if $data['opcommand']['type'] is ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT
 *
 * @return array
 */
function get_operation_descr($type, $data)
{
    $result = array();
    if ($type == SHORT_DESCRIPTION) {
        switch ($data['operationtype']) {
            case OPERATION_TYPE_MESSAGE:
                $mediaTypes = API::Mediatype()->get(array('mediatypeids' => $data['opmessage']['mediatypeid'], 'output' => array('description')));
                if (empty($mediaTypes)) {
                    $mediatype = _('all media');
                } else {
                    $mediatype = reset($mediaTypes);
                    $mediatype = $mediatype['description'];
                }
                if (!empty($data['opmessage_usr'])) {
                    $users = API::User()->get(array('userids' => zbx_objectValues($data['opmessage_usr'], 'userid'), 'output' => array('userid', 'alias', 'name', 'surname')));
                    order_result($users, 'alias');
                    foreach ($users as $user) {
                        $fullnames[] = getUserFullname($user);
                    }
                    $result[] = bold(_('Send message to users') . NAME_DELIMITER);
                    $result[] = array(implode(', ', $fullnames), SPACE, _('via'), SPACE, $mediatype);
                    $result[] = BR();
                }
                if (!empty($data['opmessage_grp'])) {
                    $usrgrps = API::UserGroup()->get(array('usrgrpids' => zbx_objectValues($data['opmessage_grp'], 'usrgrpid'), 'output' => API_OUTPUT_EXTEND));
                    order_result($usrgrps, 'name');
                    $result[] = bold(_('Send message to user groups') . NAME_DELIMITER);
                    $result[] = array(implode(', ', zbx_objectValues($usrgrps, 'name')), SPACE, _('via'), SPACE, $mediatype);
                    $result[] = BR();
                }
                break;
            case OPERATION_TYPE_COMMAND:
                if (!isset($data['opcommand_grp'])) {
                    $data['opcommand_grp'] = array();
                }
                if (!isset($data['opcommand_hst'])) {
                    $data['opcommand_hst'] = array();
                }
                $hosts = API::Host()->get(array('hostids' => zbx_objectValues($data['opcommand_hst'], 'hostid'), 'output' => array('hostid', 'name')));
                foreach ($data['opcommand_hst'] as $cmd) {
                    if ($cmd['hostid'] != 0) {
                        continue;
                    }
                    $result[] = array(bold(_('Run remote commands on current host')), BR());
                    break;
                }
                if (!empty($hosts)) {
                    order_result($hosts, 'name');
                    $result[] = bold(_('Run remote commands on hosts') . NAME_DELIMITER);
                    $result[] = array(implode(', ', zbx_objectValues($hosts, 'name')), BR());
                }
                $groups = API::HostGroup()->get(array('groupids' => zbx_objectValues($data['opcommand_grp'], 'groupid'), 'output' => array('groupid', 'name')));
                if (!empty($groups)) {
                    order_result($groups, 'name');
                    $result[] = bold(_('Run remote commands on host groups') . NAME_DELIMITER);
                    $result[] = array(implode(', ', zbx_objectValues($groups, 'name')), BR());
                }
                break;
            case OPERATION_TYPE_HOST_ADD:
                $result[] = array(bold(_('Add host')), BR());
                break;
            case OPERATION_TYPE_HOST_REMOVE:
                $result[] = array(bold(_('Remove host')), BR());
                break;
            case OPERATION_TYPE_HOST_ENABLE:
                $result[] = array(bold(_('Enable host')), BR());
                break;
            case OPERATION_TYPE_HOST_DISABLE:
                $result[] = array(bold(_('Disable host')), BR());
                break;
            case OPERATION_TYPE_GROUP_ADD:
            case OPERATION_TYPE_GROUP_REMOVE:
                if (!isset($data['opgroup'])) {
                    $data['opgroup'] = array();
                }
                $groups = API::HostGroup()->get(array('groupids' => zbx_objectValues($data['opgroup'], 'groupid'), 'output' => array('groupid', 'name')));
//.........这里部分代码省略.........
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:actions.inc.php

示例6: doAction

 protected function doAction()
 {
     $mediatype = [];
     $this->getInputs($mediatype, ['type', 'description', 'status']);
     switch ($mediatype['type']) {
         case MEDIA_TYPE_EMAIL:
             $this->getInputs($mediatype, ['smtp_server', 'smtp_port', 'smtp_helo', 'smtp_email', 'smtp_security', 'smtp_verify_peer', 'smtp_verify_host', 'smtp_authentication', 'passwd']);
             if ($this->hasInput('smtp_username')) {
                 $mediatype['username'] = $this->getInput('smtp_username');
             }
             break;
         case MEDIA_TYPE_EXEC:
             $this->getInputs($mediatype, ['exec_path']);
             $mediatype['exec_params'] = '';
             if ($this->hasInput('exec_params')) {
                 $exec_params = zbx_objectValues($this->getInput('exec_params'), 'exec_param');
                 foreach ($exec_params as $exec_param) {
                     $mediatype['exec_params'] .= $exec_param . "\n";
                 }
             }
             break;
         case MEDIA_TYPE_SMS:
             $this->getInputs($mediatype, ['gsm_modem']);
             break;
         case MEDIA_TYPE_JABBER:
             $this->getInputs($mediatype, ['passwd']);
             if ($this->hasInput('jabber_username')) {
                 $mediatype['username'] = $this->getInput('jabber_username');
             }
             break;
         case MEDIA_TYPE_EZ_TEXTING:
             $this->getInputs($mediatype, ['passwd']);
             if ($this->hasInput('eztext_username')) {
                 $mediatype['username'] = $this->getInput('eztext_username');
             }
             if ($this->hasInput('eztext_limit')) {
                 $mediatype['exec_path'] = $this->getInput('eztext_limit');
             }
             break;
     }
     DBstart();
     $result = API::Mediatype()->create($mediatype);
     if ($result) {
         add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_MEDIA_TYPE, 'Media type [' . $mediatype['description'] . ']');
     }
     $result = DBend($result);
     if ($result) {
         $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.list&uncheck=1');
         $response->setMessageOk(_('Media type added'));
     } else {
         $response = new CControllerResponseRedirect('zabbix.php?action=mediatype.edit');
         $response->setFormData($this->getInputAll());
         $response->setMessageError(_('Cannot add media type'));
     }
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:56,代码来源:CControllerMediatypeCreate.php

示例7: getRequest

        $data['username'] = getRequest('username', $data['type'] == MEDIA_TYPE_EZ_TEXTING ? 'username' : 'user@server');
        $data['password'] = getRequest('password', '');
        $data['status'] = getRequest('status', MEDIA_TYPE_STATUS_ACTIVE);
    }
    // render view
    $mediaTypeView = new CView('administration.mediatypes.edit', $data);
    $mediaTypeView->render();
    $mediaTypeView->show();
} else {
    $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'description'));
    $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('sort' => $sortField, 'sortorder' => $sortOrder);
    // get media types
    $data['mediatypes'] = API::Mediatype()->get(array('output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'editable' => true, 'limit' => $config['search_limit'] + 1));
    if ($data['mediatypes']) {
        // get media types used in actions
        $actions = API::Action()->get(array('mediatypeids' => zbx_objectValues($data['mediatypes'], 'mediatypeid'), 'output' => array('actionid', 'name'), 'selectOperations' => array('operationtype', 'opmessage'), 'preservekeys' => true));
        foreach ($data['mediatypes'] as $key => $mediaType) {
            $data['mediatypes'][$key]['typeid'] = $data['mediatypes'][$key]['type'];
            $data['mediatypes'][$key]['type'] = media_type2str($data['mediatypes'][$key]['type']);
            $data['mediatypes'][$key]['listOfActions'] = array();
            if ($actions) {
                foreach ($actions as $actionId => $action) {
                    foreach ($action['operations'] as $operation) {
                        if ($operation['operationtype'] == OPERATION_TYPE_MESSAGE && $operation['opmessage']['mediatypeid'] == $mediaType['mediatypeid']) {
                            $data['mediatypes'][$key]['listOfActions'][$actionId] = array('actionid' => $actionId, 'name' => $action['name']);
                        }
                    }
                }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:media_types.php

示例8: get_request

        $data['smtp_helo'] = get_request('smtp_helo', 'localhost');
        $data['smtp_email'] = get_request('smtp_email', 'zabbix@localhost');
        $data['exec_path'] = get_request('exec_path', '');
        $data['gsm_modem'] = get_request('gsm_modem', '/dev/ttyS0');
        $data['username'] = get_request('username', $data['type'] == MEDIA_TYPE_EZ_TEXTING ? 'username' : 'user@server');
        $data['password'] = get_request('password', '');
        $data['status'] = get_request('status', MEDIA_TYPE_STATUS_ACTIVE);
    }
    // render view
    $mediaTypeView = new CView('administration.mediatypes.edit', $data);
    $mediaTypeView->render();
    $mediaTypeView->show();
} else {
    // get media types
    $options = array('output' => API_OUTPUT_EXTEND, 'preservekeys' => 1, 'editable' => true, 'limit' => $config['search_limit'] + 1);
    $data['mediatypes'] = API::Mediatype()->get($options);
    // get media types used in actions
    $options = array('mediatypeids' => zbx_objectValues($data['mediatypes'], 'mediatypeid'), 'output' => array('actionid', 'name'), 'preservekeys' => 1);
    $actions = API::Action()->get($options);
    foreach ($data['mediatypes'] as $number => $mediatype) {
        $data['mediatypes'][$number]['listOfActions'] = array();
        foreach ($actions as $actionid => $action) {
            if (!empty($action['mediatypeids'])) {
                foreach ($action['mediatypeids'] as $actionMediaTypeId) {
                    if ($mediatype['mediatypeid'] == $actionMediaTypeId) {
                        $data['mediatypes'][$number]['listOfActions'][$actionid] = array('actionid' => $actionid, 'name' => $action['name']);
                    }
                }
            }
        }
        $data['mediatypes'][$number]['usedInActions'] = !isset($mediatype['listOfActions']);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:media_types.php

示例9: makeEventsActions

function makeEventsActions($eventids)
{
    if (!$eventids) {
        return [];
    }
    $result = DBselect('SELECT a.eventid,a.mediatypeid,a.userid,a.clock,a.message,a.status,a.alerttype,a.error' . ' FROM alerts a' . ' WHERE ' . dbConditionInt('a.eventid', $eventids) . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' ORDER BY a.alertid DESC');
    $events = [];
    $userids = [];
    $users = [];
    $mediatypeids = [];
    $mediatypes = [];
    while ($row = DBfetch($result)) {
        if (!array_key_exists($row['eventid'], $events)) {
            $events[$row['eventid']] = [ALERT_STATUS_NOT_SENT => [], ALERT_STATUS_SENT => [], ALERT_STATUS_FAILED => []];
        }
        $event = ['clock' => $row['clock'], 'alerttype' => $row['alerttype'], 'error' => $row['error']];
        switch ($event['alerttype']) {
            case ALERT_TYPE_COMMAND:
                $event['message'] = $row['message'];
                break;
            case ALERT_TYPE_MESSAGE:
                $event['mediatypeid'] = $row['mediatypeid'];
                $event['userid'] = $row['userid'];
                if ($event['mediatypeid'] != 0) {
                    $mediatypeids[$row['mediatypeid']] = true;
                }
                if ($event['userid'] != 0) {
                    $userids[$row['userid']] = true;
                }
                break;
        }
        $events[$row['eventid']][$row['status']][] = $event;
    }
    if ($mediatypeids) {
        $mediatypes = API::Mediatype()->get(['output' => ['description'], 'mediatypeids' => array_keys($mediatypeids), 'preservekeys' => true]);
    }
    if ($userids) {
        $users = API::User()->get(['output' => ['alias', 'name', 'surname'], 'userids' => array_keys($userids), 'preservekeys' => true]);
    }
    foreach ($events as $eventid => &$event) {
        $event = (new CList([$event[ALERT_STATUS_SENT] ? (new CSpan(count($event[ALERT_STATUS_SENT])))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_GREEN)->setHint(makeActionHints($event[ALERT_STATUS_SENT], $mediatypes, $users, ALERT_STATUS_SENT)) : '', $event[ALERT_STATUS_NOT_SENT] ? (new CSpan(count($event[ALERT_STATUS_NOT_SENT])))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_YELLOW)->setHint(makeActionHints($event[ALERT_STATUS_NOT_SENT], $mediatypes, $users, ALERT_STATUS_NOT_SENT)) : '', $event[ALERT_STATUS_FAILED] ? (new CSpan(count($event[ALERT_STATUS_FAILED])))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_RED)->setHint(makeActionHints($event[ALERT_STATUS_FAILED], $mediatypes, $users, ALERT_STATUS_FAILED)) : '']))->addClass(ZBX_STYLE_LIST_HOR_MIN_WIDTH);
    }
    unset($event);
    return $events;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:45,代码来源:actions.inc.php

示例10: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $userIds = zbx_objectValues($result, 'userid');
     // adding usergroups
     if ($options['selectUsrgrps'] !== null && $options['selectUsrgrps'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'userid', 'usrgrpid', 'users_groups');
         $dbUserGroups = API::UserGroup()->get(array('output' => $options['selectUsrgrps'], 'usrgrpids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
         $result = $relationMap->mapMany($result, $dbUserGroups, 'usrgrps');
     }
     // adding medias
     if ($options['selectMedias'] !== null && $options['selectMedias'] != API_OUTPUT_COUNT) {
         $userMedias = API::UserMedia()->get(array('output' => $this->outputExtend('media', array('userid', 'mediaid'), $options['selectMedias']), 'userids' => $userIds, 'preservekeys' => true));
         $relationMap = $this->createRelationMap($userMedias, 'userid', 'mediaid');
         $userMedias = $this->unsetExtraFields($userMedias, array('userid', 'mediaid'), $options['selectMedias']);
         $result = $relationMap->mapMany($result, $userMedias, 'medias');
     }
     // adding media types
     if ($options['selectMediatypes'] !== null && $options['selectMediatypes'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'userid', 'mediatypeid', 'media');
         $mediaTypes = API::Mediatype()->get(array('output' => $options['selectMediatypes'], 'mediatypeids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
         $result = $relationMap->mapMany($result, $mediaTypes, 'mediatypes');
     }
     return $result;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:25,代码来源:CUser.php

示例11: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $userids = zbx_objectValues($result, 'userid');
     // adding usergroups
     if (!is_null($options['selectUsrgrps']) && str_in_array($options['selectUsrgrps'], array(API_OUTPUT_REFER, API_OUTPUT_EXTEND))) {
         foreach ($result as &$user) {
             $user['usrgrps'] = array();
         }
         unset($user);
         $usrgrps = API::UserGroup()->get(array('output' => $options['selectUsrgrps'], 'userids' => $userids, 'preservekeys' => true));
         foreach ($usrgrps as $usrgrp) {
             $uusers = $usrgrp['users'];
             unset($usrgrp['users']);
             $usrgrps = $this->unsetExtraFields('usrgrp', $usrgrps, $options['selectUsrgrps']);
             foreach ($uusers as $user) {
                 $result[$user['userid']]['usrgrps'][] = $usrgrp;
             }
         }
     }
     // adding medias
     if (!is_null($options['selectMedias']) && str_in_array($options['selectMedias'], array(API_OUTPUT_REFER, API_OUTPUT_EXTEND))) {
         foreach ($result as &$user) {
             $user['medias'] = array();
         }
         unset($user);
         $userMedias = API::UserMedia()->get(array('output' => $options['selectMedias'], 'userids' => $userids, 'preservekeys' => true));
         $userMedias = $this->unsetExtraFields('media', $userMedias, $options['selectMedias']);
         foreach ($userMedias as $mediaid => $media) {
             $result[$media['userid']]['medias'][] = $media;
         }
     }
     // adding media types
     if (!is_null($options['selectMediatypes'])) {
         foreach ($result as &$user) {
             $user['mediatypes'] = array();
         }
         unset($user);
         $mediatypes = API::Mediatype()->get(array('output' => $options['selectMediatypes'], 'userids' => $userids, 'selectUsers' => API_OUTPUT_REFER, 'preservekeys' => true));
         foreach ($mediatypes as $mediatype) {
             $users = $mediatype['users'];
             unset($mediatype['users']);
             $mediatype = $this->unsetExtraFields('media_type', $mediatype, $options['selectMediatypes']);
             foreach ($users as $user) {
                 if (!empty($result[$user['userid']])) {
                     $result[$user['userid']]['mediatypes'][] = $mediatype;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:52,代码来源:CUser.php


注:本文中的API::Mediatype方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。