• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_parent_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_parent_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_parent_id函数的具体用法?PHP get_parent_id怎么用?PHP get_parent_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_parent_url

/**
 * Get the parent permalink
 */
function get_parent_url()
{
    global $post;
    $parent = get_parent_id();
    if ($parent > 0) {
        return get_permalink($parent);
    } elseif (is_single() && get_post_type() == 'opportunity') {
        $opps_page = get_field('opportunities_listing_page', 'option');
        return get_permalink($opps_page->post_parent);
    } elseif (is_single() && get_post_type() == 'event') {
        $opps_page = get_field('programs_listing_page', 'option');
        return get_permalink($opps_page->ID);
    } elseif (is_archive()) {
        return get_permalink(get_option('page_for_posts'));
    } else {
        return false;
    }
}
开发者ID:pauljosephcox,项目名称:starter-wordpress,代码行数:21,代码来源:extras.php


示例2: reparent_branch

function reparent_branch($new_parent_id, $tree_item_id)
{
    if (empty($tree_item_id)) {
        return 0;
    }
    /* get the current tree_id */
    $graph_tree_id = db_fetch_cell("select graph_tree_id from graph_tree_items where id={$tree_item_id}");
    /* make sure the parent id actually changed */
    if (get_parent_id($tree_item_id, "graph_tree_items", "graph_tree_id={$graph_tree_id}") == $new_parent_id) {
        return 0;
    }
    /* get current key so we can do a sql select on it */
    $old_order_key = db_fetch_cell("select order_key from graph_tree_items where id={$tree_item_id}");
    $new_order_key = get_next_tree_id(db_fetch_cell("select order_key from graph_tree_items where id={$new_parent_id}"), "graph_tree_items", "order_key", "graph_tree_id={$graph_tree_id}");
    /* yeah, this would be really bad */
    if (empty($old_order_key)) {
        return 0;
    }
    $old_starting_tier = tree_tier($old_order_key);
    $new_starting_tier = tree_tier($new_order_key);
    $new_base_tier = substr($new_order_key, 0, $new_starting_tier * CHARS_PER_TIER);
    $old_base_tier = substr($old_order_key, 0, $old_starting_tier * CHARS_PER_TIER);
    /* prevent possible collisions */
    db_execute("update graph_tree_items set order_key = CONCAT('x',order_key) where order_key like '{$old_base_tier}%%' and graph_tree_id={$graph_tree_id}");
    /* truncate */
    if ($new_starting_tier >= $old_starting_tier) {
        db_execute("update graph_tree_items set order_key = SUBSTRING(REPLACE(order_key, 'x{$old_base_tier}', '{$new_base_tier}'), 1, " . MAX_TREE_DEPTH * CHARS_PER_TIER . ") where order_key like 'x{$old_base_tier}%%' and graph_tree_id={$graph_tree_id}");
        /* append */
    } else {
        db_execute("update graph_tree_items set order_key = CONCAT(REPLACE(order_key, 'x{$old_base_tier}', '{$new_base_tier}'), '" . str_repeat('0', strlen($old_base_tier) - strlen($new_base_tier)) . "') where order_key like 'x{$old_base_tier}%%' and graph_tree_id={$graph_tree_id}");
    }
}
开发者ID:songchin,项目名称:Cacti,代码行数:32,代码来源:tree.php


示例3: explore_tree

function explore_tree($path, $tree_id, $parent_tree_item_id)
{
    /* seek graph_tree_items of the tree_id which are NOT graphs but headers */
    $links = db_fetch_assoc("SELECT\n\t\tid,\n\t\ttitle,\n\t\thost_id\n\t\tFROM graph_tree_items\n\t\tWHERE rra_id = 0\n\t\tAND graph_tree_id = " . $tree_id);
    $total_graphs_created = 0;
    foreach ($links as $link) {
        /* this test gives us the parent of the curent graph_tree_item */
        if (get_parent_id($link["id"], "graph_tree_items", "graph_tree_id = " . $tree_id) == $parent_tree_item_id) {
            if (get_tree_item_type($link["id"]) == "host") {
                if (read_config_option("export_tree_isolation") == "off") {
                    $total_graphs_created += export_build_tree_single(clean_up_export_name($path), clean_up_export_name(get_host_description($link["host_id"]) . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
                } else {
                    $total_graphs_created += export_build_tree_isolated(clean_up_export_name($path), clean_up_export_name(get_host_description($link["host_id"]) . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
                }
            } else {
                /*now, this graph_tree_item is the parent of others graph_tree_items*/
                if (read_config_option("export_tree_isolation") == "off") {
                    $total_graphs_created += export_build_tree_single(clean_up_export_name($path), clean_up_export_name($link["title"] . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
                } else {
                    $total_graphs_created += export_build_tree_isolated(clean_up_export_name($path), clean_up_export_name($link["title"] . "_" . $link["id"] . ".html"), $tree_id, $link["id"]);
                }
            }
        }
    }
    return $total_graphs_created;
}
开发者ID:songchin,项目名称:Cacti,代码行数:26,代码来源:graph_export.php


示例4: makeList

    public static function makeList()
    {
        global $lng, $coach, $settings;
        HTMLOUT::frame_begin();
        # Make page frame, banner and menu.
        title($lng->getTrn('name', __CLASS__));
        echo $lng->getTrn('desc', __CLASS__) . "<br><br>\n";
        list($sel_node, $sel_node_id) = HTMLOUT::nodeSelector(array());
        $ALLOW_EDIT = is_object($coach) && $coach->isNodeCommish($sel_node, $sel_node_id);
        /* A new entry was sent. Add it to system */
        if ($ALLOW_EDIT && isset($_POST['tid']) && isset($_POST['trid'])) {
            if (get_magic_quotes_gpc()) {
                $_POST['title'] = stripslashes($_POST['title']);
                $_POST['txt'] = stripslashes($_POST['txt']);
            }
            switch ($_GET['action']) {
                case 'new':
                    status(self::create($_POST['ptype'], $_POST['tid'], $_POST['trid'], $_POST['title'], $_POST['txt']));
                    break;
            }
        }
        /* Was a request for a new entry made? */
        if (isset($_GET['action']) && $ALLOW_EDIT) {
            switch ($_GET['action']) {
                case 'delete':
                    if (isset($_GET['prid']) && is_numeric($_GET['prid'])) {
                        $pr = new Prize($_GET['prid']);
                        status($pr->delete());
                        unset($pr);
                    } else {
                        fatal('Sorry. You did not specify which prize ID you wish to delete.');
                    }
                    break;
                case 'new':
                    echo "<a href='handler.php?type=prize'><-- " . $lng->getTrn('common/back') . "</a><br><br>";
                    $_DISABLED = !isset($_POST['trid']) ? 'DISABLED' : '';
                    ?>
                <form name="STS" method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('common/tournament');
                    ?>
</b><br>
                <?php 
                    echo HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'trid');
                    ?>
                <input type='submit' value='<?php 
                    echo $lng->getTrn('common/select');
                    ?>
'>
                </form>
                <br>
                <form method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('team', __CLASS__);
                    ?>
</b><br>
                <select name="tid" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    $teams = isset($_POST['trid']) ? Team::getTeams(false, array(get_parent_id(T_NODE_TOURNAMENT, (int) $_POST['trid'], T_NODE_LEAGUE)), true) : array();
                    foreach ($teams as $tid => $name) {
                        echo "<option value='{$tid}'>{$name}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <b><?php 
                    echo $lng->getTrn('kind', __CLASS__);
                    ?>
</b><br>
                <select name="ptype" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    foreach (self::getTypes() as $ptype => $desc) {
                        echo "<option value='{$ptype}'>{$desc}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <?php 
                    echo '<b>' . $lng->getTrn('g_title', __CLASS__) . '</b> &mdash; ' . $lng->getTrn('title', __CLASS__);
                    ?>
<br>
                <input type="text" name="title" size="60" maxlength="100" value="" <?php 
                    echo $_DISABLED;
                    ?>
>
                <br><br>
                <?php 
                    echo '<b>' . $lng->getTrn('g_about', __CLASS__) . '</b> &mdash; ' . $lng->getTrn('about', __CLASS__);
                    ?>
<br>
                <textarea name="txt" rows="15" cols="100" <?php 
                    echo $_DISABLED;
                    ?>
></textarea>
//.........这里部分代码省略.........
开发者ID:TheNAF,项目名称:naflm,代码行数:101,代码来源:class_prize.php


示例5: array

     break;
     /* Name autocompletion - AJAX */
 /* Name autocompletion - AJAX */
 case 'autocomplete':
     $objs = array();
     switch ($_GET['obj']) {
         case T_OBJ_COACH:
             $query = "SELECT coach_id AS 'id', name FROM coaches WHERE name LIKE '{$_GET['query']}%' ORDER BY name ASC";
             $result = mysql_query($query);
             while ($row = mysql_fetch_assoc($result)) {
                 $objs[$row['id']] = $row['name'];
             }
             break;
         case T_OBJ_TEAM:
             $lid = isset($_GET['trid']) ? get_parent_id(T_NODE_TOURNAMENT, (int) $_GET['trid'], T_NODE_LEAGUE) : false;
             $did = $lid && get_alt_col('leagues', 'lid', $lid, 'tie_teams') == 1 ? get_parent_id(T_NODE_TOURNAMENT, (int) $_GET['trid'], T_NODE_DIVISION) : false;
             $FROM_lid = $lid ? "f_lid = {$lid} AND" : '';
             $FROM_did = $did ? "f_did = {$did} AND" : '';
             $query = "SELECT team_id AS 'id', name, rdy FROM teams WHERE {$FROM_lid} {$FROM_did} name LIKE '%{$_GET['query']}%' ORDER BY name ASC";
             $result = mysql_query($query);
             while ($row = mysql_fetch_assoc($result)) {
                 $objs[$row['id']] = $row['name'];
             }
             break;
     }
     echo json_encode(array('query' => $_GET['query'], 'suggestions' => array_values($objs), 'data' => array_keys($objs)));
     break;
     /* League Tables */
 /* League Tables */
 case 'scheduler':
     $subtype = '';
开发者ID:nicholasmr,项目名称:obblm,代码行数:31,代码来源:handler.php


示例6: getSelectedNodeLid

 public static function getSelectedNodeLid()
 {
     global $leagues;
     $lids = array_keys($leagues);
     $_lid = false;
     if (isset($_SESSION[self::T_NSStr__node_id]) && (int) $_SESSION[self::T_NSStr__node_id] > 0) {
         $_lid = (int) $_SESSION[self::T_NSStr__node] != T_NODE_LEAGUE ? get_parent_id((int) $_SESSION[self::T_NSStr__node], (int) $_SESSION[self::T_NSStr__node_id], T_NODE_LEAGUE) : (int) $_SESSION[self::T_NSStr__node_id];
         if (!in_array($_lid, $lids)) {
             $_lid = false;
         }
     }
     return $_lid;
 }
开发者ID:nicholasmr,项目名称:obblm,代码行数:13,代码来源:class_htmlout.php


示例7: get_all_cat

function get_all_cat($fid)
{
    global $db, $pre;
    $query = $db->query("SELECT * FROM {$pre}sort WHERE fup=0");
    while ($rs = $db->fetch_array($query)) {
        $listdb[] = $rs;
    }
    foreach ($listdb as $key => $row) {
        $curpid = get_parent_id($fid);
        $pid = get_parent_id($row['fid']);
        $ishighlight = $curpid == $pid ? 1 : 0;
        $arr[$key] = array('pid' => $pid, 'fid' => $row['fid'], 'name' => $row['name'], 'sid' => get_sub_cat($row['fid']), 'ishighlight' => $ishighlight);
    }
    return $arr;
}
开发者ID:GHubgenius,项目名称:qbbj,代码行数:15,代码来源:artic_function.php


示例8: get_parent_name

function get_parent_name($type, $id, $parent_type)
{
    global $relations_node, $relations_obj;
    $relations = in_array($type, array_keys($relations_node)) ? $relations_node : $relations_obj;
    return get_alt_col($relations[$parent_type]['tbl'], $relations[$parent_type]['id'], get_parent_id($type, $id, $parent_type), 'name');
}
开发者ID:rythos42,项目名称:naflm,代码行数:6,代码来源:mysql.php


示例9: create

 public static function create(array $input)
 {
     /**
      * Creates a new match.
      *
      * Input: team1_id, team2_id, round, f_tour_id
      **/
     global $settings;
     # Used multiple times in error conditions below.
     $tour__f_lid = (int) get_parent_id(T_NODE_TOURNAMENT, (int) $input['f_tour_id'], T_NODE_LEAGUE);
     $tour__f_did = (int) get_parent_id(T_NODE_TOURNAMENT, (int) $input['f_tour_id'], T_NODE_DIVISION);
     $t1__f_lid = (int) get_alt_col('teams', 'team_id', $input['team1_id'], 'f_lid');
     $t2__f_lid = (int) get_alt_col('teams', 'team_id', $input['team2_id'], 'f_lid');
     $t1__f_did = (int) get_alt_col('teams', 'team_id', $input['team1_id'], 'f_did');
     $t2__f_did = (int) get_alt_col('teams', 'team_id', $input['team2_id'], 'f_did');
     $errors = array(self::T_CREATE_ERROR__IDENTICAL_TEAM_IDS => (int) $input['team1_id'] == (int) $input['team2_id'], self::T_CREATE_ERROR__IDENTICAL_PARENT_COACH => (int) get_alt_col('teams', 'team_id', $input['team1_id'], 'owned_by_coach_id') == (int) get_alt_col('teams', 'team_id', $input['team2_id'], 'owned_by_coach_id'), self::T_CREATE_ERROR__PARENT_TOUR_LOCKED => (bool) get_alt_col('tours', 'tour_id', $input['f_tour_id'], 'locked'), self::T_CREATE_ERROR__TEAM_LEAGUE_IDS_DIFFER => $t1__f_lid != $t2__f_lid, self::T_CREATE_ERROR__TEAM_DIVISION_IDS_DIFFER => (bool) get_alt_col('leagues', 'lid', $tour__f_lid, 'tie_teams') && $t1__f_did != $t2__f_did, self::T_CREATE_ERROR__ILLEGAL_PARENT_LID_OF_TOUR => $t1__f_lid != $tour__f_lid || $t2__f_lid != $tour__f_lid, self::T_CREATE_ERROR__ILLEGAL_PARENT_DID_OF_TOUR => (bool) get_alt_col('leagues', 'lid', $tour__f_lid, 'tie_teams') && ($t1__f_did != $tour__f_did || $t2__f_did != $tour__f_did));
     foreach ($errors as $exitStatus => $halt) {
         if ($halt) {
             return array($exitStatus, null);
         }
     }
     $query = "INSERT INTO matches (team1_id, team2_id, round, f_tour_id, date_created)\n                    VALUES ({$input['team1_id']}, {$input['team2_id']}, {$input['round']}, '{$input['f_tour_id']}', NOW())";
     if (mysql_query($query)) {
         $mid = mysql_insert_id();
     } else {
         self::$T_CREATE_SQL_ERROR['query'] = $query;
         self::$T_CREATE_SQL_ERROR['error'] = mysql_error();
         return array(self::T_CREATE_ERROR__SQL_QUERY_FAIL, null);
     }
     Module::runTriggers(T_TRIGGER_MATCH_CREATE, array($mid));
     return array(self::T_CREATE_SUCCESS, $mid);
 }
开发者ID:nicholasmr,项目名称:obblm,代码行数:32,代码来源:class_match.php


示例10: item_edit

function item_edit() {
	global $colors;
	require(CACTI_BASE_PATH . "/include/data_query/data_query_arrays.php");
	require(CACTI_BASE_PATH . "/include/graph_tree/graph_tree_arrays.php");

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	input_validate_input_number(get_request_var("tree_id"));
	/* ==================================================== */

	if (!empty($_GET["id"])) {
		$tree_item = db_fetch_row("select * from graph_tree_items where id=" . $_GET["id"]);

		if ($tree_item["local_graph_id"] > 0) { $db_type = TREE_ITEM_TYPE_GRAPH; }
		if ($tree_item["title"] != "") { $db_type = TREE_ITEM_TYPE_HEADER; }
		if ($tree_item["device_id"] > 0) { $db_type = TREE_ITEM_TYPE_DEVICE; }
	}

	if (isset($_GET["type_select"])) {
		$current_type = $_GET["type_select"];
	}elseif (isset($db_type)) {
		$current_type = $db_type;
	}else{
		$current_type = TREE_ITEM_TYPE_HEADER;
	}

	$tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='" . $_GET["tree_id"] . "'");

	print "<form action='tree.php' name='form_tree' method='post'>\n";

	html_start_box("<strong>" . __("Tree Items") . "</strong>", "100", $colors["header"], "3", "center", "");

	form_alternate_row_color("parent_item");
	?>
		<td width="50%">
			<font class="textEditTitle"><?php print __("Parent Item");?></font><br>
			<?php print __("Choose the parent for this header/graph.");?>
		</td>
		<td>
			<?php grow_dropdown_tree($_GET["tree_id"], "parent_item_id", (isset($_GET["parent_id"]) ? $_GET["parent_id"] : get_parent_id($tree_item["id"], "graph_tree_items", "graph_tree_id=" . $_GET["tree_id"])));?>
		</td>
	<?php
	form_end_row();
	form_alternate_row_color("tree_item");
	?>
		<td width="50%">
			<font class="textEditTitle"><?php print __("Tree Item Type");?></font><br>
			<?php print __("Choose what type of tree item this is.");?>
		</td>
		<td>
			<select name="type_select" onChange="window.location=document.form_tree.type_select.options[document.form_tree.type_select.selectedIndex].value">
				<?php
				while (list($var, $val) = each($tree_item_types)) {
					print "<option value='" . htmlspecialchars("tree.php?action=item_edit" . (isset($_GET["id"]) ? "&id=" . $_GET["id"] : "") . (isset($_GET["parent_id"]) ? "&parent_id=" . $_GET["parent_id"] : "") . "&tree_id=" . $_GET["tree_id"] . "&type_select=" . $var) . "'"; if ($var == $current_type) { print " selected"; } print ">$val</option>\n";
				}
				?>
			</select>
		</td>
	<?php
	form_end_row();
	?>
		<tr class='rowSubHeader'>
			<td colspan="2" class='textSubHeaderDark'><?php print __("Tree Item Value");?></td>
		</tr>
	<?php
	switch ($current_type) {
	case TREE_ITEM_TYPE_HEADER:
		$i = 0;

		/* it's nice to default to the parent sorting style for new items */
		if (empty($_GET["id"])) {
			$default_sorting_type = db_fetch_cell("select sort_children_type from graph_tree_items where id=" . $_GET["parent_id"]);
		}else{
			$default_sorting_type = DATA_QUERY_INDEX_SORT_TYPE_NONE;
		}

		form_alternate_row_color("item_title"); ?>
			<td width="50%">
				<font class="textEditTitle"><?php print __("Title");?></font><br>
				<?php print __("If this item is a header, enter a title here.");?>
			</td>
			<td>
				<?php form_text_box("title", (isset($tree_item["title"]) ? $tree_item["title"] : ""), "", "255", 30, "text", (isset($_GET["id"]) ? $_GET["id"] : "0"));?>
			</td>
		<?php
		form_end_row();
		/* don't allow the user to change the tree item ordering if a tree order has been specified */
		if ($tree_sort_type == DATA_QUERY_INDEX_SORT_TYPE_NONE) {
			form_alternate_row_color("sorting_type"); ?>
				<td width="50%">
					<font class="textEditTitle"><?php print __("Sorting Type");?></font><br>
					<?php print __("Choose how children of this branch will be sorted.");?>
				</td>
				<td>
					<?php form_dropdown("sort_children_type", $tree_sort_types, "", "", (isset($tree_item["sort_children_type"]) ? $tree_item["sort_children_type"] : $default_sorting_type), "", "");?>
				</td>
			<?php
			form_end_row();
		}

//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:tree.php


示例11: explode

 // Teams
 $team_ids = explode(',', $_POST['teams']);
 $teamsCount = count($team_ids);
 // Shortcut booleans:
 $mkNewFFA = $_POST['type'] == 'FFA_TOUR';
 $addMatchToFFA = $_POST['type'] == 'FFA_SINGLE';
 $nameSet = isset($_POST['name']) && !empty($_POST['name']) && !ctype_space($_POST['name']);
 /* Error condition definitions. */
 /*
     Here we test for illegal pair-ups due to league and division relations.
     Normally Match::create() does this too, but we don't want to end up creating a long list of matches first, but
     then have to abort because (for example) the last pair of teams are an illegal paring.
 */
 $teams_OK['l'] = $teams_OK['d'] = true;
 $lid = ($GOT_DID = $_POST['type'] == 'RR_TOUR' || $mkNewFFA) ? get_parent_id(T_NODE_DIVISION, $_POST['did'], T_NODE_LEAGUE) : get_parent_id(T_NODE_TOURNAMENT, $_POST['existTour'], T_NODE_LEAGUE);
 $did = $GOT_DID ? $_POST['did'] : get_parent_id(T_NODE_TOURNAMENT, $_POST['existTour'], T_NODE_DIVISION);
 $TIE_TEAMS = get_alt_col('leagues', 'lid', $lid, 'tie_teams');
 foreach ($team_ids as $tid) {
     $query = "SELECT (t.f_did = {$did}) AS 'in_did', (t.f_lid = {$lid}) AS 'in_lid' FROM teams AS t WHERE t.team_id = {$tid}";
     $result = mysql_query($query);
     if ($result) {
         $state = mysql_fetch_assoc($result);
         if (!$state['in_lid']) {
             $teams_OK['l'] = false;
             break;
         }
         if ($TIE_TEAMS && !$state['in_did']) {
             $teams_OK['d'] = false;
             break;
         }
     }
开发者ID:nicholasmr,项目名称:obblm,代码行数:31,代码来源:admin_schedule.php


示例12: get_parent_id

						display_help($me);
						exit(1);
				}
				if (!strlen($sql_vars)) {	# no sql updates required
					$sql = "";
				} else {
					$sql .= $sql_vars . " WHERE id=" . $tree_item["id"];
				}

				if (!$debug) {
					if (strlen($sql)) {	# if only reparent action required, sql may be empty
						db_execute($sql);
					}
					/* re-parent the branch if the parent item has changed */
					if (isset($tree_item["parent_node"])) {
						$current_parent = get_parent_id($tree_item["id"], "graph_tree_items");
						if ($tree_item["parent_node"] != $current_parent) {
							reparent_branch($tree_item["parent_node"], $tree_item["id"]);
						}
					}
					echo __("Success - Tree item updated (%s)", $tree_item["id"]) . "\n";
				} else {
					print $sql . "\n";
				}

				break;

			default:
				echo __("ERROR: Unknown type: (%s)", $type) . "\n";
				display_help($me);
				exit(1);
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:tree_update.php


示例13: reparent_branch

function reparent_branch($new_parent_id, $tree_item_id) {
	if (empty($tree_item_id)) { return 0; }

	/* get the current tree_id */
	$graph_tree_id = db_fetch_cell("select graph_tree_id from graph_tree_items where id=$tree_item_id");

	/* make sure the parent id actually changed */
	if (get_parent_id($tree_item_id, "graph_tree_items", "graph_tree_id=$graph_tree_id") == $new_parent_id) {
		return 0;
	}

	/* get current key so we can do a sql select on it */
	$old_order_key = db_fetch_cell("select order_key from graph_tree_items where id=$tree_item_id");
	$new_order_key = get_next_tree_id(db_fetch_cell("select order_key from graph_tree_items where id=$new_parent_id"), "graph_tree_items", "order_key", "graph_tree_id=$graph_tree_id");

	/* yeah, this would be really bad */
	if (empty($old_order_key)) { return 0; }

	$old_starting_tier = tree_tier($old_order_key);
	$new_starting_tier = tree_tier($new_order_key);

	$new_base_tier = substr($new_order_key, 0, ($new_starting_tier * CHARS_PER_TIER));
	$old_base_tier = substr($old_order_key, 0, ($old_starting_tier * CHARS_PER_TIER));

	/* prevent possible collisions */
	db_execute("update graph_tree_items set order_key = ".sql_function_concat("'x'","order_key")." where order_key like '$old_base_tier%%' and graph_tree_id=$graph_tree_id");

	/* truncate */
	if ($new_starting_tier >= $old_starting_tier) {
		db_execute("update graph_tree_items set order_key = ".sql_function_substr()."(".sql_function_replace()."(order_key, 'x$old_base_tier', '$new_base_tier'), 1, " . (MAX_TREE_DEPTH * CHARS_PER_TIER) . ") where order_key like 'x$old_base_tier%%' and graph_tree_id=$graph_tree_id");
	/* append */
	}else{
		db_execute("update graph_tree_items set order_key = ".sql_function_concat(sql_function_replace()."(order_key, 'x$old_base_tier', '$new_base_tier')"," '" . str_repeat('0', (strlen($old_base_tier) - strlen($new_base_tier))) . "'")." where order_key like 'x$old_base_tier%%' and graph_tree_id=$graph_tree_id");
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:35,代码来源:tree.php


示例14: item_edit

function item_edit()
{
    global $colors, $tree_sort_types;
    global $tree_item_types, $host_group_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("tree_id"));
    /* ==================================================== */
    /* modify for multi user start */
    $public_tree = FALSE;
    if ($_SESSION["permission"] <= ACCESS_ADMINISTRATOR) {
        if ($_GET["tree_id"] == $_SESSION["public_tree_id"]) {
            $public_tree = TRUE;
        } else {
            if (!empty($_GET["id"])) {
                if (!check_tree_item($_GET["id"])) {
                    access_denied();
                }
            }
        }
    }
    /* modify for multi user end */
    if (!empty($_GET["id"])) {
        $tree_item = db_fetch_row("select * from graph_tree_items where id=" . get_request_var("id"));
        if ($tree_item["local_graph_id"] > 0) {
            $db_type = TREE_ITEM_TYPE_GRAPH;
        }
        if ($tree_item["title"] != "") {
            $db_type = TREE_ITEM_TYPE_HEADER;
        }
        if ($tree_item["host_id"] > 0) {
            $db_type = TREE_ITEM_TYPE_HOST;
        }
    }
    if (isset($_GET["type_select"])) {
        $current_type = $_GET["type_select"];
    } elseif (isset($db_type)) {
        $current_type = $db_type;
    } else {
        $current_type = TREE_ITEM_TYPE_HEADER;
    }
    $tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='" . get_request_var("tree_id") . "'");
    print "<form method='post' action='tree.php' name='form_tree'>\n";
    html_start_box("<strong>Tree Items</strong>", "100%", $colors["header"], "3", "center", "");
    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 0);
    ?>
		<td width="50%">
			<font class="textEditTitle">Parent Item</font><br>
			Choose the parent for this header/graph.
		</td>
		<td>
			<?php 
    grow_dropdown_tree($_GET["tree_id"], "parent_item_id", isset($_GET["parent_id"]) ? $_GET["parent_id"] : get_parent_id($tree_item["id"], "graph_tree_items", "graph_tree_id=" . $_GET["tree_id"]));
    ?>
		</td>
	</tr>
	<?php 
    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 1);
    ?>
		<td width="50%">
			<font class="textEditTitle">Tree Item Type</font><br>
			Choose what type of tree item this is.
		</td>
		<td>
			<select name="type_select" onChange="window.location=document.form_tree.type_select.options[document.form_tree.type_select.selectedIndex].value">
				<?php 
    /* modify for multi user start */
    if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
        if (!db_fetch_cell("\r\n                        SELECT COUNT(graph_local.id) FROM graph_local\r\n                            INNER JOIN host ON graph_local.host_id = host.id\r\n                            INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'")) {
            unset($tree_item_types[2]);
            // graph
        }
        if (!db_fetch_cell("\r\n                        SELECT COUNT(host.id) FROM host\r\n                            INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'")) {
            unset($tree_item_types[3]);
            // host
        }
        if ($public_tree == TRUE) {
            unset($tree_item_types[1]);
            // header
            unset($tree_item_types[3]);
            // host
            $current_type = 2;
        }
    }
    /* modify for multi user end */
    while (list($var, $val) = each($tree_item_types)) {
        print "<option value='tree.php?action=item_edit" . (isset($_GET["id"]) ? "&id=" . $_GET["id"] : "") . (isset($_GET["parent_id"]) ? "&parent_id=" . $_GET["parent_id"] : "") . "&tree_id=" . $_GET["tree_id"] . "&type_select={$var}'";
        if ($var == $current_type) {
            print " selected";
        }
        print ">{$val}</option>\n";
    }
    ?>
			</select>
		</td>
	</tr>
	<tr bgcolor='#<?php 
    print $colors["header_panel"];
    ?>
'>
//.........这里部分代码省略.........
开发者ID:resmon,项目名称:resmon-cacti,代码行数:101,代码来源:tree.php


示例15: item_edit

function item_edit() {
	global $colors, $tree_sort_types;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	input_validate_input_number(get_request_var("tree_id"));
	/* ==================================================== */

	$tree_item_types = array(
		TREE_ITEM_TYPE_HEADER => "Header",
		TREE_ITEM_TYPE_GRAPH => "Graph",
		TREE_ITEM_TYPE_HOST => "Host"
		);

	$host_group_types = array(
		HOST_GROUPING_GRAPH_TEMPLATE => "Graph Template",
		HOST_GROUPING_DATA_QUERY_INDEX => "Data Query Index"
		);

	if (!empty($_GET["id"])) {
		$tree_item = db_fetch_row("select * from graph_tree_items where id=" . $_GET["id"]);

		if ($tree_item["local_graph_id"] > 0) { $db_type = TREE_ITEM_TYPE_GRAPH; }
		if ($tree_item["title"] != "") { $db_type = TREE_ITEM_TYPE_HEADER; }
		if ($tree_item["host_id"] > 0) { $db_type = TREE_ITEM_TYPE_HOST; }
	}

	if (isset($_GET["type_select"])) {
		$current_type = $_GET["type_select"];
	}elseif (isset($db_type)) {
		$current_type = $db_type;
	}else{
		$current_type = TREE_ITEM_TYPE_HEADER;
	}

	$tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='" . $_GET["tree_id"] . "'");

	html_start_box("<strong>Tree Items</strong>", "100%", $colors["header"], "3", "center", "");

	print "<form method='post' action='tree.php' name='form_tree'>\n";

	form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?>
		<td width="50%">
			<font class="textEditTitle">Parent Item</font><br>
			Choose the parent for this header/graph.
		</td>
		<td>
			<?php grow_dropdown_tree($_GET["tree_id"], "parent_item_id", (isset($_GET["parent_id"]) ? $_GET["parent_id"] : get_parent_id($tree_item["id"], "graph_tree_items", "graph_tree_id=" . $_GET["tree_id"])));?>
		</td>
	</tr>
	<?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],1); ?>
		<td width="50%">
			<font class="textEditTitle">Tree Item Type</font><br>
			Choose what type of tree item this is.
		</td>
		<td>
			<select name="type_select" onChange="window.location=document.form_tree.type_select.options[document.form_tree.type_select.selectedIndex].value">
				<?php
				while (list($var, $val) = each($tree_item_types)) {
					print "<option value='tree.php?action=item_edit" . (isset($_GET["id"]) ? "&id=" . $_GET["id"] : "") . (isset($_GET["parent_id"]) ? "&parent_id=" . $_GET["parent_id"] : "") . "&tree_id=" . $_GET["tree_id"] . "&type_select=$var'"; if ($var == $current_type) { print " selected"; } print ">$val</option>\n";
				}
				?>
			</select>
		</td>
	</tr>
	<tr bgcolor='#<?php print $colors["header_panel"];?>'>
		<td colspan="2" class='textSubHeaderDark'>Tree Item Value</td>
	</tr>
	<?php
	switch ($current_type) {
	case TREE_ITEM_TYPE_HEADER:
		$i = 0;

		/* it's nice to default to the parent sorting style for new items */
		if (empty($_GET["id"])) {
			$default_sorting_type = db_fetch_cell("select sort_children_type from graph_tree_items where id=" . $_GET["parent_id"]);
		}else{
			$default_sorting_type = TREE_ORDERING_NONE;
		}

		form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
			<td width="50%">
				<font class="textEditTitle">Title</font><br>
				If this item is a header, enter a title here.
			</td>
			<td>
				<?php form_text_box("title", (isset($tree_item["title"]) ? $tree_item["title"] : ""), "", "255", 30, "text", (isset($_GET["id"]) ? $_GET["id"] : "0"));?>
			</td>
		</tr>
		<?php
		/* don't allow the user to change the tree item ordering if a tree order has been specified */
		if ($tree_sort_type == TREE_ORDERING_NONE) {
			form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
				<td width="50%">
					<font class="textEditTitle">Sorting Type</font><br>
					Choose how children of this branch will be sorted.
				</td>
				<td>
					<?php form_dropdown("sort_children_type", $tree_sort_types, "", "", (isset($tree_item["sort_children_type"]) ? $tree_item["sort_children_type"] : $default_sorting_type), "", "");?>
				</td>
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:tree.php


示例16: userSched

    public static function userSched()
    {
        global $lng, $coach, $settings, $leagues, $divisions, $tours;
        if (!is_object($coach)) {
            status(false, "You must be logged in to schedule games");
            return;
        }
        if (isset($_POST['creategame'])) {
            // Test input
            $trid = (int) $_POST['trid'];
            $round = (int) $_POST['round'];
            $own_team = (int) $_POST['own_team'];
            $errmsg = '';
            // Logged in coach has access to the tour?
            if (!in_array($trid, array_keys($tours))) {
                $errmsg = 'You do not have access to the tournament ' . $tours[$trid]['tname'];
            }
            // Is the team is really owned by the logged in coach?
            if ($coach->coach_id != get_alt_col('teams', 'team_id', $own_team, 'owned_by_coach_id')) {
                $errmsg = 'The team ' . get_alt_col('teams', 'team_id', $own_team, 'name') . ' is not owned by you';
            }
            // Create match
            if (!$errmsg) {
                list($exitStatus, $mid) = Match::create(array('team1_id' => $own_team, 'team2_id' => get_alt_col('teams', 'name', $_POST['opposing_team_autocomplete'], 'team_id'), 'round' => $round, 'f_tour_id' => $trid));
                $backFromMatchLink = Mobile::isMobile() ? "index.php?mobile=1" : "index.php?section=matches&amp;type=report&amp;mid={$mid}";
                status(!$exitStatus, $exitStatus ? Match::$T_CREATE_ERROR_MSGS[$exitStatus] : "<a href='{$backFromMatchLink}'>Click here</a> to open the match report");
                if (!$exitStatus) {
                    echo "<br>";
                }
            } else {
                status(false, $errmsg);
            }
        }
        $trid = isset($_GET['trid']) && is_numeric($_GET['trid']) ? (int) $_GET['trid'] : 0;
        $lid = $trid ? get_parent_id(T_NODE_TOURNAMENT, $trid, T_NODE_LEAGUE) : false;
        $lname = $lid ? get_parent_name(T_NODE_TOURNAMENT, $trid, T_NODE_LEAGUE) : '- N/A -';
        $did = $trid && get_alt_col('leagues', 'lid', $lid, 'tie_teams') == 1 ? get_parent_id(T_NODE_TOURNAMENT, $trid, T_NODE_DIVISION) : false;
        $dname = $did ? get_parent_name(T_NODE_TOURNAMENT, $trid, T_NODE_DIVISION) : false;
        $_DISABLED = !$trid ? 'DISABLED' : '';
        #print_r(array($trid, $lid, $lname, $did));
        title($lng->getTrn('menu/matches_menu/usersched'));
        $LOCK_FORMS = false;
        ?>
    <div class='boxCommon'>
        <h3 class='boxTitle<?php 
        echo T_HTMLBOX_MATCH;
        ?>
'><?php 
        echo $lng->getTrn('menu/matches_menu/usersched');
        ?>
</h3>
        <div class='boxBody'>
            <form method="POST" id="usersched">
                <?php 
        echo "In tournament ";
        echo HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'trid', array(T_NODE_TOURNAMENT => array('locked' => 0, 'type' => TT_FFA, 'allow_sched' => 1)), array(), array('sel_id' => $trid, 'extra_tags' => array('onChange="document.location.href = \'' . getFormAction('?section=matches&type=usersched') . '&trid=\' + $(this).val();"'), 'init_option' => '<option value="0">- ' . $lng->getTrn('matches/usersched/selecttour') . " -</option>\n"));
        echo ' as ';
        echo '<select name="round" id="round" ' . $_DISABLED . '>';
        $T_ROUNDS = Match::getRounds();
        foreach ($T_ROUNDS as $r => $d) {
            echo "<option value='{$r}' " . ($r == 1 ? 'SELECTED' : '') . ">" . $d . "</option>\n";
        }
        ?>
                </select>
                <br><br>
                Your team
                <?php 
        $teams = array();
        foreach ($coach->getTeams($lid, $did, array('sortby' => 'team_id DESC')) as $t) {
            if (!$t->rdy || $t->is_retired) {
                continue;
            }
            $teams[] = $t;
        }
        ?>
                <select name='own_team' id='own_team' <?php 
        echo $_DISABLED;
        ?>
>
                    <?php 
        echo "<optgroup class='leagues' label='{$lname}'>\n";
        if ($dname) {
            echo "<optgroup class='divisions' label='&nbsp;&nbsp;{$dname}'>\n";
        }
        foreach ($teams as $t) {
            echo "<option style='background-color: white; margin-left: -1em;' value='{$t->team_id}'>&nbsp;&nbsp;&nbsp;{$t->name}</option>\n";
        }
        ?>
                </select>
                &nbsp;
                VS.
                <input type="text" id='opposing_team_autoselect' name="opposing_team_autocomplete" size="30" maxlength="50" <?php 
        echo $_DISABLED;
        ?>
>
                <script>
                    $(document).ready(function(){
                        var options, b;

                        options = {
//.........这里部分代码省略.........
开发者ID:TheNAF,项目名称:naflm,代码行数:101,代码来源:class_match_htmlout.php


示例17: export_build_graphs

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_parent_interface函数代码示例发布时间:2022-05-15
下一篇:
PHP get_parent_grade函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap