/**
	 * @param null|int    $id
	 * @param UserTable   $user
	 * @param null|string $message
	 * @param null|string $messageType
	 */
	public function showMedizdEdit( $id, $user, $message = null, $messageType = 'error' )
	{
		global $_CB_framework, $_CB_database,$_PLUGINS;
                $absPath							=	$_PLUGINS->getPluginPath( $plugin );
                require $absPath . '/templates/default/medizd_edit.php';
		$inviteLimit						=	(int) $this->params->get( 'invite_limit', null );
		$cbModerator						=	Application::User( (int) $user->get( 'id' ) )->isGlobalModerator();
                
		$row								=	new cbmedizdProductTable();

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

		$canAccess							=	false;

		if ( ! $row->get( 'id' ) ) {
			if ( $cbModerator ) {
				$canAccess					=	true;
			} elseif ( $user->get( 'id' ) && Application::MyUser()->canViewAccessLevel( $this->params->get( 'invite_create_access', 2 ) ) ) {
				if ( $inviteLimit ) {
					$query					=	'SELECT COUNT(*)'
											.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_cbmedizd' )
											.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
											.	"\n AND ( " . $_CB_database->NameQuote( 'user' ) . " IS NULL OR " . $_CB_database->NameQuote( 'user' ) . " = " . $_CB_database->Quote( '' ) . " )";
					$_CB_database->setQuery( $query );
					$inviteCount			=	(int) $_CB_database->loadResult();

					if ( $inviteCount < $inviteLimit ) {
						$canAccess			=	true;
					}
				} else {
					$canAccess				=	true;
				}
			}
		} elseif ( $cbModerator || ( $row->get( 'user_id' ) == $user->get( 'id' ) ) ) {
			$canAccess						=	true;
		}

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

		if ( $canAccess) {
			$inviteEditor					=	$this->params->get( 'invite_editor', 2 );

			cbinvitesClass::getTemplate( 'medizd_edit' );

			$input							=	array();

			$toTooltip						=	cbTooltip( null, CBTxt::T( 'MEDPR_INPUT_CODE' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['code']					=	'<input type="text" id="code" name="code" value="' . htmlspecialchars( $this->input( 'post/code', $row->get( 'code' ), GetterInterface::INT ) ) . '" class="required digits form-control" size="35"' . ( $toTooltip ? ' ' . $toTooltip : null ) . ' />';

			$subjectTooltip					=	cbTooltip( null, CBTxt::T( 'MEDPR_INPUT_NAME' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['name']				=	'<input type="text" id="name" name="name" value="' . htmlspecialchars( $this->input( 'post/name', $row->get( 'name' ), GetterInterface::STRING ) ) . '" class="required form-control" size="35"' . ( $subjectTooltip ? ' ' . $subjectTooltip : null ) . ' />';

			
			$body						=	$this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING );
			

			
                        $bodyTooltip				=	cbTooltip( null, CBTxt::T( 'MEDPR_INPUT_DESCR' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

                        $input['description']				=	'<textarea id="description" name="description" class="form-control" cols="35" rows="4"' . ( $bodyTooltip ? ' ' . $bodyTooltip : null ) . '>' . htmlspecialchars( $row->get( 'description') ) . '</textarea>';
			
                        //$subjectTooltip					=	cbTooltip( null, CBTxt::T( 'Select category.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['category']				=	$this->getMedizdCategories($row->get( 'category' ));//'<input type="text" id="category" name="category" value="' . htmlspecialchars( $this->input( 'post/category', $row->get( 'category' ), GetterInterface::STRING ) ) . '" class="form-control" size="35"' . ( $subjectTooltip ? ' ' . $subjectTooltip : null ) . ' />';
                        
                        $subjectTooltip					=	cbTooltip( null, CBTxt::T( 'MEDPR_INPUT_MANUFACTIRE' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['proizvoditel']				=	'<input type="text" id="proizvoditel" name="proizvoditel" value="' . htmlspecialchars( $this->input( 'post/proizvoditel', $row->get( 'proizvoditel' ), GetterInterface::STRING ) ) . '" class="form-control" size="35"' . ( $subjectTooltip ? ' ' . $subjectTooltip : null ) . ' />';
                        
                        
                        $db = JFactory::getDBO();
                        $db->setQuery("SELECT country_name as name, country_name as id FROM #__comprofiler_countries ORDER BY country_name");
                        $countries = $db->loadObjectList();
                        
                        
			$input['country']				=	$text_field = JHTML::_('select.genericlist',   $countries, 'country', ' class="form-control" size="1" style="width:360px;"', 'id', 'name', htmlspecialchars( $this->input( 'post/country', $row->get( 'country' ), GetterInterface::STRING ) ) );
	 
                        $subjectTooltip					=	cbTooltip( null, CBTxt::T( 'MEDPR_INPUT_PRICE' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['price']				=	'<input type="text" id="price" name="price" value="' . htmlspecialchars( $this->input( 'post/price', $row->get( 'price' ), GetterInterface::STRING ) ) . '" class="form-control" size="35"' . ( $subjectTooltip ? ' ' . $subjectTooltip : null ) . ' />';

			
			if ( $message ) {
				$_CB_framework->enqueueMessage( $message, $messageType );
			}

			HTML_cbmedizdProductEdit::showProductEdit( $row, $input, $user, $this );
		} else {
			cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
		}
	}
	/**
	 * @param null|int    $id
	 * @param UserTable   $user
	 * @param null|string $message
	 * @param null|string $messageType
	 */
	public function showInviteEdit( $id, $user, $message = null, $messageType = 'error' )
	{
		global $_CB_framework, $_CB_database;

		$inviteLimit						=	(int) $this->params->get( 'invite_limit', null );
		$cbModerator						=	Application::User( (int) $user->get( 'id' ) )->isGlobalModerator();

		$row								=	new cbinvitesInviteTable();

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

		$canAccess							=	false;

		if ( ! $row->get( 'id' ) ) {
			if ( $cbModerator ) {
				$canAccess					=	true;
			} elseif ( $user->get( 'id' ) && Application::MyUser()->canViewAccessLevel( $this->params->get( 'invite_create_access', 2 ) ) ) {
				if ( $inviteLimit ) {
					$query					=	'SELECT COUNT(*)'
											.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_invites' )
											.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
											.	"\n AND ( " . $_CB_database->NameQuote( 'user' ) . " IS NULL OR " . $_CB_database->NameQuote( 'user' ) . " = " . $_CB_database->Quote( '' ) . " )";
					$_CB_database->setQuery( $query );
					$inviteCount			=	(int) $_CB_database->loadResult();

					if ( $inviteCount < $inviteLimit ) {
						$canAccess			=	true;
					}
				} else {
					$canAccess				=	true;
				}
			}
		} elseif ( $cbModerator || ( $row->get( 'user_id' ) == $user->get( 'id' ) ) ) {
			$canAccess						=	true;
		}

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

		if ( $canAccess && ( ! $row->isAccepted() ) ) {
			$inviteEditor					=	$this->params->get( 'invite_editor', 2 );

			cbinvitesClass::getTemplate( 'invite_edit' );

			$input							=	array();

			$toTooltip						=	cbTooltip( null, ( $this->params->get( 'invite_multiple', 1 ) ? CBTxt::T( 'Input invite email to address. Separate multiple email addresses with a comma.' ) : CBTxt::T( 'Input invite email to address.' ) ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['to']					=	'<input type="text" id="to" name="to" value="' . htmlspecialchars( $this->input( 'post/to', $row->get( 'to' ), GetterInterface::STRING ) ) . '" class="required form-control" size="35"' . ( $toTooltip ? ' ' . $toTooltip : null ) . ' />';

			$subjectTooltip					=	cbTooltip( null, CBTxt::T( 'Input invite email subject; if left blank a subject will be applied.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['subject']				=	'<input type="text" id="subject" name="subject" value="' . htmlspecialchars( $this->input( 'post/subject', $row->get( 'subject' ), GetterInterface::STRING ) ) . '" class="form-control" size="25"' . ( $subjectTooltip ? ' ' . $subjectTooltip : null ) . ' />';

			if ( $inviteEditor >= 2 ) {
				$body						=	$this->input( 'post/body', $row->get( 'body' ), GetterInterface::HTML );
			} else {
				$body						=	$this->input( 'post/body', $row->get( 'body' ), GetterInterface::STRING );
			}

			if ( $inviteEditor == 3 ) {
				$input['body']				=	cbTooltip( null, CBTxt::T( 'Optionally input private message to include with invite email.' ), null, null, null, $_CB_framework->displayCmsEditor( 'body', $body, 350, 175, 35, 4 ), null, 'style="display:block;"' );
			} else {
				$bodyTooltip				=	cbTooltip( null, CBTxt::T( 'Optionally input private message to include with invite email.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

				$input['body']				=	'<textarea id="body" name="body" class="form-control" cols="35" rows="4"' . ( $bodyTooltip ? ' ' . $bodyTooltip : null ) . '>' . htmlspecialchars( $body ) . '</textarea>';
			}

			$ownerTooltip					=	cbTooltip( null, CBTxt::T( 'Input owner of invite as single integer user_id. This is the user who sent the invite.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['user_id']				=	'<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . ( $ownerTooltip ? ' ' . $ownerTooltip : null ) . ' />';

			$userTooltip					=	cbTooltip( null, CBTxt::T( 'Optionally input user of invite as single integer user_id. This is the user who accepted the invite.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['user']					=	'******' . (int) $this->input( 'post/user', $row->get( 'user' ), GetterInterface::INT ) . '" class="digits form-control" size="6"' . ( $userTooltip ? ' ' . $userTooltip : null ) . ' />';

			if ( $message ) {
				$_CB_framework->enqueueMessage( $message, $messageType );
			}

			HTML_cbinvitesInviteEdit::showInviteEdit( $row, $input, $user, $this );
		} else {
			cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
		}
	}
Beispiel #3
0
	/**
	 * @param moscomprofilerTabs $tab
	 * @param UserTable          $user
	 * @param int                $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database,$_PLUGINS;

		$viewer					=	CBuser::getMyUserDataInstance();
                $absPath							=	$_PLUGINS->getPluginPath( $plugin );
                require $absPath . '/templates/default/tab.php';
                //cbmedizdClass::getTemplate();
		if ( $viewer->id == $user->id ) {
			outputCbJs( 1 );
			outputCbTemplate( 1 );
			cbimport( 'cb.pagination' );

			cbinvitesClass::getTemplate( 'tab' );

			$limit				=	(int) $this->params->get( 'tab_limit', 15 );
			$limitstart			=	$_CB_framework->getUserStateFromRequest( 'tab_medizd_limitstart{com_comprofiler}', 'tab_medizd_limitstart' );
			$filterSearch		=	$_CB_framework->getUserStateFromRequest( 'tab_medizd_search{com_comprofiler}', 'tab_medizd_search' );
			$where				=	null;
			$join				=	null;

			if ( isset( $filterSearch ) && ( $filterSearch != '' ) ) {
				$where			.=	"\n AND ( a." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
								.	" OR b." . $_CB_database->NameQuote( 'id' ) . " = " . $_CB_database->Quote( $filterSearch )
								.	" OR a." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
								.	" OR b." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )";

				$join			.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS b"
								.	' ON b.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'user_id' );
			}

			$searching			=	( $where ? true : false );

			$query				=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_cbmedizd' ) . " AS a"
								.	$join
								.	"\n WHERE a." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->id
								.	$where
								.	"\n ORDER BY " . $_CB_database->NameQuote( 'created' ) . " DESC";
			$_CB_database->setQuery( $query );
			$total				=	$_CB_database->loadResult();

			if ( $total <= $limitstart ) {
				$limitstart		=	0;
			}

			$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

			$pageNav->setInputNamePrefix( 'tab_medizd_' );

			$query				=	'SELECT a.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_cbmedizd' ) . " AS a"
								.	$join
								.	"\n WHERE a." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->id
								.	$where
								.	"\n ORDER BY " . $_CB_database->NameQuote( 'created' ) . " DESC";
			if ( $this->params->get( 'tab_paging', 1 ) ) {
				$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
			} else {
				$_CB_database->setQuery( $query );
			}
			$rows				=	$_CB_database->loadObjectList( null, 'cbmedizdProductTable', array( $_CB_database ) );

			$input				=	array();
			$input['search']	=	'<input type="text" name="tab_medizd_search" value="' . htmlspecialchars( $filterSearch ) . '" onchange="document.medizdForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'MEDPR_SEARCH_PRODUCT' ) ) . '" class="form-control" />';

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

			$return				=	'<div id="cbmedizd" class="cbmedizd' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
								.		'<div id="cbmedizdInner" class="cbmedizdInner">'
								.			HTML_cbmedizdTab::showTab( $rows, $pageNav, $searching, $input, $viewer, $user, $tab, $this )
								.		'</div>'
								.	'</div>';

			return $return;
		}

		return null;
	}