public function submit() { $this->attention_url = titania_url::unbuild_url($this->attention_url); // Subscriptions if (!$this->attention_id) { $email_vars = array('NAME' => $this->attention_title, 'U_VIEW' => titania_url::build_url('manage/attention', array('type' => $this->attention_type, 'id' => $this->attention_object_id))); titania_subscriptions::send_notifications(TITANIA_ATTENTION, 0, 'subscribe_notify.txt', $email_vars, $this->attention_poster_id); } parent::submit(); }
/** * Handle some stuff we need when submitting a revision */ public function submit() { if (!$this->revision_id) { // Update the contrib_last_update if required here if (!titania::$config->require_validation || !titania_types::$types[$this->contrib->contrib_type]->require_validation) { $this->contrib->contrib_last_update = titania::$time; $sql_ary = array('contrib_last_update' => $this->contrib->contrib_last_update); $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); // Subscriptions $email_vars = array('NAME' => $this->contrib->contrib_name, 'U_VIEW' => $this->contrib->get_url()); titania_subscriptions::send_notifications(TITANIA_CONTRIB, $this->contrib_id, 'subscribe_notify.txt', $email_vars); } } else { if (sizeof($this->phpbb_versions)) { $sql = 'DELETE FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' WHERE revision_id = ' . (int) $this->revision_id; phpbb::$db->sql_query($sql); } } parent::submit(); // Add phpBB versions supported if (sizeof($this->phpbb_versions)) { $versions = titania::$cache->get_phpbb_versions(); $sql_ary = array(); foreach ($this->phpbb_versions as $row) { if (!is_array($row)) { $row = array('phpbb_version_branch' => (int) $row); } if (!isset($row['phpbb_version_branch']) || !isset(titania::$config->phpbb_versions[$row['phpbb_version_branch']])) { continue; } // OMG, it's not in our cache! if (!isset($versions[$row['phpbb_version_branch'] . titania::$config->phpbb_versions[$row['phpbb_version_branch']]])) { titania::$cache->destroy('_titania_phpbb_versions'); } $sql_ary[] = array('revision_id' => $this->revision_id, 'contrib_id' => $this->contrib_id, 'revision_validated' => $this->revision_status == TITANIA_REVISION_APPROVED ? true : false, 'phpbb_version_branch' => $row['phpbb_version_branch'], 'phpbb_version_revision' => get_real_revision_version(isset($row['phpbb_version_revision']) ? $row['phpbb_version_revision'] : titania::$config->phpbb_versions[$row['phpbb_version_branch']]['latest_revision'])); } if (sizeof($sql_ary)) { phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary); } } // Update the release topic if ($this->revision_status == TITANIA_REVISION_APPROVED) { $this->contrib->update_release_topic(); } // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); }
titania_subscriptions::send_notifications(TITANIA_TOPIC, $post->topic_id, 'subscribe_notify.txt', $email_vars, $post->post_user_id); } $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $post->topic_id . ' AND post_approved = 0'; phpbb::$db->sql_query($sql); $cnt = phpbb::$db->sql_fetchfield('cnt'); if (!$cnt) { $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET topic_approved = 1 WHERE topic_id = ' . $post->topic_id; phpbb::$db->sql_query($sql); // 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); }
/** * Common posting stuff for post/reply/edit * * @param mixed $post_object * @param mixed $message_object */ private function common_post($mode, $post_object, $message_object) { titania::add_lang('posting'); phpbb::$user->add_lang('posting'); // Submit check...handles running $post->post_data() if required $submit = $message_object->submit_check(); if ($submit) { $error = $post_object->validate(); if (($validate_form_key = $message_object->validate_form_key()) !== false) { $error[] = $validate_form_key; } // @todo use permissions for captcha if (!phpbb::$user->data['is_registered'] && ($validate_captcha = $message_object->validate_captcha()) !== false) { $error[] = $validate_captcha; } $error = array_merge($error, $message_object->error); if (sizeof($error)) { phpbb::$template->assign_var('ERROR', implode('<br />', $error)); } else { // Force Queue Discussion topics to always be stickies if ($post_object->post_type == TITANIA_QUEUE_DISCUSSION) { $post_object->topic->topic_sticky = true; } // Does the post need approval? Never for the Queue Discussion or Queue if (!phpbb::$auth->acl_get('u_titania_post_approved') && $post_object->post_type != TITANIA_QUEUE_DISCUSSION && $post_object->post_type != TITANIA_QUEUE) { $post_object->post_approved = false; } $post_object->submit(); $message_object->submit($post_object->post_access); // Did they want to subscribe? if (isset($_POST['notify']) && phpbb::$user->data['is_registered']) { titania_subscriptions::subscribe(TITANIA_TOPIC, $post_object->topic->topic_id); } // Unapproved posts will get a notice if (!$post_object->topic->get_postcount()) { phpbb::$user->add_lang('posting'); trigger_error(phpbb::$user->lang['POST_STORED_MOD'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_INDEX'], '<a href="' . $post_object->topic->get_parent_url() . '">', '</a>')); } else { if (!$post_object->post_approved) { phpbb::$user->add_lang('posting'); trigger_error(phpbb::$user->lang['POST_STORED_MOD'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_TOPIC'], '<a href="' . $post_object->topic->get_url() . '">', '</a>')); } else { // Subscriptions if ($mode == 'reply') { if ($post_object->post_type == TITANIA_SUPPORT && is_object(titania::$contrib) && titania::$contrib->contrib_id == $post_object->topic->parent_id && titania::$contrib->contrib_name) { // Support topic reply $email_vars = array('NAME' => $post_object->topic->topic_subject, 'U_VIEW' => titania_url::append_url($post_object->topic->get_url(), array('view' => 'unread', '#' => 'unread')), 'CONTRIB_NAME' => titania::$contrib->contrib_name); titania_subscriptions::send_notifications(array(TITANIA_TOPIC, TITANIA_SUPPORT), array($post_object->topic_id, $post_object->topic->parent_id), 'subscribe_notify_contrib.txt', $email_vars, $post_object->post_user_id); } else { $email_vars = array('NAME' => $post_object->topic->topic_subject, 'U_VIEW' => titania_url::append_url($post_object->topic->get_url(), array('view' => 'unread', '#' => 'unread'))); titania_subscriptions::send_notifications(TITANIA_TOPIC, $post_object->topic_id, 'subscribe_notify.txt', $email_vars, $post_object->post_user_id); } } else { if ($mode == 'post') { if ($post_object->post_type == TITANIA_SUPPORT && is_object(titania::$contrib) && titania::$contrib->contrib_id == $post_object->topic->parent_id && titania::$contrib->contrib_name) { // New support topic $email_vars = array('NAME' => $post_object->topic->topic_subject, 'U_VIEW' => $post_object->topic->get_url(), 'CONTRIB_NAME' => titania::$contrib->contrib_name); titania_subscriptions::send_notifications($post_object->post_type, $post_object->topic->parent_id, 'subscribe_notify_forum_contrib.txt', $email_vars, $post_object->post_user_id); } else { $email_vars = array('NAME' => $post_object->topic->topic_subject, 'U_VIEW' => $post_object->topic->get_url()); titania_subscriptions::send_notifications($post_object->post_type, $post_object->topic->parent_id, 'subscribe_notify_forum.txt', $email_vars, $post_object->post_user_id); } } } } } redirect($post_object->get_url()); } } else { if (sizeof($message_object->error)) { phpbb::$template->assign_var('ERROR', implode('<br />', $message_object->error)); } } // Do we subscribe to actual topic? $is_subscribed = ($mode == 'edit' || $mode == 'reply') && titania_subscriptions::is_subscribed(TITANIA_TOPIC, $post_object->topic->topic_id) ? true : false; phpbb::$template->assign_vars(array('S_NOTIFY_ALLOWED' => phpbb::$user->data['is_registered'] && !$is_subscribed ? true : false, 'S_NOTIFY_CHECKED' => phpbb::$user->data['is_registered'] && !$is_subscribed && phpbb::$user->data['user_notify'] && $post_object->post_type == TITANIA_SUPPORT ? ' checked=checked' : '')); $message_object->display(); }
if ($repack) { $revision->repack($old_revision); } // Update the revision to be submitted, which unhides the queue topic and updates the contrib_last_update time $revision->revision_submitted = true; $revision->submit(); // Update the queue (make visible) $revision->update_queue(); if ($repack && titania::$config->use_queue && titania_types::$types[titania::$contrib->contrib_type]->use_queue) { redirect(titania_url::build_url('manage/queue', array('q' => $revision->revision_queue_id))); } // Subscriptions $queue = $revision->get_queue(); if ($queue) { $email_vars = array('NAME' => phpbb::$user->lang['VALIDATION'] . ' - ' . titania::$contrib->contrib_name . ' - ' . $revision->revision_version, 'U_VIEW' => titania_url::build_url('manage/queue', array('q' => $queue->queue_id))); titania_subscriptions::send_notifications(TITANIA_QUEUE, titania::$contrib->contrib_type, 'subscribe_notify_forum.txt', $email_vars, phpbb::$user->data['user_id']); } redirect(titania::$contrib->get_url()); break; } } while ($try_again); phpbb::$template->assign_vars(array('ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'NEXT_STEP' => $next_step, 'REVISION_ID' => $revision_id, 'AGREEMENT_NOTICE' => titania_types::$types[titania::$contrib->contrib_type]->upload_agreement ? isset(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) ? nl2br(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) : nl2br(titania_types::$types[titania::$contrib->contrib_type]->upload_agreement) : false, 'QUEUE_ALLOW_REPACK' => true, 'S_POST_ACTION' => $repack ? titania_url::append_url(titania::$contrib->get_url('revision'), array('repack' => $repack)) : titania::$contrib->get_url('revision'))); // Output the available license options foreach (titania_types::$types[titania::$contrib->contrib_type]->license_options as $option) { phpbb::$template->assign_block_vars('license_options', array('NAME' => $option, 'VALUE' => $option)); } // Display the list of phpBB versions available /*$allowed_branches = get_allowed_phpbb_branches(); foreach ($phpbb_versions as $version => $name) { if (!isset($allowed_branches[substr($version, 0, 2)]))
/** * Approve this revision * * @param mixed $public_notes */ public function approve($public_notes) { titania::add_lang(array('manage', 'contributions')); $revision = $this->get_revision(); $contrib = new titania_contribution(); if (!$contrib->load($this->contrib_id)) { return false; } $revision->contrib = $contrib; $contrib_release_topic_id = $contrib->contrib_release_topic_id; $notes = $this->queue_validation_notes; titania_decode_message($notes, $this->queue_validation_notes_uid); $message = sprintf(phpbb::$user->lang['QUEUE_REPLY_APPROVED'], $revision->revision_version, $notes); // Replace empty quotes if there are no notes if (!$notes) { $message = str_replace('[quote][/quote]', '', $message); } $this->topic_reply($message, false); $this->discussion_reply($message); // Update the revisions $revision->change_status(TITANIA_REVISION_APPROVED); // Reply to the release topic if ($contrib_release_topic_id && titania_types::$types[$contrib->contrib_type]->update_public) { // Replying to an already existing topic, use the update message $public_notes = sprintf(phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->update_public], $revision->revision_version) . ($public_notes ? sprintf(phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->update_public . '_NOTES'], $public_notes) : ''); $contrib->reply_release_topic($public_notes); } elseif (!$contrib_release_topic_id && titania_types::$types[$contrib->contrib_type]->reply_public) { // Replying to a topic that was just made, use the reply message $public_notes = phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->reply_public] . ($public_notes ? sprintf(phpbb::$user->lang[titania_types::$types[$contrib->contrib_type]->reply_public . '_NOTES'], $public_notes) : ''); $contrib->reply_release_topic($public_notes); } // Self-updating $this->queue_status = TITANIA_QUEUE_APPROVED; $this->queue_close_time = titania::$time; $this->queue_close_user = phpbb::$user->data['user_id']; $this->submit(false); // Send notification message $this->send_approve_deny_notification(true); // Subscriptions $email_vars = array('NAME' => $contrib->contrib_name, 'U_VIEW' => $contrib->get_url()); titania_subscriptions::send_notifications(TITANIA_CONTRIB, $this->contrib_id, 'subscribe_notify.txt', $email_vars); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); }