コード例 #1
0
	/**
	 * @param  int          $id
	 * @param  UserTable    $user
	 * @param  stdClass     $model
	 * @param  PluginTable  $plugin
	 */
	private function deleteBlog( $id, $user, /** @noinspection PhpUnusedParameterInspection */ $model, /** @noinspection PhpUnusedParameterInspection */ $plugin )
	{
		global $_CB_framework;

		$row				=	new cbblogsBlogTable();

		$canAccess			=	false;

		if ( $row->load( (int) $id ) ) {
			if ( $row->get( 'id' ) && ( ( $row->get( 'user' ) == $user->get( 'id' ) ) || Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) ) {
				$canAccess	=	true;
			}
		}

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

		if ( $canAccess ) {
			if ( ! $row->canDelete() ) {
				cbRedirect( $profileUrl, CBTxt::T( 'BLOG_FAILED_TO_DELETE_ERROR_ERROR', 'Blog failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' );
			}

			if ( ! $row->delete( (int) $id ) ) {
				cbRedirect( $profileUrl, CBTxt::T( 'BLOG_FAILED_TO_DELETE_ERROR_ERROR', 'Blog failed to delete! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' );
			}

			cbRedirect( $profileUrl, CBTxt::T( 'Blog deleted successfully!' ) );
		} else {
			cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
		}
	}
コード例 #2
0
ファイル: joomla25.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param  int|OrderedTable  $row
	 * @param  boolean           $htmlspecialchars
	 * @param  string            $type
	 * @return string
	 */
	static public function getUrl( $row, $htmlspecialchars = true, $type = 'article' )
	{
		global $_CB_framework;

		if ( is_integer( $row ) ) {
			$row			=	new cbblogsBlogTable();

			$row->load( (int) $row );
		}

		$category			=	$row->getCategory();

		/** @noinspection PhpIncludeInspection */
		require_once ( $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_content/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':
				$url		=	ContentHelperRoute::getCategoryRoute( $row->get( 'sectionid' ) );
				break;
			case 'category':
				$url		=	ContentHelperRoute::getCategoryRoute( $categorySlug );
				break;
			case 'article':
			default:
				$url		=	ContentHelperRoute::getArticleRoute( $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;
	}
コード例 #3
0
 /**
  * @param  int|TableInterface  $row
  * @param  bool                $htmlspecialchars
  * @param  string              $type
  * @return string
  */
 public static function getUrl($row, $htmlspecialchars = true, $type = 'article')
 {
     global $_CB_framework;
     $plugin = cbblogsClass::getPlugin();
     if (is_integer($row)) {
         $rowId = $row;
         $row = new cbblogsBlogTable();
         $row->load((int) $rowId);
     }
     $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('blog_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;
 }