Commit 9cbb6cbe by pupi1985

Prevent users from favoriting themselves

parent dd724732
...@@ -40,38 +40,41 @@ ...@@ -40,38 +40,41 @@
require_once QA_INCLUDE_DIR.'qa-app-limits.php'; require_once QA_INCLUDE_DIR.'qa-app-limits.php';
require_once QA_INCLUDE_DIR.'qa-app-updates.php'; require_once QA_INCLUDE_DIR.'qa-app-updates.php';
if ($favorite) // Make sure the user is not favoriting themselves
qa_db_favorite_create($userid, $entitytype, $entityid); if ($entitytype != QA_ENTITY_USER || $userid != $entityid) {
else if ($favorite)
qa_db_favorite_delete($userid, $entitytype, $entityid); qa_db_favorite_create($userid, $entitytype, $entityid);
else
switch ($entitytype) { qa_db_favorite_delete($userid, $entitytype, $entityid);
case QA_ENTITY_QUESTION:
$action=$favorite ? 'q_favorite' : 'q_unfavorite'; switch ($entitytype) {
$params=array('postid' => $entityid); case QA_ENTITY_QUESTION:
break; $action=$favorite ? 'q_favorite' : 'q_unfavorite';
$params=array('postid' => $entityid);
case QA_ENTITY_USER: break;
$action=$favorite ? 'u_favorite' : 'u_unfavorite';
$params=array('userid' => $entityid); case QA_ENTITY_USER:
break; $action=$favorite ? 'u_favorite' : 'u_unfavorite';
$params=array('userid' => $entityid);
case QA_ENTITY_TAG: break;
$action=$favorite ? 'tag_favorite' : 'tag_unfavorite';
$params=array('wordid' => $entityid); case QA_ENTITY_TAG:
break; $action=$favorite ? 'tag_favorite' : 'tag_unfavorite';
$params=array('wordid' => $entityid);
case QA_ENTITY_CATEGORY: break;
$action=$favorite ? 'cat_favorite' : 'cat_unfavorite';
$params=array('categoryid' => $entityid); case QA_ENTITY_CATEGORY:
break; $action=$favorite ? 'cat_favorite' : 'cat_unfavorite';
$params=array('categoryid' => $entityid);
default: break;
qa_fatal_error('Favorite type not recognized');
break; default:
qa_fatal_error('Favorite type not recognized');
break;
}
qa_report_event($action, $userid, $handle, $cookieid, $params);
} }
qa_report_event($action, $userid, $handle, $cookieid, $params);
} }
......
...@@ -347,7 +347,7 @@ ...@@ -347,7 +347,7 @@
$qa_content['title'] = qa_lang_html_sub('profile/user_x', $userhtml); $qa_content['title'] = qa_lang_html_sub('profile/user_x', $userhtml);
$qa_content['error'] = @$errors['page']; $qa_content['error'] = @$errors['page'];
if (isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS) { if (isset($loginuserid) && $loginuserid != $useraccount['userid'] && !QA_FINAL_EXTERNAL_USERS) {
$favoritemap = qa_get_favorite_non_qs_map(); $favoritemap = qa_get_favorite_non_qs_map();
$favorite = @$favoritemap['user'][$useraccount['userid']]; $favorite = @$favoritemap['user'][$useraccount['userid']];
......
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