예제 #1
0
echo generate_box_close();
// Show entity permissions only for Normal users
if ($user_data['permission_access'] && !$user_data['permission_read']) {
    // Cache user permissions
    foreach (dbFetchRows("SELECT * FROM `entity_permissions` WHERE `user_id` = ?", array($user_data['user_id'])) as $entity) {
        $user_permissions[$entity['entity_type']][$entity['entity_id']] = TRUE;
    }
    // Start bill Permissions
    if (isset($config['enable_billing']) && $config['enable_billing'] && count($user_permissions['bill'])) {
        // Display info about user bill permissions, only if user has is
        echo generate_box_open(array('header-border' => TRUE, 'title' => 'Bill Permissions'));
        //if (count($user_permissions['bill']))
        //{
        echo '<table class="' . OBS_CLASS_TABLE . '">' . PHP_EOL;
        foreach ($user_permissions['bill'] as $bill_id => $status) {
            $bill = get_bill_by_id($bill_id);
            echo '<tr><td style="width: 1px;"></td>
                  <td style="overflow: hidden;"><i class="' . $config['entities']['bill']['icon'] . '"></i> ' . $bill['bill_name'] . '
                  <small>' . $bill['bill_type'] . '</small></td>
                </tr>';
        }
        echo '</table>' . PHP_EOL;
        //} else {
        //  echo('<p class="text-center text-warning bg-warning" style="padding: 10px; margin: 0px;"><strong>This user currently has no permitted bills</strong></p>');
        //  //print_warning("This user currently has no permitted bills");
        //}
        echo generate_box_close();
    }
    // End bill permissions
    // Start group permissions
    if (OBSERVIUM_EDITION != 'community') {
       <select class="selectpicker" id='port_entity_id' name='entity_id[]' data-width="40%" multiple>
       </select>
       <button class="btn pull-right" type="submit" name="提交" value="添加"><i class="oicon-plus-circle"></i> 添加</button>
    </form>

      </div>
    </div>

    <div class="col-md-4">
      <div class="well">
        <h2>账单权限</h2>

<?php 
            if (count($user_permissions['bill'])) {
                foreach (array_keys($user_permissions['bill']) as $entity_id) {
                    $bill = get_bill_by_id($entity_id);
                    $button = '<button class="btn"><i class="oicon-servers"></i> ' . $bill['bill_name'] . '</button>';
                    $del_url = generate_url(array('page' => 'edituser', 'action' => 'perm_del', 'user_id' => $vars['user_id'], 'entity_type' => 'bill', 'entity_id' => $entity_id));
                    echo '            <div class="btn-group" style="margin-bottom: 5px;">';
                    echo '              <button class="btn btn-danger" style="color: #fff;" onclick="location.href=\'' . $del_url . '\';"><i class="icon-minus-sign icon-white"></i> 删除</button>';
                    echo '              ' . $button;
                    echo '            </div>';
                    $bill_Permissions_list[] = $bill_perm['bill_id'];
                    $bpermdone = TRUE;
                }
            } else {
                echo '<div class="alert alert-danger">无权限</div>';
            }
            ?>

        <hr />
예제 #3
0
function get_entity_by_id_cache($entity_type, $entity_id)
{
    global $cache;
    $translate = entity_type_translate_array($entity_type);
    if (is_array($cache[$entity_type][$entity_id])) {
        return $cache[$entity_type][$entity_id];
    } else {
        switch ($entity_type) {
            case "bill":
                if (function_exists('get_bill_by_id')) {
                    $entity = get_bill_by_id($entity_id);
                }
                break;
            case "port":
                $entity = get_port_by_id($entity_id);
                break;
            default:
                $sql = 'SELECT * FROM `' . $translate['table'] . '`';
                if (isset($translate['state_table'])) {
                    $sql .= ' LEFT JOIN `' . $translate['state_table'] . '` USING (`' . $translate['id_field'] . '`)';
                }
                $sql .= ' WHERE `' . $translate['table'] . '`.`' . $translate['id_field'] . '` = ?';
                $entity = dbFetchRow($sql, array($entity_id));
                if (function_exists('humanize_' . $entity_type)) {
                    $do = 'humanize_' . $entity_type;
                    $do($entity);
                } else {
                    if (isset($translate['humanize_function']) && function_exists($translate['humanize_function'])) {
                        $do = $translate['humanize_function'];
                        $do($entity);
                    }
                }
                break;
        }
        if (is_array($entity)) {
            entity_rewrite($entity_type, $entity);
            $cache[$entity_type][$entity_id] = $entity;
            return $entity;
        }
    }
    return FALSE;
}