示例#1
0
文件: qa-page.php 项目: ramo01/1kapp
function qa_page_queue_pending()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    qa_preload_options();
    $loginuserid = qa_get_logged_in_userid();
    if (isset($loginuserid)) {
        if (!QA_FINAL_EXTERNAL_USERS) {
            qa_db_queue_pending_select('loggedinuser', qa_db_user_account_selectspec($loginuserid, true));
        }
        qa_db_queue_pending_select('notices', qa_db_user_notices_selectspec($loginuserid));
    }
    qa_db_queue_pending_select('navpages', qa_db_pages_selectspec(array('B', 'M', 'O', 'F')));
    qa_db_queue_pending_select('widgets', qa_db_widgets_selectspec());
}
示例#2
0
function qa_db_select_with_pending()
{
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    global $qa_nav_pages_pending, $qa_nav_pages_cached, $qa_widgets_pending, $qa_widgets_cached, $qa_logged_in_pending;
    $selectspecs = func_get_args();
    $singleresult = count($selectspecs) == 1;
    foreach ($selectspecs as $key => $selectspec) {
        // can pass null parameters
        if (empty($selectspec)) {
            unset($selectspecs[$key]);
        }
    }
    $optionselectspecs = qa_options_pending_selectspecs();
    foreach ($optionselectspecs as $key => $selectspec) {
        $selectspecs[$key] = $selectspec;
    }
    if (@$qa_logged_in_pending && !QA_FINAL_EXTERNAL_USERS) {
        $loggedinselectspec = qa_logged_in_user_selectspec();
        if (is_array($loggedinselectspec)) {
            $selectspecs['_loggedin'] = $loggedinselectspec;
        }
    } else {
        $loggedinselectspec = null;
    }
    if (@$qa_nav_pages_pending && !isset($qa_nav_pages_cached)) {
        $selectspecs['_navpages'] = qa_db_pages_selectspec(array('B', 'M', 'O', 'F'));
    }
    if (@$qa_widgets_pending && !isset($qa_widgets_cached)) {
        $selectspecs['_widgets'] = qa_db_widgets_selectspec();
    }
    $outresults = qa_db_multi_select($selectspecs);
    qa_options_load_options($optionselectspecs, $outresults);
    if (is_array($loggedinselectspec)) {
        qa_logged_in_user_load($loggedinselectspec, $outresults['_loggedin']);
    }
    if (@$qa_nav_pages_pending && !isset($qa_nav_pages_cached)) {
        $qa_nav_pages_cached = $outresults['_navpages'];
    }
    if (@$qa_widgets_pending && !isset($qa_widgets_cached)) {
        $qa_widgets_cached = $outresults['_widgets'];
    }
    return $singleresult ? $outresults[0] : $outresults;
}
     $listhtml = '';
     $widgetmodules = qa_load_modules_with('widget', 'allow_template');
     foreach ($widgetmodules as $tryname => $trywidget) {
         if (method_exists($trywidget, 'allow_region')) {
             $listhtml .= '<li><b>' . qa_html($tryname) . '</b>';
             $listhtml .= strtr(qa_lang_html('admin/add_widget_link'), array('^1' => '<a href="' . qa_path_html('admin/layoutwidgets', array('title' => $tryname)) . '">', '^2' => '</a>'));
             if (method_exists($trywidget, 'admin_form')) {
                 $listhtml .= strtr(qa_lang_html('admin/widget_global_options'), array('^1' => '<a href="' . qa_admin_module_options_path('widget', $tryname) . '">', '^2' => '</a>'));
             }
             $listhtml .= '</li>';
         }
     }
     if (strlen($listhtml)) {
         $qa_content['form']['fields']['plugins'] = array('label' => qa_lang_html('admin/widgets_explanation'), 'style' => 'tall', 'type' => 'custom', 'html' => '<ul style="margin-bottom:0;">' . $listhtml . '</ul>');
     }
     $widgets = qa_db_single_select(qa_db_widgets_selectspec());
     $listhtml = '';
     $placeoptions = qa_admin_place_options();
     foreach ($widgets as $widget) {
         $listhtml .= '<li><b>' . qa_html($widget['title']) . '</b> - ' . '<a href="' . qa_path_html('admin/layoutwidgets', array('edit' => $widget['widgetid'])) . '">' . @$placeoptions[$widget['place']] . '</a>';
         $listhtml .= '</li>';
     }
     if (strlen($listhtml)) {
         $qa_content['form']['fields']['widgets'] = array('label' => qa_lang_html('admin/active_widgets_explanation'), 'type' => 'custom', 'html' => '<ul style="margin-bottom:0;">' . $listhtml . '</ul>');
     }
     break;
 case 'permissions':
     $qa_content['form']['fields']['permit_block'] = array('type' => 'static', 'label' => qa_lang_html('options/permit_block'), 'value' => qa_lang_html('options/permit_moderators'));
     if (!QA_FINAL_EXTERNAL_USERS) {
         $qa_content['form']['fields']['permit_approve_users'] = array('type' => 'static', 'label' => qa_lang_html('options/permit_approve_users'), 'value' => qa_lang_html('options/permit_moderators'));
         $qa_content['form']['fields']['permit_create_experts'] = array('type' => 'static', 'label' => qa_lang_html('options/permit_create_experts'), 'value' => qa_lang_html('options/permit_moderators'));
	More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
//	Get current list of widgets and determine the state of this admin page
$widgetid = qa_post_text('edit');
if (!strlen($widgetid)) {
    $widgetid = qa_get('edit');
}
list($widgets, $pages) = qa_db_select_with_pending(qa_db_widgets_selectspec(), qa_db_pages_selectspec());
if (isset($widgetid)) {
    $editwidget = null;
    foreach ($widgets as $widget) {
        if ($widget['widgetid'] == $widgetid) {
            $editwidget = $widget;
        }
    }
} else {
    $editwidget = array('title' => qa_post_text('title'));
    if (!isset($editwidget['title'])) {
        $editwidget['title'] = qa_get('title');
    }
}
$module = qa_load_module('widget', @$editwidget['title']);
$widgetfound = isset($module);
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
// report that we entered this page
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME']));
require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
//	Get current list of widgets and determine the state of this admin page
$widgetid = qa_post_text('edit');
if (!strlen($widgetid)) {
    $widgetid = qa_get('edit');
}
$widgets = qa_db_select_with_pending(qa_db_widgets_selectspec());
if (isset($widgetid)) {
    $editwidget = null;
    foreach ($widgets as $widget) {
        if ($widget['widgetid'] == $widgetid) {
            $editwidget = $widget;
        }
    }
} else {
    $editwidget = array('title' => qa_post_text('title'));
    if (!isset($editwidget['title'])) {
        $editwidget['title'] = qa_get('title');
    }
}
$module = qa_load_module('widget', @$editwidget['title']);
$widgetfound = isset($module);