Commit 5075c435 by Scott

More user-page controller refactoring

parent 1671cb43
...@@ -361,7 +361,7 @@ ...@@ -361,7 +361,7 @@
// General information about the user, only available if we're using internal user management // General information about the user, only available if we're using internal user management
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
$membertime = qa_time_to_string(qa_opt('db_time')-$useraccount['created']); $membertime = qa_time_to_string(qa_opt('db_time') - $useraccount['created']);
$joindate = qa_when_to_html($useraccount['created'], 0); $joindate = qa_when_to_html($useraccount['created'], 0);
$qa_content['form_profile'] = array( $qa_content['form_profile'] = array(
...@@ -405,11 +405,12 @@ ...@@ -405,11 +405,12 @@
// Private message link // Private message link
if ( qa_opt('allow_private_messages') && isset($loginuserid) && ($loginuserid != $userid) && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting ) if ( qa_opt('allow_private_messages') && isset($loginuserid) && ($loginuserid != $userid) && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) && !$userediting ) {
$qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array( $qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array(
'^1' => '<a href="'.qa_path_html('message/'.$handle).'">', '^1' => '<a href="'.qa_path_html('message/'.$handle).'">',
'^2' => '</a>', '^2' => '</a>',
)); ));
}
// Levels editing or viewing (add category-specific levels) // Levels editing or viewing (add category-specific levels)
...@@ -428,12 +429,13 @@ ...@@ -428,12 +429,13 @@
$leveloptions = array(); $leveloptions = array();
$catleveloptions = array('' => qa_lang_html('users/category_level_none')); $catleveloptions = array('' => qa_lang_html('users/category_level_none'));
foreach ($showlevels as $showlevel) foreach ($showlevels as $showlevel) {
if ($showlevel <= $maxlevelassign) { if ($showlevel <= $maxlevelassign) {
$leveloptions[$showlevel] = qa_html(qa_user_level_string($showlevel)); $leveloptions[$showlevel] = qa_html(qa_user_level_string($showlevel));
if ($showlevel > QA_USER_LEVEL_BASIC) if ($showlevel > QA_USER_LEVEL_BASIC)
$catleveloptions[$showlevel] = $leveloptions[$showlevel]; $catleveloptions[$showlevel] = $leveloptions[$showlevel];
} }
}
$qa_content['form_profile']['fields']['level']['options'] = $leveloptions; $qa_content['form_profile']['fields']['level']['options'] = $leveloptions;
...@@ -443,11 +445,12 @@ ...@@ -443,11 +445,12 @@
if (qa_using_categories()) { if (qa_using_categories()) {
$catleveladd = strlen(qa_get('catleveladd')) > 0; $catleveladd = strlen(qa_get('catleveladd')) > 0;
if ((!$catleveladd) && !count($userlevels)) if ((!$catleveladd) && !count($userlevels)) {
$qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array( $qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array(
'^1' => '<a href="'.qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)).'">', '^1' => '<a href="'.qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)).'">',
'^2' => '</a>', '^2' => '</a>',
)); ));
}
else else
$qa_content['form_profile']['fields']['level']['suffix'] = qa_lang_html('users/level_in_general'); $qa_content['form_profile']['fields']['level']['suffix'] = qa_lang_html('users/level_in_general');
...@@ -455,7 +458,7 @@ ...@@ -455,7 +458,7 @@
$userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY); $userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY);
$index = 0; $index = 0;
foreach ($userlevels as $userlevel) foreach ($userlevels as $userlevel) {
if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) { if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) {
$index++; $index++;
$id = 'ls_'.+$index; $id = 'ls_'.+$index;
...@@ -481,6 +484,7 @@ ...@@ -481,6 +484,7 @@
unset($qa_content['form_profile']['fields']['uc_'.$index.'_cat']['note']); unset($qa_content['form_profile']['fields']['uc_'.$index.'_cat']['note']);
} }
}
$qa_content['script_lines'][] = array( $qa_content['script_lines'][] = array(
"function qa_update_category_levels()", "function qa_update_category_levels()",
...@@ -531,7 +535,7 @@ ...@@ -531,7 +535,7 @@
$showpermits = array(); $showpermits = array();
$permitoptions = qa_get_permit_options(); $permitoptions = qa_get_permit_options();
foreach ($permitoptions as $permitoption) foreach ($permitoptions as $permitoption) {
if ( // if not available to approved and email confirmed users with no points, but yes available to the user, it's something special if ( // if not available to approved and email confirmed users with no points, but yes available to the user, it's something special
qa_permit_error($permitoption, $userid, QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_EMAIL_CONFIRMED, 0) && qa_permit_error($permitoption, $userid, QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_EMAIL_CONFIRMED, 0) &&
!qa_permit_error($permitoption, $userid, $useraccount['level'], $useraccount['flags'], $userpoints['points']) !qa_permit_error($permitoption, $userid, $useraccount['level'], $useraccount['flags'], $userpoints['points'])
...@@ -541,8 +545,9 @@ ...@@ -541,8 +545,9 @@
else else
$showpermits[] = qa_lang('profile/'.$permitoption); // then show it as an extra priviliege $showpermits[] = qa_lang('profile/'.$permitoption); // then show it as an extra priviliege
} }
}
if (count($showpermits)) if (count($showpermits)) {
$qa_content['form_profile']['fields']['permits'] = array( $qa_content['form_profile']['fields']['permits'] = array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('profile/extra_privileges'), 'label' => qa_lang_html('profile/extra_privileges'),
...@@ -550,6 +555,7 @@ ...@@ -550,6 +555,7 @@
'rows' => count($showpermits), 'rows' => count($showpermits),
'id' => 'permits', 'id' => 'permits',
); );
}
// Show email address only if we're an administrator // Show email address only if we're an administrator
...@@ -569,7 +575,6 @@ ...@@ -569,7 +575,6 @@
($userediting ? '' : qa_lang_html('users/only_shown_admins')), ($userediting ? '' : qa_lang_html('users/only_shown_admins')),
'id' => 'email', 'id' => 'email',
); );
} }
...@@ -588,7 +593,7 @@ ...@@ -588,7 +593,7 @@
'id' => 'lastlogin', 'id' => 'lastlogin',
); );
if (isset($useraccount['written'])) if (isset($useraccount['written'])) {
$qa_content['form_profile']['fields']['lastwrite'] = array( $qa_content['form_profile']['fields']['lastwrite'] = array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('users/last_write_label'), 'label' => qa_lang_html('users/last_write_label'),
...@@ -600,9 +605,9 @@ ...@@ -600,9 +605,9 @@
'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'), 'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'),
'id' => 'lastwrite', 'id' => 'lastwrite',
); );
}
else else
unset($qa_content['form_profile']['fields']['lastwrite']); unset($qa_content['form_profile']['fields']['lastwrite']);
} }
...@@ -654,10 +659,9 @@ ...@@ -654,10 +659,9 @@
// Edit form or button, if appropriate // Edit form or button, if appropriate
if ($userediting) { if ($userediting) {
if ( if (
(qa_opt('avatar_allow_gravatar') && ($useraccount['flags'] & QA_USER_FLAGS_SHOW_GRAVATAR)) || (qa_opt('avatar_allow_gravatar') && ($useraccount['flags'] & QA_USER_FLAGS_SHOW_GRAVATAR)) ||
(qa_opt('avatar_allow_upload') && (($useraccount['flags'] & QA_USER_FLAGS_SHOW_AVATAR)) && isset($useraccount['avatarblobid'])) (qa_opt('avatar_allow_upload') && ($useraccount['flags'] & QA_USER_FLAGS_SHOW_AVATAR) && isset($useraccount['avatarblobid']))
) { ) {
$qa_content['form_profile']['fields']['removeavatar'] = array( $qa_content['form_profile']['fields']['removeavatar'] = array(
'type' => 'checkbox', 'type' => 'checkbox',
...@@ -891,19 +895,22 @@ ...@@ -891,19 +895,22 @@
); );
} }
if (@$userpoints['points']) if (@$userpoints['points']) {
$qa_content['form_activity']['fields']['points']['value'] .= $qa_content['form_activity']['fields']['points']['value'] .=
qa_lang_html_sub('profile/ranked_x', '<span class="qa-uf-user-rank">'.number_format($userrank).'</span>'); qa_lang_html_sub('profile/ranked_x', '<span class="qa-uf-user-rank">'.number_format($userrank).'</span>');
}
if (@$userpoints['aselects']) if (@$userpoints['aselects']) {
$qa_content['form_activity']['fields']['questions']['value'] .= ($userpoints['aselects'] == 1) $qa_content['form_activity']['fields']['questions']['value'] .= ($userpoints['aselects'] == 1)
? qa_lang_html_sub('profile/1_with_best_chosen', '<span class="qa-uf-user-q-selects">1</span>', '1') ? qa_lang_html_sub('profile/1_with_best_chosen', '<span class="qa-uf-user-q-selects">1</span>', '1')
: qa_lang_html_sub('profile/x_with_best_chosen', '<span class="qa-uf-user-q-selects">'.number_format($userpoints['aselects']).'</span>'); : qa_lang_html_sub('profile/x_with_best_chosen', '<span class="qa-uf-user-q-selects">'.number_format($userpoints['aselects']).'</span>');
}
if (@$userpoints['aselecteds']) if (@$userpoints['aselecteds']) {
$qa_content['form_activity']['fields']['answers']['value'] .= ($userpoints['aselecteds'] == 1) $qa_content['form_activity']['fields']['answers']['value'] .= ($userpoints['aselecteds'] == 1)
? qa_lang_html_sub('profile/1_chosen_as_best', '<span class="qa-uf-user-a-selecteds">1</span>', '1') ? qa_lang_html_sub('profile/1_chosen_as_best', '<span class="qa-uf-user-a-selecteds">1</span>', '1')
: qa_lang_html_sub('profile/x_chosen_as_best', '<span class="qa-uf-user-a-selecteds">'.number_format($userpoints['aselecteds']).'</span>'); : qa_lang_html_sub('profile/x_chosen_as_best', '<span class="qa-uf-user-a-selecteds">'.number_format($userpoints['aselecteds']).'</span>');
}
......
...@@ -87,9 +87,10 @@ ...@@ -87,9 +87,10 @@
$htmldefaults['whoview'] = false; $htmldefaults['whoview'] = false;
$htmldefaults['avatarsize'] = 0; $htmldefaults['avatarsize'] = 0;
foreach ($questions as $question) foreach ($questions as $question) {
$qa_content['q_list']['qs'][] = qa_post_html_fields($question, $loginuserid, qa_cookie_get(), $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $loginuserid, qa_cookie_get(),
$usershtml, null, qa_post_html_options($question, $htmldefaults)); $usershtml, null, qa_post_html_options($question, $htmldefaults));
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next')); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
$wallposterrorhtml = qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']); $wallposterrorhtml = qa_wall_error_html($loginuserid, $useraccount['userid'], $useraccount['flags']);
foreach ($usermessages as $message) foreach ($usermessages as $message) {
if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) { if ($message['deleteable'] && qa_clicked('m'.$message['messageid'].'_dodelete')) {
if (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code'))) if (!qa_check_form_security_code('wall-'.$useraccount['handle'], qa_post_text('code')))
$errors['page'] = qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
qa_redirect(qa_request(), $_GET); qa_redirect(qa_request(), $_GET);
} }
} }
}
if (qa_clicked('dowallpost')) { if (qa_clicked('dowallpost')) {
$inmessage = qa_post_text('message'); $inmessage = qa_post_text('message');
...@@ -124,7 +125,7 @@ ...@@ -124,7 +125,7 @@
'messages' => array(), 'messages' => array(),
); );
if ($start==0) { // only allow posting on first page if ($start == 0) { // only allow posting on first page
if ($wallposterrorhtml) if ($wallposterrorhtml)
$qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post $qa_content['message_list']['error'] = $wallposterrorhtml; // an error that means we are not allowed to post
...@@ -155,8 +156,8 @@ ...@@ -155,8 +156,8 @@
// Sub menu for navigation in user pages // Sub menu for navigation in user pages
$qa_content['navigation']['sub'] = qa_user_sub_navigation( $handle, 'wall', $ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']);
isset($loginuserid) && ($loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid'])) ); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'wall', $ismyuser);
return $qa_content; return $qa_content;
......
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