Atom for users

Создание лент пользователей: в аяксе, создание при обычном постинге, удаление при удалении юзера, фиксы папок для аттачей, аватарок и атомов. Осталось сделать пересоздание лент пользователей при удалении постов из тем и удалении тем (functions_admin).
This commit is contained in:
Exile 2014-08-12 22:11:47 +04:00
commit a7f0d2148c
8 changed files with 48 additions and 24 deletions

View file

@ -57,6 +57,13 @@ switch($this->request['type'])
$this->prompt_for_confirm($lang['CONFIRM_DELETE']);
}
post_delete($post_id);
// Update user atom feed
require_once(INC_DIR .'functions_atom.php');
$topic_id = (int) $this->request['topic_id'];
$topic_poster = (int) DB()->fetch_row("SELECT topic_poster FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1", 'topic_poster');
update_user_feed($topic_poster, get_username($topic_poster));
$this->response['hide'] = true;
$this->response['post_id'] = $post_id;
}
@ -158,6 +165,12 @@ switch($this->request['type'])
}
else $this->ajax_die($lang['EMPTY_MESSAGE']);
// Update user atom feed
require_once(INC_DIR .'functions_atom.php');
$topic_id = (int) $this->request['topic_id'];
$topic_poster = (int) DB()->fetch_row("SELECT topic_poster FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1", 'topic_poster');
update_user_feed($topic_poster, get_username($topic_poster));
$this->response['html'] = bbcode2html($text);
}
else
@ -309,6 +322,12 @@ switch($this->request['type'])
user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
}
// Update user atom feed
require_once(INC_DIR .'functions_atom.php');
$topic_id = (int) $this->request['topic_id'];
$topic_poster = (int) DB()->fetch_row("SELECT topic_poster FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1", 'topic_poster');
update_user_feed($topic_poster, get_username($topic_poster));
$this->response['redirect'] = make_url(POST_URL . "$post_id#$post_id");
break;

View file

@ -50,14 +50,14 @@ if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0)
{
bb_simple_die('Invalid type of query #3');
}
if (file_exists($bb_cfg['atom']['path'] .'/u/'. floor($id/5000000) .'/'. ($id % 100) .'/'. $id .'.atom') && filemtime($bb_cfg['atom']['path'] .'/u/'. floor($id/5000000) .'/'. ($id % 100) .'/'. $id .'.atom') > $timecheck)
if (file_exists($bb_cfg['atom']['path'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom') && filemtime($bb_cfg['atom']['path'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom') > $timecheck)
{
redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000000) .'/'. ($id % 100) .'/'. $id .'.atom');
redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom');
}
else
{
require_once(INC_DIR .'functions_atom.php');
if (update_user_feed($id, $username)) redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000000) .'/'. ($id % 100) .'/'. $id .'.atom');
if (update_user_feed($id, $username)) redirect($bb_cfg['atom']['url'] .'/u/'. floor($id/5000) .'/'. ($id % 100) .'/'. $id .'.atom');
else bb_simple_die('No feed for this user (no topics)');
}
}

View file

@ -215,8 +215,6 @@ class captcha_kcaptcha extends captcha_common
$credits = $bb_cfg['server_name']; # if empty, HTTP_HOST will be shown
# CAPTCHA image colors (RGB, 0-255)
//$foreground_color = array(0, 0, 0);
//$background_color = array(220, 230, 255);
$foreground_color = array(mt_rand(0,100), mt_rand(0,100), mt_rand(0,100));
$background_color = array(mt_rand(200,255), mt_rand(200,255), mt_rand(200,255));
@ -316,7 +314,7 @@ class captcha_kcaptcha extends captcha_common
$center=$x/2;
// credits. To remove, see configuration file
// credits
$img2=imagecreatetruecolor($width, $height+($show_credits?12:0));
$foreground=imagecolorallocate($img2, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
$background=imagecolorallocate($img2, $background_color[0], $background_color[1], $background_color[2]);
@ -390,8 +388,6 @@ class captcha_kcaptcha extends captcha_common
file_write('', $img_path, null, true, true);
imagejpeg($img2, $img_path, $jpeg_quality);
# imagegif($img2, $img_path);
# imagepng($img2, $img_path);
imagedestroy($img2);

View file

@ -11,7 +11,7 @@ function get_path_from_id ($id, $ext_id, $base_path, $first_div, $sec_div)
function get_avatar_path ($id, $ext_id, $base_path = '')
{
return get_path_from_id($id, $ext_id, $base_path, 5000000, 100);
return get_path_from_id($id, $ext_id, $base_path, 5000, 100);
}
function delete_avatar ($user_id, $avatar_ext_id)
@ -24,7 +24,7 @@ function delete_avatar ($user_id, $avatar_ext_id)
function get_attach_path ($id)
{
global $bb_cfg;
return get_path_from_id($id, '', $bb_cfg['attach']['upload_path'], 1000000, 100);
return get_path_from_id($id, '', $bb_cfg['attach']['upload_path'], 1000, 100);
}
function get_tracks ($type)

View file

@ -670,7 +670,7 @@ function post_delete ($mode_or_post_id, $user_id = null, $exclude_first = true)
function user_delete ($user_id, $delete_posts = false)
{
global $log_action;
global $bb_cfg, $log_action;
if (!$user_csv = get_id_csv($user_id))
{
@ -755,6 +755,13 @@ function user_delete ($user_id, $delete_posts = false)
DB()->query("UPDATE ". BB_PRIVMSGS ." SET privmsgs_from_userid = ". DELETED ." WHERE privmsgs_from_userid IN($user_csv)");
DB()->query("UPDATE ". BB_PRIVMSGS ." SET privmsgs_to_userid = ". DELETED ." WHERE privmsgs_to_userid IN($user_csv)");
// Delete user feed
foreach (explode(',', $user_csv) as $user_id)
{
$file_path = $bb_cfg['atom']['path'] .'/u/'. floor($user_id/5000) .'/'. ($user_id % 100) .'/'. $user_id .'.atom';
@unlink($file_path);
}
}
function get_usernames_for_log ($user_id)

View file

@ -79,7 +79,7 @@ function update_forum_feed ($forum_id, $forum_data)
function update_user_feed ($user_id, $username)
{
global $bb_cfg;
$file_path = $bb_cfg['atom']['path'] .'/u/'. floor($user_id/5000000) .'/'. ($user_id % 100) .'/'. $user_id .'.atom';
$file_path = $bb_cfg['atom']['path'] .'/u/'. floor($user_id/5000) .'/'. ($user_id % 100) .'/'. $user_id .'.atom';
$sql = "
SELECT
t.topic_id, t.topic_title, t.topic_status,
@ -154,7 +154,7 @@ function create_atom ($file_path, $mode, $id, $title, $topics)
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
if ( count($orig_word) )
if (count($orig_word))
{
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
}

View file

@ -353,7 +353,7 @@ elseif ( ($submit || $confirm) && !$topic_has_new_posts )
$return_message = '';
$return_meta = '';
switch ( $mode )
switch ($mode)
{
case 'editpost':
case 'newtopic':
@ -444,6 +444,11 @@ elseif ( ($submit || $confirm) && !$topic_has_new_posts )
}
}
// Update user atom feed
require_once(INC_DIR .'functions_atom.php');
$topic_poster = (int) DB()->fetch_row("SELECT topic_poster FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1", 'topic_poster');
update_user_feed($topic_poster, get_username($topic_poster));
if ($mode == 'reply' && $post_info['topic_status'] == TOPIC_LOCKED)
{
$locked_warn = '

View file

@ -5,7 +5,6 @@
<!-- IF HIDE_POST_IMG -->img.postImg, div.postImg-wrap { display: none; }<!-- ENDIF -->
<!-- IF HIDE_SMILE -->.smile { display: none; }<!-- ENDIF -->
<!-- IF HIDE_SIGNATURE -->.signature { display: none; }<!-- ENDIF -->
</style>
<!-- IF SPOILER_OPENED -->
<script type="text/javascript">
@ -27,10 +26,10 @@ function edit_post(post_id, type, text) {
} else{
$('#pp_'+ post_id).hide();
$('#pe_'+ post_id).show();
ajax.exec({
action : 'posts',
post_id : post_id,
topic_id : {TOPIC_ID},
text : text,
type : type
});
@ -199,7 +198,6 @@ function poll_manage (mode, confirm_msg)
$('#poll-submit-btn').click();
return false;
}
function build_poll_add_form (src_el)
{
$('#poll').empty().append( $('#poll-edit-tpl').contents() ).show();
@ -237,7 +235,6 @@ function build_poll_add_form (src_el)
<table cellspacing="0" cellpadding="0" class="borderless w100">
<tr>
<!-- IF AUTH_MOD -->
<td class="small bold nowrap" style="padding: 0 0 0 4px;">
<!-- IF IN_MODERATION -->{L_MODERATE_TOPIC}<!-- ELSE --><a href="{PAGE_URL}&amp;mod=1&amp;start={PAGE_START}" class="small bold">{L_MODERATE_TOPIC}</a><!-- ENDIF -->