Commit 85a5f71e by Gideon Greenspan

1.6

parent d9dddd9f
1.6-beta-2
\ No newline at end of file
1.6
\ No newline at end of file
......@@ -22,13 +22,14 @@
More about this license: http://www.question2answer.org/license.php
*/
function qa_submit_wall_post(elem)
function qa_submit_wall_post(elem, morelink)
{
var params={};
params.message=document.forms.wallpost.message.value;
params.handle=document.forms.wallpost.handle.value;
params.code=document.forms.wallpost.code.value;
params.morelink=morelink ? 1 : 0;
qa_ajax_post('wallpost', params,
function(lines) {
......
......@@ -35,7 +35,7 @@
$usermessages=qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $tohandle, false));
$loginuserid=qa_get_logged_in_userid();
$usermessages=qa_wall_posts_add_rules($usermessages, $loginuserid);
$usermessages=qa_wall_posts_add_rules($usermessages, 0, $loginuserid);
foreach ($usermessages as $message)
if (qa_clicked('m'.$message['messageid'].'_dodelete') && $message['deleteable'])
......
......@@ -32,6 +32,7 @@
$message=qa_post_text('message');
$tohandle=qa_post_text('handle');
$morelink=qa_post_text('morelink');
$touseraccount=qa_db_select_with_pending(qa_db_user_account_selectspec($tohandle, false));
$loginuserid=qa_get_logged_in_userid();
......@@ -47,7 +48,7 @@
$touseraccount['wallposts']++; // won't have been updated
$usermessages=qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $touseraccount['userid'], true, qa_opt('page_size_wall')));
$usermessages=qa_wall_posts_add_rules($usermessages, $loginuserid);
$usermessages=qa_wall_posts_add_rules($usermessages, 0, $loginuserid);
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'wall', null, null);
......@@ -58,7 +59,7 @@
foreach ($usermessages as $message)
$themeclass->message_item(qa_wall_post_view($message));
if ($touseraccount['wallposts']>count($usermessages))
if ($morelink && ($touseraccount['wallposts']>count($usermessages)))
$themeclass->message_item(qa_wall_view_more_link($tohandle, count($usermessages)));
}
......
......@@ -117,31 +117,32 @@
}
function qa_wall_posts_add_rules($usermessages, $userid)
function qa_wall_posts_add_rules($usermessages, $start, $userid)
/*
Return the list of messages in $usermessages (as obtained via qa_db_recent_messages_selectspec()) with additional fields
indicating what actions can be performed on them by user $userid. Currently only 'deleteable' is relevant.
Return the list of messages in $usermessages (as obtained via qa_db_recent_messages_selectspec()) with additional
fields indicating what actions can be performed on them by user $userid. The messages are retrieved beginning at
offset $start in the database. Currently only 'deleteable' is relevant.
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$deleteable=isset($userid); // can delete all most recent messages...
$deleteable=($start==0) && isset($userid); // can delete all of the most recent messages...
foreach ($usermessages as $key => $message) {
if (($message['touserid']!=$userid) && ($message['fromuserid']!=$userid))
$deleteable=false; // ... until we come across one that doesn't involve me
$usermessages[$key]['deleteable']=$deleteable;
}
return $usermessages;
}
function qa_wall_post_view($message)
/*
Returns an element to add to $qa_content['message_list']['messages'] for $message (as obtained via qa_db_recent_messages_selectspec()
and then qa_wall_posts_add_rules()) where $userid is the identity of the user currently viewing the message.
Returns an element to add to $qa_content['message_list']['messages'] for $message (as obtained via
qa_db_recent_messages_selectspec() and then qa_wall_posts_add_rules()).
*/
{
require_once QA_INCLUDE_DIR.'qa-app-format.php';
......@@ -150,7 +151,7 @@
$htmlfields=qa_message_html_fields($message, $options);
if (@$message['deleteable'])
if ($message['deleteable'])
$htmlfields['form']=array(
'style' => 'light',
......
......@@ -25,8 +25,8 @@
*/
define('QA_VERSION', '1.6-beta-2'); // also used as suffix for .js and .css requests
define('QA_BUILD_DATE', '2013-06-20');
define('QA_VERSION', '1.6'); // also used as suffix for .js and .css requests
define('QA_BUILD_DATE', '2013-06-27');
// Execution section of this file - remainder contains function definitions
......
......@@ -29,7 +29,7 @@
exit;
}
define('QA_DB_VERSION_CURRENT', 55);
define('QA_DB_VERSION_CURRENT', 56);
function qa_db_user_column_type_verify()
......@@ -259,7 +259,7 @@
'heading' => 'VARCHAR('.QA_DB_MAX_TITLE_LENGTH.')', // for display within <h1> tags
'content' => 'MEDIUMTEXT', // remainder of page HTML
'PRIMARY KEY (pageid)',
'UNIQUE tags (tags)',
'KEY tags (tags)',
'UNIQUE position (position)',
),
......@@ -1363,7 +1363,9 @@
case 54:
qa_db_upgrade_query('UNLOCK TABLES');
qa_db_upgrade_query('SET FOREIGN_KEY_CHECKS=0'); // in case InnoDB not available
qa_db_upgrade_query(qa_db_create_table_sql('userlevels', array(
'userid' => $definitions['userlevels']['userid'],
'entitytype' => $definitions['userlevels']['entitytype'],
......@@ -1397,6 +1399,13 @@
// Up to here: Version 1.6 beta 2
case 56:
qa_db_upgrade_query('ALTER TABLE ^pages DROP INDEX tags, ADD KEY tags (tags)');
qa_db_upgrade_query($locktablesquery);
break;
// Up to here: Version 1.6 (release)
}
qa_db_set_db_version($newversion);
......
......@@ -149,13 +149,6 @@
$errors['name']=qa_lang('main/field_required');
elseif (qa_strlen($inname)>QA_DB_MAX_CAT_PAGE_TITLE_LENGTH)
$errors['name']=qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TITLE_LENGTH);
else
foreach ($pages as $page)
if (
($page['pageid'] != @$editpage['pageid']) &&
qa_strtolower($page['title']) == qa_strtolower($inname)
)
$errors['name']=qa_lang('admin/page_already_used');
if ($isexternal) {
......
......@@ -44,17 +44,17 @@
$passwordsent=qa_get('ps');
$emailexists=qa_get('ee');
if (qa_clicked('dologin')) {
$inemailhandle=qa_post_text('emailhandle');
$inpassword=qa_post_text('password');
$inremember=qa_post_text('remember');
if (qa_clicked('dologin') && (strlen($inemailhandle) || strlen($inpassword)) ) {
require_once QA_INCLUDE_DIR.'qa-app-limits.php';
if (qa_user_limits_remaining(QA_LIMIT_LOGINS)) {
require_once QA_INCLUDE_DIR.'qa-db-users.php';
require_once QA_INCLUDE_DIR.'qa-db-selects.php';
$inemailhandle=qa_post_text('emailhandle');
$inpassword=qa_post_text('password');
$inremember=qa_post_text('remember');
if (!qa_check_form_security_code('login', qa_post_text('code')))
$pageerror=qa_lang_html('misc/form_security_again');
......
......@@ -87,6 +87,7 @@
$htmldefaults['whoview']=false;
$htmldefaults['avatarsize']=0;
$htmldefaults['ovoteview']=true;
$htmldefaults['answersview']=false;
foreach ($questions as $question) {
$options=qa_post_html_options($question, $htmldefaults);
......
......@@ -111,9 +111,11 @@
$userediting=$usereditbutton && (qa_get_state()=='edit');
$wallposterrorhtml=qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
// This code is similar but not identical to that in to qq-page-user-wall.php
$usermessages=array_slice($usermessages, 0, qa_opt('page_size_wall'));
$usermessages=qa_wall_posts_add_rules($usermessages, $loginuserid);
$usermessages=qa_wall_posts_add_rules($usermessages, 0, $loginuserid);
foreach ($usermessages as $message)
if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) {
......@@ -911,7 +913,7 @@
$qa_content['message_list']['form']['buttons']=array(
'post' => array(
'tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this);"',
'tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, true);"',
'label' => qa_lang_html('profile/post_wall_button'),
),
);
......
......@@ -59,7 +59,43 @@
$pagesize=qa_opt('page_size_wall');
$count=$useraccount['wallposts'];
$loginuserid=qa_get_logged_in_userid();
$usermessages=array_slice($usermessages, 0, $pagesize);
$usermessages=qa_wall_posts_add_rules($usermessages, $start, $loginuserid);
// Process deleting or adding a wall post (similar but not identical code to qq-page-user-profile.php)
$errors=array();
$wallposterrorhtml=qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
foreach ($usermessages as $message)
if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) {
if (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code')))
$errors['page']=qa_lang_html('misc/form_security_again');
else {
qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message);
qa_redirect(qa_request());
}
}
if (qa_clicked('dowallpost')) {
$inmessage=qa_post_text('message');
if (!strlen($inmessage))
$errors['message']=qa_lang('profile/post_wall_empty');
elseif (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code')))
$errors['message']=qa_lang_html('misc/form_security_again');
elseif (!$wallposterrorhtml) {
qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $useraccount['userid'], $useraccount['handle'], $inmessage, '');
qa_redirect(qa_request());
}
}
// Prepare content for theme
......@@ -67,11 +103,53 @@
$qa_content=qa_content_prepare();
$qa_content['title']=qa_lang_html_sub('profile/wall_for_x', $userhtml);
$qa_content['message_list']=array('messages' => array());
$qa_content['error']=@$errors['page'];
$qa_content['script_rel'][]='qa-content/qa-user.js?'.QA_VERSION;
$qa_content['message_list']=array(
'tags' => 'id="wallmessages"',
'form' => array(
'tags' => 'name="wallpost" method="post" action="'.qa_self_html().'"',
'style' => 'tall',
'hidden' => array(
'qa_click' => '', // for simulating clicks in Javascript
),
),
'messages' => array(),
);
if ($start==0) { // only allow posting on first page
if ($wallposterrorhtml)
$qa_content['message_list']['error']=$wallposterrorhtml; // an error that means we are not allowed to post
else {
$qa_content['message_list']['form']['fields']=array(
'message' => array(
'tags' => 'name="message" id="message"',
'value' => qa_html(@$inmessage, false),
'rows' => 2,
'error' => qa_html(@$errors['message']),
),
);
$qa_content['message_list']['form']['buttons']=array(
'post' => array(
'tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, false);"',
'label' => qa_lang_html('profile/post_wall_button'),
),
);
$qa_content['message_list']['form']['hidden']['handle']=qa_html($useraccount['handle']);
$qa_content['message_list']['form']['hidden']['code']=qa_get_form_security_code('wall-'.$useraccount['handle']);
}
}
foreach ($usermessages as $message)
$qa_content['message_list']['messages'][]=qa_wall_post_view($message);
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
......
......@@ -2198,7 +2198,7 @@ background:url(images/a-count-icon-ie6.png) no-repeat 32px 13px;
.qa-template-user .qa-part-form-activity h2{
margin-top: 0;
}
.qa-template-user .qa-part-form-profile{
.qa-template-user .qa-part-form-profile {
float: left;
width: 50%;
min-height: 630px;
......@@ -2207,13 +2207,14 @@ background:url(images/a-count-icon-ie6.png) no-repeat 32px 13px;
}
.qa-template-user .qa-part-form-activity,
.qa-template-user .qa-part-message-list,
.qa-template-user .qa-part-form-profile{
.qa-template-user .qa-part-form-profile {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow:hidden;
}
.qa-template-user .qa-part-message-list .qa-form-tall-text,
.qa-template-user .qa-part-form-profile .qa-form-wide-text{
.qa-template-user .qa-part-form-profile .qa-form-wide-text {
width: 100% !important;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
......
......@@ -25,7 +25,7 @@
$this->output(
'<!--[Begin: login form]-->',
'<form id="qa-loginform" action="'.$login['url'].'" method="post">',
'<input type="text" id="qa-userid" name="emailhandle" placeholder="'.trim(qa_lang_html('users/email_handle_label'), ':').'" />',
'<input type="text" id="qa-userid" name="emailhandle" placeholder="'.trim(qa_lang_html(qa_opt('allow_login_email_only') ? 'users/email_label' : 'users/email_handle_label'), ':').'" />',
'<input type="password" id="qa-password" name="password" placeholder="'.trim(qa_lang_html('users/password_label'), ':').'" />',
'<div id="qa-rememberbox"><input type="checkbox" name="remember" id="qa-rememberme" value="1"/>',
'<label for="qa-rememberme" id="qa-remember">'.qa_lang_html('users/remember').'</label></div>',
......
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