/** * @param null|int $id * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin * @param null|string $message * @param null|string $messageType */ public function showconsultationEdit( $id, $user, $model, $plugin, $message = null, $messageType = 'error' ) { global $_CB_framework; $consultationLimit = (int) $plugin->params->get( 'consultation_limit', null ); $consultationMode = $plugin->params->get( 'consultation_mode', 1 ); $cbModerator = Application::User( (int) $user->get( 'id' ) )->isGlobalModerator(); $row = new cbconsultationsconsultationTable(); $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( 'consultation_create_access', 2 ) ) ) { if ( ( ! $consultationLimit ) || ( $consultationLimit && ( cbconsultationsModel::getconsultationsTotal( null, $user, $user, $plugin ) < $consultationLimit ) ) ) { $canAccess = true; } } } elseif ( $cbModerator || ( $row->get( 'user' ) == $user->get( 'id' ) ) ) { $canAccess = true; } } $profileUrl = $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), false, 'cbconsultationsTab' ); if ( $canAccess ) { cbconsultationsClass::getTemplate( 'consultation_edit' ); $input = array(); $publishedTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Select publish status of the consultation. Unpublished consultations 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( 'consultation_approval', 0 ) ) ? 1 : 0 ) ), GetterInterface::INT ) ); $categoryTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Select consultation category. Select the category that best describes your consultation.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $listCategory = cbconsultationsModel::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 consultation; all groups above that level will also have access to the consultation.' ), 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( 'consultation_access_default', 1 ) ), GetterInterface::INT ), 1, false, false ); $titleTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input consultation title. This is the title that will distinguish this consultation 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( $consultationMode, array( 1, 2 ) ) ) { $consultationIntro = $_CB_framework->displayCmsEditor( 'consultation_intro', $this->input( 'post/consultation_intro', $row->get( 'consultation_intro' ), GetterInterface::HTML ), 400, 200, 40, 7 ); $input['consultation_intro'] = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input HTML supported consultation intro contents. Suggested to use minimal but well formatting for easy readability.' ), null, null, null, $consultationIntro, null, 'style="display:block;"' ); } if ( in_array( $consultationMode, array( 1, 3 ) ) ) { $consultationFull = $_CB_framework->displayCmsEditor( 'consultation_full', $this->input( 'post/consultation_full', $row->get( 'consultation_full' ), GetterInterface::HTML ), 400, 200, 40, 7 ); $input['consultation_full'] = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input HTML supported consultation contents. Suggested to use minimal but well formatting for easy readability.' ), null, null, null, $consultationFull, null, 'style="display:block;"' ); } $userTooltip = cbTooltip( $_CB_framework->getUi(), CBTxt::T( 'Input owner of consultation 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_cbconsultationsconsultationEdit::showconsultationEdit( $row, $input, $user, $model, $plugin ); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } }
/** * Generates the HTML to display the user profile tab * * @param \CB\Database\Table\TabTable $tab the tab database entry * @param \CB\Database\Table\UserTable $user the user being displayed * @param int $ui 1 for front-end, 2 for back-end * @return string|boolean Either string HTML for tab content, or false if ErrorMSG generated */ public function getDisplayTab( $tab, $user, $ui ) { global $_CB_framework, $_CB_database; outputCbJs( 1 ); outputCbTemplate( 1 ); cbimport( 'cb.pagination' ); $plugin = cbconsultationsClass::getPlugin(); $model = cbconsultationsClass::getModel(); $viewer = CBuser::getMyUserDataInstance(); cbconsultationsClass::getTemplate( 'tab' ); $limit = (int) $this->params->get( 'tab_limit', 15 ); $limitstart = $_CB_framework->getUserStateFromRequest( 'tab_consultations_limitstart{com_comprofiler}', 'tab_consultations_limitstart' ); $filterSearch = $_CB_framework->getUserStateFromRequest( 'tab_consultations_search{com_comprofiler}', 'tab_consultations_search' ); $where = null; if ( isset( $filterSearch ) && ( $filterSearch != '' ) ) { if ( $model->type != 2 ) { $where .= "\n AND ( a." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " OR a." . $_CB_database->NameQuote( 'introtext' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " OR a." . $_CB_database->NameQuote( 'fulltext' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )"; } else { $where .= "\n AND ( a." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " OR a." . $_CB_database->NameQuote( 'consultation_intro' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " OR a." . $_CB_database->NameQuote( 'consultation_full' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )"; } } $searching = ( $where ? true : false ); $total = cbconsultationsModel::getconsultationsTotal( $where, $viewer, $user, $plugin ); if ( $total <= $limitstart ) { $limitstart = 0; } $pageNav = new cbPageNav( $total, $limitstart, $limit ); $pageNav->setInputNamePrefix( 'tab_consultations_' ); $rows = cbconsultationsModel::getconsultations( ( $this->params->get( 'tab_paging', 1 ) ? array( $pageNav->limitstart, $pageNav->limit ) : null ), $where, $viewer, $user, $plugin ); $input = array(); $input['search'] = '<input type="text" name="tab_consultations_search" value="' . htmlspecialchars( $filterSearch ) . '" onchange="document.consultationForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search consultations...' ) ) . '" class="form-control" />'; $tab->params = $this->params; $class = $plugin->params->get( 'general_class', null ); $return = '<div id="cbconsultations" class="cbconsultations' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbconsultationsInner" class="cbconsultationsInner">' . HTML_cbconsultationsTab::showconsultationTab( $rows, $pageNav, $searching, $input, $viewer, $user, $model, $tab, $plugin ) . '</div>' . '</div>'; return $return; }