Beispiel #1
0
/**
 * Retrieves all tags, unless the users 
 *
 * @param string   $p_username    The user's username
 * @param string   $p_password    The user's password
 * @param int      $p_page_number The page number to return data for
 * @param string   $p_per_page    The number of issues to return per page
 * @return array The tag data
 */
function mc_tag_get_all($p_username, $p_password, $p_page_number, $p_per_page)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!access_has_global_level(config_get('tag_view_threshold'))) {
        return mci_soap_fault_access_denied($t_user_id, 'No rights to view tags');
    }
    if ($p_per_page == 0) {
        $p_per_page = 1;
    }
    $t_results = array();
    $t_total_results = tag_count('');
    foreach (tag_get_all('', $p_per_page, $p_per_page * ($p_page_number - 1)) as $t_tag_row) {
        $t_results[] = array('id' => $t_tag_row['id'], 'name' => $t_tag_row['name'], 'description' => $t_tag_row['description'], 'user_id' => mci_account_get_array_by_id($t_tag_row['user_id']), 'date_created' => SoapObjectsFactory::newDateTimeVar($t_tag_row['date_created']), 'date_updated' => SoapObjectsFactory::newDateTimeVar($t_tag_row['date_updated']));
    }
    return array('results' => $t_results, 'total_results' => $t_total_results);
}
Beispiel #2
0
/**
 * Retrieves all tags, unless the users
 *
 * @param string   $p_username    The user's username
 * @param string   $p_password    The user's password
 * @param int      $p_page_number The page number to return data for
 * @param string   $p_per_page    The number of issues to return per page
 * @return array The tag data
 */
function mc_tag_get_all($p_username, $p_password, $p_page_number, $p_per_page)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    if (!access_has_global_level(config_get('tag_view_threshold'))) {
        return mci_soap_fault_access_denied($t_user_id, 'No rights to view tags');
    }
    if ($p_per_page == 0) {
        $p_per_page = 1;
    }
    $t_results = array();
    $t_total_results = tag_count('');
    $t_tags = tag_get_all('', $p_per_page, $p_per_page * ($p_page_number - 1));
    while ($t_tag = db_fetch_array($t_tags)) {
        $t_tag['user_id'] = mci_account_get_array_by_id($t_tag['user_id']);
        $t_tag['date_created'] = SoapObjectsFactory::newDateTimeVar($t_tag['date_created']);
        $t_tag['date_updated'] = SoapObjectsFactory::newDateTimeVar($t_tag['date_updated']);
        $t_results[] = $t_tag;
    }
    log_event(LOG_WEBSERVICE, "retrieved " . count($t_results) . "/{$t_total_results} tags (page #{$p_page_number})");
    return array('results' => $t_results, 'total_results' => $t_total_results);
}
Beispiel #3
0
for ($i = 'A'; $i != 'AA'; $i++) {
    $t_prefix_array[] = $i;
}
for ($i = 0; $i <= 9; $i++) {
    $t_prefix_array[] = (string) $i;
}
if ($f_filter === 'ALL') {
    $t_name_filter = '';
} else {
    $t_name_filter = $f_filter;
}
# Set the number of Tags per page.
$t_per_page = 20;
$t_offset = ($f_page_number - 1) * $t_per_page;
# Determine number of tags in tag table
$t_total_tag_count = tag_count($t_name_filter);
#Number of pages from result
$t_page_count = ceil($t_total_tag_count / $t_per_page);
if ($t_page_count < 1) {
    $t_page_count = 1;
}
# Make sure $p_page_number isn't past the last page.
if ($f_page_number > $t_page_count) {
    $f_page_number = $t_page_count;
}
# Make sure $p_page_number isn't before the first page
if ($f_page_number < 1) {
    $f_page_number = 1;
}
# Retrieve Tags from table
$t_result = tag_get_all($t_name_filter, $t_per_page, $t_offset);
Beispiel #4
0
function get_tag_nodes_for_browsing($parent_id = null)
{
    $nodes = array();
    global $app_list_strings;
    $mod_strings = get_kbtag_strings();
    //create query of nodes to display
    $query = "select id,tag_name from kbtags where deleted = '0' and ";
    //add parent id if not empty
    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;
    //process node for each value returned
    while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
        if (!empty($row['id'])) {
            $child_tag_id = $row['id'];
            //get article count
            $doc_count = tagged_documents_count($child_tag_id);
            $tag_count = tag_count($child_tag_id);
            $child_tag_name = $row['tag_name'];
            //create browse node
            $parent_tag_node = create_browse_node($child_tag_id, $child_tag_name, $tag_count, $doc_count);
            //add new node to array of nodes to display
            if (!empty($parent_tag_node)) {
                $nodes[] = $parent_tag_node;
            }
        }
    }
    //now create root node that will hold all articles that are untagged
    if ($parent_id == null) {
        $untagged_tag_id = 'UNTAGGED_NODE_ID';
        //get article count
        $untagged_count = untagged_documents_count($untagged_tag_id);
        //create browse node
        $parent_tag_node = create_browse_node($untagged_tag_id, $mod_strings['LBL_UNTAGGED_ARTICLES_NODE'], 0, $untagged_count);
        //add new node to array of nodes to display
        if (!empty($parent_tag_node)) {
            $nodes[] = $parent_tag_node;
        }
    }
    return $nodes;
}