Пример #1
0
function get_product_categories($parent_id, $open_nodes_ids = array())
{
    $href_string = "javascript:set_return('productcategories')";
    reset($open_nodes_ids);
    $nodes = array();
    if ($parent_id == '') {
        $query = "select * from product_categories where (parent_id is null or parent_id='') and deleted=0 order by list_order";
    } else {
        $query = "select * from product_categories where parent_id ='{$parent_id}' and deleted=0 order by list_order";
    }
    $result = $GLOBALS['db']->query($query);
    while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
        $node = new Node($row['id'], $row['name']);
        $node->set_property("href", $href_string);
        if (count($open_nodes_ids) > 0 and $row['id'] == current($open_nodes_ids)) {
            $node->expanded = true;
            $node->dynamic_load = false;
            $current_id = current($open_nodes_ids);
            array_shift($open_nodes_ids);
            $child_nodes = get_product_categories($current_id, $open_nodes_ids);
            //add all returned node to current node.
            foreach ($child_nodes as $child_node) {
                $node->add_node($child_node);
            }
        } else {
            $node->expanded = false;
            $node->dynamic_load = true;
        }
        $nodes[] = $node;
    }
    return $nodes;
}
Пример #2
0
function get_category_nodes($href_string)
{
    $nodes = array();
    global $mod_strings;
    global $app_list_strings;
    $query = "select distinct category_id, subcategory_id from documents where deleted=0 order by category_id, subcategory_id";
    $result = $GLOBALS['db']->query($query);
    $current_cat_id = null;
    $cat_node = null;
    while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
        if (empty($row['category_id'])) {
            $cat_id = 'null';
            $cat_name = $mod_strings['LBL_CAT_OR_SUBCAT_UNSPEC'];
        } else {
            $cat_id = $row['category_id'];
            $cat_name = $app_list_strings['document_category_dom'][$row['category_id']];
        }
        if (empty($current_cat_id) or $current_cat_id != $cat_id) {
            $current_cat_id = $cat_id;
            if (!empty($cat_node)) {
                $nodes[] = $cat_node;
            }
            $cat_node = new Node($cat_id, $cat_name);
            $cat_node->set_property("href", $href_string);
            $cat_node->expanded = true;
            $cat_node->dynamic_load = false;
        }
        if (empty($row['subcategory_id'])) {
            $subcat_id = 'null';
            $subcat_name = $mod_strings['LBL_CAT_OR_SUBCAT_UNSPEC'];
        } else {
            $subcat_id = $row['subcategory_id'];
            $subcat_name = $app_list_strings['document_subcategory_dom'][$row['subcategory_id']];
        }
        $subcat_node = new Node($subcat_id, $subcat_name);
        $subcat_node->set_property("href", $href_string);
        $subcat_node->expanded = false;
        $subcat_node->dynamic_load = true;
        $cat_node->add_node($subcat_node);
    }
    if (!empty($cat_node)) {
        $nodes[] = $cat_node;
    }
    return $nodes;
}
Пример #3
0
 public function get_test_nodes($href_string)
 {
     $nodes = array();
     $cat_node = new Node("1111", "1111");
     $cat_node->set_property("href", $href_string);
     // $cat_node->expanded = false;
     $cat_node->dynamic_load = false;
     $subcat_node = new Node("sub 1111", "sub 1111");
     $cat_node->add_node($subcat_node);
     $nodes[] = $cat_node;
     $cat_node = new Node("2222", "2222");
     $cat_node->set_property("href", $href_string);
     $cat_node->dynamic_load = false;
     $nodes[] = $cat_node;
     $cat_node = new Node("3333", "3333");
     $cat_node->set_property("href", $href_string);
     $cat_node->dynamic_load = false;
     $nodes[] = $cat_node;
     $cat_node = new Node("4444", "4444");
     $cat_node->set_property("href", $href_string);
     $cat_node->dynamic_load = true;
     $nodes[] = $cat_node;
     return $nodes;
 }
Пример #4
0
            $root_node->add_node($node);
        }
        $href_string = "javascript:handler:SUGAR.kb.adminClick()";
        if ($root_node) {
            $root_node->set_property("href", $href_string);
        }
        $root_node->expanded = true;
        $tagstree->add_node($root_node);
    } else {
        $tagstree->set_param('moduleview', 'modal');
        //$nodes = get_tags_nodes_cached(null);
        //$nodes=get_tags_nodes(false,null);
        $nodes = get_tags_nodes(false, false, null);
        $root_node = new Node('All_Tags', $mod_strings['LBL_TAGS_ROOT_LABEL']);
        foreach ($nodes as $node) {
            $root_node->add_node($node);
        }
        $href_string = "javascript:handler:SUGAR.kb.modalClose('tagstree')";
        if ($root_node) {
            $root_node->set_property("href", $href_string);
        }
        $root_node->expanded = true;
        $tagstree->add_node($root_node);
    }
    //$tagstree->add_node($root_node);
    $response = $tagstree->generate_nodes_array();
} else {
    $response = 1;
}
if (!empty($response)) {
    echo $response;
Пример #5
0
function return_advanced_tab($focus, $json, $json_config)
{
    global $theme, $image_path, $app_list_strings, $mod_strings, $app_strings;
    $ss_adv = new Sugar_Smarty();
    $ss_adv->assign("MOD", $mod_strings);
    $ss_adv->assign("APP", $app_strings);
    //assign back values from last search, if it exists.
    //do not set any values if value has been set
    if (isset($_POST['clear_loaded'])) {
        $_POST['searchText'] = '';
        foreach ($_POST as $_key => $_val) {
            $ss_adv->assign($_key, '');
        }
    } else {
        foreach ($_POST as $_key => $_val) {
            $ss_adv->assign($_key, $_val);
        }
    }
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'kbdoc_approver_id', 'name' => 'kbdoc_approver_name'));
    $ss_adv->assign('encoded_approver_popup_request_data', $json->encode($popup_request_data));
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'kbarticle_author_id', 'name' => 'kbarticle_author_name'));
    $ss_adv->assign('encoded_author_popup_request_data', $json->encode($popup_request_data));
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'tag_id', 'tag_name' => 'tag_name'));
    $ss_adv->assign('encoded_tags_popup_request_data', $json->encode($popup_request_data));
    $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'FTSFormAdvanced', 'field_to_name_array' => array('id' => 'team_id', 'name' => 'team_name'));
    $json = getJSONobj();
    $ss_adv->assign('encoded_team_popup_request_data', $json->encode($popup_request_data));
    $ss_adv->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
    $ss_adv->assign("ID", $focus->id);
    $ss_adv->assign("DOCUMENT_NAME", $focus->kbdocument_name);
    $ss_adv->assign("DESCRIPTION", $focus->description);
    $ss_adv->assign("ACTIVE_DATE", $focus->active_date);
    $ss_adv->assign("EXP_DATE", $focus->exp_date);
    $status_option = "<option value='' selected>" . $app_strings['LBL_NONE'] . "</option> ";
    if (isset($_POST['status_id'])) {
        $status_option .= get_select_options_with_id($app_list_strings['kbdocument_status_dom'], $_POST['status_id']);
        $ss_adv->assign("STATUS_OPTIONS", $status_option);
    } else {
        $status_option .= get_select_options_with_id($app_list_strings['kbdocument_status_dom'], '');
        $ss_adv->assign("STATUS_OPTIONS", $status_option);
    }
    if (isset($_POST['saved_search_select']) && !empty($_POST['saved_search_select'])) {
        $ss_adv->assign("SAVED_SEARCH_OPTIONS", getSavedSearchOptions($focus, $_POST['saved_search_select']));
        $savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . getSavedSearchOptions($focus, $_POST['saved_search_select'], true)));
    } else {
        $ss_adv->assign("SAVED_SEARCH_OPTIONS", getSavedSearchOptions($focus));
        $savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . getSavedSearchOptions($focus, '', true)));
    }
    $str = "<script>\n    YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, {$savedSearchSelects});\n    </script>";
    echo $str;
    if (isset($_POST['canned_search'])) {
        $ss_adv->assign("CANNED_SEARCH_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_canned_search'], $_POST['canned_search']));
    } else {
        $ss_adv->assign("CANNED_SEARCH_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_canned_search'], ''));
    }
    $a1_style = '';
    $x1_style = '';
    $a2_style = 'none';
    $x2_style = 'none';
    //set the expiration date filter if it exists.  Also set the style properties
    //that will determine whether to show or hide the supporting text boxes
    if (isset($_POST['active_date_filter'])) {
        $ss_adv->assign("ACTIVE_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], $_POST['active_date_filter']));
        if ($_POST['active_date_filter'] == 'on' || $_POST['active_date_filter'] == 'before' || $_POST['active_date_filter'] == 'after') {
            $a1_style = '';
        } else {
            $a1_style = 'none';
        }
        if ($_POST['active_date_filter'] == 'between_dates') {
            $a2_style = '';
        }
    } else {
        $ss_adv->assign("ACTIVE_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], ''));
    }
    //set the expiration date filter if it exists.  Also set the style properties
    //that will determine whether to show or hide the supporting text boxes
    if (isset($_POST['exp_date_filter'])) {
        $ss_adv->assign("EXP_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], $_POST['exp_date_filter']));
        if ($_POST['exp_date_filter'] == 'on' || $_POST['exp_date_filter'] == 'before' || $_POST['exp_date_filter'] == 'after') {
            $x1_style = '';
        } else {
            $x1_style = 'none';
        }
        if ($_POST['exp_date_filter'] == 'between_dates') {
            $x2_style = '';
        }
    } else {
        $ss_adv->assign("EXP_DATE_FILTER_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_date_filter_options'], ''));
    }
    //set the style sheet properties for date filters
    $ss_adv->assign("A_DATE1_STYLE", $a1_style);
    $ss_adv->assign("X_DATE1_STYLE", $x1_style);
    $ss_adv->assign("A_DATE2_STYLE", $a2_style);
    $ss_adv->assign("X_DATE2_STYLE", $x2_style);
    $attach_name_style = 'none';
    $attach_mime_style = 'none';
    if (isset($_POST['attachments'])) {
        $ss_adv->assign("ATTACHMENT_SELECT_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_attachment_option_dom'], $_POST['attachments']));
        if ($_POST['attachments'] == 'mime') {
            $attach_mime_style = ' ';
        } else {
            if ($_POST['attachments'] == 'name') {
                $attach_name_style = ' ';
            }
        }
    } else {
        $ss_adv->assign("ATTACHMENT_SELECT_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_attachment_option_dom'], ''));
    }
    $ss_adv->assign("ATTACHMENT_NAME_STYLE", $attach_name_style);
    $ss_adv->assign("ATTACHMENT_MIME_STYLE", $attach_mime_style);
    if (!empty($focus->kbdoc_approver_id)) {
        $user = BeanFactory::getBean('Users', $focus->kbdoc_approver_id);
        $ss_adv->assign("KBDOC_APPROVER_NAME", $user->name);
        $ss_adv->assign("KBDOC_APPROVER_ID", $focus->kbdoc_approver_id);
    }
    global $timedate;
    $ss_adv->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
    $ss_adv->assign("USER_DATE_FORMAT", $timedate->get_user_date_format());
    $ss_adv->assign('JSON_CONFIG_JAVASCRIPT', $json_config->get_static_json_server());
    if (isset($_POST['frequency'])) {
        $ss_adv->assign("FRQ_VIEW_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_viewing_frequency_dom'], $_POST['frequency']));
    } else {
        $ss_adv->assign("FRQ_VIEW_OPTIONS", get_select_options_with_id($app_list_strings['kbdocument_viewing_frequency_dom'], ''));
    }
    if (isset($_POST['is_external_article'])) {
        if ($_POST['is_external_article']) {
            $ss_adv->assign('is_external_id', '1');
            $ss_adv->assign('is_external_checked', 'checked');
        } else {
            $ss_adv->assign('is_external_id', '0');
            $ss_adv->assign('is_external_checked', '');
        }
    }
    //create tree for tag selection modal
    $tag = BeanFactory::getBean('KBTags');
    $ss_adv->assign("TAG_NAME", $tag->tag_name);
    //tree header.
    $tagstree = new Tree('tagstree');
    $tagstree->set_param('module', 'KBTags');
    $tagstree->set_param('moduleview', 'modal');
    $nodes = get_tags_nodes(false, false, null);
    $root_node = new Node('All_Tags', $mod_strings['LBL_TAGS_ROOT_LABEL']);
    foreach ($nodes as $node) {
        $root_node->add_node($node);
    }
    $href_string = "javascript:handler:modalClose('tagstree')";
    if ($root_node) {
        $root_node->set_property("href", $href_string);
    }
    $root_node->expanded = true;
    $tagstree->add_node($root_node);
    $ss_adv->assign("TREEINSTANCE", $tagstree->generate_nodes_array());
    return $ss_adv->fetch("modules/KBDocuments/tpls/advancedTab.tpl");
}
Пример #6
0
function get_tags_nodes($create_root_node = false, $admin = false, $parent_id = null)
{
    $nodes = array();
    global $app_list_strings;
    $mod_strings = get_kbtag_strings();
    //$query="select id,tag_name from kbtags where parent_tag_id is null and deleted=0 order by tag_name";
    $query = "select id,tag_name from kbtags where deleted = 0 and";
    if (empty($parent_id)) {
        $query .= " parent_tag_id is null order by tag_name";
    } else {
        $query .= " parent_tag_id = '{$parent_id}' order by tag_name";
    }
    $result = $GLOBALS['db']->query($query);
    $current_cat_id = null;
    $cat_node = null;
    if ($create_root_node) {
        $root_node = new Node('All_Tags', 'All Tags');
    }
    while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
        if (!empty($row['id'])) {
            $tag_id = $row['id'];
            $doc_count = tagged_documents_count($tag_id);
            $href_string = '';
            if ($admin) {
                //$tag_label =$row['tag_name'].'('.$doc_count.')';
                $tag_name = '<input type="checkbox" onclick="javascript:handler:SUGAR.kb.checkTags();" id="selected_tags[]" name="selected_tags[]" value="' . $tag_id . '">';
                $tag_name .= $row['tag_name'] . '(' . $doc_count . ')';
                $href_string = "javascript:handler:SUGAR.kb.adminClick();javascript:handler:SUGAR.kb.moveToTag();javascript:node_click('tagstree','selected_directory_children', 'div', 'get_admin_browse_articles')";
            } else {
                $tag_name = $row['tag_name'] . '(' . $doc_count . ')';
                $href_string = "javascript:handler:SUGAR.kb.modalClose('tagstree')";
                if ($create_root_node) {
                    $root_node->set_property("href", $href_string);
                }
            }
            $parent_tag_node = new Node($tag_id, $tag_name);
            $parent_tag_node->set_property("href", $href_string);
            $parent_tag_node->dynamic_load = true;
            $parent_tag_node->expanded = false;
            if ($create_root_node) {
                $root_node->dynamic_load = true;
                $root_node->expanded = false;
                if (!empty($parent_tag_node)) {
                    $root_node->add_node($parent_tag_node);
                }
                $nodes[] = $root_node;
            } else {
                //$parent_tag_node->expanded = true;
                if (!empty($parent_tag_node)) {
                    $nodes[] = $parent_tag_node;
                }
            }
            //childNodes($parent_tag_node,$tag_id,$nodes,$admin);
        }
    }
    return $nodes;
}