示例#1
0
 public function notifyUserIds($contentType, $contentId, $contentUserId, $contentUserName, $alertAction, array $userIds, array $noAlertUserIds, array $noEmailUserIds, XenForo_Model_User $userModel, array $options)
 {
     if (!empty($userIds)) {
         $fetchOptions = array();
         if (!empty($options['users']['fetchOptions'])) {
             $fetchOptions = $options['users']['fetchOptions'];
         }
         if (empty($fetchOptions['join'])) {
             $fetchOptions['join'] = 0;
         }
         $fetchOptions['join'] |= XenForo_Model_User::FETCH_USER_OPTION;
         $fetchOptions['join'] |= XenForo_Model_User::FETCH_USER_PROFILE;
         $users = $userModel->getUsersByIds($userIds, $fetchOptions);
     } else {
         $users = array();
     }
     foreach ($users as $user) {
         if ($user['user_id'] == $contentUserId) {
             // it's stupid to notify one's self
             continue;
         }
         if (!empty($options[self::OPTION_USER_CALLBACK])) {
             $userCallbackResult = call_user_func($options[self::OPTION_USER_CALLBACK], $userModel, $user, $options);
             if ($userCallbackResult === false) {
                 // user callback returns false, do not continue
                 continue;
             }
         }
         if (!$userModel->isUserIgnored($user, $contentUserId)) {
             $shouldAlert = true;
             if (!XenForo_Model_Alert::userReceivesAlert($user, $contentType, $alertAction)) {
                 $shouldAlert = false;
             }
             if (in_array($user['user_id'], $noAlertUserIds) || in_array($user['user_id'], $noEmailUserIds)) {
                 $shouldAlert = false;
             }
             if ($shouldAlert) {
                 XenForo_Model_Alert::alert($user['user_id'], $contentUserId, $contentUserName, $contentType, $contentId, $alertAction);
             }
             if (bdTagMe_Option::get('alertEmail') && !empty($user['bdtagme_email'])) {
                 $shouldEmail = true;
                 if (in_array($user['user_id'], $noEmailUserIds)) {
                     $shouldEmail = false;
                 }
                 if ($shouldEmail) {
                     /** @var bdTagMe_XenForo_Model_Alert $alertModel */
                     $alertModel = $userModel->getModelFromCache('XenForo_Model_Alert');
                     $viewLink = $alertModel->bdTagMe_getContentLink($contentType, $contentId);
                     if (!empty($viewLink)) {
                         $mail = XenForo_Mail::create('bdtagme_tagged', array('sender' => array('user_id' => $contentUserId, 'username' => $contentUserName), 'receiver' => $user, 'contentType' => $contentType, 'contentId' => $contentId, 'viewLink' => $viewLink), $user['language_id']);
                         $mail->enableAllLanguagePreCache();
                         $mail->queue($user['email'], $user['username']);
                     }
                 }
             }
         }
     }
     return true;
 }
示例#2
0
 public static function XenForo_DataWriter_DiscussionMessage_Post(XenForo_Model_User $userModel, array $user, array $options)
 {
     if (empty($user['node_permission_cache'])) {
         return false;
     }
     if (empty($options['post']) or empty($options['thread']) or empty($options['forum'])) {
         return false;
     }
     $permissions = XenForo_Permission::unserializePermissions($user['node_permission_cache']);
     /** @var XenForo_Model_Post $postModel */
     $postModel = $userModel->getModelFromCache('XenForo_Model_Post');
     return $postModel->canViewPostAndContainer($options['post'], $options['thread'], $options['forum'], $null, $permissions, $user);
 }
示例#3
0
 public static function suggestUserName($username, XenForo_Model_User $userModel)
 {
     if (preg_match('#[^0-9]([0-9]+)$#', $username, $matches, PREG_OFFSET_CAPTURE)) {
         $i = $matches[1][0];
         $origName = trim(substr($username, 0, $matches[1][1]));
     } else {
         $i = 2;
         $origName = $username;
     }
     while ($userModel->getUserByName($username)) {
         $username = $origName . ' ' . $i++;
     }
     return $username;
 }
示例#4
0
 public function prepareUserConditions(array $conditions, array &$fetchOptions)
 {
     $return = parent::prepareUserConditions($conditions, $fetchOptions);
     if (!$this->canBypassUserPrivacy()) {
         $return .= ' AND (user.visible = 1)';
     }
     return $return;
 }
示例#5
0
<?php

if ($slug == "handleUpload") {
    $pluginUsername = $params[0];
    $u = new XenForo_Model_User();
    $pluginUserID = $u->getUserIdFromUser($u->getUserByName($pluginUsername));
    $pluginName = $params[1];
    $dbQuery = Database::select('plugins', 'pid', array('pname = ? AND pauthor_id = ?', $pluginName, $pluginUserID));
    $pluginID = $dbQuery->fetchColumn();
    if ((User::$role == User::ROLE_GUEST || User::$uid != $pluginUserID) && User::$role != User::ROLE_ADMIN) {
        $httpError = 403;
    } else {
        if ($dbQuery->rowCount() != 1) {
            $httpError = 404;
        } else {
            // okay, let's do this
            // get down on it
            $tempFile = $_FILES['Filedata']['tmp_name'];
            $fileMd5 = md5_file($tempFile);
            $newFileName = $fileMd5;
            $fileDir = '/home2/bukkit/fill/uploads/';
            if (file_exists($fileDir . $newFileName)) {
                echo 'File exists';
                exit;
            }
            $a = Database::select('plugin_downloads', '*', array('dfname = ?', $_FILES['Filedata']['name']));
            $lastNum = 0;
            if ($a->rowCount() == 0) {
                Database::insert('plugin_downloads', array('pid' => $pluginID, 'dfname' => $_FILES['Filedata']['name'], 'dfriendlyname' => 'notdoneyet', 'ddesc' => 'notdoneyet'));
                $a = Database::select('plugin_downloads', '*', array('dfname = ?', $_FILES['Filedata']['name']));
                $pluginFileRow = $a->fetch(PDO::FETCH_ASSOC);