Ejemplo n.º 1
0
	/**
	 * @param string $context
	 * @param object $article
	 */
	public function onContentBeforeDisplay( $context, &$article )
	{
		if ( isset( $article->created_by ) || isset( $article->modified_by ) ) {
			static $CB_loaded				=	0;

			if ( ! $CB_loaded++ ) {
				if ( ( ! file_exists( JPATH_SITE . '/libraries/CBLib/CBLib/Core/CBLib.php' ) ) || ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) ) {
					echo 'CB not installed'; return;
				}

				include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
			}

			if ( ( isset( $article->created_by ) ) && $article->created_by ) {
				$cbUserCreate				=	CBuser::getInstance( (int) $article->created_by, false );

				if ( isset( $article->author ) ) {
					$article->author		=	$cbUserCreate->getField( 'formatname', null, 'html', 'none', 'list', 0, true );
				}

				$article->created_by_alias	=	$cbUserCreate->getField( 'formatname', null, 'html', 'none', 'list', 0, true );
			}

			if ( ( isset( $article->modified_by ) ) && $article->modified_by ) {
				$cbUserModify				=	CBuser::getInstance( (int) $article->modified_by, false );

				$article->modified_by_name	=	$cbUserModify->getField( 'formatname', null, 'html', 'none', 'list', 0, true );
			}

			if ( ( isset( $article->contactid ) ) && $article->contactid ) {
				$article->contactid			=	null;
			}
		}
	}
Ejemplo n.º 2
0
	/**
	 * @param bool                        $count
	 * @param array                       $select
	 * @param array                       $where
	 * @param array                       $join
	 * @param CB\Plugin\Activity\Activity $stream
	 */
	public function activityQuery( $count, &$select, &$where, &$join, &$stream )
	{
		global $_CB_database;

		$join[]				=	'LEFT JOIN ' . $_CB_database->NameQuote( '#__groupjive_plugin_photo' ) . ' AS gj_p'
							.	' ON a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
							.	' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' )
							.	' AND a.' . $_CB_database->NameQuote( 'item' ) . ' = gj_p.' . $_CB_database->NameQuote( 'id' );

		if ( ! CBGroupJive::isModerator() ) {
			$user			=	CBuser::getMyUserDataInstance();

			$where[]		=	'( ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
							.	' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' )
							.	' AND gj_p.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL'
							.	' AND ( gj_p.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
							.		' OR ( gj_p.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
							.		' AND ( gj_g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )'
							.		' OR gj_u.' . $_CB_database->NameQuote( 'status' ) . ' > 0 ) ) ) )'
							.	' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' != ' . $_CB_database->Quote( 'groupjive' )
							.	' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
							.	' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' != ' . $_CB_database->Quote( 'group.photo' ) . ' ) ) )';
		} else {
			$where[]		=	'( ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
							.	' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' )
							.	' AND gj_p.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )'
							.	' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' != ' . $_CB_database->Quote( 'groupjive' )
							.	' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' )
							.	' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' != ' . $_CB_database->Quote( 'group.photo' ) . ' ) ) )';
		}
	}
Ejemplo n.º 3
0
 public function getAvatar($profile)
 {
     if (!$this->exists()) {
         return false;
     }
     $user = CBuser::getInstance($profile->id);
     // @task: Apply guest avatars when necessary.
     if (!$profile->id) {
         $avatar = selectTemplate() . 'images/avatar/tnnophoto_n.png';
         return $avatar;
     }
     if (!$user) {
         $user = CBuser::getInstance(null);
     }
     // Prevent CB from adding anything to the page.
     ob_start();
     $source = $user->getField('avatar', null, 'php');
     $reset = ob_get_contents();
     ob_end_clean();
     unset($reset);
     $source = $source['avatar'];
     //incase we view from backend. we need to remove the /administrator/ from the path.
     $avatar = str_replace('/administrator/', '/', $source);
     return $avatar;
 }
Ejemplo n.º 4
0
 protected function _getURL($user, $sizex, $sizey)
 {
     global $_CB_framework;
     $app = JFactory::getApplication();
     $user = KunenaFactory::getUser($user);
     if ($app->getClientId() == 0) {
         $cbclient_id = 1;
     }
     if ($app->getClientId() == 1) {
         $cbclient_id = 2;
     }
     $_CB_framework->cbset('_ui', $cbclient_id);
     // Get CUser object
     $cbUser = null;
     if ($user->userid) {
         $cbUser = CBuser::getInstance($user->userid);
     }
     if ($cbUser === null) {
         if ($sizex <= 90) {
             return selectTemplate() . 'images/avatar/tnnophoto_n.png';
         }
         return selectTemplate() . 'images/avatar/nophoto_n.png';
     }
     if ($sizex <= 90) {
         return $cbUser->getField('avatar', null, 'csv');
     }
     return $cbUser->getField('avatar', null, 'csv', 'none', 'list');
 }
Ejemplo n.º 5
0
	/**
	 * prepare frontend about render
	 *
	 * @param string     $return
	 * @param GroupTable $group
	 * @param string     $users
	 * @param string     $invites
	 * @param array      $counters
	 * @param array      $buttons
	 * @param array      $menu
	 * @param cbTabs     $tabs
	 * @param UserTable  $user
	 * @return array|null
	 */
	public function showAbout( &$return, &$group, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user )
	{
		global $_CB_framework;

		if ( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( ( $group->get( 'published' ) == 1 ) && ( CBGroupJive::getGroupStatus( $user, $group ) >= 3 ) ) ) {
			$menu[]		=	'<a href="' . $_CB_framework->pluginClassUrl( $this->element, true, array( 'action' => 'about', 'func' => 'edit', 'id' => (int) $group->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'About' ) . '</a>';
		}

		$about			=	trim( $group->params()->get( 'about_content' ) );

		if ( ( ! $about ) || ( $about == '<p></p>' ) ) {
			return null;
		}

		CBGroupJive::getTemplate( 'about', true, true, $this->element );

		if ( $this->params->get( 'groups_about_substitutions', 0 ) ) {
			$about		=	CBuser::getInstance( (int) $user->get( 'id' ), false )->replaceUserVars( $about, false, false, null, false );
		}

		if ( $this->params->get( 'groups_about_content_plugins', 0 ) ) {
			$about		=	Application::Cms()->prepareHtmlContentPlugins( $about );
		}

		return array(	'id'		=>	'about',
						'title'		=>	CBTxt::T( 'About' ),
						'content'	=>	HTML_groupjiveAbout::showAbout( $about, $group, $user, $this )
					);
	}
	/**
	 * @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( $tab, $user, $ui, $postdata )
	{
		$format				=	$this->input( 'format', null, GetterInterface::STRING );

		if ( $format != 'raw' ) {
			outputCbJs();
			outputCbTemplate();
		}

		$action				=	$this->input( 'action', null, GetterInterface::STRING );
		$function			=	$this->input( 'func', null, GetterInterface::STRING );
		$id					=	(int) $this->input( 'id', null, GetterInterface::INT );
		$user				=	CBuser::getMyUserDataInstance();

		if ( $format != 'raw' ) {
			ob_start();
		}

		switch ( $action ) {
			case 'wall':
				switch ( $function ) {
					case 'publish':
						$this->stateWall( 1, $id, $user );
						break;
					case 'unpublish':
						$this->stateWall( 0, $id, $user );
						break;
					case 'delete':
						$this->deleteWall( $id, $user );
						break;
					case 'new':
						$this->showWallEdit( null, $user );
						break;
					case 'edit':
						$this->showWallEdit( $id, $user );
						break;
					case 'save':
						cbSpoofCheck( 'plugin' );
						$this->saveWallEdit( $id, $user );
						break;
				}
				break;
		}

		if ( $format != 'raw' ) {
			$html			=	ob_get_contents();
			ob_end_clean();

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

			$return			=	'<div class="cbGroupJive' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
							.		'<div class="cbGroupJiveInner">'
							.			$html
							.		'</div>'
							.	'</div>';

			echo $return;
		}
	}
Ejemplo n.º 7
0
 function getAvatar($userID, $email = NULL, $width = 50)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.application.component.model');
     $mainframe =& JFactory::getApplication();
     $params =& K2HelperUtilities::getParams('com_k2');
     if (K2_CB && $userID != 'alias') {
         $cbUser = CBuser::getInstance((int) $userID);
         if (is_object($cbUser)) {
             $avatar = $cbUser->getField('avatar', null, 'csv', 'none', 'profile');
             return $avatar;
         }
     }
     /*
     		 // JomSocial Avatar integration
     		 if(JFolder::exists(JPATH_SITE.DS.'components'.DS.'com_community') && $userID>0){
     		 $userInfo = &CFactory::getUser($userID);
     		 return $userInfo->getThumbAvatar();
     		 }
     */
     // Check for placeholder overrides
     if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'images' . DS . 'placeholder' . DS . 'user.png')) {
         $avatarPath = 'templates/' . $mainframe->getTemplate() . '/images/placeholder/user.png';
     } else {
         $avatarPath = 'components/com_k2/images/placeholder/user.png';
     }
     // Continue with default K2 avatar determination
     if ($userID == 'alias') {
         $avatar = JURI::root(true) . '/' . $avatarPath;
     } else {
         if ($userID == 0) {
             if ($params->get('gravatar') && !is_null($email)) {
                 $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&amp;default=' . urlencode(JURI::root() . $avatarPath);
             } else {
                 $avatar = JURI::root(true) . '/' . $avatarPath;
             }
         } else {
             if (is_numeric($userID) && $userID > 0) {
                 JModel::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models');
                 $model =& JModel::getInstance('Item', 'K2Model');
                 $profile = $model->getUserProfile($userID);
                 $avatar = is_null($profile) ? '' : $profile->image;
                 if (empty($avatar)) {
                     if ($params->get('gravatar') && !is_null($email)) {
                         $avatar = 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . $width . '&amp;default=' . urlencode(JURI::root() . $avatarPath);
                     } else {
                         $avatar = JURI::root(true) . '/' . $avatarPath;
                     }
                 } else {
                     $avatar = JURI::root(true) . '/media/k2/users/' . $avatar;
                 }
             }
         }
     }
     if (!$params->get('userImageDefault') && $avatar == JURI::root(true) . '/' . $avatarPath) {
         $avatar = '';
     }
     return $avatar;
 }
Ejemplo n.º 8
0
	/**
	 * @param TagTable[]      $rows
	 * @param Tags            $stream
	 * @param int             $output 0: Normal, 1: Raw, 2: Inline, 3: Load , 4: Save
	 * @param UserTable       $user
	 * @param UserTable       $viewer
	 * @param cbPluginHandler $plugin
	 * @return null|string
	 */
	static public function showTags( $rows, $stream, $output, $user, $viewer, $plugin )
	{
		global $_PLUGINS;

		CBActivity::loadHeaders( $output );

		$sourceClean			=	htmlspecialchars( $stream->source() );

		$tags					=	array();
		$return					=	null;

		$_PLUGINS->trigger( 'activity_onBeforeDisplayTags', array( &$return, &$rows, $stream, $output ) );

		if ( $rows ) foreach ( $rows as $row ) {
			$rowId				=	$sourceClean . 'Tag' . (int) $row->get( 'id' );

			if ( is_numeric( $row->get( 'user' ) ) ) {
				$name			=	CBuser::getInstance( (int) $row->get( 'user' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true );
			} else {
				$name			=	htmlspecialchars( $row->get( 'user' ) );
			}

			if ( ! $name ) {
				continue;
			}

			$tags[]				=	'<span id="' . $rowId . '" class="streamTag">'
								.		$name
								.	'</span>';
		}

		if ( $tags ) {
			$return				.=	( ! in_array( $output, array( 1, 4 ) ) ? '<span class="' . $sourceClean . 'Tags streamTags">' : null );

			if ( count( $tags ) > 2 ) {
				$tagOne			=	array_shift( $tags );
				$tagTwo			=	array_shift( $tags );

				$moreTooltip	=	cbTooltip( null, '<div class="streamTagRow">' . implode( '</div><div class="streamTagRow">', $tags ) . '</div>', null, 'auto', null, null, null, 'data-hascbtooltip="true" data-cbtooltip-position-my="bottom center" data-cbtooltip-position-at="top center" data-cbtooltip-open-event="click" data-cbtooltip-close-event="click unfocus" data-cbtooltip-button-hide="true"' );
				$more			=	'<a href="javascript: void(0);"' . $moreTooltip . '>' . CBTxt::T( 'TAGS_MORE', '%%COUNT%% more', array( '%%COUNT%%' => count( $tags ) ) ) . '</a>';

				$return			.=		CBTxt::T( 'TAGS_MORE_THAN_TWO', '[tag_1], [tag_2], and [more]', array( '[tag_1]' => $tagOne, '[tag_2]' => $tagTwo, '[more]' => $more ) );
			} elseif ( count( $tags ) > 1 ) {
				$return			.=		CBTxt::T( 'TAGS_TWO', '[tag_1] and [tag_2]', array( '[tag_1]' => $tags[0], '[tag_2]' => $tags[1] ) );
			} else {
				$return			.=		$tags[0];
			}

			$return				.=	( ! in_array( $output, array( 1, 4 ) ) ? '</span>' : null );
		}

		$return					.=	CBActivity::reloadHeaders( $output );

		$_PLUGINS->trigger( 'activity_onAfterDisplayTags', array( &$return, $rows, $stream, $output ) );

		return $return;
	}
Ejemplo n.º 9
0
	public function getProfileURL($user, $task='', $xhtml = true)
	{
		$user = KunenaFactory::getUser($user);
		if ($user->userid == 0) return false;
		// Get CUser object
		$cbUser = CBuser::getInstance( $user->userid );
		if($cbUser === null) return false;
		return cbSef( 'index.php?option=com_comprofiler&task=userProfile&user=' . $user->userid. getCBprofileItemid(), $xhtml );
	}
Ejemplo n.º 10
0
 /**
  * @param  OrderedTable  $row
  * @param  UserTable     $user
  * @param  stdClass      $model
  * @param  PluginTable   $plugin
  */
 static function showBlog($row, $user, $model, $plugin)
 {
     global $_CB_framework;
     $_CB_framework->setPageTitle($row->get('title'));
     $_CB_framework->appendPathWay(htmlspecialchars(CBTxt::T('Blogs')), $_CB_framework->userProfileUrl($row->get('user', $user->get('id')), true, 'cbblogsTab'));
     $_CB_framework->appendPathWay(htmlspecialchars($row->get('title')), $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'show', 'id' => (int) $row->get('id'))));
     $cbUser =& CBuser::getInstance((int) $row->get('user'), false);
     $return = '<div class="blowShow">' . '<div class="blogsTitle page-header"><h3>' . $row->get('title') . ' <small>' . CBTxt::T('WRITTEN_BY_BLOG_AUTHOR', 'Written by [blog_author]', array('[blog_author]' => $cbUser->getField('formatname', null, 'html', 'none', 'list', 0, true))) . '</small></h3></div>' . '<div class="blogsHeader well well-sm">' . CBTxt::T('CATEGORY_CATEGORY', 'Category: [category]', array('[category]' => $row->get('category'))) . ' &nbsp;/&nbsp; ' . CBTxt::T('CREATED_CREATED', 'Created: [created]', array('[created]' => cbFormatDate($row->get('created')))) . ($row->get('modified') && $row->get('modified') != '0000-00-00 00:00:00' ? ' &nbsp;/&nbsp; ' . CBTxt::T('MODIFIED_MODIFIED', 'Modified: [modified]', array('[modified]' => cbFormatDate($row->get('modified')))) : null) . '</div>' . '<div class="blogsText">' . $row->get('blog_intro') . $row->get('blog_full') . '</div>' . '</div>';
     echo $return;
 }
Ejemplo n.º 11
0
	/**
	 * @param  OrderedTable  $row
	 * @param  UserTable     $user
	 * @param  stdClass      $model
	 * @param  PluginTable   $plugin
	 */
	static function showconsultation( $row, $user, /** @noinspection PhpUnusedParameterInspection */ $model, $plugin, $bids )
	{
		global $_CB_framework;

		$_CB_framework->setPageTitle( $row->get( 'title' ) );
		$_CB_framework->appendPathWay( htmlspecialchars( CBTxt::T( 'consultations' ) ), $_CB_framework->userProfileUrl( $row->get( 'user', $user->get( 'id' ) ), true, 'cbconsultationsTab' ) );
		$_CB_framework->appendPathWay( htmlspecialchars( $row->get( 'title' ) ), $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'consultations', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ) );

		$cbUser			=&	CBuser::getInstance( (int) $row->get( 'user' ), false );

		$return			=	'<div class="blowShow">'
						.		'<div class="consultationsTitle page-header"><h3>' . $row->get( 'title' ) . ' <small>' . CBTxt::T( 'WRITTEN_BY_consultation_AUTHOR', 'Written by [consultation_author]', array( '[consultation_author]' => $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) ) ) . '</small></h3></div>'
						.		'<div class="consultationsHeader well well-sm">'
						.			CBTxt::T( 'CATEGORY_CATEGORY', 'Category: [category]', array( '[category]' => $row->get( 'category' ) ) )
						.			' &nbsp;/&nbsp; ' . CBTxt::T( 'CREATED_CREATED', 'Created: [created]', array( '[created]' => cbFormatDate( $row->get( 'created' ) ) ) )
						.			( $row->get( 'modified' ) && ( $row->get( 'modified' ) != '0000-00-00 00:00:00' ) ? ' &nbsp;/&nbsp; ' . CBTxt::T( 'MODIFIED_MODIFIED', 'Modified: [modified]', array( '[modified]' => cbFormatDate( $row->get( 'modified' ) ) ) ) : null )
						.		'</div>'
						.		'<div class="consultationsText">' . $row->get( 'consultation_intro' ) . $row->get( 'consultation_full' ) . '</div>'
						.	'</div>';
    if($bids!=null){
      $return .= '<script >
          window.___gcfg = {
                  lang: \'ru\',
                          parsetags: \'onload\'
                              };
                              </script>

<script src="https://apis.google.com/js/platform.js" async defer></script>
';
      $return .= '<h2>Ставки</h2>';
      if(empty($bids)){
        $return .= "Нет ставок";
      }else{
        $return .= '<table cellspacing="5" class="consultationsContainer table table-hover table-responsive">';
        $return .= '<tr><th>Дата</th><th>Пользователь</th><th>e-mail</th><th>Цена</th><th></th></tr>';
        foreach($bids as $key=>$value){
          $return .='<tr>';
          $return .= '<td>'.$value->bid_date.'</td>';
          $return .= '<td>'.$value->name.'</td>';
          $return .= '<td>'.$value->email.'</td>';
          $return .= '<td>$'.$value->bid_price.'</td>';
          $return .= '<td>';
          if($key==0){
            //Old version was using Goolge Hangouts for communications.
            //$return .= '<g:hangout render="createhangout" hangout_type="normal" topic="'.addslashes($row->get('title')).'"
            //           invites="[{ id : \''.$value->email.'\', invite_type : \'EMAIL\' }]">
            //           </g:hangout>';
            //New version is using CloudInterpreter
            $return .= '<a target="_blank" href="http://dev.cloudinterpreter.com:8901/'.md5($row->get('id')).'"><button class="btn btn-success">Начать консультацию</button></a>';
          }
          $return .= '</td>';
          $return .='</tr>';
        }
        $return .= '</table>';
      }
		}
    echo $return;
	}
 /**
  * Replaces CB variables and general variables left.
  * 
  * @param  string       $numberFormat  Format for the replacements
  * @param  int          $user_id       User id for user-variables replacements
  * @param  array        $extraStrings  Set of extra-strings for additional replacements
  * @return string|null
  */
 protected static function replaceCbVars($numberFormat, $user_id, $extraStrings)
 {
     global $_CB_framework;
     if ($numberFormat) {
         list($year, $month, $day) = self::_getYearMonthDay();
         $uniqid = uniqid('');
         $extraExtraStrings = array('YEAR' => $year, 'YEARSHORT' => substr($year, 2), 'MONTH' => $month, 'DAY' => $day, 'SITENAME' => $_CB_framework->getCfg('sitename'), 'SITEURL' => $_CB_framework->getCfg('live_site'), 'UNIQ_ID' => hexdec(substr($uniqid, 7)) . hexdec(substr($uniqid, 0, 7)), 'GROWING_ID' => $uniqid);
         return trim(CBuser::getInstance($user_id)->replaceUserVars($numberFormat, false, false, array_merge($extraExtraStrings, $extraStrings), false));
     } else {
         return null;
     }
 }
	/**
	 * @param null      $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @param array     $postdata
	 */
	public function getCBpluginComponent( $tab, $user, $ui, $postdata )
	{
		global $_CB_framework;

		outputCbJs( 1 );
		outputCbTemplate( 1 );

		$action					=	$this->input( 'action', null, GetterInterface::STRING );
		$function				=	$this->input( 'func', null, GetterInterface::STRING );
		$id						=	$this->input( 'id', null, GetterInterface::INT );
		$user					=	CBuser::getMyUserDataInstance();

		$tab					=	new TabTable();

		$tab->load( array( 'pluginclass' => 'cbinvitesTab' ) );

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

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

		ob_start();
		switch ( $action ) {
			case 'preparaty':
				switch ( $function ) {
					
					case 'delete':
						$this->deletePreparaty( $id, $user );
						break;

				}
				break;
			default:
				cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
				break;
		}
		$html					=	ob_get_contents();
		ob_end_clean();

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

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

		echo $return;
	}
Ejemplo n.º 14
0
	/**
	 * @param cbantispamWhitelistTable $row
	 * @param array                    $input
	 * @param string                   $type
	 * @param int|string               $tab
	 * @param UserTable                $user
	 * @param cbPluginHandler          $plugin
	 */
	static public function showWhitelist( $row, $input, $type, $tab, $user, $plugin )
	{
		global $_CB_framework;

		cbValidator::loadValidation();

		$name			=	CBuser::getInstance( (int) $user->get( 'id' ), false )->getField( 'formatname', null, 'html', 'none', 'profile', 0, true );
		$pageTitle		=	CBTxt::T( 'WHITELIST_NAME', 'Whitelist [name]', array( '[name]' => $name ) );

		$_CB_framework->setPageTitle( $pageTitle );
		$_CB_framework->appendPathWay( htmlspecialchars( CBTxt::T( 'Whitelists' ) ), $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, $tab ) );
		$_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'whitelist', 'func' => ( $type ? $type : 'edit' ), 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ) ) : array( 'action' => 'whitelist', 'func' => ( $type ? $type : 'new' ), 'usr' => (int) $user->get( 'id' ) ) ) ) );

		$return			=	'<div class="whitelistEdit">'
						.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'whitelist', 'func' => 'save', 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="whitelistForm" id="whitelistForm" class="cb_form whitelistForm form-auto cbValidation">'
						.			( $pageTitle ? '<div class="whitelistTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null )
						.			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.				'<label for="type" class="col-sm-3 control-label">' . CBTxt::T( 'Type' ) . '</label>'
						.				'<div class="cb_field col-sm-9">'
						.					$input['type']
						.					getFieldIcons( 1, 1, null, CBTxt::T( 'Select the whitelist type. Type determines what value should be supplied.' ) )
						.				'</div>'
						.			'</div>'
						.			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
						.				'<label for="value" class="col-sm-3 control-label">' . CBTxt::T( 'Value' ) . '</label>'
						.				'<div class="cb_field col-sm-9">'
						.					$input['value']
						.					getFieldIcons( 1, 1, null, CBTxt::T( 'Input whitelist value in relation to the type. User type use the users user_id (e.g. 42). IP Address type use a full valid IP Address (e.g. 192.168.0.1). Email type use a fill valid email address (e.g. invalid@cb.invalid). Email Domain type use a full email address domain after @ (e.g. example.com).' ) )
						.				'</div>'
						.			'</div>'
						.			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
						.				'<label for="reason" class="col-sm-3 control-label">' . CBTxt::T( 'Reason' ) . '</label>'
						.				'<div class="cb_field col-sm-9">'
						.					$input['reason']
						.					getFieldIcons( 1, 0, null, CBTxt::T( 'Optionally input whitelist reason. Note this is for administrative purposes only.' ) )
						.				'</div>'
						.			'</div>'
						.			'<div class="form-group cb_form_line clearfix">'
						.				'<div class="col-sm-offset-3 col-sm-9">'
						.					'<input type="submit" value="' . htmlspecialchars( ( $row->get( 'id' ) ? CBTxt::T( 'Update Whitelist' ) : CBTxt::T( 'Create Whitelist' ) ) ) . '" class="whitelistButton whitelistButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />&nbsp;'
						.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="whitelistButton whitelistButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $tab ) . '\'; }" />'
						.				'</div>'
						.			'</div>'
						.			cbGetSpoofInputTag( 'plugin' )
						.		'</form>'
						.	'</div>';

		echo $return;
	}
Ejemplo n.º 15
0
 /**
  * Cleans the field value by type in a secure way for SQL
  *
  * @param  mixed                    $fieldValue
  * @param  string                   $type           const,sql,param : string,int,float,datetime,formula
  * @param  GetterInterface          $pluginParams
  * @param  DatabaseDriverInterface  $db
  * @param  array|null               $extDataModels
  * @return string|boolean                           STRING: sql-safe value, Quoted or type-casted to int or float, or FALSE in case of type error
  */
 public static function sqlCleanQuote($fieldValue, $type, GetterInterface $pluginParams, DatabaseDriverInterface $db, array $extDataModels = null)
 {
     $typeArray = explode(':', $type, 3);
     if (count($typeArray) < 2) {
         $typeArray = array('const', $type);
     }
     if ($typeArray[0] == 'param') {
         $fieldValue = $pluginParams->get($fieldValue);
     } elseif ($typeArray[0] == 'user') {
         // TODO: Change this to use Inversion Of Control, and allow XML valuetypes to be extended dynamically (e.g. instead of calling specifically CBLib\CB\User or similar when available, it is CB that adds the type and a closure to handle that type.
         if ($fieldValue == 'viewaccesslevels') {
             $fieldValue = Application::MyUser()->getAuthorisedViewLevels();
         } else {
             if ($fieldValue == 'usergroups') {
                 $fieldValue = Application::MyUser()->getAuthorisedGroups(false);
             } else {
                 $fieldValue = \CBuser::getMyUserDataInstance()->get($fieldValue);
             }
         }
     } elseif (in_array($typeArray[0], array('request', 'get', 'post', 'cookie', 'cbcookie', 'session', 'server', 'env'))) {
         $fieldValue = self::_globalConv($typeArray[0], $fieldValue);
     } elseif ($typeArray[0] == 'ext') {
         if (isset($typeArray[2]) && $extDataModels && isset($extDataModels[$typeArray[2]])) {
             $model = $extDataModels[$typeArray[2]];
             if (is_object($model)) {
                 if ($model instanceof ParamsInterface) {
                     $fieldValue = $model->get($fieldValue);
                 } elseif (isset($model->{$fieldValue})) {
                     $fieldValue = $model->{$fieldValue};
                 }
             } elseif (is_array($model)) {
                 if (isset($model[$fieldValue])) {
                     $fieldValue = $model[$fieldValue];
                 }
             } else {
                 $fieldValue = $model;
             }
         } else {
             trigger_error('SQLXML::sqlCleanQuote: ERROR: ext valuetype "' . htmlspecialchars($type) . '" has not been setExternalDataTypeValues.', E_USER_NOTICE);
         }
         // } elseif ( ( $typeArray[0] == 'const' ) || ( $cnt_valtypeArray[0] == 'sql' ) {
         //	$fieldValue	=	$fieldValue;
     }
     if (is_array($fieldValue)) {
         return self::cleanArrayType($fieldValue, $typeArray[1], $db);
     }
     return self::cleanScalarType($fieldValue, $typeArray[1], $db);
 }
Ejemplo n.º 16
0
	/**
	 * Builds and sends e-mail
	 *
	 * @param UserTable  $user
	 * @param string     $mailFrom_email
	 * @param string     $mailFrom_name
	 * @param string     $mailTo
	 * @param string     $mailSubject
	 * @param string     $mailBody
	 * @param string     $mailHtml
	 * @param string     $mailCC
	 * @param string     $mailBCC
	 * @param string     $mailAttachments
	 * @param string[]   $extraStrings
	 * @return void
	 */
	protected function sendMail( $user, $mailFrom_email, $mailFrom_name, $mailTo, $mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments, $extraStrings ) {
		global $_CB_framework;

		cbimport( 'cb.tabs' );

		$cbUser					=	CBuser::getInstance( $user->id );

		if ( ! $cbUser ) {
			return;
		}

		$mailFrom_email			=	trim( $cbUser->replaceUserVars( $mailFrom_email, false, false, array(), false ) );
		$mailFrom_name			=	trim( $cbUser->replaceUserVars( $mailFrom_name, false, false, array(), false ) );
		$mailTo					=	trim( $cbUser->replaceUserVars( $mailTo, false, false, array(), false ) );
		$mailCC					=	trim( $cbUser->replaceUserVars( $mailCC, false, false, array(), false ) );
		$mailBCC				=	trim( $cbUser->replaceUserVars( $mailBCC, false, false, array(), false ) );
		$mailSubject			=	trim( $cbUser->replaceUserVars( CBPTXT::T( $mailSubject ), false, false, $extraStrings, false ) );
		$mailBody				=	trim( $cbUser->replaceUserVars( CBPTXT::T( $mailBody ), false, false, $extraStrings, false ) );
		$mailAttachments		=	trim( $mailAttachments );

		if ( $mailTo != '' ) {
			$mailTo				=	preg_split( '/ *, */', $mailTo );
		} else {
			return;
		}

		if ( $mailCC != '' ) {
			$mailCC				=	preg_split( '/ *, */', $mailCC );
		} else {
			$mailCC				=	null;
		}

		if ( $mailBCC != '' ) {
			$mailBCC			=	preg_split( '/ *, */', $mailBCC );
		} else {
			$mailBCC			=	null;
		}

		if ( $mailAttachments != '' ) {
			$mailAttachments	=	preg_split( '/ *, */', $mailAttachments );
		} else {
			$mailAttachments	=	null;
		}

		if ( $mailTo && ( $mailSubject || $mailBody ) ) {
			comprofilerMail( $mailFrom_email, $mailFrom_name, $mailTo, $_CB_framework->getCfg( 'sitename' ).' - '.$mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments );
		}
	}
Ejemplo n.º 17
0
 protected function getCBUserid()
 {
     global $_CB_framework;
     $cbpath = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
     if (file_exists($cbpath)) {
         require_once $cbpath;
     } else {
         return null;
     }
     $userid = $_CB_framework->myId();
     $cbUser = CBuser::getInstance((int) $userid);
     if ($cbUser === null) {
         return null;
     }
     return $userid;
 }
Ejemplo n.º 18
0
	function editUser( $uid = '0', $option = 'users' ) {
		global $_CB_framework, $_PLUGINS;

		$this->_importNeeded();

		$msg						=	checkCBpermissions( array($uid), "edit", true );
		if ($msg) {
			echo "<script type=\"text/javascript\"> alert('".$msg."'); window.history.go(-1);</script>\n";
			exit;
		}
	
		$_PLUGINS->loadPluginGroup('user');
	
		$cbUser						=&	CBuser::getInstance( $uid );
		$cmsUserExists				=	( $uid != 0 ) && ( $cbUser !== null );
		if ( ! $cmsUserExists ) {
			$cbUser					=&	CBuser::getInstance( null );
		}
		$user						=&	$cbUser->getUserData();
	/*
		$user						=	new moscomprofilerUser( $_CB_database );
		$cmsUserExists				=	$user->load( (int) $uid );
	*/
		$comprofilerExists			=	( $user->user_id != null );
		if ( $cmsUserExists && $comprofilerExists ) {
			// Edit existing CB user:
			$newCBuser				=	'******';
		} else {
			$newCBuser				=	'******';
			if ( $cmsUserExists ) {
				// Edit existing CMS (but new CB) user:
				$user->approved		=	'1';
				$user->confirmed	=	'1';
			} else {
				// New user:
				$user->block		=	'0';
				$user->approved		=	'1';
				$user->confirmed	=	'1';
				$user->sendEmail	=	'0';
				$user->gid			=	$_CB_framework->acl->get_group_id( $_CB_framework->getCfg( 'new_usertype' ), 'ARO' );
				$user->gids			=	array( $user->gid );
			}
		}
		$null						=	null;
		$usersView					=	_CBloadView( 'user' );
		$usersView->edituser( $user, $option, $newCBuser, $null );
	}
Ejemplo n.º 19
0
	public function getInboxLink ($text) {
		if (!$text) $text = JText::_('COM_KUNENA_PMS_INBOX');
		global $_CB_framework;

		$cbpath = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
		if (file_exists($cbpath)) require_once($cbpath);
		else return;

		$userid = $_CB_framework->myId();

		$cbUser =& CBuser::getInstance( (int) $userid );
		if($cbUser === null) return;

		$itemid = getCBprofileItemid();

		return CKunenaLink::GetHrefLink ( cbSef ('index.php?option=com_comprofiler&task=userProfile&user='******'', 'follow');
	}
Ejemplo n.º 20
0
 public function check()
 {
     if ($this->get('title') == '') {
         $this->setError(CBTxt::T('Title not specified!'));
         return false;
     } elseif (!$this->get('user')) {
         $this->setError(CBTxt::T('User not specified!'));
         return false;
     } elseif ($this->get('user') && !CBuser::getUserDataInstance((int) $this->get('user'))->id) {
         $this->setError(CBTxt::T('User specified does not exist!'));
         return false;
     } elseif ($this->get('access') === '') {
         $this->setError(CBTxt::T('Access not specified!'));
         return false;
     } elseif ($this->get('category') === '') {
         $this->setError(CBTxt::T('Category not specified!'));
         return false;
     } elseif (!in_array($this->get('category'), cbblogsModel::getCategoriesList(true))) {
         $this->setError(CBTxt::T('Category not allowed!'));
         return false;
     }
     return true;
 }
Ejemplo n.º 21
0
	/**
	 * Constructor for stream object
	 *
	 * @param null|string    $source
	 * @param null|UserTable $user
	 */
	public function __construct( $source = null, $user = null )
	{
		global $_PLUGINS;

		parent::__construct();

		$_PLUGINS->loadPluginGroup( 'user' );

		if ( $source === null ) {
			$source			=	'stream';
		}

		if ( $user === null ) {
			$user			=	\CBuser::getMyUserDataInstance();
		}

		$this->source		=	$source;
		$this->user			=	$user;

		if ( ! $this->id ) {
			$this->id		=	uniqid();
		}
	}
Ejemplo n.º 22
0
 /**
  * Saves legacy user edit display
  *
  * @param string $option
  * @param string $task
  */
 public function saveUser($option, $task = 'save')
 {
     global $_CB_framework, $_CB_Backend_task, $_POST, $_PLUGINS;
     cbimport('language.all');
     cbimport('cb.tabs');
     cbimport('cb.params');
     cbimport('cb.adminfilesystem');
     cbimport('cb.imgtoolbox');
     $userIdPosted = (int) cbGetParam($_POST, 'id', 0);
     if ($userIdPosted == 0) {
         $_POST['id'] = null;
     }
     $msg = $this->_authorizedEdit($userIdPosted);
     if (!$msg) {
         if ($userIdPosted != 0) {
             $msg = checkCBpermissions(array($userIdPosted), 'save', true);
         } else {
             $msg = checkCBpermissions(null, 'save', true);
         }
     }
     if ($userIdPosted != 0) {
         $_PLUGINS->trigger('onBeforeUserProfileSaveRequest', array($userIdPosted, &$msg, 2));
     }
     if ($msg) {
         cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
     }
     $_PLUGINS->loadPluginGroup('user');
     // Get current user state:
     if ($userIdPosted != 0) {
         $userComplete = CBuser::getUserDataInstance($userIdPosted);
         if (!($userComplete && $userComplete->id)) {
             cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('Your profile could not be updated.'), 'error');
         }
     } else {
         $userComplete = new UserTable();
     }
     // Store new user state:
     $saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit');
     if (!$saveResult) {
         $regErrorMSG = $userComplete->getError();
         $msg = checkCBpermissions(array((int) $userComplete->id), 'edit', true);
         if ($userIdPosted != 0) {
             $_PLUGINS->trigger('onBeforeUserProfileEditRequest', array((int) $userComplete->id, &$msg, 2));
         }
         if ($msg) {
             cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
         }
         if ($userIdPosted != 0) {
             $_PLUGINS->trigger('onAfterUserProfileSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
         } else {
             $_PLUGINS->trigger('onAfterUserRegistrationSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
         }
         $_CB_framework->enqueueMessage($regErrorMSG, 'error');
         $_CB_Backend_task = 'edit';
         // so the toolbar comes up...
         $_PLUGINS->loadPluginGroup('user');
         // resets plugin errors
         $userView = _CBloadView('user');
         /** @var CBController_user $userView */
         $userView->edituser($userComplete, $option, $userComplete->user_id != null ? 0 : 1, $_POST);
         return;
     }
     // Checks-in the row:
     $userComplete->checkin();
     if ($userIdPosted != 0) {
         $_PLUGINS->trigger('onAfterUserProfileSaved', array(&$userComplete, 2));
     } else {
         $messagesToUser = array();
         $_PLUGINS->trigger('onAfterSaveUserRegistration', array(&$userComplete, &$messagesToUser, 2));
     }
     if ($task == 'apply') {
         cbRedirect($_CB_framework->backendViewUrl('edit', false, array('cid' => (int) $userComplete->user_id)), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
     } else {
         cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
     }
 }
Ejemplo n.º 23
0
 /**
  * @param  string     $message
  * @param  UserTable  $row
  * @param  int        $mode
  * @param  array      $extras
  * @return string
  */
 public function _replaceVariables($message, $row, $mode = 0, $extras = array())
 {
     global $_CB_framework, $ueConfig;
     // Always build the confirm link for substitution:
     $confirmLink = $_CB_framework->rawViewUrl('confirm', false, array('confirmcode' => $row->cbactivation));
     // Lets build the confirm output only if confirmation is enabled:
     if ($ueConfig['reg_confirmation'] == 1) {
         if ($row->confirmed) {
             $confirm = "\n" . CBTxt::T('UE_USER_EMAIL_CONFIRMED', 'Email address is already confirmed') . "\n";
         } else {
             $confirm = "\n" . $confirmLink . "\n";
         }
     } else {
         $confirm = null;
     }
     // Lets fix linebreaks encase the message was sent as a plain string:
     $message = str_replace(array('\\r\\n', '\\n'), array("\r\n", "\n"), $message);
     // Prepare default substitution extras (note how we push some normal substitutions as extras so non-existing users can still substitute information):
     $extraStrings = array('emailaddress' => $row->email, 'email' => $row->email, 'formatname' => getNameFormat($row->name, $row->username, $ueConfig['name_format']), 'name' => $row->name, 'username' => $row->username, 'details' => $this->_getUserDetails($row, isset($ueConfig['emailpass']) ? $ueConfig['emailpass'] : 0), 'confirm' => $confirm, 'confirmlink' => $confirmLink, 'sitename' => $_CB_framework->getCfg('sitename'), 'siteurl' => $_CB_framework->getCfg('live_site'));
     // Combine default substitutions with extras supplied:
     if ($extras && is_array($extras)) {
         $extraStrings = array_merge($extraStrings, $extras);
     }
     if ($row instanceof UserTable && $row->id) {
         return CBuser::getInstance($row->id)->replaceUserVars($message, true, true, $extraStrings, false);
     }
     return cbReplaceVars($message, $row, $mode, true, $extraStrings, false);
 }
 /**
  * CB messaging anti-spam protection for maximum messages per time-frame
  *
  * @param  int          $userId       User id
  * @param  boolean      $count        Should it increment the number of messages or just check ?
  * @param  boolean      $allowPublic  Should public messaging also be allowed ?
  * @return null|string
  */
 function cbSpamProtect($userId, $count, $allowPublic = false)
 {
     global $_CB_framework, $_CB_database, $ueConfig;
     $maxEmailsPerHr = isset($ueConfig['maxEmailsPerHr']) ? (int) $ueConfig['maxEmailsPerHr'] : 10;
     // mails per
     $maxInterval = 24 * 3600;
     // hours (expressed in seconds) limit
     $time = time();
     if (!$userId && $allowPublic) {
         $messageNumberSent = (int) $_CB_framework->getUserState('cb_message_number_sent', 0);
         $messageLastSent = $_CB_framework->getUserState('cb_message_last_sent', '0000-00-00 00:00:00');
         $canSendMessage = true;
     } else {
         $user = CBuser::getUserDataInstance((int) $userId);
         if ($user) {
             $messageNumberSent = (int) $user->message_number_sent;
             $messageLastSent = $user->message_last_sent;
             $canSendMessage = true;
         } else {
             $messageNumberSent = 0;
             $messageLastSent = '0000-00-00 00:00:00';
             $canSendMessage = false;
         }
     }
     if ($canSendMessage) {
         if ($messageLastSent != '0000-00-00 00:00:00') {
             list($y, $c, $d, $h, $m, $s) = sscanf($messageLastSent, "%4d-%2d-%2d\t%2d:%2d:%2d");
             $expiryTime = gmmktime($h, $m, $s, $c, $d, $y) + $maxInterval;
             if ($time < $expiryTime) {
                 if ($messageNumberSent >= $maxEmailsPerHr) {
                     return CBTxt::Th('UE_MAXEMAILSLIMIT', 'You exceeded the maximum limit of ||one email|%%NUMBERMAILSPERHOUR%% emails|| per hour| every %%NUMBERHOURS%% hours||. Please try again later.', array('%%NUMBERMAILSPERHOUR%%' => $maxEmailsPerHr, '%%NUMBERHOURS%%' => round($maxInterval / 3600)));
                 } else {
                     if ($count) {
                         if ($userId) {
                             $query = 'UPDATE ' . $_CB_database->NameQuote('#__comprofiler') . "\n SET " . $_CB_database->NameQuote('message_number_sent') . " = " . (int) ($messageNumberSent + 1) . "\n WHERE " . $_CB_database->NameQuote('id') . " = " . (int) $userId;
                             $_CB_database->setQuery($query);
                             $_CB_database->query();
                         } else {
                             $_CB_framework->setUserState('cb_message_number_sent', $messageNumberSent + 1);
                         }
                     }
                 }
             } else {
                 if ($count) {
                     if ($userId) {
                         $query = 'UPDATE ' . $_CB_database->NameQuote('#__comprofiler') . "\n SET " . $_CB_database->NameQuote('message_number_sent') . " = 1" . ', ' . $_CB_database->NameQuote('message_last_sent') . ' = ' . $_CB_database->Quote($_CB_framework->getUTCDate()) . "\n WHERE " . $_CB_database->NameQuote('id') . " = " . (int) $userId;
                         $_CB_database->setQuery($query);
                         $_CB_database->query();
                     } else {
                         $_CB_framework->setUserState('cb_message_number_sent', 1);
                         $_CB_framework->setUserState('cb_message_last_sent', $_CB_framework->getUTCDate());
                     }
                 }
             }
         } else {
             if ($count) {
                 if ($userId) {
                     $query = 'UPDATE ' . $_CB_database->NameQuote('#__comprofiler') . "\n SET " . $_CB_database->NameQuote('message_number_sent') . " = 1" . ', ' . $_CB_database->NameQuote('message_last_sent') . ' = ' . $_CB_database->Quote($_CB_framework->getUTCDate()) . "\n WHERE " . $_CB_database->NameQuote('id') . " = " . (int) $userId;
                     $_CB_database->setQuery($query);
                     $_CB_database->query();
                 } else {
                     $_CB_framework->setUserState('cb_message_number_sent', 1);
                     $_CB_framework->setUserState('cb_message_last_sent', $_CB_framework->getUTCDate());
                 }
             }
         }
         return null;
     } else {
         return 'Not Authorized';
     }
 }
	/**
	 * save invite
	 *
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function saveInviteEdit( $id, $user )
	{
		global $_CB_framework, $_CB_database, $_PLUGINS;

		$row							=	new InviteTable();

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

		$isModerator					=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$groupId						=	$this->input( 'group', null, GetterInterface::INT );

		if ( $groupId === null ) {
			$group						=	$row->group();
		} else {
			$group						=	CBGroupJive::getGroup( $groupId );
		}

		$returnUrl						=	$_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) );

		if ( ! CBGroupJive::canAccessGroup( $group, $user ) ) {
			cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' );
		} elseif ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) ) {
			cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this invite.' ), 'error' );
		} elseif ( ! $isModerator ) {
			if ( ( $group->get( 'published' ) == -1 ) || ( ( ! $this->params->get( 'groups_invites_display', 1 ) ) && ( $group->get( 'type' ) != 3 ) ) ) {
				cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to invites in this group.' ), 'error' );
			} elseif ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'invites' ) ) ) {
				cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create an invite in this group.' ), 'error' );
			}
		}

		$skipCaptcha					=	false;

		$row->set( 'message', $this->input( 'post/message', $row->get( 'message' ), GetterInterface::STRING ) );

		if ( ! $row->get( 'id' ) ) {
			$row->set( 'user_id', (int) $row->get( 'user_id', $user->get( 'id' ) ) );
			$row->set( 'group', (int) $group->get( 'id' ) );

			$to							=	$this->input( 'post/to', null, GetterInterface::STRING );
			$selected					=	(int) $this->input( 'post/selected', 0, GetterInterface::INT );

			if ( $selected ) {
				$token					=	$this->input( 'post/token', null, GetterInterface::STRING );

				if ( $token ) {
					if ( $token == md5( $row->get( 'user_id' ) . $to . $row->get( 'group' ) . $row->get( 'message' ) . $_CB_framework->getCfg( 'secret' ) ) ) {
						$skipCaptcha	=	true;

						$row->set( 'user', (int) $selected );
					}
				} elseif ( $this->params->get( 'groups_invites_list', 0 ) ) {
					$connections		=	array();
					$cbConnection		=	new cbConnection( (int) $user->get( 'id' ) );

					foreach( $cbConnection->getConnectedToMe( (int) $user->get( 'id' ) ) as $connection ) {
						$connections[]	=	(int) $connection->id;
					}

					if ( in_array( $selected, $connections ) ) {
						$row->set( 'user', (int) $selected );
					}
				}
			} else {
				$inviteByLimit			=	explode( '|*|', $this->params->get( 'groups_invites_by', '1|*|2|*|3|*|4' ) );

				if ( ! $inviteByLimit ) {
					$inviteByLimit		=	array( 1, 2, 3, 4 );
				}

				$recipient				=	new UserTable();

				if ( in_array( 1, $inviteByLimit ) && $recipient->load( (int) $to ) ) {
					$row->set( 'user', (int) $recipient->get( 'id' ) );
				} elseif ( in_array( 4, $inviteByLimit ) && cbIsValidEmail( $to ) ) {
					if ( $recipient->load( array( 'email' => $to ) ) ) {
						$row->set( 'user', (int) $recipient->get( 'id' ) );
					} else {
						$row->set( 'email', $to );
					}
				} elseif ( in_array( 2, $inviteByLimit ) && $recipient->load( array( 'username' => $to ) ) ) {
					$row->set( 'user', (int) $recipient->get( 'id' ) );
				} elseif ( in_array( 3, $inviteByLimit ) ) {
					$query				=	'SELECT cb.' . $_CB_database->NameQuote( 'id' )
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
										.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
										.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
										.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
										.	' ON u.' . $_CB_database->NameQuote( 'user_id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
										.	' AND u.' . $_CB_database->NameQuote( 'group' ) . ' = ' . (int) $group->get( 'id' )
										.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
										.	' ON i.' . $_CB_database->NameQuote( 'group' ) . ' = ' . (int) $group->get( 'id' )
										.	' AND i.' . $_CB_database->NameQuote( 'user' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
										.	"\n WHERE j." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $to, true ) . '%', false )
										.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
										.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
										.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0"
										.	"\n AND u." . $_CB_database->NameQuote( 'id' ) . " IS NULL"
										.	"\n AND i." . $_CB_database->NameQuote( 'id' ) . " IS NULL"
										.	"\n ORDER BY j." . $_CB_database->NameQuote( 'registerDate' ) . " DESC";
					$_CB_database->setQuery( $query, 0, 15 );
					$users				=	$_CB_database->loadResultArray();

					if ( $users ) {
						if ( count( $users ) > 1 ) {
							CBGroupJive::getTemplate( 'invite_list' );

							CBuser::advanceNoticeOfUsersNeeded( $users );

							HTML_groupjiveInviteList::showInviteList( $to, $users, $row, $group, $user, $this );
							return;
						} else {
							$row->set( 'user', (int) $users[0] );
						}
					}
				}
			}
		}

		if ( ( ! $isModerator ) && $this->params->get( 'groups_create_captcha', 0 ) && ( ! $skipCaptcha ) ) {
			$_PLUGINS->loadPluginGroup( 'user' );

			$_PLUGINS->trigger( 'onCheckCaptchaHtmlElements', array() );

			if ( $_PLUGINS->is_errors() ) {
				$row->setError( $_PLUGINS->getErrorMSG() );
			}
		}

		$new							=	( $row->get( 'id' ) ? false : true );

		if ( $row->getError() || ( ! $row->check() ) ) {
			$_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_INVITE_FAILED_TO_SAVE', 'Invite failed to save! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' );

			$this->showInviteEdit( $id, $user );
			return;
		}

		if ( $row->getError() || ( ! $row->store() ) ) {
			$_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_INVITE_FAILED_TO_SAVE', 'Invite failed to save! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' );

			$this->showInviteEdit( $id, $user );
			return;
		}

		if ( $new ) {
			cbRedirect( $returnUrl, CBTxt::T( 'Invite created successfully!' ) );
		} else {
			cbRedirect( $returnUrl, CBTxt::T( 'Invite saved successfully!' ) );
		}
	}
 /**
  * Checks for upgrade or renewal possibilities
  *
  * @param  int                   $ui                     1=frontend, 2=backend
  * @param  int                   $user_id
  * @param  int                   $now                    system unix time
  * @param  cbpaidUsersubscriptionRecord[]  $subscriptionsReturned  RETURNED: current subscriptions
  *                                                               with ->status = 'A' for active ones and 'X' for expired ones. 'R' unpaid, 'C' cancelled.
  * @param  array|null            $plansToShowOnly        array of specific plan numbers to show (so we add these plans if allowed and not spontaneous in frontend
  * @param  int                   $subsAccess             0 has only read access, 1 has user access, 2 reserved for future Super-admin access
  * @param  boolean               $plansToShowOnlyDoIncludeChildren  Include children with plansToShowOnly
  * @return cbPaidProduct[]                               upgrade possibilities including _renewalDiscount in plan's currency
  */
 public function getUpgradeAndRenewalPossibilities($ui, $user_id, $now, &$subscriptionsReturned, $plansToShowOnly = null, $subsAccess = 1, $plansToShowOnlyDoIncludeChildren = false)
 {
     global $_CB_database, $_CB_framework;
     if (!isset($this->_upgradesCache[$user_id])) {
         $quantity = 1;
         //TBD later !
         $paidUserExtension = cbpaidUserExtension::getInstance($user_id);
         $subscriptions = $paidUserExtension->getUserSubscriptions(null, true);
         $user = CBuser::getUserDataInstance((int) $user_id);
         $plansMgr = cbpaidPlansMgr::getInstance();
         $plans = $plansMgr->loadPublishedPlans($user, true, 'any', null);
         //TBD LATER: upgrades limiting owners
         $params = cbpaidApp::settingsParams();
         $enableFreeRegisteredUser = $params->get('enableFreeRegisteredUser', 1);
         $createAlsoFreeSubscriptions = $params->get('createAlsoFreeSubscriptions', 0);
         $noValidSubscriptionFound = true;
         $subscriptionsUpgradePlansIdsDiscount = array();
         // array: [$k][$upgrade_plan->id]=discountedPrice  where $l is index in $subscriptions
         $activeExclusiveSubChild = array();
         // array: [$parentPlanId] = true
         $notProposedParents = array();
         foreach (array_keys($subscriptions) as $k) {
             // for each user subscription:
             // 1. check if it's plan can be shown as an extra subscription possibility and/or upgrade,
             $subscriptions[$k]->checkRenewalUpgrade($ui, $user, $quantity, $now, $subsAccess);
             // 2. don't propose subscription which can not be shown to the user
             if ($subscriptions[$k]->_hideItsPlan && isset($plans[$subscriptions[$k]->plan_id])) {
                 $plans[$subscriptions[$k]->plan_id]->_drawOnlyAsContainer = true;
                 // $notProposedParents[$subscriptions[$k]->plan_id]				=	true;
             }
             if (($subscriptions[$k]->_hideThisSubscription || !$subscriptions[$k]->checkIfValid($now)) && (isset($plans[$subscriptions[$k]->plan_id]) && $plans[$subscriptions[$k]->plan_id]->get('multiple') == 0)) {
                 foreach (array_keys($plans) as $pk) {
                     // hidden or inactive subscription: do not display any of its children plans as upgrade possibility:
                     if ($plans[$pk]->get('parent') == $subscriptions[$k]->plan_id) {
                         $plans[$pk]->_drawOnlyAsContainer = true;
                         $notProposedParents[$pk] = true;
                     }
                 }
             }
             if ($subscriptions[$k]->_hideThisSubscription) {
                 unset($subscriptions[$k]);
             } elseif ($subscriptions[$k]->checkIfValid($now)) {
                 // 3. all upgrade possibilities of this subscription
                 $noValidSubscriptionFound = false;
                 $subscriptionsUpgradePlansIdsDiscount[$k] = $subscriptions[$k]->_upgradePlansIdsDiscount;
                 if ($subscriptions[$k]->getPlanAttribute('exclusive') == 1) {
                     $activeExclusiveSubChild[$subscriptions[$k]->getPlanAttribute('parent')] = true;
                 }
             } else {
             }
         }
         // add to each plan the subscriptions which can be upgraded: plan, subscription and price:
         foreach (array_keys($plans) as $pk) {
             foreach ($subscriptionsUpgradePlansIdsDiscount as $k => $upgradePlansDiscount) {
                 foreach ($upgradePlansDiscount as $planId => $discountedPrice) {
                     if ($plans[$pk]->get('id') == $planId) {
                         $plans[$pk]->_subscriptionToUpdate = array($subscriptions[$k]->plan_id, $subscriptions[$k]->id);
                         $plans[$pk]->_renewalDiscount = $discountedPrice;
                     }
                 }
             }
         }
         // finally remove all plans not allowed for upgrade and
         // also all exclusive plans which can't be upgraded to by no subscription
         // (already subscribed plans have already been removed by plan's _hideItsPlan instructions):
         // also memorize them as removed parent, so that children are not proposed either:
         foreach (array_keys($plans) as $pk) {
             $exclPlan = $plans[$pk]->get('exclusive');
             $resultTexts = array();
             // remove plans not listed by default and not specifically selected:
             if (!$plans[$pk]->isPlanAllowingUpgradesToThis($user_id, $resultTexts) || $plans[$pk]->get('propose_upgrade') != 1 && $ui != 2 && !($plansToShowOnly && (in_array($pk, $plansToShowOnly) || $plansToShowOnlyDoIncludeChildren && in_array($plans[$pk]->get('parent'), $plansToShowOnly))) || $exclPlan == 1 && $plans[$pk]->get('multiple') == 0 && isset($activeExclusiveSubChild[$plans[$pk]->get('parent')]) && $plans[$pk]->_subscriptionToUpdate === null) {
                 // if ( $ui == 1 ) {	// when we are in frontend:
                 if (!(isset($plans[$pk]->_drawOnlyAsContainer) && $plans[$pk]->_drawOnlyAsContainer)) {
                     $plans[$pk]->_drawOnlyAsContainer = true;
                     $notProposedParents[$pk] = true;
                 }
             }
         }
         // very finally remove also children of non-authorized parent plans:
         // second case is that parent plan isn't published:
         foreach (array_keys($plans) as $pk) {
             $parentPlanId = $plans[$pk]->get('parent');
             if ($parentPlanId && (isset($notProposedParents[$parentPlanId]) || !isset($plans[$parentPlanId]))) {
                 $plans[$pk]->_drawOnlyAsContainer = true;
             }
         }
         // If no sbscriptions at all or no active/registered ones, and the corresponding setting allows it:
         // Find the first free lifetime one with Registered level:
         if ((count($subscriptions) == 0 || $noValidSubscriptionFound) && $enableFreeRegisteredUser && !$createAlsoFreeSubscriptions) {
             $firstFreePlanId = null;
             $registeredUserGroup = $_CB_framework->getCfg('new_usertype');
             foreach ($plans as $v) {
                 if ($v->isLifetimeValidity() && $v->isFree() && in_array($v->get('usergroup'), array($registeredUserGroup, 0))) {
                     if ($firstFreePlanId === null) {
                         $firstFreePlanId = $v->get('id');
                     }
                     break;
                 }
             }
             if ($firstFreePlanId) {
                 $freeSub = new cbpaidUsersubscriptionRecord($_CB_database);
                 $freeSub->createSubscription($user_id, $plans[$firstFreePlanId], null, null, 'A', false);
                 array_unshift($subscriptions, $freeSub);
                 $plans[$firstFreePlanId]->_drawOnlyAsContainer = true;
             }
         }
         $this->_upgradesCache[$user_id] = array('subscriptions' => &$subscriptions, 'plans' => &$plans);
     }
     $subscriptionsReturned = $this->_upgradesCache[$user_id]['subscriptions'];
     return $this->_upgradesCache[$user_id]['plans'];
 }
Ejemplo n.º 27
0
	public function delete( $id = null )
	{
		global $_PLUGINS;

		$plugin		=	cbconsultationsClass::getPlugin();
		$user		=	CBuser::getMyUserDataInstance();

		$key		=	$this->get( '_tbl_key' );

		if ( $id !== null ) {
			$this->set( $key, $id );
		}

		$id			=	$this->get( $key );
		$article	=	JTable::getInstance( 'K2Item', 'Table' );

		if ( ! $article->load( (int) $id ) ) {
			return false;
		}

		$_PLUGINS->trigger( 'cbconsultations_onBeforeDeleteconsultation', array( &$this, &$article, $user, $plugin ) );

		if ( ! $article->delete( (int) $id ) ) {
			return false;
		}

		$_PLUGINS->trigger( 'cbconsultations_onAfterDeleteconsultation', array( $this, $article, $user, $plugin ) );

		$article->reorder( $this->_db->NameQuote( 'catid' ) . ' = ' . (int) $article->get( 'catid' ) );

		return true;
	}
Ejemplo n.º 28
0
 /**
  * @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 boolean
  */
 public function getMenuAndStatus($tab, $user, $ui)
 {
     global $_CB_framework, $_CB_database, $ueConfig, $_REQUEST, $_POST;
     $params = $this->params;
     $userId = $user->id && $_CB_framework->myId() == $user->id ? null : $user->id;
     $firstMenuName = $params->get('firstMenuName', '');
     // CBTxt::T( '_UE_MENU_CB', 'Community' )
     $firstSubMenuName = $params->get('firstSubMenuName', '');
     // CBTxt::T( '_UE_MENU_ABOUT_CB', 'About Community Builder...' )
     $firstSubMenuHref = $params->get('firstSubMenuHref', '');
     $secondSubMenuName = $params->get('secondSubMenuName', '');
     $secondSubMenuHref = $params->get('secondSubMenuHref', '');
     // ----- CUSTOM MENU -----
     if ($firstMenuName != '') {
         $customMenu = array();
         $customMenu['arrayPos'] = $firstMenuName;
         $customMenu['position'] = 'menuBar';
         $customMenu['caption'] = CBTxt::T($firstMenuName);
         $this->addMenu($customMenu);
         if ($firstSubMenuName != '') {
             // Custom 1:
             $first = array();
             $first['arrayPos'] = array($firstMenuName => array('_UE_FIRST' => null));
             $first['position'] = 'menuBar';
             $first['caption'] = CBTxt::T($firstSubMenuName);
             $first['url'] = $firstSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($firstSubMenuHref);
             $first['target'] = '';
             $first['img'] = '';
             $first['tooltip'] = '';
             $this->addMenu($first);
             if ($secondSubMenuName != '') {
                 // Custom 2:
                 $second = array();
                 $second['arrayPos'] = array($firstMenuName => array('_UE_SECOND' => null));
                 $second['position'] = 'menuBar';
                 $second['caption'] = CBTxt::T($secondSubMenuName);
                 $second['url'] = $secondSubMenuHref == '' ? "javascript: void( 0 );" : cbSef($secondSubMenuHref);
                 $second['target'] = '';
                 $second['img'] = '';
                 $second['tooltip'] = '';
                 $this->addMenu($second);
             }
         }
     }
     // ----- VIEW MENU -----
     $viewMenu = array();
     $viewMenu['arrayPos'] = '_UE_MENU_VIEW';
     $viewMenu['position'] = 'menuBar';
     $viewMenu['caption'] = CBTxt::T('_UE_MENU_VIEW', 'View');
     $this->addMenu($viewMenu);
     if ($_CB_framework->myId() > 0) {
         if ($_CB_framework->displayedUser() === null || $_CB_framework->myId() != $user->id && $_CB_framework->displayedUser() !== null) {
             // View My Profile:
             $myProfile = array();
             $myProfile['arrayPos'] = array('_UE_MENU_VIEW' => array('_UE_MENU_VIEWMYPROFILE' => null));
             $myProfile['position'] = 'menuBar';
             $myProfile['caption'] = CBTxt::T('UE_MENU_VIEWMYPROFILE', 'View Your Profile');
             $myProfile['url'] = $_CB_framework->userProfileUrl();
             $myProfile['target'] = '';
             $myProfile['img'] = '<span class="fa fa-home"></span> ';
             $myProfile['tooltip'] = CBTxt::T('UE_MENU_VIEWMYPROFILE_DESC', 'View your own profile');
             $this->addMenu($myProfile);
         }
     }
     // ----- EDIT MENU -----
     $editMenu = array();
     $editMenu['arrayPos'] = '_UE_MENU_EDIT';
     $editMenu['position'] = 'menuBar';
     $editMenu['caption'] = CBTxt::T('_UE_MENU_EDIT', 'Edit');
     $this->addMenu($editMenu);
     if (!cbCheckIfUserCanPerformUserTask($user->id, 'allowModeratorsUserEdit')) {
         if ($user->id == $_CB_framework->myId()) {
             $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_UPDATEPROFILE', 'Update Your Profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MENU_UPDATEPROFILE_DESC', 'Change your profile settings'));
         } else {
             $menuTexts = array('_UE_UPDATEPROFILE' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE', 'Update user profile'), '_UE_MENU_UPDATEPROFILE_DESC' => CBTxt::T('UE_MOD_MENU_UPDATEPROFILE_DESC', 'Change profile settings of this user profile'));
         }
         // Update Profile:
         $updateProfile = array();
         $updateProfile['arrayPos'] = array('_UE_MENU_EDIT' => array('_UE_UPDATEPROFILE' => null));
         $updateProfile['position'] = 'menuBar';
         $updateProfile['caption'] = $menuTexts['_UE_UPDATEPROFILE'];
         $updateProfile['url'] = $_CB_framework->userProfileEditUrl($userId);
         $updateProfile['target'] = '';
         $updateProfile['img'] = '<span class="fa fa-edit"></span> ';
         $updateProfile['tooltip'] = $menuTexts['_UE_MENU_UPDATEPROFILE_DESC'];
         $this->addMenu($updateProfile);
     }
     // ----- MESSAGES MENU -----
     $messagesMenu = array();
     $messagesMenu['arrayPos'] = '_UE_MENU_MESSAGES';
     $messagesMenu['position'] = 'menuBar';
     $messagesMenu['caption'] = CBTxt::T('_UE_MENU_MESSAGES', 'Messages');
     $this->addMenu($messagesMenu);
     if ($_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) {
         global $_CB_PMS;
         $resultArray = $_CB_PMS->getPMSlinks($user->id, $_CB_framework->myId(), '', '', 1);
         if (count($resultArray) > 0) {
             foreach ($resultArray as $res) {
                 if (is_array($res)) {
                     // Send Private Message:
                     $sendMessage = array();
                     $sendMessage['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_PM_USER' => null));
                     $sendMessage['position'] = 'menuBar';
                     $sendMessage['caption'] = $res['caption'];
                     // Already translated in CB Menu
                     $sendMessage['url'] = cbSef($res['url']);
                     $sendMessage['target'] = '';
                     $sendMessage['img'] = '<span class="fa fa-comment"></span> ';
                     $sendMessage['tooltip'] = $res['tooltip'];
                     // Already translated in CB Menu
                     $this->addMenu($sendMessage);
                 }
             }
         }
     }
     if ($ueConfig['allow_email_display'] != 4 && $_CB_framework->myId() != $user->id && $_CB_framework->myId() > 0) {
         switch ($ueConfig['allow_email_display']) {
             case 1:
                 // Display Email only
                 $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 0);
                 $url = "javascript: void( 0 );;";
                 $desc = CBTxt::T('UE_MENU_USEREMAIL_DESC', 'Email address of this user');
                 break;
             case 2:
                 // Display Email with link
                 $caption = moscomprofilerHTML::emailCloaking(htmlspecialchars($user->email), 1);
                 $url = "javascript: void( 0 );;";
                 $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user');
                 break;
             case 3:
                 // Display Email-to text with link to web-form
             // Display Email-to text with link to web-form
             default:
                 $caption = CBTxt::T('UE_MENU_SENDUSEREMAIL', 'Send Email to User');
                 $url = $_CB_framework->viewUrl('emailuser', true, array('uid' => $userId));
                 $desc = CBTxt::T('UE_MENU_SENDUSEREMAIL_DESC', 'Send an Email to this user');
                 break;
         }
         // Send Email:
         $sendEmail = array();
         $sendEmail['arrayPos'] = array('_UE_MENU_MESSAGES' => array('_UE_MENU_SENDUSEREMAIL' => null));
         $sendEmail['position'] = 'menuBar';
         $sendEmail['caption'] = $caption;
         $sendEmail['url'] = $url;
         $sendEmail['target'] = '';
         $sendEmail['img'] = '<span class="fa fa-envelope"></span> ';
         $sendEmail['tooltip'] = $desc;
         $this->addMenu($sendEmail);
     }
     // ----- CONNECTIONS MENU -----
     $connectionsMenu = array();
     $connectionsMenu['arrayPos'] = '_UE_MENU_CONNECTIONS';
     $connectionsMenu['position'] = 'menuBar';
     $connectionsMenu['caption'] = CBTxt::T('_UE_MENU_CONNECTIONS', 'Connections');
     $this->addMenu($connectionsMenu);
     if ($ueConfig['allowConnections'] && $_CB_framework->myId() > 0) {
         // Manage My Connections:
         $manageConnections = array();
         $manageConnections['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array('_UE_MENU_MANAGEMYCONNECTIONS' => null));
         $manageConnections['position'] = 'menuBar';
         $manageConnections['caption'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS', 'Manage Your Connections');
         $manageConnections['url'] = $_CB_framework->viewUrl('manageconnections');
         $manageConnections['target'] = '';
         $manageConnections['img'] = '<span class="fa fa-users"></span> ';
         $manageConnections['tooltip'] = CBTxt::T('UE_MENU_MANAGEMYCONNECTIONS_DESC', 'Manage your existing connections and pending connections actions');
         $this->addMenu($manageConnections);
         if ($_CB_framework->myId() != $user->id) {
             $cbConnection = new cbConnection((int) $_CB_framework->myId());
             $cbUser =& CBuser::getInstance((int) $user->id, false);
             $connClass = null;
             $connLink = null;
             $connDesc = null;
             $connMsg = null;
             $connImg = null;
             $isConnection = $cbConnection->isConnected((int) $user->id);
             if ($isConnection) {
                 $isApproved = $cbConnection->isConnectionApproved((int) $user->id);
                 $isAccepted = $cbConnection->isConnectionAccepted((int) $user->id);
             } else {
                 $isApproved = false;
                 $isAccepted = false;
             }
             if (!$isConnection) {
                 $connUrl = $_CB_framework->viewUrl('addconnection', true, array('connectionid' => (int) $user->id));
                 if ($ueConfig['useMutualConnections'] == 1) {
                     $connClass = 'UE_ADDCONNECTIONREQUEST';
                     $connMsg = CBTxt::T('UE_ADDCONNECTIONREQUEST', 'Request Connection');
                     $connDesc = CBTxt::T('UE_ADDCONNECTIONREQUEST_DESC', 'Request a Connection to that user');
                 } else {
                     $connClass = 'UE_ADDCONNECTION';
                     $connMsg = CBTxt::T('UE_ADDCONNECTION', 'Add Connection');
                     $connDesc = CBTxt::T('UE_ADDCONNECTION_DESC', 'Add a Connection to that user');
                 }
                 if ($ueConfig['conNotifyType'] != 0) {
                     cbValidator::loadValidation();
                     $tooltipTitle = sprintf(CBTxt::T('UE_CONNECTTO', 'Connect to %s'), $cbUser->getField('formatname', null, 'html', 'none', 'profile', 0, true));
                     $connectionInvitationMsg = CBTxt::T('UE_CONNECTIONINVITATIONMSG', 'Personalize your invitation to connect by adding a message that will be included with your connection.');
                     $tooltip = null;
                     if ($connectionInvitationMsg) {
                         $tooltip .= '<div class="form-group cb_form_line clearfix">' . $connectionInvitationMsg . '</div>';
                     }
                     $tooltip .= '<form action="' . $connUrl . '" method="post" id="connOverForm" name="connOverForm" class="cb_form cbValidation">' . '<div class="form-group cb_form_line clearfix">' . '<label for="message" class="control-label">' . CBTxt::T('UE_MESSAGE', 'Message') . '</label>' . '<div class="cb_field">' . '<textarea cols="40" rows="8" name="message" class="form-control"></textarea>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<input type="submit" class="btn btn-primary cbConnReqSubmit" value="' . htmlspecialchars(CBTxt::Th('UE_SENDCONNECTIONREQUEST', 'Request Connection')) . '"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . ' <input type="button" id="cbConnReqCancel" class="btn btn-default cbConnReqCancel cbTooltipClose" value="' . htmlspecialchars(CBTxt::Th('UE_CANCELCONNECTIONREQUEST', 'Cancel')) . '" />' . '</div>' . '</form>';
                     $connLink = cbTooltip($ui, $tooltip, $tooltipTitle, 400, null, '<span class="fa fa-heart"></span> ' . CBTxt::Th($connMsg), 'javascript: void( 0 );', 'data-hascbtooltip="true" data-cbtooltip-modal="true"');
                 } else {
                     $connLink = $connUrl;
                     $connImg = '<span class="fa fa-heart"></span> ';
                 }
             } else {
                 if ($isAccepted) {
                     $connUrl = $_CB_framework->viewUrl('removeconnection', true, array('connectionid' => (int) $user->id));
                     if ($isApproved) {
                         $connClass = 'UE_REMOVECONNECTION';
                         $connMsg = CBTxt::T('UE_REMOVECONNECTION', 'Remove Connection');
                         $connDesc = CBTxt::T('UE_REMOVECONNECTION_DESC', 'Remove Connection to that user');
                     } else {
                         $connClass = 'UE_REVOKECONNECTIONREQUEST';
                         $connMsg = CBTxt::T('UE_REVOKECONNECTIONREQUEST', 'Revoke Connection Request');
                         $connDesc = CBTxt::T('UE_REVOKECONNECTIONREQUEST_DESC', 'Cancel the Connection Request to that user');
                     }
                     $js = "if ( typeof confirmSubmit != 'function' ) {" . "function confirmSubmit() {" . "if ( confirm( '" . addslashes(CBTxt::T('UE_CONFIRMREMOVECONNECTION', 'Are you sure you want to remove this connection?')) . "' ) ) {" . "return true;" . "} else {" . "return false;" . "}" . "};" . "}";
                     $_CB_framework->document->addHeadScriptDeclaration($js);
                     $connLink = $connUrl . '" onclick="return confirmSubmit();';
                     $connImg = '<span class="fa fa-heart-o"></span> ';
                 } else {
                     $connClass = null;
                     $connMsg = null;
                 }
             }
             if ($connMsg) {
                 // Request/Add/Remove/Revoke Connection:
                 $connectionRequest = array();
                 $connectionRequest['arrayPos'] = array('_UE_MENU_CONNECTIONS' => array($connClass => null));
                 $connectionRequest['position'] = 'menuBar';
                 $connectionRequest['caption'] = $connMsg;
                 $connectionRequest['url'] = $connLink;
                 $connectionRequest['target'] = '';
                 $connectionRequest['img'] = $connImg;
                 $connectionRequest['tooltip'] = $connDesc;
                 $this->addMenu($connectionRequest);
             }
         }
     }
     // ----- MODERATE MENU -----
     $moderateMenu = array();
     $moderateMenu['arrayPos'] = '_UE_MENU_MODERATE';
     $moderateMenu['position'] = 'menuBar';
     $moderateMenu['caption'] = CBTxt::T('_UE_MENU_MODERATE', 'Moderate');
     $this->addMenu($moderateMenu);
     if ($_CB_framework->myId() == $user->id) {
         if ($user->banned == 1 && $this->cbUserIsModerator == 0 && $ueConfig['allowUserBanning'] == 1) {
             // Request Unban:
             $requestUnban = array();
             $requestUnban['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REQUESTUNBANPROFILE' => null));
             $requestUnban['position'] = 'menuBar';
             $requestUnban['caption'] = CBTxt::T('UE_REQUESTUNBANPROFILE', 'Submit Unban Request');
             $requestUnban['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 2, 'reportform' => 1, 'uid' => (int) $user->id));
             $requestUnban['target'] = '';
             $requestUnban['img'] = '<span class="fa fa-envelope"></span> ';
             $requestUnban['tooltip'] = CBTxt::T('UE_MENU_REQUESTUNBANPROFILE_DESC', 'Submit a request to the site moderator to unban your profile');
             $this->addMenu($requestUnban);
         }
     } else {
         if ($ueConfig['allowUserReports'] == 1 && $this->cbUserIsModerator == 0 && $_CB_framework->myId() > 0) {
             // Report User:
             $reportUser = array();
             $reportUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_REPORTUSER' => null));
             $reportUser['position'] = 'menuBar';
             $reportUser['caption'] = CBTxt::T('UE_REPORTUSER', 'Report User');
             $reportUser['url'] = $_CB_framework->viewUrl('reportuser', true, array('uid' => (int) $user->id));
             $reportUser['target'] = '';
             $reportUser['img'] = '<span class="fa fa-bullhorn"></span> ';
             $reportUser['tooltip'] = CBTxt::T('UE_MENU_REPORTUSER_DESC', 'Report this user to the site moderator so that he can take appropriate action');
             $this->addMenu($reportUser);
         }
         if ($this->cbMyIsModerator == 1 && $this->cbUserIsModerator == 0) {
             $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id . "\n AND " . $_CB_database->NameQuote('reportedstatus') . " = 0";
             $_CB_database->setQuery($query);
             $pendingReports = $_CB_database->loadResult();
             $query = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_userreports') . "\n WHERE " . $_CB_database->NameQuote('reporteduser') . " = " . (int) $user->id;
             $_CB_database->setQuery($query);
             $processedReports = $_CB_database->loadResult();
             if ($ueConfig['allowUserBanning'] == 1) {
                 if ($user->banned != 0) {
                     // Unban Profile:
                     $unbanUser = array();
                     $unbanUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_UNBANPROFILE' => null));
                     $unbanUser['position'] = 'menuBar';
                     $unbanUser['caption'] = CBTxt::T('UE_UNBANPROFILE', 'Unban Profile');
                     $unbanUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 0, 'reportform' => 0, 'uid' => (int) $user->id));
                     $unbanUser['target'] = '';
                     $unbanUser['img'] = '<span class="fa fa-check-circle-o"></span> ';
                     $unbanUser['tooltip'] = CBTxt::T('UE_MENU_UNBANPROFILE_DESC', 'As Site Moderator: Unban this profile, making it visible to other users');
                     $this->addMenu($unbanUser);
                 } else {
                     // Ban Profile:
                     $banUser = array();
                     $banUser['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_BANPROFILE' => null));
                     $banUser['position'] = 'menuBar';
                     $banUser['caption'] = CBTxt::T('UE_BANPROFILE', 'Ban Profile');
                     $banUser['url'] = $_CB_framework->viewUrl('banprofile', true, array('act' => 1, 'uid' => (int) $user->id));
                     $banUser['target'] = '';
                     $banUser['img'] = '<span class="fa fa-ban"></span> ';
                     $banUser['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_DESC', 'As Site Moderator: Ban this profile, making it invisible to other users');
                     $this->addMenu($banUser);
                 }
                 if ($user->bannedby) {
                     // Ban History:
                     $banHistory = array();
                     $banHistory['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_MENU_BANPROFILE_HISTORY' => null));
                     $banHistory['position'] = 'menuBar';
                     $banHistory['caption'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY', 'Ban history');
                     $banHistory['url'] = $_CB_framework->viewUrl('moderatebans', true, array('act' => 2, 'uid' => (int) $user->id));
                     $banHistory['target'] = '';
                     $banHistory['img'] = '<span class="fa fa-book"></span> ';
                     $banHistory['tooltip'] = CBTxt::T('UE_MENU_BANPROFILE_HISTORY_DESC', 'As Site Moderator: See ban history of this profile');
                     $this->addMenu($banHistory);
                 }
             }
             if ($ueConfig['allowUserReports'] == 1 && $pendingReports > 0) {
                 // View Pending Reports:
                 $userReports = array();
                 $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null));
                 $userReports['position'] = 'menuBar';
                 $userReports['caption'] = CBTxt::T('UE_VIEWUSERREPORTS', 'View User Reports');
                 $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('uid' => (int) $user->id));
                 $userReports['target'] = '';
                 $userReports['img'] = '<span class="fa fa-warning"></span> ';
                 $userReports['tooltip'] = CBTxt::T('UE_MENU_VIEWUSERREPORTS_DESC', 'As Site Moderator: View User Reports for this user');
                 $this->addMenu($userReports);
             } elseif ($ueConfig['allowUserReports'] == 1 && $processedReports > 0) {
                 // View Processed Reports:
                 $userReports = array();
                 $userReports['arrayPos'] = array('_UE_MENU_MODERATE' => array('_UE_VIEWUSERREPORTS' => null));
                 $userReports['position'] = 'menuBar';
                 $userReports['caption'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS', 'View processed user reports');
                 $userReports['url'] = $_CB_framework->viewUrl('viewreports', true, array('act' => 1, 'uid' => (int) $user->id));
                 $userReports['target'] = '';
                 $userReports['img'] = '<span class="fa fa-warning"></span> ';
                 $userReports['tooltip'] = CBTxt::T('UE_MOD_MENU_VIEWOLDUSERREPORTS_DESC', 'As site moderator: View processed user reports for this user');
                 $this->addMenu($userReports);
             }
         }
     }
 }
Ejemplo n.º 29
0
	/**
	 * Translates, prepares the HTML $htmlText with triggering CMS Content Plugins, replaces CB substitutions and extra HTML and non-HTML substitutions
	 * @see CBuser::replaceUserVars
	 *
	 * @param  string      $mainText
	 * @param  int         $user_id
	 * @param  boolean     $html
	 * @param  boolean     $translateMainText
	 * @param  boolean     $prepareHtmlContentPlugins
	 * @param  array|null  $extraHtmlStrings
	 * @param  array|null  $extraNonHtmlStrings
	 * @return string
	 */
	public static function replaceUserVars( $mainText, $user_id, $html, $translateMainText = true,
											$prepareHtmlContentPlugins = false,
											$extraHtmlStrings = null, $extraNonHtmlStrings = null )
	{
		if ( $translateMainText ) {
			$mainText		=	$html ? parent::Th( $mainText ) : parent::T( $mainText );
		}

		if ( $prepareHtmlContentPlugins ) {
			$mainText		=	Application::Cms()->prepareHtmlContentPlugins( $mainText );

			if ( ! $html ) {
				$mainText	=	strip_tags( $mainText );
			}
		}

		$cbUser				=	CBuser::getInstance( (int) $user_id );

		if ( ! $cbUser ) {
			$cbUser			=	CBuser::getInstance( null );
		}

		$mainText			=	$cbUser->replaceUserVars( $mainText, true, false, $extraNonHtmlStrings, false );

		if ( $extraHtmlStrings ) {
			foreach ( $extraHtmlStrings as $k => $v ) {
				$mainText	=	str_replace( "[$k]", $html ? $v : strip_tags( $v ), $mainText );
			}
		}

		return $mainText;
	}
Ejemplo n.º 30
0
 function getAvatar($user, $extension, $default_avatar)
 {
     $avatar = 0;
     if ($user->get('id') == 0) {
         $avatar = !empty($default_avatar) ? $default_avatar : 0;
     } elseif ($extension == 1) {
         require_once JPATH_ADMINISTRATOR . '/components/com_rokbridge/helper.php';
         $rokbridge = new RokBridgeHelper();
         $phpbb_db = $rokbridge->phpbb_db;
         $query = "SELECT user_id, user_type, username, user_unread_privmsg, user_new_privmsg, user_avatar, user_avatar_type, user_avatar_width, user_avatar_height, user_lastvisit, FROM_UNIXTIME(user_lastvisit,'%a %b %D %x %h:%i %p') AS LastVisit FROM #__users WHERE " . $rokbridge->getWhereClause($user->username);
         $phpbb_db->setQuery($query);
         $fuser = $phpbb_db->loadObject();
         $avatar = $rokbridge->getAvatar($fuser, 35, "", $default_avatar);
         $avatar = substr($avatar, strpos($avatar, '"') + 1);
         $avatar = substr($avatar, 0, strpos($avatar, '"'));
     } elseif ($extension == 2) {
         $jspath = JPATH_BASE . DS . 'components/com_community';
         include_once $jspath . DS . 'libraries/core.php';
         $user =& CFactory::getUser($user->get('id'));
         $avatar = $user->getThumbAvatar();
     } elseif ($extension == 3) {
         $jspath = JPATH_ADMINISTRATOR . '/components/com_comprofiler';
         include_once $jspath . DS . 'plugin.foundation.php';
         cbimport('cb.database');
         $user =& CBuser::getInstance($user->get('id'));
         $avatar = $user->avatarFilePath(1);
         if (empty($avatar)) {
             $avatar = $default_avatar;
         }
     } elseif ($extension == 4) {
         $ini = JFile::read(JPATH_ADMINISTRATOR . '/components/com_juser/config.ini');
         $juserparams = new JParameter($ini);
         $avatar_save_path = $juserparams->get('general::avatars_dir');
         if (file_exists(JPATH_ROOT . DS . $avatar_save_path . DS . $user->get('username') . '.jpg')) {
             $avatar = JURI::root() . str_replace('\\', '/', $avatar_save_path) . '/' . $user->get('username') . '.jpg';
         } else {
             $avatar = JURI::root() . '/components/com_juser/images/default_avatar.png';
         }
     } elseif ($extension == 5) {
         require_once JPATH_BASE . DS . 'components/com_kunena/class.kunena.php';
         $kunena_user = KunenaFactory::getUser($user->get('id'));
         $username = $kunena_user->getName();
         $avatar = $kunena_user->getAvatarURL();
     }
     return $avatar;
 }