Commit 716cb8db by Scott

Merge branch 'pr/38' into dev

Closes #38
parents 584e4c9e 8c7ee30b
......@@ -44,7 +44,7 @@
}
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs)
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, $html = false)
/*
Send email to person with $userid and/or $email and/or $handle (null/invalid values are ignored or retrieved from
user database as appropriate). Email uses $subject and $body, after substituting each key in $subs with its
......@@ -77,7 +77,12 @@
} else {
$useraccount=qa_db_select_with_pending(
qa_db_user_account_selectspec($userid, true)
array(
'columns' => array('email', 'handle'),
'source' => '^users WHERE userid = #',
'arguments' => array($userid),
'single' => true,
)
);
if ($needhandle)
......@@ -103,7 +108,7 @@
'toname' => $handle,
'subject' => strtr($subject, $subs),
'body' => (empty($handle) ? '' : qa_lang_sub('emails/to_handle_prefix', $handle)).strtr($body, $subs),
'html' => false,
'html' => $html,
));
} else
......@@ -157,4 +162,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
......@@ -149,7 +149,7 @@
$favoritenonqs=qa_db_get_pending_result('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
foreach ($favoritenonqs as $favorite)
foreach ($favoritenonqs as $favorite) {
switch ($favorite['type']) {
case QA_ENTITY_USER:
$qa_favorite_non_qs_map['user'][$favorite['userid']]=true;
......@@ -163,6 +163,7 @@
$qa_favorite_non_qs_map['category'][$favorite['categorybackpath']]=true;
break;
}
}
}
}
......@@ -1493,82 +1494,86 @@
(or null for no maximum) and $excludecategoryid to a category that should not be included.
*/
{
$pathcategories=qa_category_path($navcategories, $categoryid);
$pathcategories = qa_category_path($navcategories, $categoryid);
$startpath='';
$startpath = '';
foreach ($pathcategories as $category)
$startpath.='/'.$category['categoryid'];
$startpath .= '/' . $category['categoryid'];
if (!isset($maxdepth))
$maxdepth=QA_CATEGORY_DEPTH;
$maxdepth=min(QA_CATEGORY_DEPTH, $maxdepth);
if (isset($maxdepth))
$maxdepth = min(QA_CATEGORY_DEPTH, $maxdepth);
else
$maxdepth = QA_CATEGORY_DEPTH;
$qa_content['script_rel'][]='qa-content/qa-ask.js?'.QA_VERSION;
$qa_content['script_onloads'][]='qa_category_select('.qa_js($fieldname).', '.qa_js($startpath).');';
$qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
$qa_content['script_onloads'][] = sprintf('qa_category_select(%s, %s);', qa_js($fieldname), qa_js($startpath));
$qa_content['script_var']['qa_cat_exclude']=$excludecategoryid;
$qa_content['script_var']['qa_cat_allownone']=(int)$allownone;
$qa_content['script_var']['qa_cat_allownosub']=(int)$allownosub;
$qa_content['script_var']['qa_cat_maxdepth']=$maxdepth;
$qa_content['script_var'] = array(
'qa_cat_exclude' => $excludecategoryid,
'qa_cat_allownone' => (int) $allownone,
'qa_cat_allownosub' => (int) $allownosub,
'qa_cat_maxdepth' => $maxdepth,
);
$field['type']='select';
$field['tags']='name="'.$fieldname.'_0" id="'.$fieldname.'_0" onchange="qa_category_select('.qa_js($fieldname).');"';
$field['options']=array();
$field['type'] = 'select';
$field['tags'] = sprintf('name="%s_0" id="%s_0" onchange="qa_category_select(%s);"', $fieldname, $fieldname, qa_js($fieldname));
$field['options'] = array();
// create the menu that will be shown if Javascript is disabled
if ($allownone)
$field['options']['']=qa_lang_html('main/no_category'); // this is also copied to first menu created by Javascript
$field['options'][''] = qa_lang_html('main/no_category'); // this is also copied to first menu created by Javascript
$keycategoryids=array();
$keycategoryids = array();
if ($allownosub) {
$category=@$navcategories[$categoryid];
$upcategory=$category;
while (true) { // first get supercategories
$upcategory=@$navcategories[$upcategory['parentid']];
$category = @$navcategories[$categoryid];
if (!isset($upcategory))
break;
$keycategoryids[$upcategory['categoryid']]=true;
$upcategory = @$navcategories[$category['parentid']]; // first get supercategories
while (isset($upcategory)) {
$keycategoryids[$upcategory['categoryid']] = true;
$upcategory = @$navcategories[$upcategory['parentid']];
}
$keycategoryids=array_reverse($keycategoryids, true);
$keycategoryids = array_reverse($keycategoryids, true);
$depth=count($keycategoryids); // number of levels above
$depth = count($keycategoryids); // number of levels above
if (isset($category)) {
$depth++; // to count category itself
foreach ($navcategories as $navcategory) // now get siblings and self
if (!strcmp($navcategory['parentid'], $category['parentid']))
$keycategoryids[$navcategory['categoryid']]=true;
$keycategoryids[$navcategory['categoryid']] = true;
}
if ($depth<$maxdepth)
if ($depth < $maxdepth)
foreach ($navcategories as $navcategory) // now get children, if not too deep
if (!strcmp($navcategory['parentid'], $categoryid))
$keycategoryids[$navcategory['categoryid']]=true;
$keycategoryids[$navcategory['categoryid']] = true;
} else {
$haschildren=false;
$haschildren = false;
foreach ($navcategories as $navcategory) // check if it has any children
if (!strcmp($navcategory['parentid'], $categoryid))
$haschildren=true;
if (!strcmp($navcategory['parentid'], $categoryid)) {
$haschildren = true;
break;
}
if (!$haschildren)
$keycategoryids[$categoryid]=true; // show this category if it has no children
$keycategoryids[$categoryid] = true; // show this category if it has no children
}
foreach ($keycategoryids as $keycategoryid => $dummy)
if (strcmp($keycategoryid, $excludecategoryid))
$field['options'][$keycategoryid]=qa_category_path_html($navcategories, $keycategoryid);
$field['options'][$keycategoryid] = qa_category_path_html($navcategories, $keycategoryid);
$field['value']=@$field['options'][$categoryid];
$field['note']='<div id="'.$fieldname.'_note"><noscript style="color:red;">'.qa_lang_html('question/category_js_note').'</noscript></div>';
$field['value'] = @$field['options'][$categoryid];
$field['note'] =
'<div id="' . $fieldname . '_note">' .
'<noscript style="color:red;">' . qa_lang_html('question/category_js_note') . '</noscript>' .
'</div>';
}
......
......@@ -390,19 +390,19 @@
break;
case 'show_custom_sidebar':
$value=strlen(qa_opt('custom_sidebar')) ? true : false;
$value = strlen(qa_opt('custom_sidebar')) > 0;
break;
case 'show_custom_header':
$value=strlen(qa_opt('custom_header')) ? true : false;
$value = strlen(qa_opt('custom_header')) > 0;
break;
case 'show_custom_footer':
$value=strlen(qa_opt('custom_footer')) ? true : false;
$value = strlen(qa_opt('custom_footer')) > 0;
break;
case 'show_custom_in_head':
$value=strlen(qa_opt('custom_in_head')) ? true : false;
$value = strlen(qa_opt('custom_in_head')) > 0;
break;
case 'custom_sidebar':
......
......@@ -54,11 +54,11 @@
{
qa_post_unindex($oldquestion['postid']);
$wasqueued=($oldquestion['type']=='Q_QUEUED');
$titlechanged=strcmp($oldquestion['title'], $title) ? true : false;
$contentchanged=strcmp($oldquestion['content'], $content) || strcmp($oldquestion['format'], $format);
$tagschanged=strcmp($oldquestion['tags'], $tagstring) ? true : false;
$setupdated=($titlechanged || $contentchanged || $tagschanged) && (!$wasqueued) && !$silent;
$wasqueued = ($oldquestion['type'] == 'Q_QUEUED');
$titlechanged = strcmp($oldquestion['title'], $title) !== 0;
$contentchanged = strcmp($oldquestion['content'], $content) !== 0 || strcmp($oldquestion['format'], $format) !== 0;
$tagschanged = strcmp($oldquestion['tags'], $tagstring) !== 0;
$setupdated = ($titlechanged || $contentchanged || $tagschanged) && (!$wasqueued) && !$silent;
qa_db_post_set_content($oldquestion['postid'], $title, $content, $format, $tagstring, $notify,
$setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null,
......@@ -72,18 +72,19 @@
if ($setupdated && $remoderate) {
require_once QA_INCLUDE_DIR.'qa-app-posts.php';
$answers=qa_post_get_question_answers($oldquestion['postid']);
$commentsfollows=qa_post_get_question_commentsfollows($oldquestion['postid']);
$closepost=qa_post_get_question_closepost($oldquestion['postid']);
$answers = qa_post_get_question_answers($oldquestion['postid']);
$commentsfollows = qa_post_get_question_commentsfollows($oldquestion['postid']);
$closepost = qa_post_get_question_closepost($oldquestion['postid']);
foreach ($answers as $answer)
qa_post_unindex($answer['postid']);
foreach ($commentsfollows as $comment)
if ($comment['basetype']=='C')
foreach ($commentsfollows as $comment) {
if ($comment['basetype'] == 'C')
qa_post_unindex($comment['postid']);
}
if (@$closepost['parentid']==$oldquestion['postid'])
if (@$closepost['parentid'] == $oldquestion['postid'])
qa_post_unindex($closepost['postid']);
qa_db_post_set_type($oldquestion['postid'], 'Q_QUEUED');
......@@ -94,7 +95,8 @@
if ($oldquestion['flagcount'])
qa_db_flaggedcount_update();
} elseif ($oldquestion['type']=='Q') { // not hidden or queued
}
else if ($oldquestion['type'] == 'Q') { // not hidden or queued
qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']);
}
......
......@@ -102,7 +102,7 @@
if (isset($userid) && isset($categoryid)) {
$favoritemap=qa_get_favorite_non_qs_map();
$categoryisfavorite=@$favoritemap['category'][$navcategories[$categoryid]['backpath']] ? true : false;
$categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']];
$qa_content['favorite']=qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite,
qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
......
......@@ -220,7 +220,7 @@
Return whether there are any blobs whose content has been stored as a file on disk
*/
{
return count(qa_db_read_all_values(qa_db_query_sub('SELECT blobid FROM ^blobs WHERE content IS NULL LIMIT 1'))) ? true : false;
return qa_db_read_one_value(qa_db_query_sub('SELECT blobid FROM ^blobs WHERE content IS NULL LIMIT 1'), true) != null;
}
......@@ -229,7 +229,7 @@
Return whether there are any blobs whose content has been stored in the database
*/
{
return count(qa_db_read_all_values(qa_db_query_sub('SELECT blobid FROM ^blobs WHERE content IS NOT NULL LIMIT 1'))) ? true : false;
return qa_db_read_one_value(qa_db_query_sub('SELECT blobid FROM ^blobs WHERE content IS NOT NULL LIMIT 1'), true) != null;
}
......@@ -603,4 +603,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
......@@ -60,7 +60,7 @@
$doconfirms=qa_opt('confirm_user_emails') && ($useraccount['level']<QA_USER_LEVEL_EXPERT);
$isconfirmed=($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) ? true : false;
$haspassword=isset($useraccount['passsalt']) && isset($useraccount['passcheck']);
$isblocked=qa_user_permit_error() ? true : false;
$isblocked = qa_user_permit_error() !== false;
// Process profile if saved
......@@ -439,4 +439,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
......@@ -110,9 +110,9 @@
$userlevel=qa_user_level_for_categories($categoryids);
$in['name']=qa_post_text('name');
$in['notify']=qa_post_text('notify') ? true : false;
$in['notify'] = strlen(qa_post_text('notify')) > 0;
$in['email']=qa_post_text('email');
$in['queued']=qa_user_moderation_reason($userlevel) ? true : false;
$in['queued'] = qa_user_moderation_reason($userlevel) !== false;
qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
......
......@@ -75,7 +75,7 @@
if (strtolower(qa_db_calc_passcheck($inpassword, $userinfo['passsalt'])) == strtolower($userinfo['passcheck'])) { // login and redirect
require_once QA_INCLUDE_DIR.'qa-app-users.php';
qa_set_logged_in_user($inuserid, $userinfo['handle'], $inremember ? true : false);
qa_set_logged_in_user($inuserid, $userinfo['handle'], !empty($inremember));
$topath=qa_get('to');
......@@ -143,7 +143,7 @@
'type' => 'checkbox',
'label' => qa_lang_html('users/remember_label'),
'tags' => 'name="remember"',
'value' => @$inremember ? true : false,
'value' => !empty(@$inremember),
),
),
......
......@@ -450,7 +450,7 @@
if ($question['isbyuser']) {
$in['name']=qa_post_text('q_name');
$in['notify']=qa_post_text('q_notify') ? true : false;
$in['notify'] = !empty(qa_post_text('q_notify'));
$in['email']=qa_post_text('q_email');
}
......@@ -781,7 +781,7 @@
if ($answer['isbyuser']) {
$in['name']=qa_post_text($prefix.'name');
$in['notify']=qa_post_text($prefix.'notify') ? true : false;
$in['notify'] = !empty(qa_post_text($prefix.'notify'));
$in['email']=qa_post_text($prefix.'email');
}
......@@ -982,7 +982,7 @@
if ($comment['isbyuser']) {
$in['name']=qa_post_text($prefix.'name');
$in['notify']=qa_post_text($prefix.'notify') ? true : false;
$in['notify'] = !empty(qa_post_text($prefix.'notify'));
$in['email']=qa_post_text($prefix.'email');
}
......
......@@ -324,9 +324,9 @@
{
$in=array(
'name' => qa_post_text('a_name'),
'notify' => qa_post_text('a_notify') ? true : false,
'notify' => !empty(qa_post_text('a_notify')),
'email' => qa_post_text('a_email'),
'queued' => qa_user_moderation_reason(qa_user_level_for_post($question)) ? true : false,
'queued' => qa_user_moderation_reason(qa_user_level_for_post($question)) !== false,
);
qa_get_post_content('a_editor', 'a_content', $in['editor'], $in['content'], $in['format'], $in['text']);
......@@ -386,9 +386,9 @@
$in=array(
'name' => qa_post_text($prefix.'name'),
'notify' => qa_post_text($prefix.'notify') ? true : false,
'notify' => !empty(qa_post_text($prefix.'notify')),
'email' => qa_post_text($prefix.'email'),
'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) ? true : false,
'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) !== false,
);
qa_get_post_content($prefix.'editor', $prefix.'content', $in['editor'], $in['content'], $in['format'], $in['text']);
......@@ -443,9 +443,9 @@
'content' => $post['content'],
'format' => $post['format'],
'text' => qa_viewer_text($post['content'], $post['format']),
'notify' => isset($post['notify']) ? true : false,
'notify' => isset($post['notify']),
'email' => qa_email_validate($post['notify']) ? $post['notify'] : null,
'queued' => qa_user_moderation_reason(qa_user_level_for_post($post)) ? true : false,
'queued' => qa_user_moderation_reason(qa_user_level_for_post($post)) !== false,
);
if ($post['basetype']=='Q') {
......
......@@ -435,7 +435,7 @@
// Category-specific levels
if (qa_using_categories()) {
$catleveladd=qa_get('catleveladd') ? true : false;
$catleveladd = strlen(qa_get('catleveladd')) > 0;
if ((!$catleveladd) && !count($userlevels))
$qa_content['form_profile']['fields']['level']['suffix']=strtr(qa_lang_html('users/category_level_add'), array(
......@@ -545,10 +545,10 @@
// Show email address only if we're an administrator
if (($loginlevel>=QA_USER_LEVEL_ADMIN) && !qa_user_permit_error()) {
$doconfirms=qa_opt('confirm_user_emails') && ($useraccount['level']<QA_USER_LEVEL_EXPERT);
$isconfirmed=($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) ? true : false;
$htmlemail=qa_html(isset($inemail) ? $inemail : $useraccount['email']);
if (($loginlevel >= QA_USER_LEVEL_ADMIN) && !qa_user_permit_error()) {
$doconfirms = qa_opt('confirm_user_emails') && ($useraccount['level']<QA_USER_LEVEL_EXPERT);
$isconfirmed = ($useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) > 0;
$htmlemail = qa_html(isset($inemail) ? $inemail : $useraccount['email']);
$qa_content['form_profile']['fields']['email']=array(
'type' => $userediting ? 'text' : 'static',
......@@ -610,7 +610,7 @@
if (!isset($value))
$value=@$userprofile[$userfield['title']];
$valuehtml=qa_html($value, (($userfield['flags'] & QA_FIELD_FLAGS_MULTI_LINE) && !$fieldsediting) ? true : false);
$valuehtml=qa_html($value, (($userfield['flags'] & QA_FIELD_FLAGS_MULTI_LINE) && !$fieldsediting));
}
$label=trim(qa_user_userfield_label($userfield), ':');
......
......@@ -646,7 +646,7 @@
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
return preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email) ? true : false;
return preg_match("/^[\-\!\#\$\%\&\'\*\+\/\=\?\_\`\{\|\}\~a-zA-Z0-9\.\^]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\.\-]+$/", $email) === 1;
}
......
......@@ -109,6 +109,10 @@ form, fieldset {
border: none;
}
input[type="text"].qa-search-field {
padding: 4px 5px;
}
input[type="text"], input[type="password"], textarea, select, checkbox, radio {
border: 1px solid #ddd;
padding: 5px;
......
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