Esempio n. 1
0
function generate_tree($id, $mode = '')
{
    # selected item
    # get childs
    $child_array = get_childs($id, $mode);
    # get information of selected item
    $query = 'SELECT DISTINCT attr_value as name,ItemLinks.fk_id_item AS item_id,
                  (SELECT config_class FROM ConfigItems,ConfigClasses
                      WHERE id_class=fk_id_class AND id_item=item_id) AS type,
                  (SELECT attr_value
                    FROM ConfigValues, ItemLinks, ConfigAttrs, ConfigClasses
                    WHERE ConfigValues.fk_id_item = ItemLinks.fk_item_linked2
                    AND id_attr = ConfigValues.fk_id_attr
                    AND attr_name = "icon_image"
                    AND id_class = fk_id_class
                    AND config_class = "os"
                    AND ItemLinks.fk_id_item = item_id
                  ) AS os_icon
                FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses
                WHERE ItemLinks.fk_id_item=ConfigValues.fk_id_item
                    AND id_attr=ItemLinks.fk_id_attr
                    AND ConfigAttrs.visible="yes"
                    AND fk_id_class=id_class
                    AND (SELECT naming_attr FROM ConfigAttrs WHERE id_attr=ConfigValues.fk_id_attr)="yes"
                    AND ItemLinks.fk_id_item="' . $id . '"
                ORDER BY config_class DESC,attr_value';
    $selected_item_info = db_handler($query, "assoc", "Get informations on selected item");
    # get informations about host
    # prepend inforomation from selected host to the top of the list
    array_unshift($child_array, get_informations($id));
    # set values of selected item AND put all childs (generated bevore) in it.
    $root_item = array($id => array("id" => $id, "selected" => TRUE, "status" => 'open', "name" => $selected_item_info["name"], "type" => $selected_item_info["type"], "os_icon" => $selected_item_info["os_icon"], "childs" => $child_array));
    # get parents
    $parents_flat = get_parents($id);
    # make the parents array ordered top2down
    $parents_flat = array_reverse($parents_flat);
    # prepare list (if there are parents call the prepare function
    if (!empty($parents_flat)) {
        $tree = prepare_dependency($parents_flat, $root_item);
    } else {
        $tree = $root_item;
    }
    ## Display the top tree item
    # check for parent loop error
    if (isset($tree[0]["status"]) and $tree[0]["status"] == "loop_error") {
        # make a error item at the top
        $dependency_tree = array("root" => array("id" => "root", "status" => 'open', "name" => TXT_DEPVIEW_ERROR_LOOP, "type" => "warn", "childs" => $tree));
    } else {
        # make a root tree at the top
        $dependency_tree = array("root" => array("id" => "root", "status" => 'open', "name" => "Top level", "type" => "parent", "childs" => $tree));
    }
    //echo "<pre>";
    //var_dump($tree);
    //echo "</pre>";
    echo '<div>';
    displayTree_list($dependency_tree);
    echo '</div>';
}
Esempio n. 2
0
function get_parents($id, &$parents)
{
    global $db, $module_prefix;
    $parent = $db->sql_ufetchrow("SELECT id, parent_id, pos, title FROM " . $module_prefix . "_pages WHERE id={$id}", SQL_ASSOC);
    if ($parent['parent_id'] > 0) {
        get_parents($parent['parent_id'], $parents);
    }
    $parents[] = $parent;
}
Esempio n. 3
0
 public function routeCatList()
 {
     $this->load->helper('wall_type');
     $cat = $_POST['cat'];
     $parents = get_parents($cat);
     $url = site_url("ads?cat=0");
     if (isset($parents[0])) {
         echo "<span class=\"spanpath\"><a href=\"{$url}\" class=\"filterCats\" data-id=\"0\">خانه</a></span>";
         $ctr = 0;
         $max = count($parents);
         foreach ($parents as $parent) {
             $ctr++;
             $url = site_url("ads?cat={$parent['id']}");
             if ($ctr != $max) {
                 echo "<span class=\"spanpath\"><a href=\"{$url}\" class=\"filterCats\" data-id=\"{$parent['id']}\">{$parent['title']}</a></span>";
             } else {
                 echo "<span ><a href=\"{$url}\" class=\"filterCats\" data-id=\"{$parent['id']}\">{$parent['title']}</a></span>";
             }
         }
     } else {
         echo "<span><a href=\"{$url}\" class=\"filterCats\" data-id=\"0\">خانه</a></span>";
     }
 }
Esempio n. 4
0
function get_parents($id, &$flat = array(), $levels = 0)
{
    # $all_parents holds the taken parents, so the function will stop getting more parents if one already was fetched
    # (otherwise it will be an endless loop)
    global $all_parents;
    $all_parents[$id] = TRUE;
    $parent_id = 0;
    # get parents
    $sql = 'SELECT ConfigAttrs.friendly_name,attr_value,fk_item_linked2 AS item_id,
                (SELECT config_class FROM ConfigItems,ConfigClasses WHERE id_class=fk_id_class AND id_item=item_id) AS config_class,
(SELECT attr_value
                    FROM ConfigValues, ItemLinks, ConfigAttrs, ConfigClasses
                    WHERE ConfigValues.fk_id_item = ItemLinks.fk_item_linked2
                    AND id_attr = ConfigValues.fk_id_attr
                    AND attr_name = "icon_image"
                    AND id_class = fk_id_class
                    AND config_class = "os"
                    AND ItemLinks.fk_id_item = item_id
                  ) AS os_icon
            FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses
            WHERE fk_item_linked2=ConfigValues.fk_id_item
                AND id_attr=ItemLinks.fk_id_attr
                AND fk_id_class=id_class
                AND (SELECT naming_attr FROM ConfigAttrs WHERE id_attr=ConfigValues.fk_id_attr) ="yes"
                AND ItemLinks.fk_id_item=' . $id . '
                AND ConfigAttrs.attr_name = "parents"
            ORDER BY ConfigAttrs.friendly_name DESC,attr_value';
    $result = db_handler($sql, "result", "Recursive get parents");
    while ($entry = mysql_fetch_assoc($result)) {
        #special for services
        /*
                if($entry["config_class"] == "service"){
                    $host_query = 'SELECT attr_value AS hostname FROM ConfigValues,ConfigAttrs,ConfigClasses,ItemLinks
                                                   WHERE fk_item_linked2=ConfigValues.fk_id_item
                                                       AND id_attr=ConfigValues.fk_id_attr
                                                       AND naming_attr="yes"
                                                       AND fk_id_class = id_class
                                                       AND config_class="host"
                                                       AND ItemLinks.fk_id_item='.$entry["item_id"];
        
                    $hostname = db_handler($host_query, "getOne", "Get linked hostnames");
                }*/
        # set parent
        $flat[$levels][$parent_id]["name"] = $entry["attr_value"];
        $flat[$levels][$parent_id]["id"] = $entry["item_id"];
        $flat[$levels][$parent_id]["child"] = $id;
        $flat[$levels][$parent_id]["os_icon"] = $entry["os_icon"];
        $flat[$levels][$parent_id]["type"] = $entry["config_class"];
        # check if that parent is called a second time (prevent a endless loop)
        if (!isset($all_parents[$entry["item_id"]])) {
            # go get all all parents recursive
            get_parents($entry["item_id"], $flat, $levels + 1);
        } else {
            # parent loop
            $parent_loop = TRUE;
            $flat[$levels][$parent_id]["status"] = "loop_error";
        }
        # increase parent
        $parent_id++;
    }
    # return parent information
    return $flat;
}
Esempio n. 5
0
 // IF NO PROCESSGUID FOUND EXIT
 if (empty($tempArray[0])) {
     exit('Process Guid not found sorry!');
 }
 $selected_obj = $tempArray[0];
 $sysobj = $selected_obj;
 // GET CHILD PROCESSES UP TO 10 DEEP
 $childProcessArray = get_child_process($sysobj);
 // print_r($childProcessArray);
 array_push($globalProcessArray, $selected_obj);
 $parentProcessArray = array();
 $x = 0;
 $obj = $selected_obj;
 // GET PARENT PROCESSES UP TO 10 DEEP
 while (true && $x < 10) {
     $parentProcessArray = get_parents($obj);
     if (!is_null($parentProcessArray)) {
         // is initial condition true
         // do something that also changes initial condition
         $obj = $parentProcessArray[0];
         array_push($globalProcessArray, $obj);
     } else {
         // condition failed
         break;
         // leave loop
     }
     $x++;
 }
 $divider = "&nbsp;&nbsp;";
 $reverse_array = array_reverse($globalProcessArray);
 //DISPLAY ARRAYS
Esempio n. 6
0
 public function edit($id = false)
 {
     if ($this->ion_auth->logged_in() && $id) {
         $this->load->helper('wall_type');
         $this->load->helper('wall_mapdb');
         $this->load->model('ads_model');
         $this->load->model('user_model');
         $uid = $this->get_uid();
         $admin = ($this->ion_auth->is_admin() or $this->ion_auth->in_group(3) && $this->permission(2));
         $owner = $this->get_adsOwner($id);
         if ($uid == $owner or $admin) {
             $data['ads'] = $this->ads_model->get_detail($id);
             $data['routes'] = get_parents($data['ads']['info']['cat_']);
             // print_r($data['routes']);
             $data['cat_childs']['items'][0] = get_slave_items(1, 0);
             foreach ($data['routes'] as $key => $parent) {
                 $data['cat_childs']['selected'][$key] = $parent['id'];
                 $key++;
                 $data['cat_childs']['items'][$key] = get_slave_items(1, $parent['id']);
                 // $data['cat_childs'][$key]['selected'] = array('sel' => $parent['id']);
             }
             $data['states'] = get_state();
             $data['state_id'] = $this->session->userdata('state');
             $data['cities'] = get_city(false, $data['ads']['info']['state_']);
             //print_r($data['ads']['fields']);
             $this->load->view('ads/edit', $data);
         } else {
             $msg = "عدم دسترسی، لطفا وارد شوید.";
             $this->session->set_userdata('error', $msg);
             $this->session->set_userdata('redirect', "dashboard/myads");
             redirect(site_url('user/login'));
             exit;
         }
         //print_r($data['ads']);
     } else {
         $msg = "عدم دسترسی، لطفا وارد شوید.";
         $this->session->set_userdata('error', $msg);
         $this->session->set_userdata('redirect', "ads/edit/{$id}");
         redirect(site_url('user/login'));
         exit;
     }
 }
Esempio n. 7
0
 /**
  * An array of string identifiers that uniquely idenitifies an entity such as class name, parent
  * classes and the entity service identifier
  *
  * @return array
  */
 public function getUniqueIdentifiers()
 {
     if (!isset($this->_unique_identifiers)) {
         $classname = $this->getEntityIdentifier()->classname;
         $this->_unique_identifiers = get_parents($classname, 'AnDomainEntity');
         if (strpos($classname, 'AnDomainEntity') !== 0) {
             $this->_unique_identifiers[] = $classname;
         }
         $this->_unique_identifiers[] = (string) $this->getEntityIdentifier();
     }
     return $this->_unique_identifiers;
 }
function get_parents(&$obj, $obj_id, $level)
{
    if (is_array($obj[$obj_id])) {
        if ($level <= 10) {
            foreach ($obj[$obj_id] as $parent_id) {
                if ($parent_id > 0) {
                    $result = get_parents($obj, $parent_id, ++$level);
                    if (!is_numeric($result)) {
                        $parents .= $result;
                        $parents .= $parent_id . ",";
                    } else {
                        return 0;
                    }
                }
            }
        } else {
            return 0;
        }
    }
    return $parents;
}
            if ($level < $maxlevel) {
                // point of recursion
                build_tree($family[$count][0], $henry, $level + 1, $total);
            }
            $count++;
        }
        echo "</ul></li>\n";
    }
    return;
}
$person = $_GET["person"];
$name = get_name($person);
$descendants = true;
$title = "{$person} {$name}, {$_descendants}";
require "./header.php";
echo "<div class=\"normal\">";
print "<h2>{$_Descendants} {$_of} {$name}</h2>\n";
$parents = get_parents($person);
print "<p><strong>{$_Father}:</strong> {$parents['0']}<br />\n";
print "<strong>{$_Mother}:</strong> {$parents['1']}\n</p>\n";
printf("<ul class=\"descendants\">\n<li><strong>%s</strong></li>\n", get_name_and_dates('./family.php', $person));
$spouses = 0;
$descendants = 0;
build_tree($person, '', 0, 0);
echo "</ul>\n";
echo "<p>{$_There_are} {$descendants} {$_descendants} {$_and} {$coparents} {$_coparents} {$_in_this_report}.</p>\n";
echo '<p class="bmd">Utskrift av ' . mydate(date("Y-m-d")) . "</p>\n";
// this report is a great handout, and I include my name and address here
researcher_info('leif.txt');
echo "</div>\n";
include "./footer.php";
Esempio n. 10
0
if (!defined('CPG_NUKE')) {
    exit;
}
require_once "modules/{$module_name}/inc/functions.php";
//define('MEMBER_BLOCK', true);
if (isset($_GET['id'])) {
    $page_id = intval($_GET['id']);
    $page = $db->sql_ufetchrow("SELECT * FROM " . $module_prefix . "_pages WHERE id={$page_id}", SQL_ASSOC);
    if (!$page || empty($page['title'])) {
        cpg_error('Page doesn\'t exist');
    }
    $page_no = '';
    $crumbs[] = '<a href="' . URL::index() . '">' . $module_name . '</a>';
    if ($page['parent_id'] > 0) {
        $parents = array();
        get_parents($page['parent_id'], $parents);
        foreach ($parents as $parent) {
            $page_no .= "{$parent['pos']}.";
            $crumbs[] = '<a href="' . URL::index('&amp;id=' . $parent['id']) . '">' . $parent['title'] . '</a>';
        }
    }
    $crumbs[] = $page['title'];
    $crumbs = implode(' ' . _BC_DELIM . ' ', $crumbs);
    $pagetitle = strip_tags($crumbs);
    $tree = $page;
    $tree['sub'] = list_all($page['id'], false);
    $tree = go_up($tree);
    require_once 'header.php';
    $cpgtpl->assign_vars(array('G_ID' => '1', 'U_CRUMBS' => '<span style="float: left;">' . $crumbs . '</span>', 'U_ADDPAGE' => is_user() ? '<a href="' . URL::index('&amp;file=manage') . '">Add new page</a>' : '', 'U_EDITPAGE' => isset($_GET['id']) ? '&nbsp;|&nbsp;<a href="' . URL::index('&amp;file=manage&amp;id=' . intval($_GET['id'])) . '">Edit this page</a>' : '', 'U_TREE' => create_tree($page_id, $tree), 'S_PAGE' => $page_no, 'S_SUBPAGE' => $page['pos'], 'S_TITLE' => $page['title'], 'S_COMMENT' => $page['comment'], 'S_BODY' => $page['body'], 'S_AUTHOR' => 'Author:&nbsp;<a href="' . URL::index('Your_Account&amp;profile=' . $page['user_id']) . '">' . $page['author'] . '</a>', 'S_CREATED' => 'Created:&nbsp;' . formatDateTime($page['time'], _DATESTRING), 'S_UPDATED' => $page['supercede'] ? 'Last update: ' . formatDateTime($page['supercede'], _DATESTRING) . ' by <a href="' . URL::index('Your_Account&amp;profile=' . $page['upd_user_id']) . '">' . $page['upd_author'] . '</a>' : ''));
    $cpgtpl->set_filenames(array('body' => 'wiki/index.html'));
    $cpgtpl->display('body');
Esempio n. 11
0
function get_cat_pic($id)
{
    $parents = get_parents($id);
    $ci =& get_instance();
    $ci->load->database();
    $ci->db->where('cat_', $parents[0]['id']);
    $query = $ci->db->get('cat_pics');
    $pic = $query->row_array();
    if (isset($pic['pic'])) {
        return $pic['pic'];
    } else {
        return false;
    }
}
Esempio n. 12
0
function get_parents_ids($arr, $id)
{
    $ret = array();
    foreach ($arr as $item) {
        if ($item['id'] == $id) {
            $ret[] = $item['id'];
            $parent = get_parents($arr, $item['parent_id']);
            $ret = array_merge($parent, $ret);
        }
    }
    return $ret;
}