Example #1
0
    /**
     * 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;
    }
Example #2
0
function wiki_uninstall()
{
    global $db, $cache;
    // Template Deletion
    $db->delete_query("templategroups", "title = 'Wiki'");
    // Table deletion
    $db->drop_table('wiki');
    $db->drop_table('wiki_edits');
    $db->drop_table('wiki_categories');
    $db->drop_table('wiki_perms');
    $db->drop_table('wiki_settings');
    $db->drop_table('wiki_templates');
    // Clear caches
    $db->delete_query("datacache", 'title="wiki_articles"');
    $db->delete_query("datacache", 'title="wiki_permissions"');
    require_once MYBB_ADMIN_DIR . "inc/functions_themes.php";
    // Stylesheet Deletion
    $query = $db->simple_select("themes", "tid");
    while ($tid = $db->fetch_field($query, "tid")) {
        $css_file = MYBB_ROOT . "cache/themes/theme{$tid}/wiki.css";
        if (file_exists($css_file)) {
            unlink($css_file);
        }
    }
    update_theme_stylesheet_list("1");
    if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) {
        $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
        if (!$alertTypeManager) {
            $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
        }
        $alertTypeManager->deleteByCode('mybb_wiki_alert_code');
    }
}
Example #3
0
function myalerts_acp_manage_alert_types()
{
    global $mybb, $lang, $page, $db, $cache;
    $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
    $alertTypes = $alertTypeManager->getAlertTypes();
    if (strtolower($mybb->request_method) == 'post') {
        if (!verify_post_check($mybb->get_input('my_post_key'))) {
            flash_message($lang->invalid_post_verify_key2, 'error');
            admin_redirect("index.php?module=config-myalerts_alert_types");
        }
        $enabledAlertTypes = $mybb->get_input('alert_types_enabled', MyBB::INPUT_ARRAY);
        $canBeUserDisabled = $mybb->get_input('alert_types_can_be_user_disabled', MyBB::INPUT_ARRAY);
        $enabledAlertTypes = array_map('intval', array_keys($enabledAlertTypes));
        $canBeUserDisabled = array_map('intval', array_keys($canBeUserDisabled));
        $updateArray = array();
        foreach ($alertTypes as $alertType) {
            $type = MybbStuff_MyAlerts_Entity_AlertType::unserialize($alertType);
            $type->setEnabled(in_array($type->getId(), $enabledAlertTypes));
            $type->setCanBeUserDisabled(in_array($type->getId(), $canBeUserDisabled));
            $updateArray[] = $type;
        }
        $alertTypeManager->updateAlertTypes($updateArray);
        flash_message($lang->myalerts_alert_types_updated, 'success');
        admin_redirect("index.php?module=config-myalerts_alert_types");
    } else {
        $page->output_header($lang->myalerts_alert_types);
        $form = new Form('index.php?module=config-myalerts_alert_types', 'post');
        $table = new Table();
        $table->construct_header($lang->myalerts_alert_type_code);
        $table->construct_header($lang->myalerts_alert_type_enabled, array('width' => '5%', 'class' => 'align_center'));
        $table->construct_header($lang->myalerts_alert_type_can_be_user_disabled, array('width' => '10%', 'class' => 'align_center'));
        $noResults = false;
        if (!empty($alertTypes)) {
            foreach ($alertTypes as $type) {
                $alertCode = htmlspecialchars_uni($type['code']);
                $table->construct_cell($alertCode);
                $table->construct_cell($form->generate_check_box('alert_types_enabled[' . $type['id'] . ']', '', '', array('checked' => $type['enabled'])));
                $table->construct_cell($form->generate_check_box('alert_types_can_be_user_disabled[' . $type['id'] . ']', '', '', array('checked' => $type['can_be_user_disabled'])));
                $table->construct_row();
            }
        } else {
            $table->construct_cell($lang->myalerts_no_alert_types, array('colspan' => 2));
            $table->construct_row();
            $noResults = true;
        }
        $table->output($lang->myalerts_alert_types);
        if (!$noResults) {
            $buttons[] = $form->generate_submit_button($lang->myalerts_update_alert_types);
            $form->output_submit_wrapper($buttons);
        }
        $form->end();
        $page->output_footer();
    }
}
Example #4
0
 private function handleMyAlerts()
 {
     global $db, $cache;
     if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) {
         $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
         if (!$alertTypeManager) {
             $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
         }
         $alertType = new MybbStuff_MyAlerts_Entity_AlertType();
         $alertType->setCode('mybb_wiki_alert_code');
         // The codename for your alert type. Can be any unique string.
         $alertType->setEnabled(true);
         $alertType->setCanBeUserDisabled(true);
         $alertTypeManager->add($alertType);
     }
 }
Example #5
0
/**
 * Show a user their settings for MyAlerts.
 *
 * @param MyBB               $mybb      MyBB core object.
 * @param DB_MySQLi|DB_MySQL $db        Database object.
 * @param MyLanguage         $lang      Language object.
 * @param pluginSystem       $plugins   MyBB plugin system.
 * @param templates          $templates Template manager.
 * @param array              $theme     Details about the current theme.
 */
function myalerts_alert_settings($mybb, $db, $lang, $plugins, $templates, $theme)
{
    $alertTypes = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getAlertTypes();
    if (strtolower($mybb->request_method) == 'post') {
        // Saving alert type settings
        $disabledAlerts = array();
        foreach ($alertTypes as $alertCode => $alertType) {
            if (!isset($_POST[$alertCode]) && $alertType['can_be_user_disabled']) {
                $disabledAlerts[] = (int) $alertType['id'];
            }
        }
        if ($disabledAlerts != $mybb->user['myalerts_disabled_alert_types']) {
            // Different settings, so update
            $jsonEncodedDisabledAlerts = json_encode($disabledAlerts);
            $db->update_query('users', array('myalerts_disabled_alert_types' => $db->escape_string($jsonEncodedDisabledAlerts)), 'uid=' . (int) $mybb->user['uid']);
        }
        redirect('alerts.php?action=settings', $lang->myalerts_settings_updated, $lang->myalerts_settings_updated_title);
    } else {
        // Displaying alert type settings form
        $content = '';
        global $headerinclude, $header, $footer, $usercpnav;
        add_breadcrumb($lang->myalerts_settings_page_title, 'alerts.php?action=settings');
        require_once __DIR__ . '/inc/functions_user.php';
        usercp_menu();
        foreach ($alertTypes as $key => $value) {
            if ($value['enabled'] && $value['can_be_user_disabled']) {
                $altbg = alt_trow();
                $tempKey = 'myalerts_setting_' . $key;
                $plugins->run_hooks('myalerts_load_lang');
                $langline = $lang->{$tempKey};
                $checked = '';
                if (!in_array($value['id'], $mybb->user['myalerts_disabled_alert_types'])) {
                    $checked = ' checked="checked"';
                }
                eval("\$alertSettings .= \"" . $templates->get('myalerts_setting_row') . "\";");
            }
        }
        eval("\$content = \"" . $templates->get('myalerts_settings_page') . "\";");
        output_page($content);
    }
}
Example #6
0
 }
 if (!$contributed) {
     // Concatenate the author onto our string.
     $authors .= ",{$mybb->user['uid']}";
 }
 // 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'];
function ffplugin_deactivate()
{
    //MyAlerts stuff
    if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) {
        $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
        if (!$alertTypeManager) {
            $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
        }
        $alertTypeManager->deleteByCode('ffplugin_myalerts');
    }
}
 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);
         }
     }
 }
Example #9
0
/**
 * Alert all attached accounts if one of them receives a new pm.
 *
 */
function accountswitcher_pm_sent_alert()
{
    global $mybb, $lang, $pm, $eas;
    if ($mybb->settings['aj_myalerts'] != 1 || !isset($mybb->settings['myalerts_perpage']) || $pm['saveasdraft'] == 1) {
        return;
    }
    if (!isset($lang->aj_newpm_switch_notice_one)) {
        $lang->load('accountswitcher');
    }
    // Get recipients
    if (is_array($pm['bcc'])) {
        $rec_users = array_merge($pm['to'], $pm['bcc']);
    } else {
        $rec_users = $pm['to'];
    }
    $pm_users = array_map("trim", $rec_users);
    // Alert Type
    $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('accountswitcher_pm');
    $alerts = array();
    foreach ($pm_users as $recipient) {
        $count = 0;
        $pmuser = get_user_by_username($recipient);
        $user = get_user($pmuser['uid']);
        $accounts = $eas->accountswitcher_cache;
        if (is_array($accounts)) {
            // If recipient is master account send alerts to attached users
            foreach ($accounts as $key => $account) {
                if ($user['uid'] == $account['as_uid']) {
                    ++$count;
                    if ($count > 0) {
                        $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, 0);
                        $alert->setExtraDetails(array('uid' => (int) $user['uid'], 'message' => htmlspecialchars_uni($user['username'])));
                        $alerts[] = $alert;
                    }
                }
            }
        }
        // If there are no users attached to the current account but the current account is attached to another user
        if ($count == 0 && $user['as_uid'] != 0) {
            $master = get_user((int) $user['as_uid']);
            // Get the masters permission
            $permission = user_permissions($master['uid']);
            // If the master has permission to use the Enhanced Account Switcher, get the userlist
            if ($permission['as_canswitch'] == 1) {
                // If recipient is attached account, alert master account
                if ($master['uid'] == $user['as_uid']) {
                    $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $master['uid'], $alertType, 0);
                    $alert->setExtraDetails(array('uid' => (int) $user['uid'], 'message' => htmlspecialchars_uni($user['username'])));
                    $alerts[] = $alert;
                }
                if (is_array($accounts)) {
                    // If recipient has the same master account, send alert
                    foreach ($accounts as $key => $account) {
                        // Leave recipient out
                        if ($account['uid'] == $user['uid']) {
                            continue;
                        }
                        if ($master['uid'] == $account['as_uid']) {
                            $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $account['uid'], $alertType, 0);
                            $alert->setExtraDetails(array('message' => htmlspecialchars_uni($user['username'])));
                            $alerts[] = $alert;
                        }
                    }
                }
            }
        }
        // If there are no users attached to the a recipient and the recipient isn't attached to another user
        if ($count == 0 && $user['as_uid'] == 0) {
            $alert = new MybbStuff_MyAlerts_Entity_Alert((int) $user['uid'], $alertType, 0);
            $alert->setExtraDetails(array('message' => htmlspecialchars_uni($user['username'])));
            $alerts[] = $alert;
        }
        if (!empty($alerts)) {
            MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts);
        }
    }
}
 if (get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'] == null) {
     if (isset($mybb->input['ajax'])) {
         header("Content-type: application/json;");
         echo json_encode(array("status" => "false", "followers" => 0));
     } else {
         error("Can't add this user to your followers list: User not found.");
     }
 } else {
     if ($db->num_rows($db->simple_select("ffplugin", "*", "following='" . get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'] . "' AND follower='" . $mybb->user['uid'] . "'")) == 0) {
         $insert_array = array("following" => get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], "follower" => $mybb->user['uid']);
         $db->insert_query("ffplugin", $insert_array);
         if ($mybb->settings['ffplugin_em'] == 1) {
             if (function_exists("myalerts_info")) {
                 $myalertsinfo = myalerts_info();
                 if ($myalertsinfo['version'] >= "2.0.0") {
                     $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('ffplugin_myalerts');
                     if ($alertType != null && $alertType->getEnabled()) {
                         $alert = new MybbStuff_MyAlerts_Entity_Alert(get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], $alertType, 0);
                         MybbStuff_MyAlerts_AlertManager::getInstance()->addAlert($alert);
                     }
                 }
             }
         }
         if (isset($mybb->input['ajax'])) {
             header("Content-type: application/json;");
             echo json_encode(array("status" => "true", "followers" => countf(get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], false)));
         } else {
             redirect("member.php?action=profile&uid=" . get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], "You are now following " . getName(get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid']) . ".");
         }
     } else {
         if (isset($mybb->input['ajax'])) {
Example #11
0
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);
        }
    }
}
Example #12
0
/**
 * MyAlerts 2.0 integration.
 *
 */
function accountswitcher_alerts_integrate()
{
    global $db, $cache, $lang;
    if (!isset($lang->aj_name)) {
        $lang->load('accountswitcher');
    }
    $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
    $alertType = new MybbStuff_MyAlerts_Entity_AlertType();
    $alertType->setCode("accountswitcher_author");
    $alertType->setEnabled(true);
    $alertType->setCanBeUserDisabled(true);
    $alertTypeManager->add($alertType);
    $alertType->setCode("accountswitcher_pm");
    $alertType->setEnabled(true);
    $alertType->setCanBeUserDisabled(true);
    $alertTypeManager->add($alertType);
}
function tyl_recordAlertThankyou()
{
    global $db, $lang, $mybb, $alert, $post, $codename, $prefix;
    $codename = basename(__FILE__, ".php");
    $prefix = 'g33k_' . $codename . '_';
    $lang->load("thankyoulike", false, true);
    if (!$mybb->settings[$prefix . 'enabled'] == "1") {
        return false;
    }
    $uid = (int) $post['uid'];
    $tid = (int) $post['tid'];
    $pid = (int) $post['pid'];
    $subject = htmlspecialchars_uni($post['subject']);
    $fid = (int) $post['fid'];
    $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('tyl');
    if (isset($alertType) && $alertType->getEnabled()) {
        //check if already alerted
        $query = $db->simple_select('alerts', 'id', 'object_id = ' . $pid . ' AND uid = ' . $uid . ' AND unread = 1 AND alert_type_id = ' . $alertType->getId() . '');
        if ($db->num_rows($query) == 0) {
            $alert = new MybbStuff_MyAlerts_Entity_Alert($uid, $alertType, $pid, $mybb->user['uid']);
            $alert->setExtraDetails(array('tid' => $tid, 'pid' => $pid, 't_subject' => $subject, 'fid' => $fid));
            MybbStuff_MyAlerts_AlertManager::getInstance()->addAlert($alert);
        }
    }
}
Example #14
0
/**
 * 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;
    }
}
Example #15
0
function trader_myalerts($toid, $fid)
{
    $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('tradefeedback');
    $alert = new MybbStuff_MyAlerts_Entity_Alert($toid, $alertType, 0);
    $alert->setExtraDetails(array('toid' => $toid, 'fid' => $fid));
    MybbStuff_MyAlerts_AlertManager::getInstance()->addAlert($alert);
}