本文整理汇总了PHP中sendNotifications函数的典型用法代码示例。如果您正苦于以下问题:PHP sendNotifications函数的具体用法?PHP sendNotifications怎么用?PHP sendNotifications使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendNotifications函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_removetopic2
/**
* Completely remove an entire topic.
* Redirects to the board when completed.
* Accessed by ?action=removetopic2
*/
public function action_removetopic2()
{
global $user_info, $topic, $board, $modSettings;
// Make sure they aren't being lead around by someone. (:@)
checkSession('get');
// This file needs to be included for sendNotifications().
require_once SUBSDIR . '/Notification.subs.php';
// This needs to be included for all the topic db functions
require_once SUBSDIR . '/Topic.subs.php';
// Trying to fool us around, are we?
if (empty($topic)) {
redirectexit();
}
$this->removeDeleteConcurrence();
$topic_info = getTopicInfo($topic, 'message');
if ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('remove_any')) {
isAllowedTo('remove_own');
} else {
isAllowedTo('remove_any');
}
// Can they see the topic?
if ($modSettings['postmod_active'] && !$topic_info['approved'] && $topic_info['id_member_started'] != $user_info['id']) {
isAllowedTo('approve_posts');
}
// Notify people that this topic has been removed.
sendNotifications($topic, 'remove');
removeTopics($topic);
// Note, only log topic ID in native form if it's not gone forever.
if (allowedTo('remove_any') || allowedTo('remove_own') && $topic_info['id_member_started'] == $user_info['id']) {
logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id' => $topic, 'subject' => $topic_info['subject'], 'member' => $topic_info['id_member_started'], 'board' => $board));
}
redirectexit('board=' . $board . '.0');
}
示例2: RemoveTopic2
/**
* Completely remove an entire topic.
* Redirects to the board when completed.
*/
function RemoveTopic2()
{
global $user_info, $topic, $board, $sourcedir, $smcFunc, $context, $modSettings;
// Make sure they aren't being lead around by someone. (:@)
checkSession('get');
// This file needs to be included for sendNotifications().
require_once $sourcedir . '/Subs-Post.php';
// Trying to fool us around, are we?
if (empty($topic)) {
redirectexit();
}
removeDeleteConcurrence();
$request = $smcFunc['db_query']('', '
SELECT t.id_member_started, ms.subject, t.approved
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
WHERE t.id_topic = {int:current_topic}
LIMIT 1', array('current_topic' => $topic));
list($starter, $subject, $approved) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if ($starter == $user_info['id'] && !allowedTo('remove_any')) {
isAllowedTo('remove_own');
} else {
isAllowedTo('remove_any');
}
// Can they see the topic?
if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) {
isAllowedTo('approve_posts');
}
// Notify people that this topic has been removed.
sendNotifications($topic, 'remove');
removeTopics($topic);
// Note, only log topic ID in native form if it's not gone forever.
if (allowedTo('remove_any') || allowedTo('remove_own') && $starter == $user_info['id']) {
logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id' => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board));
}
redirectexit('board=' . $board . '.0');
}
示例3: RemoveTopic2
function RemoveTopic2()
{
global $ID_MEMBER, $db_prefix, $topic, $board, $sourcedir;
// Make sure they aren't being lead around by someone. (:@)
checkSession('get');
// This file needs to be included for sendNotifications().
require_once $sourcedir . '/Subs-Post.php';
$request = db_query("\n\t\tSELECT t.ID_MEMBER_STARTED, ms.subject\n\t\tFROM ({$db_prefix}topics AS t, {$db_prefix}messages AS ms)\n\t\tWHERE t.ID_TOPIC = {$topic}\n\t\t\tAND ms.ID_MSG = t.ID_FIRST_MSG\n\t\tLIMIT 1", __FILE__, __LINE__);
list($starter, $subject) = mysql_fetch_row($request);
mysql_free_result($request);
if ($starter == $ID_MEMBER && !allowedTo('remove_any')) {
isAllowedTo('remove_own');
} else {
isAllowedTo('remove_any');
}
// Notify people that this topic has been removed.
sendNotifications($topic, 'remove');
removeTopics($topic);
if (allowedTo('remove_any') && (!allowedTo('remove_own') || $starter != $ID_MEMBER)) {
logAction('remove', array('topic' => $topic, 'subject' => $subject, 'member' => $starter));
}
redirectexit('board=' . $board . '.0');
}
示例4: mob_m_move_topic
function mob_m_move_topic($rpcmsg)
{
global $mobdb, $context, $sourcedir, $topic, $board, $user_info;
require_once $sourcedir . '/Subs-Post.php';
require_once $sourcedir . '/Subs-Boards.php';
$topicinfo = get_topicinfo($rpcmsg->getScalarValParam(0));
$newboard = get_boardinfo($rpcmsg->getScalarValParam(1));
if (empty($topicinfo) || empty($newboard)) {
mob_error('topic not found');
}
$topic = $topicinfo['id_topic'];
$board = $topicinfo['id_board'];
loadBoard();
loadPermissions();
if (!(allowedTo('move_any') || allowedTo('move_own') && $topicinfo['id_member_started'] == $user_info['id']) || $board == $newboard['id_board']) {
mob_error('cannot move topic');
}
// Send the notifications
logAction('move', array('topic' => $topicinfo['id_topic'], 'board_from' => $board, 'board_to' => $newboard['id_board']));
sendNotifications($topic, 'move');
move_topic($topic, $board, $newboard, $topicinfo);
// Return the true response
return new xmlrpcresp(new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean')), 'struct'));
}
示例5: action_mergeExecute
//.........这里部分代码省略.........
if ($row['approved']) {
$num_replies = $row['message_count'] - 1;
$num_unapproved = 0;
} else {
$topic_approved = 0;
$num_replies = 0;
$num_unapproved = $row['message_count'];
}
} else {
// If this has a lower first_msg then the first post is not approved and hence the number of replies was wrong!
if ($first_msg > $row['first_msg']) {
$first_msg = $row['first_msg'];
$num_replies++;
$topic_approved = 0;
}
$num_unapproved = $row['message_count'];
}
}
$db->free_result($request);
// Ensure we have a board stat for the target board.
if (!isset($boardTotals[$target_board])) {
$boardTotals[$target_board] = array('num_posts' => 0, 'num_topics' => 0, 'unapproved_posts' => 0, 'unapproved_topics' => 0);
}
// Fix the topic count stuff depending on what the new one counts as.
if ($topic_approved) {
$boardTotals[$target_board]['num_topics']--;
} else {
$boardTotals[$target_board]['unapproved_topics']--;
}
$boardTotals[$target_board]['unapproved_posts'] -= $num_unapproved;
$boardTotals[$target_board]['num_posts'] -= $topic_approved ? $num_replies + 1 : $num_replies;
// Get the member ID of the first and last message.
$request = $db->query('', '
SELECT id_member
FROM {db_prefix}messages
WHERE id_msg IN ({int:first_msg}, {int:last_msg})
ORDER BY id_msg
LIMIT 2', array('first_msg' => $first_msg, 'last_msg' => $last_msg));
list($member_started) = $db->fetch_row($request);
list($member_updated) = $db->fetch_row($request);
// First and last message are the same, so only row was returned.
if ($member_updated === null) {
$member_updated = $member_started;
}
$db->free_result($request);
// Obtain all the message ids we are going to affect.
$affected_msgs = messagesInTopics($topics);
// Assign the first topic ID to be the merged topic.
$id_topic = min($topics);
// Grab the response prefix (like 'Re: ') in the default forum language.
$context['response_prefix'] = response_prefix();
$enforce_subject = isset($_POST['enforce_subject']) ? Util::htmlspecialchars(trim($_POST['enforce_subject'])) : '';
// Merge topic notifications.
$notifications = isset($_POST['notifications']) && is_array($_POST['notifications']) ? array_intersect($topics, $_POST['notifications']) : array();
fixMergedTopics($first_msg, $topics, $id_topic, $target_board, $target_subject, $enforce_subject, $notifications);
// Asssign the properties of the newly merged topic.
$db->query('', '
UPDATE {db_prefix}topics
SET
id_board = {int:id_board},
id_member_started = {int:id_member_started},
id_member_updated = {int:id_member_updated},
id_first_msg = {int:id_first_msg},
id_last_msg = {int:id_last_msg},
id_poll = {int:id_poll},
num_replies = {int:num_replies},
unapproved_posts = {int:unapproved_posts},
num_views = {int:num_views},
is_sticky = {int:is_sticky},
approved = {int:approved}
WHERE id_topic = {int:id_topic}', array('id_board' => $target_board, 'is_sticky' => $is_sticky, 'approved' => $topic_approved, 'id_topic' => $id_topic, 'id_member_started' => $member_started, 'id_member_updated' => $member_updated, 'id_first_msg' => $first_msg, 'id_last_msg' => $last_msg, 'id_poll' => $target_poll, 'num_replies' => $num_replies, 'unapproved_posts' => $num_unapproved, 'num_views' => $num_views));
// Get rid of the redundant polls.
if (!empty($deleted_polls)) {
require_once SUBSDIR . '/Poll.subs.php';
removePoll($deleted_polls);
}
// Cycle through each board...
foreach ($boardTotals as $id_board => $stats) {
decrementBoard($id_board, $stats);
}
// Determine the board the final topic resides in
$topic_info = getTopicInfo($id_topic);
$id_board = $topic_info['id_board'];
// Update all the statistics.
updateStats('topic');
updateStats('subject', $id_topic, $target_subject);
updateLastMessages($boards);
logAction('merge', array('topic' => $id_topic, 'board' => $id_board));
// Notify people that these topics have been merged?
require_once SUBSDIR . '/Notification.subs.php';
sendNotifications($id_topic, 'merge');
// If there's a search index that needs updating, update it...
require_once SUBSDIR . '/Search.subs.php';
$searchAPI = findSearchAPI();
if (is_callable(array($searchAPI, 'topicMerge'))) {
$searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($enforce_subject) ? null : array($context['response_prefix'], $target_subject));
}
// Send them to the all done page.
redirectexit('action=mergetopics;sa=done;to=' . $id_topic . ';targetboard=' . $target_board);
}
示例6: QuickModeration
//.........这里部分代码省略.........
$members[$row['id_member']] -= 1;
}
}
$smcFunc['db_free_result']($request);
// And now update them member's post counts
foreach ($members as $id_member => $post_adj) {
updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
}
}
}
}
// Now delete the topics...
if (!empty($removeCache)) {
// They can only delete their own topics. (we wouldn't be here if they couldn't do that..)
$result = $smcFunc['db_query']('', '
SELECT id_topic, id_board
FROM {db_prefix}topics
WHERE id_topic IN ({array_int:removed_topic_ids})' . (!empty($board) && !allowedTo('remove_any') ? '
AND id_member_started = {int:current_member}' : '') . '
LIMIT ' . count($removeCache), array('current_member' => $user_info['id'], 'removed_topic_ids' => $removeCache));
$removeCache = array();
$removeCacheBoards = array();
while ($row = $smcFunc['db_fetch_assoc']($result)) {
$removeCache[] = $row['id_topic'];
$removeCacheBoards[$row['id_topic']] = $row['id_board'];
}
$smcFunc['db_free_result']($result);
// Maybe *none* were their own topics.
if (!empty($removeCache)) {
// Gotta send the notifications *first*!
foreach ($removeCache as $topic) {
// Only log the topic ID if it's not in the recycle board.
logAction('remove', array(empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $removeCacheBoards[$topic] ? 'topic' : 'old_topic_id' => $topic, 'board' => $removeCacheBoards[$topic]));
sendNotifications($topic, 'remove');
}
require_once $sourcedir . '/RemoveTopic.php';
removeTopics($removeCache);
}
}
// Approve the topics...
if (!empty($approveCache)) {
// We need unapproved topic ids and their authors!
$request = $smcFunc['db_query']('', '
SELECT id_topic, id_member_started
FROM {db_prefix}topics
WHERE id_topic IN ({array_int:approve_topic_ids})
AND approved = {int:not_approved}
LIMIT ' . count($approveCache), array('approve_topic_ids' => $approveCache, 'not_approved' => 0));
$approveCache = array();
$approveCacheMembers = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$approveCache[] = $row['id_topic'];
$approveCacheMembers[$row['id_topic']] = $row['id_member_started'];
}
$smcFunc['db_free_result']($request);
// Any topics to approve?
if (!empty($approveCache)) {
// Handle the approval part...
approveTopics($approveCache);
// Time for some logging!
foreach ($approveCache as $topic) {
logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
}
}
}
// And (almost) lastly, lock the topics...
示例7: Sticky
function Sticky()
{
global $modSettings, $topic, $board, $sourcedir;
// Make sure the user can sticky it, and they are stickying *something*.
isAllowedTo('make_sticky');
// You shouldn't be able to (un)sticky a topic if the setting is disabled.
if (empty($modSettings['enableStickyTopics'])) {
fatal_lang_error('cannot_make_sticky', false);
}
// You can't sticky a board or something!
if (empty($topic)) {
fatal_lang_error('not_a_topic', false);
}
checkSession('get');
// We need Subs-Post.php for the sendNotifications() function.
require_once $sourcedir . '/lib/Subs-Post.php';
// Is this topic already stickied, or no?
$request = smf_db_query('
SELECT is_sticky
FROM {db_prefix}topics
WHERE id_topic = {int:current_topic}
LIMIT 1', array('current_topic' => $topic));
list($is_sticky) = mysql_fetch_row($request);
mysql_free_result($request);
// Toggle the sticky value.... pretty simple ;).
smf_db_query('
UPDATE {db_prefix}topics
SET is_sticky = {int:is_sticky}
WHERE id_topic = {int:current_topic}', array('current_topic' => $topic, 'is_sticky' => empty($is_sticky) ? 1 : 0));
// Log this sticky action - always a moderator thing.
logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board));
// Notify people that this topic has been stickied?
if (empty($is_sticky)) {
sendNotifications($topic, 'sticky');
}
// Take them back to the now stickied topic.
redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
}
示例8: displayForm
function displayForm($formframe, $entry = "", $mainform = "", $done_dest = "", $button_text = "", $settings = "", $titleOverride = "", $overrideValue = "", $overrideMulti = "", $overrideSubMulti = "", $viewallforms = 0, $profileForm = 0, $printall = 0, $screen = null)
{
include_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
include_once XOOPS_ROOT_PATH . '/modules/formulize/include/extract.php';
formulize_benchmark("Start of formDisplay.");
if ($titleOverride == "formElementsOnly") {
$titleOverride = "all";
$formElementsOnly = true;
}
if (!is_numeric($titleOverride) and $titleOverride != "" and $titleOverride != "all") {
// we can pass in a text title for the form, and that will cause the $titleOverride "all" behaviour to be invoked, and meanwhile we will use this title for the top of the form
$passedInTitle = $titleOverride;
$titleOverride = "all";
}
//syntax:
//displayform($formframe, $entry, $mainform)
//$formframe is the id of the form OR title of the form OR name of the framework. Can also be an array. If it is an array, then flag 'formframe' is the $formframe variable, and flag 'elements' is an array of all the elements that are to be displayed.
//the array option is intended for displaying only part of a form at a time
//$entry is the numeric entry to display in the form -- if $entry is the word 'proxy' then it is meant to force a new form entry when the form is a single-entry form that the user already may have an entry in
//$mainform is the starting form to use, if this is a framework (can be specified by form id or by handle)
//$done_dest is the URL to go to after the form has been submitted
//Steps:
//1. identify form or framework
//2. if framework, check for unified display options
//3. if entry specified, then get data for that entry
//4. drawform with data if necessary
global $xoopsDB, $xoopsUser, $myts;
global $sfidsDrawn;
if (!is_array($sfidsDrawn)) {
$sfidsDrawn = array();
}
$groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
$original_entry = $entry;
// flag used to tell whether the function was called with an actual entry specified, ie: we're supposed to be editing this entry, versus the entry being set by coming back form a sub_form or other situation.
$mid = getFormulizeModId();
$currentURL = getCurrentURL();
/* Alter currentURL if necessary.
* Display list of entries screen on-click of form buttons "Save and Leave" and "Leave Page".
*/
if (isset($_GET['sid'])) {
$curr_screen = xoops_getmodulehandler('screen', 'formulize')->get($_GET['sid']);
if ($curr_screen->getVar('type') == 'form') {
$currentURL = $_SERVER['PHP_SELF'] . "?fid=" . $curr_screen->form_id();
}
} elseif (isset($_GET['ve']) && isset($_GET['fid'])) {
$currentURL = $_SERVER['PHP_SELF'] . "?fid=" . $_GET['fid'];
}
// identify form or framework
$elements_allowed = "";
// if a screen object is passed in, select the elements for display based on the screen's settings
if ($screen and is_a($screen, "formulizeFormScreen")) {
$elements_allowed = $screen->getVar("formelements");
}
if (is_array($formframe)) {
$elements_allowed = $formframe['elements'];
$printViewPages = isset($formframe['pages']) ? $formframe['pages'] : "";
$printViewPageTitles = isset($formframe['pagetitles']) ? $formframe['pagetitles'] : "";
$formframetemp = $formframe['formframe'];
unset($formframe);
$formframe = $formframetemp;
}
list($fid, $frid) = getFormFramework($formframe, $mainform);
if ($_POST['deletesubsflag']) {
// if deletion of sub entries requested
foreach ($_POST as $k => $v) {
if (strstr($k, "delbox")) {
$subs_to_del[] = $v;
}
}
if (count($subs_to_del) > 0) {
deleteFormEntries($subs_to_del, intval($_POST['deletesubsflag']));
// deletesubsflag will be the sub form id
sendNotifications($_POST['deletesubsflag'], "delete_entry", $subs_to_del, $mid, $groups);
}
}
if ($_POST['parent_form']) {
// if we're coming back from a subform
$entry = $_POST['parent_entry'];
$fid = $_POST['parent_form'];
}
if ($_POST['go_back_form']) {
// we just received a subform submission
$entry = $_POST['sub_submitted'];
$fid = $_POST['sub_fid'];
$go_back['form'] = $_POST['go_back_form'];
$go_back['entry'] = $_POST['go_back_entry'];
}
// set $entry in the case of a form_submission where we were editing an entry (just in case that entry is not what is used to call this function in the first place -- ie: we're on a subform and the mainform has no entry specified, or we're clicking submit over again on a single-entry form where we started with no entry)
$entrykey = "entry" . $fid;
if ((!$entry or $entry == "proxy") and $_POST[$entrykey]) {
// $entrykey will only be set when *editing* an entry, not on new saves
$entry = $_POST[$entrykey];
}
// this is probably not necessary any more, due to architecture changes in Formulize 3
// formulize_newEntryIds is set when saving data
if (!$entry and isset($GLOBALS['formulize_newEntryIds'][$fid])) {
$entry = $GLOBALS['formulize_newEntryIds'][$fid][0];
}
$member_handler =& xoops_gethandler('member');
$gperm_handler =& xoops_gethandler('groupperm');
//.........这里部分代码省略.........
示例9: action_movetopic2
//.........这里部分代码省略.........
checkSubmitOnce('check');
// Get the basic details on this topic
$topic_info = getTopicInfo($topic);
$context['is_approved'] = $topic_info['approved'];
// Can they see it?
if (!$context['is_approved']) {
isAllowedTo('approve_posts');
}
// Can they move topics on this board?
if (!allowedTo('move_any')) {
if ($topic_info['id_member_started'] == $user_info['id']) {
isAllowedTo('move_own');
} else {
isAllowedTo('move_any');
}
}
checkSession();
require_once SUBSDIR . '/Post.subs.php';
require_once SUBSDIR . '/Boards.subs.php';
// The destination board must be numeric.
$toboard = (int) $_POST['toboard'];
// Make sure they can see the board they are trying to move to (and get whether posts count in the target board).
$board_info = boardInfo($toboard, $topic);
if (empty($board_info)) {
fatal_lang_error('no_board');
}
// Remember this for later.
$_SESSION['move_to_topic'] = array('move_to' => $toboard);
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$custom_subject = strtr(Util::htmltrim(Util::htmlspecialchars($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
// Keep checking the length.
if (Util::strlen($custom_subject) > 100) {
$custom_subject = Util::substr($custom_subject, 0, 100);
}
// If it's still valid move onwards and upwards.
if ($custom_subject != '') {
$all_messages = isset($_POST['enforce_subject']);
if ($all_messages) {
// Get a response prefix, but in the forum's default language.
$context['response_prefix'] = response_prefix();
topicSubject($topic_info, $custom_subject, $context['response_prefix'], $all_messages);
} else {
topicSubject($topic_info, $custom_subject);
}
// Fix the subject cache.
updateStats('subject', $topic, $custom_subject);
}
}
// Create a link to this in the old board.
// @todo Does this make sense if the topic was unapproved before? I'd just about say so.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$reason = Util::htmlspecialchars($_POST['reason'], ENT_QUOTES);
preparsecode($reason);
// Add a URL onto the message.
$reason = strtr($reason, array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $toboard . '.0]' . $board_info['name'] . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
// Auto remove this MOVED redirection topic in the future?
$redirect_expires = !empty($_POST['redirect_expires']) ? (int) $_POST['redirect_expires'] : 0;
// Redirect to the MOVED topic from topic list?
$redirect_topic = isset($_POST['redirect_topic']) ? $topic : 0;
// And remember the last expiry period too.
$_SESSION['move_to_topic']['redirect_topic'] = $redirect_topic;
$_SESSION['move_to_topic']['redirect_expires'] = $redirect_expires;
$msgOptions = array('subject' => $txt['moved'] . ': ' . $board_info['subject'], 'body' => $reason, 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true, 'redirect_expires' => empty($redirect_expires) ? 0 : $redirect_expires * 60 + time(), 'redirect_topic' => $redirect_topic);
$posterOptions = array('id' => $user_info['id'], 'update_post_count' => empty($board_info['count_posts']));
createPost($msgOptions, $topicOptions, $posterOptions);
}
$board_from = boardInfo($board);
if ($board_from['count_posts'] != $board_info['count_posts']) {
$posters = postersCount($topic);
foreach ($posters as $id_member => $posts) {
// The board we're moving from counted posts, but not to.
if (empty($board_from['count_posts'])) {
updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
} else {
updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
}
}
}
// Do the move (includes statistics update needed for the redirect topic).
moveTopics($topic, $toboard);
// Log that they moved this topic.
if (!allowedTo('move_own') || $topic_info['id_member_started'] != $user_info['id']) {
logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $toboard));
}
// Notify people that this topic has been moved?
require_once SUBSDIR . '/Notification.subs.php';
sendNotifications($topic, 'move');
// Why not go back to the original board in case they want to keep moving?
if (!isset($_REQUEST['goback'])) {
redirectexit('board=' . $board . '.0');
} else {
redirectexit('topic=' . $topic . '.0');
}
}
示例10: MoveTopic2
function MoveTopic2()
{
global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context;
global $db_prefix, $ID_MEMBER, $board, $language, $user_info, $func;
// Make sure this form hasn't been submitted before.
checkSubmitOnce('check');
$request = db_query("\n\t\tSELECT ID_MEMBER_STARTED, ID_FIRST_MSG\n\t\tFROM {$db_prefix}topics\n\t\tWHERE ID_TOPIC = {$topic}\n\t\tLIMIT 1", __FILE__, __LINE__);
list($ID_MEMBER_STARTED, $ID_FIRST_MSG) = mysql_fetch_row($request);
mysql_free_result($request);
// Can they move topics on this board?
if (!allowedTo('move_any')) {
if ($ID_MEMBER_STARTED == $ID_MEMBER) {
isAllowedTo('move_own');
$boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any'));
} else {
isAllowedTo('move_any');
}
} else {
$boards = boardsAllowedTo('move_any');
}
checkSession();
require_once $sourcedir . '/Subs-Post.php';
// The destination board must be numeric.
$_POST['toboard'] = (int) $_POST['toboard'];
// !!!
/*if (!in_array($_POST['toboard'], $boards) && !in_array(0, $boards))
fatal_lang_error('smf232');*/
// Make sure they can see the board they are trying to move to (and get whether posts count in the target board).
$request = db_query("\n\t\tSELECT b.countPosts, b.name, m.subject\n\t\tFROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)\n\t\tWHERE {$user_info['query_see_board']}\n\t\t\tAND b.ID_BOARD = {$_POST['toboard']}\n\t\t\tAND t.ID_TOPIC = {$topic}\n\t\t\tAND m.ID_MSG = t.ID_FIRST_MSG\n\t\tLIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0) {
fatal_lang_error('smf232');
}
list($pcounter, $board_name, $subject) = mysql_fetch_row($request);
mysql_free_result($request);
// Remember this for later.
$_SESSION['move_to_topic'] = $_POST['toboard'];
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$_POST['custom_subject'] = $func['htmlspecialchars']($_POST['custom_subject']);
if (isset($_POST['enforce_subject'])) {
// Get a response prefix, but in the forum's default language.
if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) {
if ($language === $user_info['language']) {
$context['response_prefix'] = $txt['response_prefix'];
} else {
loadLanguage('index', $language, false);
$context['response_prefix'] = $txt['response_prefix'];
loadLanguage('index');
}
cache_put_data('response_prefix', $context['response_prefix'], 600);
}
db_query("\n\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\tSET subject = '{$context['response_prefix']}{$_POST['custom_subject']}'\n\t\t\t\tWHERE ID_TOPIC = {$topic}", __FILE__, __LINE__);
}
db_query("\n\t\t\tUPDATE {$db_prefix}messages\n\t\t\tSET subject = '{$_POST['custom_subject']}'\n\t\t\tWHERE ID_MSG = {$ID_FIRST_MSG}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
// Fix the subject cache.
updateStats('subject', $topic, $_POST['custom_subject']);
}
// Create a link to this in the old board.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$_POST['reason'] = $func['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
preparsecode($_POST['reason']);
// Add a URL onto the message.
$_POST['reason'] = strtr($_POST['reason'], array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $_POST['toboard'] . ']' . addslashes($board_name) . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
$msgOptions = array('subject' => addslashes($txt['smf56'] . ': ' . $subject), 'body' => $_POST['reason'], 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true);
$posterOptions = array('id' => $ID_MEMBER, 'update_post_count' => !empty($pcounter));
createPost($msgOptions, $topicOptions, $posterOptions);
}
$request = db_query("\n\t\tSELECT countPosts\n\t\tFROM {$db_prefix}boards\n\t\tWHERE ID_BOARD = {$board}\n\t\tLIMIT 1", __FILE__, __LINE__);
list($pcounter_from) = mysql_fetch_row($request);
mysql_free_result($request);
if ($pcounter_from != $pcounter) {
$request = db_query("\n\t\t\tSELECT ID_MEMBER\n\t\t\tFROM {$db_prefix}messages\n\t\t\tWHERE ID_TOPIC = {$topic}", __FILE__, __LINE__);
$posters = array();
while ($row = mysql_fetch_assoc($request)) {
$posters[] = $row['ID_MEMBER'];
}
mysql_free_result($request);
// The board we're moving from counted posts, but not to.
if (empty($pcounter_from)) {
updateMemberData($posters, array('posts' => '-'));
} else {
updateMemberData($posters, array('posts' => '+'));
}
}
// Do the move (includes statistics update needed for the redirect topic).
moveTopics($topic, $_POST['toboard']);
// Log that they moved this topic.
if (!allowedTo('move_own') || $ID_MEMBER_STARTED != $ID_MEMBER) {
logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
}
// Notify people that this topic has been moved?
sendNotifications($topic, 'move');
// Update the cache?
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] == 3) {
cache_put_data('topic_board-' . $topic, null, 120);
//.........这里部分代码省略.........
示例11: QuickModeration
//.........这里部分代码省略.........
$affectedBoards[$to] = array(0, 0);
}
if (!isset($affectedBoards[$row['ID_BOARD']])) {
$affectedBoards[$row['ID_BOARD']] = array(0, 0);
}
$affectedBoards[$row['ID_BOARD']][0]--;
$affectedBoards[$row['ID_BOARD']][1] -= $row['numReplies'];
$affectedBoards[$to][0]++;
$affectedBoards[$to][1] += $row['numReplies'];
// Move the actual topic.
db_query("\n\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\tSET ID_BOARD = {$to}\n\t\t\t\tWHERE ID_TOPIC = {$row['ID_TOPIC']}\n\t\t\t\tLIMIT 1", __FILE__, __LINE__);
db_query("\n\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\tSET ID_BOARD = {$to}\n\t\t\t\tWHERE ID_TOPIC = {$row['ID_TOPIC']}", __FILE__, __LINE__);
db_query("\n\t\t\t\tUPDATE {$db_prefix}calendar\n\t\t\t\tSET ID_BOARD = {$to}\n\t\t\t\tWHERE ID_TOPIC = {$row['ID_TOPIC']}", __FILE__, __LINE__);
$moveCache2[] = array($row['ID_TOPIC'], $row['ID_BOARD'], $to);
}
mysql_free_result($request);
$moveCache = $moveCache2;
foreach ($affectedBoards as $ID_BOARD => $topicsPosts) {
db_query("\n\t\t\t\tUPDATE {$db_prefix}boards\n\t\t\t\tSET numPosts = numPosts + {$topicsPosts['1']}, numTopics = numTopics + {$topicsPosts['0']}\n\t\t\t\tWHERE ID_BOARD = {$ID_BOARD}\n\t\t\t\tLIMIT 1", __FILE__, __LINE__);
}
}
// Now delete the topics...
if (!empty($removeCache)) {
// They can only delete their own topics. (we wouldn't be here if they couldn't do that..)
if (!empty($board) && !allowedTo('remove_any')) {
$result = db_query("\n\t\t\t\tSELECT ID_TOPIC\n\t\t\t\tFROM {$db_prefix}topics\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $removeCache) . ")\n\t\t\t\t\tAND ID_MEMBER_STARTED = {$ID_MEMBER}\n\t\t\t\tLIMIT " . count($removeCache), __FILE__, __LINE__);
$removeCache = array();
while ($row = mysql_fetch_assoc($result)) {
$removeCache[] = $row['ID_TOPIC'];
}
mysql_free_result($result);
}
// Maybe *none* were their own topics.
if (!empty($removeCache)) {
// Gotta send the notifications *first*!
foreach ($removeCache as $topic) {
logAction('remove', array('topic' => $topic));
sendNotifications($topic, 'remove');
}
require_once $sourcedir . '/RemoveTopic.php';
removeTopics($removeCache);
}
}
// And lastly, lock the topics...
if (!empty($lockCache)) {
$lockStatus = array();
// Gotta make sure they CAN lock/unlock these topics...
if (!empty($board) && !allowedTo('lock_any')) {
// Make sure they started the topic AND it isn't already locked by someone with higher priv's.
$result = db_query("\n\t\t\t\tSELECT ID_TOPIC, locked\n\t\t\t\tFROM {$db_prefix}topics\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $lockCache) . ")\n\t\t\t\t\tAND ID_MEMBER_STARTED = {$ID_MEMBER}\n\t\t\t\t\tAND locked IN (2, 0)\n\t\t\t\tLIMIT " . count($lockCache), __FILE__, __LINE__);
$lockCache = array();
while ($row = mysql_fetch_assoc($result)) {
$lockCache[] = $row['ID_TOPIC'];
$lockStatus[$row['ID_TOPIC']] = empty($row['locked']);
}
mysql_free_result($result);
} else {
$result = db_query("\n\t\t\t\tSELECT ID_TOPIC, locked\n\t\t\t\tFROM {$db_prefix}topics\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $lockCache) . ")\n\t\t\t\tLIMIT " . count($lockCache), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result)) {
$lockStatus[$row['ID_TOPIC']] = empty($row['locked']);
}
mysql_free_result($result);
}
// It could just be that *none* were their own topics...
if (!empty($lockCache)) {
// Alternate the locked value.
db_query("\n\t\t\t\tUPDATE {$db_prefix}topics\n\t\t\t\tSET locked = IF(locked = 0, " . (allowedTo('lock_any') ? '1' : '2') . ", 0)\n\t\t\t\tWHERE ID_TOPIC IN (" . implode(', ', $lockCache) . ")\n\t\t\t\tLIMIT " . count($lockCache), __FILE__, __LINE__);
}
}
if (!empty($markCache)) {
$setString = '';
foreach ($markCache as $topic) {
$setString .= "\n\t\t\t\t({$modSettings['maxMsgID']}, {$ID_MEMBER}, {$topic}),";
}
db_query("\n\t\t\tREPLACE INTO {$db_prefix}log_topics\n\t\t\t\t(ID_MSG, ID_MEMBER, ID_TOPIC)\n\t\t\tVALUES" . substr($setString, 0, -1), __FILE__, __LINE__);
}
foreach ($moveCache as $topic) {
// Didn't actually move anything!
if (!isset($topic[0])) {
break;
}
logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
sendNotifications($topic[0], 'move');
}
foreach ($lockCache as $topic) {
logAction('lock', array('topic' => $topic));
sendNotifications($topic, $lockStatus ? 'lock' : 'unlock');
}
foreach ($stickyCache as $topic) {
logAction('sticky', array('topic' => $topic));
sendNotifications($topic, 'sticky');
}
updateStats('topic');
updateStats('message');
updateStats('calendar');
if (!empty($affectedBoards)) {
updateLastMessages(array_keys($affectedBoards));
}
redirectexit($redirect_url);
}
示例12: pbe_create_topic
/**
* Create a new topic by email
*
* What it does:
* - Called by pbe_topic to create a new topic or by pbe_main to create a new topic via a subject change
* - checks posting permissions, but requires all email validation checks are complete
* - Calls pbe_load_text to prepare text for the post
* - Uses createPost to do the actual "posting"
* - Calls sendNotifications to announce the new post
* - Calls query_update_member_stats to show they did something
* - Requires the pbe, email_message and board_info arrays to be populated.
*
* @package Maillist
* @param mixed[] $pbe array of pbe 'user_info' values
* @param Email_Parse $email_message
* @param mixed[] $board_info
*/
function pbe_create_topic($pbe, $email_message, $board_info)
{
global $txt, $modSettings;
// It does not work like that
if (empty($pbe) || empty($email_message)) {
return false;
}
// We have the board info, and their permissions - do they have a right to start a new topic?
$becomesApproved = true;
if (!$pbe['user_info']['is_admin']) {
if (!in_array('postby_email', $pbe['user_info']['permissions'])) {
return pbe_emailError('error_permission', $email_message);
} elseif ($modSettings['postmod_active'] && in_array('post_unapproved_topics', $pbe['user_info']['permissions']) && !in_array('post_new', $pbe['user_info']['permissions'])) {
$becomesApproved = false;
} elseif (!in_array('post_new', $pbe['user_info']['permissions'])) {
return pbe_emailError('error_cant_start', $email_message);
}
}
// Approving all new topics by email anyway, smart admin this one is ;)
if (!empty($modSettings['maillist_newtopic_needsapproval'])) {
$becomesApproved = false;
}
// First on the agenda the subject
$subject = pbe_clean_email_subject($email_message->subject);
$subject = strtr(Util::htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));
// Not to long not to short
if (Util::strlen($subject) > 100) {
$subject = Util::substr($subject, 0, 100);
} elseif ($subject == '') {
return pbe_emailError('error_no_subject', $email_message);
}
// The message itself will need a bit of work
$html = $email_message->html_found;
$text = pbe_load_text($html, $email_message, $pbe);
if (empty($text)) {
return pbe_emailError('error_no_message', $email_message);
}
// Build the attachment array if needed
if (!empty($email_message->attachments) && !empty($modSettings['maillist_allow_attachments']) && !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1) {
if ($modSettings['postmod_active'] && in_array('post_unapproved_attachments', $pbe['user_info']['permissions']) || in_array('post_attachment', $pbe['user_info']['permissions'])) {
$attachIDs = pbe_email_attachments($pbe, $email_message);
} else {
$text .= "\n\n" . $txt['error_no_attach'] . "\n";
}
}
// If we get to this point ... then its time to play, lets start a topic !
require_once SUBSDIR . '/Post.subs.php';
// Setup the topic variables.
$msgOptions = array('id' => 0, 'subject' => $subject, 'smileys_enabled' => true, 'body' => $text, 'attachments' => empty($attachIDs) ? array() : $attachIDs, 'approved' => $becomesApproved);
$topicOptions = array('id' => 0, 'board' => $board_info['id_board'], 'mark_as_read' => false);
$posterOptions = array('id' => $pbe['profile']['id_member'], 'name' => $pbe['profile']['real_name'], 'email' => $pbe['profile']['email_address'], 'update_post_count' => empty($board_info['count_posts']), 'ip' => isset($email_message->ip) ? $email_message->ip : $pbe['profile']['member_ip']);
// Attempt to make the new topic.
createPost($msgOptions, $topicOptions, $posterOptions);
// The auto_notify setting
$theme_settings = query_get_theme($pbe['profile']['id_member'], $pbe['profile']['id_theme'], $board_info);
$auto_notify = isset($theme_settings['auto_notify']) ? $theme_settings['auto_notify'] : 0;
// Notifications on or off
query_notifications($pbe['profile']['id_member'], $board_info['id_board'], $topicOptions['id'], $auto_notify, $pbe['user_info']['permissions']);
// Notify members who have notification turned on for this, (if it's approved)
if ($becomesApproved) {
require_once SUBSDIR . '/Notification.subs.php';
sendNotifications($topicOptions['id'], 'reply', array(), array(), $pbe);
}
// Update this users info so the log shows them as active
query_update_member_stats($pbe, $email_message, $topicOptions);
return true;
}
示例13: action_post2
//.........这里部分代码省略.........
// If we had a draft for this, its time to remove it since it was just posted
if (!empty($modSettings['drafts_enabled']) && !empty($_POST['id_draft'])) {
deleteDrafts($_POST['id_draft'], $user_info['id']);
}
// Editing or posting an event?
if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) {
require_once SUBSDIR . '/Calendar.subs.php';
// Make sure they can link an event to this post.
canLinkEvent();
// Insert the event.
$eventOptions = array('id_board' => $board, 'id_topic' => $topic, 'title' => $_POST['evtitle'], 'member' => $user_info['id'], 'start_date' => sprintf('%04d-%02d-%02d', $_POST['year'], $_POST['month'], $_POST['day']), 'span' => isset($_POST['span']) && $_POST['span'] > 0 ? min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1) : 0);
insertEvent($eventOptions);
} elseif (isset($_POST['calendar'])) {
$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
// Validate the post...
require_once SUBSDIR . '/Calendar.subs.php';
validateEventPost();
// If you're not allowed to edit any events, you have to be the poster.
if (!allowedTo('calendar_edit_any')) {
$event_poster = getEventPoster($_REQUEST['eventid']);
// Silly hacker, Trix are for kids. ...probably trademarked somewhere, this is FAIR USE! (parody...)
isAllowedTo('calendar_edit_' . ($event_poster == $user_info['id'] ? 'own' : 'any'));
}
// Delete it?
if (isset($_REQUEST['deleteevent'])) {
removeEvent($_REQUEST['eventid']);
} else {
$span = !empty($modSettings['cal_allowspan']) && !empty($_REQUEST['span']) ? min((int) $modSettings['cal_maxspan'], (int) $_REQUEST['span'] - 1) : 0;
$start_time = mktime(0, 0, 0, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year']);
$eventOptions = array('start_date' => strftime('%Y-%m-%d', $start_time), 'end_date' => strftime('%Y-%m-%d', $start_time + $span * 86400), 'title' => $_REQUEST['evtitle']);
modifyEvent($_REQUEST['eventid'], $eventOptions);
}
}
// Marking boards as read.
// (You just posted and they will be unread.)
if (!$user_info['is_guest']) {
$board_list = !empty($board_info['parent_boards']) ? array_keys($board_info['parent_boards']) : array();
// Returning to the topic?
if (!empty($_REQUEST['goback'])) {
$board_list[] = $board;
}
if (!empty($board_list)) {
markBoardsRead($board_list, false, false);
}
}
// Turn notification on or off.
if (!empty($_POST['notify']) && allowedTo('mark_any_notify')) {
setTopicNotification($user_info['id'], $topic, true);
} elseif (!$newTopic) {
setTopicNotification($user_info['id'], $topic, false);
}
// Log an act of moderation - modifying.
if (!empty($moderationAction)) {
logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $msgInfo['id_member'], 'board' => $board));
}
if (isset($_POST['lock']) && $_POST['lock'] != 2) {
logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
}
if (isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics'])) {
logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
}
// Notify any members who have notification turned on for this topic/board - only do this if it's going to be approved(!)
if ($becomesApproved) {
require_once SUBSDIR . '/Notification.subs.php';
if ($newTopic) {
$notifyData = array('body' => $_POST['message'], 'subject' => $_POST['subject'], 'name' => $user_info['name'], 'poster' => $user_info['id'], 'msg' => $msgOptions['id'], 'board' => $board, 'topic' => $topic, 'signature' => isset($user_settings['signature']) ? $user_settings['signature'] : '');
sendBoardNotifications($notifyData);
} elseif (empty($_REQUEST['msg'])) {
// Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it.
if ($topic_info['approved']) {
sendNotifications($topic, 'reply');
} else {
sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']);
}
}
}
if (!empty($modSettings['mentions_enabled']) && !empty($actually_mentioned)) {
require_once CONTROLLERDIR . '/Mentions.controller.php';
$mentions = new Mentions_Controller();
$mentions->setData(array('id_member' => $actually_mentioned, 'type' => 'men', 'id_msg' => $msgOptions['id'], 'status' => $becomesApproved ? 'new' : 'unapproved'));
$mentions->action_add();
}
if ($board_info['num_topics'] == 0) {
cache_put_data('board-' . $board, null, 120);
}
if (!empty($_POST['announce_topic'])) {
redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
}
if (!empty($_POST['move']) && allowedTo('move_any')) {
redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
}
// Return to post if the mod is on.
if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) {
redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
} elseif (!empty($_REQUEST['goback'])) {
redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
} else {
redirectexit('board=' . $board . '.0');
}
}
示例14: array_diff
$notUpdatedForms = array_diff($formulize_allWrittenFids, $formsUpdatedInFramework);
foreach ($notUpdatedForms as $thisFid) {
$formObject = $form_handler->get($thisFid, true);
// true causes all elements to be gathered, including ones that are not displayed to the users
if (array_search("derived", $formObject->getVar('elementTypes'))) {
foreach ($formulize_allWrittenEntryIds[$thisFid] as $thisEntry) {
formulize_updateDerivedValues($thisEntry, $thisFid);
}
}
}
}
// send notifications
foreach ($notEntriesList as $notEvent => $notDetails) {
foreach ($notDetails as $notFid => $notEntries) {
$notEntries = array_unique($notEntries);
sendNotifications($notFid, $notEvent, $notEntries);
}
}
$formulize_readElementsWasRun = true;
// flag that will prevent this from running again
// set the variables that need to be in global space, just in case this file was included from inside a function, which can happen in some cases
$GLOBALS['formulize_newEntryIds'] = $formulize_newEntryIds;
$GLOBALS['formulize_newEntryUsers'] = $formulize_newEntryUsers;
$GLOBALS['formulize_allWrittenEntryIds'] = $formulize_allWrittenEntryIds;
$GLOBALS['formulize_newSubformBlankElementIds'] = $formulize_newSubformBlankElementIds;
$GLOBALS['formulize_readElementsWasRun'] = $formulize_readElementsWasRun;
return $formulize_allWrittenEntryIds;
// this function handles triggering the after Saving Logic of custom elements after each entry is written to the database
// values are the element handle->data value pairs that were written to the database
// entry_id is the entry id that was just written to the database
function afterSavingLogic($values, $entry_id)
示例15: splitTopic
//.........这里部分代码省略.........
LIMIT 2', array('msg_list' => $splitMessages, 'id_topic' => $split1_ID_TOPIC));
while ($row = $db->fetch_assoc($request)) {
// As before get the right first and last message dependant on approved state...
if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) {
$split2_first_msg = $row['myid_first_msg'];
}
if (empty($split2_last_msg) || $row['approved']) {
$split2_last_msg = $row['myid_last_msg'];
}
// Then do the counts again...
if ($row['approved']) {
$split2_approved = true;
$split2_replies = $row['message_count'] - 1;
$split2_unapprovedposts = 0;
} else {
// Should this one be approved??
if ($split2_first_msg == $row['myid_first_msg']) {
$split2_approved = false;
}
if (!isset($split2_replies)) {
$split2_replies = 0;
} elseif (!$split2_approved) {
$split2_replies++;
}
$split2_unapprovedposts = $row['message_count'];
}
}
$db->free_result($request);
$split2_firstMem = getMsgMemberID($split2_first_msg);
$split2_lastMem = getMsgMemberID($split2_last_msg);
// No database changes yet, so let's double check to see if everything makes at least a little sense.
if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) {
fatal_lang_error('cant_find_messages');
}
// You cannot split off the first message of a topic.
if ($split1_first_msg > $split2_first_msg) {
fatal_lang_error('split_first_post', false);
}
// We're off to insert the new topic! Use 0 for now to avoid UNIQUE errors.
$db->insert('', '{db_prefix}topics', array('id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', 'id_last_msg' => 'int', 'num_replies' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int', 'is_sticky' => 'int'), array((int) $id_board, $split2_firstMem, $split2_lastMem, 0, 0, $split2_replies, $split2_unapprovedposts, (int) $split2_approved, 0), array('id_topic'));
$split2_ID_TOPIC = $db->insert_id('{db_prefix}topics', 'id_topic');
if ($split2_ID_TOPIC <= 0) {
fatal_lang_error('cant_insert_topic');
}
// Move the messages over to the other topic.
$new_subject = strtr(Util::htmltrim(Util::htmlspecialchars($new_subject)), array("\r" => '', "\n" => '', "\t" => ''));
// Check the subject length.
if (Util::strlen($new_subject) > 100) {
$new_subject = Util::substr($new_subject, 0, 100);
}
// Valid subject?
if ($new_subject != '') {
$db->query('', '
UPDATE {db_prefix}messages
SET
id_topic = {int:id_topic},
subject = CASE WHEN id_msg = {int:split_first_msg} THEN {string:new_subject} ELSE {string:new_subject_replies} END
WHERE id_msg IN ({array_int:split_msgs})', array('split_msgs' => $splitMessages, 'id_topic' => $split2_ID_TOPIC, 'new_subject' => $new_subject, 'split_first_msg' => $split2_first_msg, 'new_subject_replies' => $txt['response_prefix'] . $new_subject));
// Cache the new topics subject... we can do it now as all the subjects are the same!
updateStats('subject', $split2_ID_TOPIC, $new_subject);
}
// Any associated reported posts better follow...
require_once SUBSDIR . '/Topic.subs.php';
updateSplitTopics(array('splitMessages' => $splitMessages, 'split2_ID_TOPIC' => $split2_ID_TOPIC, 'split1_replies' => $split1_replies, 'split1_first_msg' => $split1_first_msg, 'split1_last_msg' => $split1_last_msg, 'split1_firstMem' => $split1_firstMem, 'split1_lastMem' => $split1_lastMem, 'split1_unapprovedposts' => $split1_unapprovedposts, 'split1_ID_TOPIC' => $split1_ID_TOPIC, 'split2_first_msg' => $split2_first_msg, 'split2_last_msg' => $split2_last_msg, 'split2_ID_TOPIC' => $split2_ID_TOPIC, 'split2_approved' => $split2_approved), $id_board);
require_once SUBSDIR . '/FollowUps.subs.php';
// Let's see if we can create a stronger bridge between the two topics
// @todo not sure what message from the oldest topic I should link to the new one, so I'll go with the first
linkMessages($split1_first_msg, $split2_ID_TOPIC);
// Copy log topic entries.
// @todo This should really be chunked.
$request = $db->query('', '
SELECT id_member, id_msg, unwatched
FROM {db_prefix}log_topics
WHERE id_topic = {int:id_topic}', array('id_topic' => (int) $split1_ID_TOPIC));
if ($db->num_rows($request) > 0) {
$replaceEntries = array();
while ($row = $db->fetch_assoc($request)) {
$replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']);
}
require_once SUBSDIR . '/Topic.subs.php';
markTopicsRead($replaceEntries, false);
unset($replaceEntries);
}
$db->free_result($request);
// Housekeeping.
updateTopicStats();
updateLastMessages($id_board);
logAction('split', array('topic' => $split1_ID_TOPIC, 'new_topic' => $split2_ID_TOPIC, 'board' => $id_board));
// Notify people that this topic has been split?
require_once SUBSDIR . '/Notification.subs.php';
sendNotifications($split1_ID_TOPIC, 'split');
// If there's a search index that needs updating, update it...
require_once SUBSDIR . '/Search.subs.php';
$searchAPI = findSearchAPI();
if (is_callable(array($searchAPI, 'topicSplit'))) {
$searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages);
}
// Return the ID of the newly created topic.
return $split2_ID_TOPIC;
}