Example #1
0
/**
 * Display a topic selection drop-down menu
 *
 * @param    string $dir_topic current topic
 * @param    int    $year      current year
 * @param    int    $month     current month
 * @return   string            HTML string of drop-down menu
 */
function DIR_topicList($dir_topic = 'all', $year = 0, $month = 0)
{
    global $_CONF, $LANG21;
    $retval = '<form class="floatright" action="';
    $retval .= $_CONF['site_url'] . '/' . THIS_SCRIPT;
    $retval .= '" method="post" style="margin:0"><div>' . LB;
    $retval .= '<select name="topic" onchange="this.form.submit()">' . LB;
    $retval .= TOPIC_getTopicListSelect($dir_topic, 2, true) . LB;
    $retval .= '</select>' . LB;
    $retval .= '<input type="hidden" name="year" value="' . $year . '"' . XHTML . '>' . LB;
    $retval .= '<input type="hidden" name="month" value="' . $month . '"' . XHTML . '>' . LB;
    $retval .= '</div></form>' . LB;
    return $retval;
}
Example #2
0
 /**
  * Shows search form
  *
  * Shows advanced search page
  *
  * @author Tony Bibbs, tony AT geeklog DOT net
  * @return string HTML output for form
  *
  */
 public function showForm()
 {
     global $_CONF, $_TABLES, $LANG09;
     $retval = '';
     // Verify current user my use the search form
     if (!$this->_isFormAllowed()) {
         return SEC_loginRequiredForm();
     }
     $retval .= COM_startBlock($LANG09[1], 'advancedsearch.html');
     $searchform = COM_newTemplate($_CONF['path_layout'] . 'search');
     $searchform->set_file(array('searchform' => 'searchform.thtml', 'authors' => 'searchauthors.thtml'));
     $searchform->set_var('search_intro', $LANG09[19]);
     $searchform->set_var('lang_keywords', $LANG09[2]);
     $searchform->set_var('lang_keytype', $LANG09[36]);
     $searchform->set_var('lang_date', $LANG09[20]);
     $searchform->set_var('lang_to', $LANG09[21]);
     $searchform->set_var('date_format', $LANG09[22]);
     $searchform->set_var('lang_topic', $LANG09[3]);
     $searchform->set_var('lang_all', $LANG09[4]);
     $searchform->set_var('topic_option_list', TOPIC_getTopicListSelect($this->_topic, 2, true));
     $searchform->set_var('lang_type', $LANG09[5]);
     $searchform->set_var('lang_results', $LANG09[59]);
     $searchform->set_var('lang_per_page', $LANG09[60]);
     $searchform->set_var('lang_exact_phrase', $LANG09[43]);
     $searchform->set_var('lang_all_words', $LANG09[44]);
     $searchform->set_var('lang_any_word', $LANG09[45]);
     $searchform->set_var('lang_titles', $LANG09[69]);
     $escquery = htmlspecialchars($this->_query);
     $escquery = str_replace(array('{', '}'), array('&#123;', '&#125;'), $escquery);
     $searchform->set_var('query', $escquery);
     $searchform->set_var('datestart', $this->_dateStart);
     $searchform->set_var('dateend', $this->_dateEnd);
     if ($this->_titlesOnly) {
         $searchform->set_var('title_checked', ' checked="checked"');
     } else {
         $searchform->set_var('title_checked', '');
     }
     $phrase_selected = '';
     $all_selected = '';
     $any_selected = '';
     if ($this->_keyType == 'phrase') {
         $phrase_selected = 'selected="selected"';
     } else {
         if ($this->_keyType == 'all') {
             $all_selected = 'selected="selected"';
         } else {
             if ($this->_keyType == 'any') {
                 $any_selected = 'selected="selected"';
             }
         }
     }
     $searchform->set_var('key_phrase_selected', $phrase_selected);
     $searchform->set_var('key_all_selected', $all_selected);
     $searchform->set_var('key_any_selected', $any_selected);
     $options = '';
     $plugintypes = array('all' => $LANG09[4], 'stories' => $LANG09[6], 'comments' => $LANG09[7]);
     $plugintypes = array_merge($plugintypes, PLG_getSearchTypes());
     // Generally I don't like to hardcode HTML but this seems easiest
     foreach ($plugintypes as $key => $val) {
         $options .= "<option value=\"{$key}\"";
         if ($this->_type == $key) {
             $options .= ' selected="selected"';
         }
         $options .= ">{$val}</option>" . LB;
     }
     $searchform->set_var('plugin_types', $options);
     if ($_CONF['contributedbyline'] == 1) {
         $searchform->set_var('lang_authors', $LANG09[8]);
         $searchusers = array();
         $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['comments']}");
         while ($A = DB_fetchArray($result)) {
             $searchusers[$A['uid']] = $A['uid'];
         }
         $result = DB_query("SELECT DISTINCT uid FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)");
         while ($A = DB_fetchArray($result)) {
             $searchusers[$A['uid']] = $A['uid'];
         }
         $inlist = implode(',', $searchusers);
         if (!empty($inlist)) {
             $sql = "SELECT uid,username,fullname FROM {$_TABLES['users']} WHERE uid IN ({$inlist})";
             if (isset($_CONF['show_fullname']) && $_CONF['show_fullname'] == 1) {
                 /* Caveat: This will group all users with an emtpy fullname
                  *         together, so it's not exactly sorted by their
                  *         full name ...
                  */
                 $sql .= ' ORDER BY fullname,username';
             } else {
                 $sql .= ' ORDER BY username';
             }
             $result = DB_query($sql);
             $options = '';
             while ($A = DB_fetchArray($result)) {
                 $options .= '<option value="' . $A['uid'] . '"';
                 if ($A['uid'] == $this->_author) {
                     $options .= ' selected="selected"';
                 }
                 $options .= '>' . htmlspecialchars(COM_getDisplayName('', $A['username'], $A['fullname'])) . '</option>';
             }
             $searchform->set_var('author_option_list', $options);
             $searchform->parse('author_form_element', 'authors', true);
         } else {
             $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>');
         }
     } else {
         $searchform->set_var('author_form_element', '<input type="hidden" name="author" value="0"' . XHTML . '>');
     }
     // Results per page
     $options = '';
     $limits = explode(',', $_CONF['search_limits']);
     foreach ($limits as $limit) {
         $options .= "<option value=\"{$limit}\"";
         if ($_CONF['num_search_results'] == $limit) {
             $options .= ' selected="selected"';
         }
         $options .= ">{$limit}</option>" . LB;
     }
     $searchform->set_var('search_limits', $options);
     $searchform->set_var('lang_search', $LANG09[10]);
     PLG_templateSetVars('search', $searchform);
     $searchform->parse('output', 'searchform');
     $retval .= $searchform->finish($searchform->get_var('output'));
     $retval .= COM_endBlock();
     return $retval;
 }
Example #3
0
/**
 * Show topic administration form
 *
 * @param    string  tid     ID of topic to edit
 * @return   string          HTML for the topic editor
 */
function edittopic($tid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG04, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS;
    $retval = '';
    if (empty($tid)) {
        // new topic - set defaults
        $A = array('tid' => '', 'topic' => '', 'sortnum' => 0, 'parent_id' => TOPIC_ROOT, 'inherit' => 1, 'hidden' => 0, 'limitnews' => '', 'is_default' => 0, 'archive_flag' => 0);
    } else {
        $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='{$tid}'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 || $access == 2) {
            $retval .= COM_showMessageText($LANG27[13], $LANG27[12]);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}.");
            return $retval;
        }
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    if (!is_array($A) || empty($A['owner_id'])) {
        $A['owner_id'] = $_USER['uid'];
        // this is the one instance where we default the group
        // most topics should belong to the Topic Admin group
        if (isset($_GROUPS['Topic Admin'])) {
            $A['group_id'] = $_GROUPS['Topic Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('topic.edit');
        }
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
        $access = 3;
    }
    $topic_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/topic');
    $topic_templates->set_file('editor', 'topiceditor.thtml');
    if (!empty($tid) && SEC_hasRights('topic.edit')) {
        $delButton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsConfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $topic_templates->set_var('delete_option', sprintf($delButton, $jsConfirm));
        $topic_templates->set_var('delete_option_no_confirmation', sprintf($delButton, ''));
        $topic_templates->set_var('allow_delete', true);
        $topic_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
        $topic_templates->set_var('confirm_message', $MESSAGE[76]);
        $topic_templates->set_var('warning_msg', $LANG27[6]);
    }
    if ($_CONF['titletoid'] && empty($tid)) {
        $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js');
        $topic_templates->set_var('titletoid', true);
    }
    $topic_templates->set_var('lang_topicid', $LANG27[2]);
    $topic_templates->set_var('topic_id', $A['tid']);
    $topic_templates->set_var('lang_parent_id', $LANG27[32]);
    $topic_templates->set_var('parent_id_options', TOPIC_getTopicListSelect($A['parent_id'], 1, false, $A['tid'], true));
    $topic_templates->set_var('lang_inherit', $LANG27[33]);
    $topic_templates->set_var('lang_inherit_info', $LANG27[34]);
    if ($A['inherit'] == 1) {
        $topic_templates->set_var('inherit_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('inherit_checked', '');
    }
    $topic_templates->set_var('lang_hidden', $LANG27[35]);
    $topic_templates->set_var('lang_hidden_info', $LANG27[36]);
    if ($A['hidden'] == 1) {
        $topic_templates->set_var('hidden_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('hidden_checked', '');
    }
    $topic_templates->set_var('lang_donotusespaces', $LANG27[5]);
    $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $topic_templates->set_var('owner_name', $ownername);
    $topic_templates->set_var('owner', $ownername);
    $topic_templates->set_var('owner_id', $A['owner_id']);
    $topic_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $topic_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $topic_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    // show sort order only if they specified sortnum as the sort method
    if ($_CONF['sortmethod'] !== 'alpha') {
        $topic_templates->set_var('lang_sortorder', $LANG27[10]);
        if ($A['sortnum'] == 0) {
            $A['sortnum'] = '';
        }
        $topic_templates->set_var('sort_order', '<input type="text" size="5" maxlength="5" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>');
    } else {
        $topic_templates->set_var('lang_sortorder', $LANG27[14]);
        $topic_templates->set_var('sort_order', $LANG27[15] . '<input type="hidden" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>');
    }
    $topic_templates->set_var('lang_storiesperpage', $LANG27[11]);
    if ($A['limitnews'] == 0) {
        $topic_templates->set_var('story_limit', '');
    } else {
        $topic_templates->set_var('story_limit', $A['limitnews']);
    }
    $topic_templates->set_var('default_limit', $_CONF['limitnews']);
    $topic_templates->set_var('lang_defaultis', $LANG27[16]);
    $topic_templates->set_var('lang_topicname', $LANG27[3]);
    $topic_templates->set_var('topic_name', htmlspecialchars(stripslashes($A['topic']), ENT_QUOTES, COM_getEncodingt()));
    if (empty($A['tid'])) {
        $A['imageurl'] = '/images/topics/';
    }
    $topic_templates->set_var('lang_topicimage', $LANG27[4]);
    $topic_templates->set_var('lang_uploadimage', $LANG27[27]);
    $topic_templates->set_var('lang_maxsize', $LANG27[28]);
    $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']);
    $topic_templates->set_var('max_url_length', 255);
    $topic_templates->set_var('image_url', $A['imageurl']);
    if (empty($_CONF['image_lib'])) {
        $scaling = $LANG04[162];
    } else {
        $scaling = $LANG04[161];
    }
    $topic_templates->set_var('icon_max_dimensions', sprintf($LANG04[160], $_CONF['max_topicicon_width'], $_CONF['max_topicicon_height'], $_CONF['max_topicicon_size'], $scaling));
    $topic_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $topic_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($A['meta_description'])) {
        $topic_templates->set_var('meta_description', $A['meta_description']);
    }
    if (!empty($A['meta_keywords'])) {
        $topic_templates->set_var('meta_keywords', $A['meta_keywords']);
    }
    if ($_CONF['meta_tags'] > 0) {
        $topic_templates->set_var('hide_meta', '');
    } else {
        $topic_templates->set_var('hide_meta', ' style="display:none;"');
    }
    $topic_templates->set_var('lang_defaulttopic', $LANG27[22]);
    $topic_templates->set_var('lang_defaulttext', $LANG27[23]);
    if ($A['is_default'] == 1) {
        $topic_templates->set_var('default_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('default_checked', '');
    }
    $topic_templates->set_var('lang_archivetopic', $LANG27[25]);
    $topic_templates->set_var('lang_archivetext', $LANG27[26]);
    $topic_templates->set_var('archive_disabled', '');
    if ($A['archive_flag'] == 1) {
        $topic_templates->set_var('archive_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('archive_checked', '');
        // Only 1 topic can be the archive topic - so check if there already is one
        if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) {
            $topic_templates->set_var('archive_disabled', 'disabled');
        }
    }
    if (empty($tid)) {
        $num_stories = $LANG_ADMIN['na'];
    } else {
        $nResult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'article' AND ta.id = sid AND ta.tid = '" . DB_escapeString($tid) . "'" . COM_getPermSql('AND'));
        $N = DB_fetchArray($nResult);
        $num_stories = COM_numberFormat($N['count']);
    }
    $topic_templates->set_var('lang_num_stories', $LANG27[30]);
    $topic_templates->set_var('num_stories', $num_stories);
    $topic_templates->set_var('gltoken_name', CSRF_TOKEN);
    $topic_templates->set_var('gltoken', $token);
    $topic_templates->parse('output', 'editor');
    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Example #4
0
/**
* Provide list of stories
*
* @param    string  $current_topic  (optional) currently selected topic
* @return   string                  HTML for the list of stories
*
*/
function liststories($current_topic = '')
{
    global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG09, $LANG_ADMIN, $LANG_ACCESS, $LANG24;
    require_once $_CONF['path_system'] . 'lib-admin.php';
    $retval = '';
    if (empty($current_topic)) {
        $current_topic = TOPIC_ALL_OPTION;
    }
    $seltopics = TOPIC_getTopicListSelect($current_topic, 2);
    if (empty($seltopics)) {
        $retval .= COM_showMessage(101);
        return $retval;
    }
    if ($current_topic == TOPIC_ALL_OPTION) {
        // Retrieve list of inherited topics
        // $tid_list = TOPIC_getChildList(TOPIC_ROOT);
        // Retrieve list of all topics user has access to (did not do inherit way since may not see all stories has access too)
        $tid_list = TOPIC_getList(0, true, false);
        if (empty($tid_list)) {
            $retval .= COM_showMessage(101);
            return $retval;
        }
        $excludetopics = " (tid IN ('" . implode("','", $tid_list) . "')) ";
    } else {
        // Retrieve list of inherited topics
        $tid_list = TOPIC_getChildList($current_topic);
        // Get list of blocks to display (except for dynamic). This includes blocks for all topics, and child blocks that are inherited
        $excludetopics = " (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$current_topic}')))";
        /*
        $seltopics = COM_topicList('tid,topic', $current_topic, 1, true);
        if (empty($seltopics)) {
            $retval .= COM_showMessage(101);
            return $retval;
        }
        */
    }
    $filter = $LANG_ADMIN['topic'] . ': <select name="tid" style="width: 125px" onchange="this.form.submit()">' . $seltopics . '</select>';
    $header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false), array('text' => $LANG_ADMIN['copy'], 'field' => 'copy', 'sort' => false), array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true), array('text' => $LANG_ACCESS['access'], 'field' => 'access', 'sort' => false), array('text' => $LANG24[34], 'field' => 'draft_flag', 'sort' => true));
    if ($_CONF['show_fullname'] == 1) {
        $header_arr[] = array('text' => $LANG24[7], 'field' => 'fullname', 'sort' => true);
        // author
    } else {
        $header_arr[] = array('text' => $LANG24[7], 'field' => 'username', 'sort' => true);
        // author
    }
    $header_arr[] = array('text' => $LANG24[15], 'field' => 'unixdate', 'sort' => true);
    // date
    $header_arr[] = array('text' => $LANG_ADMIN['topic'], 'field' => 'tid', 'sort' => true);
    $header_arr[] = array('text' => $LANG24[32], 'field' => 'featured', 'sort' => true);
    if (SEC_hasRights('story.ping') && ($_CONF['trackback_enabled'] || $_CONF['pingback_enabled'] || $_CONF['ping_enabled'])) {
        $header_arr[] = array('text' => $LANG24[20], 'field' => 'ping', 'sort' => false);
    }
    $defsort_arr = array('field' => 'unixdate', 'direction' => 'desc');
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/story.php?mode=edit', 'text' => $LANG_ADMIN['create_new']));
    $menu_arr[] = array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']);
    $form_arr = array('bottom' => '', 'top' => '');
    $retval .= COM_startBlock($LANG24[22], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG24[23], $_CONF['layout_url'] . '/images/icons/story.' . $_IMAGE_TYPE);
    $text_arr = array('has_extras' => true, 'form_url' => $_CONF['site_admin_url'] . '/story.php');
    $sql = "SELECT {$_TABLES['stories']}.*, {$_TABLES['users']}.username, {$_TABLES['users']}.fullname, " . "UNIX_TIMESTAMP(date) AS unixdate  FROM {$_TABLES['stories']} " . "LEFT JOIN {$_TABLES['users']} ON {$_TABLES['stories']}.uid={$_TABLES['users']}.uid " . "LEFT JOIN {$_TABLES['topic_assignments']} ta ON ta.type = 'article' AND ta.id = sid " . "WHERE 1=1 ";
    if (!empty($excludetopics)) {
        $excludetopics = 'AND ' . $excludetopics;
    }
    $query_arr = array('table' => 'stories', 'sql' => $sql, 'query_group' => "sid,{$_TABLES['users']}.username,{$_TABLES['users']}.fullname", 'query_fields' => array('title', 'introtext', 'bodytext', 'sid', 'tid'), 'default_filter' => $excludetopics . COM_getPermSQL('AND'));
    // Add in topic filter so it is remembered with paging
    $pagenavurl = '&amp;tid=' . $current_topic;
    $retval .= ADMIN_list('story', 'ADMIN_getListField_stories', $header_arr, $text_arr, $query_arr, $defsort_arr, $filter, '', '', $form_arr, true, $pagenavurl);
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Example #5
0
function links_edit_category($cid, $pid)
{
    global $_CONF, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN, $LANG_ADMIN, $LANG_ACCESS, $_LI_CONF;
    $retval = '';
    $cid = DB_escapeString($cid);
    if (!empty($pid)) {
        // have parent id, so making a new subcategory
        // get parent access rights
        $result = DB_query("SELECT group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='" . DB_escapeString($pid) . "'");
        $A = DB_fetchArray($result);
        $A['owner_id'] = $_USER['uid'];
        $A['pid'] = $pid;
    } elseif (!empty($cid)) {
        // have category id, so editing a category
        $sql = "SELECT * FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'" . COM_getPermSQL('AND');
        $result = DB_query($sql);
        $A = DB_fetchArray($result);
    } else {
        // nothing, so making a new top-level category
        // get default access rights
        $A['group_id'] = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Links Admin'");
        SEC_setDefaultPermissions($A, $_LI_CONF['category_permissions']);
        $A['owner_id'] = $_USER['uid'];
        $A['pid'] = $_LI_CONF['root'];
    }
    $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    if ($access < 3) {
        return COM_showMessage(6, 'links');
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG_LINKS_ADMIN[56], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    $T = COM_newTemplate(CTL_plugin_templatePath('links', 'admin'));
    $T->set_file(array('page' => 'categoryeditor.thtml'));
    $T->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
    $T->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]);
    $T->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]);
    $T->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]);
    $T->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]);
    $T->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]);
    $T->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
    $T->set_var('instructions', $LANG_LINKS_ADMIN[29]);
    $T->set_var('lang_category', $LANG_LINKS_ADMIN[30]);
    $T->set_var('lang_cid', $LANG_LINKS_ADMIN[32]);
    $T->set_var('lang_description', $LANG_LINKS_ADMIN[31]);
    $T->set_var('lang_topic', $LANG_LINKS_ADMIN[33]);
    $T->set_var('lang_parent', $LANG_LINKS_ADMIN[34]);
    $T->set_var('lang_save', $LANG_ADMIN['save']);
    if (!empty($cid)) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $T->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $T->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $T->set_var('allow_delete', true);
        $T->set_var('lang_delete', $LANG_ADMIN['delete']);
        $T->set_var('confirm_message', $MESSAGE[76]);
    } else {
        $T->set_var('delete_option', '');
    }
    $T->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    if (!empty($cid)) {
        $T->set_var('cid_value', $A['cid']);
        $T->set_var('old_cid_value', $A['cid']);
        $T->set_var('category_options', links_select_box(3, $A['pid']));
        $T->set_var('category_value', $A['category']);
        $T->set_var('description_value', $A['description']);
    } else {
        $A['cid'] = COM_makeSid();
        $T->set_var('cid_value', $A['cid']);
        $T->set_var('old_cid_value', '');
        $T->set_var('category_options', links_select_box(3, $A['pid']));
        $T->set_var('category_value', '');
        $T->set_var('description_value', '');
    }
    if (!isset($A['tid'])) {
        $A['tid'] = TOPIC_ALL_OPTION;
    }
    /*
    $topics = COM_topicList('tid,topic', $A['tid'], 1, true);
    $T->set_var('topic_list', $topics);
    $alltopics = '<option value="all"';
    if ($A['tid'] == 'all') {
        $alltopics .= ' selected="selected"';
    }
    $alltopics .= '>' . $LANG_LINKS_ADMIN[35] . '</option>' . LB;
    $T->set_var('topic_selection', '<select name="tid">' . $alltopics
                                   . $topics . '</select>');
    */
    $T->set_var('topic_selection', '<select name="tid" id="tid">' . TOPIC_getTopicListSelect($A['tid'], 2, true) . '</select>');
    if (empty($cid)) {
        $num_links = $LANG_ADMIN['na'];
    } else {
        $nresult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$cid}'" . COM_getPermSQL('AND'));
        $N = DB_fetchArray($nresult);
        $num_links = COM_numberFormat($N['count']);
    }
    $T->set_var('lang_num_links', $LANG_LINKS_ADMIN[61]);
    $T->set_var('num_links', $num_links);
    // user access info
    $T->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $T->set_var('lang_owner', $LANG_ACCESS['owner']);
    $T->set_var('owner_name', COM_getDisplayName($A['owner_id']));
    $T->set_var('cat_ownerid', $A['owner_id']);
    $T->set_var('lang_group', $LANG_ACCESS['group']);
    $T->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $T->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $T->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $T->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $T->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $T->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $T->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']);
    $T->set_var('gltoken_name', CSRF_TOKEN);
    $T->set_var('gltoken', $token);
    $T->parse('output', 'page');
    $retval .= $T->finish($T->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Example #6
0
/**
* Shows topic control for an object
*
* This will return the HTML needed to create the topic control seen on the
* admin screen for GL objects (i.e. stories, blocks, etc)
*
* @param        string     $type            Type of object to display access for
* @param        string     $id              Id of onject (if '' then load date from control)
* @param        boolean    $show_options    True/False. If true then All and Homepage options will be visible
* @param        boolean    $show_inherit    True/False. If true then inhert selection will be enabled
* @param        boolean    $show_default    True/False. If true then default topic selection will be enabled
* @return       string  needed HTML (table) in HTML
*
*/
function TOPIC_getTopicSelectionControl($type, $id, $show_options = false, $show_inherit = false, $show_default = false)
{
    global $_CONF, $LANG27, $_TABLES, $topic, $_SCRIPTS;
    $tids = array();
    $inherit_tids = array();
    $default_tid = '';
    // Set Default Topic Option
    $topic_option = TOPIC_SELECTED_OPTION;
    if ($show_options) {
        $topic_option = TOPIC_ALL_OPTION;
        // Default to all topics so things will work similar to how topics handled before Geeklog 2.0.0
    }
    // Do they have any access to topics first?
    // Retrieve Topic options
    $from_db = true;
    if (empty($type) || empty($id)) {
        $from_db = false;
    }
    if (!$from_db) {
        // see if a selection control variable is_a set. If not then first time for display of control
        if (isset($_POST['topic_options_hide'])) {
            TOPIC_getDataTopicSelectionControl($topic_option, $tids, $inherit_tids, $default_tid);
        } else {
            // Figure out if we set current topic for first display or use default topic
            if ($topic_option == TOPIC_SELECTED_OPTION && empty($tids)) {
                if ($topic == '') {
                    $tids = DB_getItem($_TABLES['topics'], 'tid', 'is_default = 1' . COM_getPermSQL('AND'));
                } else {
                    $tids = $topic;
                }
            }
        }
    } else {
        $sql = "SELECT * FROM {$_TABLES['topic_assignments']} WHERE type = '{$type}' AND id ='{$id}'";
        $result = DB_query($sql);
        $B = DB_fetchArray($result);
        $nrows = DB_numRows($result);
        if ($nrows > 0) {
            if ($B['tid'] == TOPIC_ALL_OPTION || $B['tid'] == TOPIC_HOMEONLY_OPTION) {
                $topic_option = $B['tid'];
            } else {
                $topic_option = TOPIC_SELECTED_OPTION;
                $tids = array();
                $tids[] = $B['tid'];
                if ($B['inherit'] == 1) {
                    $inherit_tids[] = $B['tid'];
                }
                if ($B['tdefault'] == 1) {
                    $default_tid = $B['tid'];
                }
                for ($i = 1; $i < $nrows; $i++) {
                    $B = DB_fetchArray($result);
                    $tids[] = $B['tid'];
                    if ($B['inherit'] == 1) {
                        $inherit_tids[] = $B['tid'];
                    }
                    if ($B['tdefault'] == 1) {
                        $default_tid = $B['tid'];
                    }
                }
            }
        } else {
            // Shouldn't happen but prepare
            $show_inherit = false;
            $show_default = false;
        }
    }
    $retval = '';
    $topic_info = $LANG27[40];
    $topic_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/common');
    $topic_templates->set_file(array('editor' => 'edit_topics.thtml'));
    $_SCRIPTS->setJavaScriptLibrary('jquery');
    $_SCRIPTS->setJavascriptFile('topic_control', '/javascript/topic_control.js');
    $topiclist = TOPIC_getTopicListSelect($tids, false);
    if (!$show_options && $topiclist == '') {
        // If access to no topics return nothing
        return '';
    }
    $topic_hide = false;
    // If false then topics multi select box will be visible
    $val_hide = 'display:none;';
    if ($topiclist == '') {
        // Topics do not exist
        $topic_hide = true;
        $topic_templates->set_var('topic_option_hide', $val_hide);
    } else {
        $topic_templates->set_var('topic_options', $topiclist);
    }
    if ($show_options && $topic_option !== TOPIC_SELECTED_OPTION) {
        $topic_hide = true;
    }
    $inherit_hide = true;
    // If false then inhert topic selection will be visible
    $default_hide = true;
    // If false then default topic selection will be visible
    if (!$topic_hide) {
        $inherit_hide = $show_inherit ? false : true;
        $default_hide = $show_default ? false : true;
    }
    if ($show_options) {
        $topic_templates->set_var('topic_options_hide', '0');
        $topic_info = $LANG27[41];
        $val_checked = 'checked="checked"';
        $all_checked = $topic_option == TOPIC_ALL_OPTION ? $val_checked : '';
        $homeonly_checked = $topic_option == TOPIC_HOMEONLY_OPTION ? $val_checked : '';
        $selectedtopics_checked = $topic_option == TOPIC_SELECTED_OPTION ? $val_checked : '';
        // if no topics found cannot check so set default
        if ($topic_option == TOPIC_SELECTED_OPTION && $topiclist == '') {
            $all_checked = $val_checked;
            $selectedtopics_checked = '';
        }
        $topic_templates->set_var('all_checked', $val_checked);
        $topic_templates->set_var('homeonly_checked', $homeonly_checked);
        $topic_templates->set_var('selectedtopics_checked', $selectedtopics_checked);
    } else {
        $topic_templates->set_var('options_hide', $val_hide);
        $topic_templates->set_var('topic_options_hide', '1');
    }
    $opt_dummy = '<option value="dummy">dummy</option>';
    $inherit_options = $opt_dummy;
    $topic_inherit_hide = '1';
    if ($show_inherit) {
        $topic_inherit_hide = '0';
        $topic_info .= $LANG27[42];
        if (!empty($inherit_tids)) {
            if ($from_db) {
                $inherit_options = TOPIC_getOtherListSelect($type, $id, $inherit_tids);
            } else {
                $inherit_options = TOPIC_getOtherListSelect($type, $id, $inherit_tids, $tids);
            }
        } else {
            $inherit_hide = true;
        }
    }
    $default_options = $opt_dummy;
    $topic_default_hide = '1';
    if ($show_default) {
        $topic_default_hide = '0';
        $topic_info .= $LANG27[43];
        if (!empty($default_tid)) {
            if ($from_db) {
                $default_options = TOPIC_getOtherListSelect($type, $id, $default_tid);
            } else {
                $default_options = TOPIC_getOtherListSelect($type, $id, $default_tid, $tids);
            }
        } else {
            $default_hide = true;
        }
    }
    $topic_templates->set_var('topic_inherit_hide', $topic_inherit_hide);
    $topic_templates->set_var('inherit_options', $inherit_options);
    $topic_templates->set_var('topic_default_hide', $topic_default_hide);
    $topic_templates->set_var('default_options', $default_options);
    $topic_templates->set_var('topic_hide', $topic_hide ? $val_hide : '');
    $topic_templates->set_var('inherit_hide', $inherit_hide ? $val_hide : '');
    $topic_templates->set_var('default_hide', $default_hide ? $val_hide : '');
    $topic_templates->set_var('info_hide', '');
    $topic_templates->set_var('topic_info', $topic_info);
    $topic_templates->set_var('lang_all', $LANG27[38]);
    $topic_templates->set_var('lang_homeonly', $LANG27[39]);
    $topic_templates->set_var('lang_selected', $LANG27[54]);
    $topic_templates->set_var('lang_assigned', $LANG27[55]);
    $topic_templates->set_var('lang_inherit', $LANG27[44]);
    $topic_templates->set_var('lang_default', $LANG27[45]);
    $topic_templates->parse('output', 'editor');
    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
    return $retval;
}
Example #7
0
function migrate_topicsList($selected = '')
{
    global $LANG_GF01;
    $retval = '<select name="seltopic"><option value="all">' . $LANG_GF01['ALL'] . '</option>';
    $retval .= '<option value="submissions"';
    if ($selected == "submissions") {
        $retval .= ' selected="selected"';
    }
    $retval .= '>' . $LANG_GF01['SUBMISSIONS'] . '</option>';
    $retval .= TOPIC_getTopicListSelect(array($selected), 0);
    $retval .= '</select>';
    return $retval;
}
Example #8
0
/**
* Display the feed editor.
*
* @param    int      $fid    feed id (0 for new feeds)
* @param    string   $type   type of feed, e.g. 'article'
* @return   string           HTML for the feed editor
*
*/
function editfeed($fid = 0, $type = '')
{
    global $_CONF, $_TABLES, $LANG33, $LANG_ADMIN, $MESSAGE;
    if ($fid > 0) {
        $result = DB_query("SELECT *,UNIX_TIMESTAMP(updated) AS date FROM {$_TABLES['syndication']} WHERE fid = '{$fid}'");
        $A = DB_fetchArray($result);
        $fid = $A['fid'];
    }
    if ($fid == 0) {
        if (!empty($type)) {
            // set defaults
            $A['fid'] = $fid;
            $A['type'] = $type;
            $A['topic'] = '::all';
            $A['header_tid'] = 'none';
            $A['format'] = 'RSS-2.0';
            $A['limits'] = $_CONF['rdf_limit'];
            $A['content_length'] = $_CONF['rdf_storytext'];
            $A['title'] = $_CONF['site_name'];
            $A['description'] = $_CONF['site_slogan'];
            $A['feedlogo'] = '';
            $A['filename'] = '';
            $A['charset'] = $_CONF['default_charset'];
            $A['language'] = $_CONF['rdf_language'];
            $A['is_enabled'] = 1;
            $A['updated'] = '';
            $A['update_info'] = '';
            $A['date'] = time();
        } else {
            return COM_refresh($_CONF['site_admin_url'] . '/syndication.php');
        }
    }
    $retval = '';
    $token = SEC_createToken();
    $feed_template = COM_newTemplate($_CONF['path_layout'] . 'admin/syndication');
    $feed_template->set_file('editor', 'feededitor.thtml');
    $start_block = COM_startBlock($LANG33[24], '', COM_getBlockTemplate('_admin_block', 'header'));
    $start_block .= SEC_getTokenExpiryNotice($token);
    $feed_template->set_var('start_feed_editor', $start_block);
    $feed_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $feed_template->set_var('lang_feedtitle', $LANG33[25]);
    $feed_template->set_var('lang_enabled', $LANG33[19]);
    $feed_template->set_var('lang_format', $LANG33[17]);
    $feed_template->set_var('lang_limits', $LANG33[26]);
    $feed_template->set_var('lang_content_length', $LANG33[27]);
    $feed_template->set_var('lang_clen_explain', $LANG33[28]);
    $feed_template->set_var('lang_description', $LANG33[29]);
    $feed_template->set_var('lang_feedlogo', $LANG33[49]);
    $feed_template->set_var('lang_feedlogo_explain', $LANG33[50]);
    $feed_template->set_var('lang_filename', $LANG33[16]);
    $feed_template->set_var('lang_updated', $LANG33[30]);
    $feed_template->set_var('lang_type', $LANG33[15]);
    $feed_template->set_var('lang_charset', $LANG33[31]);
    $feed_template->set_var('lang_language', $LANG33[32]);
    $feed_template->set_var('lang_topic', $LANG33[33]);
    $feed_template->set_var('lang_header_topic', $LANG33[45]);
    $feed_template->set_var('header_topic_options', TOPIC_getTopicListSelect($A['header_tid'], 6, true));
    $feed_template->set_var('lang_save', $LANG_ADMIN['save']);
    $feed_template->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    if ($A['fid'] > 0) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $feed_template->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $feed_template->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $feed_template->set_var('allow_delete', true);
        $feed_template->set_var('lang_delete', $LANG_ADMIN['delete']);
        $feed_template->set_var('confirm_message', $MESSAGE[76]);
    }
    $feed_template->set_var('feed_id', $A['fid']);
    $feed_template->set_var('feed_title', $A['title']);
    $feed_template->set_var('feed_description', $A['description']);
    $feed_template->set_var('feed_logo', $A['feedlogo']);
    $feed_template->set_var('feed_content_length', $A['content_length']);
    $feed_template->set_var('feed_filename', $A['filename']);
    $feed_template->set_var('feed_type', $A['type']);
    $feed_template->set_var('feed_type_display', ucwords($A['type']));
    $feed_template->set_var('feed_charset', $A['charset']);
    $feed_template->set_var('feed_language', $A['language']);
    if ($A['is_enabled'] == 1 && !empty($A['updated'])) {
        $nicedate = COM_getUserDateTimeFormat($A['date']);
        $feed_template->set_var('feed_updated', $nicedate[0]);
    } else {
        $feed_template->set_var('feed_updated', $LANG_ADMIN['na']);
    }
    $formats = find_feedFormats();
    $selection = '<select name="format">' . LB;
    foreach ($formats as $f) {
        // if one changes this format below ('name-version'), also change parsing
        // in COM_createHTMLDocument. It uses explode( "-" , $string )
        $selection .= '<option value="' . $f['name'] . '-' . $f['version'] . '"';
        if ($A['format'] == $f['name'] . '-' . $f['version']) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . ucwords($f['name'] . ' ' . $f['version']) . '</option>' . LB;
    }
    $selection .= '</select>' . LB;
    $feed_template->set_var('feed_format', $selection);
    $limits = $A['limits'];
    $hours = false;
    if (substr($A['limits'], -1) == 'h') {
        $limits = substr($A['limits'], 0, -1);
        $hours = true;
    }
    $selection = '<select name="limits_in">' . LB;
    $selection .= '<option value="0"';
    if (!$hours) {
        $selection .= ' selected="selected"';
    }
    $selection .= '>' . $LANG33[34] . '</option>' . LB;
    $selection .= '<option value="1"';
    if ($hours) {
        $selection .= ' selected="selected"';
    }
    $selection .= '>' . $LANG33[35] . '</option>' . LB;
    $selection .= '</select>' . LB;
    $feed_template->set_var('feed_limits', $limits);
    $feed_template->set_var('feed_limits_what', $selection);
    if ($A['type'] != 'article' and $A['type'] != 'comment') {
        $result = DB_query("SELECT pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name='{$A['type']}'");
        if ($result) {
            $P = DB_fetchArray($result);
            if ($P['pi_enabled'] == 0) {
                echo COM_refresh($_CONF['site_admin_url'] . '/syndication.php?msg=80');
                exit;
            }
        }
    }
    $options = PLG_getFeedNames($A['type']);
    $selection = '<select name="topic">' . LB;
    foreach ($options as $o) {
        $selection .= '<option value="' . $o['id'] . '"';
        if ($A['topic'] == $o['id']) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $o['name'] . '</option>' . LB;
    }
    $selection .= '</select>' . LB;
    $feed_template->set_var('feed_topic', $selection);
    if ($A['is_enabled'] == 1) {
        $feed_template->set_var('is_enabled', 'checked="checked"');
    } else {
        $feed_template->set_var('is_enabled', '');
    }
    $feed_template->set_var('gltoken_name', CSRF_TOKEN);
    $feed_template->set_var('gltoken', $token);
    $retval .= $feed_template->finish($feed_template->parse('output', 'editor'));
    return $retval;
}