<?php
 class vB_Api_Pmchat extends vB_Api { protected $disableWhiteList = array('canUsePMChat'); public function canUsePMChat($skipUserOption = false) { $currentUser = vB::getCurrentSession()->get('userid'); if (empty($currentUser)) { return [ 'canuse' => false, 'reason' => 'not_logged_no_permission', ]; } $canUsePmSystem = vB_Api::instanceInternal('content_privatemessage')->canUsePmSystem(); if (empty($canUsePmSystem)) { return [ 'canuse' => false, 'reason' => 'not_logged_no_permission', ]; } $vboptions = vB::getDatastore()->getValue('options'); $systemOnline = ($vboptions['pmchat_enabled']); if (!$systemOnline) { return [ 'canuse' => false, 'reason' => 'pmchat_disabled_global', ]; } $userGroupAuthorized = vB::getUserContext()->hasPermission('pmpermissions', 'canusepmchat'); if (!$userGroupAuthorized) { return [ 'canuse' => false, 'reason' => 'pmchat_disabled_usergroup', ]; } if (!$skipUserOption) { $userInfo = vB::getCurrentSession()->fetch_userinfo(); if (!$userInfo['enable_pmchat']) { return [ 'canuse' => false, 'reason' => 'pmchat_disabled_user_optout', ]; } } return [ 'canuse' => true, ]; } public function isMessageParticipant($nodeid) { $userid = vB::getCurrentSession()->get('userid'); $check = vB::getDbAssertor()->getRow('vBForum:sentto', [ 'nodeid' => $nodeid, 'userid' => $userid ]); if (!empty($check) AND $check['userid'] == $userid AND $check['nodeid'] == $nodeid) { return ['result' => true]; } return ['result' => false]; } } 