コード例 #1
0
	/**
	 * @param  TabTable   $tab       Current tab
	 * @param  UserTable  $user      Current user
	 * @param  int        $ui        1 front, 2 admin UI
	 * @param  array      $postdata  Raw unfiltred POST data
	 * @return string                HTML
	 */
	public function getCBpluginComponent( /** @noinspection PhpUnusedParameterInspection */ $tab, $user, $ui, $postdata )
	{
		global $_CB_framework;

		outputCbJs( 1 );
		outputCbTemplate( 1 );

		$plugin					=	cbconsultationsClass::getPlugin();
		$model					=	cbconsultationsClass::getModel();
		$action					=	$this->input( 'action', null, GetterInterface::STRING );
		$function				=	$this->input( 'func', null, GetterInterface::STRING );
		$id						=	$this->input( 'id', null, GetterInterface::INT );
		$user					=	CBuser::getUserDataInstance( $_CB_framework->myId() );

		$tab					=	new TabTable();

		$tab->load( array( 'pluginid' => (int) $plugin->id ) );

		$profileUrl				=	$_CB_framework->userProfileUrl( $user->get( 'id' ), false, 'cbconsultationsTab' );

		if ( ! ( $tab->enabled && Application::MyUser()->canViewAccessLevel( $tab->viewaccesslevel ) ) ) {
			cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
		}

		ob_start();
		switch ( $action ) {
			case 'consultations':
				switch ( $function ) {
					case 'new':
						$this->showconsultationEdit( null, $user, $model, $plugin );
						break;
					case 'edit':
						$this->showconsultationEdit( $id, $user, $model, $plugin );
						break;
					case 'save':
						cbSpoofCheck( 'plugin' );
						$this->saveconsultationEdit( $id, $user, $model, $plugin );
						break;
					case 'publish':
						$this->stateconsultation( 1, $id, $user, $model, $plugin );
						break;
					case 'unpublish':
						$this->stateconsultation( 0, $id, $user, $model, $plugin );
						break;
					case 'delete':
						$this->deleteconsultation( $id, $user, $model, $plugin );
						break;
					case 'show':
					default:
						if ( $model->type != 2 ) {
							cbRedirect( cbconsultationsModel::getUrl( (int) $id, false ) );
						} else {
							$this->showconsultation( $id, $user, $model, $plugin );
						}
						break;
				}
				break;
			default:
				cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
				break;
		}
		$html		=	ob_get_contents();
		ob_end_clean();

		$class		=	$plugin->params->get( 'general_class', null );

		$return		=	'<div id="cbconsultations" class="cbconsultations' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
					.		'<div id="cbconsultationsInner" class="cbconsultationsInner">'
					.			$html
					.		'</div>'
					.	'</div>';

		echo $return;
	}
コード例 #2
0
	/**
	 * @param  UserTable  $user
	 * @param  int        $status
	 */
	public function deleteconsultations( $user, /** @noinspection PhpUnusedParameterInspection */ $status )
	{
		$plugin			=	cbconsultationsClass::getPlugin();

		if ( $plugin->params->get( 'consultation_delete', 1 ) ) {
			cbconsultationsClass::getModel();

			$consultations		=	cbconsultationsModel::getconsultations( null, null, $user, $user, $plugin );

			if ( $consultations ) foreach ( $consultations as $consultation ) {
				$consultation->delete();
			}
		}
	}