/** * Build a link to an alert's content so that the system can redirect to * it. * * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the * link for. * * @return string The built alert, preferably an absolute link. */ public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { $alertContent = $alert->getExtraDetails(); $threadLink = $this->mybb->settings['bburl'] . '/' . get_thread_link((int) $alertContent['tid'], 0, 'newpost'); return $threadLink; }
} // And now the magic begins. $plugins->run_hooks("wiki_edit_commit"); $message = $db->escape_string($mybb->input['message']); $id = (int) $mybb->input['id']; $notes = $db->escape_string($mybb->input['notes']); $notes = str_replace("~~~~", "[signoff:{$mybb->user['uid']}]", $notes); $sql = $db->write_query(sprintf("UPDATE `%swiki`", TABLE_PREFIX) . "SET `content`='{$message}', `authors`='{$authors}', `lastauthor`='{$mybb->user['username']}', `lastauthorid`='{$mybb->user['uid']}', `notepad`='{$notes}'\n\t\t\t\tWHERE `id`='{$id}'"); $sql = $db->write_query(sprintf("INSERT INTO %swiki_edits(`aid`,`author`,`revision`) VALUES('{$id}','{$mybb->user['uid']}','{$message}')", TABLE_PREFIX)); if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) { $user_array = explode(',', $wiki['watching']); $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('mybb_wiki_alert_code'); if ($alertType != null && $alertType->getEnabled()) { $alerts = array(); foreach ($user_array as $user) { $alert = new MybbStuff_MyAlerts_Entity_Alert($user, $alertType, $id); $alert->setExtraDetails(array('title' => $wiki['title'])); $alerts[] = $alert; } MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts); } } if (!$sql) { error($lang->notupdated); } else { // All done. :-) $id = (int) $mybb->input['id']; redirect("wiki.php?action=view&id={$id}", $lang->wiki_edited); } } } elseif ($mybb->input['action'] == 'new') {
/** * Get a single alert by ID. * * @param int $id The ID of the alert to fetch. * * @return MybbSTuff_MyAlerts_Entity_Alert */ public function getAlert($id = 0) { $id = (int) $id; $alert = null; $this->mybb->user['uid'] = (int) $this->mybb->user['uid']; $prefix = TABLE_PREFIX; $alertsQuery = <<<SQL SELECT a.*, u.uid, u.username, u.avatar, u.usergroup, u.displaygroup, t.code FROM {$prefix}alerts a LEFT JOIN {$prefix}users u ON (a.from_user_id = u.uid) INNER JOIN {$prefix}alert_types t ON (a.alert_type_id = t.id) WHERE a.uid = {$this->mybb->user['uid']} AND a.id = {$id}; SQL; $query = $this->db->write_query($alertsQuery); if ($this->db->num_rows($query) > 0) { while ($alertRow = $this->db->fetch_array($query)) { $alertType = $this->alertTypeManager->getByCode($alertRow['code']); if ($alertType != null) { $alert = new MybbStuff_MyAlerts_Entity_Alert($alertRow['uid'], $alertType, $alertRow['object_id']); $alert->setId($alertRow['id']); $alert->setCreatedAt(new DateTime($alertRow['dateline'])); $alert->setUnread((bool) $alertRow['unread']); $alert->setExtraDetails(json_decode($alertRow['extra_details'], true)); $user = array('uid' => (int) $alertRow['uid'], 'username' => $alertRow['username'], 'avatar' => $alertRow['avatar'], 'usergroup' => $alertRow['usergroup'], 'displaygroup' => $alertRow['displaygroup']); $alert->setFromUser($user); } } } return $alert; }
public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { global $eas; $alertContent = $alert->getExtraDetails(); $pmLink = $this->mybb->settings['bburl'] . '/alerts.php'; return $pmLink; }
public function alert_comment($user, $commentor, $cid) { global $mybb, $db, $settings, $cache, $plugins; /* if the admin choosed alertbar, or "MyAlerts or Alert bar" but MyAlerts don't exist, notify the user */ if ($settings["mpcommentsnotification"] == "alertbar" || $settings["mpcommentsnotification"] == "myalertsoralertbar" && !MyProfileUtils::myalerts_exists()) { $update_array = array("mpnewcomments" => $user["mpnewcomments"] + 1); $db->update_query("users", $update_array, "uid='{$user['uid']}'", "1"); $user["mpnewcomments"]++; } elseif (($settings["mpcommentsnotification"] == "myalerts" || $settings["mpcommentsnotification"] == "myalertsoralertbar") && MyProfileUtils::myalerts_exists()) { $myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types'); if (isset($myalerts_plugins[MyProfileCommentsMyAlertsFormatter::alert_type_code()]) && $myalerts_plugins[MyProfileCommentsMyAlertsFormatter::alert_type_code()]['enabled'] == 1) { $alertType = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache)->getByCode(MyProfileCommentsMyAlertsFormatter::alert_type_code()); $alert = MybbStuff_MyAlerts_Entity_Alert::make($user["uid"], $alertType, null, array("cid" => $cid)); MybbStuff_MyAlerts_AlertManager::createInstance($mybb, $db, $cache, $plugins, $alertType)->addAlert($alert); } } }
function myalertsrow_subscribed(&$dataHandler) { global $db, $post; $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('subscribed_thread'); if ($alertType != null && $alertType->getEnabled()) { $thread = get_thread($post['tid']); $alerts = array(); $post['tid'] = (int) $post['tid']; $post['uid'] = (int) $post['uid']; $thread['lastpost'] = (int) $thread['lastpost']; $query = $db->query("SELECT s.uid FROM " . TABLE_PREFIX . "threadsubscriptions s\n LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=s.uid)\n WHERE (s.notification = 0 OR s.notification = 1) AND s.tid='{$post['tid']}'\n AND s.uid != '{$post['uid']}'\n AND u.lastactive>'{$thread['lastpost']}'"); while ($poster = $db->fetch_array($query)) { $forumPerms = forum_permissions($thread['fid'], $poster['uid']); if ($forumPerms['canview'] != 0 || $forumPerms['canviewthreads'] != 0) { $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $poster['uid'], $alertType, $thread['tid']); $alert->setExtraDetails(array('thread_title' => $thread['subject'], 'tid' => (int) $thread['tid'])); $alerts[] = $alert; } } if (!empty($alerts)) { MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts); } } }
/** * Build a link to an alert's content so that the system can redirect to it. * * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the link for. * * @return string The built alert, preferably an absolute link. */ public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { return get_profile_link($alert->getFromUserId()); }
/** * Build a link to an alert's content so that the system can redirect to * it. * * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the * link for. * * @return string The built alert, preferably an absolute link. */ public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { $pmId = $alert->getObjectId(); return "{$this->mybb->settings['bburl']}/private.php?action=read&pmid={$pmId}"; }
/** * Build a link to an alert's content so that the system can redirect to * it. * * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the * link for. * * @return string The built alert, preferably an absolute link. */ public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { $alertContent = $alert->getExtraDetails(); $postLink = $this->mybb->settings['bburl'] . '/' . get_post_link((int) $alertContent['pid'], (int) $alertContent['tid']) . '#pid' . (int) $alertContent['pid']; return $postLink; }
/** * Build a link to an alert's content so that the system can redirect to it. * * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the link for. * * @return string The built alert, preferably an absolute link. */ public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { return "wiki.php?action=view&id=" . $alert->getObjectId(); }
/** * Changes the author of the post. * * */ function accountswitcher_author_change() { global $mybb, $db, $eas; // Change action if ($mybb->input['action'] == "do_author" && $mybb->request_method == "post" && ($mybb->settings['aj_changeauthor'] == 1 || $mybb->settings['aj_admin_changeauthor'] == 1)) { // Verify incoming POST request verify_post_check($mybb->get_input('my_post_key')); // Get the current author of the post $pid = $mybb->get_input('pid', MyBB::INPUT_INT); $post = get_post($pid); $tid = (int) $post['tid']; $forum = get_forum($post['fid']); // Get the new user if (is_numeric($mybb->input['authorswitch'])) { // Input is uid from change author $newuid = $mybb->get_input('authorswitch', MyBB::INPUT_INT); $newauthor = get_user($newuid); } else { // Input is username from author moderation $newname = htmlspecialchars_uni($mybb->get_input('authorswitch')); $newauthor = get_user_by_username($newname); $newauthor = get_user((int) $newauthor['uid']); } // New user doesn't exist? Redirect back to the post without changes if ($newauthor['uid'] == 0) { redirect(htmlentities($_POST['p_link'])); return; } // Subtract from the users post count // Update the post count if this forum allows post counts to be tracked if ($forum['usepostcounts'] != 0) { $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum-1 WHERE uid='" . (int) $post['uid'] . "'"); $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum+1 WHERE uid='" . (int) $newauthor['uid'] . "'"); } $updated_record = array("uid" => (int) $newauthor['uid'], "username" => $db->escape_string($newauthor['username'])); if ($db->update_query("posts", $updated_record, "pid='" . (int) $post['pid'] . "'")) { global $lang; if (!isset($lang->aj_author_change_log)) { $lang->load("accountswitcher"); } // Update first/last post info, log moderator action, redirect back to the post update_thread_data($tid); update_forum_lastpost((int) $post['fid']); $lang->aj_author_change_log = $lang->sprintf($lang->aj_author_change_log, (int) $post['pid'], htmlspecialchars_uni($post['username']), htmlspecialchars_uni($newauthor['username'])); log_moderator_action(array("pid" => $post['pid']), $lang->aj_author_change_log); // Send pm to old and new author after moderation if ($post['uid'] != $mybb->user['uid'] && $mybb->settings['aj_admin_changeauthor'] == 1) { if ($mybb->settings['aj_authorpm'] == 1) { // Send PM require_once MYBB_ROOT . "inc/datahandlers/pm.php"; $pmhandler = new PMDataHandler(); $lang->aj_author_change_pm_body = $lang->sprintf($lang->aj_author_change_pm_body, htmlspecialchars_uni($mybb->user['username']), $mybb->settings['bburl'] . '/' . htmlentities($_POST['p_link']), htmlspecialchars_uni($post['subject']), htmlspecialchars_uni($post['username']), htmlspecialchars_uni($newauthor['username'])); $subject = $lang->aj_author_change_pm_subject; $body = $lang->aj_author_change_pm_body; $pm = array('subject' => $subject, 'message' => $body, 'icon' => '', 'toid' => array($post['uid'], $newauthor['uid']), 'fromid' => $mybb->user['uid'], "do" => '', "pmid" => ''); $pm['options'] = array('signature' => '0', 'savecopy' => '0', 'disablesmilies' => '0', 'readreceipt' => '0'); $pmhandler->set_data($pm); $valid_pm = $pmhandler->validate_pm(); if ($valid_pm) { $pmhandler->insert_pm(); } } // Show alert if ($mybb->settings['aj_myalerts'] == 1 && isset($mybb->user['myalerts_disabled_alert_types'])) { $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('accountswitcher_author'); $alerts = array(); $subject = htmlspecialchars_uni($post['subject']); $alert_old = new MybbStuff_MyAlerts_Entity_Alert((int) $post['uid'], $alertType, $tid); $alert_old->setExtraDetails(array('thread_title' => $subject, 'pid' => $pid, 'tid' => $tid, 'olduser' => htmlspecialchars_uni($post['username']), 'newuser' => htmlspecialchars_uni($newauthor['username']))); $alerts[] = $alert_old; $alert_new = new MybbStuff_MyAlerts_Entity_Alert((int) $newauthor['uid'], $alertType, $tid); $alert_new->setExtraDetails(array('thread_title' => $subject, 'pid' => $pid, 'tid' => $tid, 'olduser' => htmlspecialchars_uni($post['username']), 'newuser' => htmlspecialchars_uni($newauthor['username']))); $alerts[] = $alert_new; if (!empty($alerts)) { MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts); } } } $eas->update_accountswitcher_cache(); redirect(htmlentities($_POST['p_link'])); } } else { return; } }
public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) { $alertContent = $alert->getExtraDetails(); $feedbackLink = $this->mybb->settings['bburl'] . '/tradefeedback.php?action=view&uid=' . $mybb->user['uid'] . '&fid=' . $alertContent['fid']; return $feedbackLink; }