/** * Copy new posts for queue discussion, queue to the forum */ function phpbb_com_titania_queue_update_first_queue_post($hook, &$post_object, $queue_object) { if ($queue_object->queue_status == TITANIA_QUEUE_HIDE || !$queue_object->queue_topic_id) { return; } // First we copy over the queue discussion topic if required $sql = 'SELECT topic_id, phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . ' WHERE parent_id = ' . $queue_object->contrib_id . ' AND topic_type = ' . TITANIA_QUEUE_DISCUSSION; $result = phpbb::$db->sql_query($sql); $topic_row = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); // Do we need to create the queue discussion topic or not? if ($topic_row['topic_id'] && !$topic_row['phpbb_topic_id']) { $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, TITANIA_QUEUE_DISCUSSION); $temp_post = new titania_post(); // Go through any posts in the queue discussion topic and copy them $topic_id = false; $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $topic_row['topic_id']; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $temp_post->__set_array($row); $post_text = $row['post_text']; titania_decode_message($post_text, $row['post_text_uid']); $post_text .= "\n\n" . titania_url::remove_sid($temp_post->get_url()); $options = array('poster_id' => $row['post_user_id'], 'forum_id' => $forum_id, 'topic_title' => $row['post_subject'], 'post_text' => $post_text); titania::_include('functions_posting', 'phpbb_posting'); if ($topic_id) { $options = array_merge($options, array('topic_id' => $topic_id)); phpbb_posting('reply', $options); } else { switch ($topic_row['topic_category']) { case TITANIA_TYPE_MOD: $options['poster_id'] = titania::$config->forum_mod_robot; break; case TITANIA_TYPE_STYLE: $options['poster_id'] = titania::$config->forum_style_robot; break; } $topic_id = phpbb_posting('post', $options); } } phpbb::$db->sql_freeresult($result); if ($topic_id) { $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET phpbb_topic_id = ' . $topic_id . ' WHERE topic_id = ' . $topic_row['topic_id']; phpbb::$db->sql_query($sql); } unset($temp_post); } // Does a queue topic already exist? If so, don't repost. $sql = 'SELECT phpbb_topic_id FROM ' . TITANIA_TOPICS_TABLE . ' WHERE topic_id = ' . $queue_object->queue_topic_id; phpbb::$db->sql_query($sql); $phpbb_topic_id = phpbb::$db->sql_fetchfield('phpbb_topic_id'); phpbb::$db->sql_freeresult(); if ($phpbb_topic_id) { return; } $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->topic->topic_type); if (!$forum_id) { return; } $post_object->submit(); titania::_include('functions_posting', 'phpbb_posting'); // Need some stuff titania::add_lang('contributions'); $contrib = new titania_contribution(); $contrib->load((int) $queue_object->contrib_id); $revision = $queue_object->get_revision(); $contrib->get_download($revision->revision_id); switch ($post_object->topic->topic_category) { case TITANIA_TYPE_MOD: $post_object->topic->topic_first_post_user_id = titania::$config->forum_mod_robot; $lang_var = 'MOD_QUEUE_TOPIC'; break; case TITANIA_TYPE_STYLE: $post_object->topic->topic_first_post_user_id = titania::$config->forum_style_robot; $lang_var = 'STYLE_QUEUE_TOPIC'; break; default: return; break; } $description = $contrib->contrib_desc; titania_decode_message($description, $contrib->contrib_desc_uid); $post_text = sprintf(phpbb::$user->lang[$lang_var], $contrib->contrib_name, $contrib->author->get_url(), users_overlord::get_user($contrib->author->user_id, '_username'), $description, $revision->revision_version, titania_url::build_url('download', array('id' => $revision->attachment_id)), $contrib->download['real_filename'], $contrib->download['filesize']); $post_text .= "\n\n" . $post_object->post_text; titania_decode_message($post_text, $post_object->post_text_uid); $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url()); $options = array('poster_id' => $post_object->topic->topic_first_post_user_id, 'forum_id' => $forum_id, 'topic_title' => $post_object->topic->topic_subject, 'post_text' => $post_text); $topic_id = phpbb_posting('post', $options); $post_object->topic->phpbb_topic_id = $topic_id; $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET phpbb_topic_id = ' . (int) $topic_id . ' WHERE topic_id = ' . $post_object->topic->topic_id; phpbb::$db->sql_query($sql); }
public function posts($mode, $start = false, $limit = false) { switch ($mode) { case 'index': $data = array(); $post = new titania_post(); $sql = 'SELECT p.*, t.topic_id, t.topic_type, t.topic_subject_clean, t.parent_id FROM ' . TITANIA_POSTS_TABLE . ' p, ' . TITANIA_TOPICS_TABLE . ' t WHERE t.topic_id = p.topic_id ORDER BY p.post_id ASC'; if ($start === false || $limit === false) { $result = phpbb::$db->sql_query($sql); } else { $result = phpbb::$db->sql_query_limit($sql, (int) $limit, (int) $start); } while ($row = phpbb::$db->sql_fetchrow($result)) { $post->__set_array($row); $post->topic->__set_array($row); $data[] = array('object_type' => $post->post_type, 'object_id' => $post->post_id, 'parent_id' => $post->topic->parent_id, 'title' => $post->post_subject, 'text' => $post->post_text, 'text_uid' => $post->post_text_uid, 'text_bitfield' => $post->post_text_bitfield, 'text_options' => $post->post_text_options, 'author' => $post->post_user_id, 'date' => $post->post_time, 'url' => titania_url::unbuild_url($post->get_url()), 'approved' => $post->post_approved, 'access_level' => $post->post_access); } phpbb::$db->sql_freeresult($result); titania_search::mass_index($data); break; } }
// Subscriptions if ($post->topic->topic_last_post_id == $post->post_id) { $email_vars = array('NAME' => $post->topic->topic_subject, 'U_VIEW' => $post->topic->get_url()); titania_subscriptions::send_notifications($post->post_type, $post->topic->parent_id, 'subscribe_notify_forum.txt', $email_vars, $post->post_user_id); } } // Notify poster about approval if ($post->post_user_id != ANONYMOUS) { $lang_path = phpbb::$user->lang_path; phpbb::$user->set_custom_lang_path(titania::$config->language_path); $messenger = new messenger(false); users_overlord::load_users(array($post->post_user_id)); $email_template = $post->post_id == $post->topic->topic_first_post_id && $post->post_id == $post->topic->topic_last_post_id ? 'topic_approved' : 'post_approved'; $messenger->template($email_template, users_overlord::get_user($post->post_user_id, 'user_lang')); $messenger->to(users_overlord::get_user($post->post_user_id, 'user_email'), users_overlord::get_user($post->post_user_id, '_username')); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode(users_overlord::get_user($post->post_user_id, '_username')), 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post->post_subject)), 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post->topic->topic_subject)), 'U_VIEW_TOPIC' => titania_url::append_url($post->topic->get_url()), 'U_VIEW_POST' => titania_url::append_url($post->get_url()))); $messenger->send(); phpbb::$user->set_custom_lang_path($lang_path); } redirect(titania_url::build_url(titania_url::$current_page)); } users_overlord::load_users(array($post->post_user_id, $post->post_edit_user, $post->post_delete_user)); users_overlord::assign_details($post->post_user_id, 'POSTER_', true); phpbb::$template->assign_vars(array('POST_SUBJECT' => censor_text($post->post_subject), 'POST_DATE' => phpbb::$user->format_date($post->post_time), 'POST_TEXT' => $post->generate_text_for_display(), 'EDITED_MESSAGE' => $post->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($post->post_edit_user, '_full'), phpbb::$user->format_date($post->post_edited)) : '', 'DELETED_MESSAGE' => $post->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($post->post_delete_user, '_full'), phpbb::$user->format_date($post->post_deleted), $post->get_url('undelete')) : '', 'POST_EDIT_REASON' => censor_text($post->post_edit_reason), 'U_VIEW' => $post->get_url(), 'U_EDIT' => $post->get_url('edit'), 'SECTION_NAME' => '<a href="' . $post->get_url() . '">' . censor_text($post->post_subject) . '</a> - ' . phpbb::$user->lang['ATTENTION'])); $title = censor_text($post->post_subject); break; case TITANIA_CONTRIB: $contrib = new titania_contribution(); if (!$contrib->load((int) $object_id)) { $attention_object->delete(); trigger_error('NO_CONTRIB');