コード例 #1
0
ファイル: cbNotification.php プロジェクト: Raul-mz/web-erpcya
 /**
  * Send an email to all global moderators
  *
  * @param  string         $subject           Subject
  * @param  string         $message           HTML message for PMS
  * @param  boolean|int    $replaceVariables  Should we replace variables ?
  * @param  int            $mode              false = plain text, true = HTML
  * @param  null|string    $cc                Email CC address
  * @param  null|string    $bcc               Email BCC address
  * @param  null|string    $attachment        Email attachment files
  * @param  array          $extraStrings      Extra replacement strings to use if $replaceVariables = true
  * @return boolean                           Result
  */
 public function sendToModerators($subject, $message, $replaceVariables = false, $mode = 0, $cc = null, $bcc = null, $attachment = null, $extraStrings = array())
 {
     global $_CB_database;
     $moderators = Application::CmsPermissions()->getGroupsOfViewAccessLevel(Application::Config()->get('moderator_viewaccesslevel', 3, \CBLib\Registry\GetterInterface::INT), true);
     if ($moderators) {
         $query = 'SELECT u.id' . "\n FROM #__users u" . "\n INNER JOIN #__comprofiler c" . ' ON u.id = c.id';
         $query .= "\n INNER JOIN #__user_usergroup_map g" . ' ON c.id = g.user_id' . "\n WHERE g.group_id IN " . $_CB_database->safeArrayOfIntegers($moderators);
         $query .= "\n AND u.block = 0" . "\n AND c.confirmed = 1" . "\n AND c.approved = 1" . "\n AND u.sendEmail = 1";
         $_CB_database->setQuery($query);
         $mods = $_CB_database->loadObjectList();
         if ($mods) {
             foreach ($mods as $mod) {
                 $this->sendFromSystem($mod->id, $subject, $message, $replaceVariables, $mode, $cc, $bcc, $attachment, $extraStrings);
             }
         }
     }
 }
コード例 #2
0
	/**
	 * prepare frontend invite edit render
	 *
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function showInviteEdit( $id, $user )
	{
		global $_CB_framework;

		$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 ( ( $row->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' );
			}
		}

		CBGroupJive::getTemplate( 'invite_edit' );

		$input								=	array();

		$inviteBy							=	array();
		$inviteByLimit						=	explode( '|*|', $this->params->get( 'groups_invites_by', '1|*|2|*|3|*|4' ) );

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

		if ( in_array( 1, $inviteByLimit ) ) {
			$inviteBy[]						=	CBTxt::T( 'User ID' );
		}

		if ( in_array( 2, $inviteByLimit ) ) {
			$inviteBy[]						=	CBTxt::T( 'Username' );
		}

		if ( in_array( 3, $inviteByLimit ) ) {
			$inviteBy[]						=	CBTxt::T( 'Name' );
		}

		if ( in_array( 4, $inviteByLimit ) ) {
			$inviteBy[]						=	CBTxt::T( 'Email Address' );
		}

		$input['invite_by']					=	$inviteBy;

		$listConnections					=	array();

		if ( Application::Config()->get( 'allowConnections' ) ) {
			$cbConnection					=	new cbConnection( (int) $user->get( 'id' ) );

			foreach( $cbConnection->getConnectedToMe( (int) $user->get( 'id' ) ) as $connection ) {
				$listConnections[]			=	moscomprofilerHTML::makeOption( (string) $connection->id, getNameFormat( $connection->name, $connection->username, Application::Config()->get( 'name_format', 3 ) ) );
			}
		}

		if ( $listConnections ) {
			array_unshift( $listConnections, moscomprofilerHTML::makeOption( '0', CBTxt::T( '- Select Connection -' ) ) );

			$listTooltip					=	cbTooltip( null, CBTxt::T( 'Select a connection to invite.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['list']					=	moscomprofilerHTML::selectList( $listConnections, 'selected', 'class="gjInviteConnection form-control"' . $listTooltip, 'value', 'text', (int) $this->input( 'post/selected', 0, GetterInterface::INT ), 1, false, false );
		} else {
			$input['list']					=	null;
		}

		$toTooltup							=	cbTooltip( null, CBTxt::T( 'GROUP_INVITE_BY', 'Input the recipient as [invite_by].', array( '[invite_by]' => implode( ', ', $inviteBy ) ) ), 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( 'user' ) ? (int) $row->get( 'user' ) : $row->get( 'email' ) ), GetterInterface::STRING ) ) . '" class="gjInviteOther form-control" size="40"' . $toTooltup . ' />';

		$messageTooltip						=	cbTooltip( null, CBTxt::T( 'Optionally input private message to include with the invite.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['message']					=	'<textarea id="message" name="message" class="form-control" cols="40" rows="5"' . $messageTooltip . '>' . htmlspecialchars( $this->input( 'post/message', $row->get( 'message' ), GetterInterface::STRING ) ) . '</textarea>';

		HTML_groupjiveInviteEdit::showInviteEdit( $row, $input, $group, $user, $this );
	}
コード例 #3
0
 /**
  * records a visit and the hit with timed protection similar to voting protections
  *
  * @param  int      $viewerId   Viewing user id
  * @param  int     $profileId  Viewed user id
  * @param  string  $ipAddress  IP address of viewing user
  */
 function recordViewHit($viewerId, $profileId, $ipAddress)
 {
     global $_CB_framework, $_CB_database, $ueConfig;
     if (!Application::Config()->get('profile_recordviews', 1)) {
         return;
     }
     $query = 'SELECT ' . $_CB_database->NameQuote('lastview') . ', ' . $_CB_database->NameQuote('lastip') . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_views') . "\n WHERE " . $_CB_database->NameQuote('viewer_id') . " = " . (int) $viewerId . "\n AND " . $_CB_database->NameQuote('profile_id') . " = " . (int) $profileId . ($viewerId == 0 ? "\n AND " . $_CB_database->NameQuote('lastip') . " = " . $_CB_database->Quote($ipAddress) : null) . "\n ORDER BY " . $_CB_database->NameQuote('lastview') . " DESC";
     $_CB_database->setQuery($query);
     $views = $_CB_database->loadObjectList();
     if (count($views) == 0) {
         // no views yet: insert the view record:
         $query = 'INSERT INTO ' . $_CB_database->NameQuote('#__comprofiler_views') . "\n ( " . $_CB_database->NameQuote('viewer_id') . ', ' . $_CB_database->NameQuote('profile_id') . ', ' . $_CB_database->NameQuote('lastip') . ', ' . $_CB_database->NameQuote('lastview') . ', ' . $_CB_database->NameQuote('viewscount') . ' )' . "\n VALUES ( " . (int) $viewerId . ', ' . (int) $profileId . ', ' . $_CB_database->Quote($ipAddress) . ', ' . $_CB_database->Quote($_CB_framework->getUTCDate()) . ', 1 )';
         $_CB_database->setQuery($query);
         if (!$_CB_database->query()) {
             echo "<script type=\"text/javascript\">alert( 'InsertViews: " . addslashes($_CB_database->getErrorMsg()) . "' );</script>\n";
         }
         _incHits($profileId);
     } else {
         // we already have view(s):
         $count = count($views);
         $lastview = $_CB_framework->getUTCTimestamp($views[0]->lastview);
         if ($count > 1) {
             // huston, we have a database problem: we have more than one entry for the pair viewer-viewed OR the tripplet (anonymous viewer=0 - viewed - IP address):
             // updating would generate key conflicts: cleanupt that mess please:
             $query = 'DELETE FROM ' . $_CB_database->NameQuote('#__comprofiler_views') . "\n WHERE " . $_CB_database->NameQuote('viewer_id') . " = " . (int) $viewerId . "\n AND " . $_CB_database->NameQuote('profile_id') . " = " . (int) $profileId . ($viewerId == 0 ? "\n AND " . $_CB_database->NameQuote('lastip') . " = " . $_CB_database->Quote($ipAddress) : null) . "\n AND " . $_CB_database->NameQuote('lastview') . " <> " . $_CB_database->Quote($views[0]->lastview);
             $_CB_database->setQuery($query);
             if (!$_CB_database->query()) {
                 echo "<script type=\"text/javascript\">alert( 'DeleteViews: " . addslashes($_CB_database->getErrorMsg()) . "' );</script>\n";
             }
         }
         // ok there was a view, we will count it only if lastview time is greater than the minimum interval configured,
         $needsUpdate = $_CB_framework->getUTCTimestamp() - $lastview > $ueConfig['minHitsInterval'] * 60;
         // but we will update any IP address changes in case of a logged-in user (for guests, the SELECT above is by IP address, so that entry and IP is already same:
         if ($ipAddress != $views[0]->lastip || $needsUpdate) {
             $query = 'UPDATE ' . $_CB_database->NameQuote('#__comprofiler_views') . "\n SET " . $_CB_database->NameQuote('lastview') . " = " . $_CB_database->Quote($_CB_framework->getUTCDate()) . ', ' . $_CB_database->NameQuote('lastip') . " = " . $_CB_database->Quote($ipAddress) . ($needsUpdate ? ', ' . $_CB_database->NameQuote('viewscount') . " = (" . $_CB_database->NameQuote('viewscount') . "+1)" : '') . "\n WHERE " . $_CB_database->NameQuote('viewer_id') . " = " . (int) $viewerId . "\n AND " . $_CB_database->NameQuote('profile_id') . " = " . (int) $profileId . ($viewerId == 0 ? "\n AND " . $_CB_database->NameQuote('lastip') . " = " . $_CB_database->Quote($ipAddress) : null);
             $_CB_database->setQuery($query);
             if (!$_CB_database->query()) {
                 echo "<script type=\"text/javascript\">alert( 'UpdateViews: " . addslashes($_CB_database->getErrorMsg()) . "' );</script>\n";
             }
             if ($needsUpdate) {
                 _incHits($profileId);
             }
         }
     }
 }
コード例 #4
0
	/**
	 * prepare frontend tab render
	 *
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database;

		if ( ! ( $tab->params instanceof ParamsInterface ) ) {
			$tab->params		=	new Registry( $tab->params );
		}

		$viewer					=	CBuser::getMyUserDataInstance();
		$isModerator			=	CBGroupJive::isModerator( $viewer->get( 'id' ) );
		$isOwner				=	( $viewer->get( 'id' ) == $user->get( 'id' ) );

		CBGroupJive::getTemplate( 'tab' );

		$limit					=	(int) $tab->params->get( 'tab_limit', 30 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_tab_limitstart{com_comprofiler}', 'gj_tab_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_tab_search{com_comprofiler}', 'gj_tab_search' );
		$where					=	null;

		if ( $search && $tab->params->get( 'tab_search', 1 ) ) {
			$where				.=	"\n AND ( g." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR g." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

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

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g";

		if ( ! $isModerator ) {
			$query				.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_categories' ) . " AS c"
								.	' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_CB_database->NameQuote( 'category' );
		}

		$query					.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
								.	' ON u.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND u.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	' ON i.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( i.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) )
								.	' AND i.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( i.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )';

		if ( $isOwner ) {
			$query				.=	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )';
			}
		} else {
			$query				.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS mu"
								.	' ON mu.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND mu.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $viewer->get( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS mi"
								.	' ON mi.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( mi.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $viewer->get( 'email' ) )
								.	' AND mi.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( mi.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $viewer->get( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )'
								.	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) ) )'
								.	"\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $viewer->get( 'id' )
								.		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )'
								.		' OR mu.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR mi.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) )';
			}
		}

		if ( ! $isModerator ) {
			$query				.=	"\n AND ( ( c." . $_CB_database->NameQuote( 'published' ) . " = 1"
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $user->get( 'id' ) ) )
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $viewer->get( 'id' ) ) ) . ' )'
								.		( $this->params->get( 'groups_uncategorized', 1 ) ? ' OR g.' . $_CB_database->NameQuote( 'category' ) . ' = 0 )' : ' )' );
		}

		$query					.=	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		if ( ( ! $total ) && ( ! $searching ) && ( ( ! $isOwner ) || ( $isOwner && ( ! CBGroupJive::canCreateGroup( $user ) ) ) ) && ( ! Application::Config()->get( 'showEmptyTabs', 1 ) ) ) {
			return null;
		}

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

		$pageNav->setInputNamePrefix( 'gj_tab_' );

		switch( (int) $tab->params->get( 'tab_orderby', 1 ) ) {
			case 2:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'ordering' ) . ' DESC';
				break;
			case 3:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'date' ) . ' ASC';
				break;
			case 4:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'date' ) . ' DESC';
				break;
			case 5:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'name' ) . ' ASC';
				break;
			case 6:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'name' ) . ' DESC';
				break;
			case 7:
				$orderBy		=	$_CB_database->NameQuote( '_users' ) . ' ASC';
				break;
			case 8:
				$orderBy		=	$_CB_database->NameQuote( '_users' ) . ' DESC';
				break;
			case 1:
			default:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'ordering' ) . ' ASC';
				break;
		}

		$users					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS uc"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS uccb"
								.	' ON uccb.' . $_CB_database->NameQuote( 'id' ) . ' = uc.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS ucj"
								.	' ON ucj.' . $_CB_database->NameQuote( 'id' ) . ' = uccb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE uc." . $_CB_database->NameQuote( 'group' ) . " = g." . $_CB_database->NameQuote( 'id' )
								.	"\n AND uccb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND uccb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND ucj." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $isModerator ) {
			$users				.=	"\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $viewer->get( 'id' )
								.		( ! $isOwner ? ' OR mu.' . $_CB_database->NameQuote( 'status' ) . ' >= 2' : null )
								.		' OR uc.' . $_CB_database->NameQuote( 'status' ) . ' >= 1 )';
		}

		if ( ! $this->params->get( 'groups_users_owner', 1 ) ) {
			$users				.=	"\n AND uc." . $_CB_database->NameQuote( 'status' ) . " != 4";
		}

		$query					=	'SELECT g.*'
								.	', c.' . $_CB_database->NameQuote( 'name' ) . ' AS _category_name';

		if ( $isOwner ) {
			$query				.=	', u.' . $_CB_database->NameQuote( 'status' ) . ' AS _user_status'
								.	', i.' . $_CB_database->NameQuote( 'id' ) . ' AS _invite_id';
		} else {
			$query				.=	', mu.' . $_CB_database->NameQuote( 'status' ) . ' AS _user_status'
								.	', mi.' . $_CB_database->NameQuote( 'id' ) . ' AS _invite_id';
		}

		$query					.=	', ( ' . $users . ' ) AS _users'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_categories' ) . " AS c"
								.	' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_CB_database->NameQuote( 'category' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
								.	' ON u.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND u.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	' ON i.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( i.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) )
								.	' AND i.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( i.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )';

		if ( $isOwner ) {
			$query				.=	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )';
			}
		} else {
			$query				.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS mu"
								.	' ON mu.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $viewer->get( 'id' )
								.	' AND mu.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS mi"
								.	' ON mi.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( mi.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $viewer->get( 'email' ) )
								.	' AND mi.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( mi.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $viewer->get( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )'
								.	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) ) )'
								.	"\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $viewer->get( 'id' )
								.		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )'
								.		' OR mu.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR mi.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) )';
			}
		}

		if ( ! $isModerator ) {
			$query				.=	"\n AND ( ( c." . $_CB_database->NameQuote( 'published' ) . " = 1"
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $user->get( 'id' ) ) )
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $viewer->get( 'id' ) ) ) . ' )'
								.		( $this->params->get( 'groups_uncategorized', 1 ) ? ' OR g.' . $_CB_database->NameQuote( 'category' ) . ' = 0 )' : ' )' );
		}

		$query					.=	$where
								.	"\n ORDER BY " . $orderBy;
		if ( $tab->params->get( 'tab_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\GroupTable', array( $_CB_database ) );

		$input['search']		=	'<input type="text" name="gj_tab_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjTabForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Groups...' ) ) . '" class="form-control" />';

		CBGroupJive::getGroup( $rows );
		CBGroupJive::preFetchUsers( $rows );

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

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

		return $return;
	}
コード例 #5
0
ファイル: CBuser.php プロジェクト: bobozhangshao/HeartCare
 /**
  * Check authorization to view for $contentType for content $id
  *
  * @since 1.8 (experimental)
  *
  * @param  string  $contentType  Content-type: 'profile'
  * @param  int     $id           Content id
  * @return boolean               True if authorized, False if not authorized
  */
 public function authoriseView($contentType, $id)
 {
     global $_PLUGINS;
     $authorization = false;
     if ($contentType == 'profile') {
         // Check for profile View Access Level (new in CB 2.0):
         $viewAccessLevel = Application::Config()->get('profile_viewaccesslevel', 0, GetterInterface::INT);
         if ($viewAccessLevel == 0) {
             // No configuration here: Check for old config (safely defaulting to Special View access level) until config is re-saved:
             $oldGID = Application::Config()->get('allow_profileviewbyGID', 3, GetterInterface::INT);
             $mapping = array(-2 => 1, -1 => 2, 0 => 1, 1 => 1, 2 => 2, 3 => 3);
             if (in_array($oldGID, $mapping)) {
                 $viewAccessLevel = $mapping[$oldGID];
             } else {
                 // Default here is "Special" Access level until configuration is saved:
                 $viewAccessLevel = 3;
             }
         }
         $authorization = Application::MyUser()->canViewAccessLevel($viewAccessLevel);
     }
     if ($contentType == 'userslist') {
         $authorization = Application::MyUser()->canViewAccessLevel(cbUsersList::getInstance($id)->viewaccesslevel);
     }
     if ($_PLUGINS) {
         $_PLUGINS->trigger('onAfterAuthorizeView', array($contentType, $id, &$authorization));
     }
     return $authorization;
 }
コード例 #6
0
 /**
  * Formats a field value $oValue for field name $oType for user $user
  *
  * @deprecated 1.0 (used only by (and kept only for) ProfileBook 1.3 until it is rewritten)
  *
  * @param  string     $oType
  * @param  string     $oValue
  * @param  UserTable  $user
  * @return string
  */
 function getFieldValue($oType, $oValue = null, $user = null)
 {
     if (!$user || !$user->id) {
         return '';
     }
     if ($oType == 'text') {
         return htmlspecialchars($oValue);
     }
     if ($oType == 'webaddress') {
         if ($oValue == null) {
             return '';
         }
         if (Application::Config()->get('allow_website') == 1) {
             $oReturn = explode('|*|', $oValue);
             if (count($oReturn) < 2) {
                 $oReturn[1] = $oReturn[0];
             }
             return '<a href="http://' . htmlspecialchars($oReturn[0]) . '" target="_blank" rel="nofollow">' . htmlspecialchars($oReturn[1]) . '</a>';
         }
         return htmlspecialchars($oValue);
     }
     return CBuser::getInstance($user->id)->getField($oType, $oValue);
 }
コード例 #7
0
	/**
	 * Uploads category or group canvas or logo
	 *
	 * @param string                   $type
	 * @param CategoryTable|GroupTable $row
	 * @return bool
	 */
	static public function uploadImage( $type = 'canvas', &$row )
	{
		global $_CB_framework, $_PLUGINS;

		if ( ( ! $type ) || ( ! in_array( $type, array( 'canvas', 'logo' ) ) ) ) {
			return false;
		}

		$method							=	Application::Input()->get( 'post/' . $type . '_method', null, GetterInterface::INT );

		if ( $method === 0 ) {
			return true;
		}

		static $params					=	null;

		if ( ! $params ) {
			$plugin						=	$_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' );
			$params						=	$_PLUGINS->getPluginParams( $plugin );
		}

		$basePath						=	$_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/plug_cbgroupjive';

		if ( $row instanceof GroupTable ) {
			$imagePath					=	$basePath . '/' . (int) $row->get( 'category' ) . '/' . (int) $row->get( 'id' );
		} else {
			$imagePath					=	$basePath . '/' . (int) $row->get( 'id' );
		}

		if ( ( ( $method === null ) || ( $method === 1 ) ) && isset( $_FILES[$type]['tmp_name'] ) && ( ! empty( $_FILES[$type]['tmp_name'] ) ) ) {
			if ( $row instanceof GroupTable ) {
				self::createDirectory( $basePath, $row->get( 'category' ), $row->get( 'id' ) );
			} else {
				self::createDirectory( $basePath, $row->get( 'id' ) );
			}

			$resample					=	$params->get( $type . '_resample', 1 );
			$aspectRatio				=	$params->get( $type . '_maintain_aspect_ratio', 1 );
			$imageHeight				=	(int) $params->get( $type . '_image_height', 640 );

			if ( ! $imageHeight ) {
				$imageHeight			=	640;
			}

			$imageWidth					=	(int) $params->get( $type . '_image_width', 1280 );

			if ( ! $imageWidth ) {
				$imageWidth				=	1280;
			}

			$thumbHeight				=	(int) $params->get( $type . '_thumbnail_height', 320 );

			if ( ! $thumbHeight ) {
				$thumbHeight			=	320;
			}

			$thumbWidth					=	(int) $params->get( $type . '_thumbnail_width', 640 );

			if ( ! $thumbWidth ) {
				$thumbWidth				=	640;
			}

			$conversionType				=	(int) Application::Config()->get( 'conversiontype', 0 );
			$imageSoftware				=	( $conversionType == 5 ? 'gmagick' : ( $conversionType == 1 ? 'imagick' : 'gd' ) );
			$imageId					=	uniqid();

			try {
				$image					=	new \CBLib\Image\Image( $imageSoftware, $resample, $aspectRatio );

				$image->setName( $imageId );
				$image->setSource( $_FILES[$type] );
				$image->setDestination( $imagePath . '/' );

				$image->processImage( $imageWidth, $imageHeight );

				$newFileName			=	$image->getCleanFilename();

				$image->setName( 'tn' . $imageId );

				$image->processImage( $thumbWidth, $thumbHeight );

				if ( $row->get( $type ) ) {
					$oldImage			=	$imagePath . '/' . $row->get( $type );

					if ( file_exists( $oldImage ) ) {
						@unlink( $oldImage );
					}

					$oldThumbnail		=	$imagePath . '/tn' . $row->get( $type );

					if ( file_exists( $oldThumbnail ) ) {
						@unlink( $oldThumbnail );
					}
				}

				$row->set( $type, $newFileName );
			} catch ( \Exception $e ) {
				$row->setError( $e->getMessage() );

				return false;
			}
		} elseif ( ( $method === 2 ) && $row->get( $type ) ) {
			$image						=	$imagePath . '/' . $row->get( $type );

			if ( file_exists( $image ) ) {
				@unlink( $image );
			}

			$thumbnail					=	$imagePath . '/tn' . $row->get( $type );

			if ( file_exists( $thumbnail ) ) {
				@unlink( $thumbnail );
			}

			$row->set( $type, '' );
		}

		return true;
	}
コード例 #8
0
ファイル: Parser.php プロジェクト: kosmosby/medicine-prof
	/**
	 * Replaces @MENTION with profile urls
	 *
	 * @return string
	 */
	public function profiles()
	{
		global $_CB_database, $_CB_framework;

		/** @var UserTable[] $users */
		static $users						=	array();

		foreach ( $this->words as $k => $word ) {
			if ( preg_match( $this->regexp['profile'], $word, $match ) ) {
				$cleanWord					=	Get::clean( $match[1], GetterInterface::STRING );

				if ( ! isset( $users[$cleanWord] ) ) {
					$user					=	new UserTable();

					if ( is_numeric( $match[1] ) ) {
						$user->load( (int) $match[1] );
					}

					if ( ! $user->get( 'id' ) ) {
						$wordNext2			=	( isset( $this->words[$k+1] ) && ( ! preg_match( $this->regexp['profile'], $this->words[$k+1] ) ) ? $cleanWord . ' ' . Get::clean( $this->words[$k+1], GetterInterface::STRING ) : null );
						$wordNext3			=	( $wordNext2 && isset( $this->words[$k+2] ) && ( ! preg_match( $this->regexp['profile'], $this->words[$k+2] ) ) ? $wordNext2 . ' ' . Get::clean( $this->words[$k+2], GetterInterface::STRING ) : null );
						$wordNext4			=	( $wordNext3 && isset( $this->words[$k+3] ) && ( ! preg_match( $this->regexp['profile'], $this->words[$k+3] ) ) ? $wordNext3 . ' ' . Get::clean( $this->words[$k+3], GetterInterface::STRING ) : null );
						$wordNext5			=	( $wordNext4 && isset( $this->words[$k+4] ) && ( ! preg_match( $this->regexp['profile'], $this->words[$k+4] ) ) ? $wordNext4 . ' ' . Get::clean( $this->words[$k+4], GetterInterface::STRING ) : null );
						$wordNext6			=	( $wordNext5 && isset( $this->words[$k+5] ) && ( ! preg_match( $this->regexp['profile'], $this->words[$k+5] ) ) ? $wordNext5 . ' ' . Get::clean( $this->words[$k+5], GetterInterface::STRING ) : null );

						$query				=	'SELECT c.*, u.*'
											.	"\n FROM " . $_CB_database->NameQuote( '#__users' ) . " AS u"
											.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS c"
											.	' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = u.' . $_CB_database->NameQuote( 'id' )
											.	"\n WHERE ( u." . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $cleanWord )		// Match username exactly
											.	' OR u.' . $_CB_database->NameQuote( 'name' ) . ' = ' . $_CB_database->Quote( $cleanWord );					// Match name exactly

						if ( $wordNext2 ) { // 2 Words
							$query			.=	' OR u.' . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $wordNext2 )				// Match username +1 word exactly
											.	' OR u.' . $_CB_database->NameQuote( 'name' ) . ' = ' . $_CB_database->Quote( $wordNext2 );					// Match name +1 word exactly
						}

						if ( $wordNext3 ) { // 3 Words
							$query			.=	' OR u.' . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $wordNext3 )				// Match username +2 words exactly
											.	' OR u.' . $_CB_database->NameQuote( 'name' ) . ' = ' . $_CB_database->Quote( $wordNext3 );					// Match name +2 words exactly
						}

						if ( $wordNext4 ) { // 4 Words
							$query			.=	' OR u.' . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $wordNext4 )				// Match username +3 words exactly
											.	' OR u.' . $_CB_database->NameQuote( 'name' ) . ' = ' . $_CB_database->Quote( $wordNext4 );					// Match name +3 words exactly
						}

						if ( $wordNext5 ) { // 5 Words
							$query			.=	' OR u.' . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $wordNext5 )				// Match username +4 words exactly
											.	' OR u.' . $_CB_database->NameQuote( 'name' ) . ' = ' . $_CB_database->Quote( $wordNext5 );					// Match name +4 words exactly
						}

						if ( $wordNext6 ) { // 6 Words
							$query			.=	' OR u.' . $_CB_database->NameQuote( 'username' ) . ' = ' . $_CB_database->Quote( $wordNext6 )				// Match username +5 words exactly
											.	' OR u.' . $_CB_database->NameQuote( 'name' ) . ' = ' . $_CB_database->Quote( $wordNext6 );					// Match name +5 words exactly
						}

						$query				.=	' )'
											.	"\n ORDER BY u." . $_CB_database->NameQuote( 'username' ) . ", u." . $_CB_database->NameQuote( 'name' );
						$_CB_database->setQuery( $query );
						$_CB_database->loadObject( $user );
					}

					$users[$cleanWord]		=	$user;
				}

				$user						=	$users[$cleanWord];

				if ( $user->get( 'id' ) ) {
					$this->parsed			=	preg_replace( '/@' . (int) $user->get( 'id' ) . '\b|@' . preg_quote( $user->get( 'name' ), '/' ) . '\b|@' . preg_quote( $user->get( 'username' ), '/' ) . '\b|' . preg_quote( $word, '/' ) . '\b/i', '<a href="' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ) ) . '" rel="nofollow">@' . htmlspecialchars( getNameFormat( $user->get( 'name' ), $user->get( 'username' ), Application::Config()->get( 'name_format' ) ) ) . '</a>', $this->parsed );
				}
			}
		}

		return $this->parsed;
	}
コード例 #9
0
ファイル: cb.core.php プロジェクト: bobozhangshao/HeartCare
 /**
  * Returns a USERPARAMS field in specified format
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $output      'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string      $formatting  'table', 'td', 'span', 'div', 'none'
  * @param  string      $reason      'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int         $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed
  */
 public function getFieldRow(&$field, &$user, $output, $formatting, $reason, $list_compare_types)
 {
     global $_CB_framework, $ueConfig;
     $results = null;
     if (class_exists('JFactory')) {
         // Joomla 1.5 :
         $lang = JFactory::getLanguage();
         $lang->load('com_users');
     }
     $pseudoFields = array();
     //Implementing Joomla's new user parameters such as editor
     $ui = $_CB_framework->getUi();
     $userParams = $this->_getUserParams($ui, $user);
     if (is_array($userParams) && count($userParams) > 0 && ($ui == 2 || (isset($ueConfig['frontend_userparams']) ? $ueConfig['frontend_userparams'] == 1 : in_array($_CB_framework->getCfg('frontend_userparams'), array('1', null))))) {
         if ($ui == 1) {
             $excludeParams = explode('|*|', $field->params->get('hide_userparams'));
         } else {
             $excludeParams = array();
         }
         //Loop through each parameter and prepare rendering appropriately.
         foreach ($userParams as $k => $userParam) {
             if (checkJversion() >= 2) {
                 $nameId = isset($userParam[4]) ? $userParam[4] : null;
             } else {
                 $nameId = isset($userParam[5]) ? $userParam[5] : null;
             }
             if (!$excludeParams || !$nameId || $nameId && !in_array($nameId, $excludeParams)) {
                 $paramField = new FieldTable($field->getDbo());
                 $paramField->title = $userParam[0];
                 $paramField->_html = $userParam[1];
                 $paramField->description = isset($userParam[2]) && class_exists("JText") ? JText::_($userParam[2]) : null;
                 $paramField->name = isset($userParam[3]) && class_exists("JText") ? JText::_($userParam[3]) : null;
                 // very probably wrong!
                 $paramField->fieldid = 'userparam_' . $k;
                 $paramField->type = 'param';
                 // this is for cb_ftparam class to be correct.
                 if (!preg_match('/<(?:input|select|textarea)[^>]*class[^>]*>/i', $paramField->_html)) {
                     $paramField->_html = preg_replace('/<(input|select|textarea)/i', '<$1 class="form-control"', $paramField->_html);
                 }
                 $pseudoFields[] = $paramField;
             }
         }
     }
     if ($ui == 2) {
         $i_am_super_admin = Application::MyUser()->isSuperAdmin();
         $canBlockUser = Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.edit.state', 'com_users');
         $canEmailEvents = $user->id == 0 && $canBlockUser || Application::User((int) $user->id)->isAuthorizedToPerformActionOnAsset('core.edit.state', 'com_users') || Application::User((int) $user->id)->canViewAccessLevel(Application::Config()->get('moderator_viewaccesslevel', 3, \CBLib\Registry\GetterInterface::INT));
         $lists = array();
         if ($canBlockUser) {
             // ensure user can't add group higher than themselves
             $gtree = $_CB_framework->acl->get_groups_below_me();
             if (!$i_am_super_admin && $user->id && Application::User((int) $user->id)->isAuthorizedToPerformActionOnAsset('core.manage', 'com_users') && (Application::User((int) $user->id)->isAuthorizedToPerformActionOnAsset('core.edit', 'com_users') || Application::User((int) $user->id)->isAuthorizedToPerformActionOnAsset('core.edit.state', 'com_users'))) {
                 $disabled = ' disabled="disabled"';
             } else {
                 $disabled = '';
             }
             if ($user->id) {
                 $strgids = array_map('strval', Application::User((int) $user->id)->getAuthorisedGroups(false));
             } else {
                 $strgids = (string) $_CB_framework->getCfg('new_usertype');
             }
             $lists['gid'] = moscomprofilerHTML::selectList($gtree, 'gid[]', 'class="form-control" size="11" multiple="multiple"' . $disabled, 'value', 'text', $strgids, 2, false, null, false);
             // build the html select list
             $lists['block'] = moscomprofilerHTML::yesnoSelectList('block', 'class="form-control"', (string) $user->block);
             $list_banned = array();
             $list_banned[] = moscomprofilerHTML::makeOption('1', CBTxt::T('Banned'));
             $list_banned[] = moscomprofilerHTML::makeOption('2', CBTxt::T('Pending'));
             $list_banned[] = moscomprofilerHTML::makeOption('0', CBTxt::T('Active'));
             $lists['banned'] = moscomprofilerHTML::selectList($list_banned, 'banned', 'class="form-control"', 'value', 'text', (string) $user->banned, 2, false, null, false);
             $list_approved = array();
             $list_approved[] = moscomprofilerHTML::makeOption('2', CBTxt::T('Rejected'));
             $list_approved[] = moscomprofilerHTML::makeOption('0', CBTxt::T('Pending'));
             $list_approved[] = moscomprofilerHTML::makeOption('1', CBTxt::T('Approved'));
             $lists['approved'] = moscomprofilerHTML::selectList($list_approved, 'approved', 'class="form-control"', 'value', 'text', (string) $user->approved, 2, false, null, false);
             $lists['confirmed'] = moscomprofilerHTML::yesnoSelectList('confirmed', 'class="form-control"', (string) $user->confirmed, CBTxt::T('Confirmed'), CBTxt::T('Pending'));
             // build the html select list
             $lists['sendEmail'] = moscomprofilerHTML::yesnoSelectList('sendEmail', 'class="form-control"', (string) $user->sendEmail);
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Group';
             // For translation parser:  CBTxt::T( 'Group' );
             $paramField->_html = $lists['gid'];
             $paramField->description = '';
             $paramField->name = 'gid';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Block User';
             // For translation parser:  CBTxt::T( 'Block User' );
             $paramField->_html = $lists['block'];
             $paramField->description = '';
             $paramField->name = 'block';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Approve User';
             // For translation parser:  CBTxt::T( 'Approve User' );
             $paramField->_html = $lists['approved'];
             $paramField->description = '';
             $paramField->name = 'approved';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Confirm User';
             // For translation parser:  CBTxt::T( 'Confirm User' );
             $paramField->_html = $lists['confirmed'];
             $paramField->description = '';
             $paramField->name = 'confirmed';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Ban User';
             // For translation parser:  CBTxt::T( 'Ban User' );
             $paramField->_html = $lists['banned'];
             $paramField->description = '';
             $paramField->name = 'banned';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Receive Moderator Emails';
             // For translation parser:  CBTxt::T( 'Receive Moderator Emails' );
             if ($canEmailEvents || $user->sendEmail) {
                 $paramField->_html = $lists['sendEmail'];
             } else {
                 $paramField->_html = CBTxt::T('No (User\'s group-level doesn\'t allow this)') . '<input type="hidden" name="sendEmail" value="0" />';
             }
             $paramField->description = '';
             $paramField->name = 'sendEmail';
             $pseudoFields[] = $paramField;
         }
         if ($user->id) {
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Register Date';
             // For translation parser:  CBTxt::T( 'Register Date' );
             $paramField->_html = cbFormatDate($user->registerDate);
             $paramField->description = '';
             $paramField->name = 'registerDate';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Last Visit Date';
             // For translation parser:  CBTxt::T( 'Last Visit Date' );
             $paramField->_html = cbFormatDate($user->lastvisitDate);
             $paramField->description = '';
             $paramField->name = 'lastvisitDate';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Last Reset Time';
             // For translation parser:  CBTxt::T( 'Last Reset Time' );
             $paramField->_html = cbFormatDate($user->lastResetTime);
             $paramField->description = '';
             $paramField->name = 'lastResetTime';
             $pseudoFields[] = $paramField;
             $paramField = new FieldTable($field->getDbo());
             $paramField->title = 'Password Reset Count';
             // For translation parser:  CBTxt::T( 'Password Reset Count' );
             $paramField->_html = (int) $user->resetCount;
             $paramField->description = '';
             $paramField->name = 'resetCount';
             $pseudoFields[] = $paramField;
         }
     }
     switch ($output) {
         case 'htmledit':
             foreach ($pseudoFields as $paramField) {
                 $paramField->required = $this->_isRequired($field, $user, $reason);
                 $paramField->profile = $field->profile;
                 $paramField->params = $field->params;
                 $results .= parent::getFieldRow($paramField, $user, $output, $formatting, $reason, $list_compare_types);
             }
             unset($pseudoFields);
             return $results;
             break;
         default:
             return null;
             break;
     }
 }
コード例 #10
0
 /**
  * Outputs a JQuery init string into JQuery strings at end of page,
  * and adds if needed JS file inclusions at begin of page.
  * Pro-memo, JQuery runs in CB in noConflict mode.
  *
  * @param  string  $javascriptCode  Javascript code ended by ; which will be put in between jQuery(document).ready(function($){ AND });
  * @param  string  $jQueryPlugin    (optional) name of plugin to auto-load (if core plugin, or call first addJQueryPlugin).
  */
 function outputCbJQuery($javascriptCode, $jQueryPlugin = null)
 {
     if (Application::Config()->get('jsJqueryMigrate', 1) || Application::Cms()->getClientId()) {
         $this->addJQueryPlugin('migrate', true);
     }
     if ($jQueryPlugin) {
         $this->addJQueryPlugin($jQueryPlugin, true);
     }
     if ($javascriptCode) {
         $this->_jQueryCodes[] = $javascriptCode;
     }
     if ($this->document->isHeadOutputed()) {
         $this->getAllJsPageCodes();
     }
 }
コード例 #11
0
ファイル: CBConfig.php プロジェクト: bobozhangshao/HeartCare
 /**
  * Legacy support function: Loads the CB Config from database (if it is ready) and
  * Sets the global $ueConfig
  * It also loads the Language handler powering CBTxt.
  *
  * @param  boolean  $legacy  prepare legacy config params
  * @return void
  */
 public static function loadLegacyCBueConfig($legacy = false)
 {
     global $ueConfig;
     if (self::$configReady) {
         $version = $ueConfig['version'];
         $config = Application::Config();
         $ueConfig = $config->asArray();
         $ueConfig['version'] = $version;
         // Legacy config options for B/C:
         if ($legacy) {
             if (isset($ueConfig['profile_viewaccesslevel'])) {
                 switch ((int) $ueConfig['profile_viewaccesslevel']) {
                     case 1:
                         // Public
                     // Public
                     case 5:
                         // Guest
                         $profileAccess = '1';
                         // Public
                         break;
                     case 3:
                         // Special
                         $profileAccess = '3';
                         // Author
                         break;
                     default:
                         $profileAccess = '2';
                         // Registered
                         break;
                 }
             } else {
                 $profileAccess = '2';
                 // Registered
             }
             if (isset($ueConfig['moderator_viewaccesslevel'])) {
                 switch ((int) $ueConfig['moderator_viewaccesslevel']) {
                     case 1:
                         // Public
                     // Public
                     case 5:
                         // Guest
                         $modAccess = '1';
                         // Public
                         break;
                     case 2:
                         // Registered
                         $modAccess = '2';
                         // Registered
                         break;
                     default:
                         $modAccess = '6';
                         // Manager
                         break;
                 }
             } else {
                 $modAccess = '6';
                 // Manager
             }
             $ueConfig['allow_profileviewbyGID'] = $profileAccess;
             // "Allow Access To:"
             $ueConfig['imageApproverGid'] = $modAccess;
             // "Moderator Groups"
             $ueConfig['reg_email_checker'] = '0';
             // "Ajax Email checker"
             $ueConfig['reg_toc_url'] = '';
             // "URL to Terms &amp; Conditions"
             $ueConfig['num_per_page'] = '30';
             // "Users Per Page"
             $ueConfig['allow_profilelink'] = '1';
             // "Allow Link to Profile"
             $ueConfig['nesttabs'] = '0';
             // "Nest Tabs"
             $ueConfig['xhtmlComply'] = '1';
             // "W3C XHTML 1.0 Trans. compliance"
             $ueConfig['im_path'] = 'auto';
             // "Path to ImageMagick"
             $ueConfig['netpbm_path'] = 'auto';
             // "Path to NetPBM"
             $ueConfig['allowAvatar'] = '1';
             // "Image"
             $ueConfig['allowAvatarUpload'] = '1';
             // "Allow Image Upload"
             $ueConfig['allowAvatarGallery'] = '1';
             // "Use Image Gallery"
         }
         $languageParams = array('debugMode' => $config->get('translations_debug', 0));
         if ($languageParams['debugMode'] == 0) {
             $languageParams['translationsLogger'] = null;
         }
     } else {
         $languageParams = array();
     }
     // Set Language as singleton and instantiate it now that Config is read:
     Application::DI()->get('Language', $languageParams);
 }
コード例 #12
0
ファイル: comprofiler.php プロジェクト: ankaau/GathBandhan
function userProfile($option, $uid, $submitvalue)
{
    global $_REQUEST, $ueConfig, $_CB_framework, $_PLUGINS;
    $msg = null;
    if (isset($_REQUEST['user'])) {
        if (!CBuser::getMyInstance()->authoriseView('profile', $uid)) {
            $canRegister = !isset($ueConfig['reg_admin_allowcbregistration']) || $ueConfig['reg_admin_allowcbregistration'] != '1';
            // Can the guest access once registered with default User Group ? (and doing the check only if he even can register to avoid unneeded checks)
            $canAccess = $canRegister && Application::CmsPermissions()->checkGroupsForViewAccessLevel($_CB_framework->getCfg('new_usertype'), Application::Config()->get('profile_viewaccesslevel', 3));
            if ($_CB_framework->myId() < 1 && !($_CB_framework->getCfg('allowUserRegistration') == '0' && $canRegister) && $canAccess) {
                $msg = CBTxt::Th('UE_REGISTERFORPROFILEVIEW', 'Please log in or sign up to view user profiles.');
            } else {
                $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
            }
        }
    } else {
        if ($uid == 0) {
            $msg = CBTxt::Th('UE_REGISTERFORPROFILE', 'Please log in or sign up to view or modify your profile.');
        }
    }
    $_PLUGINS->loadPluginGroup('user');
    $_PLUGINS->trigger('onBeforeUserProfileAccess', array($uid, &$msg, 1));
    if ($msg) {
        $_CB_framework->enqueueMessage($msg, 'error');
        return;
    }
    $user =& loadComprofilerUser($uid);
    if ($user === null) {
        $_CB_framework->enqueueMessage(CBTxt::Th('UE_NOSUCHPROFILE', 'This profile does not exist or is no longer available'), 'error');
        return;
    }
    if (cbGetParam($_GET, 'reason') == 'canceledit') {
        if ($uid == 0) {
            $Euid = $_CB_framework->myId();
        } else {
            $Euid = $uid;
        }
        $msg = cbCheckIfUserCanPerformUserTask($Euid, 'allowModeratorsUserEdit');
        if ($Euid != $_CB_framework->myId() && $msg === null) {
            // safeguard against missconfiguration of the above: also avoids lower-level users editing higher level ones:
            $msg = checkCBpermissions(array((int) $Euid), 'edit', true);
        }
        $_PLUGINS->trigger('onBeforeUserProfileEditRequest', array($Euid, &$msg, 1));
        if ($msg) {
            $_CB_framework->enqueueMessage($msg, 'error');
            return;
        }
        $_PLUGINS->trigger('onAfterUserProfileEditCancel', array(&$user));
        if ($_PLUGINS->is_errors()) {
            echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n";
            exit;
        }
    }
    HTML_comprofiler::userProfile($user, $option, $submitvalue);
}
コード例 #13
0
ファイル: PhotoTable.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param bool $updateNulls
	 * @return bool
	 */
	public function store( $updateNulls = false )
	{
		global $_CB_framework, $_PLUGINS;

		$new						=	( $this->get( 'id' ) ? false : true );
		$old						=	new self();

		$this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) );

		if ( isset( $_FILES['image']['tmp_name'] ) && ( ! empty( $_FILES['image']['tmp_name'] ) ) ) {
			static $params		=	null;

			if ( ! $params ) {
				$plugin				=	$_PLUGINS->getLoadedPlugin( 'user/plug_cbgroupjive/plugins', 'cbgroupjivephoto' );
				$params				=	$_PLUGINS->getPluginParams( $plugin );
			}

			$basePath				=	$_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivephoto';
			$filePath				=	$basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' );

			CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) );

			$resample				=	$params->get( 'groups_photo_resample', 1 );
			$aspectRatio			=	$params->get( 'groups_photo_maintain_aspect_ratio', 1 );
			$imageHeight			=	(int) $params->get( 'groups_photo_image_height', 640 );

			if ( ! $imageHeight ) {
				$imageHeight		=	640;
			}

			$imageWidth				=	(int) $params->get( 'groups_photo_image_width', 1280 );

			if ( ! $imageWidth ) {
				$imageWidth			=	1280;
			}

			$thumbHeight			=	(int) $params->get( 'groups_photo_thumbnail_height', 320 );

			if ( ! $thumbHeight ) {
				$thumbHeight		=	320;
			}

			$thumbWidth				=	(int) $params->get( 'groups_photo_thumbnail_width', 640 );

			if ( ! $thumbWidth ) {
				$thumbWidth			=	640;
			}

			$conversionType			=	(int) Application::Config()->get( 'conversiontype', 0 );
			$imageSoftware			=	( $conversionType == 5 ? 'gmagick' : ( $conversionType == 1 ? 'imagick' : 'gd' ) );

			$fileExtension			=	strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', pathinfo( $_FILES['image']['name'], PATHINFO_EXTENSION ) ) );
			$fileName				=	Get::clean( pathinfo( $_FILES['image']['name'], PATHINFO_FILENAME ), GetterInterface::STRING ) . '.' . $fileExtension;
			$fileId					=	uniqid();

			try {
				$image				=	new Image( $imageSoftware, $resample, $aspectRatio );

				$image->setName( $fileId );
				$image->setSource( $_FILES['image'] );
				$image->setDestination( $filePath . '/' );

				$image->processImage( $imageWidth, $imageHeight );

				$newFileName		=	$image->getCleanFilename();

				$image->setName( 'tn' . $fileId );

				$image->processImage( $thumbWidth, $thumbHeight );

				if ( $this->get( 'image' ) ) {
					if ( file_exists( $filePath . '/' . $this->get( 'image' ) ) ) {
						@unlink( $filePath . '/' . $this->get( 'image' ) );
					}

					if ( file_exists( $filePath . '/tn' . $this->get( 'image' ) ) ) {
						@unlink( $filePath . '/tn' . $this->get( 'image' ) );
					}
				}

				$this->set( 'image', $newFileName );
				$this->set( 'filename', $fileName );

				$params				=	$this->params();

				$params->unsetEntry( 'name' );
				$params->unsetEntry( 'extension' );
				$params->unsetEntry( 'mimetype' );
				$params->unsetEntry( 'filesize' );
				$params->unsetEntry( 'filesize_thumbnail' );
				$params->unsetEntry( 'height' );
				$params->unsetEntry( 'width' );
				$params->unsetEntry( 'height_thumbnail' );
				$params->unsetEntry( 'width_thumbnail' );

				$params->set( 'name', $this->name() );
				$params->set( 'extension', $this->extension() );
				$params->set( 'mimetype', $this->mimeType() );
				$params->set( 'filesize', $this->size( true ) );
				$params->set( 'filesize_thumbnail', $this->size( true, true ) );
				$params->set( 'height', $this->height() );
				$params->set( 'width', $this->width() );
				$params->set( 'height_thumbnail', $this->height( true ) );
				$params->set( 'width_thumbnail', $this->width( true ) );

				$this->set( 'params', $params->asJson() );
			} catch ( Exception $e ) {
				$this->setError( $e->getMessage() );

				return false;
			}
		} elseif ( ! $this->get( 'filename' ) ) {
			$this->set( 'filename', $this->get( 'image' ) );
		}

		if ( ! $new ) {
			$old->load( (int) $this->get( 'id' ) );

			$_PLUGINS->trigger( 'gj_onBeforeUpdatePhoto', array( &$this, $old ) );
		} else {
			$_PLUGINS->trigger( 'gj_onBeforeCreatePhoto', array( &$this ) );
		}

		if ( ! parent::store( $updateNulls ) ) {
			return false;
		}

		if ( $old->get( 'id' ) && $this->get( 'image' ) && ( $old->get( 'group' ) != $this->get( 'group' ) ) ) {
			$basePath				=	$_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivephoto';
			$oldPath				=	$basePath . '/' . (int) $old->group()->get( 'category' ) . '/' . (int) $old->group()->get( 'id' );
			$newPath				=	$basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' );

			if ( is_dir( $oldPath ) ) {
				CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) );

				if ( file_exists( $oldPath . '/' . $this->get( 'image' ) ) ) {
					@rename( $oldPath . '/' . $this->get( 'image' ), $newPath . '/' . $this->get( 'image' ) );
				}

				if ( file_exists( $oldPath . '/tn' . $this->get( 'image' ) ) ) {
					@rename( $oldPath . '/tn' . $this->get( 'image' ), $newPath . '/tn' . $this->get( 'image' ) );
				}
			}
		}

		if ( ! $new ) {
			$_PLUGINS->trigger( 'gj_onAfterUpdatePhoto', array( $this, $old ) );
		} else {
			$_PLUGINS->trigger( 'gj_onAfterCreatePhoto', array( $this ) );
		}

		return true;
	}
コード例 #14
0
	private function _displayWebAddress( $oValue )
	{
		if ( Application::Config()->get( 'allow_website' ) != 1 ) {
			return '';
		}

		$oReturn			=	explode( '|*|', $oValue );
		if ( count( $oReturn ) < 2 ) {
			$oReturn[1]		=	$oReturn[0];
		}

		return '<a href="http://' . htmlspecialchars( $oReturn[0] ) . '" target="_blank" rel="nofollow">' . htmlspecialchars( $oReturn[1] ) . '</a>';
	}
コード例 #15
0
ファイル: CBActivity.php プロジェクト: kosmosby/medicine-prof
	/**
	 * Returns an options array of available user tags with optional activity specific
	 *
	 * @param null|int|ActivityTable $activityId
	 * @param null|int               $userId
	 * @return array
	 */
	static public function loadTagOptions( $activityId = null, $userId = null )
	{
		global $_CB_database;

		/** @var ActivityTable[] $cache */
		static $cache							=	array();

		if ( $activityId && ( $userId === null ) ) {
			if ( $activityId instanceof ActivityTable ) {
				$activity						=	$activityId;
				$activityId						=	(int) $activity->get( 'id' );
			} else {
				if ( ! isset( $cache[$activityId] ) ) {
					$activity					=	new ActivityTable();

					$activity->load( (int) $activityId );

					$cache[$activityId]			=	$activity;
				}

				$activity						=	$cache[$activityId];
			}

			$userId								=	(int) $activity->get( 'user_id' );
		} elseif ( $userId === null ) {
			$userId								=	Application::MyUser()->getUserId();
		}

		static $connections						=	array();
		static $custom							=	array();
		static $options							=	array();

		if ( ! isset( $options[$userId][$activityId] ) ) {
			if ( ! isset( $connections[$userId] ) ) {
				$connectionOptions				=	array();

				if ( Application::Config()->get( 'allowConnections' ) ) {
					$cbConnection				=	new \cbConnection( $userId );

					foreach( $cbConnection->getConnectedToMe( $userId ) as $connection ) {
						$connectionOptions[]	=	\moscomprofilerHTML::makeOption( (string) $connection->id, getNameFormat( $connection->name, $connection->username, Application::Config()->get( 'name_format', 3 ) ) );
					}
				}

				$connections[$userId]			=	$connectionOptions;
			}

			if ( ! isset( $custom[$activityId] ) ) {
				$activityOptions				=	array();

				if ( $activityId ) {
					$exclude					=	array();

					foreach ( $connections[$userId] as $connection ) {
						$exclude[]				=	$connection->value;
					}

					$query						=	'SELECT *'
												.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_activity_tags' )
												.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'activity' )
												.	"\n AND " . $_CB_database->NameQuote( 'item' ) . " = " . (int) $activityId
												.	"\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " ASC";
					$_CB_database->setQuery( $query );
					$tags						=	$_CB_database->loadObjectList( null, '\CB\Plugin\Activity\Table\TagTable', array( $_CB_database ) );

					/** @var TagTable[] $tags */
					foreach ( $tags as $tag ) {
						if ( ! in_array( $tag->get( 'user' ), $exclude ) ) {
							$activityOptions[]	=	\moscomprofilerHTML::makeOption( (string) $tag->get( 'user' ), $tag->get( 'user' ) );
						}
					}
				}

				$custom[$activityId]			=	$activityOptions;
			}

			$options[$userId][$activityId]		=	array_merge( $connections[$userId], $custom[$activityId] );
		}

		return $options[$userId][$activityId];
	}
コード例 #16
0
 /**
  * Main Filtering method
  *
  * @param   string|array  $source
  * @param   string        $method       'html' or 'text' only
  * @param   array|null    $allowedTags  if $method is 'html' this is the list of allowed tags. if NULL: uses the Application Config setting.
  * @return  string|array
  *
  * @throws \InvalidArgumentException
  */
 public static function filter($source, $method, array $allowedTags = null)
 {
     if ($method == 'html') {
         $filter = static::getInstance(array(), array(), 1, 1);
         if ($allowedTags === null) {
             $allowedTags = Application::Config()->get('html_filter_allowed_tags');
         }
         if ($allowedTags) {
             $filter->tagBlacklist = array_diff($filter->tagBlacklist, explode(' ', $allowedTags));
         }
         return $filter->process($source);
     }
     if ($method == 'text') {
         $filter = static::getInstance();
         return $filter->process($source);
     }
     throw new \InvalidArgumentException(__CLASS__ . '::' . __FUNCTION__ . ': Unexpected filter method.');
 }