/** * @param UserTable $user * @param int $status */ public function deleteHangout( $user, /** @noinspection PhpUnusedParameterInspection */ $status ) { $plugin = cbhangoutClass::getPlugin(); if ( $plugin->params->get( 'hangout_delete', 1 ) ) { cbhangoutClass::getModel(); $hangout = cbhangoutModel::getHangout( null, null, $user, $user, $plugin ); if ( $hangout ) foreach ( $hangout as $hng ) { $hng->delete(); } } }
/** * @param boolean $raw * @return array */ static public function getCategoriesList( $raw = false ) { static $cache = null; if ( ! isset( $cache ) ) { $plugin = cbhangoutClass::getPlugin(); $categories = explode( ',', $plugin->params->get( 'hangout_categories', 'General,Movies,Music,Games,Sports' ) ); $cache = array(); if ( $categories ) foreach ( $categories as $category ) { $cache[] = moscomprofilerHTML::makeOption( $category, CBTxt::T( $category ) ); } } $rows = $cache; if ( $rows ) { if ( $raw === true ) { $categories = array(); foreach ( $rows as $row ) { $categories[] = $row->value; } $rows = $categories; } } else { $rows = array(); } return $rows; }
/** * @param boolean $raw * @return array */ static public function getCategoriesList( $raw = false ) { global $_CB_database; static $cache = null; if ( ! isset( $cache ) ) { $plugin = cbhangoutClass::getPlugin(); $section = $plugin->params->get( 'hangout_j_section', null ); if ( $section ) { $query = 'SELECT cat.' . $_CB_database->NameQuote( 'id' ) . ' AS value' . ", IF( cat." . $_CB_database->NameQuote( 'level' ) . " = ( sec." . $_CB_database->NameQuote( 'level' ) . " + 1 ), cat." . $_CB_database->NameQuote( 'title' ) . ", CONCAT( REPEAT( '- ', cat." . $_CB_database->NameQuote( 'level' ) . " - ( sec." . $_CB_database->NameQuote( 'level' ) . " + 1 ) ), cat." . $_CB_database->NameQuote( 'title' ) . " ) ) AS text" . "\n FROM " . $_CB_database->NameQuote( '#__categories' ) . " AS cat" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__categories' ) . " AS sec" . ' ON sec.' . $_CB_database->NameQuote( 'id' ) . ' = ' . (int) $section . "\n WHERE cat." . $_CB_database->NameQuote( 'lft' ) . " BETWEEN ( sec." . $_CB_database->NameQuote( 'lft' ) . " + 1 ) AND ( sec." . $_CB_database->NameQuote( 'rgt' ) . " - 1 )" . "\n AND sec." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n AND sec." . $_CB_database->NameQuote( 'extension' ) . " = " . $_CB_database->Quote( 'com_content' ) . "\n AND cat." . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND cat." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n AND cat." . $_CB_database->NameQuote( 'extension' ) . " = " . $_CB_database->Quote( 'com_content' ); } else { $query = 'SELECT ' . $_CB_database->NameQuote( 'id' ) . ' AS value' . ", CONCAT( REPEAT( '- ', " . $_CB_database->NameQuote( 'level' ) . " ), " . $_CB_database->NameQuote( 'title' ) . " ) AS text" . "\n FROM " . $_CB_database->NameQuote( '#__categories' ) . "\n WHERE " . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND " . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n AND " . $_CB_database->NameQuote( 'extension' ) . " = " . $_CB_database->Quote( 'com_content' ); } $_CB_database->setQuery( $query ); $cache = $_CB_database->loadObjectList(); } $rows = $cache; if ( $rows ) { if ( $raw === true ) { $categories = array(); foreach ( $rows as $row ) { $categories[] = (int) $row->value; } $rows = $categories; } } else { $rows = array(); } return $rows; }
/** * @param int|TableInterface $row * @param bool $htmlspecialchars * @param string $type * @return string */ static public function getUrl( $row, $htmlspecialchars = true, $type = 'article' ) { global $_CB_framework; $plugin = cbhangoutClass::getPlugin(); if ( is_integer( $row ) ) { $row = new cbhangoutBlogTable(); $row->load( (int) $row ); } $category = $row->getCategory(); /** @noinspection PhpIncludeInspection */ require_once ( $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_k2/helpers/route.php' ); $categorySlug = $row->get( 'catid' ) . ( $category->get( 'alias' ) ? ':' . $category->get( 'alias' ) : null ); $articleSlug = $row->get( 'id' ) . ( $row->get( 'alias' ) ? ':' . $row->get( 'alias' ) : null ); switch ( $type ) { case 'section': /** @noinspection PhpUndefinedClassInspection */ $url = K2HelperRoute::getCategoryRoute( $plugin->params->get( 'hangout_section', null ) ); break; case 'category': /** @noinspection PhpUndefinedClassInspection */ $url = K2HelperRoute::getCategoryRoute( $categorySlug ); break; case 'article': default: /** @noinspection PhpUndefinedClassInspection */ $url = K2HelperRoute::getItemRoute( $articleSlug, $categorySlug ); break; } if ( ! stristr( $url, 'Itemid' ) ) { $url = $_CB_framework->getCfg( 'live_site' ) . '/' . $url; } else { $url = JRoute::_( $url, false ); } if ( $url ) { if ( $htmlspecialchars ) { $url = htmlspecialchars( $url ); } } return $url; }
/** * @param null|int $id * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin * @param null|string $message * @param null|string $messageType */ public function showBlogEdit( $id, $user, $model, $plugin, $message = null, $messageType = 'error' ) { global $_CB_framework, $_LANG; $blogLimit = (int) $plugin->params->get( 'hangout_limit', null ); $blogMode = $plugin->params->get( 'hangout_mode', 1 ); $cbModerator = Application::User( (int) $user->get( 'id' ) )->isGlobalModerator(); $row = new cbhangoutBlogTable(); $canAccess = false; if ( $row->load( (int) $id ) ) { if ( ! $row->get( 'id' ) ) { if ( $cbModerator ) { $canAccess = true; } elseif ( $user->get( 'id' ) && Application::MyUser()->canViewAccessLevel( $plugin->params->get( 'hangout_create_access', 2 ) ) ) { if ( ( ! $blogLimit ) || ( $blogLimit && ( cbhangoutModel::getHangoutTotal( null, $user, $user, $plugin ) < $blogLimit ) ) ) { $canAccess = true; } } } elseif ( $cbModerator || ( $row->get( 'user' ) == $user->get( 'id' ) ) ) { $canAccess = true; } } $profileUrl = $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), false, 'cbhangoutTab' ); if ( $canAccess ) { cbhangoutClass::getTemplate( 'blog_edit' ); $input = array(); $publishedTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Select publish status of the blog. Unpublished hangout will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . ( $publishedTooltip ? ' ' . $publishedTooltip : null ), (int) $this->input( 'post/published', $row->get( 'published', ( $cbModerator || ( ! $plugin->params->get( 'hangout_approval', 0 ) ) ? 1 : 0 ) ), GetterInterface::INT ) ); $categoryTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Select blog category. Select the category that best describes your blog.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $listCategory = cbhangoutModel::getCategoriesList(); $input['category'] = moscomprofilerHTML::selectList( $listCategory, 'category', 'class="form-control"' . ( $categoryTooltip ? ' ' . $categoryTooltip : null ), 'value', 'text', $this->input( 'post/category', $row->get( 'category' ), GetterInterface::STRING ), 1, false, false ); $accessTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Select access to blog; all groups above that level will also have access to the blog.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $listAccess = Application::CmsPermissions()->getAllViewAccessLevels( true, Application::MyUser() ); $input['access'] = moscomprofilerHTML::selectList( $listAccess, 'access', 'class="form-control"' . ( $accessTooltip ? ' ' . $accessTooltip : null ), 'value', 'text', (int) $this->input( 'post/access', $row->get( 'access', $plugin->params->get( 'hangout_access_default', 1 ) ), GetterInterface::INT ), 1, false, false ); $titleTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input blog title. This is the title that will distinguish this blog from others. Suggested to input something unique and intuitive.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['title'] = '<input type="text" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="required form-control" size="30"' . ( $titleTooltip ? ' ' . $titleTooltip : null ) . ' />'; if ( in_array( $blogMode, array( 1, 2 ) ) ) { $blogIntro = $_CB_framework->displayCmsEditor( 'hangout_intro', $this->input( 'post/hangout_intro', $row->get( 'hangout_intro' ), GetterInterface::HTML ), 400, 200, 40, 7 ); $input['hangout_intro'] = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input HTML supported blog intro contents. Suggested to use minimal but well formatting for easy readability.' ), null, null, null, $blogIntro, null, 'style="display:block;"' ); } if ( in_array( $blogMode, array( 1, 3 ) ) ) { $blogFull = $_CB_framework->displayCmsEditor( 'hangout_full', $this->input( 'post/hangout_full', $row->get( 'hangout_full' ), GetterInterface::HTML ), 400, 200, 40, 7 ); $input['hangout_full'] = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input HTML supported blog contents. Suggested to use minimal but well formatting for easy readability.' ), null, null, null, $blogFull, null, 'style="display:block;"' ); $input['price'] = '<input type="text" id="price" name="price" value="' . htmlspecialchars( $this->input( 'post/price', $row->get( 'price' ), GetterInterface::STRING ) ) . '" class="required form-control" size="30"' . ( $priceTooltip ? ' ' . $priceTooltip : null ) . ' />'; } $userTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input owner of blog as single integer user_id.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['user'] = '******' . (int) ( $cbModerator ? $this->input( 'post/user', $row->get( 'user', $user->get( 'id' ) ), GetterInterface::INT ) : $user->get( 'id' ) ) . '" class="digits required form-control" size="4"' . ( $userTooltip ? ' ' . $userTooltip : null ) . ' />'; if ( $message ) { $_CB_framework->enqueueMessage( $message, $messageType ); } HTML_cbhangoutBlogEdit::showBlogEdit( $row, $input, $user, $model, $plugin ); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } }