Commit 69f0154b by Scott

Reformat code for users pages, tags page, and base theme

And normalize some line endings
parent e707b833
<?php
/*
Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/
File: qa-include/qa-page-message.php
Version: See define()s at top of qa-include/qa-base.php
Description: Controller for private messaging page
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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-db-selects.php';
require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-app-format.php';
require_once QA_INCLUDE_DIR.'qa-app-limits.php';
$loginUserId = qa_get_logged_in_userid();
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$showingInbox = qa_request_part(1) !== 'sent';
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
if (!isset($loginUserId)) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content;
}
if ( !qa_opt('allow_private_messages') )
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
// Find the user profile and questions and answers for this handle
$pmSpec = $showingInbox
? qa_db_messages_inbox_selectspec('private', $loginUserId, true)
: qa_db_messages_outbox_selectspec('private', $loginUserId, true);
$userMessages = qa_db_select_with_pending($pmSpec);
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = $showingInbox ? qa_lang_html('misc/pm_inbox_title') : qa_lang_html('misc/pm_outbox_title');
$qa_content['message_list'] = array(
'tags' => 'id="privatemessages"',
'messages' => array(),
);
$htmlDefaults = qa_message_html_defaults();
if (!$showingInbox) {
$htmlDefaults['towhomview'] = true;
}
foreach ($userMessages as $message) {
$qa_content['message_list']['messages'][] = qa_message_html_fields($message, $htmlDefaults);
}
$qa_content['navigation']['sub'] = array(
'inbox' => array(
'label' => qa_lang_html('misc/inbox'),
'url' => qa_path_html('messages'),
'selected' => $showingInbox,
),
'outbox' => array(
'label' => qa_lang_html('misc/outbox'),
'url' => qa_path_html('messages/sent'),
'selected' => !$showingInbox,
)
);
return $qa_content;
<?php
/*
Question2Answer (c) Gideon Greenspan
http://www.question2answer.org/
File: qa-include/qa-page-message.php
Version: See define()s at top of qa-include/qa-base.php
Description: Controller for private messaging page
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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-db-selects.php';
require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-app-format.php';
require_once QA_INCLUDE_DIR.'qa-app-limits.php';
$loginUserId = qa_get_logged_in_userid();
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$showingInbox = qa_request_part(1) !== 'sent';
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
if (!isset($loginUserId)) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content;
}
if ( !qa_opt('allow_private_messages') )
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
// Find the user profile and questions and answers for this handle
$pmSpec = $showingInbox
? qa_db_messages_inbox_selectspec('private', $loginUserId, true)
: qa_db_messages_outbox_selectspec('private', $loginUserId, true);
$userMessages = qa_db_select_with_pending($pmSpec);
// Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = $showingInbox ? qa_lang_html('misc/pm_inbox_title') : qa_lang_html('misc/pm_outbox_title');
$qa_content['message_list'] = array(
'tags' => 'id="privatemessages"',
'messages' => array(),
);
$htmlDefaults = qa_message_html_defaults();
if (!$showingInbox) {
$htmlDefaults['towhomview'] = true;
}
foreach ($userMessages as $message) {
$qa_content['message_list']['messages'][] = qa_message_html_fields($message, $htmlDefaults);
}
$qa_content['navigation']['sub'] = array(
'inbox' => array(
'label' => qa_lang_html('misc/inbox'),
'url' => qa_path_html('messages'),
'selected' => $showingInbox,
),
'outbox' => array(
'label' => qa_lang_html('misc/outbox'),
'url' => qa_path_html('messages/sent'),
'selected' => !$showingInbox,
)
);
return $qa_content;
......@@ -35,49 +35,49 @@
// Get popular tags
$start=qa_get_start();
$userid=qa_get_logged_in_userid();
$populartags=qa_db_select_with_pending(
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
$populartags = qa_db_select_with_pending(
qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags'))
);
$tagcount=qa_opt('cache_tagcount');
$pagesize=qa_opt('page_size_tags');
$tagcount = qa_opt('cache_tagcount');
$pagesize = qa_opt('page_size_tags');
// Prepare content for theme
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('main/popular_tags');
$qa_content['title'] = qa_lang_html('main/popular_tags');
$qa_content['ranking']=array(
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil($pagesize/qa_opt('columns_tags')),
'type' => 'tags'
);
if (count($populartags)) {
$favoritemap=qa_get_favorite_non_qs_map();
$favoritemap = qa_get_favorite_non_qs_map();
$output=0;
$output = 0;
foreach ($populartags as $word => $count) {
$qa_content['ranking']['items'][]=array(
$qa_content['ranking']['items'][] = array(
'label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]),
'count' => number_format($count),
);
if ((++$output)>=$pagesize)
if ((++$output) >= $pagesize)
break;
}
} else
$qa_content['title']=qa_lang_html('main/no_tags_found');
$qa_content['title'] = qa_lang_html('main/no_tags_found');
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next'));
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next'));
if (empty($qa_content['page_links']))
$qa_content['suggest_next']=qa_html_suggest_ask();
$qa_content['suggest_next'] = qa_html_suggest_ask();
return $qa_content;
......
......@@ -42,44 +42,44 @@
// Get list of blocked users
$users=qa_db_select_with_pending(qa_db_users_with_flag_selectspec(QA_USER_FLAGS_USER_BLOCKED));
$users = qa_db_select_with_pending(qa_db_users_with_flag_selectspec(QA_USER_FLAGS_USER_BLOCKED));
// Check we have permission to view this page (moderator or above)
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// Get userids and handles of retrieved users
$usershtml=qa_userids_handles_html($users);
$usershtml = qa_userids_handles_html($users);
// Prepare content for theme
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=count($users) ? qa_lang_html('users/blocked_users') : qa_lang_html('users/no_blocked_users');
$qa_content['title'] = count($users) ? qa_lang_html('users/blocked_users') : qa_lang_html('users/no_blocked_users');
$qa_content['ranking']=array(
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil(count($users)/qa_opt('columns_users')),
'type' => 'users'
);
foreach ($users as $user) {
$qa_content['ranking']['items'][]=array(
$qa_content['ranking']['items'][] = array(
'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_user_level_string($user['level'])),
'raw' => $user,
);
}
$qa_content['navigation']['sub']=qa_users_sub_navigation();
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
......
......@@ -42,44 +42,44 @@
// Get list of special users
$users=qa_db_select_with_pending(qa_db_users_from_level_selectspec(QA_USER_LEVEL_EXPERT));
$users = qa_db_select_with_pending(qa_db_users_from_level_selectspec(QA_USER_LEVEL_EXPERT));
// Check we have permission to view this page (moderator or above)
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// Get userids and handles of retrieved users
$usershtml=qa_userids_handles_html($users);
$usershtml = qa_userids_handles_html($users);
// Prepare content for theme
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('users/special_users');
$qa_content['title'] = qa_lang_html('users/special_users');
$qa_content['ranking']=array(
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil(qa_opt('page_size_users')/qa_opt('columns_users')),
'type' => 'users'
);
foreach ($users as $user) {
$qa_content['ranking']['items'][]=array(
$qa_content['ranking']['items'][] = array(
'label' => $usershtml[$user['userid']],
'score' => qa_html(qa_user_level_string($user['level'])),
'raw' => $user,
);
}
$qa_content['navigation']['sub']=qa_users_sub_navigation();
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
......
......@@ -36,22 +36,22 @@
// Get list of all users
$start=qa_get_start();
$users=qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users')));
$start = qa_get_start();
$users = qa_db_select_with_pending(qa_db_top_users_selectspec($start, qa_opt_if_loaded('page_size_users')));
$usercount=qa_opt('cache_userpointscount');
$pagesize=qa_opt('page_size_users');
$users=array_slice($users, 0, $pagesize);
$usershtml=qa_userids_handles_html($users);
$usercount = qa_opt('cache_userpointscount');
$pagesize = qa_opt('page_size_users');
$users = array_slice($users, 0, $pagesize);
$usershtml = qa_userids_handles_html($users);
// Prepare content for theme
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('main/highest_users');
$qa_content['title'] = qa_lang_html('main/highest_users');
$qa_content['ranking']=array(
$qa_content['ranking'] = array(
'items' => array(),
'rows' => ceil($pagesize/qa_opt('columns_users')),
'type' => 'users'
......@@ -76,11 +76,11 @@
}
}
else
$qa_content['title']=qa_lang_html('main/no_active_users');
$qa_content['title'] = qa_lang_html('main/no_active_users');
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $usercount, qa_opt('pages_prev_next'));
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $usercount, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub']=qa_users_sub_navigation();
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
......
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5.0.0
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/
* @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2013 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
* @param string $classname The name of the class to load
*/
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5.0.0
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/
* @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2013 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
* @param string $classname The name of the class to load
*/
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment