Example #1
0
 /**
  * Moderate users
  *
  * @param array $validate Validate information
  * @param bool $send_validated Whether to send email to users who have been accepted
  * @param bool $send_deleted Whether to send email to users who have been deleted
  * @return bool True if user accounts validated successfully
  */
 public function moderate($validate, $send_validated, $send_deleted)
 {
     $this->checkHasAdminPermission('canadminusers');
     if (empty($validate)) {
         throw new vB_Exception_Api('please_complete_required_fields');
     }
     $evalemail_validated = array();
     $evalemail_deleted = array();
     $vboptions = vB::getDatastore()->getValue('options');
     $usergroupcache = vB::getDatastore()->getValue('usergroupcache');
     $bf_ugp_genericpermissions = vB::getDatastore()->getValue('bf_ugp_genericpermissions');
     require_once DIR . '/includes/functions_misc.php';
     if ($vboptions['welcomepm']) {
         if ($fromuser = vB_User::fetchUserInfo($vboptions['welcomepm'])) {
             cache_permissions($fromuser, false);
         }
     }
     foreach ($validate as $userid => $status) {
         $userid = intval($userid);
         $user = vB::getDbAssertor()->getRow('user', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, '#filters' => array('userid' => $userid)));
         if (!$user) {
             // use was likely deleted
             continue;
         }
         $username = unhtmlspecialchars($user['username']);
         $chosenlanguage = iif($user['languageid'] < 1, intval($vboptions['languageid']), intval($user['languageid']));
         if ($status == 1) {
             // validated
             // init user data manager
             $displaygroupid = ($user['displaygroupid'] > 0 and $user['displaygroupid'] != $user['usergroupid']) ? $user['displaygroupid'] : 2;
             $userdata = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_ARRAY_UNPROCESSED);
             $userdata->set_existing($user);
             $userdata->set('usergroupid', 2);
             $userdata->set_usertitle($user['customtitle'] ? $user['usertitle'] : '', false, $usergroupcache["{$displaygroupid}"], $usergroupcache['2']['genericpermissions'] & $bf_ugp_genericpermissions['canusecustomtitle'] ? true : false, false);
             $userdata->save();
             if ($userdata->has_errors(false)) {
                 throw $userdata->get_exception();
             }
             if ($send_validated) {
                 if (!isset($evalemail_validated["{$user['languageid']}"])) {
                     // note that we pass the "all languages" flag as true all the time because if the function does
                     // caching internally and is not smart enough to check if the language requested the second time
                     // was cached on the first pass -- so we make sure that we load and cache all language version
                     // in case the second user has a different language from the first
                     $forumHome = vB_Library::instance('content_channel')->getForumHomeChannel();
                     $evalemail_deleted["{$user['languageid']}"] = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('moderation_validated', array(vB5_Route::buildUrl($forumHome['routeid'] . '|fullurl'), $username, $vboptions['bbtitle'], $vboptions['bburl']), array($vboptions['bbtitle']), $chosenlanguage);
                 }
                 vB_Mail::vbmail($user['email'], $evalemail_deleted["{$user['languageid']}"]['subject'], $evalemail_deleted["{$user['languageid']}"]['message'], true);
             }
             if ($vboptions['welcomepm'] and $fromuser and !$user['posts']) {
                 $userdata = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_STANDARD);
                 $userdata->send_welcomepm(null, $user['userid']);
             }
         } else {
             if ($status == -1) {
                 // deleted
                 if ($send_deleted) {
                     if (!isset($evalemail_deleted["{$user['languageid']}"])) {
                         // note that we pass the "all languages" flag as true all the time because if the function does
                         // caching internally and is not smart enough to check if the language requested the second time
                         // was cached on the first pass -- so we make sure that we load and cache all language version
                         // in case the second user has a different language from the first
                         $evalemail_deleted["{$user['languageid']}"] = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('moderation_deleted', array($username, $vboptions['bbtitle']), array($vboptions['bbtitle']), $chosenlanguage);
                     }
                     vB_Mail::vbmail($user['email'], $evalemail_deleted["{$user['languageid']}"]['subject'], $evalemail_deleted["{$user['languageid']}"]['message'], true);
                 }
                 $userdm = new vB_Datamanager_User(vB_DataManager_Constants::ERRTYPE_SILENT);
                 $userdm->set_existing($user);
                 $userdm->delete();
                 unset($userdm);
             }
         }
         // else, do nothing
     }
     // rebuild stats so new user displays on forum home
     require_once DIR . '/includes/functions_databuild.php';
     build_user_statistics();
     return true;
 }
Example #2
0
                        //note that we pass the "all languages" flag as true all the time because if the function does
                        //caching internally and is not smart enough to check if the language requested the second time
                        //was cached on the first pass -- so we make sure that we load and cache all language version
                        //in case the second user has a different language from the first
                        $phraseAux = vB_Api::instanceInternal('phrase')->fetch(array('welcomepm_gemailbody', 'welcomepm_gemailsubject'));
                        $text_message = $phraseAux['welcomepm_gemailbody'];
                        $text_subject = $phraseAux['welcomepm_gemailsubject'];
                        $evalpm_validated["{$user['languageid']}"] = '
							$message = "' . $text_message . '";
							$subject = "' . $text_subject . '";
						';
                    }
                    eval($evalpm_validated["{$user['languageid']}"]);
                    // create the DM to do error checking and insert the new PM
                    $userdata = new vB_Datamanager_User(null, vB_DataManager_Constants::ERRTYPE_STANDARD);
                    $userdata->send_welcomepm(null, $user['userid']);
                    // Legacy Hook 'private_insertpm_process' Removed //
                    // Legacy Hook 'private_insertpm_complete' Removed //
                }
            } else {
                if ($status == -1) {
                    // deleted
                    if ($vbulletin->GPC['send_deleted']) {
                        if (!isset($evalemail_deleted["{$user['languageid']}"])) {
                            //note that we pass the "all languages" flag as true all the time because if the function does
                            //caching internally and is not smart enough to check if the language requested the second time
                            //was cached on the first pass -- so we make sure that we load and cache all language version
                            //in case the second user has a different language from the first
                            $evalemail_deleted["{$user['languageid']}"] = vB_Api::instanceInternal('phrase')->fetchEmailPhrases('moderation_deleted', array($username, $vboptions['bbtitle']), array($vboptions['bbtitle']), $chosenlanguage);
                        }
                        vB_Mail::vbmail($user['email'], $evalemail_deleted["{$user['languageid']}"]['subject'], $evalemail_deleted["{$user['languageid']}"]['message'], true);