/**
 * create object with all user inputs
 *
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $key2search = array('doAction', 'cfield', 'display_order', 'location', 'hidden_active_cfield', 'active_cfield', 'hidden_required_cfield', 'required_cfield');
    foreach ($key2search as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : null;
    }
    // Need comments
    if (!$args->cfield) {
        $args->cfield = array();
    }
    $args->tproject_name = '';
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id == 0) {
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    if ($args->tproject_id > 0) {
        $mgr = new tree($dbHandler);
        $dummy = $mgr->get_node_hierarchy_info($args->tproject_id, null, array('nodeType' => 'testproject'));
        if (is_null($dummy)) {
            throw new Exception("Unable to get Test Project ID");
        }
        $args->tproject_name = $dummy['name'];
    }
    return $args;
}
 public function load($param)
 {
     $key = $this->build_key(__CLASS__, $param);
     $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
     $cate_list = $GLOBALS['fcache']->get($key);
     if ($cate_list === false) {
         $pid = intval($param['pid']);
         $extwhere = $param['extwhere'];
         require_once APP_ROOT_PATH . "system/utils/child.php";
         require_once APP_ROOT_PATH . "system/utils/tree.php";
         $ids_util = new child("deal_cate");
         $ids = $ids_util->getChildIds($pid);
         $ids[] = $pid;
         $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate where is_effect = 1 and is_delete = 0 and id in (" . implode(",", $ids) . ") {$extwhere} order by sort desc");
         foreach ($cate_list as $k => $v) {
             if ($v['uname'] != '') {
                 $curl = url("youhui", "ycate", array("id" => $v['uname']));
             } else {
                 $curl = url("youhui", "ycate", array("id" => $v['id']));
             }
             $cate_list[$k]['url'] = $curl;
             $sub_ids = $ids_util->getChildIds($v['id']);
             $sub_ids[] = $v['id'];
             $cate_list[$k]['count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and is_shop = 2 and cate_id in (" . implode(",", $sub_ids) . ")");
         }
         $tree_util = new tree();
         $cate_list = $tree_util->toFormatTree($cate_list, 'name');
         $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
         $GLOBALS['fcache']->set($key, $cate_list);
     }
     return $cate_list;
 }
示例#3
0
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->show_help = isset($_REQUEST['level']) && $_REQUEST['level'] == 'testproject';
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    $args->tplan_name = '';
    if ($args->tplan_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tplan_id);
        $args->tplan_name = $dummy['name'];
    }
    $args->node_type = isset($_REQUEST['level']) ? $_REQUEST['level'] : OFF;
    $args->node_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ERROR;
    // Sets urgency for suite
    if (isset($_REQUEST['high_urgency'])) {
        $args->urgency = HIGH;
    } elseif (isset($_REQUEST['medium_urgency'])) {
        $args->urgency = MEDIUM;
    } elseif (isset($_REQUEST['low_urgency'])) {
        $args->urgency = LOW;
    } else {
        $args->urgency = OFF;
    }
    // Sets urgency for every single tc
    if (isset($_REQUEST['urgency'])) {
        $args->urgency_tc = $_REQUEST['urgency'];
    }
    return $args;
}
示例#4
0
/**
 * init_args
 *
 */
function init_args(&$dbHandler)
{
    // take care of proper escaping when magic_quotes_gpc is enabled
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $iParams = array("requirement_id" => array(tlInputParameter::INT_N), "req_spec_id" => array(tlInputParameter::INT_N), "containerID" => array(tlInputParameter::INT_N), "reqDocId" => array(tlInputParameter::STRING_N, 0, 64), "req_title" => array(tlInputParameter::STRING_N, 0, 100), "scope" => array(tlInputParameter::STRING_N), "reqStatus" => array(tlInputParameter::STRING_N, 0, 1), "reqType" => array(tlInputParameter::STRING_N, 0, 1), "countReq" => array(tlInputParameter::INT_N), "expected_coverage" => array(tlInputParameter::INT_N), "doAction" => array(tlInputParameter::STRING_N, 0, 20), "req_id_cbox" => array(tlInputParameter::ARRAY_INT), "itemSet" => array(tlInputParameter::ARRAY_INT), "testcase_count" => array(tlInputParameter::ARRAY_INT), "req_version_id" => array(tlInputParameter::INT_N), "copy_testcase_assignment" => array(tlInputParameter::CB_BOOL), "relation_id" => array(tlInputParameter::INT_N), "relation_source_req_id" => array(tlInputParameter::INT_N), "relation_type" => array(tlInputParameter::STRING_N), "relation_destination_req_doc_id" => array(tlInputParameter::STRING_N, 0, 64), "relation_destination_testproject_id" => array(tlInputParameter::INT_N), "save_rev" => array(tlInputParameter::INT_N), "do_save" => array(tlInputParameter::INT_N), "tproject_id" => array(tlInputParameter::INT_N), "log_message" => array(tlInputParameter::STRING_N));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $args->req_id = $args->requirement_id;
    $args->title = $args->req_title;
    $args->arrReqIds = $args->req_id_cbox;
    $args->basehref = $_SESSION['basehref'];
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    $args->user_id = isset($_SESSION['userID']) ? $_SESSION['userID'] : 0;
    $args->user = $_SESSION['currentUser'];
    // to avoid database errors with null value
    if (!is_numeric($args->expected_coverage)) {
        $args->expected_coverage = 0;
    }
    $uk = 'setting_refresh_tree_on_action';
    $args->refreshTree = testproject::getUserChoice($args->tproject_id, array('reqTreeRefreshOnAction'));
    $args->stay_here = isset($_REQUEST['stay_here']) ? 1 : 0;
    return $args;
}
示例#5
0
 /**
  * 获取模块菜单
  * @author jry <*****@*****.**>
  */
 public function getAdminMenu($module_name = MODULE_NAME)
 {
     // 获取模块左侧导航
     $where['name'] = $module_name;
     $module_info = $this->where($where)->find();
     $_side_menu_list = json_decode($module_info['admin_menu'], true);
     // 转换成树结构
     $tree = new tree();
     return $tree->list_to_tree($_side_menu_list);
 }
示例#6
0
 protected function _initialize()
 {
     /* 读取站点配置 */
     $config = api('Config/lists');
     C($config);
     //添加配置
     if (!C('WEB_SITE_CLOSE') && $_SESSION[C('USER_AUTH_KEY')] != 1) {
         $this->error('站点已经关闭,请稍后访问~', '', 1000);
     }
     $a = D('Member')->need_login();
     $field = array('uid', 'username', 'nickname', 'name', 'email', 'space_url', 'reg_time', 'last_login_time', 'signature', 'avatar32', 'avatar64', 'avatar128', 'avatar256');
     $userinfo = query_user($field, $_SESSION['cs_home']['user_auth']['uid']);
     $roleauth = getmroleauth();
     checkscore($_SESSION['cs_home']['user_auth']['uid']);
     $mymail['status'] = 1;
     $mymail['is_read'] = 0;
     $mymail['to_uid'] = $_SESSION['cs_home']['user_auth']['uid'];
     $mymailcount = M('Message')->where($mymail)->count();
     $userinfo['mymailcount'] = empty($mymailcount) ? '' : $mymailcount;
     $isadmin = is_admin($_SESSION['cs_home']['user_auth']['uid']);
     $this->assign('isadmin', $isadmin);
     $this->assign('user_auth', session('user_auth'));
     $this->assign('uid', getnowUid());
     $this->assign('userinfo', $userinfo);
     $this->assign('roleauth', $roleauth);
     //得到会员组权限
     $cname = strtolower(CONTROLLER_NAME);
     $aname = strtolower(ACTION_NAME);
     $this->assign('aname', $aname);
     $this->assign('cname', $cname);
     $cate = new CategoryApi();
     $clist = $cate->get_catelist(0);
     $clistnum = $cate->get_editcnum();
     $this->assign('clist', $clist);
     $nosigncate = M('Cate')->where(array('status' => 1, 'type' => 1))->select();
     $m = D('cate');
     $catelist = $m->field('*,CONCAT(spid,id) as path2')->where(array('type' => 1, 'status' => 1))->order('path2')->select();
     $t = new tree();
     $catelistarr = $t->unlimitCategoryFormat($catelist);
     $catehtml = $t->treeFormat($catelistarr);
     $this->assign('catehtml', $catehtml);
     $this->assign('nosigncate', $nosigncate);
     $this->assign('clistnum', $clistnum);
     $nav = D('nav')->where(array('status' => 1))->order('sort desc')->select();
     foreach ($nav as $key => $vo) {
         $nav[$key]['url'] = navurl($vo['id'], $vo['type']);
         $nav[$key]['active'] = navactive($vo['id'], $vo['type']);
         if ($vo['win']) {
             $nav[$key]['target'] = '_blank';
         } else {
             $nav[$key]['target'] = '_self';
         }
     }
     $this->assign('nav', $nav);
 }
 /**
  * 获取所有导航
  * @author jry <*****@*****.**>
  */
 public function getTree()
 {
     $con = array();
     $con['status'] = 1;
     $link_list = $this->where($con)->order('sort asc, id asc')->select();
     foreach ($link_list as $key => &$value) {
         if (!stristr($value['url'], 'http://') && !stristr($value['url'], 'https://')) {
             $value['url'] = U($value['url']);
         }
     }
     $tree = new tree();
     return $tree->list_to_tree($link_list);
 }
示例#8
0
/**
 * create object with all user inputs
 *
 * @internal revisions
 * 20110417 - franciscom - BUGID 4429: Code refactoring to remove global coupling as much as possible
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    return $args;
}
function init_args(&$dbHandler)
{
    $args = new stdClass();
    $args->tproject_name = '';
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    $args->basehref = $_SESSION['basehref'];
    return $args;
}
function init_args(&$dbHandler)
{
    $argsObj = new stdClass();
    $argsObj->tproject_name = '';
    $argsObj->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($argsObj->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($argsObj->tproject_id);
        $argsObj->tproject_name = $dummy['name'];
    }
    // new dbug($argsObj, array('calledFrom' => ' file: ' . basename(__FILE__) . ' -  function: ' . __FUNCTION__));
    return $argsObj;
}
function init_args(&$dbHandler, $dateFormat)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    // BUGID 3716
    $args->target_date_original = isset($_REQUEST['target_date']) ? $_REQUEST['target_date'] : null;
    $args->start_date_original = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : null;
    // convert target date to iso format to write to db
    if (isset($_REQUEST['target_date']) && $_REQUEST['target_date'] != '') {
        $date_array = split_localized_date($_REQUEST['target_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $args->target_date = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    // convert start date to iso format to write to db
    if (isset($_REQUEST['start_date']) && $_REQUEST['start_date'] != '') {
        $date_array = split_localized_date($_REQUEST['start_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $args->start_date = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    $key2loop = array('low_priority_tcases', 'medium_priority_tcases', 'high_priority_tcases');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? intval($_REQUEST[$key]) : 0;
    }
    $args->id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
    $args->name = isset($_REQUEST['milestone_name']) ? $_REQUEST['milestone_name'] : null;
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : null;
    $args->basehref = $_SESSION['basehref'];
    $treeMgr = new tree($dbHandler);
    $tprojectMgr = new testproject($dbHandler);
    $args->tproject_options = new stdClass();
    $args->tproject_options->testPriorityEnabled = 0;
    $args->tproject_name = '';
    $args->tproject_id = isset($_REQUEST['tproject_id']) ? intval($_REQUEST['tproject_id']) : 0;
    if ($args->tproject_id > 0) {
        $info = $tprojectMgr->get_by_id($args->tproject_id);
        $args->tproject_name = $info['name'];
        $args->tproject_options = $info['opt'];
    }
    $args->tplan_name = '';
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    if ($args->tplan_id > 0) {
        $info = $treeMgr->get_node_hierarchy_info($args->tplan_id);
        $args->tplan_name = $info['name'];
    }
    return $args;
}
示例#12
0
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $iParams = array("doAction" => array(tlInputParameter::STRING_N, 0, 50), "export_filename" => array(tlInputParameter::STRING_N, 0, 255), "exportType" => array(tlInputParameter::STRING_N, 0, 255), "tproject_id" => array(tlInputParameter::INT_N));
    R_PARAMS($iParams, $args);
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    return $args;
}
示例#13
0
function init_args(&$dbHandler, $cfgObj)
{
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $tplan_mgr = new testplan($dbHandler);
    // Settings we put on session to create some sort of persistent scope,
    // because we have had issues when passing this info using GET mode (size limits)
    //
    // we get info about build_id, platform_id, etc ...
    getContextFromGlobalScope($args);
    $args->user = $_SESSION['currentUser'];
    $args->user_id = $args->user->dbID;
    $args->caller = isset($_REQUEST['caller']) ? $_REQUEST['caller'] : 'exec_feature';
    $args->reload_caller = false;
    $args->tplan_id = intval(isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : $_SESSION['testplanID']);
    $args->tproject_id = intval(isset($_REQUEST['tproject_id']) ? $_REQUEST['tproject_id'] : $_SESSION['testprojectID']);
    if ($args->tproject_id <= 0) {
        $tree_mgr = new tree($dbHandler);
        $dm = $tree_mgr->get_node_hierarchy_info($args->tplan_id);
        $args->tproject_id = $dm['parent_id'];
    }
    if (is_null($args->build_id) || $args->build_id == 0) {
        // Go for the build
        // this info can be present in session, then we will try different ways
        // ATTENTION:
        // give a look to tlTestCaseFilterControl.class.php method init_setting_build()
        //
        $key = $args->tplan_id . '_stored_setting_build';
        $args->build_id = isset($_SESSION[$key]) ? intval($_SESSION[$key]) : null;
        if (is_null($args->build_id)) {
            $args->build_id = $tplan_mgr->get_max_build_id($args->tplan_id, 1, 1);
        }
    }
    if (is_null($args->platform_id) || $args->platform_id <= 0) {
        // Go for the platform (if any exists)
        // this info can be present in session, then we will try different ways
        // ATTENTION:
        // give a look to tlTestCaseFilterControl.class.php method init_setting_platform()
        //
        $itemSet = $tplan_mgr->getPlatforms($args->tplan_id);
        if (!is_null($itemSet)) {
            $key = $args->tplan_id . '_stored_setting_platform';
            $args->platform_id = isset($_SESSION[$key]) ? intval($_SESSION[$key]) : null;
            if (is_null($args->platform_id) || $args->platform_id <= 0) {
                $args->platform_id = $itemSet[0]['id'];
            }
        }
    }
    return array($args, $tplan_mgr);
}
示例#14
0
 public function getActionTree()
 {
     $sql = "SELECT id,parent_id,action_name from {$this->_table}";
     $cates = $res = $this->getList($sql);
     $this->load->helper('html_tree');
     $tree = new tree($cates);
     $tree->icon = array('&nbsp;&nbsp;│&nbsp;', '&nbsp;&nbsp;├─&nbsp;', '&nbsp;&nbsp;└─&nbsp;');
     //树形图标
     $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
     //三个空格
     $options = '';
     $tree->init($cates);
     return $tree->get_tree(0, "<option value='\$id'>\$spacer\$action_name</option>\n");
 }
/**
 *
 */
function init_args(&$dbHandler)
{
    $iParams = array("item_id" => array(tlInputParameter::INT_N), "showContextInfo" => array(tlInputParameter::INT_N), "tproject_id" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $args->tproject_name = null;
    if ($args->tproject_id > 0) {
        $mgr = new tree($dbHandler);
        $dummy = $mgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    $args->user = $_SESSION['currentUser'];
    $args->userID = $args->user->dbID;
    return $args;
}
示例#16
0
/**
 *
 */
function init_args(&$dbHandler)
{
    $iParams = array("req_spec_id" => array(tlInputParameter::INT_N), "refreshTree" => array(tlInputParameter::INT_N), "tproject_id" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $args->refreshTree = intval($args->refreshTree);
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    $args->user = $_SESSION['currentUser'];
    return $args;
}
 function _valid_perform()
 {
     $tree =& tree::instance();
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['parent_path'] = $this->dataspace->get('parent_path');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $object =& site_object_factory::create($params['class']);
     $is_root = false;
     if (!($parent_data = fetch_one_by_path($params['parent_path']))) {
         if ($params['parent_path'] == '/') {
             $is_root = true;
         } else {
             error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         }
     }
     if (!$is_root) {
         $params['parent_node_id'] = $parent_data['node_id'];
     } else {
         $params['parent_node_id'] = 0;
     }
     $object->import_attributes($params);
     if (!$object->create($is_root)) {
         error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     if (!$is_root) {
         $parent_object =& site_object_factory::instance($parent_data['class_name']);
         $parent_object->import_attributes($parent_data);
         $access_policy =& access_policy::instance();
         $access_policy->save_object_access($object, $parent_object);
     }
     return new close_popup_response(RESPONSE_STATUS_FORM_SUBMITTED);
 }
 function setUp()
 {
     $this->db =& db_factory::instance();
     $this->_clean_up();
     $this->_init_site_object();
     $this->object->set_attribute('controller_name', 'site_object_controller');
     $controller_id = site_object_controller::get_id('site_object_controller');
     $this->object->set_attribute('controller_id', $controller_id);
     debug_mock::init($this);
     $user =& user::instance();
     $user->_set_id(10);
     $tree =& tree::instance();
     $values['identifier'] = 'root';
     $values['object_id'] = 100;
     $this->root_node_id = $tree->create_root_node($values, false, true);
     $class_id = $this->object->get_class_id();
     $this->db->sql_insert('sys_site_object', array('id' => 100, 'class_id' => $class_id, 'current_version' => 1));
     $values['identifier'] = 'ru';
     $values['object_id'] = 1;
     $this->parent_node_id = $tree->create_sub_node($this->root_node_id, $values);
     $this->db->sql_insert('sys_site_object', array('id' => 1, 'class_id' => $class_id, 'current_version' => 1));
     $values['identifier'] = 'document';
     $values['object_id'] = 10;
     $this->sub_node_id = $tree->create_sub_node($this->parent_node_id, $values);
     $this->db->sql_insert('sys_site_object', array('id' => 10, 'class_id' => $class_id, 'current_version' => 1));
 }
示例#19
0
/**
 * @return object returns the arguments for the page
 */
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $iParams = array("UploadFile" => array(tlInputParameter::STRING_N, 0, 1), "importType" => array(tlInputParameter::STRING_N, 0, 100), "tproject_id" => array(tlInputParameter::INT_N));
    R_PARAMS($iParams, $args);
    $args->UploadFile = $args->UploadFile != "" ? 1 : 0;
    $args->fInfo = isset($_FILES['uploadedFile']) ? $_FILES['uploadedFile'] : null;
    $args->source = isset($args->fInfo['tmp_name']) ? $args->fInfo['tmp_name'] : null;
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    return $args;
}
  function validate(&$dataspace)
  {
    if(!$value = $dataspace->get($this->field_name))
      return;

    $tree = tree :: instance();

    if(!$tree->is_node($this->parent_node_id))
      return;

    if(!$nodes = $tree->get_children($this->parent_node_id))
      return;

    foreach($nodes as $id => $node)
    {
      if($node['identifier'] != $value)
        continue;

      if($this->node_id == TREE_IDENTIFIER_RULE_UNKNOWN_NODE_ID)
      {
        $this->error(strings :: get('error_duplicate_tree_identifier', 'error'));
        break;
      }
      elseif($id != $this->node_id)
      {
        $this->error(strings :: get('error_duplicate_tree_identifier', 'error'));
        break;
      }
    }
  }
 function perform(&$request, &$response)
 {
     $tree =& tree::instance();
     $tree->initialize_expanded_parents();
     $this->_set_template_tree();
     parent::perform($request, $response);
 }
 function _valid_perform(&$request, &$response)
 {
     $tree =& tree::instance();
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $params['parent_node_id'] = $this->dataspace->get('parent_node_id');
     $params['controller_id'] = site_object_controller::get_id($this->dataspace->get('controller_name'));
     $object =& site_object_factory::create($params['class']);
     if (!($parent_data = fetch_one_by_node_id($params['parent_node_id']))) {
         error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $object->merge_attributes($params);
     if (!$object->create()) {
         error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $parent_object =& site_object_factory::create($parent_data['class_name']);
     $parent_object->merge_attributes($parent_data);
     $access_policy =& access_policy::instance();
     $access_policy->save_initial_object_access($object, $parent_object);
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     }
 }
  function setUp()
  {
    parent :: setUp();

    $this->db =& db_factory :: instance();

    $tree =& tree :: instance();

    $values['identifier'] = 'root';
    $this->node_id_root = $tree->create_root_node($values, false, true);

    $values['identifier'] = 'ru';
    $values['object_id'] = 1;
    $this->node_id_ru = $tree->create_sub_node($this->node_id_root, $values);

    $values['identifier'] = 'document';
    $values['object_id'] = 10;
    $this->node_id_document = $tree->create_sub_node($this->node_id_ru, $values);

    $values['identifier'] = 'doc1';
    $values['object_id'] = 20;
    $this->node_id_doc1 = $tree->create_sub_node($this->node_id_ru, $values);

    $values['identifier'] = 'doc2';
    $values['object_id'] = 30;
    $this->node_id_doc2 = $tree->create_sub_node($this->node_id_ru, $values);
  }
 function &search_fetch_sub_branch($path, $loader_class_name, &$counter, $params = array(), $fetch_method = 'fetch')
 {
     $tree =& tree::instance();
     $site_object =& site_object_factory::create($loader_class_name);
     if (!isset($params['restrict_by_class']) || isset($params['restrict_by_class']) && (bool) $params['restrict_by_class']) {
         $class_id = $site_object->get_class_id();
     } else {
         $class_id = null;
     }
     if (isset($params['check_expanded_parents'])) {
         $check_expanded_parents = (bool) $params['check_expanded_parents'];
     } else {
         $check_expanded_parents = false;
     }
     if (isset($params['include_parent'])) {
         $include_parent = (bool) $params['include_parent'];
     } else {
         $include_parent = false;
     }
     $depth = isset($params['depth']) ? $params['depth'] : 1;
     if (!($nodes = $tree->get_accessible_sub_branch_by_path($path, $depth, $include_parent, $check_expanded_parents, $class_id))) {
         return array();
     }
     $object_ids = complex_array::get_column_values('object_id', $nodes);
     if (!count($object_ids)) {
         return array();
     }
     $result =& $this->search_fetch_by_ids($object_ids, $loader_class_name, $counter, $params, $fetch_method);
     return $result;
 }
	function _get_objects_to_delete($node_ids)
	{
		$params = array(
			'restrict_by_class' => false
		);
		
		$objects =& fetch_by_node_ids($node_ids, 'site_object', $counter, $params);
		
		$result = array();
		$tree = tree :: instance();
		
		foreach($objects as $id => $item)
		{
			if (!isset($item['actions']['delete']))
			{
				$objects[$id]['delete_status'] = 1;
				$objects[$id]['delete_reason'] = strings :: get('delete_action_not_accessible', 'error');
				continue;
			}
			
			$site_object =& wrap_with_site_object($item);
			if (!$site_object->can_delete())
			{
				$objects[$id]['delete_status'] = 1;
				$objects[$id]['delete_reason'] = strings :: get('cant_be_deleted', 'error');
				continue;
			}	
			
			$objects[$id]['delete_reason'] = strings :: get('ok');
			$objects[$id]['delete_status'] = 0;
			$objects[$id]['ids'][$item['node_id']] = 1;
		}
		
		return $objects;
	}
 function &_fetch(&$counter, $params)
 {
     $tree =& tree::instance();
     if (isset($params['order'])) {
         $order = $params['order'];
         unset($params['order']);
     } else {
         $order = array('priority' => 'ASC');
     }
     $tree_array =& parent::_fetch($counter, $params);
     $tree_array =& tree_sorter::sort($tree_array, $order, 'node_id', 'parent_node_id');
     $path_node = $tree->get_node_by_path($params['path']);
     if (isset($params['include_parent']) && (bool) $params['include_parent']) {
         $path_node_level = $path_node['level'] - 1;
     } else {
         $path_node_level = $path_node['level'];
     }
     $levels_status_array = array();
     $size = count($tree_array);
     $current_pos = 0;
     $parent_data = array();
     foreach ($tree_array as $id => $tree_item) {
         $parent_node_id = $tree_item['parent_node_id'];
         if (!isset($parent_data[$parent_node_id])) {
             if ($parent_node_id == 0) {
                 $parent_data[$parent_node_id]['children_amount'] = 1;
             } else {
                 $parent_data[$parent_node_id]['children_amount'] = $tree->count_accessible_children($parent_node_id);
             }
             $parent_data[$parent_node_id]['counter'] = 0;
         }
         $parent_data[$parent_node_id]['counter']++;
         if ($parent_data[$parent_node_id]['counter'] == 1) {
             $is_first_child = true;
         } else {
             $is_first_child = false;
         }
         if ($parent_data[$parent_node_id]['counter'] == $parent_data[$parent_node_id]['children_amount']) {
             $is_last_child = true;
         } else {
             $is_last_child = false;
         }
         $tree_array[$id]['level'] = $tree_array[$id]['level'] - $path_node_level;
         $levels_status_array[$tree_item['level'] - $path_node_level] = $is_last_child;
         $tree_array[$id]['level_' . $tree_array[$id]['level']] = 1;
         $tree_array[$id]['is_expanded'] = $tree->is_node_expanded($tree_item['node_id']);
         $tree_array[$id]['is_last_child'] = $is_last_child;
         $tree_array[$id]['is_first_child'] = $is_first_child;
         $tree_array[$id]['levels_status'] = $levels_status_array;
         if ($tree_array[$id]['class_name'] == 'image_object' || $tree_array[$id]['class_name'] == 'file_object') {
             $tree_array[$id]['icon'] = '/root?node_id=' . $tree_item['node_id'] . '&icon';
         } elseif (isset($tree_item['icon']) && $tree_item['icon']) {
             $tree_array[$id]['icon'] = $tree_item['icon'];
         } else {
             $tree_array[$id]['icon'] = '/shared/images/generic.gif';
         }
     }
     return $tree_array;
 }
示例#27
0
 function _load_tree()
 {
     $tree =& tree::instance();
     if (file_exists($tree->get_cache_path())) {
         unlink($tree->get_cache_path());
     }
     $tree->load_tree();
 }
 function validate(&$dataspace)
 {
     $value = $dataspace->get($this->field_name);
     $tree = tree::instance();
     if (!$tree->get_node_by_path($value)) {
         $this->error(strings::get('error_invalid_tree_path', 'error'));
     }
 }
	function check($value)
	{
		$tree = tree :: instance();
		
		if(empty($value))
		  $this->error(strings :: get('error_invalid_tree_node_id', 'error'));
		elseif(!$tree->get_node((int)$value))
			$this->error(strings :: get('error_invalid_tree_node_id', 'error'));
	} 
function init_args(&$dbHandler)
{
    $iParams = array("tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    R_PARAMS($iParams, $args);
    $treeMgr = new tree($dbHandler);
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $dummy = $treeMgr->get_node_hierarchy_info($args->tproject_id);
        $args->tproject_name = $dummy['name'];
    }
    $args->tplan_name = '';
    if ($args->tplan_id > 0) {
        $dummy = $treeMgr->get_node_hierarchy_info($args->tplan_id);
        $args->tplan_name = $dummy['name'];
    }
    return $args;
}