protected function _preDispatch($action) { if (!Nobita_Teams_Validation::assertAddOnValidAndUsable('sonnb_xengallery')) { throw $this->getNoPermissionResponseException(); } if (!$this->_getTeamModel()->canViewTeams($error)) { throw $this->getErrorOrNoPermissionResponseException($error); } return parent::_preDispatch($action); }
public static function uninstall($db = null) { if (!$db) { $db = XenForo_Application::get('db'); } if (!Nobita_Teams_Validation::assertAddOnValidAndUsable('sonnb_xengallery', false)) { // addon didn't existed return; } try { $db->query("ALTER TABLE sonnb_xengallery_album DROP COLUMN team_id"); } catch (Zend_Db_Exception $e) { } }
public static function XenMedia_renderOption(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit) { if (!Nobita_Teams_Validation::assertAddOnValidAndUsable('XenGallery')) { $preparedOption['formatParams'] = array('value' => 0, 'label' => '(' . new XenForo_Phrase('unspecified') . ')', 'selected' => true, 'depth' => 0); } else { $categoryModel = XenForo_Model::create('XenGallery_Model_Category'); $categories = $categoryModel->getAllCategories(); $options[0] = array('value' => 0, 'label' => '(' . new XenForo_Phrase('unspecified') . ')', 'selected' => true, 'depth' => 0); foreach ($categories as $category) { $options[$category['category_id']] = array('value' => $category['category_id'], 'label' => $category['category_title'], 'selected' => false, 'depth' => $category['depth']); } $preparedOption['formatParams'] = $options; } return XenForo_ViewAdmin_Helper_Option::renderOptionTemplateInternal('option_list_option_select', $view, $fieldPrefix, $preparedOption, $canEdit); }
protected function _postDelete() { $db = $this->_db; $teamIdQuoted = $db->quote($this->get('team_id')); $postIds = $db->fetchCol(' SELECT post_id FROM xf_team_post WHERE team_id = ? ', $this->getTeamId()); $this->getModelFromCache('XenForo_Model_Attachment')->deleteAttachmentsFromContentIds('team_post', $postIds); $this->getModelFromCache('XenForo_Model_Alert')->deleteAlerts('team_post', $postIds); $db->delete('xf_team_post', 'team_id = ' . $teamIdQuoted); $db->delete('xf_team_post_comment', 'team_id = ' . $teamIdQuoted); $db->delete('xf_team_member', 'team_id = ' . $teamIdQuoted); $db->delete('xf_team_field_value', 'team_id = ' . $teamIdQuoted); // update thread $db->query("\n\t\t\tUPDATE xf_thread\n\t\t\tSET team_id = 0, discussion_type = ''\n\t\t\tWHERE team_id = ?\n\t\t", $this->getTeamId()); // 1.1.3 support event! $db->delete('xf_team_event', 'team_id = ' . $teamIdQuoted); if ($this->getExisting('team_state') == 'visible') { $this->_teamRemoved(); } $this->_updateDeletionLog(true); $this->getModelFromCache('XenForo_Model_ModerationQueue')->deleteFromModerationQueue('team', $this->get('team_id')); $this->getModelFromCache('Nobita_Teams_Model_Avatar')->deleteAvatar($this->getTeamId(), false); if ($this->get('cover_date')) { $this->getModelFromCache('Nobita_Teams_Model_Cover')->deleteCoverPhoto($this->getTeamId(), false); // fixed! remove cover as well! $this->getModelFromCache('Nobita_Teams_Model_Cover')->deleteCoverCropPhoto($this->getTeamId(), $this->get('cover_date')); } $this->_deleteFromNewsFeed(); $this->getModelFromCache('XenForo_Model_Alert')->deleteAlerts('team', $this->getTeamId()); if (Nobita_Teams_Validation::assertAddOnValidAndUsable('sonnb_xengallery', false)) { try { $db->query("\n\t\t\t\t\tUPDATE sonnb_xengallery_album\n\t\t\t\t\tSET team_id = 0\n\t\t\t\t\tWHERE team_id = ?\n\t\t\t\t", $this->get('team_id')); } catch (Zend_Db_Exception $e) { } } }
/** * Control tabs to display *members, photos, events * @params $tabId */ public function canViewTabAndContainer($tabId, array $team, array $category, &$errorPhraseKey = '', array $viewingUser = null) { $this->standardizeViewingUserReference($viewingUser); $allowTabs = array('members', 'photos', 'events', 'extra', 'threads'); if (!in_array($tabId, $allowTabs)) { return false; } $setup = $this->_teamSetup(); $photoProvider = $setup->getOption('photoProvider'); if ($tabId == 'photos' && $photoProvider == 'disabled') { return false; } if (!$this->isOpen($team)) { // should be invisible to guest if team not public // @privacy error $user = $this->isTeamMember($team['team_id'], $viewingUser); if (!$viewingUser['user_id'] || empty($user)) { $errorPhraseKey = 'requested_page_not_found'; return false; } } $disableTabs = explode(',', $team['disable_tabs']); if ('threads' == $tabId && empty($category['discussion_node_id'])) { return false; } switch ($tabId) { case 'members': if ($this->isTeamAdmin($team['team_id'], $viewingUser)) { return true; } return !in_array('member_list', $disableTabs); case 'photos': return !in_array($tabId, $disableTabs) && (Nobita_Teams_Validation::assetXenMediaValidAndUsable() || Nobita_Teams_Validation::assetSonnbXenGalleryValidAndUsable()); case 'extra': case 'events': case 'threads': return !in_array($tabId, $disableTabs); } }