示例#1
0
function addData($inc_data, $custom_table = null)
{
    global $context;
    // No tables? Create one even though we are probably already in a bad state!
    if (empty($context['table_count'])) {
        newTable();
    }
    // Specific table?
    if ($custom_table !== null && !isset($context['tables'][$custom_table])) {
        return false;
    } elseif ($custom_table !== null) {
        $table = $custom_table;
    } else {
        $table = $context['current_table'];
    }
    // If we have keys, sanitise the data...
    if (!empty($context['keys'])) {
        // Basically, check every key exists!
        foreach ($context['keys'] as $key => $dummy) {
            $data[$key] = array('v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key]);
            // Special "hack" the adding separators when doing data by column.
            if (substr($key, 0, 5) == '#sep#') {
                $data[$key]['separator'] = true;
            }
        }
    } else {
        $data = $inc_data;
        foreach ($data as $key => $value) {
            $data[$key] = array('v' => $value);
            if (substr($key, 0, 5) == '#sep#') {
                $data[$key]['separator'] = true;
            }
        }
    }
    // Is it by row?
    if (empty($context['key_method']) || $context['key_method'] == 'rows') {
        // Add the data!
        $context['tables'][$table]['data'][] = $data;
    } else {
        foreach ($data as $key => $item) {
            $context['tables'][$table]['data'][$key][] = $item;
        }
    }
}
示例#2
0
 /**
  * Report for showing all the forum staff members - quite a feat!
  * functions ending with "Report" are responsible for generating data
  * for reporting.
  * they are all called from action_index.
  * never access the context directly, but use the data handling
  * functions to do so.
  */
 public function action_staff()
 {
     global $txt;
     require_once SUBSDIR . '/Members.subs.php';
     require_once SUBSDIR . '/Boards.subs.php';
     require_once SUBSDIR . '/Membergroups.subs.php';
     // Fetch all the board names.
     $boards = fetchBoardsInfo('all');
     $moderators = allBoardModerators(true);
     $boards_moderated = array();
     foreach ($moderators as $id_member => $rows) {
         foreach ($rows as $row) {
             $boards_moderated[$id_member][] = $row['id_board'];
         }
     }
     // Get a list of global moderators (i.e. members with moderation powers).
     $global_mods = array_intersect(membersAllowedTo('moderate_board', 0), membersAllowedTo('approve_posts', 0), membersAllowedTo('remove_any', 0), membersAllowedTo('modify_any', 0));
     // How about anyone else who is special?
     $allStaff = array_merge(membersAllowedTo('admin_forum'), membersAllowedTo('manage_membergroups'), membersAllowedTo('manage_permissions'), array_keys($moderators), $global_mods);
     // Make sure everyone is there once - no admin less important than any other!
     $allStaff = array_unique($allStaff);
     // This is a bit of a cop out - but we're protecting their forum, really!
     if (count($allStaff) > 300) {
         fatal_lang_error('report_error_too_many_staff');
     }
     // Get all the possible membergroups!
     $all_groups = getBasicMembergroupData(array('all'), array(), null, false);
     $groups = array(0 => $txt['full_member']);
     foreach ($all_groups as $row) {
         $groups[$row['id']] = empty($row['online_color']) ? $row['name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['name'] . '</span>';
     }
     // All the fields we'll show.
     $staffSettings = array('position' => $txt['report_staff_position'], 'moderates' => $txt['report_staff_moderates'], 'posts' => $txt['report_staff_posts'], 'last_login' => $txt['report_staff_last_login']);
     // Do it in columns, it's just easier.
     setKeys('cols');
     // Get the latest activated member's display name.
     $result = getBasicMemberData($allStaff, array('moderation' => true, 'sort' => 'real_name'));
     foreach ($result as $row) {
         // Each member gets their own table!.
         newTable($row['real_name'], '', 'left', 'auto', 'left', 200, 'center');
         // First off, add in the side key.
         addData($staffSettings);
         // Create the main data array.
         $staffData = array('position' => isset($groups[$row['id_group']]) ? $groups[$row['id_group']] : $groups[0], 'posts' => $row['posts'], 'last_login' => standardTime($row['last_login']), 'moderates' => array());
         // What do they moderate?
         if (in_array($row['id_member'], $global_mods)) {
             $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>';
         } elseif (isset($boards_moderated[$row['id_member']])) {
             // Get the names
             foreach ($boards_moderated[$row['id_member']] as $board) {
                 if (isset($boards[$board])) {
                     $staffData['moderates'][] = $boards[$board]['name'];
                 }
             }
             $staffData['moderates'] = implode(', ', $staffData['moderates']);
         } else {
             $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>';
         }
         // Next add the main data.
         addData($staffData);
     }
 }
<?php

//---------------------------
// programmer:	Jafarkhani
// create Date:	90.06
//---------------------------
require_once '../../header.inc.php';
require_once '../class/columns.class.php';
require_once inc_dataReader;
require_once inc_response;
$task = isset($_POST["task"]) ? $_POST["task"] : (isset($_GET["task"]) ? $_GET["task"] : "");
switch ($task) {
    case "GetTreeNodes":
        GetTreeNodes();
    case "newTable":
        newTable();
}
function GetTreeNodes()
{
    $ref = array();
    $returnArray = array();
    $nodes = PdoDataAccess::runquery("\n\t\tselect relation_id,if(parent_tree_id<>0, parent_tree_id,parent_table_id) as parent_table_id,\n\t\t\t\tif(tree_id<>0, tree_id, table_id) as table_id,description\n\t\tfrom rp_relations\n\t\torder by relation_id");
    $returnArray[] = array("id" => $nodes[0]["relation_id"], "text" => $nodes[0]["description"], "leaf" => "false");
    $ref[$nodes[0]["table_id"]][] =& $returnArray[count($returnArray) - 1];
    for ($i = 1; $i < count($nodes); $i++) {
        $parent =& $ref[$nodes[$i]["parent_table_id"]];
        for ($j = 0; $j < count($parent); $j++) {
            if (!isset($parent[$j]["children"])) {
                $parent[$j]["children"] = array();
            }
            $parent[$j]["children"][] = array("id" => $parent[$j]["id"] . "_" . $nodes[$i]["relation_id"], "text" => $nodes[$i]["description"], "leaf" => "false");
示例#4
0
        break;
    }
}
if ($isExist == false) {
    returnApiError('no exist this id');
    exit('');
}
for ($i = $delIndex; $i < count($dataArr); $i++) {
    $dataArr[$i] = $dataArr[$i + 1];
}
$dataArr = array_filter($dataArr);
//删除数组中的空元素
$json_string = json_encode($dataArr);
$ifSuccess = file_put_contents('data.json', $json_string);
if ($ifSuccess == true) {
    newTable($dataArr);
    returnApiSuccess($ifSuccess);
    exit('');
} else {
    returnApiError('file put fail');
}
function returnApiSuccess($msg = null)
{
    //请求成功时调用,返回数据。
    $result = array('flag' => 'success', 'msg' => $msg);
    print json_encode($result);
}
function returnApiError($msg = null)
{
    //请求失败时调用,返回失败信息
    $result = array('flag' => 'error', 'msg' => $msg);