Пример #1
0
	/**
	 * render frontend group wall notify params
	 *
	 * @param NotificationTable $row
	 * @param array             $input
	 * @param GroupTable        $group
	 * @param UserTable         $user
	 * @param cbgjWallPlugin    $plugin
	 * @return string
	 */
	static function showWallNotifications( $row, $input, $group, $user, $plugin )
	{
		$return			=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__wall_new" class="col-sm-9 control-label">' . CBTxt::T( 'Create of new post' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['wall_new']
						.		'</div>'
						.	'</div>';

		if ( $row->group()->params()->get( 'wall', 1 ) == 2 ) {
			$return		.=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__wall_approve" class="col-sm-9 control-label">' . CBTxt::T( 'New post requires approval' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['wall_approve']
						.		'</div>'
						.	'</div>';
		}

		if ( $plugin->params->get( 'groups_wall_replies', 1 ) ) {
			$return		.=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__wall_reply" class="col-sm-9 control-label">' . CBTxt::T( 'User reply to my existing posts' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['wall_reply']
						.		'</div>'
						.	'</div>';
		}

		return $return;
	}
Пример #2
0
	/**
	 * render frontend group file notify params
	 *
	 * @param NotificationTable $row
	 * @param array             $input
	 * @param GroupTable        $group
	 * @param UserTable         $user
	 * @param cbgjFilePlugin    $plugin
	 * @return string
	 */
	static function showFileNotifications( $row, $input, $group, $user, $plugin )
	{
		$return			=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__file_new" class="col-sm-9 control-label">' . CBTxt::T( 'Upload of new file' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['file_new']
						.		'</div>'
						.	'</div>';

		if ( $row->group()->params()->get( 'file', 1 ) == 2 ) {
			$return		.=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__file_approve" class="col-sm-9 control-label">' . CBTxt::T( 'New file requires approval' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['file_approve']
						.		'</div>'
						.	'</div>';
		}

		return $return;
	}
Пример #3
0
	/**
	 * render frontend group event notify params
	 *
	 * @param NotificationTable $row
	 * @param array             $input
	 * @param GroupTable        $group
	 * @param UserTable         $user
	 * @param cbgjEventsPlugin  $plugin
	 * @return string
	 */
	static function showEventNotifications( $row, $input, $group, $user, $plugin )
	{
		$return			=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__event_new" class="col-sm-9 control-label">' . CBTxt::T( 'Schedule of new event' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['event_new']
						.		'</div>'
						.	'</div>'
						.	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__event_edit" class="col-sm-9 control-label">' . CBTxt::T( 'Edit of existing event' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['event_edit']
						.		'</div>'
						.	'</div>';

		if ( $row->group()->params()->get( 'events', 1 ) == 2 ) {
			$return		.=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__event_approve" class="col-sm-9 control-label">' . CBTxt::T( 'New event requires approval' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['event_approve']
						.		'</div>'
						.	'</div>';
		}

		$return			.=	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__event_attend" class="col-sm-9 control-label">' . CBTxt::T( 'User attends my existing events' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['event_attend']
						.		'</div>'
						.	'</div>'
						.	'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
						.		'<label for="params__event_unattend" class="col-sm-9 control-label">' . CBTxt::T( 'User unattends my existing events' ) . '</label>'
						.		'<div class="cb_field col-sm-3 text-right">'
						.			$input['event_unattend']
						.		'</div>'
						.	'</div>';

		return $return;
	}
	/**
	 * save notifications
	 *
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function saveNotifications( $id, $user )
	{
		global $_CB_framework;

		$row				=	new NotificationTable();

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

		$group				=	CBGroupJive::getGroup( $id );

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

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

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

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

		foreach ( $this->getInput()->subTree( 'params' ) as $k => $v ) {
			if ( is_array( $v ) || is_object( $v ) ) {
				continue;
			}

			$k				=	Get::clean( $k, GetterInterface::COMMAND );

			if ( $k ) {
				if ( is_numeric( $v ) ) {
					$v		=	(int) $this->input( 'post/params.' . $k, null, GetterInterface::INT );
				} else {
					$v		=	$this->input( 'post/params.' . $k, null, GetterInterface::STRING );
				}

				$row->params()->set( $k, $v );
			}
		}

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

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

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

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

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

		cbRedirect( $returnUrl, CBTxt::T( 'Notifications saved successfully!' ) );
	}
Пример #5
0
	/**
	 * render frontend events group notifications edit params
	 *
	 * @param string            $return
	 * @param NotificationTable $row
	 * @param array             $input
	 * @param GroupTable        $group
	 * @param UserTable         $user
	 * @return string
	 */
	public function editNotifications( &$return, &$row, &$input, $group, $user )
	{
		CBGroupJive::getTemplate( 'notifications', true, true, $this->element );

		$listToggle					=	array();
		$listToggle[]				=	moscomprofilerHTML::makeOption( '0', CBTxt::T( "Don't Notify" ) );
		$listToggle[]				=	moscomprofilerHTML::makeOption( '1', CBTxt::T( 'Notify' ) );

		$input['event_new']			=	moscomprofilerHTML::yesnoSelectList( 'params[event_new]', 'class="form-control"', (int) $this->input( 'post/params.event_new', $row->params()->get( 'event_new', $this->params->get( 'notifications_default_event_new', 0 ) ), GetterInterface::INT ), CBTxt::T( 'Notify' ), CBTxt::T( "Don't Notify" ), false );
		$input['event_edit']		=	moscomprofilerHTML::yesnoSelectList( 'params[event_edit]', 'class="form-control"', (int) $this->input( 'post/params.event_edit', $row->params()->get( 'event_edit', $this->params->get( 'notifications_default_event_edit', 0 ) ), GetterInterface::INT ), CBTxt::T( 'Notify' ), CBTxt::T( "Don't Notify" ), false );
		$input['event_approve']		=	moscomprofilerHTML::yesnoSelectList( 'params[event_approve]', 'class="form-control"', (int) $this->input( 'post/params.event_approve', $row->params()->get( 'event_approve', $this->params->get( 'notifications_default_event_approve', 0 ) ), GetterInterface::INT ), CBTxt::T( 'Notify' ), CBTxt::T( "Don't Notify" ), false );
		$input['event_attend']		=	moscomprofilerHTML::yesnoSelectList( 'params[event_attend]', 'class="form-control"', (int) $this->input( 'post/params.event_attend', $row->params()->get( 'event_attend', $this->params->get( 'notifications_default_event_attend', 0 ) ), GetterInterface::INT ), CBTxt::T( 'Notify' ), CBTxt::T( "Don't Notify" ), false );
		$input['event_unattend']	=	moscomprofilerHTML::yesnoSelectList( 'params[event_unattend]', 'class="form-control"', (int) $this->input( 'post/params.event_unattend', $row->params()->get( 'event_unattend', $this->params->get( 'notifications_default_event_unattend', 0 ) ), GetterInterface::INT ), CBTxt::T( 'Notify' ), CBTxt::T( "Don't Notify" ), false );

		return HTML_groupjiveEventNotifications::showEventNotifications( $row, $input, $group, $user, $this );
	}
Пример #6
0
	/**
	 * @param null|int $id
	 * @return bool
	 */
	public function delete( $id = null )
	{
		global $_PLUGINS;

		$_PLUGINS->trigger( 'gj_onBeforeDeleteUser', array( &$this ) );

		if ( ! parent::delete( $id ) ) {
			return false;
		}

		static $params			=	null;

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

		if ( ( ! CBGroupJive::isModerator( $this->get( 'user_id' ) ) ) && $params->get( 'groups_delete', 1 ) ) {
			// Delete this users group invites (to and from):
			$query				=	'SELECT *'
								.	"\n FROM " . $this->getDbo()->NameQuote( '#__groupjive_invites' )
								.	"\n WHERE " . $this->getDbo()->NameQuote( 'group' ) . " = " . (int) $this->get( 'group' )
								.	"\n AND ( " . $this->getDbo()->NameQuote( 'user_id' ) . " = " . (int) $this->get( 'user_id' )
								.	"\n OR " . $this->getDbo()->NameQuote( 'user' ) . " = " . (int) $this->get( 'user_id' ) . " )";
			$this->getDbo()->setQuery( $query );
			$invites			=	$this->getDbo()->loadObjectList( null, '\CB\Plugin\GroupJive\Table\InviteTable', array( $this->getDbo() ) );

			/** @var InviteTable[] $invites */
			foreach ( $invites as $invite ) {
				$invite->delete();
			}

			// Delete this users group notifications:
			$notification		=	new NotificationTable();

			$notification->load( array( 'user_id' => (int) $this->get( 'user_id' ), 'group' => (int) $this->get( 'group' ) ) );

			if ( $notification->get( 'id' ) ) {
				$notification->delete();
			}
		}

		$_PLUGINS->trigger( 'gj_onAfterDeleteUser', array( $this ) );

		return true;
	}