public function publishAsNeeded($optionId, bdSocialShare_Shareable_Abstract $shareable, $key = false) { extract($this->_getTargets($optionId, $key)); $shareQueueModel = $this->_getShareQueueModel(); $preConfiguredTargets = $shareable->getPreConfiguredTargets(); if (!empty($included)) { if (!empty($targets) and $shareQueueModel->canQueue() and $shareQueueModel->insertQueue($shareable, $targets, $default)) { // good, queued now } else { // unable to queue, publish asap $shareQueueModel->publish($shareable, $targets, $default); } } if (!empty($preConfiguredTargets)) { $userModel = $this->_controller->getModelFromCache('XenForo_Model_User'); $viewingUserGuest = $userModel->getVisitingGuestUser(); $userModel->bdSocialShare_prepareViewingUser($viewingUserGuest); if ($shareQueueModel->canQueue() and $shareQueueModel->insertQueue($shareable, $preConfiguredTargets, false, $viewingUserGuest)) { // good, queued now } else { // unable to queue, publish asap $shareQueueModel->publish($shareable, $preConfiguredTargets, false, $viewingUserGuest); } } }
public function getPreConfiguredTargets() { $resource = $this->_resourceDw->getMergedData(); $visitor = XenForo_Visitor::getInstance(); if ($resource['user_id'] == $visitor['user_id'] and $visitor->hasPermission('general', 'bdSocialShare_resourceAut')) { $option = bdSocialShare_Option::get('resourceAddAuto'); if (is_array($option)) { return $option; } } return parent::getPreConfiguredTargets(); }
public function getPreConfiguredTargets() { $profilePost = $this->_profilePostDw->getMergedData(); if ($profilePost['user_id'] != $profilePost['profile_user_id']) { // not a status return parent::getPreConfiguredTargets(); } if (isset($profilePost['message_state']) and $profilePost['message_state'] !== 'visible') { // not visible, no auto share return parent::getPreConfiguredTargets(); } $visitor = XenForo_Visitor::getInstance(); if ($profilePost['user_id'] == $visitor['user_id'] and $visitor->hasPermission('general', 'bdSocialShare_statusAuto')) { $option = bdSocialShare_Option::get('statusAuto'); if (is_array($option)) { return $option; } } return parent::getPreConfiguredTargets(); }
public function getPreConfiguredTargets() { $post = $this->_postDw->getMergedData(); if (isset($post['message_state']) and $post['message_state'] !== 'visible') { // not visible, no auto share return parent::getPreConfiguredTargets(); } if ($post['position'] == 0) { $visitor = XenForo_Visitor::getInstance(); if ($post['user_id'] == $visitor['user_id'] and $visitor->hasPermission('general', 'bdSocialShare_threadAuto')) { $threadDw = $this->_postDw->getDiscussionDataWriter(); if (!empty($threadDw)) { $forumData = $threadDw->bdSocialShare_getForumData(); $forumDataThreadAuto = bdSocialShare_Helper_Common::unserializeOrFalse($forumData, 'bdsocialshare_threadauto'); if ($forumDataThreadAuto !== false) { // forum configuration takes precedence return $forumDataThreadAuto; } else { // use system configuration $option = bdSocialShare_Option::get('threadAuto'); if (is_array($option)) { return $option; } } } } } return parent::getPreConfiguredTargets(); }