/**
	 * 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 )
					);
	}
Example #2
0
	/**
	 * render frontend forum backlink
	 *
	 * @param GroupTable       $group
	 * @param object           $category
	 * @param cbgjForumsPlugin $plugin
	 * @return string
	 */
	static function showBacklink( $group, $category, $plugin )
	{
		global $_CB_framework;

		$return		=	'<div class="cb_template cb_template_' . selectTemplate( 'dir' ) . '">'
					.		'<div class="gjBacklink text-right" style="margin-bottom: 5px;">'
					.			'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '\';" class="gjButton gjButtonBacklink btn btn-xs btn-default"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'Back to Group' ) . '</button>'
					.		'</div>'
					.	'</div>';

		return $return;
	}
Example #3
0
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NOT_INSTALLED', ':: Action [action] :: CB GroupJive is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'groupjive' ) as $row ) {
			/** @var ParamsInterface $row */
			switch( (int) $row->get( 'mode', 1, GetterInterface::INT ) ) {
				case 3:
					$owner							=	$row->get( 'owner', null, GetterInterface::STRING );

					if ( ! $owner ) {
						$owner						=	(int) $user->get( 'id' );
					} else {
						$owner						=	(int) $trigger->getSubstituteString( $owner );
					}

					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_OWNER', ':: Action [action] :: CB GroupJive skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$name							=	$trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );

					if ( ! $name ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_NAME', ':: Action [action] :: CB GroupJive skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$category						=	new CategoryTable();

					$category->load( array( 'name' => $name ) );

					if ( ! $category->get( 'id' ) ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CATEGORY', ':: Action [action] :: CB GroupJive skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$category->set( 'published', 1 );
					$category->set( 'user_id', $owner );
					$category->set( 'name', $name );
					$category->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );
					$category->set( 'access', 1 );
					$category->set( 'create_access', 0 );
					$category->set( 'types', $row->get( 'types', '1|*|2|*|3', GetterInterface::STRING ) );
					$category->set( 'ordering', 1 );

					if ( ! $category->store() ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $category->getError() ) ) );

							continue;
						}
					}
					break;
				case 2:
					$owner							=	$row->get( 'owner', null, GetterInterface::STRING );

					if ( ! $owner ) {
						$owner						=	(int) $user->get( 'id' );
					} else {
						$owner						=	(int) $trigger->getSubstituteString( $owner );
					}

					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_OWNER', ':: Action [action] :: CB GroupJive skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$categoryId						=	(int) $row->get( 'category', -1, GetterInterface::INT );

					$category						=	new CategoryTable();

					if ( $categoryId == -1 ) {
						$name						=	$trigger->getSubstituteString( $row->get( 'category_name', null, GetterInterface::STRING ) );

						if ( ! $name ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CAT_NAME', ':: Action [action] :: CB GroupJive skipped due to missing category name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
							}

							continue;
						}

						$category->load( array( 'name' => $name ) );

						if ( ! $category->get( 'id' ) ) {
							$category->set( 'published', 1 );
							$category->set( 'user_id', $owner );
							$category->set( 'name', $name );
							$category->set( 'description', $trigger->getSubstituteString( $row->get( 'category_description', null, GetterInterface::STRING ) ) );
							$category->set( 'access', 1 );
							$category->set( 'create_access', 0 );
							$category->set( 'types', $row->get( 'category_types', '1|*|2|*|3', GetterInterface::STRING ) );
							$category->set( 'ordering', 1 );

							if ( ! $category->store() ) {
								if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
									var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $category->getError() ) ) );
								}

								continue;
							}
						}
					} else {
						$category->load( (int) $categoryId );
					}

					if ( ! $category->get( 'id' ) ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CATEGORY', ':: Action [action] :: CB GroupJive skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$name							=	$trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );

					if ( ! $name ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_NAME', ':: Action [action] :: CB GroupJive skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$group							=	new GroupTable();
					$join							=	false;

					if ( $row->get( 'unique', 1, GetterInterface::BOOLEAN ) ) {
						$group->load( array( 'category' => (int) $category->get( 'id' ), 'user_id' => (int) $owner, 'name' => $name ) );
					} else {
						$group->load( array( 'category' => (int) $category->get( 'id' ), 'name' => $name ) );

						if ( $row->get( 'autojoin', 1, GetterInterface::BOOLEAN ) ) {
							$join					=	true;
						}
					}

					if ( ! $group->get( 'id' ) ) {
						$group->set( 'published', 1 );
						$group->set( 'category', (int) $category->get( 'id' ) );
						$group->set( 'user_id', $owner );
						$group->set( 'name', $name );
						$group->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );
						$group->set( 'types', (int) $row->get( 'type', 1, GetterInterface::INT ) );
						$group->set( 'ordering', 1 );

						if ( ! $group->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $group->getError() ) ) );
							}

							continue;
						}
					} elseif ( $join ) {
						$groupUser					=	new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database );

						$groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) );

						if ( ! $groupUser->get( 'id' ) ) {
							$groupUser->set( 'user_id', (int) $user->get( 'id' ) );
							$groupUser->set( 'group', (int) $group->get( 'id' ) );
							$groupUser->set( 'status', (int) $row->get( 'group_status', 1, GetterInterface::INT ) );

							if ( ! $groupUser->store() ) {
								if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
									var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $groupUser->getError() ) ) );
								}

								continue;
							}
						}
					}
					break;
				case 4:
					$groups							=	$row->get( 'groups', null, GetterInterface::STRING );

					if ( $groups ) {
						$groups						=	explode( '|*|', $groups );

						cbArrayToInts( $groups );

						foreach ( $groups as $groupId ) {
							$group					=	new GroupTable();

							$group->load( (int) $groupId );

							if ( $group->get( 'id' ) ) {
								$groupUser			=	new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database );

								$groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) );

								if ( $groupUser->get( 'id' ) && ( $groupUser->get( 'status' ) != 4 ) ) {
									$groupUser->delete();
								}
							}
						}
					}
					break;
				case 1:
				default:
					$groups							=	$row->get( 'groups', null, GetterInterface::STRING );

					if ( $groups ) {
						$groups						=	explode( '|*|', $groups );

						cbArrayToInts( $groups );

						foreach ( $groups as $groupId ) {
							$group					=	new GroupTable();

							$group->load( (int) $groupId );

							if ( $group->get( 'id' ) ) {
								$groupUser			=	new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database );

								$groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) );

								if ( ! $groupUser->get( 'id' ) ) {
									$groupUser->set( 'user_id', (int) $user->get( 'id' ) );
									$groupUser->set( 'group', (int) $group->get( 'id' ) );
									$groupUser->set( 'status', (int) $row->get( 'status', 1, GetterInterface::INT ) );

									if ( ! $groupUser->store() ) {
										if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
											var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $groupUser->getError() ) ) );
										}

										continue;
									}
								}
							}
						}
					}
					break;
			}
		}
	}
Example #4
0
	/**
	 * render frontend group activity
	 *
	 * @param CB\Plugin\Activity\Table\ActivityTable $row
	 * @param string                                 $title
	 * @param string                                 $message
	 * @param CB\Plugin\Activity\Activity            $stream
	 * @param GroupTable                             $group
	 * @param cbgjPlugin                             $plugin
	 * @return string
	 */
	static function showActivity( $row, &$title, &$message, $stream, $group, $plugin )
	{
		global $_CB_framework;

		initToolTip();

		$message				=	null;

		switch( $row->get( 'subtype' ) ) {
			case 'group.join':
				$title			=	CBTxt::T( 'joined a group' );
				break;
			case 'group.leave':
				$title			=	CBTxt::T( 'left a group' );
				break;
			case 'group':
				$title			=	CBTxt::T( 'created a group' );
				break;
		}

		$user					=	CBuser::getMyUserDataInstance();
		$isModerator			=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$groupOwner				=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus				=	CBGroupJive::getGroupStatus( $user, $group );

		$return					=	'<div class="gjActivity">'
								.		'<div class="gjGroupCanvas gjPageHeader border-default">'
								.			'<div class="gjPageHeaderCanvas">'
								.				'<div class="gjPageHeaderCanvasBackground">'
								.					$group->canvas()
								.				'</div>'
								.				'<div class="gjPageHeaderCanvasLogo">'
								.					$group->logo( false, true, true )
								.				'</div>';

		if ( $isModerator || $groupOwner || ( ( ! $groupOwner ) && ( ( $userStatus === null ) || ( $userStatus === 0 ) || ( $userStatus >= 1 ) ) ) ) {
			$return				.=				'<div class="gjPageHeaderCanvasButtons text-right">';

			if ( $isModerator && ( $group->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) {
				$return			.=					' <span class="gjPageHeaderCanvasButton">'
								.						'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>'
								.					'</span>';
			} elseif ( ! $groupOwner ) {
				if ( $userStatus === null ) {
					$return		.=					' <span class="gjPageHeaderCanvasButton">'
								.						( $group->get( '_invite_id' ) ? '<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to reject all invites to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'reject', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\'; })" class="gjButton gjButtonReject btn btn-xs btn-danger">' . CBTxt::T( 'Reject' ) . '</button> ' : null )
								.						'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'join', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonJoin btn btn-xs btn-success">' . ( $group->get( '_invite_id' ) ? CBTxt::T( 'Accept Invite' ) : CBTxt::T( 'Join' ) ) . '</button>'
								.					'</span>';
				} elseif ( $userStatus === 0 ) {
					$return		.=					' <span class="gjPageHeaderCanvasButton">'
								.						'<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel your pending join request to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'cancel', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\'; })" class="gjButton gjButtonCancel btn btn-xs btn-danger">' . CBTxt::T( 'Cancel' ) . '</button> '
								.						'<span class="gjButton gjButtonPending btn btn-xs btn-warning disabled">' . CBTxt::T( 'Pending Approval' ) . '</span>'
								.					'</span>';
				}
			}

			$return				.=				'</div>';
		}

		$return					.=			'</div>'
								.			'<div class="gjPageHeaderBar border-default">'
								.				'<div class="gjPageHeaderBarTitle text-primary">'
								.					'<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $group->get( 'name' ) ) ) . '</a></strong>'
								.				'</div>'
								.				'<div class="gjPageHeaderBarCounters text-muted small">';

		if ( $group->get( 'category' ) ) {
			$return				.=					'<span class="gjPageHeaderBarCounter"><span class="gjGroupCategoryIcon fa-before fa-folder">'
								.						' <a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $group->get( 'category' ) ) ) . '">' . CBTxt::T( $group->category()->get( 'name' ) ) . '</a>'
								.					'</span></span>';
		}

		$return					.=					' <span class="gjPageHeaderBarCounter"><span class="gjGroupTypeIcon fa-before fa-globe"> ' . $group->type() . '</span></span>'
								.					' <span class="gjPageHeaderBarCounter"><span class="gjGroupUsersIcon fa-before fa-user"> ' . CBTxt::T( 'GROUP_USERS_COUNT', '%%COUNT%% User|%%COUNT%% Users', array( '%%COUNT%%' => (int) $group->get( '_users', 0 ) ) ) . '</span></span>'
								.				'</div>'
								.				( $group->get( 'description' ) ? ' <div class="gjPageHeaderBarDescription">' . cbTooltip( 1, CBTxt::T( $group->get( 'description' ) ), CBTxt::T( $group->get( 'name' ) ), 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null )
								.			'</div>'
								.		'</div>'
								.	'</div>';

		return $return;
	}
Example #5
0
	/**
	 * render frontend events
	 *
	 * @param EventTable[]     $rows
	 * @param cbPageNav        $pageNav
	 * @param bool             $searching
	 * @param array            $input
	 * @param array            $counters
	 * @param GroupTable       $group
	 * @param UserTable        $user
	 * @param cbgjEventsPlugin $plugin
	 * @return string
	 */
	static function showEvents( $rows, $pageNav, $searching, $input, &$counters, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_CB_framework->outputCbJQuery( "$( '.gjGroupEventDescription .cbMoreLess' ).cbmoreless();", 'cbmoreless' );

		$counters[]							=	'<span class="gjGroupEventsIcon fa-before fa-calendar"> ' . CBTxt::T( 'GROUP_EVENTS_COUNT', '%%COUNT%% Event|%%COUNT%% Events', array( '%%COUNT%%' => (int) $pageNav->total ) ) . '</span>';

		initToolTip();

		$isModerator						=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner							=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus							=	CBGroupJive::getGroupStatus( $user, $group );
		$canCreate							=	CBGroupJive::canCreateGroupContent( $user, $group, 'events' );
		$canSearch							=	( $plugin->params->get( 'groups_events_search', 1 ) && ( $searching || $pageNav->total ) );
		$showAddress						=	$plugin->params->get( 'groups_events_address', 1 );
		$return								=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayEvents', array( &$return, &$rows, $group, $user ) );

		$return								.=	'<div class="gjGroupEvents">'
											.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupEventsForm" id="gjGroupEventsForm" class="gjGroupEventsForm">';

		if ( $canCreate || $canSearch ) {
			$return							.=			'<div class="gjHeader gjGroupEventsHeader row">';

			if ( $canCreate ) {
				$return						.=				'<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
											.					'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'new', 'group' => (int) $group->get( 'id' ) ) ) . '\';" class="gjButton gjButtonNewEvent btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'New Event' ) . '</button>'
											.				'</div>';
			}

			if ( $canSearch ) {
				$return						.=				'<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">'
											.					'<div class="input-group">'
											.						'<span class="input-group-addon"><span class="fa fa-search"></span></span>'
											.						$input['search']
											.					'</div>'
											.				'</div>';
			}

			$return							.=			'</div>';
		}

		$return								.=			'<div class="gjGroupEventsRows">';

		if ( $rows ) foreach ( $rows as $row ) {
			$rowOwner						=	( $user->get( 'id' ) == $row->get( 'user_id' ) );
			$address						=	htmlspecialchars( $row->get( 'location' ) );

			if ( $showAddress ) {
				if ( $row->get( 'address' ) ) {
					$mapUrl					=	CBTxt::T( 'GROUP_EVENT_ADDRESS_MAP_URL', 'https://www.google.com/maps/place/[address]', array( '[location]' => urlencode( $row->get( 'location' ) ), '[address]' => urlencode( $row->get( 'address' ) ) ) );
				} else {
					$mapUrl					=	CBTxt::T( 'GROUP_EVENT_LOCATION_MAP_URL', 'https://www.google.com/maps/search/[location]', array( '[location]' => urlencode( $row->get( 'location' ) ), '[address]' => urlencode( $row->get( 'address' ) ) ) );
				}

				if ( $mapUrl ) {
					$address				=	'<a href="' . htmlspecialchars( $mapUrl ) . '" target="_blank" rel="nofollow">' . $address . '</a>';
				}
			}

			$menu							=	array();

			$integrations					=	$_PLUGINS->trigger( 'gj_onDisplayEvent', array( &$row, &$menu, $group, $user ) );

			$canAttend						=	( ( ! $rowOwner ) && ( $row->status() != 1 ) && ( ! $row->get( '_attending' ) ) && ( $userStatus >= 1 ) && ( ( ! $row->get( 'limit' ) ) || ( $row->get( 'limit' ) && ( $row->get( '_guests' ) < $row->get( 'limit' ) ) ) ) );
			$canMenu						=	( $isModerator || $isOwner || $rowOwner || ( $userStatus >= 2 ) || ( ( ! $rowOwner ) && ( $row->status() != 1 ) && ( $userStatus >= 1 ) && $row->get( '_attending' ) ) || $menu );

			$return							.=				'<div class="gjGroupEventsRow row' . ( $row->status() == 1 ? ' gjGroupEventExpired' : ( $row->status() == 2 ? ' gjGroupEventActive' : null ) ) . '">'
											.					'<div class="gjGroupEventCalendar col-md-2 hidden-sm hidden-xs">'
											.						'<div class="panel panel-default text-center">'
											.							'<div class="gjGroupEventMonth panel-body">' . cbFormatDate( $row->get( 'start' ), true, false, 'M' ) . '</div>'
											.							'<div class="gjGroupEventDay panel-footer">' . cbFormatDate( $row->get( 'start' ), true, false, 'j' ) . '</div>'
											.						'</div>'
											.					'</div>'
											.					'<div class="gjGroupEventContainer col-md-10 col-sm-12 col-xs-12">'
											.						'<div class="panel ' . ( $row->status() == 1 ? 'panel-warning' : ( $row->status() == 2 ? 'panel-primary' : 'panel-default' ) ) . '">'
											.							'<div class="gjGroupEventHeader panel-heading">'
											.								'<div class="row">'
											.									'<div class="gjGroupEventTitle ' . ( $canAttend || $canMenu ? 'col-sm-8' : 'col-sm-12' ) . '">' . htmlspecialchars( $row->get( 'title' ) ) . '</div>';

			if ( $canAttend || $canMenu ) {
				$return						.=									'<div class="gjGroupEventMenu col-sm-4 text-right">';

				if ( $canAttend ) {
					$return					.=										'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'attend', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonAttend btn btn-xs btn-success">' . CBTxt::T( 'Attend' ) . '</button> ';
				}

				if ( $canMenu ) {
					$menuItems				=	'<ul class="gjEventMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

					if ( ( ! $rowOwner ) && ( $row->status() != 1 ) && ( $userStatus >= 1 ) && $row->get( '_attending' ) ) {
						$menuItems			.=		'<li class="gjEventMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you do not want to attend this Event?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'unattend', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unattend' ) . '</a></li>';
					}

					if ( $isModerator || $isOwner || $rowOwner || ( $userStatus >= 2 ) ) {
						$menuItems			.=		'<li class="gjEventMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

						if ( ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'events', 1 ) == 2 ) ) {
							if ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) {
								$menuItems	.=		'<li class="gjEventMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
							}
						} elseif ( $row->get( 'published' ) == 1 ) {
							$menuItems		.=		'<li class="gjEventMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Event?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
						} else {
							$menuItems		.=		'<li class="gjEventMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
						}
					}

					if ( $menu ) {
						$menuItems			.=		'<li class="gjEventMenuItem">' . implode( '</li><li class="gjEventMenuItem">', $menu ) . '</li>';
					}

					if ( $isModerator || $isOwner || $rowOwner || ( $userStatus >= 2 ) ) {
						$menuItems			.=		'<li class="gjEventMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Event?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
					}

					$menuItems				.=	'</ul>';

					$menuAttr				=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

					$return					.=										'<span class="gjEventMenu btn-group">'
											.											'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
											.										'</span>';
				}

				$return						.=									'</div>';
			}

			$return							.=								'</div>'
											.							'</div>'
											.							'<div class="gjGroupEventDetails panel-body small">';

			if ( $row->status() == 1 ) {
				$return						.=								'<div class="gjGroupEventNotice text-warning text-right">' . CBTxt::T( 'This event has ended.' ) . '</div>';
			} elseif ( $row->status() == 2 ) {
				if ( $row->get( 'end' ) ) {
					$return					.=								'<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'GROUP_EVENT_ENDS_IN', 'This event is currently in progress and ends in [timeago].', array( '[timeago]' => cbFormatDate( $row->get( 'end' ), true, 'exacttimeago' ) ) ) . '</div>';
				} else {
					$return					.=								'<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'This event is currently in progress.' ) . '</div>';
				}
			} else {
				$return						.=								'<div class="gjGroupEventNotice text-right">' . CBTxt::T( 'GROUP_EVENT_STARTS_IN', 'This event starts in [timeago].', array( '[timeago]' => cbFormatDate( $row->get( 'start' ), true, 'exacttimeago' ) ) ) . '</div>';
			}

			$return							.=								'<div class="gjGroupEventDate">'
											.									'<span class="gjGroupEventIcon fa fa-clock-o text-center"></span> ' . $row->date()
											.								'</div>'
											.								'<div class="gjGroupEventLocation">'
											.									'<span class="gjGroupEventIcon fa fa-map-marker text-center"></span> ' . $address
											.								'</div>'
											.								'<div class="gjGroupEventAttending row">'
											.									'<div class="gjGroupEventGuests col-sm-6">'
											.										'<span class="gjGroupEventIcon fa fa-users text-center"></span> '
											.										'<a href="' . htmlspecialchars( $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'attending', 'id' => (int) $row->get( 'id' ) ) ) ) . '">'
											.											( $row->get( 'limit' ) ? CBTxt::T( 'GROUP_GUESTS_COUNT_LIMITED', '%%COUNT%% of [limit] Guest|%%COUNT%% of [limit] Guests', array( '%%COUNT%%' => (int) $row->get( '_guests', 0 ), '[limit]' => (int) $row->get( 'limit' ) ) ) : CBTxt::T( 'GROUP_GUESTS_COUNT', '%%COUNT%% Guest|%%COUNT%% Guests', array( '%%COUNT%%' => (int) $row->get( '_guests', 0 ) ) ) )
											.										'</a>'
											.									'</div>'
											.									'<div class="gjGroupEventHost col-sm-6 text-right">'
											.										CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true )
											.									'</div>'
											.								'</div>'
											.							'</div>'
											.							'<div class="gjGroupEventDescription panel-footer">'
											.								'<div class="cbMoreLess">'
											.									'<div class="cbMoreLessContent">'
											.										( $plugin->params->get( 'groups_events_content_plugins', 0 ) ? Application::Cms()->prepareHtmlContentPlugins( $row->get( 'event' ) ) : $row->get( 'event' ) )
											.									'</div>'
											.									'<div class="cbMoreLessOpen fade-edge hidden">'
											.										'<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>'
											.									'</div>'
											.								'</div>'
											.							'</div>'
											.							( is_array( $integrations ) && $integrations ? '<div class="gjGroupEventFooter panel-footer">' . implode( '', $integrations ) . '</div>' : null )
											.						'</div>'
											.					'</div>'
											.				'</div>';
		} else {
			if ( $searching ) {
				$return						.=				CBTxt::T( 'No group event search results found.' );
			} else {
				$return						.=				CBTxt::T( 'This group currently has no events.' );
			}
		}

		$return								.=			'</div>';

		if ( $plugin->params->get( 'groups_events_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return							.=			'<div class="gjGroupEventsPaging text-center">'
											.				$pageNav->getListLinks()
											.			'</div>';
		}

		$return								.=			$pageNav->getLimitBox( false )
											.		'</form>'
											.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayEvents', array( &$return, $rows, $group, $user ) );

		return $return;
	}
Example #6
0
	/**
	 * render frontend notifications
	 *
	 * @param NotificationTable  $row
	 * @param array              $input
	 * @param GroupTable         $group
	 * @param UserTable          $user
	 * @param CBplug_cbgroupjive $plugin
	 * @return string
	 */
	static function showNotifications( $row, $input, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$js							=	"$( '.gjToggleNotifications' ).on( 'change', function() {"
									.		"if ( $( this ).val() == 0 ) {"
									.			"$( '.gjNotificationsForm' ).find( 'select:not(.gjToggleNotifications)' ).val( 0 ).change();"
									.		"} else if ( $( this ).val() == 1 ) {"
									.			"$( '.gjNotificationsForm' ).find( 'select:not(.gjToggleNotifications)' ).val( 1 ).change();"
									.		"}"
									.		"$( this ).val( -1 );"
									.	"});";

		$_CB_framework->outputCbJQuery( $js );

		$pageTitle					=	CBTxt::T( 'Notifications' );

		$_CB_framework->setPageTitle( $pageTitle );

		cbValidator::loadValidation();
		initToolTip();

		$isModerator				=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner					=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$status						=	CBGroupJive::getGroupStatus( $user, $group );
		$return						=	null;

		$integrations				=	$_PLUGINS->trigger( 'gj_onBeforeDisplayNotifications', array( &$return, &$row, &$input, $group, $user ) );

		$return						.=	'<div class="gjNotifications">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'notifications', 'func' => 'save', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjNotificationsForm" id="gjNotificationsForm" class="cb_form gjNotificationsForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="gjNotificationsTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null )
									.			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-12 text-right">'
									.					$input['toggle']
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__user_join" class="col-sm-9 control-label">' . CBTxt::T( 'Join of new user' ) . '</label>'
									.				'<div class="cb_field col-sm-3 text-right">'
									.					$input['user_join']
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__user_leave" class="col-sm-9 control-label">' . CBTxt::T( 'Leave of existing user' ) . '</label>'
									.				'<div class="cb_field col-sm-3 text-right">'
									.					$input['user_leave']
									.				'</div>'
									.			'</div>';

		if ( ( $isModerator || $isOwner || ( $status >= 2 ) ) && ( $group->get( 'type' ) == 2 ) ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__user_approve" class="col-sm-9 control-label">' . CBTxt::T( 'New user requires approval' ) . '</label>'
									.				'<div class="cb_field col-sm-3 text-right">'
									.					$input['user_approve']
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__user_cancel" class="col-sm-9 control-label">' . CBTxt::T( 'New user join request cancelled' ) . '</label>'
									.				'<div class="cb_field col-sm-3 text-right">'
									.					$input['user_cancel']
									.				'</div>'
									.			'</div>';
		}

		if ( ( $plugin->params->get( 'groups_invites_display', 1 ) || ( $group->get( 'type' ) == 3 ) ) && ( $group->params()->get( 'invites', 1 ) || ( $isModerator || $isOwner || ( $status >= 3 ) ) ) ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__invite_accept" class="col-sm-9 control-label">' . CBTxt::T( 'My group invite requests accepted' ) . '</label>'
									.				'<div class="cb_field col-sm-3 text-right">'
									.					$input['invite_accept']
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__invite_reject" class="col-sm-9 control-label">' . CBTxt::T( 'My group invite requests rejected' ) . '</label>'
									.				'<div class="cb_field col-sm-3 text-right">'
									.					$input['invite_reject']
									.				'</div>'
									.			'</div>';
		}

		if ( is_array( $integrations ) && $integrations ) {
			$return					.=			implode( '', $integrations );
		}

		$return						.=			'<div class="form-group cb_form_line clearfix">'
									.				'<div class="col-sm-12 text-right">'
									.					'<input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-default" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '\'; })" />'
									.					' <input type="submit" value="' . htmlspecialchars( CBTxt::T( 'Update Notifications' ) ) . '" class="gjButton gjButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'
									.				'</div>'
									.			'</div>'
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayNotifications', array( &$return, $row, $input, $group, $user ) );

		$_CB_framework->setMenuMeta();

		echo $return;
	}
Example #7
0
	/**
	 * render frontend photos
	 *
	 * @param PhotoTable[]    $rows
	 * @param cbPageNav       $pageNav
	 * @param bool            $searching
	 * @param array           $input
	 * @param array           $counters
	 * @param GroupTable      $group
	 * @param UserTable       $user
	 * @param cbgjPhotoPlugin $plugin
	 * @return string
	 */
	static function showPhotos( $rows, $pageNav, $searching, $input, &$counters, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$js								=	"$( document ).on( 'click', '.gjGroupPhotoImageScrollLeftIcon', function() {"
										.		"var previous = $( this ).data( 'previous-photo' );"
										.		"if ( previous ) {"
										.			"$( previous ).find( '.gjGroupPhotoItem' ).click();"
										.		"}"
										.	"});"
										.	"$( document ).on( 'click', '.gjGroupPhotoImageScrollRightIcon', function() {"
										.		"var next = $( this ).data( 'next-photo' );"
										.		"if ( next ) {"
										.			"$( next ).find( '.gjGroupPhotoItem' ).click();"
										.		"}"
										.	"});";

		$_CB_framework->outputCbJQuery( $js );

		$counters[]						=	'<span class="gjGroupPhotoIcon fa-before fa-photo"> ' . CBTxt::T( 'GROUP_PHOTOS_COUNT', '%%COUNT%% Photo|%%COUNT%% Photos', array( '%%COUNT%%' => (int) $pageNav->total ) ) . '</span>';

		initToolTip();

		$isModerator					=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner						=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus						=	CBGroupJive::getGroupStatus( $user, $group );
		$canCreate						=	CBGroupJive::canCreateGroupContent( $user, $group, 'photo' );
		$canSearch						=	( $plugin->params->get( 'groups_photo_search', 1 ) && ( $searching || $pageNav->total ) );
		$return							=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayPhotos', array( &$return, &$rows, $group, $user ) );

		$return							.=	'<div class="gjGroupPhoto">'
										.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupPhotoForm" id="gjGroupPhotoForm" class="gjGroupPhotoForm">';

		if ( $canCreate || $canSearch ) {
			$return						.=			'<div class="gjHeader gjGroupPhotoHeader row">';

			if ( $canCreate ) {
				$return					.=				'<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
										.					'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'photo', 'func' => 'new', 'group' => (int) $group->get( 'id' ) ) ) . '\';" class="gjButton gjButtonNewPhoto btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'New Photo' ) . '</button>'
										.				'</div>';
			}

			if ( $canSearch ) {
				$return					.=				'<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">'
										.					'<div class="input-group">'
										.						'<span class="input-group-addon"><span class="fa fa-search"></span></span>'
										.						$input['search']
										.					'</div>'
										.				'</div>';
			}

			$return						.=			'</div>';
		}

		$i								=	0;

		$return							.=			'<div class="gjGroupPhotoRows">';

		if ( $rows ) foreach ( $rows as $row ) {
			$rowCounters				=	array();
			$content					=	null;
			$menu						=	array();

			$_PLUGINS->trigger( 'gj_onDisplayPhoto', array( &$row, &$rowCounters, &$content, &$menu, $group, $user ) );

			$title						=	( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : $row->name() );
			$item						=	$title;
			$logo						=	null;

			if ( $row->exists() ) {
				$showPath				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ), 'raw', 0, true );

				$image					=	'<div class="gjGroupPhotoImageContainer">';

				if ( $pageNav->total > 1 ) {
					$image				.=		'<div class="gjGroupPhotoImageScrollLeft">'
										.			'<table>'
										.				'<tr>'
										.					'<td>'
										.						'<span class="gjGroupPhotoImageScrollLeftIcon fa fa-chevron-left" data-previous-photo=".gjGroupPhotoRow' . ( $i == 0 ? ( count( $rows ) - 1 ) : ( $i - 1 ) ) . '"></span>'
										.					'</td>'
										.				'</tr>'
										.			'</table>'
										.		'</div>';
				}

				$image					.=		'<div style="background-image: url(' . $showPath . ')" class="gjGroupPhotoImage"></div>'
										.		'<div class="gjGroupPhotoImageInfo">'
										.			'<div class="gjGroupPhotoImageInfoRow">'
										.				'<div class="gjGroupPhotoImageInfoTitle col-sm-8 text-left"><strong>' . $title . '</strong></div>'
										.				'<div class="gjGroupPhotoImageInfoOriginal col-sm-4 text-right">'
										.					'<a href="' . $showPath . '" target="_blank">'
										.						CBTxt::T( 'Original' )
										.					'</a>'
										.				'</div>'
										.			'</div>';

				if ( $row->get( 'description' ) ) {
					$image				.=			'<div class="gjGroupPhotoImageInfoRow">'
										.				'<div class="gjGroupPhotoImageInfoDescription col-sm-8 text-left">' . htmlspecialchars( $row->get( 'description' ) ) . '</div>'
										.				'<div class="gjGroupPhotoImageInfoDownload col-sm-4 text-right">'
										.				'</div>'
										.			'</div>';
				}

				$image					.=		'</div>';

				if ( $pageNav->total > 1 ) {
					$image				.=		'<div class="gjGroupPhotoImageScrollRight">'
										.			'<table>'
										.				'<tr>'
										.					'<td>'
										.						'<span class="gjGroupPhotoImageScrollRightIcon fa fa-chevron-right" data-next-photo=".gjGroupPhotoRow' . ( isset( $rows[$i+1] ) ? ( $i + 1 ) : 0 ) . '"></span>'
										.					'</td>'
										.				'</tr>'
										.			'</table>'
										.		'</div>';
				}

				$image					.=	'</div>';

				$item					=	cbTooltip( 1, $image, null, array( '80%', '80%' ), null, $item, 'javascript: void(0);', 'class="gjGroupPhotoItem" data-cbtooltip-modal="true" data-cbtooltip-open-solo="document" data-cbtooltip-classes="gjGroupPhotoImageModal"' );
				$logo					=	cbTooltip( 1, $image, null, array( '80%', '80%' ), null, '<div style="background-image: url(' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'preview', 'id' => (int) $row->get( 'id' ) ), 'raw', 0, true ) . ')" class="gjGroupPhotoLogo"></div>', 'javascript: void(0);', 'class="gjGroupPhotoLogo" data-cbtooltip-modal="true" data-cbtooltip-open-solo="document" data-cbtooltip-classes="gjGroupPhotoImageModal"' );
			}

			$return						.=				'<div class="gjGroupPhotoRow gjGroupPhotoRow' . $i . ' gjContainerBox img-thumbnail">'
										.					'<div class="gjContainerBoxHeader">'
										.						'<div class="gjContainerBoxCanvas">'
										.							$logo
										.						'</div>'
										.					'</div>'
										.					'<div class="gjContainerBoxBody text-left">'
										.						'<div class="gjContainerBoxTitle">'
										.							$item
										.						'</div>'
										.						'<div class="gjContainerBoxCounters text-muted small row">'
										.							'<div class="gjGroupPhotoPublisher gjContainerBoxCounter col-sm-6">' . CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</div>'
										.							'<div class="gjContainerBoxCounter col-sm-6 text-right">'
										.								'<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">'
										.									cbFormatDate( $row->get( 'date' ), true, false, CBTxt::T( 'GROUP_PHOTO_DATE_FORMAT', 'M j, Y' ) )
										.								'</span>'
										.							'</div>'
										.							( $rowCounters ? '<div class="gjContainerBoxCounter col-sm-6">' . implode( '</div><div class="gjContainerBoxCounter col-sm-6">', $rowCounters ) . '</div>' : null )
										.						'</div>'
										.						( $content ? '<div class="gjContainerBoxContent">' . $content . '</div>' : null )
										.						( $row->get( 'description' ) ? '<div class="gjContainerBoxDescription">' . cbTooltip( 1, $row->get( 'description' ), $row->name(), 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null );

			if ( ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) && ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'photo', 1 ) == 2 ) ) {
				$return					.=						'<div class="gjContainerBoxButton text-right">'
										.							'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>'
										.						'</div>';
			}

			$return						.=					'</div>';

			if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) || $menu ) {
				$menuItems				=	'<ul class="gjPhotoMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems			.=		'<li class="gjPhotoMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

					if ( ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'photo', 1 ) == 2 ) ) {
						if ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) {
							$menuItems	.=		'<li class="gjPhotoMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
						}
					} elseif ( $row->get( 'published' ) == 1 ) {
						$menuItems		.=		'<li class="gjPhotoMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Photo?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'photo', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
					} else {
						$menuItems		.=		'<li class="gjPhotoMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'photo', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
					}
				}

				if ( $menu ) {
					$menuItems			.=		'<li class="gjPhotoMenuItem">' . implode( '</li><li class="gjPhotoMenuItem">', $menu ) . '</li>';
				}

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems			.=		'<li class="gjPhotoMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Photo?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'photo', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
				}

				$menuItems				.=	'</ul>';

				$menuAttr				=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return					.=					'<div class="gjContainerBoxMenu">'
										.						'<div class="gjPhotoMenu btn-group">'
										.							'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
										.						'</div>'
										.					'</div>';
			}

			$return						.=				'</div>';

			$i++;
		} else {
			if ( $searching ) {
				$return					.=				CBTxt::T( 'No group photo search results found.' );
			} else {
				$return					.=				CBTxt::T( 'This group currently has no photos.' );
			}
		}

		$return							.=			'</div>';

		if ( $plugin->params->get( 'groups_photo_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return						.=			'<div class="gjGroupPhotoPaging text-center">'
										.				$pageNav->getListLinks()
										.			'</div>';
		}

		$return							.=			$pageNav->getLimitBox( false )
										.		'</form>'
										.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayPhotos', array( &$return, $rows, $group, $user ) );

		return $return;
	}
	/**
	 * prepare frontend group invites render
	 *
	 * @param GroupTable $group
	 * @param UserTable  $user
	 * @return mixed
	 */
	private function showGroupInvites( &$group, $user )
	{
		global $_CB_framework, $_CB_database;

		if ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) {
			if ( ( ! $this->params->get( 'groups_invites_display', 1 ) ) && ( $group->get( 'type' ) != 3 ) ) {
				return null;
			} elseif ( ( CBGroupJive::getGroupStatus( $user, $group ) < 1 ) ) {
				return null;
			}
		}

		CBGroupJive::getTemplate( 'invites' );

		$limit					=	(int) $this->params->get( 'groups_invites_limit', 15 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_group_invites_limitstart{com_comprofiler}', 'gj_group_invites_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_group_invites_search{com_comprofiler}', 'gj_group_invites_search' );
		$where					=	null;

		if ( $search && $this->params->get( 'groups_invites_search', 0 ) ) {
			$where				.=	"\n AND ( i." . $_CB_database->NameQuote( 'email' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR j." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR j." . $_CB_database->NameQuote( 'username' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

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

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = i.' . $_CB_database->NameQuote( 'user' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE i." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.	"\n AND i." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND ( ( cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	' AND cb.' . $_CB_database->NameQuote( 'confirmed' ) . ' = 1'
								.	' AND j.' . $_CB_database->NameQuote( 'block' ) . ' = 0 )'
								.	' OR i.' . $_CB_database->NameQuote( 'user' ) . ' = 0 )'
								.	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'invites' ) ) ) {
			return null;
		}

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

		$pageNav->setInputNamePrefix( 'gj_group_invites_' );

		switch( (int) $this->params->get( 'groups_invites_orderby', 1 ) ) {
			case 1:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'invited' ) . ' ASC';
				break;
			case 3:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'accepted' ) . ' ASC';
				break;
			case 4:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'accepted' ) . ' DESC';
				break;
			case 2:
			default:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'invited' ) . ' DESC';
				break;
		}

		$query					=	'SELECT i.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = i.' . $_CB_database->NameQuote( 'user' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE i." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.	"\n AND i." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND ( ( cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	' AND cb.' . $_CB_database->NameQuote( 'confirmed' ) . ' = 1'
								.	' AND j.' . $_CB_database->NameQuote( 'block' ) . ' = 0 )'
								.	' OR i.' . $_CB_database->NameQuote( 'user' ) . ' = 0 )'
								.	"\n ORDER BY " . $orderBy;
		if ( $this->params->get( 'groups_invites_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\InviteTable', array( $_CB_database ) );

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

		CBGroupJive::preFetchUsers( $rows );

		$group->set( '_invites', $pageNav->total );

		return HTML_groupjiveInvites::showInvites( $rows, $pageNav, $searching, $input, $group, $user, $this );
	}
Example #9
0
	/**
	 * render frontend videos
	 *
	 * @param VideoTable[]    $rows
	 * @param cbPageNav       $pageNav
	 * @param bool            $searching
	 * @param array           $input
	 * @param array           $counters
	 * @param GroupTable      $group
	 * @param UserTable       $user
	 * @param cbgjVideoPlugin $plugin
	 * @return string
	 */
	static function showVideos( $rows, $pageNav, $searching, $input, &$counters, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_CB_framework->outputCbJQuery( "$( '.gjVideoPlayer' ).mediaelementplayer();", 'media' );

		$counters[]						=	'<span class="gjGroupVideoIcon fa-before fa-film"> ' . CBTxt::T( 'GROUP_VIDEOS_COUNT', '%%COUNT%% Video|%%COUNT%% Videos', array( '%%COUNT%%' => (int) $pageNav->total ) ) . '</span>';

		initToolTip();

		$isModerator					=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner						=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus						=	CBGroupJive::getGroupStatus( $user, $group );
		$canCreate						=	CBGroupJive::canCreateGroupContent( $user, $group, 'video' );
		$canSearch						=	( $plugin->params->get( 'groups_video_search', 1 ) && ( $searching || $pageNav->total ) );
		$return							=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayVideos', array( &$return, &$rows, $group, $user ) );

		$return							.=	'<div class="gjGroupVideo">'
										.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupVideoForm" id="gjGroupVideoForm" class="gjGroupVideoForm">';

		if ( $canCreate || $canSearch ) {
			$return						.=			'<div class="gjHeader gjGroupVideoHeader row">';

			if ( $canCreate ) {
				$return					.=				'<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
										.					'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'video', 'func' => 'new', 'group' => (int) $group->get( 'id' ) ) ) . '\';" class="gjButton gjButtonNewVideo btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'New Video' ) . '</button>'
										.				'</div>';
			}

			if ( $canSearch ) {
				$return					.=				'<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">'
										.					'<div class="input-group">'
										.						'<span class="input-group-addon"><span class="fa fa-search"></span></span>'
										.						$input['search']
										.					'</div>'
										.				'</div>';
			}

			$return						.=			'</div>';
		}

		$return							.=			'<div class="gjGroupVideoRows">';

		if ( $rows ) foreach ( $rows as $row ) {
			$rowCounters				=	array();
			$content					=	null;
			$menu						=	array();

			$_PLUGINS->trigger( 'gj_onDisplayVideo', array( &$row, &$rowCounters, &$content, &$menu, $group, $user ) );

			$return						.=				'<div class="gjGroupVideoRow gjContainerBox img-thumbnail">'
										.					'<div class="gjContainerBoxHeader">'
										.						'<video width="640" height="360" style="width: 100%; height: 100%;" id="gjVideoPlayer' . (int) $row->get( 'id' ) . '" src="' . htmlspecialchars( $row->get( 'url' ) ) . '" type="' . htmlspecialchars( $row->mimeType() ) . '" controls="controls" preload="none" class="gjVideoPlayer"></video>'
										.					'</div>'
										.					'<div class="gjContainerBoxBody text-left">'
										.						'<div class="gjContainerBoxTitle">'
										.							'<a href="' . htmlspecialchars( $row->get( 'url' ) ) . '" target="_blank" rel="nofollow">' . htmlspecialchars( ( $row->get( 'title' ) ? $row->get( 'title' ) : $row->name() ) ) . '</a>'
										.						'</div>'
										.						'<div class="gjContainerBoxCounters text-muted small row">'
										.							'<div class="gjGroupVideoPublisher gjContainerBoxCounter col-sm-6">' . CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</div>'
										.							'<div class="gjContainerBoxCounter col-sm-6 text-right">'
										.								'<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">'
										.									cbFormatDate( $row->get( 'date' ), true, false, CBTxt::T( 'GROUP_VIDEO_DATE_FORMAT', 'M j, Y' ) )
										.								'</span>'
										.							'</div>'
										.							( $rowCounters ? '<div class="gjContainerBoxCounter col-sm-6">' . implode( '</div><div class="gjContainerBoxCounter col-sm-6">', $rowCounters ) . '</div>' : null )
										.						'</div>'
										.						( $content ? '<div class="gjContainerBoxContent">' . $content . '</div>' : null )
										.						( $row->get( 'caption' ) ? '<div class="gjContainerBoxDescription">' . cbTooltip( 1, $row->get( 'caption' ), $row->name(), 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null );

			if ( ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) && ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'video', 1 ) == 2 ) ) {
				$return					.=						'<div class="gjContainerBoxButton text-right">'
										.							'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'video', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>'
										.						'</div>';
			}

			$return						.=					'</div>';

			if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) || $menu ) {
				$menuItems				=	'<ul class="gjVideoMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems			.=		'<li class="gjVideoMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'video', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

					if ( ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'video', 1 ) == 2 ) ) {
						if ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) {
							$menuItems	.=		'<li class="gjVideoMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'video', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
						}
					} elseif ( $row->get( 'published' ) == 1 ) {
						$menuItems		.=		'<li class="gjVideoMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Video?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'video', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
					} else {
						$menuItems		.=		'<li class="gjVideoMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'video', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
					}
				}

				if ( $menu ) {
					$menuItems			.=		'<li class="gjVideoMenuItem">' . implode( '</li><li class="gjVideoMenuItem">', $menu ) . '</li>';
				}

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems			.=		'<li class="gjVideoMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Video?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'video', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
				}

				$menuItems				.=	'</ul>';

				$menuAttr				=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return					.=					'<div class="gjContainerBoxMenu">'
										.						'<div class="gjVideoMenu btn-group">'
										.							'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
										.						'</div>'
										.					'</div>';
			}

			$return						.=				'</div>';
		} else {
			if ( $searching ) {
				$return					.=				CBTxt::T( 'No group video search results found.' );
			} else {
				$return					.=				CBTxt::T( 'This group currently has no videos.' );
			}
		}

		$return							.=			'</div>';

		if ( $plugin->params->get( 'groups_video_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return						.=			'<div class="gjGroupVideoPaging text-center">'
										.				$pageNav->getListLinks()
										.			'</div>';
		}

		$return							.=			$pageNav->getLimitBox( false )
										.		'</form>'
										.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayVideos', array( &$return, $rows, $group, $user ) );

		return $return;
	}
	/**
	 * store the forum category for the group or category that was deleted
	 *
	 * @param GroupTable|CategoryTable $row
	 */
	public function storeForum( $row )
	{
		if ( ( ! $this->_forumModel ) || $row->get( '_skipForums' ) ) {
			return;
		}

		$parent					=	(int) $this->params->get( 'groups_forums_category' );

		if ( ! $parent ) {
			return;
		}

		if ( ( $row instanceof GroupTable ) && $row->category()->get( 'id' ) ) {
			$parentCategory		=	$this->_forumModel->getCategory( (int) $row->category()->params()->get( 'forum_id' ) );

			if ( ! $parentCategory->get( 'id' ) ) {
				$parentCategory->set( 'parent', $parent );
				$parentCategory->set( 'name', $row->category()->get( 'name' ) );
				$parentCategory->set( 'alias', $row->category()->get( 'id' ) . '-' . $row->category()->get( 'name' ) );
				$parentCategory->set( 'description', $row->category()->get( 'description' ) );
				$parentCategory->set( 'published', ( ! $row->category()->params()->get( 'forums', 1 ) ? 0 : $row->category()->get( 'published' ) ) );

				$parentCategory->access( $row->category() );

				if ( ! $parentCategory->check() ) {
					return;
				}

				if ( ! $parentCategory->store() ) {
					return;
				}

				$row->category()->set( '_skipForums', true );

				$row->category()->params()->set( 'forum_id', (int) $parentCategory->get( 'id' ) );

				$row->category()->set( 'params', $row->category()->params()->asJson() );

				$row->category()->store();

				$row->category()->set( '_skipForums', false );
			}

			$parent				=	(int) $parentCategory->get( 'id' );
		}

		$category				=	$this->_forumModel->getCategory( (int) $row->params()->get( 'forum_id' ) );

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

		$category->set( 'parent', $parent );
		$category->set( 'name', $row->get( 'name' ) );
		$category->set( 'alias', $row->get( 'id' ) . '-' . $row->get( 'name' ) );
		$category->set( 'description', $row->get( 'description' ) );
		$category->set( 'published', ( ! $row->params()->get( 'forums', 1 ) ? 0 : $row->get( 'published' ) ) );

		$category->access( $row );

		if ( ! $category->check() ) {
			return;
		}

		if ( ! $category->store() ) {
			return;
		}

		if ( ( $row instanceof GroupTable ) && ( ! CBGroupJive::isModerator( $row->get( 'user_id' ) ) ) ) {
			$moderators			=	$category->moderators();

			if ( ! in_array( $row->get( 'user_id' ), $moderators ) ) {
				$category->moderators( $row->get( 'user_id' ) );
			}
		}

		if ( $new ) {
			$row->set( '_skipForums', true );

			$row->params()->set( 'forum_id', (int) $category->get( 'id' ) );

			$row->set( 'params', $row->params()->asJson() );

			$row->store();

			$row->set( '_skipForums', false );
		}
	}
Example #11
0
	/**
	 * render frontend files
	 *
	 * @param FileTable[]    $rows
	 * @param cbPageNav      $pageNav
	 * @param bool           $searching
	 * @param array          $input
	 * @param array          $counters
	 * @param GroupTable     $group
	 * @param UserTable      $user
	 * @param cbgjFilePlugin $plugin
	 * @return string
	 */
	static function showFiles( $rows, $pageNav, $searching, $input, &$counters, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$counters[]							=	'<span class="gjGroupFileIcon fa-before fa-file-o"> ' . CBTxt::T( 'GROUP_FILES_COUNT', '%%COUNT%% File|%%COUNT%% Files', array( '%%COUNT%%' => (int) $pageNav->total ) ) . '</span>';

		initToolTip();

		$isModerator						=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner							=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus							=	CBGroupJive::getGroupStatus( $user, $group );
		$canCreate							=	CBGroupJive::canCreateGroupContent( $user, $group, 'file' );
		$canSearch							=	( $plugin->params->get( 'groups_file_search', 1 ) && ( $searching || $pageNav->total ) );
		$return								=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayFiles', array( &$return, &$rows, $group, $user ) );

		$return								.=	'<div class="gjGroupFile">'
											.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupFileForm" id="gjGroupFileForm" class="gjGroupFileForm">';

		if ( $canCreate || $canSearch ) {
			$return							.=			'<div class="gjHeader gjGroupFileHeader row">';

			if ( $canCreate ) {
				$return						.=				'<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
											.					'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'file', 'func' => 'new', 'group' => (int) $group->get( 'id' ) ) ) . '\';" class="gjButton gjButtonNewFile btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'New File' ) . '</button>'
											.				'</div>';
			}

			if ( $canSearch ) {
				$return						.=				'<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">'
											.					'<div class="input-group">'
											.						'<span class="input-group-addon"><span class="fa fa-search"></span></span>'
											.						$input['search']
											.					'</div>'
											.				'</div>';
			}

			$return							.=			'</div>';
		}

		$return								.=			'<table class="gjGroupFileRows table table-hover table-responsive">'
											.				'<thead>'
											.					'<tr>'
											.						'<th colspan="2">&nbsp;</th>'
											.						'<th style="width: 15%;" class="text-center">' . CBTxt::T( 'Type' ) . '</th>'
											.						'<th style="width: 15%;" class="text-left">' . CBTxt::T( 'Size' ) . '</th>'
											.						'<th style="width: 20%;" class="text-left hidden-xs">' . CBTxt::T( 'Date' ) . '</th>'
											.						'<th style="width: 1%;" class="text-right">&nbsp;</th>'
											.					'</tr>'
											.				'</thead>'
											.				'<tbody>';

		if ( $rows ) foreach ( $rows as $row ) {
			$extension						=	null;
			$size							=	0;
			$title							=	( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : $row->name() );
			$item							=	$title;

			if ( $row->exists() ) {
				$downloadPath				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'file', 'func' => 'download', 'id' => (int) $row->get( 'id' ) ), 'raw', 0, true );
				$extension					=	$row->extension();
				$size						=	$row->size();

				switch ( $extension ) {
					case 'txt':
					case 'pdf':
					case 'jpg':
					case 'jpeg':
					case 'png':
					case 'gif':
					case 'js':
					case 'css':
					case 'mp4':
					case 'mp3':
					case 'wav':
						$item				=	'<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'file', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ), 'raw', 0, true ) . '" target="_blank">'
											.		$item
											.	'</a>';
						break;
					default:
						$item				=	'<a href="' . $downloadPath . '" target="_blank">'
											.		$item
											.	'</a>';
						break;
				}

				$download					=	'<a href="' . $downloadPath . '" target="_blank" title="' . htmlspecialchars( CBTxt::T( 'Click to Download' ) ) . '" class="gjGroupDownloadIcon btn btn-xs btn-default">'
											.		'<span class="fa fa-download"></span>'
											.	'</a>';
			} else {
				$download					=	'<button type="button" class="gjButton gjButtonDownloadFile btn btn-xs btn-default disabled">'
											.		'<span class="fa fa-download"></span>'
											.	'</button>';
			}

			if ( $row->get( 'description' ) ) {
				$item						.=	' ' . cbTooltip( 1, $row->get( 'description' ), $title, 400, null, '<span class="fa fa-info-circle text-muted"></span>' );
			}

			$menu							=	array();

			$_PLUGINS->trigger( 'gj_onDisplayFile', array( &$row, &$menu, $group, $user ) );

			$return							.=					'<tr>'
											.						'<td style="width: 1%;" class="text-center">' . $download . '</td>'
											.						'<td style="width: 45%;" class="gjGroupFileItem text-left">'
											.							$item
											.							'<div class="gjGroupFileUploader small">' . CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</div>'
											.						'</td>'
											.						'<td style="width: 15%;" class="text-center"><span class="gjGroupFileTypeIcon fa fa-' . $row->icon() . '" title="' . htmlspecialchars( ( $extension ? strtoupper( $extension ) : CBTxt::T( 'Unknown' ) ) ) . '"></span></td>'
											.						'<td style="width: 15%;" class="text-left">' . $size . '</td>'
											.						'<td style="width: 20%;" class="text-left hidden-xs">'
											.							'<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">'
											.								cbFormatDate( $row->get( 'date' ), true, false, CBTxt::T( 'GROUP_FILE_DATE_FORMAT', 'M j, Y' ) )
											.							'</span>'
											.						'</td>';

			if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) || $menu ) {
				$menuItems					=	'<ul class="gjFileMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems				.=		'<li class="gjFileMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'file', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

					if ( ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'file', 1 ) == 2 ) ) {
						if ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) {
							$menuItems		.=		'<li class="gjFileMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'file', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
						}
					} elseif ( $row->get( 'published' ) == 1 ) {
						$menuItems			.=		'<li class="gjFileMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this File?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'file', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
					} else {
						$menuItems			.=		'<li class="gjFileMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'file', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
					}
				}

				if ( $menu ) {
					$menuItems				.=		'<li class="gjFileMenuItem">' . implode( '</li><li class="gjFileMenuItem">', $menu ) . '</li>';
				}

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems				.=		'<li class="gjFileMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this File?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'file', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
				}

				$menuItems					.=	'</ul>';

				$menuAttr					=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return						.=						'<td style="width: 1%;" class="text-right">'
											.							'<div class="gjFileMenu btn-group">'
											.								'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
											.							'</div>'
											.						'</td>';
			} else{
				$return						.=						'<td style="width: 1%;"></td>';
			}

			$return							.=					'</tr>';
		} else {
			$return							.=					'<tr>'
											.						'<td colspan="6" class="text-left">';

			if ( $searching ) {
				$return						.=							CBTxt::T( 'No group file search results found.' );
			} else {
				$return						.=							CBTxt::T( 'This group currently has no files.' );
			}

			$return							.=						'</td>'
											.					'</tr>';
		}

		$return								.=				'</tbody>';

		if ( $plugin->params->get( 'groups_file_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return							.=				'<tfoot>'
											.					'<tr>'
											.						'<td colspan="6" class="gjGroupFilePaging text-center">'
											.							$pageNav->getListLinks()
											.						'</td>'
											.					'</tr>'
											.				'</tfoot>';
		}

		$return								.=			'</table>'
											.			$pageNav->getLimitBox( false )
											.		'</form>'
											.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayFiles', array( &$return, $rows, $group, $user ) );

		return $return;
	}
Example #12
0
	/**
	 * render frontend replies
	 *
	 * @param WallTable      $reply
	 * @param WallTable[]    $rows
	 * @param cbPageNav      $pageNav
	 * @param GroupTable     $group
	 * @param UserTable      $user
	 * @param cbgjWallPlugin $plugin
	 * @return string
	 */
	static function showReplies( $reply, $rows, $pageNav, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$isModerator						=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$messageLimit						=	( ! $isModerator ? (int) $plugin->params->get( 'groups_wall_character_limit', 0 ) : 0 );

		$js									=	"$( '.gjGroupWallNewReply:not(.gjGroupWallNewReplyOpen)' ).on( 'click', function() {"
											.		"$( this ).find( '.gjGroupWallLimit,.gjGroupWallNewReplyFooter' ).removeClass( 'hidden' );"
											.		"$( this ).addClass( 'gjGroupWallNewReplyOpen' );"
											.		"$( this ).find( 'textarea' ).autosize({"
											.			"append: '',"
											.			"resizeDelay: 0,"
											.			"placeholder: false"
											.		"});"
											.	"});"
											.	"$( '.gjGroupWallReplies .cbMoreLess' ).cbmoreless();";

		if ( $messageLimit ) {
			$js								.=	"$( '.gjGroupWallNewReply textarea' ).on( 'keyup input change', function() {"
											.		"var inputLength = $( this ).val().length;"
											.		"if ( inputLength > " . (int) $messageLimit . " ) {"
											.			"$( this ).val( $( this ).val().substr( 0, " . (int) $messageLimit . " ) );"
											.		"} else {"
											.			"$( this ).siblings( '.gjGroupWallLimit' ).find( '.gjGroupWallLimitCurrent' ).html( $( this ).val().length );"
											.		"}"
											.	"});";
		}

		$_CB_framework->outputCbJQuery( $js, array( 'cbmoreless', 'autosize' ) );

		$isOwner							=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus							=	CBGroupJive::getGroupStatus( $user, $group );
		$canCreate							=	CBGroupJive::canCreateGroupContent( $user, $group, 'wall' );
		$return								=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayWall', array( &$return, &$rows, $group, $user ) );

		$return								.=	'<div class="gjGroupWallReplies">'
											.		'<div class="gjGroupWallRows">';

		if ( $rows ) foreach ( $rows as $row ) {
			$menu							=	array();

			$integrations					=	$_PLUGINS->trigger( 'gj_onDisplayWall', array( &$row, &$menu, $group, $user ) );

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

			$return							.=			'<div class="gjGroupWallRow">'
											.				'<div class="gjGroupWallHeader media clearfix">'
											.					'<div class="gjGroupWallAvatar media-left">'
											.						$cbUser->getField( 'avatar', null, 'html', 'none', 'list', 0, true )
											.					'</div>'
											.					'<div class="gjGroupWallDetails media-body">'
											.						'<div class="cbMoreLess">'
											.							'<div class="cbMoreLessContent">'
											.								'<strong>' . $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</strong> '
											.								$row->post()
											.							'</div>'
											.							'<div class="cbMoreLessOpen fade-edge hidden">'
											.								'<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>'
											.							'</div>'
											.						'</div>'
											.						'<div class="gjGroupWallDate text-muted small">'
											.							cbFormatDate( $row->get( 'date' ), true, 'timeago' )
											.						'</div>'
											.					'</div>'
											.				'</div>'
											.				( is_array( $integrations ) && $integrations ? '<div class="gjGroupWallFooter panel-footer">' . implode( '', $integrations ) . '</div>' : null );

			if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) || $menu ) {
				$menuItems					=	'<ul class="gjWallMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems				.=		'<li class="gjWallMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'wall', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

					if ( ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'wall', 1 ) == 2 ) ) {
						if ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) {
							$menuItems		.=		'<li class="gjWallMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'wall', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
						}
					} elseif ( $row->get( 'published' ) == 1 ) {
						$menuItems			.=		'<li class="gjWallMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Post?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'wall', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
					} else {
						$menuItems			.=		'<li class="gjWallMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'wall', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
					}
				}

				if ( $menu ) {
					$menuItems				.=		'<li class="gjWallMenuItem">' . implode( '</li><li class="gjWallMenuItem">', $menu ) . '</li>';
				}

				if ( $isModerator || $isOwner || ( $user->get( 'id' ) == $row->get( 'user_id' ) ) || ( $userStatus >= 2 ) ) {
					$menuItems				.=		'<li class="gjWallMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Post?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'wall', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
				}

				$menuItems					.=	'</ul>';

				$menuAttr					=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return						.=				'<div class="gjWallMenu btn-group">'
											.					'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
											.				'</div>';
			}

			$return							.=			'</div>';
		}

		if ( $plugin->params->get( 'groups_wall_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return							.=			'<div class="gjGroupWallRow gjGroupWallPaging text-center">'
											.				'<form action="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupWallFormPaging" id="gjGroupWallFormPaging" class="gjGroupWallForm">'
											.					$pageNav->getListLinks()
											.					$pageNav->getLimitBox( false )
											.				'</form>'
											.			'</div>';
		}

		if ( $canCreate ) {
			$return							.=			'<div class="gjGroupWallRow gjGroupWallNewReply">'
											.				'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'wall', 'func' => 'save' ) ) . '" method="post" name="gjGroupWallFormNewReply' . (int) $reply->get( 'id' ) . '" id="gjGroupWallFormNewReply' . (int) $reply->get( 'id' ) . '" class="gjGroupWallForm cbValidation">';

			if ( $messageLimit ) {
				$return						.=					'<div class="gjGroupWallLimit small hidden">'
											.						'<div class="gjGroupWallLimitCurrent">0</div>'
											.						' / <div class="gjGroupWallLimitMax">' . (int) $messageLimit . '</div>'
											.					'</div>';
			}

			$return							.=					'<textarea name="post" rows="1" class="form-control required" placeholder="' . htmlspecialchars( CBTxt::T( 'Write a reply...' ) ) . '"' . ( $messageLimit ? ' maxlength="' . (int) $messageLimit . '"' : null ) . '></textarea>'
											.					'<div class="gjGroupWallNewReplyFooter text-right hidden">'
											.						'<button type="submit" class="gjButton gjButtonSubmit btn btn-primary btn-xs" ' . cbValidator::getSubmitBtnHtmlAttributes() . '>' . CBTxt::T( 'Reply' ) . '</button>'
											.					'</div>'
											.					'<input type="hidden" name="group" value="' . (int) $group->get( 'id' ) . '" />'
											.					'<input type="hidden" name="reply" value="' . (int) $reply->get( 'id' ) . '" />'
											.					cbGetSpoofInputTag( 'plugin' )
											.				'</form>'
											.			'</div>';
		}

		$return								.=		'</div>'
											.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayWall', array( &$return, $rows, $group, $user ) );

		return $return;
	}
Example #13
0
	/**
	 * render frontend invite list
	 *
	 * @param string             $to
	 * @param UserTable[]        $users
	 * @param InviteTable        $invite
	 * @param GroupTable         $group
	 * @param UserTable          $user
	 * @param CBplug_cbgroupjive $plugin
	 * @return string
	 */
	static function showInviteList( $to, $users, $invite, $group, $user, $plugin )
	{
		global $_CB_framework;

		$js								=	"$( '.gjButtonInvite' ).on( 'click', function() {"
										.		"var from = $( this ).closest( 'form' );"
										.		"from.find( '#selected' ).val( $( this ).data( 'user-id' ) );"
										.		"from.find( '.gjButtonInvite' ).addClass( 'disabled' ).prop( 'disabled', true );"
										.		"from.submit();"
										.	"});";

		$_CB_framework->outputCbJQuery( $js );

		$_CB_framework->enqueueMessage( CBTxt::T( 'Multiple matching users found. Please select the user to invite. If you do not see the user you are looking for please be more specific.' ) );

		$pageTitle					=	CBTxt::T( 'INVITE_LIST_TO', 'Invite: [to]', array( '[to]' => $to ) );

		$_CB_framework->setPageTitle( $pageTitle );

		$return						=	'<div class="gjInviteList">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'invites', 'func' => 'save', 'id' => (int) $invite->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjInviteListForm" id="gjInviteListForm" class="cb_form gjInviteListForm form-auto">'
									.			( $pageTitle ? '<div class="gjInviteListTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null )
									.			'<div class="gjInviteListRows">';

		foreach ( $users as $userId ) {
			$cbUser					=	CBuser::getInstance( (int) $userId, false );

			$return					.=				'<div class="gjInviteListUser gjContainerBox img-thumbnail">'
									.					'<div class="gjContainerBoxHeader">'
									.						'<div class="gjContainerBoxCanvas text-left">'
									.							$cbUser->getField( 'canvas', null, 'html', 'none', 'profile', 0, true )
									.						'</div>'
									.						'<div class="gjContainerBoxLogo text-left">'
									.							$cbUser->getField( 'avatar', null, 'html', 'none', 'list', 0, true )
									.						'</div>'
									.					'</div>'
									.					'<div class="gjContainerBoxBody text-left">'
									.						'<div class="gjContainerBoxTitle">'
									.							$cbUser->getField( 'onlinestatus', null, 'html', 'none', 'list', 0, true, array( '_imgMode' => 1 ) )
									.							' <strong>' . $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</strong>'
									.						'</div>'
									.						'<div class="gjContainerBoxButton text-right">'
									.							'<button type="button" class="gjButton gjButtonInvite btn btn-xs btn-success" data-user-id="' . (int) $userId . '">' . CBTxt::T( 'Invite' ) . '</button>'
									.						'</div>'
									.					'</div>'
									.				'</div>';
		}

		$return						.=			'</div>'
									.			'<div class="form-group cb_form_line clearfix">'
									.				'<input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-default" onclick="window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '\';" />'
									.			'</div>'
									.			'<input type="hidden" id="selected" name="selected" value="0" />';

		if ( ! $invite->get( 'id' ) ) {
			$return					.=			'<input type="hidden" id="to" name="to" value="' . htmlspecialchars( $to ) . '" />'
									.			'<input type="hidden" id="group" name="group" value="' . (int) $group->get( 'id' ) . '" />'
									.			'<input type="hidden" id="message" name="message" value="' . htmlspecialchars( $invite->get( 'message' ) ) . '" />';
		}

		$return						.=			'<input type="hidden" id="token" name="token" value="' . htmlspecialchars( md5( $invite->get( 'user_id' ) . $to . $invite->get( 'group' ) . $invite->get( 'message' ) . $_CB_framework->getCfg( 'secret' ) ) ) . '" />'
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		$_CB_framework->setMenuMeta();

		echo $return;
	}
Example #14
0
	/**
	 * sets the forum access based off category or group object access
	 *
	 * @param \CB\Plugin\GroupJive\Table\CategoryTable|GroupTable $row
	 */
	public function access( $row )
	{
		if ( $row instanceof \CB\Plugin\GroupJive\Table\CategoryTable ) {
			$this->_category->set( 'accesstype', 'joomla.level' );
			$this->_category->set( 'access', $row->get( 'access' ) );
		} elseif ( $row instanceof GroupTable ) {
			$this->_category->set( 'accesstype', 'communitybuilder' );
			$this->_category->set( 'access', $row->get( 'id' ) );
		}
	}
Example #15
0
	/**
	 * render frontend group
	 *
	 * @param GroupTable         $row
	 * @param mixed              $users
	 * @param mixed              $invites
	 * @param UserTable          $user
	 * @param CBplug_cbgroupjive $plugin
	 * @return string
	 */
	static function showGroup( $row, $users, $invites, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_CB_framework->setPageTitle( htmlspecialchars( CBTxt::T( $row->get( 'name' ) ) ) );

		initToolTip();

		$js								=	"$( '.gjGroupTabsMenuNavBar' ).on( 'click', '.navbar-toggle', function() {"
										.		"if ( ! $( this ).hasClass( 'dropdown-toggle' ) ) {"
										.			"var navbar = $( this ).closest( '.gjGroupTabsMenuNavBar' ).find( '.navbar-collapse' );"
										.			"var toggle = $( this ).closest( '.gjGroupTabsMenuNavBar' ).find( '.navbar-toggle' );"
										.			"if ( toggle.hasClass( 'collapsed' ) ) {"
										.				"navbar.addClass( 'in' );"
										.				"toggle.removeClass( 'collapsed' );"
										.			"} else {"
										.				"navbar.removeClass( 'in' );"
										.				"toggle.addClass( 'collapsed' );"
										.			"}"
										.		"}"
										.	"}).find( '.cbScroller' ).cbscroller({"
										.		"height: false"
										.	"});"
										.	"$( '.gjGroupTabs' ).on( 'cbtabs.selected', function( e, event, cbtabs, tab ) {"
										.		"var dropdownNav = $( event.target ).closest( '.gjGroupTabsMenuNavBar' );"
										.		"if ( dropdownNav.length ) {"
										.			"var toggle = dropdownNav.find( '.navbar-toggle' );"
										.			"if ( ! toggle.hasClass( 'collapsed' ) ) {"
										.				"toggle.click();"
										.			"}"
										.		"}"
										.	"});";

		$_CB_framework->outputCbJQuery( $js, 'cbscroller' );

		$isModerator					=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner						=	( $user->get( 'id' ) == $row->get( 'user_id' ) );
		$userStatus						=	CBGroupJive::getGroupStatus( $user, $row );
		$counters						=	array();
		$buttons						=	array();
		$menu							=	array();
		$tabs							=	new cbTabs( 1, 1 );
		$return							=	null;

		$integrations					=	$_PLUGINS->trigger( 'gj_onBeforeDisplayGroup', array( &$return, &$row, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user ) );

		$return							.=	'<div class="gjGroup">'
										.		'<div class="gjGroupCanvas gjPageHeader border-default">'
										.			'<div class="gjPageHeaderCanvas">'
										.				'<div class="gjPageHeaderCanvasBackground">'
										.					$row->canvas()
										.				'</div>'
										.				'<div class="gjPageHeaderCanvasLogo">'
										.					$row->logo()
										.				'</div>';

		if ( $isModerator || $isOwner || ( ( ! $isOwner ) && ( ( $userStatus === null ) || ( $userStatus === 0 ) || ( $userStatus >= 1 ) ) ) || $buttons || $menu ) {
			$return						.=				'<div class="gjPageHeaderCanvasButtons text-right">'
										.					( $buttons ? ' <span class="gjPageHeaderCanvasButton">' . implode( '</span> <span class="gjPageHeaderCanvasButton">', $buttons ) . '</span>' : null );

			if ( $isModerator && ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) {
				$return					.=					' <span class="gjPageHeaderCanvasButton">'
										.						'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>'
										.					'</span>';
			} elseif ( ! $isOwner ) {
				if ( $userStatus === null ) {
					$return				.=					' <span class="gjPageHeaderCanvasButton">'
										.						( $row->get( '_invite_id' ) ? '<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to reject all invites to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'reject', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })" class="gjButton gjButtonReject btn btn-xs btn-danger">' . CBTxt::T( 'Reject' ) . '</button> ' : null )
										.						'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'join', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonJoin btn btn-xs btn-success">' . ( $row->get( '_invite_id' ) ? CBTxt::T( 'Accept Invite' ) : CBTxt::T( 'Join' ) ) . '</button>'
										.					'</span>';
				} elseif ( $userStatus === 0 ) {
					$return				.=					' <span class="gjPageHeaderCanvasButton">'
										.						'<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel your pending join request to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'cancel', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })" class="gjButton gjButtonCancel btn btn-xs btn-danger">' . CBTxt::T( 'Cancel' ) . '</button> '
										.						'<span class="gjButton gjButtonPending btn btn-xs btn-warning disabled">' . CBTxt::T( 'Pending Approval' ) . '</span>'
										.					'</span>';
				}
			}

			if ( $isModerator || $isOwner || $menu || ( $userStatus >= 1) ) {
				$menuItems				=	'<ul class="gjGroupMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

				if ( $isModerator || $isOwner ) {
					$menuItems			.=		'<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

					if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) {
						if ( $isModerator ) {
							$menuItems	.=		'<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
						}
					} elseif ( $row->get( 'published' ) == 1 ) {
						$menuItems		.=		'<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
					} else {
						$menuItems		.=		'<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
					}
				}

				if ( $plugin->params->get( 'notifications', 1 ) && ( $isModerator || ( ( $row->get( 'published' ) == 1 ) && ( $isOwner || ( $userStatus >= 1 ) ) ) ) ) {
					$menuItems			.=		'<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'notifications', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-envelope"></span> ' . CBTxt::T( 'Notifications' ) . '</a></li>';
				}

				if ( $isModerator || ( ( $row->get( 'published' ) == 1 ) && $plugin->params->get( 'groups_message', 0 ) && ( $isOwner || ( $userStatus >= 3 ) ) ) ) {
					$delay				=	false;

					if ( ( ! $isModerator ) && $row->params()->get( 'messaged' ) && $plugin->params->get( 'groups_message_delay', 60 ) ) {
						$seconds		=	(int) $plugin->params->get( 'groups_message_delay', 60 );

						if ( $seconds ) {
							$diff		=	Application::Date( 'now', 'UTC' )->diff( $row->get( 'messaged' ) );

							if ( ( $diff === false ) || ( $diff->s < $seconds ) ) {
								$delay	=	true;
							}
						}
					}

					if ( ! $delay ) {
						$menuItems		.=		'<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'message', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-comment"></span> ' . CBTxt::T( 'Message' ) . '</a></li>';
					}
				}

				if ( ( ! $isOwner ) && ( $userStatus >= 1 ) ) {
					$menuItems			.=		'<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to leave this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'leave', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-minus-circle"></span> ' . CBTxt::T( 'Leave' ) . '</a></li>';
				}

				if ( $menu ) {
					$menuItems			.=		'<li class="gjGroupMenuItem">' . implode( '</li><li class="gjGroupMenuItem">', $menu ) . '</li>';
				}

				if ( $isModerator || $isOwner ) {
					$menuItems			.=		'<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
				}

				$menuItems				.=	'</ul>';

				$menuAttr				=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return					.=					' <span class="gjPageHeaderCanvasButton">'
										.						'<div class="gjGroupMenu btn-group">'
										.							'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
										.						'</div>'
										.					'</span>';
			}

			$return						.=				'</div>';
		}

		$return							.=			'</div>'
										.			'<div class="gjPageHeaderBar border-default">'
										.				'<div class="gjPageHeaderBarTitle text-primary">'
										.					'<strong>' . htmlspecialchars( CBTxt::T( $row->get( 'name' ) ) ) . '</strong>'
										.				'</div>'
										.				'<div class="gjPageHeaderBarCounters text-muted small">';

		if ( $row->get( 'category' ) ) {
			$return						.=					'<span class="gjPageHeaderBarCounter"><span class="gjGroupCategoryIcon fa-before fa-folder">'
										.						' <a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $row->get( 'category' ) ) ) . '">' . CBTxt::T( $row->category()->get( 'name' ) ) . '</a>'
										.					'</span></span>';
		}

		$return							.=					' <span class="gjPageHeaderBarCounter"><span class="gjGroupTypeIcon fa-before fa-globe"> ' . $row->type() . '</span></span>'
										.					' <span class="gjPageHeaderBarCounter"><span class="gjGroupUsersIcon fa-before fa-user"> ' . CBTxt::T( 'GROUP_USERS_COUNT', '%%COUNT%% User|%%COUNT%% Users', array( '%%COUNT%%' => (int) $row->get( '_users', 0 ) ) ) . '</span></span>'
										.					( $counters ? ' <span class="gjPageHeaderBarCounter">' . implode( '</span> <span class="gjPageHeaderBarCounter">', $counters ) . '</span>' : null )
										.				'</div>'
										.				( $row->get( 'description' ) ? ' <div class="gjPageHeaderBarDescription">' . cbTooltip( 1, CBTxt::T( $row->get( 'description' ) ), CBTxt::T( $row->get( 'name' ) ), 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null )
										.			'</div>'
										.		'</div>'
										.		'<div class="gjGroupTabs cbTabs cbTabsMenu" id="cbtabsgrouptab" data-cbtabs-use-cookies="true">'
										.			'<div class="gjGroupTabsMenuNavBar cbTabsMenuNavBar navbar navbar-default">'
										.				'<div class="container-fluid">'
										.					'<div class="navbar-header">'
										.						'<button type="button" class="gjGroupTabsMenuNavBarToggle cbTabsMenuNavBarToggle navbar-toggle collapsed">'
										.							'<span class="icon-bar"></span>'
										.							'<span class="icon-bar"></span>'
										.							'<span class="icon-bar"></span>'
										.						'</button>'
										.					'</div>'
										.					'<div class="collapse navbar-collapse cbScroller">'
										.						'<div class="cbScrollerLeft hidden">'
										.							'<button type="button" class="btn btn-xs btn-default"><span class="fa fa-angle-left"></span></button>'
										.						'</div>'
										.						'<ul class="gjGroupTabsNav cbTabsNav cbTabsMenuNav nav navbar-nav cbScrollerContent"></ul>'
										.						'<div class="cbScrollerRight hidden">'
										.							'<button type="button" class="btn btn-xs btn-default"><span class="fa fa-angle-right"></span></button>'
										.						'</div>'
										.					'</div>'
										.				'</div>'
										.			'</div>'
										.			'<div class="cbTabsContent cbTabsMenuContent tab-content">';

		foreach ( $integrations as $integration ) {
			if ( ( ! $integration ) || ( ! isset( $integration['id'] ) ) || ( ! isset( $integration['title'] ) ) || ( ! isset( $integration['content'] ) ) ) {
				continue;
			}

			$return						.=				$tabs->startTab( null, $integration['title'], 'grouptab' . $integration['id'], array( 'tab' => 'cbTabNavMenu', 'pane' => 'tab-pane cbTabPaneMenu', 'override' => true ) )
										.					'<div class="cb_tab_content cb_tab_menu">'
										.						$integration['content']
										.					'</div>'
										.				$tabs->endTab();
		}

		if ( $users ) {
			$return						.=				$tabs->startTab( null, CBTxt::T( 'GROUP_USERS', 'Users' ), 'grouptabusers', array( 'tab' => 'cbTabNavMenu', 'pane' => 'tab-pane cbTabPaneMenu', 'override' => true ) )
										.					'<div class="cb_tab_content cb_tab_menu">'
										.						$users
										.					'</div>'
										.				$tabs->endTab();
		}

		if ( $invites ) {
			$return						.=				$tabs->startTab( null, CBTxt::T( 'Invites' ), 'grouptabinvites', array( 'tab' => 'cbTabNavMenu', 'pane' => 'tab-pane cbTabPaneMenu', 'override' => true ) )
										.					'<div class="cb_tab_content cb_tab_menu">'
										.						$invites
										.					'</div>'
										.				$tabs->endTab();
		}

		$return							.=			'</div>'
										.		'</div>'
										.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayGroup', array( &$return, $row, $users, $invites, $user ) );

		$_CB_framework->setMenuMeta();

		echo $return;
	}
Example #16
0
	/**
	 * render frontend about edit
	 *
	 * @param GroupTable              $row
	 * @param array                   $input
	 * @param UserTable               $user
	 * @param CBplug_cbgroupjiveabout $plugin
	 * @return string
	 */
	static function showAboutEdit( $row, $input, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$pageTitle					=	CBTxt::T( 'About' );

		$_CB_framework->setPageTitle( $pageTitle );

		cbValidator::loadValidation();
		initToolTip();

		$return						=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayAboutEdit', array( &$return, &$row, &$input, $user ) );

		$return						.=	'<div class="gjAboutEdit">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'about', 'func' => 'save', 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjAboutEditForm" id="gjAboutEditForm" class="cb_form gjAboutEditForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="gjAboutEditTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null )
									.			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix cbtwolines">'
									.				'<div class="cb_field col-sm-12">'
									.					$input['about']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally input a detailed description about this group.' ) )
									.				'</div>'
									.			'</div>';

		if ( ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) && $plugin->params->get( 'groups_about_captcha', 0 ) ) {
			$_PLUGINS->loadPluginGroup( 'user' );

			$captcha				=	$_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( false ) );

			if ( ! empty( $captcha ) ) {
				$captcha			=	$captcha[0];

				$return				.=			'<div class="form-group cb_form_line clearfix">'
									.				'<label class="col-sm-3 control-label">' . CBTxt::T( 'Captcha' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					( isset( $captcha[0] ) ? $captcha[0] : null )
									.				'</div>'
									.			'</div>'
									.			'<div class="form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					str_replace( 'inputbox', 'form-control', ( isset( $captcha[1] ) ? $captcha[1] : null ) )
									.					getFieldIcons( null, 1, null )
									.				'</div>'
									.			'</div>';
			}
		}

		$return						.=			'<div class="form-group cb_form_line clearfix cbtwolines">'
									.				'<div class="col-sm-12">'
									.					'<input type="submit" value="' . htmlspecialchars( CBTxt::T( 'Update About' ) ) . '" class="gjButton gjButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'
									.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-default" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })" />'
									.				'</div>'
									.			'</div>'
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayAboutEdit', array( &$return, $row, $input, $user ) );

		$_CB_framework->setMenuMeta();

		echo $return;
	}
Example #17
0
	/**
	 * @param GroupTable  $group
	 * @param UserTable   $user
	 * @return bool
	 */
	static public function canAccessGroup( $group, $user )
	{
		global $_PLUGINS;

		if ( ! $group->get( 'id' ) ) {
			return false;
		} elseif ( CBGroupJive::isModerator( $user->get( 'id' ) ) ) {
			return true;
		}

		static $params					=	null;

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

		static $cache					=	array();

		$groupId						=	(int) $group->get( 'id' );
		$userId							=	(int) $user->get( 'id' );

		if ( ! isset( $cache[$userId][$groupId] ) ) {
			$access						=	true;

			if ( ( ! $group->category()->get( 'id' ) ) && ( ! $params->get( 'groups_uncategorized', 1 ) ) ) {
				$access					=	false;
			} elseif ( $group->category()->get( 'id' ) && ( ( ! $group->category()->get( 'published' ) ) || ( ! CBGroupJive::canAccess( (int) $group->category()->get( 'access' ), (int) $user->get( 'id' ) ) ) ) ) {
				$access					=	false;
			} elseif ( ( $group->get( 'published' ) != 1 ) && ( $user->get( 'id' ) != $group->get( 'user_id' ) ) ) {
				$access					=	false;
			} elseif ( $user->get( 'id' ) != $group->get( 'user_id' ) ) {
				$userStatus				=	CBGroupJive::getGroupStatus( $user, $group );

				if ( $userStatus == -1 ) {
					$access				=	false;
				} elseif ( ( $group->get( 'type' ) == 3 ) && ( ( $userStatus === false ) || ( $userStatus === null ) ) && ( ! CBGroupJive::getGroupInvited( $user, $group ) ) ) {
					$access				=	false;
				}
			}

			$cache[$userId][$groupId]	=	$access;
		}

		return $cache[$userId][$groupId];
	}
Example #18
0
	/**
	 * render frontend group users
	 *
	 * @param CB\Plugin\GroupJive\Table\UserTable[] $rows
	 * @param cbPageNav                             $pageNav
	 * @param bool                                  $searching
	 * @param array                                 $input
	 * @param GroupTable                            $group
	 * @param UserTable                             $user
	 * @param CBplug_cbgroupjive                    $plugin
	 * @return string
	 */
	static function showUsers( $rows, $pageNav, $searching, $input, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		initToolTip();

		$isModerator					=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$isOwner						=	( $user->get( 'id' ) == $group->get( 'user_id' ) );
		$userStatus						=	CBGroupJive::getGroupStatus( $user, $group );
		$canSearch						=	( $plugin->params->get( 'groups_users_search', 0 ) && ( $searching || $pageNav->total ) );
		$return							=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayUsers', array( &$return, &$rows, $group, $user ) );

		$return							.=	'<div class="gjGroupUsers">'
										.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupUsersForm" id="gjGroupUsersForm" class="gjGroupUsersForm">';

		if ( $canSearch ) {
			$return						.=			'<div class="gjHeader gjGroupUsersHeader row">'
										.				'<div class="col-sm-offset-8 col-sm-4 text-right">'
										.					'<div class="input-group">'
										.						'<span class="input-group-addon"><span class="fa fa-search"></span></span>'
										.						$input['search']
										.					'</div>'
										.				'</div>'
										.			'</div>';
		}

		$return							.=			'<div class="gjGroupUsersRows">';

		if ( $rows ) foreach ( $rows as $row ) {
			$canModerate				=	( ( $userStatus >= 2 ) && ( $userStatus > $row->get( 'status' ) ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) );

			$counters					=	array();
			$content					=	null;
			$menu						=	array();

			$_PLUGINS->trigger( 'gj_onDisplayUser', array( &$row, &$counters, &$content, &$menu, $group, $user ) );

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

			switch ( (int) $row->get( 'status' ) ) {
				case -1:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-ban text-danger"></span> ';
					break;
				case 0:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-warning text-warning"></span> ';
					break;
				case 1:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-user"></span> ';
					break;
				case 2:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-gavel text-success"></span> ';
					break;
				case 3:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-gavel text-success"></span> ';
					break;
				case 4:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-star text-primary"></span> ';
					break;
				default:
					$icon				=	'<span class="gjGroupUserStatusIcon fa fa-question text-warning"></span> ';
					break;
			}

			$return						.=				'<div class="gjGroupUsersUser gjContainerBox img-thumbnail">'
										.					'<div class="gjContainerBoxHeader">'
										.						'<div class="gjContainerBoxCanvas text-left">'
										.							$cbUser->getField( 'canvas', null, 'html', 'none', 'profile', 0, true )
										.						'</div>'
										.						'<div class="gjContainerBoxLogo text-left">'
										.							$cbUser->getField( 'avatar', null, 'html', 'none', 'list', 0, true )
										.						'</div>'
										.					'</div>'
										.					'<div class="gjContainerBoxBody text-left">'
										.						'<div class="gjContainerBoxTitle">'
										.							$cbUser->getField( 'onlinestatus', null, 'html', 'none', 'list', 0, true, array( '_imgMode' => 1 ) )
										.							' <strong>' . $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</strong>'
										.						'</div>'
										.						'<div class="gjContainerBoxCounters text-muted small row">'
										.							( $isModerator || $isOwner || $canModerate || ( $row->get( 'status' ) != 1 ) ? '<div class="gjContainerBoxCounter col-sm-6">' . $icon . $row->status() . '</div>' : null )
										.							( $counters ? '<div class="gjContainerBoxCounter col-sm-6">' . implode( '</div><div class="gjContainerBoxCounter col-sm-6">', $counters ) . '</div>' : null )
										.						'</div>'
										.						( $content ? '<div class="gjContainerBoxContent">' . $content . '</div>' : null );

			if ( ( $isModerator || $isOwner || $canModerate ) && ( $row->get( 'status' ) == 0 ) && ( $group->get( 'type' ) == 2 ) ) {
				$return					.=						'<div class="gjContainerBoxButton text-right">'
										.							'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'users', 'func' => 'active', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>'
										.						'</div>';
			}

			$return						.=					'</div>';

			if ( ( $row->get( 'status' ) != 4 ) && ( $isModerator || $isOwner || $canModerate || $menu ) ) {
				$menuItems				=	'<ul class="gjUserMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

				if ( $isModerator || $isOwner ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to promote this user to Owner?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'owner', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-thumbs-o-up"></span> ' . CBTxt::T( 'Promote to Owner' ) . '</a></li>';
				}

				if ( ( $row->get( 'status' ) <= 2 ) && ( $isModerator || $isOwner ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to promote this user to Admin?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'admin', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-thumbs-o-up"></span> ' . CBTxt::T( 'Promote to Admin' ) . '</a></li>';
				}

				if ( ( $row->get( 'status' ) <= 1 ) && ( $isModerator || $isOwner || ( $canModerate && ( $userStatus >= 3 ) ) ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to promote this user to Moderator?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'moderator', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-thumbs-o-up"></span> ' . CBTxt::T( 'Promote to Moderator' ) . '</a></li>';
				}

				if ( ( $row->get( 'status' ) <= 0 ) && ( $isModerator || $isOwner || ( $canModerate && ( $userStatus >= 2 ) ) ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'users', 'func' => 'active', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-thumbs-o-up"></span> ' . ( ( $row->get( 'status' ) == 0 ) && ( $group->get( 'type' ) == 2 ) ? CBTxt::T( 'Approve' ) : CBTxt::T( 'Promote to Active' ) ) . '</a></li>';
				}

				if ( ( $row->get( 'status' ) >= 3 ) && ( $isModerator || $isOwner ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to demote this user to Moderator?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'moderator', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-thumbs-o-down"></span> ' . CBTxt::T( 'Demote to Moderator' ) . '</a></li>';
				}

				if ( ( $row->get( 'status' ) >= 2 ) && ( $isModerator || $isOwner || ( $canModerate && ( $userStatus >= 3 ) ) ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to demote this user to Active?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'active', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-thumbs-o-down"></span> ' . CBTxt::T( 'Demote to Active' ) . '</a></li>';
				}

				if ( ( $row->get( 'status' ) >= 0 ) && ( $isModerator || $isOwner || ( $canModerate && ( $userStatus >= 2 ) ) ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to ban this User?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'ban', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-ban"></span> ' . CBTxt::T( 'Ban' ) . '</a></li>';
				}

				if ( $menu ) {
					$menuItems			.=		'<li class="gjUserMenuItems">' . implode( '</li><li class="gjGroupMenuItem">', $menu ) . '</li>';
				}

				if ( $isModerator || $isOwner || ( $canModerate && ( $userStatus >= 3 ) ) ) {
					$menuItems			.=		'<li class="gjUserMenuItems"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this User?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'users', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . ( ( $row->get( 'status' ) == 0 ) && ( $group->get( 'type' ) == 2 ) ? CBTxt::T( 'Reject' ) : CBTxt::T( 'Delete' ) ) . '</a></li>';
				}

				$menuItems				.=	'</ul>';

				$menuAttr				=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return					.=					'<div class="gjContainerBoxMenu">'
										.						'<div class="gjUserMenu btn-group">'
										.							'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
										.						'</div>'
										.					'</div>';
			}

			$return						.=				'</div>';
		} else {
			if ( $searching ) {
				$return					.=				CBTxt::T( 'No group user search results found.' );
			} else {
				$return					.=				CBTxt::T( 'This group currently has no users.' );
			}
		}

		$return							.=			'</div>';

		if ( $plugin->params->get( 'groups_users_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return						.=			'<div class="gjGroupUsersPaging text-center">'
										.				$pageNav->getListLinks()
										.			'</div>';
		}

		$return							.=			$pageNav->getLimitBox( false )
										.		'</form>'
										.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayUsers', array( &$return, &$rows, $group, $user ) );

		return $return;
	}
	/**
	 * check events create limit
	 *
	 * @param bool       $access
	 * @param string     $param
	 * @param GroupTable $group
	 * @param UserTable  $user
	 */
	public function canCreate( &$access, $param, $group, $user )
	{
		global $_CB_database;

		if ( $param == 'events' ) {
			$createLimit				=	(int) $this->params->get( 'groups_events_create_limit', 0 );

			if ( $createLimit ) {
				static $count			=	array();

				$countId				=	md5( $user->get( 'id' ) . $group->get( 'id' ) );

				if ( ! isset( $count[$countId] ) ) {
					$query				=	'SELECT COUNT(*)'
										.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events' )
										.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
										.	"\n AND " . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' );
					$_CB_database->setQuery( $query );
					$count[$countId]	=	(int) $_CB_database->loadResult();
				}

				if ( $count[$countId] >= $createLimit ) {
					$access				=	false;
				}
			}
		}
	}
	/**
	 * delete all the posts for the group that was deleted
	 *
	 * @param GroupTable $group
	 */
	public function deleteGroup( $group )
	{
		global $_CB_database;

		$query			=	'SELECT *'
						.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_wall' )
						.	"\n WHERE " . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' );
		$_CB_database->setQuery( $query );
		$posts			=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveWall\Table\WallTable', array( $_CB_database ) );

		/** @var WallTable[] $posts */
		foreach ( $posts as $post ) {
			$post->delete();
		}
	}
Example #21
0
	/**
	 * render frontend group edit
	 *
	 * @param GroupTable         $row
	 * @param array              $input
	 * @param CategoryTable      $category
	 * @param UserTable          $user
	 * @param CBplug_cbgroupjive $plugin
	 * @return string
	 */
	static function showGroupEdit( $row, $input, $category, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		cbValidator::loadValidation();
		initToolTip();

		$js							=	"$( '#canvas_method' ).on( 'change', function() {"
									.		"if ( $( this ).val() == 1 ) {"
									.			"$( '#gjCanvasUpload' ).removeClass( 'hidden' ).find( 'input' ).removeClass( 'cbValidationDisabled' );"
									.		"} else {"
									.			"$( '#gjCanvasUpload' ).addClass( 'hidden' ).find( 'input' ).addClass( 'cbValidationDisabled' ).val( '' );"
									.		"}"
									.	"}).change();"
									.	"$( '#logo_method' ).on( 'change', function() {"
									.		"if ( $( this ).val() == 1 ) {"
									.			"$( '#gjLogoUpload' ).removeClass( 'hidden' ).find( 'input' ).removeClass( 'cbValidationDisabled' );"
									.		"} else {"
									.			"$( '#gjLogoUpload' ).addClass( 'hidden' ).find( 'input' ).addClass( 'cbValidationDisabled' ).val( '' );"
									.		"}"
									.	"}).change();";

		$_CB_framework->outputCbJQuery( $js );

		$isModerator				=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$returnUrl					=	CBGroupJive::getReturn( true, true );
		$return						=	null;

		$integrations				=	$_PLUGINS->trigger( 'gj_onBeforeDisplayGroupEdit', array( &$return, &$row, &$input, $category, $user ) );

		if ( $row->get( 'id' ) ) {
			$pageTitle				=	CBTxt::T( 'Edit Group' );

			if ( ! $returnUrl ) {
				$returnUrl			=	$_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) );
			}
		} else {
			$pageTitle				=	CBTxt::T( 'New Group' );

			if ( ! $returnUrl ) {
				$returnUrl			=	$_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $category->get( 'id' ) ) );
			}
		}

		$_CB_framework->setPageTitle( $pageTitle );

		$return						.=	'<div class="gjGroupEdit">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'save', 'id' => (int) $row->get( 'id' ), 'return' => CBGroupJive::getReturn( true ) ) ) . '" method="post" enctype="multipart/form-data" name="gjGroupEditForm" id="gjGroupEditForm" class="cb_form gjGroupEditForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="gjGroupEditTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null );

		if ( $isModerator || ( $row->get( 'id' ) && ( $row->get( 'published' ) != -1 ) ) || ( ! $plugin->params->get( 'groups_create_approval', 0 ) ) ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="published" class="col-sm-3 control-label">' . CBTxt::T( 'Published' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['published']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Select publish state of this group. Unpublished groups will not be visible to the public.' ) )
									.				'</div>'
									.			'</div>';
		}

		if ( $input['category'] ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="category" class="col-sm-3 control-label">' . CBTxt::T( 'Category' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['category']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Select the group category. This is the category a group will belong to and decide its navigation path.' ) )
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<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( null, 0, null, CBTxt::T( 'Select the group type. Type determines the way your group is joined (e.g. Invite requires new users to be invited to join your group).' ) )
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="name" class="col-sm-3 control-label">' . CBTxt::T( 'Name' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['name']
									.					getFieldIcons( null, 1, null, CBTxt::T( 'Input the group name. This is the name that will distinguish this group from others. Suggested to input something unique and intuitive.' ) )
									.				'</div>'
									.			'</div>'
									.			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
									.				'<label for="description" class="col-sm-3 control-label">' . CBTxt::T( 'Description' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['description']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally input the group description. The group description should be short and to the point; describing what your group is all about.' ) )
									.				'</div>'
									.			'</div>';

		if ( $row->get( 'canvas' ) ) {
			$return					.=			'<div class="cbft_delimiter form-group cb_form_line clearfix">'
									.				'<label for="canvas_method" class="col-sm-3 control-label">' . CBTxt::T( 'Canvas' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$row->canvas()
									.				'</div>'
									.			'</div>'
									.			'<div id="gjCanvasMethod" class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					$input['canvas_method']
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<div id="gjCanvasUpload" class="cbft_file cbtt_input form-group cb_form_line clearfix' . ( $row->get( 'canvas' ) ? ' hidden' : null ) . '">'
									.				( ! $row->get( 'canvas' ) ? '<label for="canvas" class="col-sm-3 control-label">' . CBTxt::T( 'Canvas' ) . '</label>' : null )
									.				'<div class="cb_field' . ( $row->get( 'canvas' ) ? ' col-sm-offset-3' : null ) . ' col-sm-9">'
									.					$input['canvas']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally select the group canvas. A canvas should represent the topic of your group; please be respectful and tasteful when selecting a canvas.' ) )
									.					'<div class="help-block">' . implode( ' ', $input['canvas_limits'] ) . '</div>'
									.				'</div>'
									.			'</div>';

		if ( $row->get( 'logo' ) ) {
			$return					.=			'<div class="cbft_delimiter form-group cb_form_line clearfix">'
									.				'<label for="logo_method" class="col-sm-3 control-label">' . CBTxt::T( 'Logo' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$row->logo()
									.				'</div>'
									.			'</div>'
									.			'<div id="gjLogoMethod" class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					$input['logo_method']
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<div id="gjLogoUpload" class="cbft_file cbtt_input form-group cb_form_line clearfix' . ( $row->get( 'logo' ) ? ' hidden' : null ) . '">'
									.				( ! $row->get( 'logo' ) ? '<label for="logo" class="col-sm-3 control-label">' . CBTxt::T( 'Logo' ) . '</label>' : null )
									.				'<div class="cb_field' . ( $row->get( 'logo' ) ? ' col-sm-offset-3' : null ) . ' col-sm-9">'
									.					$input['logo']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally select the group logo. A logo should represent the topic of your group; please be respectful and tasteful when selecting a logo.' ) )
									.					'<div class="help-block">' . implode( ' ', $input['logo_limits'] ) . '</div>'
									.				'</div>'
									.			'</div>';

		if ( ( $row->get( 'type' ) != 3 ) && ( $isModerator || $plugin->params->get( 'groups_invites_display', 1 ) ) ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="params__invites" class="col-sm-3 control-label">' . CBTxt::T( 'Invites' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['invites']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally enable or disable usage of group invites. Group invites allow group users to invite other users to join the group. Group owner and group administrators are exempt from this configuration and can always invite users. Note existing invites will still be accessible.' ) )
									.				'</div>'
									.			'</div>';
		}

		if ( is_array( $integrations ) && $integrations ) {
			$return					.=			implode( '', $integrations );
		}

		if ( $isModerator ) {
			$return					.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="user_id" class="col-sm-3 control-label">' . CBTxt::T( 'Owner' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['user_id']
									.					getFieldIcons( null, 1, null, CBTxt::T( 'Input the group owner id. Group owner determines the creator of the group specified as User ID.' ) )
									.				'</div>'
									.			'</div>';
		}

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

			$captcha				=	$_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( false ) );

			if ( ! empty( $captcha ) ) {
				$captcha			=	$captcha[0];

				$return				.=			'<div class="form-group cb_form_line clearfix">'
									.				'<label class="col-sm-3 control-label">' . CBTxt::T( 'Captcha' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					( isset( $captcha[0] ) ? $captcha[0] : null )
									.				'</div>'
									.			'</div>'
									.			'<div class="form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					str_replace( 'inputbox', 'form-control', ( isset( $captcha[1] ) ? $captcha[1] : null ) )
									.					getFieldIcons( null, 1, null )
									.				'</div>'
									.			'</div>';
			}
		}

		$return						.=			'<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 Group' ) : CBTxt::T( 'Create Group' ) ) ) . '" class="gjButton gjButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'
									.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-default" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ).done( function() { window.location.href = \'' . $returnUrl . '\'; })" />'
									.				'</div>'
									.			'</div>'
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayGroupEdit', array( &$return, $row, $input, $category, $user ) );

		$_CB_framework->setMenuMeta();

		echo $return;
	}
Example #22
0
	/**
	 * render frontend invite edit
	 *
	 * @param InviteTable        $row
	 * @param array              $input
	 * @param GroupTable         $group
	 * @param UserTable          $user
	 * @param CBplug_cbgroupjive $plugin
	 * @return string
	 */
	static function showInviteEdit( $row, $input, $group, $user, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$js							=	"$( '.gjInviteConnection' ).on( 'change', function() {"
									.		"if ( $( this ).val() != 0 ) {"
									.			"$( '.gjInviteOther' ).addClass( 'hidden' );"
									.			"$( this ).parent().css({ display: 'inline' });"
									.		"} else {"
									.			"$( '.gjInviteOther' ).removeClass( 'hidden' );"
									.			"$( this ).parent().css({ display: 'block' });"
									.		"}"
									.	"});";

		$_CB_framework->outputCbJQuery( $js );

		$pageTitle					=	( $row->get( 'id' ) ? CBTxt::T( 'Edit Invite' ) : CBTxt::T( 'New Invite' ) );

		$_CB_framework->setPageTitle( $pageTitle );

		cbValidator::loadValidation();
		initToolTip();

		$isModerator				=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$return						=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayInviteEdit', array( &$return, &$row, &$input, $group, $user ) );

		$return						.=	'<div class="gjInviteEdit">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'invites', 'func' => 'save', 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjInviteEditForm" id="gjInviteEditForm" class="cb_form gjInviteEditForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="gjInviteEditTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null );

		if ( ! $row->get( 'id' ) ) {
			$return					.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="to" class="col-sm-3 control-label">' . CBTxt::T( 'To' ) . '</label>'
									.				'<div class="cb_field col-sm-9">';

			if ( $plugin->params->get( 'groups_invites_list', 0 ) && $input['list'] ) {
				$return				.=					'<div style="margin-bottom: 10px;">' . $input['list'] . '</div>';
			}

			$return					.=					$input['to'];

			if ( $plugin->params->get( 'groups_invites_list', 0 ) && $input['list'] ) {
				$return				.=					getFieldIcons( null, 1, null, CBTxt::T( 'GROUP_INVITE_BY_LIST', 'Input the recipient as [invite_by] or select one of your connections.', array( '[invite_by]' => implode( ', ', $input['invite_by'] ) ) ) );
			} else {
				$return				.=					getFieldIcons( null, 1, null, CBTxt::T( 'GROUP_INVITE_BY', 'Input the recipient as [invite_by].', array( '[invite_by]' => implode( ', ', $input['invite_by'] ) ) ) );
			}

			$return					.=				'</div>'
									.			'</div>';
		}

		$return						.=			'<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">'
									.				'<label for="message" class="col-sm-3 control-label">' . CBTxt::T( 'Message' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['message']
									.					getFieldIcons( null, 0, null, CBTxt::T( 'Optionally input private message to include with the invite.' ) )
									.				'</div>'
									.			'</div>';

		if ( ( ! $isModerator ) && $plugin->params->get( 'groups_invites_captcha', 0 ) ) {
			$_PLUGINS->loadPluginGroup( 'user' );

			$captcha				=	$_PLUGINS->trigger( 'onGetCaptchaHtmlElements', array( false ) );

			if ( ! empty( $captcha ) ) {
				$captcha			=	$captcha[0];

				$return				.=			'<div class="form-group cb_form_line clearfix">'
									.				'<label class="col-sm-3 control-label">' . CBTxt::T( 'Captcha' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					( isset( $captcha[0] ) ? $captcha[0] : null )
									.				'</div>'
									.			'</div>'
									.			'<div class="form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					str_replace( 'inputbox', 'form-control', ( isset( $captcha[1] ) ? $captcha[1] : null ) )
									.					getFieldIcons( null, 1, null )
									.				'</div>'
									.			'</div>';
			}
		}

		$return						.=			'<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 Invite' ) : CBTxt::T( 'Create Invite' ) ) ) . '" class="gjButton gjButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'
									.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-default" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '\'; })" />'
									.				'</div>'
									.			'</div>'
									.			( ! $row->get( 'id' ) ? '<input type="hidden" id="group" name="group" value="' . (int) $group->get( 'id' ) . '" />' : null )
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		$_PLUGINS->trigger( 'gj_onAfterDisplayInviteEdit', array( &$return, $row, $input, $group, $user ) );

		$_CB_framework->setMenuMeta();

		echo $return;
	}