コード例 #1
0
 /**
  * @param null      $tab
  * @param UserTable $user
  * @param int       $ui
  * @param array     $postdata
  */
 public function getCBpluginComponent($tab, $user, $ui, $postdata)
 {
     global $_CB_framework, $_PLUGINS, $_CB_PMS;
     cbSpoofCheck('plugin');
     $id = $this->input('id', null, GetterInterface::INT);
     $user = CBuser::getMyUserDataInstance();
     if (!$id) {
         cbRedirect($_CB_framework->userProfileUrl($user->get('id'), false, 'getmypmsproTab'), CBTxt::T('SEND_PMS_MISSING_TO_USER', 'Private message failed to send! Error: Missing to user'), 'error');
     }
     $profileUrl = $_CB_framework->userProfileUrl($id, false, 'getmypmsproTab');
     if (!$user->get('id')) {
         cbRedirect($profileUrl, CBTxt::T('Not authorized.'), 'error');
     }
     if ($id == $user->get('id')) {
         cbRedirect($profileUrl, CBTxt::T('SEND_PMS_ERROR_SELF', 'Private message failed to send! Error: You can not send a private message to your self'), 'error');
     }
     $tab = new TabTable();
     $tab->load(array('pluginclass' => 'getmypmsproTab'));
     if (!($tab->enabled && Application::MyUser()->canViewAccessLevel($tab->viewaccesslevel))) {
         cbRedirect($profileUrl, CBTxt::T('Not authorized.'), 'error');
     }
     $subject = $this->input('subject', null, GetterInterface::STRING);
     $message = $this->input('message', null, GetterInterface::STRING);
     $send = $_CB_PMS->sendPMSMSG($id, $user->get('id'), $subject, $message, false);
     if (is_array($send) && count($send) > 0) {
         $result = $send[0];
     } else {
         $result = false;
     }
     if ($result) {
         cbRedirect($profileUrl, CBTxt::T('SEND_PMS_SUCCESS', 'Private message sent successfully!'));
     } else {
         cbRedirect($profileUrl, $_PLUGINS->getErrorMSG(), 'error');
     }
 }
コード例 #2
0
 /**
  * @param  TabTable   $tab       Current tab
  * @param  UserTable  $user      Current user
  * @param  int        $ui        1 front, 2 admin UI
  * @param  array      $postdata  Raw unfiltred POST data
  * @return string                HTML
  */
 public function getCBpluginComponent($tab, $user, $ui, $postdata)
 {
     global $_CB_framework;
     outputCbJs(1);
     outputCbTemplate(1);
     $plugin = cbblogsClass::getPlugin();
     $model = cbblogsClass::getModel();
     $action = $this->input('action', null, GetterInterface::STRING);
     $function = $this->input('func', null, GetterInterface::STRING);
     $id = $this->input('id', null, GetterInterface::INT);
     $user = CBuser::getUserDataInstance($_CB_framework->myId());
     $tab = new TabTable();
     $tab->load(array('pluginid' => (int) $plugin->id));
     $profileUrl = $_CB_framework->userProfileUrl($user->get('id'), false, 'cbblogsTab');
     if (!($tab->enabled && Application::MyUser()->canViewAccessLevel($tab->viewaccesslevel))) {
         cbRedirect($profileUrl, CBTxt::T('Not authorized.'), 'error');
     }
     ob_start();
     switch ($action) {
         case 'blogs':
             switch ($function) {
                 case 'new':
                     $this->showBlogEdit(null, $user, $model, $plugin);
                     break;
                 case 'edit':
                     $this->showBlogEdit($id, $user, $model, $plugin);
                     break;
                 case 'save':
                     cbSpoofCheck('plugin');
                     $this->saveBlogEdit($id, $user, $model, $plugin);
                     break;
                 case 'publish':
                     $this->stateBlog(1, $id, $user, $model, $plugin);
                     break;
                 case 'unpublish':
                     $this->stateBlog(0, $id, $user, $model, $plugin);
                     break;
                 case 'delete':
                     $this->deleteBlog($id, $user, $model, $plugin);
                     break;
                 case 'show':
                 default:
                     if ($model->type != 2) {
                         cbRedirect(cbblogsModel::getUrl((int) $id, false));
                     } else {
                         $this->showBlog($id, $user, $model, $plugin);
                     }
                     break;
             }
             break;
         default:
             cbRedirect($profileUrl, CBTxt::T('Not authorized.'), 'error');
             break;
     }
     $html = ob_get_contents();
     ob_end_clean();
     $class = $plugin->params->get('general_class', null);
     $return = '<div id="cbBlogs" class="cbBlogs' . ($class ? ' ' . htmlspecialchars($class) : null) . '">' . '<div id="cbBlogsInner" class="cbBlogsInner">' . $html . '</div>' . '</div>';
     echo $return;
 }
コード例 #3
0
	/**
	 * @param null      $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @param array     $postdata
	 */
	public function getCBpluginComponent( $tab, $user, $ui, $postdata )
	{
		global $_CB_framework;

		outputCbJs( 1 );
		outputCbTemplate( 1 );

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

		$tab					=	new TabTable();

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

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

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

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

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

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

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

		echo $return;
	}
コード例 #4
0
function plug_cbgroupjive_install()
{
	global $_CB_database, $_PLUGINS;

	// Uninstall the old integrations to avoid conflicts:
	$integrations									=	array(	'cbgroupjiveabout', 'cbgroupjiveevents', 'cbgroupjivefile',
																'cbgroupjiveforums', 'cbgroupjivephoto', 'cbgroupjivevideo',
																'cbgroupjivewall', 'cbgroupjiveauto'
															);

	foreach ( $integrations as $integration ) {
		$plugin										=	new PluginTable();

		$plugin->load( array( 'element' => $integration ) );

		if ( $plugin->get( 'id' ) && ( ! is_dir( $_PLUGINS->getPluginPath( $plugin ) . '/xml' ) ) ) {
			$plugin->delete();
		}
	}

	// Migrate categories:
	$table											=	'#__groupjive_categories';
	$fields											=	$_CB_database->getTableFields( $table );
	$migrate										=	false;

	if ( isset( $fields[$table]['parent'] ) ) {
		$migrate									=	true;

		$query										=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_categories' );
		$_CB_database->setQuery( $query );
		$categories									=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_categories', 'id' ) );

		/** @var $categories Table[] */
		foreach ( $categories as $category ) {
			$category->set( 'access', ( $category->get( 'access' ) == -2 ? 1 : ( $category->get( 'access' ) == -1 ? 2 : Application::CmsPermissions()->convertOldGroupToViewAccessLevel( $category->get( 'access' ), 'CB GroupJive: Category Access - ' . (int) $category->get( 'id' ) ) ) ) );
			$category->set( 'create_access', ( ! $category->get( 'create' ) ? -1 : ( $category->get( 'create_access' ) == -1 ? 2 : Application::CmsPermissions()->convertOldGroupToViewAccessLevel( $category->get( 'create_access' ), 'CB GroupJive: Category Create Access - ' . (int) $category->get( 'id' ) ) ) ) );

			$categoryParams							=	new Registry( $category->get( 'params' ) );

			// CB GroupJive Forums:
			$categoryParams->set( 'forums', $categoryParams->get( 'forum_show' ) );

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

			$category->store();
		}

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'parent' );
		$_CB_database->dropColumn( $table, 'create' );
		$_CB_database->dropColumn( $table, 'nested' );
		$_CB_database->dropColumn( $table, 'nested_access' );
	}

	// Migrate groups:
	$table											=	'#__groupjive_groups';
	$fields											=	$_CB_database->getTableFields( $table );

	if ( isset( $fields[$table]['parent'] ) ) {
		$migrate									=	true;

		$query										=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' );
		$_CB_database->setQuery( $query );
		$groups										=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_groups', 'id' ) );

		/** @var $groups Table[] */
		foreach ( $groups as $group ) {
			$groupParams							=	new Registry( $group->get( 'params' ) );

			// Core:
			$groupParams->set( 'invites', ( $group->get( 'invite' ) > 0 ? 0 : 1 ) );

			// CB GroupJive Events:
			$groupParams->set( 'events', ( $groupParams->get( 'events_approve' ) ? 2 : $groupParams->get( 'events_show' ) ) );

			// CB GroupJive File:
			$groupParams->set( 'file', ( $groupParams->get( 'file_approve' ) ? 2 : $groupParams->get( 'file_show' ) ) );

			// CB GroupJive Forums:
			$groupParams->set( 'forums', $groupParams->get( 'forum_show' ) );

			// CB GroupJive Photo:
			$groupParams->set( 'photo', ( $groupParams->get( 'photo_approve' ) ? 2 : $groupParams->get( 'photo_show' ) ) );

			// CB GroupJive Video:
			$groupParams->set( 'video', ( $groupParams->get( 'video_approve' ) ? 2 : $groupParams->get( 'video_show' ) ) );

			// CB GroupJive Wall:
			$groupParams->set( 'wall', ( $groupParams->get( 'wall_approve' ) ? 2 : $groupParams->get( 'wall_show' ) ) );

			$group->set( 'params', $groupParams->asJson() );

			$group->store();
		}

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'parent' );
		$_CB_database->dropColumn( $table, 'access' );
		$_CB_database->dropColumn( $table, 'invite' );
		$_CB_database->dropColumn( $table, 'users' );
		$_CB_database->dropColumn( $table, 'nested' );
		$_CB_database->dropColumn( $table, 'nested_access' );
	}

	// Migrate notifications:
	$table											=	'#__groupjive_notifications';
	$fields											=	$_CB_database->getTableFields( $table );

	if ( isset( $fields[$table]['type'] ) ) {
		$migrate									=	true;

		// Delete notification types no longer supported:
		$query										=	'DELETE'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_notifications' )
													.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " != " . $_CB_database->Quote( 'group' );
		$_CB_database->setQuery( $query );
		$_CB_database->query();

		// Migration notification parameters:
		$query										=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_notifications' );
		$_CB_database->setQuery( $query );
		$notifications								=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_notifications', 'id' ) );

		/** @var $notifications Table[] */
		foreach ( $notifications as $notification ) {
			if ( ( $notification->get( 'type' ) == 'group' ) && $notification->get( 'item' ) ) {
				$notification->set( 'group', (int) $notification->get( 'item' ) );

				$notificationParams					=	new Registry( $notification->get( 'params' ) );

				// Core:
				$notificationParams->set( 'user_join', $notificationParams->get( 'group_userjoin' ) );
				$notificationParams->set( 'user_leave', $notificationParams->get( 'group_userleave' ) );
				$notificationParams->set( 'user_approve', $notificationParams->get( 'group_userapprove' ) );
				$notificationParams->set( 'invite_accept', $notificationParams->get( 'group_inviteaccept' ) );

				// CB GroupJive Events:
				$notificationParams->set( 'event_new', $notificationParams->get( 'group_eventnew' ) );
				$notificationParams->set( 'event_approve', $notificationParams->get( 'group_eventapprove' ) );
				$notificationParams->set( 'event_attend', $notificationParams->get( 'group_eventyes' ) );
				$notificationParams->set( 'event_unattend', $notificationParams->get( 'group_eventno' ) );

				// CB GroupJive File:
				$notificationParams->set( 'file_new', $notificationParams->get( 'group_filenew' ) );
				$notificationParams->set( 'file_approve', $notificationParams->get( 'group_fileapprove' ) );

				// CB GroupJive Photo:
				$notificationParams->set( 'photo_new', $notificationParams->get( 'group_photonew' ) );
				$notificationParams->set( 'photo_approve', $notificationParams->get( 'group_photoapprove' ) );

				// CB GroupJive Video:
				$notificationParams->set( 'video_new', $notificationParams->get( 'group_videonew' ) );
				$notificationParams->set( 'video_approve', $notificationParams->get( 'group_videoapprove' ) );

				// CB GroupJive Wall:
				$notificationParams->set( 'wall_new', $notificationParams->get( 'group_wallnew' ) );
				$notificationParams->set( 'wall_approve', $notificationParams->get( 'group_wallapprove' ) );
				$notificationParams->set( 'wall_reply', $notificationParams->get( 'group_wallreply' ) );

				$notification->set( 'params', $notificationParams->asJson() );

				$notification->store();
			}
		}

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'type' );
		$_CB_database->dropColumn( $table, 'item' );
	}

	if ( $migrate ) {
		// Migrate global parameters:
		$plugin										=	new PluginTable();

		$plugin->load( array( 'element' => 'cbgroupjive' ) );

		$pluginParams								=	new Registry( $plugin->get( 'params' ) );

		// Logos:
		$pluginParams->set( 'logo_max_size', $pluginParams->get( 'logo_size' ) );
		$pluginParams->set( 'logo_image_width', $pluginParams->get( 'logo_width' ) );
		$pluginParams->set( 'logo_image_height', $pluginParams->get( 'logo_height' ) );
		$pluginParams->set( 'logo_thumbnail_width', $pluginParams->get( 'logo_thumbwidth' ) );
		$pluginParams->set( 'logo_thumbnail_height', $pluginParams->get( 'logo_thumbheight' ) );

		// Notifications:
		$pluginParams->set( 'notifications', $pluginParams->get( 'general_notifications' ) );
		$pluginParams->set( 'notifications_notifyby', ( $pluginParams->get( 'general_notifyby' ) < 4 ? 2 : 1 ) );
		$pluginParams->set( 'notifications_default_user_join', $pluginParams->get( 'notifications_group_userjoin' ) );
		$pluginParams->set( 'notifications_default_user_leave', $pluginParams->get( 'notifications_group_userleave' ) );
		$pluginParams->set( 'notifications_default_user_approve', $pluginParams->get( 'notifications_group_userapprove' ) );
		$pluginParams->set( 'notifications_default_invite_accept', $pluginParams->get( 'notifications_group_inviteaccept' ) );

		// Categories:
		$pluginParams->set( 'categories_paging', $pluginParams->get( 'overview_paging' ) );
		$pluginParams->set( 'categories_limit', $pluginParams->get( 'overview_limit' ) );
		$pluginParams->set( 'categories_search', $pluginParams->get( 'overview_search' ) );

		switch( (int) $pluginParams->get( 'overview_orderby' ) ) {
			case 7:
				$orderBy							=	5;
				break;
			case 8:
				$orderBy							=	6;
				break;
			case 5:
				$orderBy							=	3;
				break;
			case 6:
				$orderBy							=	4;
				break;
			case 1:
			case 2:
				$orderBy							=	(int) $pluginParams->get( 'overview_orderby' );
				break;
			case 3:
			case 4:
			case 9:
			case 10:
			default:
				$orderBy							=	1;
				break;
		}

		$pluginParams->set( 'categories_orderby', $orderBy );
		$pluginParams->set( 'categories_groups_paging', $pluginParams->get( 'category_groups_paging' ) );
		$pluginParams->set( 'categories_groups_limit', $pluginParams->get( 'category_groups_limit' ) );
		$pluginParams->set( 'categories_groups_search', $pluginParams->get( 'category_groups_search' ) );
		$pluginParams->set( 'categories_groups_orderby', ( $pluginParams->get( 'category_groups_orderby' ) > 8 ? 4 : $pluginParams->get( 'category_groups_orderby' ) ) );

		// Groups:
		$pluginParams->set( 'groups_create_access', ( ! $pluginParams->get( 'group_create' ) ? -1 : ( $pluginParams->get( 'group_create_access' ) == -1 ? 2 : Application::CmsPermissions()->convertOldGroupToViewAccessLevel( $pluginParams->get( 'group_create_access' ), 'CB GroupJive: Groups Create Access' ) ) ) );
		$pluginParams->set( 'groups_create_limit', $pluginParams->get( 'group_limit' ) );
		$pluginParams->set( 'groups_create_approval', $pluginParams->get( 'group_approve' ) );
		$pluginParams->set( 'groups_create_captcha', $pluginParams->get( 'group_captcha' ) );
		$pluginParams->set( 'groups_message', $pluginParams->get( 'group_message' ) );
		$pluginParams->set( 'groups_message_captcha', $pluginParams->get( 'group_message_captcha' ) );
		$pluginParams->set( 'groups_users_paging', $pluginParams->get( 'group_users_paging' ) );
		$pluginParams->set( 'groups_users_limit', $pluginParams->get( 'group_users_limit' ) );
		$pluginParams->set( 'groups_users_search', $pluginParams->get( 'group_users_search' ) );
		$pluginParams->set( 'groups_invites_display', $pluginParams->get( 'group_invites_display' ) );
		$pluginParams->set( 'groups_invites_by', $pluginParams->get( 'group_invites_by' ) );
		$pluginParams->set( 'groups_invites_list', $pluginParams->get( 'group_invites_list' ) );
		$pluginParams->set( 'groups_invites_accept', $pluginParams->get( 'group_invites_accept' ) );
		$pluginParams->set( 'groups_invites_captcha', $pluginParams->get( 'group_invites_captcha' ) );
		$pluginParams->set( 'groups_invites_paging', $pluginParams->get( 'group_invites_paging' ) );
		$pluginParams->set( 'groups_invites_limit', $pluginParams->get( 'group_invites_limit' ) );
		$pluginParams->set( 'groups_invites_search', $pluginParams->get( 'group_invites_search' ) );
		$pluginParams->set( 'groups_paging', $pluginParams->get( 'group_all_paging' ) );
		$pluginParams->set( 'groups_limit', $pluginParams->get( 'group_all_limit' ) );
		$pluginParams->set( 'groups_search', $pluginParams->get( 'group_all_search' ) );
		$pluginParams->set( 'groups_orderby', ( $pluginParams->get( 'group_all_orderby' ) > 8 ? 4 : $pluginParams->get( 'group_all_orderby' ) ) );

		$plugin->set( 'params', $pluginParams->asJson() );

		$plugin->store();

		// Migrate the old auto fields to core GJ:
		$query										=	'UPDATE '. $_CB_database->NameQuote( '#__comprofiler_fields' )
													.	"\n SET " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'groupautojoin' )
													.	', ' . $_CB_database->NameQuote( 'pluginid' ) . ' = ' . (int) $plugin->get( 'id' )
													.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'cbgjautojoin' );
		$_CB_database->setQuery( $query );
		$_CB_database->query();

		// Migrate tab parameters:
		$tab										=	new TabTable();

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

		$tabParams									=	new Registry( $tab->get( 'params' ) );

		$tabParams->set( 'tab_paging', $pluginParams->get( 'group_tab_paging' ) );
		$tabParams->set( 'tab_limit', $pluginParams->get( 'group_tab_limit' ) );
		$tabParams->set( 'tab_search', $pluginParams->get( 'group_tab_search' ) );
		$tabParams->set( 'tab_orderby', ( $pluginParams->get( 'group_tab_orderby' ) > 8 ? 4 : $pluginParams->get( 'group_tab_orderby' ) ) );

		$tab->set( 'params', $tabParams->asJson() );

		$tab->store();
	}

	// Migrate gj auto to cb auto actions if possible:
	$table											=	'#__groupjive_plugin_auto';

	if ( $_CB_database->getTableStatus( $table ) ) {
		$fields										=	$_CB_database->getTableFields( $table );

		if ( isset( $fields[$table]['trigger'] ) ) {
			$autoActions							=	new PluginTable();

			$autoActions->load( array( 'element' => 'cbautoactions' ) );

			if ( $autoActions->get( 'id' ) ) {
				$table								=	'#__comprofiler_plugin_autoactions';
				$fields								=	$_CB_database->getTableFields( $table );

				if ( ! isset( $fields[$table]['conditions'] ) ) {
					return;
				}

				$query								=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_auto' );
				$_CB_database->setQuery( $query );
				$autos								=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_plugin_auto', 'id' ) );

				/** @var $autos Table[] */
				foreach ( $autos as $auto ) {
					$oldParams						=	new Registry( $auto->get( 'params' ) );

					if ( $oldParams->get( 'migrated' ) ) {
						continue;
					}

					$newParams						=	new Registry();
					$newConditions					=	null;

					if ( $auto->get( 'field' ) ) {
						$fields						=	new Registry( $auto->get( 'field' ) );
						$operators					=	new Registry( $auto->get( 'operator' ) );
						$values						=	new Registry( $auto->get( 'value' ) );

						$conditionals				=	count( $fields );

						if ( $conditionals ) {
							$conditions				=	array();

							for ( $i = 0, $n = $conditionals; $i < $n; $i++ ) {
								$field				=	$fields->get( "field$i" );
								$operator			=	$operators->get( "operator$i" );
								$value				=	$values->get( "value$i" );

								if ( $operator ) {
									$conditions[]	=	array( 'field' => $field, 'operator' => $operator, 'value' => $value, 'translate' => 0 );
								}
							}

							if ( $conditions ) {
								$newConditionals	=	new Registry( $conditions );
								$newConditions		=	$newConditionals->asJson();
							}
						}
					}

					$mode							=	$oldParams->get( 'auto' );

					$join							=	array(	'mode'					=>	$mode,
																'groups'				=>	$oldParams->get( 'groups' ),
																'status'				=>	$oldParams->get( 'status' ),
																'name'					=>	( $mode == 2 ? $oldParams->get( 'grp_name' ) : $oldParams->get( 'cat_name' ) ),
																'category'				=>	$oldParams->get( 'category' ),
																'category_name'			=>	$oldParams->get( 'cat_name' ),
																'category_parent'		=>	$oldParams->get( 'cat_parent' ),
																'category_types'		=>	$oldParams->get( 'types' ),
																'category_description'	=>	$oldParams->get( 'cat_description' ),
																'category_unique'		=>	$oldParams->get( 'cat_unique' ),
																'group_parent'			=>	$oldParams->get( 'grp_parent' ),
																'type'					=>	$oldParams->get( 'type' ),
																'parent'				=>	$oldParams->get( 'cat_parent' ),
																'types'					=>	$oldParams->get( 'types' ),
																'description'			=>	( $mode == 2 ? $oldParams->get( 'grp_description' ) : $oldParams->get( 'cat_description' ) ),
																'owner'					=>	( $mode == 2 ? $oldParams->get( 'grp_owner' ) : $oldParams->get( 'cat_owner' ) ),
																'unique'				=>	( $mode == 2 ? $oldParams->get( 'grp_unique' ) : $oldParams->get( 'cat_unique' ) ),
																'autojoin'				=>	$oldParams->get( 'grp_autojoin' ),
																'group_status'			=>	$oldParams->get( 'status' )
															);

					$newParams->set( 'groupjive', array( $join ) );
					$newParams->set( 'exclude', $auto->get( 'exclude' ) );

					$query							=	'INSERT IGNORE INTO '. $_CB_database->NameQuote( '#__comprofiler_plugin_autoactions' )
													.	' ( '
													.		$_CB_database->NameQuote( 'published' )
													.		', ' . $_CB_database->NameQuote( 'title' )
													.		', ' . $_CB_database->NameQuote( 'description' )
													.		', ' . $_CB_database->NameQuote( 'type' )
													.		', ' . $_CB_database->NameQuote( 'trigger' )
													.		', ' . $_CB_database->NameQuote( 'object' )
													.		', ' . $_CB_database->NameQuote( 'variable' )
													.		', ' . $_CB_database->NameQuote( 'access' )
													.		', ' . $_CB_database->NameQuote( 'conditions' )
													.		', ' . $_CB_database->NameQuote( 'params' )
													.	' ) VALUES ( '
													.		(int) $auto->get( 'published' )
													.		', ' . $_CB_database->Quote( $auto->get( 'title' ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'description' ) )
													.		', ' . $_CB_database->Quote( 'groupjive' )
													.		', ' . $_CB_database->Quote( str_replace( ',', '|*|', $auto->get( 'trigger' ) ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'object' ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'variable' ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'access' ) )
													.		', ' . $_CB_database->Quote( $newConditions )
													.		', ' . $_CB_database->Quote( $newParams->asJson() )
													.	' )';
					$_CB_database->setQuery( $query );
					$_CB_database->query();

					$oldParams->set( 'migrated', true );

					$auto->set( 'params', $oldParams->asJson() );

					$auto->store();
				}
			}
		}
	}
}
コード例 #5
0
 /**
  * Deletes tabs and private fields of plugin id
  *
  * @param int $id   id of plugin
  */
 function deleteTabAndFieldsOfPlugin($id)
 {
     global $_CB_database;
     //Find all tabs related to this plugin
     $_CB_database->setQuery("SELECT `tabid`, `fields` FROM #__comprofiler_tabs WHERE pluginid=" . (int) $id);
     $tabs = $_CB_database->loadObjectList();
     if (count($tabs) > 0) {
         $rowTab = new TabTable();
         foreach ($tabs as $tab) {
             //Find all fields related to the tab
             $_CB_database->setQuery("SELECT `fieldid`, `name` FROM #__comprofiler_fields WHERE `tabid`=" . (int) $tab->tabid . " AND `pluginid`=" . (int) $id);
             $fields = $_CB_database->loadObjectList();
             $rowField = new FieldTable();
             //Delete fields and fieldValues, but not data content itself in the comprofilier table so they stay on reinstall
             if (count($fields) > 0) {
                 //delete each field related to a tab and all field value related to a field, but not the content
                 foreach ($fields as $field) {
                     //Now delete the field itself without deleting the user data, preserving it for reinstall
                     //$rowField->deleteColumn('#__comprofiler',$field->name);	// this would delete the user data
                     $rowField->delete($field->fieldid);
                 }
             }
             if ($tab->fields) {
                 $_CB_database->setQuery("SELECT COUNT(*) FROM #__comprofiler_fields WHERE tabid=" . (int) $tab->tabid);
                 $fieldsCount = $_CB_database->loadResult();
                 if ($fieldsCount > 0) {
                     $_CB_database->setQuery("UPDATE #__comprofiler_tabs SET `pluginclass`=null, `pluginid`=null WHERE `tabid`=" . (int) $tab->tabid);
                     $_CB_database->query();
                 } else {
                     //delete each tab
                     $rowTab->delete($tab->tabid);
                 }
             } else {
                 //delete each tab
                 $rowTab->delete($tab->tabid);
             }
         }
     }
     //Find all fields related to this plugin which are in other tabs, are calculated and delete them as they are of no use anymore:
     $_CB_database->setQuery("SELECT `fieldid`, `name` FROM #__comprofiler_fields WHERE `calculated`=1 AND `sys`=0 AND `pluginid`=" . (int) $id);
     $fields = $_CB_database->loadObjectList();
     $rowField = new FieldTable();
     if (count($fields) > 0) {
         foreach ($fields as $field) {
             //Now delete the field itself:
             $rowField->delete($field->fieldid);
         }
     }
     //Find all fields related to this plugin and set to NULL the now uninstalled plugin.
     $_CB_database->setQuery("SELECT COUNT(*) FROM #__comprofiler_fields WHERE pluginid=" . (int) $id);
     $fieldsNumber = $_CB_database->loadResult();
     if ($fieldsNumber > 0) {
         $_CB_database->setQuery("UPDATE #__comprofiler_fields SET pluginid = NULL WHERE pluginid=" . (int) $id);
         $_CB_database->query();
     }
 }
コード例 #6
0
ファイル: tab.php プロジェクト: kosmosby/medicine-prof
	/**
	 * render frontend tab
	 *
	 * @param GroupTable[] $rows
	 * @param cbPageNav    $pageNav
	 * @param bool         $searching
	 * @param array        $input
	 * @param UserTable    $viewer
	 * @param UserTable    $user
	 * @param TabTable     $tab
	 * @param cbgjTab      $plugin
	 * @return string
	 */
	static function showTab( $rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		initToolTip();

		/** @var Registry $params */
		$params							=	$tab->params;

		$isModerator					=	CBGroupJive::isModerator( $viewer->get( 'id' ) );
		$canCreateGroup					=	( $isModerator || ( $viewer->get( 'id' ) == $user->get( 'id' ) ) ? CBGroupJive::canCreateGroup( $viewer ) : false );
		$canSearch						=	( $params->get( 'tab_search', 1 ) && ( $searching || $pageNav->total ) );
		$return							=	null;

		$_PLUGINS->trigger( 'gj_onBeforeDisplayTab', array( &$return, &$rows, $viewer, $user, $tab ) );

		$return							.=	'<div class="gjTab">'
										.		'<form action="' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, (int) $tab->get( 'tabid' ) ) . '" method="post" name="gjTabForm" id="gjTabForm" class="gjTabForm">';

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

			if ( $canCreateGroup ) {
				$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' => 'groups', 'func' => 'new', 'user' => (int) $user->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonNewGroup btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'New Group' ) . '</button>'
										.				'</div>';
			}

			if ( $canSearch ) {
				$return					.=				'<div class="' . ( ! $canCreateGroup ? '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="gjTabRows">';

		if ( $rows ) foreach ( $rows as $row ) {
			$rowOwner					=	( $viewer->get( 'id' ) == $row->get( 'user_id' ) );
			$userStatus					=	CBGroupJive::getGroupStatus( $viewer, $row );

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

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

			$return						.=				'<div class="gjTabGroup gjContainerBox img-thumbnail">'
										.					'<div class="gjContainerBoxHeader">'
										.						'<div class="gjContainerBoxCanvas text-left">'
										.							$row->canvas( true, true )
										.						'</div>'
										.						'<div class="gjContainerBoxLogo text-center">'
										.							$row->logo( true, true, true )
										.						'</div>'
										.					'</div>'
										.					'<div class="gjContainerBoxBody text-left">'
										.						'<div class="gjContainerBoxTitle">'
										.							'<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $row->get( 'name' ) ) ) . '</a></strong>'
										.						'</div>';

			if ( $row->get( 'category' ) ) {
				$return					.=						'<div class="gjContainerBoxSubTitle small">'
										.							'<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $row->get( 'category' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $row->get( '_category_name' ) ) ) . '</a></strong>'
										.						'</div>';
			}

			$return						.=						'<div class="gjContainerBoxCounters text-muted small row">'
										.							'<div class="gjContainerBoxCounter col-sm-6"><span class="gjGroupTypeIcon fa-before fa-globe"> ' . $row->type() . '</span></div>'
										.							'<div class="gjContainerBoxCounter col-sm-6"><span class="gjGroupUsersIcon fa-before fa-user"> ' . CBTxt::T( 'GROUP_USERS_COUNT', '%%COUNT%% User|%%COUNT%% Users', array( '%%COUNT%%' => (int) $row->get( '_users', 0 ) ) ) . '</span></div>'
										.							( $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 )
										.						( $row->get( 'description' ) ? '<div class="gjContainerBoxDescription">' . 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 );

			if ( $isModerator && ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) {
				$return					.=						'<div class="gjContainerBoxButton text-right">'
										.							'<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>'
										.						'</div>';
			} elseif ( ! $rowOwner ) {
				if ( $userStatus === null ) {
					$return				.=						'<div class="gjContainerBoxButton text-right">'
										.							( $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' ), '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) $row->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonJoin btn btn-xs btn-success">' . ( $row->get( '_invite_id' ) ? CBTxt::T( 'Accept Invite' ) : CBTxt::T( 'Join' ) ) . '</button>'
										.						'</div>';
				} elseif ( $userStatus === 0 ) {
					$return				.=						'<div class="gjContainerBoxButton text-right">'
										.							'<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' ), '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>'
										.						'</div>';
				}
			}

			$return						.=					'</div>';

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

				if ( $isModerator || $rowOwner ) {
					$menuItems			.=		'<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'edit', 'id' => (int) $row->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '"><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' ), 'return' => CBGroupJive::getReturn() ) ) . '"><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' ), 'return' => CBGroupJive::getReturn() ) ) . '\'; })"><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' ), 'return' => CBGroupJive::getReturn() ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
					}
				}

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

				if ( $isModerator || $rowOwner ) {
					$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' ), 'return' => CBGroupJive::getReturn() ) ) . '\'; })"><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="gjGroupMenu 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 search results found.' );
			} else {
				if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) {
					$return				.=				CBTxt::T( 'You have no groups.' );
				} else {
					$return				.=				CBTxt::T( 'This user has no groups.' );
				}
			}
		}

		$return							.=			'</div>';

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

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

		$_PLUGINS->trigger( 'gj_onAfterDisplayTab', array( &$return, $rows, $viewer, $user, $tab ) );

		return $return;
	}
コード例 #7
0
ファイル: files.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryItemTable[]      $rows
	 * @param cbPageNav                 $pageNav
	 * @param cbgalleryFolderTable|null $folder
	 * @param bool                      $searching
	 * @param UserTable                 $viewer
	 * @param UserTable                 $user
	 * @param TabTable                  $tab
	 * @param cbTabHandler              $plugin
	 * @return string
	 */
	static public function showFiles( $rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeDisplayFiles', array( &$rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) );

		/** @var Registry $params */
		$params							=	$tab->params;
		$profileOwner					=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator					=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();

		$return							=	'<table class="filesItemsContainer 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->getFileName() );
			$item						=	$title;

			if ( $row->checkExists() ) {
				if ( $row->getLinkDomain() ) {
					$showPath			=	htmlspecialchars( $row->getFilePath() );
					$downloadPath		=	$showPath;
				} else {
					$showPath			=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					$downloadPath		=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'download', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
				}

				$extension				=	$row->getExtension();
				$size					=	$row->getFileSize();

				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="' . $showPath . '" 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="filesItemsDownload btn btn-xs btn-default">'
										.		'<span class="fa fa-download"></span>'
										.	'</a>';
			} else {
				$download				=	'<button type="button" class="filesItemsDownload 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>' );
			}

			$return						.=			'<tr>'
										.				'<td style="width: 1%;" class="text-center">' . $download . '</td>'
										.				'<td class="text-left">' . $item . '</td>'
										.				'<td style="width: 15%;" class="text-center"><span class="filesItemsType fa fa-' . htmlspecialchars( self::getFileIcon( $extension ) ) . '" 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, (int) $params->get( 'tab_files_items_time_display', 0 ), $params->get( 'tab_files_items_date_format', 'M j, Y' ), $params->get( 'tab_files_items_time_format', ' g:h A' ) )
										.					'</span>'
										.				'</td>';

			if ( $cbModerator || $profileOwner ) {
				$menuItems				=	'<ul class="galleryItemsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'
										.		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'edit', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

				if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'files_item_approval', 0 ) ) {
					if ( $cbModerator ) {
						$menuItems		.=		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
					}
				} elseif ( $row->get( 'published' ) > 0 ) {
					$menuItems			.=		'<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this File?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'unpublish', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
				} else {
					$menuItems			.=		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
				}

				$menuItems				.=		'<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this File?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'delete', 'type' => 'files', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'
										.	'</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="galleryItemsMenu 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 file search results found.' );
			} else {
				if ( $folder ) {
					$return				.=					CBTxt::T( 'This folder has no files.' );
				} else {
					if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) {
						$return			.=					CBTxt::T( 'You have no files.' );
					} else {
						$return			.=					CBTxt::T( 'This user has no files.' );
					}
				}
			}

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

		$return							.=		'</tbody>';

		if ( $params->get( ( $folder ? 'tab_files_folder_items_paging' : 'tab_files_items_paging' ), 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return						.=		'<tfoot>'
										.			'<tr>'
										.				'<td colspan="6" class="galleryItemsPaging text-center">'
										.					$pageNav->getListLinks()
										.				'</td>'
										.			'</tr>'
										.		'</tfoot>';
		}

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

		return $return;
	}
コード例 #8
0
/**
 * Commented CBT calls for language parser pickup: Moved to cb.core.php so they get picked-up in front-end language file and not in backend one.
 */
function loadSampleData()
{
    global $_CB_Backend_Title;
    @set_time_limit(240);
    $_CB_Backend_Title = array(0 => array('fa fa-wrench', CBTxt::T('TOOLS_SAMPLE_DATA_TITLE', 'CB Tools: Sample Data: Results')));
    $return = null;
    $affected = false;
    $tab = new TabTable();
    $tab->load(array('title' => '_UE_ADDITIONAL_INFO_HEADER'));
    if (!$tab->tabid) {
        $affected = true;
        $tab->set('title', '_UE_ADDITIONAL_INFO_HEADER');
        $tab->set('displaytype', 'menunested');
        $tab->set('position', 'canvas_main_middle');
        $tab->set('viewaccesslevel', 1);
        $tab->set('enabled', 1);
        $tab->set('ordering', 1);
        if ($tab->getError() || !$tab->store()) {
            $return .= '<div class="form-group cb_form_line clearfix text-danger">' . CBTxt::T('TOOLS_SAMPLE_DATA_TAB_NOT_OK', 'Tab [title] failed to add. Error: [error]', array('[title]' => $tab->get('title'), '[error]' => $tab->getError())) . '</div>';
        }
    }
    if ($affected) {
        $return .= '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('TOOLS_SAMPLE_DATA_TAB_OK', 'Tab Added Successfully!') . '</div>';
    }
    $affected = false;
    $fields = array('cb_website' => array('title' => '_UE_Website', 'type' => 'webaddress', 'registration' => 0, 'ordering' => 1), 'cb_location' => array('title' => '_UE_Location', 'type' => 'text', 'maxlength' => 50, 'size' => 25, 'registration' => 0, 'ordering' => 2), 'cb_occupation' => array('title' => '_UE_Occupation', 'type' => 'text', 'registration' => 0, 'ordering' => 3), 'cb_interests' => array('title' => '_UE_Interests', 'type' => 'text', 'registration' => 0, 'ordering' => 4), 'cb_company' => array('title' => '_UE_Company', 'type' => 'text', 'ordering' => 5), 'cb_city' => array('title' => '_UE_City', 'type' => 'text', 'ordering' => 6), 'cb_state' => array('title' => '_UE_State', 'type' => 'text', 'maxlength' => 10, 'size' => 4, 'ordering' => 7), 'cb_zipcode' => array('title' => '_UE_ZipCode', 'type' => 'text', 'ordering' => 8), 'cb_country' => array('title' => '_UE_Country', 'type' => 'text', 'ordering' => 9), 'cb_address' => array('title' => '_UE_Address', 'type' => 'text', 'ordering' => 10), 'cb_phone' => array('title' => '_UE_PHONE', 'type' => 'text', 'ordering' => 11), 'cb_fax' => array('title' => '_UE_FAX', 'type' => 'text', 'ordering' => 12));
    foreach ($fields as $fieldName => $fieldSettings) {
        $field = new FieldTable();
        $field->load(array('name' => $fieldName));
        if (!$field->fieldid) {
            $affected = true;
            $field->set('name', $fieldName);
            $field->set('registration', 1);
            $field->set('profile', 1);
            $field->set('edit', 1);
            $field->set('published', 1);
            foreach ($fieldSettings as $column => $value) {
                $field->set($column, $value);
            }
            $field->set('tabid', $tab->tabid);
            $field->set('pluginid', 1);
            if ($field->getError() || !$field->store()) {
                $return .= '<div class="form-group cb_form_line clearfix text-danger">' . CBTxt::T('TOOLS_SAMPLE_DATA_FIELD_NOT_OK', 'Field [name] failed to add. Error: [error]', array('[name]' => $field->get('name'), '[error]' => $field->getError())) . '</div>';
            }
        }
    }
    if ($affected) {
        $return .= '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('TOOLS_SAMPLE_DATA_FIELD_OK', 'Fields Added Successfully!') . '</div>';
    }
    $affected = false;
    $list = new ListTable();
    $list->load(array('title' => 'Members List'));
    if (!$list->listid) {
        $affected = true;
        $list->set('title', 'Members List');
        $list->set('viewaccesslevel', 1);
        $list->set('usergroupids', '1|*|6|*|7|*|2|*|3|*|4|*|5|*|8');
        $list->set('default', 1);
        $list->set('published', 1);
        $list->set('ordering', 1);
        $listParams = new Registry();
        $listParams->set('sort_mode', '0');
        $listParams->set('basic_sort', array(array('column' => 'username', 'direction' => 'ASC')));
        $listParams->set('columns', array(array('title' => 'User', 'size' => '3', 'fields' => array(array('field' => '17', 'display' => '4'), array('field' => '29', 'display' => '4'), array('field' => '42', 'display' => '4'), array('field' => '26', 'display' => '4'))), array('title' => 'Info', 'size' => '9', 'fields' => array(array('field' => '27', 'display' => '1'), array('field' => '49', 'display' => '1'), array('field' => '28', 'display' => '1')))));
        $listParams->set('list_grid_layout', '1');
        $list->set('params', $listParams->asJson());
        if ($list->getError() || !$list->store()) {
            $return .= '<div class="form-group cb_form_line clearfix text-danger">' . CBTxt::T('TOOLS_SAMPLE_DATA_LIST_NOT_OK', 'List [title] failed to add. Error: [error]', array('[title]' => $list->get('title'), '[error]' => $tab->getError())) . '</div>';
        }
    }
    if ($affected) {
        $return .= '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('TOOLS_SAMPLE_DATA_LIST_OK', 'List Added Successfully!') . '</div>';
    }
    if (!$return) {
        $return .= '<div class="form-group cb_form_line clearfix">' . CBTxt::T('TOOLS_SAMPLE_DATA_ALREADY_CONFIGURED', 'Sample Data is already loaded!') . '</div>';
    }
    echo $return;
}
コード例 #9
0
ファイル: whitelists.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbantispamWhitelistTable[] $rows
	 * @param cbPageNav                  $pageNav
	 * @param UserTable                  $viewer
	 * @param UserTable                  $user
	 * @param TabTable                   $tab
	 * @param cbTabHandler               $plugin
	 * @return string
	 */
	static public function showWhitelists( $rows, $pageNav, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework;

		/** @var Registry $params */
		$params						=	$tab->params;
		$tabWhitelistUser			=	(int) $params->get( 'tab_whitelist_user', 1 );
		$tabWhitelistIp				=	(int) $params->get( 'tab_whitelist_ip', 1 );
		$tabWhitelistEmail			=	(int) $params->get( 'tab_whitelist_email', 0 );
		$tabWhitelistDomain			=	(int) $params->get( 'tab_whitelist_domain', 0 );

		$return						=	'<div class="whitelistsTab">'
									.		'<form action="' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, (int) $tab->get( 'tabid' ) ) . '" method="post" name="whitelistsForm" id="whitelistsForm" class="whitelistsForm">';

		if ( $tabWhitelistUser || $tabWhitelistIp || $tabWhitelistEmail || $tabWhitelistDomain ) {
			$return					.=			'<div class="whitelistsHeader text-left" style="margin-bottom: 10px;">'
									.				'<div class="btn-group">'
									.					( $tabWhitelistUser ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'whitelist', 'func' => 'user', 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\';" class="whitelistsButton whitelistsButtonWhitelistUser btn btn-default"><span class="fa fa-user"></span> ' . CBTxt::T( 'Whitelist User' ) . '</button>' : null )
									.					( $tabWhitelistIp ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'whitelist', 'func' => 'ip', 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\';" class="whitelistsButton whitelistsButtonWhitelistIP btn btn-default"><span class="fa fa-flag"></span> ' . CBTxt::T( 'Whitelist IP Address' ) . '</button>' : null )
									.					( $tabWhitelistEmail ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'whitelist', 'func' => 'email', 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\';" class="whitelistsButton whitelistsButtonWhitelistEmail btn btn-default"><span class="fa fa-at"></span> ' . CBTxt::T( 'Whitelist Email Address' ) . '</button>' : null )
									.					( $tabWhitelistDomain ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'whitelist', 'func' => 'domain', 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\';" class="whitelistsButton whitelistsButtonWhitelistDomain btn btn-default"><span class="fa fa-globe"></span> ' . CBTxt::T( 'Whitelist Email Domain' ) . '</button>' : null )
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<table class="whitelistsContainer table table-hover table-responsive">'
									.				'<thead>'
									.					'<tr>'
									.						'<th class="text-left">' . CBTxt::T( 'Value' ) . '</th>'
									.						'<th style="width: 20%;" class="text-center hidden-xs">' . CBTxt::T( 'Type' ) . '</th>'
									.						'<th style="width: 30%;" class="text-center hidden-xs">' . CBTxt::T( 'Reason' ) . '</th>'
									.						'<th style="width: 1%;" class="text-right">&nbsp;</th>'
									.					'</tr>'
									.				'</thead>'
									.				'<tbody>';

		if ( $rows ) foreach ( $rows as $row ) {
			$menuItems				=	'<ul class="whitelistsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'
									.		'<li class="whitelistsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'whitelist', 'func' => 'edit', 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'
									.		'<li class="whitelistsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Whitelist?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'whitelist', 'func' => 'delete', 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'
									.	'</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"' );

			switch ( $row->get( 'type' ) ) {
				case 'user':
					$type			=	CBTxt::T( 'User' );
					break;
				case 'ip':
					$type			=	CBTxt::T( 'IP Address' );
					break;
				case 'email':
					$type			=	CBTxt::T( 'Email Address' );
					break;
				case 'domain':
					$type			=	CBTxt::T( 'Email Domain' );
					break;
				default:
					$type			=	CBTxt::T( 'Unknown' );
					break;
			}

			$return					.=					'<tr>'
									.						'<td class="text-left">' . $row->get( 'value' ) . '</td>'
									.						'<td style="width: 20%;" class="text-center hidden-xs">' . $type . '</td>'
									.						'<td style="width: 30%;" class="text-left hidden-xs">' . $row->get( 'reason' ) . '</td>'
									.						'<td style="width: 1%;" class="text-right">'
									.							'<div class="whitelistsMenu btn-group">'
									.								'<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
									.							'</div>'
									.						'</td>'
									.					'</tr>';
		} else {
			$return					.=					'<tr>'
									.						'<td colspan="3" class="text-left">';

			if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) {
				$return				.=							CBTxt::T( 'You have no whitelists.' );
			} else {
				$return				.=							CBTxt::T( 'This user has no whitelists.' );
			}

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

		$return						.=				'</tbody>';

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

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

		return $return;
	}
コード例 #10
0
 /**
  * Fix old 1.x usergroups-based permissions to 2.x access-levels in lists and in tabs
  *
  * @param  \CB\Database\Table\TabTable|\CB\Database\Table\ListTable  $loaderTabOrList
  * @param  string                                                    $titleIfCreate    Title for newly created access levels if needed (e.g. 'CB Tab access')
  * @return void
  *
  * @throws \RuntimeException
  */
 private function convertUserGroupsToViewAccessLevels($loaderTabOrList, $titleIfCreate)
 {
     $loaderTabOrList->getDbo()->setQuery('SELECT * FROM ' . $loaderTabOrList->getDbo()->NameQuote($loaderTabOrList->getTableName()));
     $allTabsOrLists = $loaderTabOrList->loadTrueObjects();
     foreach ($allTabsOrLists as $tabOrList) {
         if (isset($tabOrList->useraccessgroupid)) {
             if ((int) $tabOrList->useraccessgroupid == 0) {
                 // Already converted or new in 2.x+:
                 continue;
             }
             $alreadyConvertedButNotZeroed = (int) $tabOrList->useraccessgroupid == -2 && $tabOrList->viewaccesslevel;
             if ((int) $tabOrList->viewaccesslevel <= 1 && !$alreadyConvertedButNotZeroed) {
                 // Still database default: Convert:
                 $tabOrList->viewaccesslevel = Application::CmsPermissions()->convertOldGroupToViewAccessLevel($tabOrList->useraccessgroupid, $titleIfCreate);
             }
             // Always set to 0 after conversion:
             $tabOrList->useraccessgroupid = 0;
             $tabOrList->store();
         }
     }
 }
コード例 #11
0
	/**
	 * @param null|string|int|TabTable[] $tabs
	 * @param string                     $reason
	 * @param int                        $userId
	 * @param bool                       $jquery
	 * @param string                     $formatting
	 * @param bool                       $tabbed
	 * @return array
	 */
	private function getTabConditional( $tabs, $reason, $userId, $jquery = false, $formatting = 'table', $tabbed = true )
	{
		global $_CB_database, $_CB_framework;

		$disabled													=	array();

		static $userCache											=	array();

		if ( ! isset( $userCache[$userId] ) ) {
			$cbUser													=	CBuser::getInstance( (int) $userId, false );
			$cmsUser												=	Application::User( (int) $userId );

			$userCache[$userId]										=	array( $cbUser, $cbUser->getUserData(), $cmsUser->getAuthorisedViewLevels(), $cmsUser->getAuthorisedGroups() );
		}

		/** @var CBuser $cbUser */
		$cbUser														=	$userCache[$userId][0];
		/** @var UserTable $user */
		$user														=	$userCache[$userId][1];
		/** @var array $userAccessLevels */
		$userAccessLevels											=	$userCache[$userId][2];
		/** @var array $userUsergroups */
		$userUsergroups												=	$userCache[$userId][3];

		static $tabCache											=	array();

		if ( ! $tabs ) {
			/** @var TabTable[] $tabsCache */
			static $tabsCache										=	array();

			if ( ! isset( $tabsCache[$user->id] ) ) {
				$cbTabs												=	$cbUser->_getCbTabs();
				$tabsCache[$user->id]								=	$cbTabs->_getTabsDb( $user, 'adminfulllist' );
			}

			$tabs													=	$tabsCache[$user->id];
		} elseif ( ! is_array( $tabs ) ) {
			if ( is_string( $tabs ) || is_integer( $tabs ) ) {
				$tabId												=	(int) $tabs;

				if ( $tabId ) {
					if ( ! isset( $tabCache[$tabId] ) ) {
						$tab										=	new TabTable();

						$tab->load( $tabId );

						$tabCache[$tabId]							=	$tab;
					}

					$tabs											=	$tabCache[$tabId];
				}
			}

			$tabs													=	array( $tabs );
		} elseif ( is_array( $tabs ) ) {
			$tabArray												=	array();

			foreach ( $tabs as $tabId ) {
				if ( is_string( $tabId ) || is_integer( $tabId ) ) {
					$tabId											=	(int) $tabId;

					if ( $tabId ) {
						if ( ! isset( $tabCache[$tabId] ) ) {
							$tab									=	new TabTable();

							$tab->load( $tabId );

							$tabCache[$tabId]						=	$tab;
						}

						$tabArray[]									=	$tabCache[$tabId];
					}
				} elseif ( $tabId instanceof TabTable ) {
					$tabArray[]										=	$tabId;
				}
			}

			$tabs													=	$tabArray;
		}

		/** @var Registry[] $tabParams */
		static $tabParams											=	array();
		/** @var FieldTable[] $fields */
		static $fields												=	array();
		/** @var FieldTable[] $tabFields */
		static $tabFields											=	array();
		/** @var array[] $conditioned */
		static $conditioned											=	array();

		$uId														=	(int) $user->get( 'id' );

		if ( $tabs ) foreach ( $tabs as $tab ) {
			if ( $tab instanceof TabTable ) {
				$tId												=	(int) $tab->get( 'tabid' );

				if ( ! isset( $conditioned[$tId][$uId][$reason][$jquery] ) ) {
					$tabConditions									=	array();

					$conditioned[$tId][$uId][$reason][$jquery]		=	$tabConditions;

					if ( ! isset( $tabParams[$tId] ) ) {
						if ( ! ( $tab->params instanceof ParamsInterface ) ) {
							$tab->params							=	new Registry( $tab->params );
						}

						$tabParams[$tId]							=	$tab->params;
					}

					$params											=	$tabParams[$tId];

					for ( $i = 1; $i <= 5; $i++ ) {
						$conditional								=	( $i > 1 ? $i : null );
						$display									=	(int) $params->get( 'cbconditional_display' . $conditional, 0 );

						if ( $reason == 'profile' ) {
							if ( ! $params->get( 'cbconditional_target_view' . $conditional, 1 ) ) {
								$display							=	0;
							}
						} elseif ( $reason == 'edit' ) {
							if ( ! $params->get( 'cbconditional_target_edit' . $conditional, 0 ) ) {
								$display							=	0;
							}
						} elseif ( $reason == 'register' ) {
							if ( ! $params->get( 'cbconditional_target_reg' . $conditional, 0 ) ) {
								$display							=	0;
							}
						}

						if ( $display ) {
							$fieldName								=	$params->get( 'cbconditional_field' . $conditional, null );

							if ( $fieldName ) {
								$operator							=	(int) $params->get( 'cbconditional_operator' . $conditional, 0 );
								$value								=	$cbUser->replaceUserVars( $params->get( 'cbconditional_value' . $conditional, null ), false, true, $this->getExtras(), ( (int) $params->get( 'cbconditional_value_translate' . $conditional, 0 ) ? true : false ) );

								if ( in_array( $operator, array( '6', '7' ) ) ) {
									$value							=	null;
								}

								$mode								=	(int) $params->get( 'cbconditional_mode' . $conditional, 0 );

								switch ( $fieldName ) {
									case 'customvalue':
										$fieldValue					=	$cbUser->replaceUserVars( $params->get( 'cbconditional_customvalue' . $conditional, null ), false, true, $this->getExtras(), ( (int) $params->get( 'cbconditional_customvalue_translate' . $conditional, 0 ) ? true : false ) );
										break;
									case 'customviewaccesslevels':
										$accessLevels				=	cbToArrayOfInt( explode( '|*|', $params->get( 'cbconditional_customviewaccesslevels' . $conditional, null ) ) );
										$fieldValue					=	0;

										foreach ( $accessLevels as $accessLevel ) {
											if ( in_array( $accessLevel, $userAccessLevels ) ) {
												$fieldValue			=	1;
												break;
											}
										}

										$operator					=	0;
										$value						=	1;
										break;
									case 'customusergroups':
										$userGroups					=	cbToArrayOfInt( explode( '|*|', $params->get( 'cbconditional_customusergroups' . $conditional, null ) ) );
										$fieldValue					=	0;

										foreach ( $userGroups as $userGroup ) {
											if ( in_array( $userGroup, $userUsergroups ) ) {
												$fieldValue			=	1;
												break;
											}
										}

										$operator					=	0;
										$value						=	1;
										break;
									default:
										if ( ! isset( $fields[$fieldName] ) ) {
											$field					=	new FieldTable();

											$field->load( array( 'name' => $fieldName ) );

											$fields[$fieldName]		=	$field;
										}

										$fieldValue					=	$this->getFieldValue( $user, $cbUser, $fields[$fieldName], $reason );
										break;
								}

								if ( $jquery ) {
									$_CB_framework->addJQueryPlugin( 'cbcondition', '/components/com_comprofiler/plugin/user/plug_cbconditional/js/cbcondition.js' );

									$js								=	"var tabCondition = ['#cbtp_$tId'];";

									if ( $tabbed ) {
										$js							.=	"tabCondition.push( '#cbtabpane$tId' );";
									} else {
										if ( in_array( $formatting, array( 'tables', 'divs' ) ) ) {
											$js						.=	"tabCondition.push( '#cbtf_$tId' );";
										} else {
											if ( ! isset( $tabFields[$tId] ) ) {
												$query				=	'SELECT *'
																	.	"\n FROM " .  $_CB_database->NameQuote( '#__comprofiler_fields' )
																	.	"\n WHERE " . $_CB_database->NameQuote( 'tabid' ) . " = " . (int) $tId;
												$_CB_database->setQuery( $query );
												$tabFields[$tId]	=	$_CB_database->loadObjectList( null, '\CB\Database\Table\FieldTable', array( $_CB_database ) );
											}

											foreach ( $tabFields[$tId] as $tabField ) {
												/** @var  FieldTable $tabField */
												$fId				=	(int) $tabField->get( 'fieldid' );

												$js					.=	"tabCondition.push( '#cbfr_$fId,#cbfr_' . $fId . '__verify,#cbfrd_$fId,#cbfrd_' . $fId . '__verify' );";
											}
										}
									}

									switch ( $fieldName ) {
										case 'customvalue':
										case 'customviewaccesslevels':
										case 'customusergroups':
											$js						.=	"$.cbcondition({"
																	.		"conditions: [{"
																	.			"operator: " . (int) $operator . ","
																	.			"input: '" . addslashes( str_replace( array( "\n", "\r" ), array( "\\n", "\\r" ), ( is_array( $fieldValue ) ? implode( '|*|', $fieldValue ) : $fieldValue ) ) ) . "',"
																	.			"value: '" . addslashes( str_replace( array( "\n", "\r" ), array( "\\n", "\\r" ), ( is_array( $value ) ? implode( '|*|', $value ) : $value ) ) ) . "',"
																	.			( $mode ? "show: tabCondition," : "hide: tabCondition," )
																	.			"reset: " . (int) $this->params->get( 'cond_reset', 0 ) . ""
																	.		"}]"
																	.	"});";
											break;
										default:
											$fieldId				=	$fields[$fieldName]->get( 'fieldid' );

											if ( $fieldId ) {
												$js					.=	"$( '#cbfr_" . (int) $fieldId . ",#cbfrd_" . (int) $fieldId . "' ).cbcondition({"
																	.		"conditions: [{"
																	.			"operator: " . (int) $operator . ","
																	.			"input: '" . addslashes( str_replace( array( "\n", "\r" ), array( "\\n", "\\r" ), ( is_array( $fieldValue ) ? implode( '|*|', $fieldValue ) : $fieldValue ) ) ) . "',"
																	.			"value: '" . addslashes( str_replace( array( "\n", "\r" ), array( "\\n", "\\r" ), ( is_array( $value ) ? implode( '|*|', $value ) : $value ) ) ) . "',"
																	.			( $mode ? "show: tabCondition," : "hide: tabCondition," )
																	.			"reset: " . (int) $this->params->get( 'cond_reset', 0 ) . ""
																	.		"}]"
																	.	"});";
											}
											break;
									}

									$_CB_framework->outputCbJQuery( $js, 'cbcondition' );
								}

								$tabConditions[]					=	array(	'match' => $this->getMatch( $fieldValue, $operator, $value ),
																				'mode' => $mode,
																				'tab' => $tId
																			);
							}
						}
					}

					$conditioned[$tId][$uId][$reason][$jquery]		=	$tabConditions;
				}

				$conditions											=	$conditioned[$tId][$uId][$reason][$jquery];

				foreach ( $conditions as $cond ) {
					if ( $cond['match'] ) {
						if ( ( ! $cond['mode'] ) && ( ! in_array( $cond['tab'], $disabled ) ) ) {
							array_push( $disabled, $cond['tab'] );
						}
					} else {
						if ( $cond['mode'] && ( ! in_array( $cond['tab'], $disabled ) ) ) {
							array_push( $disabled, $cond['tab'] );
						}
					}
				}
			}
		}

		return $disabled;
	}
コード例 #12
0
ファイル: item_edit.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryItemTable $row
	 * @param array              $input
	 * @param string             $type
	 * @param TabTable           $tab
	 * @param UserTable          $user
	 * @param UserTable          $viewer
	 * @param cbPluginHandler    $plugin
	 */
	static public function showItemEdit( $row, $input, $type, $tab, $user, $viewer, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeItemEdit', array( &$row, &$input, $type, $tab, $user, $viewer, $plugin ) );

		/** @var Registry $params */
		$params						=	$tab->params;

		cbValidator::loadValidation();

		switch( $type ) {
			case 'photos':
				$typeTranslated		=	CBTxt::T( 'Photo' );
				$galleryType		=	CBTxt::T( 'Photos' );
				break;
			case 'files':
				$typeTranslated		=	CBTxt::T( 'File' );
				$galleryType		=	CBTxt::T( 'Files' );
				break;
			case 'videos':
				$typeTranslated		=	CBTxt::T( 'Video' );
				$galleryType		=	CBTxt::T( 'Videos' );
				break;
			case 'music':
				$typeTranslated		=	CBTxt::T( 'Music' );
				$galleryType		=	$typeTranslated;
				break;
			default:
				$typeTranslated		=	CBTxt::T( 'Item' );
				$galleryType		=	CBTxt::T( 'Items' );
				break;
		}

		switch( $type ) {
			case 'photos':
			case 'videos':
			case 'music':
				$folderType			=	CBTxt::T( 'Album' );
				break;
			default:
				$folderType			=	CBTxt::T( 'Folder' );
				break;
		}

		$cbModerator				=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();
		$pageTitle					=	( $row->get( 'id' ) ? CBTxt::T( 'EDIT_ITEM_TYPE', 'Edit [type]', array( '[type]' => $typeTranslated ) ) : CBTxt::T( 'NEW_ITEM_TYPE', 'New [type]', array( '[type]' => $typeTranslated ) ) );

		if ( $row->get( 'folder' ) ) {
			$returnUrl				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'folder' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) );
		} else {
			$returnUrl				=	$_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, $tab->get( 'tabid' ) );
		}

		$_CB_framework->setPageTitle( $pageTitle );
		$_CB_framework->appendPathWay( htmlspecialchars( $galleryType ), $returnUrl );
		$_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'items', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) : array( 'action' => 'items', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) ) );

		initToolTip();

		$return						=	'<div class="' . htmlspecialchars( $type ) . 'ItemEdit">'
									.		'<form action="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'save', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '" method="post" enctype="multipart/form-data" name="' . htmlspecialchars( $type ) . 'ItemForm" id="' . htmlspecialchars( $type ) . 'ItemForm" class="cb_form ' . htmlspecialchars( $type ) . 'ItemForm galleryItemForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="galleryItemTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null );

		if ( $cbModerator || ( ! $plugin->params->get( $type . '_item_approval', 0 ) ) || ( $row->get( 'id' ) && ( $row->get( 'published' ) != -1 ) ) ) {
			$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( 1, 0, null, CBTxt::T( 'ITEM_PUBLISHED_DESCRIPTION', 'Select publish status of the [type]. If unpublished the [type] will not be visible to the public.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="title" class="col-sm-3 control-label">' . CBTxt::T( 'Title' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['title']
									.					getFieldIcons( 1, 0, null, CBTxt::T( 'ITEM_TITLE_DESCRIPTION', 'Optionally input a title. If no title is provided the filename will be displayed as the title.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';

		if ( $params->get( 'tab_' . $type . '_folders', 1 ) ) {
			$return					.=			'<div class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="folder" class="col-sm-3 control-label">' . $folderType . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['folder']
									.					getFieldIcons( 1, 0, null, CBTxt::T( 'ITEM_FOLDER_DESCRIPTION', 'Select the [folder_type] for this [type].', array( '[folder_type]' => $folderType, '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';
		}

		if ( $row->get( 'id' ) && $row->checkExists() ) {
			$domain					=	$row->getLinkDomain();

			if ( $domain ) {
				$downloadPath		=	htmlspecialchars( $row->getFilePath() );
			} else {
				$downloadPath		=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'download', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
			}

			$return					.=			'<div class="cbft_delimiter form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					'<a href="' . $downloadPath . '" target="_blank">'
									.						$row->getFileName()
									.					'</a>'
									.					( ! in_array( $domain, array( 'youtube', 'youtu' ) ) ? ' (' . $row->getFileSize() . ')' : null )
									.				'</div>'
									.			'</div>';

			switch( $type ) {
				case 'photos':
					if ( $domain ) {
						$photoSrc	=	htmlspecialchars( $row->getFilePath() );
					} else {
						$photoSrc	=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'preview', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					}

					$itemDisplay	=	'<img src="' . $photoSrc . '" type="' . htmlspecialchars( $row->getMimeType() ) . '" class="itemPhotoPreview img-responsive" />';
					break;
				case 'videos':
					$_CB_framework->outputCbJQuery( "$( '#itemVideoPlayer' ).mediaelementplayer({ isVideo: true });", 'media' );

					if ( $domain ) {
						$videoSrc	=	htmlspecialchars( $row->getFilePath() );
					} else {
						$videoSrc	=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'videos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					}

					$itemDisplay	=	'<video width="640" height="360" style="width: 100%; height: 100%;" src="' . $videoSrc . '" type="' . htmlspecialchars( $row->getMimeType() ) . '" id="itemVideoPlayer"></video>';
					break;
				case 'music':
					$_CB_framework->outputCbJQuery( "$( '#itemMusicPlayer' ).mediaelementplayer({ isVideo: false });", 'media' );

					if ( $domain ) {
						$audioSrc	=	htmlspecialchars( $row->getFilePath() );
					} else {
						$audioSrc	=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					}

					$itemDisplay	=	'<audio width="640" style="width: 100%;" src="' . $audioSrc . '" type="' . htmlspecialchars( $row->getMimeType() ) . '" id="itemMusicPlayer"></audio>';
					break;
				default:
					$itemDisplay	=	null;
					break;
			}

			if ( $itemDisplay ) {
				$return				.=			'<div class="cbft_delimiter form-group cb_form_line clearfix">'
									.				'<div class="cb_field col-sm-offset-3 col-sm-9">'
									.					$itemDisplay
									.				'</div>'
									.			'</div>';
			}
		}

		if ( $input['method'] ) {
			$return					.=			'<div id="itemMethod" class="cbft_select cbtt_select form-group cb_form_line clearfix">'
									.				'<label for="method" class="col-sm-3 control-label">' . $typeTranslated . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['method']
									.				'</div>'
									.			'</div>';
		}

		$newButton					=	null;

		if ( $input['upload'] ) {
			$newButton				=	CBTxt::T( 'UPLOAD_ITEM_TYPE', 'Upload [type]', array( '[type]' => $typeTranslated ) );

			$return					.=			'<div id="itemUpload" class="cbft_file cbtt_input form-group cb_form_line clearfix' . ( $input['method'] ? ' hidden' : null ) . '">'
									.				( ! $input['method'] ? '<label for="file" class="col-sm-3 control-label">' . $typeTranslated . '</label>' : null )
									.				'<div class="cb_field' . ( $input['method'] ? ' col-sm-offset-3' : null ) . ' col-sm-9">'
									.					$input['upload']
									.					getFieldIcons( 1, ( ! $row->get( 'id' ) ? 1 : 0 ), null, CBTxt::T( 'ITEM_UPLOAD_DESCRIPTION', 'Select the file to upload.', array( '[type]' => $typeTranslated ) ) )
									.					( $input['upload_limits'] ? '<div class="help-block">' . implode( ' ', $input['upload_limits'] ) . '</div>' : null )
									.				'</div>'
									.			'</div>';
		}

		if ( $input['link'] ) {
			if ( ! $newButton ) {
				$newButton			=	CBTxt::T( 'LINK_ITEM_TYPE', 'Link [type]', array( '[type]' => $typeTranslated ) );
			}

			$return					.=			'<div id="itemLink" class="cbft_text cbtt_input form-group cb_form_line clearfix' . ( $input['method'] ? ' hidden' : null ) . '">'
									.				( ! $input['method'] ? '<label for="value" class="col-sm-3 control-label">' . $typeTranslated . '</label>' : null )
									.				'<div class="cb_field' . ( $input['method'] ? ' col-sm-offset-3' : null ) . ' col-sm-9">'
									.					$input['link']
									.					getFieldIcons( 1, ( ! $row->get( 'id' ) ? 1 : 0 ), null, CBTxt::T( 'ITEM_LINK_DESCRIPTION', 'Input the URL to the file to link.', array( '[type]' => $typeTranslated ) ) )
									.					( $input['link_limits'] ? '<div class="help-block">' . implode( ' ', $input['link_limits'] ) . '</div>' : null )
									.				'</div>'
									.			'</div>';
		}

		if ( ! $newButton ) {
			$newButton				=	CBTxt::T( 'CREATE_ITEM_TYPE', 'Create [type]', array( '[type]' => $typeTranslated ) );
		}

		$return						.=			'<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( 1, 0, null, CBTxt::T( 'ITEM_DESCRIPTION_DESCRIPTION', 'Optionally input a description.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';

		if ( $cbModerator ) {
			$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( 1, 1, null, CBTxt::T( 'ITEM_OWNER_DESCRIPTION', 'Input owner as single integer user_id.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';
		}

		if ( $plugin->params->get( $type . '_item_captcha', 0 ) && ( ! $cbModerator ) ) {
			$_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( 1, 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_ITEM_TYPE', 'Update [type]', array( '[type]' => $typeTranslated ) ) : $newButton ) ) . '" class="galleryButton galleryButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />&nbsp;'
									.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="galleryButton galleryButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $returnUrl . '\'; }" />'
									.				'</div>'
									.			'</div>'
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		echo $return;
	}
コード例 #13
0
	/**
	 * @param  TabTable   $tab       Current tab
	 * @param  UserTable  $user      Current user
	 * @param  int        $ui        1 front, 2 admin UI
	 * @param  array      $postdata  Raw unfiltred POST data
	 * @return string                HTML
	 */
	public function getCBpluginComponent( $tab, $user, $ui, $postdata )
	{
		global $_CB_framework;

		$format						=	$this->input( 'format', null, GetterInterface::STRING );
		$raw						=	( $format == 'raw' );

		if ( ! $raw ) {
			outputCbJs();
			outputCbTemplate();
		}

		$action						=	null;
		$function					=	null;
		$id							=	null;
		$viewer						=	CBuser::getMyUserDataInstance();
		$user						=	$viewer;
		$stream						=	null;
		$inline						=	false;
		$data						=	true;

		if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof StreamInterface ) ) {
			$stream					=	$postdata['stream'];

			if ( $stream instanceof ActivityInterface ) {
				$action				=	'activity';
				$function			=	'show';
			} elseif ( $stream instanceof CommentsInterface ) {
				$action				=	'comments';
				$function			=	'show';
			} elseif ( $stream instanceof TagsInterface ) {
				$action				=	'tags';
				$function			=	'show';
			}

			if ( isset( $postdata['inline'] ) ) {
				$inline				=	$postdata['inline'];
			}

			if ( isset( $postdata['data'] ) ) {
				$data				=	$postdata['data'];
			}

			$user					=	$stream->user();
		} else {
			$action					=	$this->input( 'action', null, GetterInterface::STRING );
			$function				=	$this->input( 'func', null, GetterInterface::STRING );

			if ( $action == 'recentactivity' ) {
				$action				=	'activity';
				$function			=	'recent';
			} elseif ( $action == 'myactivity' ) {
				$action				=	'activity';
				$function			=	'my';
			} elseif ( $action == 'hiddenactivity' ) {
				$action				=	'hidden';
				$function			=	'activity';
			} elseif ( $action == 'hiddencomments' ) {
				$action				=	'hidden';
				$function			=	'comments';
			}

			if ( ( $action == 'activity' ) || ( $function == 'activity' ) ) {
				$stream				=	new Activity();
			} elseif ( ( $action == 'comments' ) || ( $function == 'comments' ) ) {
				$stream				=	new Comments();
			} elseif ( ( $action == 'tags' ) || ( $function == 'tags' ) ) {
				$stream				=	new Tags();
			}

			if ( $stream && $raw ) {
				$token				=	$this->input( 'token', null, GetterInterface::STRING );

				$post				=	new Registry( base64_decode( $this->input( 'stream', null, GetterInterface::BASE64 ) ) );

				$source				=	$post->get( 'source', null, GetterInterface::STRING );
				$userId				=	$post->get( 'user', null, GetterInterface::INT );
				$direction			=	$post->get( 'direction', null, GetterInterface::INT );

				if ( $source !== null ) {
					$stream->source( $source );
				}

				if ( $userId !== null ) {
					$user			=	CBuser::getUserDataInstance( (int) $userId );

					$stream->user( $user );
				}

				if ( ! ( $stream instanceof TagsInterface ) ) {
					if ( $direction !== null ) {
						$stream->direction( $direction );
					}
				}

				$stream->load( $post );

				if ( ( $stream->token() != $token ) || ( ! $token ) ) {
					header( 'HTTP/1.0 401 Unauthorized' );
					exit();
				}

				$id					=	$stream->get( 'id', null, GetterInterface::INT );
			}
		}

		if ( $stream && ( ! ( ( $stream instanceof CommentsInterface ) || ( $stream instanceof TagsInterface ) ) ) ) {
			$hashtag				=	$this->input( 'hashtag', null, GetterInterface::STRING );

			if ( $hashtag !== null ) {
				$stream->set( 'filter', '#' . $hashtag );
			}
		}

		if ( ! $raw ) {
			ob_start();
		}

		switch ( $action ) {
			case 'comments':
				if ( ! $stream ) {
					if ( $raw ) {
						header( 'HTTP/1.0 401 Unauthorized' );
						exit();
					} else {
						cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
					}
				}

				switch ( $function ) {
					case 'new':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->saveComment( null, $stream, $user, $viewer );
						break;
					case 'save':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->saveComment( $id, $stream, $user, $viewer );
						break;
					case 'delete':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->deleteComment( $id, $stream, $user, $viewer );
						break;
					case 'hide':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->hideComment( $id, $stream, $user, $viewer );
						break;
					case 'unhide':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->unhideComment( $id, $stream, $user, $viewer );
						break;
					case 'load':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->showComments( $id, $stream, 3, true, $user, $viewer );
						break;
					case 'show':
					default:
						if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof CommentsInterface ) ) {
							$this->showComments( $id, $stream, ( $inline ? 2 : 0 ), $data, $user, $viewer );
						} else {
							$this->showComments( $id, $stream, ( $inline ? 2 : ( $raw ? 1 : 0 ) ), true, $user, $viewer );
						}
						break;
				}
				break;
			case 'activity':
				if ( ! $stream ) {
					if ( $raw ) {
						header( 'HTTP/1.0 401 Unauthorized' );
						exit();
					} else {
						cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
					}
				}

				switch ( $function ) {
					case 'new':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->saveActivity( null, $stream, $user, $viewer );
						break;
					case 'save':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->saveActivity( $id, $stream, $user, $viewer );
						break;
					case 'delete':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->deleteActivity( $id, $stream, $user, $viewer );
						break;
					case 'hide':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->hideActivity( $id, $stream, $user, $viewer );
						break;
					case 'unhide':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->unhideActivity( $id, $stream, $user, $viewer );
						break;
					case 'load':
						if ( ! $raw ) {
							cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
						}

						$this->showActivity( $id, $stream, 3, true, $user, $viewer );
						break;
					case 'recent':
						$stream->source( 'recent' );

						$menu				=	JFactory::getApplication()->getMenu()->getActive();

						if ( $menu && isset( $menu->id ) ) {
							CBActivity::loadStreamDefaults( $stream, $menu->params, 'activity_' );
						}

						$this->showActivity( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer );

						$_CB_framework->setMenuMeta();
						break;
					case 'my':
						$tab				=	new TabTable();

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

						if ( ! ( $tab->get( 'enabled' ) && CBActivity::canAccess( (int) $tab->get( 'viewaccesslevel' ), (int) $viewer->get( 'id' ) ) ) ) {
							if ( $raw ) {
								header( 'HTTP/1.0 401 Unauthorized' );
								exit();
							} else {
								cbRedirect( $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, 'cbactivityTab' ), CBTxt::T( 'Not authorized.' ), 'error' );
							}
						}

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

						$stream->source( 'profile' );

						CBActivity::loadStreamDefaults( $activity, $tab->params, 'tab_activity_' );

						$this->showActivity( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer );

						$_CB_framework->setMenuMeta();
						break;
					case 'show':
					default:
						if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof ActivityInterface ) ) {
							$this->showActivity( $id, $stream, ( $inline ? 2 : 0 ), $data, $user, $viewer );
						} else {
							$this->showActivity( $id, $stream, ( $inline ? 2 : ( $raw ? 1 : 0 ) ), true, $user, $viewer );
						}
						break;
				}
				break;
			case 'hidden':
				if ( ! $stream ) {
					if ( $raw ) {
						header( 'HTTP/1.0 401 Unauthorized' );
						exit();
					} else {
						cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
					}
				}

				switch ( $function ) {
					case 'users':
						break;
					case 'types':
						break;
					case 'comments':
						$stream->source( 'hidden' );

						$stream->set( 'create_access', -1 );
						$stream->set( 'replies', 0 );

						$this->showComments( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer );
						break;
					case 'activity':
						$stream->source( 'hidden' );

						$stream->set( 'create_access', -1 );
						$stream->set( 'comments', 0 );

						$this->showActivity( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer );
						break;
				}

				$_CB_framework->setMenuMeta();
				break;
			case 'tags':
				if ( ! $stream ) {
					if ( $raw ) {
						header( 'HTTP/1.0 401 Unauthorized' );
						exit();
					} else {
						cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' );
					}
				}

				switch ( $function ) {
					case 'show':
					default:
						if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof TagsInterface ) ) {
							$this->showTags( $id, $stream, ( $inline ? 2 : 0 ), $data, $user, $viewer );
						} else {
							$this->showTags( $id, $stream, ( $inline ? 2 : ( $raw ? 1 : 0 ) ), true, $user, $viewer );
						}
						break;
				}
				break;
			case 'cleanup':
				if ( ( ! $raw ) || ( $this->input( 'token', null, GetterInterface::STRING ) != md5( $_CB_framework->getCfg( 'secret' ) ) ) ) {
					header( 'HTTP/1.0 401 Unauthorized' );
					exit();
				}

				$this->cleanUp();
				break;
		}

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

			if ( ! $inline ) {
				$class					=	$this->params->get( 'general_class', null );

				$html					=	'<div id="cbActivity" class="cbActivity' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
										.		'<div id="cbActivityInner" class="cbActivityInner">'
										.			$html
										.		'</div>'
										.	'</div>';
			}

			echo $html;
		}
	}
コード例 #14
0
ファイル: cbantispam.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database;

		if ( ( ! Application::MyUser()->isGlobalModerator() ) || Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) {
			return null;
		}

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

		$blocksEnabled				=	( $this->params->get( 'general_block', 1 ) && $tab->params->get( 'tab_block', $this->tabBlock ) );
		$whitelistsEnabled			=	( $this->params->get( 'general_whitelist', 1 ) && $tab->params->get( 'tab_whitelist', $this->tabWhitelist ) );
		$attemptsEnabled			=	( $this->params->get( 'general_attempts', 1 ) && $tab->params->get( 'tab_attempts', $this->tabAttempts ) );
		$logsEnabled				=	( $this->params->get( 'general_log', 1 ) && $tab->params->get( 'tab_logs', $this->tabLogs ) );
		$return						=	null;

		if ( $blocksEnabled || $whitelistsEnabled || $attemptsEnabled || $logsEnabled ) {
			$tabPrefix				=	'tab_' . (int) $tab->get( 'tabid' ) . '_';
			$viewer					=	CBuser::getMyUserDataInstance();

			outputCbJs( 1 );
			outputCbTemplate( 1 );
			cbimport( 'cb.pagination' );

			cbantispamClass::getTemplate( 'tab' );

			$ipAddress				=	cbantispamClass::getUserIP( $user );
			$emailParts				=	explode( '@', $user->get( 'email' ) );
			$emailDomain			=	null;

			if ( count( $emailParts ) > 1 ) {
				$emailDomain		=	array_pop( $emailParts );
			}

			$blocks					=	null;

			if ( $blocksEnabled ) {
				cbantispamClass::getTemplate( 'blocks' );

				$blocksPrefix		=	$tabPrefix . 'blocks_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $blocksPrefix . 'limitstart{com_comprofiler}', $blocksPrefix . 'limitstart' );

				$query				=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_block' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$_CB_database->setQuery( $query );
				$total				=	$_CB_database->loadResult();

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

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

				$pageNav->setInputNamePrefix( $blocksPrefix );

				$query				=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_block' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$query				.=	"\n ORDER BY " . $_CB_database->NameQuote( 'id' ) . " ASC";
				if ( $tab->params->get( 'tab_paging', 1 ) ) {
					$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
				} else {
					$_CB_database->setQuery( $query );
				}
				$rows				=	$_CB_database->loadObjectList( null, 'cbantispamBlockTable', array( $_CB_database ) );

				$blocks				=	HTML_cbantispamBlocks::showBlocks( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$whitelists				=	null;

			if ( $whitelistsEnabled ) {
				cbantispamClass::getTemplate( 'whitelists' );

				$whitelistsPrefix	=	$tabPrefix . 'whitelists_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $whitelistsPrefix . 'limitstart{com_comprofiler}', $whitelistsPrefix . 'limitstart' );

				$query				=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_whitelist' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$_CB_database->setQuery( $query );
				$total				=	$_CB_database->loadResult();

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

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

				$pageNav->setInputNamePrefix( $whitelistsPrefix );

				$query				=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_whitelist' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$query				.=	"\n ORDER BY " . $_CB_database->NameQuote( 'id' ) . " ASC";
				if ( $tab->params->get( 'tab_paging', 1 ) ) {
					$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
				} else {
					$_CB_database->setQuery( $query );
				}
				$rows				=	$_CB_database->loadObjectList( null, 'cbantispamWhitelistTable', array( $_CB_database ) );

				$whitelists			=	HTML_cbantispamWhitelists::showWhitelists( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$attempts				=	null;

			if ( $attemptsEnabled ) {
				cbantispamClass::getTemplate( 'attempts' );

				$attemptsPrefix		=	$tabPrefix . 'attempts_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $attemptsPrefix . 'limitstart{com_comprofiler}', $attemptsPrefix . 'limitstart' );

				if ( $ipAddress ) {
					$query			=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_attempts' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'ip_address' ) . " = " . $_CB_database->Quote( $ipAddress );
					$_CB_database->setQuery( $query );
					$total			=	$_CB_database->loadResult();
				} else {
					$total			=	0;
				}

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

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

				$pageNav->setInputNamePrefix( $attemptsPrefix );

				if ( $ipAddress ) {
					$query			=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_attempts' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'ip_address' ) . " = " . $_CB_database->Quote( $ipAddress )
									.	"\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " DESC";
					if ( $tab->params->get( 'tab_paging', 1 ) ) {
						$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
					} else {
						$_CB_database->setQuery( $query );
					}
					$rows			=	$_CB_database->loadObjectList( null, 'cbantispamAttemptsTable', array( $_CB_database ) );
				} else {
					$rows			=	array();
				}

				$attempts			=	HTML_cbantispamAttempts::showAttempts( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$logs					=	null;

			if ( $logsEnabled ) {
				cbantispamClass::getTemplate( 'logs' );

				$logsPrefix			=	$tabPrefix . 'logs_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $logsPrefix . 'limitstart{com_comprofiler}', $logsPrefix . 'limitstart' );

				$query				=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_log' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );
				$_CB_database->setQuery( $query );
				$total				=	$_CB_database->loadResult();

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

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

				$pageNav->setInputNamePrefix( $logsPrefix );

				$query				=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_log' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
									.	"\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " DESC";
				if ( $tab->params->get( 'tab_paging', 1 ) ) {
					$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
				} else {
					$_CB_database->setQuery( $query );
				}
				$rows				=	$_CB_database->loadObjectList( null, 'cbantispamLogTable', array( $_CB_database ) );

				$logs				=	HTML_cbantispamLogs::showLogs( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

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

			$return					=	'<div id="cbAntiSpam" class="cbAntiSpam' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
									.		'<div id="cbAntiSpamInner" class="cbAntiSpamInner">'
									.			HTML_cbantispamTab::showTab( $blocks, $whitelists, $attempts, $logs, $viewer, $user, $tab, $this )
									.		'</div>'
									.	'</div>';
		}

		return $return;
	}
コード例 #15
0
ファイル: cbprivacy.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param string    $content
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param array     $postdata
	 * @param string    $output
	 * @param string    $formatting
	 * @param string    $reason
	 * @param bool      $tabbed
	 */
	public function tabEdit( &$content, &$tab, &$user, &$postdata, $output, $formatting, $reason, $tabbed )
	{
		if ( in_array( $reason, array( 'edit', 'register' ) ) ) {
			if ( $tab instanceof TabTable ) {
				$userId						=	(int) $user->get( 'id' );
				$tabId						=	(int) $tab->get( 'tabid' );

				if ( ( $reason != 'register' ) && ( ! Application::Cms()->getClientId() ) && ( ! cbprivacyClass::checkUserModerator() ) && ( ! cbprivacyClass::checkTabEditAccess( $tab ) ) ) {
					$content				=	' ';
				} else {
					if ( ! ( $tab->params instanceof ParamsInterface ) ) {
						$tab->params		=	new Registry( $tab->params );
					}

					$display				=	$tab->params->get( 'cbprivacy_display', '0' );

					if ( ( $reason == 'register' ) && ( ! $tab->params->get( 'cbprivacy_display_reg', '0' ) ) ) {
						$display			=	'0';
					}

					if ( ( $display == 1 ) || ( ( $display == 2 ) && cbprivacyClass::checkUserModerator() ) ) {
						$privacy			=	new cbprivacyPrivacyTable();

						$privacy->load( array( 'user_id' => (int) $userId, 'type' => 'profile', 'subtype' => 'tab', 'item' => (int) $tabId ) );

						$input				=	cbprivacyClass::getPrivacyInput( 'privacy_tab_' . $tabId, $privacy->get( 'rule', $tab->params->get( 'cbprivacy_default', '0' ) ) );
						$return				=	null;

						switch ( $formatting ) {
							case 'tabletrs':
								$return		.=	'<tr id="cbtp_' . (int) $tabId . '" class="cb_table_line cbft_privacy cbtt_select cb_table_line_field">'
											.		'<td class="fieldCell text-right" colspan="2" style="width: 100%;">'
											.			$input
											.		'</td>'
											.	'</tr>';
								break;
							default:
								$return		.=	'<div class="cbft_privacy cbtt_select form-group cb_form_line clearfix cbtwolinesfield" id="cbtp_' . (int) $tabId . '">'
											.		'<div class="cb_field col-sm-12">'
											.			'<div class="text-right">'
											.				$input
											.			'</div>'
											.		'</div>'
											.	'</div>';
								break;
						}

						$content			=	$return
											.	$content;
					}
				}
			}
		}
	}
コード例 #16
0
ファイル: music.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryItemTable[]      $rows
	 * @param cbPageNav                 $pageNav
	 * @param cbgalleryFolderTable|null $folder
	 * @param bool                      $searching
	 * @param UserTable                 $viewer
	 * @param UserTable                 $user
	 * @param TabTable                  $tab
	 * @param cbTabHandler              $plugin
	 * @return string
	 */
	static public function showMusic( $rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeDisplayMusic', array( &$rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) );

		/** @var Registry $params */
		$params							=	$tab->params;
		$allowDownload					=	$params->get( 'tab_music_download', 0 );
		$profileOwner					=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator					=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();
		$return							=	null;

		if ( $rows ) {
			$js							=	"var musicPlayer = null;"
										.	"$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).on( 'click', function( event ) {"
										.		"event.preventDefault();"
										.		"if ( $( this ).hasClass( 'musicItemPlaying' ) ) {"
										.			"if ( musicPlayer != null ) {"
										.				"musicPlayer.pause();"
										.			"}"
										.		"} else if ( $( this ).hasClass( 'musicItemPaused' ) ) {"
										.			"if ( musicPlayer != null ) {"
										.				"musicPlayer.play();"
										.			"}"
										.		"} else {"
										.			"$( '.musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "Container' ).hide();"
										.			"if ( musicPlayer != null ) {"
										.				"musicPlayer.remove();"
										.				"$( '.musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "Container > .mejs-offscreen' ).remove();"
										.			"}"
										.			"$( '#musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "' ).attr( 'src', $( this ).attr( 'href' ) ).attr( 'type', $( this ).data( 'mimetype' ) ).attr( 'controls', 'controls' ).attr( 'autoplay', 'autoplay' ).attr( 'preload', 'none' );"
										.			"musicPlayer = new MediaElementPlayer( '#musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "', {"
										.				"isVideo: false,"
										.				"success: function( media ) {"
										.					"media.addEventListener( 'play', function() {"
										.						"$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . ".active' ).removeClass( 'musicItemPaused' ).addClass( 'musicItemPlaying' ).find( '.fa' ).removeClass( 'fa-play' ).addClass( 'fa-pause' );"
										.					"}, false );"
										.					"media.addEventListener( 'pause', function() {"
										.						"$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . ".active' ).removeClass( 'musicItemPlaying' ).addClass( 'musicItemPaused' ).find( '.fa' ).removeClass( 'fa-pause' ).addClass( 'fa-play' );"
										.					"}, false );"
										.					"media.addEventListener( 'ended', function() {"
										.						"var music = $( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . ".active' );"
										.						"var repeat = $( '.musicItemRepeat" . (int) $tab->get( 'tabid' ) . "' );"
										.						"var shuffle = $( '.musicItemShuffle" . (int) $tab->get( 'tabid' ) . "' );"
										.						"var next = null;"
										.						"music.removeClass( 'musicItemPlayed' ).addClass( 'musicItemPlayed' );"
										.						"if ( repeat.hasClass( 'btn-primary' ) ) {"
										.							"if ( shuffle.hasClass( 'btn-primary' ) ) {"
										.								"next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.active)' );"
										.								"if ( next.length ) {"
										.								"next = next.eq( Math.floor( Math.random() * next.length ) );"
										.								"}"
										.							"} else {"
										.								"next = music.closest( 'tr' ).nextAll( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).first();"
										.								"if ( ! next.length ) {"
										.									"next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).first();"
										.								"}"
										.							"}"
										.						"} else {"
										.							"if ( shuffle.hasClass( 'btn-primary' ) ) {"
										.								"next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.musicItemPlayed,.active)' ).first();"
										.								"if ( next.length ) {"
										.									"next = next.eq( Math.floor( Math.random() * next.length ) );"
										.								"}"
										.							"} else {"
										.								"next = music.closest( 'tr' ).nextAll( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.musicItemPlayed)' ).first();"
										.								"if ( ! next.length ) {"
										.									"next = music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).filter( ':not(.musicItemPlayed)' ).first();"
										.								"}"
										.							"}"
										.							"if ( ! next.length ) {"
										.								"music.closest( 'tr' ).parent().children( 'tr' ).find( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).removeClass( 'musicItemPlayed' );"
										.							"}"
										.						"}"
										.						"if ( next.length ) {"
										.							"next.click();"
										.						"}"
										.					"}, false );"
										.				"}"
										.			"});"
										.			"$( '.musicItemsPlayer" . (int) $tab->get( 'tabid' ) . "Container' ).slideDown();"
										.			"$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).find( '.fa' ).removeClass( 'fa-play fa-pause' ).addClass( 'fa-play' );"
										.			"$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).removeClass( 'active musicItemPlaying musicItemPaused' );"
										.			"$( '.musicItemPlay" . (int) $tab->get( 'tabid' ) . "' ).closest( 'tr' ).removeClass( 'active' );"
										.			"$( this ).addClass( 'active musicItemPaused' );"
										.			"$( this ).closest( 'tr' ).addClass( 'active' );"
										.			"musicPlayer.play();"
										.		"}"
										.	"});"
										.	"$( '.musicItemToggle' ).on( 'click', function( event ) {"
										.		"event.preventDefault();"
										.		"if ( $( this ).hasClass( 'btn-primary' ) ) {"
										.			"$( this ).removeClass( 'btn-primary' ).addClass( 'btn-muted' );"
										.		"} else {"
										.			"$( this ).addClass( 'btn-primary' ).removeClass( 'btn-muted' );"
										.		"}"
										.	"});";

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

			$width						=	(int) $params->get( 'tab_music_width', 0 );

			$return						.=	'<div class="musicItemsPlayer' . (int) $tab->get( 'tabid' ) . 'Container text-center" style="display: none; margin: 0 auto 10px auto;' . ( $width ? ' max-width: ' . $width . 'px;' : null ) . '">'
										.		'<audio width="640" style="width: 100%;" id="musicItemsPlayer' . (int) $tab->get( 'tabid' ) . '" controls="controls" autoplay="autoplay" preload="none"></audio>'
										.	'</div>';
		}

		$return							.=	'<table class="musicItemsContainer table table-hover table-responsive">'
										.		'<thead>'
										.			'<tr>'
										.				'<th style="width: 1%;" class="text-left">#</th>'
										.				'<th class="text-left" colspan="' . ( $allowDownload ? 3 : 2 ) . '">';

		if ( $rows ) {
			$return						.=					'<button type="button" class="musicItemToggle musicItemRepeat' . (int) $tab->get( 'tabid' ) . ' btn btn-xs btn-primary" title="' . htmlspecialchars( CBTxt::T( 'Repeat' ) ) . '"><span class="fa fa-refresh"></span></button>'
										.					' <button type="button" class="musicItemToggle musicItemShuffle' . (int) $tab->get( 'tabid' ) . ' btn btn-xs btn-primary" title="' . htmlspecialchars( CBTxt::T( 'Shuffle' ) ) . '"><span class="fa fa-random"></span></button>';
		}

		$return							.=				'</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>';

		$i								=	0;

		if ( $rows ) foreach ( $rows as $row ) {
			$exists						=	$row->checkExists();
			$title						=	( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : $row->getFileName() );
			$item						=	$title;

			if ( $exists ) {
				if ( $row->getLinkDomain() ) {
					$showPath			=	htmlspecialchars( $row->getFilePath() );
					$downloadPath		=	$showPath;
				} else {
					$showPath			=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					$downloadPath		=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'download', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
				}

				$play					=	'<a href="' . $showPath . '" title="' . htmlspecialchars( CBTxt::T( 'Click to Play' ) ) . '" class="musicItemsPlay musicItemPlay' . (int) $tab->get( 'tabid' ) . ' btn btn-xs btn-default" data-mimetype="' . htmlspecialchars( $row->getMimeType() ) . '">'
										.		'<span class="fa fa-play"></span>'
										.	'</a>';

				$item					=	'<a href="' . $showPath . '" target="_blank">'
										.		$item
										.	'</a>';

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

				$download				=	'<button type="button" class="musicItemsDownload 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>' );
			}

			$return						.=			'<tr' . ( $exists ? ' class="musicItemPlayable"' : null ) . '>'
										.				'<td style="width: 1%;" class="text-center">' . ( $i + 1 ) . '</td>'
										.				'<td style="width: 1%;" class="text-center">' . $play . '</td>'
										.				( $allowDownload ? '<td style="width: 1%;" class="text-center">' . $download . '</td>' : null )
										.				'<td class="text-left">' . $item . '</td>'
										.				'<td style="width: 20%;" class="text-left hidden-xs">'
										.					'<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">'
										.						cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_music_items_time_display', 0 ), $params->get( 'tab_music_items_date_format', 'M j, Y' ), $plugin->params->get( 'tab_music_items_time_format', ' g:h A' ) )
										.					'</span>'
										.				'</td>';

			if ( $cbModerator || $profileOwner ) {
				$menuItems				=	'<ul class="galleryItemsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'
										.		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'edit', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

				if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'music_item_approval', 0 ) ) {
					if ( $cbModerator ) {
						$menuItems		.=		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
					}
				} elseif ( $row->get( 'published' ) > 0 ) {
					$menuItems			.=		'<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Music?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'unpublish', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
				} else {
					$menuItems			.=		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
				}

				$menuItems				.=		'<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Music?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'delete', 'type' => 'music', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'
										.	'</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="galleryItemsMenu 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>';

			$i++;
		} else {
			$return						.=			'<tr>'
										.				'<td colspan="' . ( $allowDownload ? 6 : 5 ) . '" class="text-left">';

			if ( $searching ) {
				$return					.=					CBTxt::T( 'No music search results found.' );
			} else {
				if ( $folder ) {
					$return				.=					CBTxt::T( 'This album has no music.' );
				} else {
					if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) {
						$return			.=					CBTxt::T( 'You have no music.' );
					} else {
						$return			.=					CBTxt::T( 'This user has no music.' );
					}
				}
			}

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

		$return							.=		'</tbody>';

		if ( $params->get( ( $folder ? 'tab_music_folder_items_paging' : 'tab_music_items_paging' ), 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return						.=		'<tfoot>'
										.			'<tr>'
										.				'<td colspan="' . ( $allowDownload ? 6 : 5 ) . '" class="galleryItemsPaging text-center">'
										.					$pageNav->getListLinks()
										.				'</td>'
										.			'</tr>'
										.		'</tfoot>';
		}

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

		return $return;
	}
コード例 #17
0
ファイル: folder.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryFolderTable $row
	 * @param string               $type
	 * @param UserTable            $viewer
	 * @param UserTable            $user
	 * @param TabTable             $tab
	 * @param cbTabHandler         $plugin
	 * @return string
	 */
	static public function showFolder( $row, $type, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeDisplayFolder', array( &$row, $type, $viewer, $user, $tab, $plugin ) );

		/** @var Registry $params */
		$params							=	$tab->params;

		switch( $type ) {
			case 'photos':
				$galleryType			=	CBTxt::T( 'Photos' );
				break;
			case 'files':
				$galleryType			=	CBTxt::T( 'Files' );
				break;
			case 'videos':
				$galleryType			=	CBTxt::T( 'Videos' );
				break;
			case 'music':
				$galleryType			=	CBTxt::T( 'Music' );
				break;
			default:
				$galleryType			=	CBTxt::T( 'Items' );
				break;
		}

		switch( $type ) {
			case 'photos':
			case 'videos':
			case 'music':
				$typeTranslated			=	CBTxt::T( 'Album' );
				break;
			default:
				$typeTranslated			=	CBTxt::T( 'Folder' );
				break;
		}

		$profileOwner					=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator					=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();
		$date							=	cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_' . $type . '_folder_items_time_display', 0 ), $params->get( 'tab_' . $type . '_folder_items_date_format', 'F j, Y' ), $params->get( 'tab_' . $type . '_folder_items_time_format', ' g:h A' ) );

		$return							=	'<div class="galleryFolderTitle page-header clearfix">'
										.		'<h3 class="row">'
										.			'<div class="col-sm-8 text-left">'
										.				( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) . ( $row->get( 'id' ) !== 0 ? '<div class="small" title="' . htmlspecialchars( $row->get( 'date' ) ) . '">' . $date . '</div>' : null ) : $date )
										.			'</div>'
										.			'<div class="col-sm-4 text-right">'
										.				'<small>'
										.					'<a href="' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, (int) $tab->get( 'tabid' ) ) . '">'
										.						CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'profile', 0, true )
										.					'</a>'
										.				'</small>';

		if ( ( $row->get( 'id' ) !== 0 ) && ( $cbModerator || $profileOwner ) ) {
			$menuItems					=	'<ul class="galleryFolderMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'
										.		'<li class="galleryFolderMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

			if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( $type . '_folder_approval', 0 ) ) {
				if ( $cbModerator ) {
					$menuItems			.=		'<li class="galleryFolderMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
				}
			} elseif ( $row->get( 'published' ) > 0 ) {
				$menuItems				.=		'<li class="galleryFolderMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_UNPUBLISH_TYPE', 'Are you sure you want to unpublish this [type]?', array( '[type]' => $typeTranslated ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'unpublish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
			} else {
				$menuItems				.=		'<li class="galleryFolderMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
			}

			$menuItems					.=		'<li class="galleryFolderMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_DELETE_TYPE', 'Are you sure you want to delete this [folder_type] and all its [item_type]?', array( '[folder_type]' => $typeTranslated, '[item_type]' => $galleryType ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'delete', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'
										.	'</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="folderMenu">'
										.					'<div class="galleryFolderMenu 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>'
										.		'</h3>'
										.	'</div>'
										.	( $row->get( 'description' ) ? '<div class="galleryFolderDescription well well-sm">' . htmlspecialchars( $row->get( 'description' ) ) . '</div>' : null );

		return $return;
	}
コード例 #18
0
ファイル: photos.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryItemTable[]      $rows
	 * @param cbPageNav                 $pageNav
	 * @param cbgalleryFolderTable|null $folder
	 * @param bool                      $searching
	 * @param UserTable                 $viewer
	 * @param UserTable                 $user
	 * @param TabTable                  $tab
	 * @param cbTabHandler              $plugin
	 * @return string
	 */
	static public function showPhotos( $rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeDisplayPhotos', array( &$rows, $pageNav, $folder, $searching, $viewer, $user, $tab, $plugin ) );

		/** @var Registry $params */
		$params							=	$tab->params;
		$allowDownload					=	$params->get( 'tab_photos_download', 0 );
		$profileOwner					=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator					=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();

		if ( $rows ) {
			static $JS_LOADED			=	0;

			if ( ! $JS_LOADED++ ) {
				$js						=	"$( document ).on( 'click', '.galleryImageScrollLeftIcon', function() {"
										.		"var previous = $( this ).data( 'previous-photo' );"
										.		"if ( previous ) {"
										.			"$( previous ).find( '.galleryImageItem' ).click();"
										.		"}"
										.	"});"
										.	"$( document ).on( 'click', '.galleryImageScrollRightIcon', function() {"
										.		"var next = $( this ).data( 'next-photo' );"
										.		"if ( next ) {"
										.			"$( next ).find( '.galleryImageItem' ).click();"
										.		"}"
										.	"});";

				$_CB_framework->outputCbJQuery( $js );
			}
		}

		$return							=	'<div class="photosItemsContainer">';

		$i								=	0;

		if ( $rows ) foreach ( $rows as $row ) {
			$return						.=		'<div class="galleryContainer galleryContainer' . (int) $tab->get( 'tabid' ) . '_' . $i . ' img-thumbnail">';

			if ( $cbModerator || $profileOwner ) {
				$menuItems				=	'<ul class="galleryItemsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'
										.		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'edit', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

				if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'photos_item_approval', 0 ) ) {
					if ( $cbModerator ) {
						$menuItems		.=		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
					}
				} elseif ( $row->get( 'published' ) > 0 ) {
					$menuItems			.=		'<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Photo?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'unpublish', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
				} else {
					$menuItems			.=		'<li class="galleryItemsMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'publish', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
				}

				$menuItems				.=		'<li class="galleryItemsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Photo?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'delete', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'
										.	'</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="galleryContainerMenu">'
										.				'<div class="galleryItemsMenu btn-group">'
										.					'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
										.				'</div>'
										.			'</div>';
			}

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

			if ( $row->checkExists() ) {
				if ( $row->getLinkDomain() ) {
					$showPath			=	htmlspecialchars( $row->getFilePath() );
					$previewPath		=	$showPath;
					$downloadPath		=	$showPath;
				} else {
					$showPath			=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'show', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					$previewPath		=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'preview', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
					$downloadPath		=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'items', 'func' => 'download', 'type' => 'photos', 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'v' => uniqid() ), 'raw', 0, true );
				}

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

				if ( $pageNav->total > 1 ) {
					$image				.=		'<div class="galleryImageScrollLeft">'
										.			'<table>'
										.				'<tr>'
										.					'<td>'
										.						'<span class="galleryImageScrollLeftIcon fa fa-chevron-left" data-previous-photo=".galleryContainer' . (int) $tab->get( 'tabid' ) . '_' . ( $i == 0 ? ( count( $rows ) - 1 ) : ( $i - 1 ) ) . '"></span>'
										.					'</td>'
										.				'</tr>'
										.			'</table>'
										.		'</div>';
				}

				$image					.=		'<div style="background-image: url(' . $showPath . ')" class="galleryImage"></div>'
										.		'<div class="galleryImageInfo">'
										.			'<div class="galleryImageInfoRow">'
										.				'<div class="galleryImageInfoTitle col-sm-8 text-left"><strong>' . $title . '</strong></div>'
										.				'<div class="galleryImageInfoOriginal col-sm-4 text-right">'
										.					'<a href="' . $showPath . '" target="_blank">'
										.						CBTxt::T( 'Original' )
										.					'</a>'
										.				'</div>'
										.			'</div>';

				if ( $row->get( 'description' ) || $allowDownload ) {
					$image				.=			'<div class="galleryImageInfoRow">'
										.				'<div class="galleryImageInfoDescription col-sm-8 text-left">' . htmlspecialchars( $row->get( 'description' ) ) . '</div>'
										.				'<div class="galleryImageInfoDownload col-sm-4 text-right">';

					if ( $allowDownload ) {
						$image			.=					'<a href="' . $downloadPath . '" target="_blank">'
										.						CBTxt::T( 'Download' )
										.					'</a>';
					}

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

				$image					.=		'</div>';

				if ( $pageNav->total > 1 ) {
					$image				.=		'<div class="galleryImageScrollRight">'
										.			'<table>'
										.				'<tr>'
										.					'<td>'
										.						'<span class="galleryImageScrollRightIcon fa fa-chevron-right" data-next-photo=".galleryContainer' . (int) $tab->get( 'tabid' ) . '_' . ( 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="galleryImageItem" data-cbtooltip-modal="true" data-cbtooltip-open-solo="document" data-cbtooltip-classes="galleryImageModal"' );
				$logo					=	cbTooltip( 1, $image, null, array( '80%', '80%' ), null, '<div style="background-image: url(' . $previewPath . ')" class="galleryContainerLogo"></div>', 'javascript: void(0);', 'class="galleryImageLogo" data-cbtooltip-modal="true" data-cbtooltip-open-solo="document" data-cbtooltip-classes="galleryImageModal"' );
			}

			$width						=	(int) $params->get( 'tab_photos_width', 200 );

			if ( ! $width ) {
				$width					=	200;
			} elseif ( $width < 100 ) {
				$width					=	100;
			}

			$return						.=			'<div class="galleryContainerInner" style="height: ' . $width . 'px; width: ' . $width . 'px;">'
										.				'<div class="galleryContainerTop" style="height: ' . ( $width - 40 ) . 'px;">'
										.					$logo
										.				'</div>'
										.				'<div class="galleryContainerBottom" style="height: 40px;">'
										.					'<div class="galleryContainerContent">'
										.						'<div class="galleryContainerContentRow text-nowrap text-overflow small">'
										.							'<strong>'
										.								$item
										.							'</strong>'
										.						'</div>'
										.						'<div class="galleryContainerContentRow text-nowrap text-overflow small">'
										.							'<span title="' . htmlspecialchars( $row->get( 'date' ) ) . '">'
										.								cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_photos_items_time_display', 0 ), $params->get( 'tab_photos_items_date_format', 'M j, Y' ), $params->get( 'tab_photos_items_time_format', ' g:h A' ) )
										.							'</span>'
										.							( $row->get( 'description' ) ? '<div class="galleryContainerDescription">' . cbTooltip( 1, $row->get( 'description' ), $title, 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null )
										.						'</div>'
										.					'</div>'
										.				'</div>'
										.			'</div>'
										.		'</div>';

			$i++;
		} else {
			$return						.=		'<div>';

			if ( $searching ) {
				$return					.=			CBTxt::T( 'No photos search results found.' );
			} else {
				if ( $folder ) {
					$return				.=			CBTxt::T( 'This album has no photos.' );
				} else {
					if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) {
						$return			.=			CBTxt::T( 'You have no photos.' );
					} else {
						$return			.=			CBTxt::T( 'This user has no photos.' );
					}
				}
			}

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

		if ( $params->get( ( $folder ? 'tab_photos_folder_items_paging' : 'tab_photos_items_paging' ), 1 ) && ( $pageNav->total > $pageNav->limit ) ) {
			$return						.=		'<div class="galleryItemsPaging text-center">'
										.			$pageNav->getListLinks()
										.		'</div>';
		}

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

		return $return;
	}
コード例 #19
0
	/**
	 * @param cbgalleryFolderTable $row
	 * @param array                $input
	 * @param string               $type
	 * @param TabTable             $tab
	 * @param UserTable            $user
	 * @param UserTable            $viewer
	 * @param cbPluginHandler      $plugin
	 */
	static public function showFolderEdit( $row, $input, $type, $tab, $user, $viewer, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeFolderEdit', array( &$row, &$input, $type, $tab, $user, $viewer, $plugin ) );

		cbValidator::loadValidation();

		switch( $type ) {
			case 'photos':
				$galleryType		=	CBTxt::T( 'Photos' );
				break;
			case 'files':
				$galleryType		=	CBTxt::T( 'Files' );
				break;
			case 'videos':
				$galleryType		=	CBTxt::T( 'Videos' );
				break;
			case 'music':
				$galleryType		=	CBTxt::T( 'Music' );
				break;
			default:
				$galleryType		=	CBTxt::T( 'Items' );
				break;
		}

		switch( $type ) {
			case 'photos':
			case 'videos':
			case 'music':
				$typeTranslated		=	CBTxt::T( 'Album' );
				break;
			default:
				$typeTranslated		=	CBTxt::T( 'Folder' );
				break;
		}

		$cbModerator				=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();
		$pageTitle					=	( $row->get( 'id' ) ? CBTxt::T( 'EDIT_FOLDER_TYPE', 'Edit [type]', array( '[type]' => $typeTranslated ) ) : CBTxt::T( 'NEW_FOLDER_TYPE', 'New [type]', array( '[type]' => $typeTranslated ) ) );

		if ( $plugin->input( 'folder', false, GetterInterface::BOOLEAN ) ) {
			$returnUrl				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) );
			$formUrl				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'save', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => true ) );
		} else {
			$returnUrl				=	$_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, $tab->get( 'tabid' ) );
			$formUrl				=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'save', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) );
		}

		$_CB_framework->setPageTitle( $pageTitle );
		$_CB_framework->appendPathWay( htmlspecialchars( $galleryType ), $returnUrl );
		$_CB_framework->appendPathWay( htmlspecialchars( $pageTitle ), $_CB_framework->pluginClassUrl( $plugin->element, true, ( $row->get( 'id' ) ? array( 'action' => 'folders', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) : array( 'action' => 'folders', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) ) );

		initToolTip();

		$return						=	'<div class="' . htmlspecialchars( $type ) . 'FolderEdit">'
									.		'<form action="' . $formUrl . '" method="post" enctype="multipart/form-data" name="' . htmlspecialchars( $type ) . 'FolderForm" id="' . htmlspecialchars( $type ) . 'FolderForm" class="cb_form ' . htmlspecialchars( $type ) . 'FolderForm galleryFolderForm form-auto cbValidation">'
									.			( $pageTitle ? '<div class="galleryFolderTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null );

		if ( $cbModerator || ( ! $plugin->params->get( $type . '_folder_approval', 0 ) ) || ( $row->get( 'id' ) && ( $row->get( 'published' ) != -1 ) ) ) {
			$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( 1, 0, null, CBTxt::T( 'FOLDER_PUBLISHED_DESCRIPTION', 'Select publish status of the [type]. If unpublished the [type] will not be visible to the public.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';
		}

		$return						.=			'<div class="cbft_text cbtt_input form-group cb_form_line clearfix">'
									.				'<label for="title" class="col-sm-3 control-label">' . CBTxt::T( 'Title' ) . '</label>'
									.				'<div class="cb_field col-sm-9">'
									.					$input['title']
									.					getFieldIcons( 1, 0, null, CBTxt::T( 'FOLDER_TITLE_DESCRIPTION', 'Optionally input a title. If no title is provided the date will be displayed as the title.', array( '[type]' => $typeTranslated ) ) )
									.				'</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( 1, 0, null, CBTxt::T( 'FOLDER_DESCRIPTION_DESCRIPTION', 'Optionally input a description.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';

		if ( $cbModerator ) {
			$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( 1, 1, null, CBTxt::T( 'FOLDER_OWNER_DESCRIPTION', 'Input owner as single integer user_id.', array( '[type]' => $typeTranslated ) ) )
									.				'</div>'
									.			'</div>';
		}

		if ( $plugin->params->get( $type . '_folder_captcha', 0 ) && ( ! $cbModerator ) ) {
			$_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( 1, 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_FOLDER_TYPE', 'Update [type]', array( '[type]' => $typeTranslated ) ) : CBTxt::T( 'CREATE_FOLDER_TYPE', 'Create [type]', array( '[type]' => $typeTranslated ) ) ) ) . '" class="galleryButton galleryButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' />&nbsp;'
									.					' <input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="galleryButton galleryButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '\' ) ) { location.href = \'' . $returnUrl . '\'; }" />'
									.				'</div>'
									.			'</div>'
									.			cbGetSpoofInputTag( 'plugin' )
									.		'</form>'
									.	'</div>';

		echo $return;
	}
コード例 #20
0
	/**
	 * Deletes a folder
	 *
	 * @param int       $id
	 * @param string    $type
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param UserTable $viewer
	 */
	private function deleteFolder( $id, $type, $tab, $user, $viewer )
	{
		global $_CB_framework;

		$row						=	new cbgalleryFolderTable();

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

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

		if ( ( ! $row->get( 'id' ) ) || ( $row->get( 'type' ) != $type ) || ( ( $viewer->get( 'id' ) != $row->get( 'user_id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ) ) {
			cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' );
		}

		switch( $type ) {
			case 'photos':
			case 'videos':
			case 'music':
				$typeTranslated		=	CBTxt::T( 'Album' );
				break;
			default:
				$typeTranslated		=	CBTxt::T( 'Folder' );
				break;
		}

		if ( ! $row->canDelete() ) {
			cbRedirect( $profileUrl, CBTxt::T( 'FOLDER_FAILED_TO_DELETE', '[type] failed to delete! Error: [error]', array( '[type]' => $typeTranslated, '[error]' => $row->getError() ) ), 'error' );
		}

		if ( ! $row->delete() ) {
			cbRedirect( $profileUrl, CBTxt::T( 'FOLDER_FAILED_TO_DELETE', '[type] failed to delete! Error: [error]', array( '[type]' => $typeTranslated, '[error]' => $row->getError() ) ), 'error' );
		}

		cbRedirect( $profileUrl, CBTxt::T( 'FOLDER_DELETED_SUCCESSFULLY', '[type] deleted successfully!', array( '[type]' => $typeTranslated ) ) );
	}
コード例 #21
0
ファイル: cbgallery.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param string    $type
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param UserTable $viewer
	 * @param bool|int  $start
	 * @return null|string
	 */
	private function getItems( $type, $tab, $user, $viewer, $start = false )
	{
		global $_CB_framework, $_CB_database, $_PLUGINS;

		/** @var Registry $params */
		$params							=	$tab->params;
		$tabPrefix						=	'tab_' . (int) $tab->get( 'tabid' ) . '_';
		$publishedOnly					=	( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) );
		$input							=	array();

		// Items:
		$typePrefix						=	$tabPrefix . $type . '_items_';
		$limit							=	(int) $params->get( 'tab_' . $type . '_items_limit', 15 );
		$limitstart						=	( $start !== false ? (int) $start : $_CB_framework->getUserStateFromRequest( $typePrefix . 'limitstart{com_comprofiler}', $typePrefix . 'limitstart' ) );
		$search							=	$_CB_framework->getUserStateFromRequest( $typePrefix . 'search{com_comprofiler}', $typePrefix . 'search' );
		$where							=	null;

		if ( $search && $params->get( 'tab_' . $type . '_items_search', 1 ) ) {
			$where						.=	"\n AND ( " . $_CB_database->NameQuote( 'value' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
										.	" OR " . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
										.	" OR " . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

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

		$query							=	'SELECT COUNT(*)'
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' )
										.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type )
										.	"\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
										.	"\n AND " . $_CB_database->NameQuote( 'folder' ) . " = 0"
										.	( $publishedOnly ? "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" : null )
										.	$where;
		$_CB_database->setQuery( $query );
		$total							=	(int) $_CB_database->loadResult();

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

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

		$itemsPageNav->setInputNamePrefix( $typePrefix );

		$orderBy						=	$params->get( 'tab_' . $type . '_items_orderby', 'date_desc' );

		if ( ! $orderBy ) {
			$orderBy					=	'date_desc';
		}

		$orderBy						=	explode( '_', $orderBy );

		$query							=	'SELECT *'
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' )
										.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type )
										.	"\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
										.	"\n AND " . $_CB_database->NameQuote( 'folder' ) . " = 0"
										.	( $publishedOnly ? "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" : null )
										.	$where
										.	"\n ORDER BY " . $_CB_database->NameQuote( $orderBy[0] ) . " " . strtoupper( $orderBy[1] );
		if ( $params->get( 'tab_' . $type . '_items_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $itemsPageNav->limitstart, $itemsPageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$items							=	$_CB_database->loadObjectList( null, 'cbgalleryItemTable', array( $_CB_database ) );
		$itemsCount						=	count( $items );

		$_PLUGINS->trigger( 'gallery_onLoadItems', array( &$items, $user ) );

		if ( $itemsCount && ( ! count( $items ) ) ) {
			return $this->getItems( $type, $tab, $user, $viewer, ( $limitstart + $limit ) );
		}

		switch( $type ) {
			case 'photos':
				$placeholder			=	CBTxt::T( 'Search Photos...' );
				break;
			case 'files':
				$placeholder			=	CBTxt::T( 'Search Files...' );
				break;
			case 'videos':
				$placeholder			=	CBTxt::T( 'Search Videos...' );
				break;
			case 'music':
				$placeholder			=	CBTxt::T( 'Search Music...' );
				break;
			default:
				$placeholder			=	CBTxt::T( 'Search...' );
				break;
		}

		$input['search_items']			=	'<input type="text" name="' . htmlspecialchars( $typePrefix . 'search' ) . '" value="' . htmlspecialchars( $search ) . '" onchange="document.' . htmlspecialchars( $type ) . 'ItemsForm.submit();" placeholder="' . htmlspecialchars( $placeholder ) . '" class="form-control" />';

		return array( $items, $itemsPageNav, $itemsSearching, $input );
	}
コード例 #22
0
ファイル: folders.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryFolderTable[] $rows
	 * @param cbPageNav              $pageNav
	 * @param int                    $uncategorized
	 * @param string                 $type
	 * @param UserTable              $viewer
	 * @param UserTable              $user
	 * @param TabTable               $tab
	 * @param cbTabHandler           $plugin
	 * @return string
	 */
	static public function showFolders( $rows, $pageNav, $uncategorized, $type, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeDisplayFolders', array( &$rows, $pageNav, $uncategorized, $type, $viewer, $user, $tab, $plugin ) );

		switch( $type ) {
			case 'photos':
				$galleryType			=	CBTxt::T( 'Photos' );
				break;
			case 'files':
				$galleryType			=	CBTxt::T( 'Files' );
				break;
			case 'videos':
				$galleryType			=	CBTxt::T( 'Videos' );
				break;
			case 'music':
				$galleryType			=	CBTxt::T( 'Music' );
				break;
			default:
				$galleryType			=	CBTxt::T( 'Items' );
				break;
		}

		switch( $type ) {
			case 'photos':
			case 'videos':
			case 'music':
				$typeTranslated			=	CBTxt::T( 'Album' );
				break;
			default:
				$typeTranslated			=	CBTxt::T( 'Folder' );
				break;
		}

		/** @var Registry $params */
		$params							=	$tab->params;
		$profileOwner					=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator					=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();

		$return							=			'<div class="' . htmlspecialchars( $type ) . 'FoldersContainer" style="margin-bottom: 10px;">';

		if ( $uncategorized ) {
			switch( $type ) {
				case 'photos':
					$count				=	CBTxt::T( 'FOLDER_PHOTOS_COUNT', '%%COUNT%% Photo|%%COUNT%% Photos', array( '%%COUNT%%' => $uncategorized ) );
					break;
				case 'files':
					$count				=	CBTxt::T( 'FOLDER_FILES_COUNT', '%%COUNT%% File|%%COUNT%% Files', array( '%%COUNT%%' => $uncategorized ) );
					break;
				case 'videos':
					$count				=	CBTxt::T( 'FOLDER_VIDEOS_COUNT', '%%COUNT%% Video|%%COUNT%% Videos', array( '%%COUNT%%' => $uncategorized ) );
					break;
				case 'music':
					$count				=	CBTxt::T( 'FOLDER_MUSIC_COUNT', '%%COUNT%% Music|%%COUNT%% Music', array( '%%COUNT%%' => $uncategorized ) );
					break;
				default:
					$count				=	CBTxt::T( 'FOLDER_ITEM_COUNT', '%%COUNT%% Item|%%COUNT%% Items', array( '%%COUNT%%' => $uncategorized ) );
					break;
			}

			$return						.=		'<div class="galleryContainer img-thumbnail">'
										.			'<div class="galleryContainerInner" style="height: 100px; width: 100px;">'
										.				'<div class="galleryContainerTop" style="height: 60px">'
										.					'<div class="galleryContainerContent">'
										.						( $uncategorized ? '<span class="galleryFoldersNotEmpty fa fa-folder-open-o"></span>' : '<span class="galleryFoldersEmpty fa fa-folder-o"></span>' )
										.					'</div>'
										.				'</div>'
										.				'<div class="galleryContainerBottom" style="height: 40px">'
										.					'<div class="galleryContainerContent">'
										.						'<div class="galleryContainerContentRow text-nowrap text-overflow small">'
										.							'<strong>'
										.								'<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => 0, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '">'
										.									CBTxt::T( 'Uncategorized' )
										.								'</a>'
										.							'</strong>'
										.						'</div>'
										.						'<div class="galleryContainerContentRow text-nowrap text-overflow small">' . $count . '</div>'
										.					'</div>'
										.				'</div>'
										.			'</div>'
										.		'</div>';
		}

		if ( $rows ) foreach ( $rows as $row ) {
			$return						.=		'<div class="galleryContainer img-thumbnail">';

			if ( $cbModerator || $profileOwner ) {
				$menuItems				=	'<ul class="galleryFoldersMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'
										.		'<li class="galleryFoldersMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'edit', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>';

				if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( $type . '_folder_approval', 0 ) ) {
					if ( $cbModerator ) {
						$menuItems		.=		'<li class="galleryFoldersMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>';
					}
				} elseif ( $row->get( 'published' ) > 0 ) {
					$menuItems			.=		'<li class="galleryFoldersMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_UNPUBLISH_TYPE', 'Are you sure you want to unpublish this [type]?', array( '[type]' => $typeTranslated ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'unpublish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>';
				} else {
					$menuItems			.=		'<li class="galleryFoldersMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'publish', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>';
				}

				$menuItems				.=		'<li class="galleryFoldersMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'FOLDER_DELETE_TYPE', 'Are you sure you want to delete this [folder_type] and all its [item_type]?', array( '[folder_type]' => $typeTranslated, '[item_type]' => $galleryType ) ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'delete', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'
										.	'</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="galleryContainerMenu">'
										.				'<div class="galleryFoldersMenu btn-group">'
										.					'<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
										.				'</div>'
										.			'</div>';
			}

			$title						=	( $row->get( 'title' ) ? htmlspecialchars( $row->get( 'title' ) ) : cbFormatDate( $row->get( 'date' ), true, (int) $params->get( 'tab_' . $type . '_folders_time_display', 0 ), $params->get( 'tab_' . $type . '_folders_date_format', 'M j, Y' ), $params->get( 'tab_' . $type . '_folders_time_format', ' g:h A' ) ) );

			switch( $type ) {
				case 'photos':
					$count				=	CBTxt::T( 'FOLDER_PHOTOS_COUNT', '%%COUNT%% Photo|%%COUNT%% Photos', array( '%%COUNT%%' => $row->countItems() ) );
					break;
				case 'files':
					$count				=	CBTxt::T( 'FOLDER_FILES_COUNT', '%%COUNT%% File|%%COUNT%% Files', array( '%%COUNT%%' => $row->countItems() ) );
					break;
				case 'videos':
					$count				=	CBTxt::T( 'FOLDER_VIDEOS_COUNT', '%%COUNT%% Video|%%COUNT%% Video', array( '%%COUNT%%' => $row->countItems() ) );
					break;
				case 'music':
					$count				=	CBTxt::T( 'FOLDER_MUSIC_COUNT', '%%COUNT%% Music|%%COUNT%% Music', array( '%%COUNT%%' => $row->countItems() ) );
					break;
				default:
					$count				=	CBTxt::T( 'FOLDER_ITEM_COUNT', '%%COUNT%% Item|%%COUNT%% Items', array( '%%COUNT%%' => $row->countItems() ) );
					break;
			}

			$return						.=			'<div class="galleryContainerInner" style="height: 100px; width: 100px;">'
										.				'<div class="galleryContainerTop" style="height: 60px">'
										.					'<div class="galleryContainerContent">'
										.						( $row->countItems() ? '<span class="galleryFoldersNotEmpty fa fa-folder-open-o"></span>' : '<span class="galleryFoldersEmpty fa fa-folder-o"></span>' )
										.					'</div>'
										.				'</div>'
										.				'<div class="galleryContainerBottom" style="height: 40px">'
										.					'<div class="galleryContainerContent">'
										.						'<div class="galleryContainerContentRow text-nowrap text-overflow small">'
										.							'<strong>'
										.								'<a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '" title="' . htmlspecialchars( $row->get( 'date' ) ) . '">'
										.									$title
										.								'</a>'
										.							'</strong>'
										.						'</div>'
										.						'<div class="galleryContainerContentRow text-nowrap text-overflow small">'
										.							$count
										.							( $row->get( 'description' ) ? '<div class="galleryContainerDescription">' . cbTooltip( 1, $row->get( 'description' ), $title, 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null )
										.						'</div>'
										.					'</div>'
										.				'</div>'
										.			'</div>'
										.		'</div>';
		}

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

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

		return $return;
	}
コード例 #23
0
ファイル: logs.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbantispamLogTable[] $rows
	 * @param cbPageNav            $pageNav
	 * @param UserTable            $viewer
	 * @param UserTable            $user
	 * @param TabTable             $tab
	 * @param cbTabHandler         $plugin
	 * @return string
	 */
	static public function showLogs( $rows, $pageNav, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework;

		/** @var Registry $params */
		$params						=	$tab->params;

		$return						=	'<div class="logsTab">'
									.		'<form action="' . $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, (int) $tab->get( 'tabid' ) ) . '" method="post" name="logsForm" id="logsForm" class="logsForm">'
									.			'<table class="logsContainer table table-hover table-responsive">'
									.				'<thead>'
									.					'<tr>'
									.						'<th class="text-left">' . CBTxt::T( 'IP Address' ) . '</th>'
									.						'<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Date' ) . '</th>'
									.						'<th style="width: 10%;" class="text-center hidden-xs">' . CBTxt::T( 'Count' ) . '</th>'
									.						'<th style="width: 1%;" class="text-right">&nbsp;</th>'
									.					'</tr>'
									.				'</thead>'
									.				'<tbody>';

		if ( $rows ) foreach ( $rows as $row ) {
			$return					.=					'<tr>'
									.						'<td class="text-left">' . $row->get( 'ip_address' ) . '</td>'
									.						'<td style="width: 25%;" class="text-left hidden-xs">' . cbFormatDate( $row->get( 'date' ), false ) . '</td>'
									.						'<td style="width: 10%;" class="text-center hidden-xs">' . $row->get( 'count' ) . '</td>'
									.						'<td style="width: 1%;" class="text-right">'
									.							'<a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Log?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'log', 'func' => 'delete', 'id' => (int) $row->get( 'id' ), 'usr' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\'; }" title="' . htmlspecialchars( CBTxt::T( 'Delete' ) ) . '"><span class="fa fa-trash-o"></span></a>'
									.						'</td>'
									.					'</tr>';
		} else {
			$return					.=					'<tr>'
									.						'<td colspan="3" class="text-left">';

			if ( $viewer->get( 'id' ) == $user->get( 'id' ) ) {
				$return				.=							CBTxt::T( 'You have no logs.' );
			} else {
				$return				.=							CBTxt::T( 'This user has no logs.' );
			}

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

		$return						.=				'</tbody>';

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

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

		return $return;
	}
コード例 #24
0
ファイル: items.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbgalleryFolderTable|cbgalleryFolderTable[] $folders        cbgalleryFolderTable: we're IN a folder; cbgalleryFolderTable[]: we're on profile
	 * @param null|cbPageNav                              $foldersPageNav Null: we're IN a folder; cbPageNav: we're on profile
	 * @param bool                                        $foldersSearching
	 * @param cbgalleryItemTable[]                        $items
	 * @param cbPageNav                                   $itemsPageNav
	 * @param bool                                        $itemsSearching
	 * @param string                                      $type
	 * @param array                                       $input
	 * @param UserTable                                   $viewer
	 * @param UserTable                                   $user
	 * @param TabTable                                    $tab
	 * @param cbTabHandler                                $plugin
	 * @return string
	 */
	static public function showItems( $folders, $foldersPageNav, $foldersSearching, $items, $itemsPageNav, $itemsSearching, $type, $input, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_PLUGINS;

		$_PLUGINS->trigger( 'gallery_onBeforeDisplayItems', array( &$folders, $foldersPageNav, $foldersSearching, &$items, $itemsPageNav, $itemsSearching, $type, &$input, $viewer, $user, $tab, $plugin ) );

		switch( $type ) {
			case 'photos':
				$typeTranslated				=	CBTxt::T( 'Photo' );
				break;
			case 'files':
				$typeTranslated				=	CBTxt::T( 'File' );
				break;
			case 'videos':
				$typeTranslated				=	CBTxt::T( 'Video' );
				break;
			case 'music':
				$typeTranslated				=	CBTxt::T( 'Music' );
				break;
			default:
				$typeTranslated				=	CBTxt::T( 'Item' );
				break;
		}

		switch( $type ) {
			case 'photos':
			case 'videos':
			case 'music':
				$folderType					=	CBTxt::T( 'Album' );
				break;
			default:
				$folderType					=	CBTxt::T( 'Folder' );
				break;
		}

		/** @var Registry $params */
		$params								=	$tab->params;
		$folder								=	( is_object( $folders ) ? $folders : null );
		$allowFolders						=	( $params->get( 'tab_' . $type . '_folders', 1 ) && ( ! $folder ) );
		$showFolders						=	( $allowFolders && $folders );
		$showItems							=	( ( ! $allowFolders ) || ( $allowFolders && $params->get( 'tab_' . $type . '_uncategorized', 1 ) ) );
		$canSearchFolders					=	( $showFolders ? ( $params->get( 'tab_' . $type . '_folders_search', 1 ) && ( $foldersSearching || $foldersPageNav->total ) ) : false );
		$canSearchItems						=	( $showItems ? ( $params->get( ( $folder ? 'tab_' . $type . '_folder_items_search' : 'tab_' . $type . '_items_search' ), 1 ) && ( $itemsSearching || $itemsPageNav->total ) ) : false );
		$profileOwner						=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator						=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();
		$canCreateFolders					=	( ( $profileOwner || $cbModerator ) && $allowFolders ? cbgalleryClass::canUserCreate( $viewer, $type, true ) : false );
		$canCreateItems						=	( $profileOwner || $cbModerator ? cbgalleryClass::canUserCreate( $viewer, $type, false ) : false );

		if ( $folder ) {
			$formUrl						=	$_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $folders->get( 'id' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) );
		} else {
			$formUrl						=	$_CB_framework->userProfileUrl( (int) $user->get( 'id' ), true, (int) $tab->get( 'tabid' ) );
		}

		$return								=	'<div class="' . htmlspecialchars( $type ) . 'ItemsTab">'
											.		'<form action="' . $formUrl . '" method="post" name="' . htmlspecialchars( $type ) . 'ItemsForm" id="' . htmlspecialchars( $type ) . 'ItemsForm" class="' . htmlspecialchars( $type ) . 'ItemsForm galleryItemsForm">';

		if ( $folder ) {
			$return							.=			HTML_cbgalleryFolder::showFolder( $folders, $type, $viewer, $user, $tab, $plugin );
		}

		if ( ( $showFolders && ( $canCreateFolders || $canSearchFolders ) ) || ( ( ! $showItems ) && $canCreateItems ) ) {
			$return							.=			'<div class="galleryItemsHeader row" style="margin-bottom: 10px;">';

			if ( $canCreateFolders || ( ( ! $showItems ) && $canCreateItems ) ) {
				$return						.=				'<div class="' . ( ! $canSearchFolders ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
											.					'<div class="btn-group">'
											.						( ( ! $showItems ) && $canCreateItems ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => ( $folder ? (int) $folders->get( 'id' ) : 0 ) ) ) . '\';" class="galleryButton galleryButtonNewItem btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'NEW_ITEM_TYPE', 'New [type]', array( '[type]' => $typeTranslated ) ) . '</button>' : null )
											.						( $canCreateFolders ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\';" class="galleryButton galleryButtonNewItem btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'NEW_FOLDER_TYPE', 'New [type]', array( '[type]' => $folderType ) ) . '</button>' : null )
											.					'</div>'
											.				'</div>';
			}

			if ( $canSearchFolders ) {
				$return						.=				'<div class="' . ( ! ( $canCreateFolders || ( ( ! $showItems ) && $canCreateItems ) ) ? '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_folders']
											.					'</div>'
											.				'</div>';
			}

			$return							.=			'</div>';
		} elseif ( ( ! $showFolders ) && ( $canCreateFolders || $canCreateItems || $canSearchItems ) ) {
			$return							.=			'<div class="galleryItemsHeader row" style="margin-bottom: 10px;">';

			if ( $canCreateFolders || $canCreateItems ) {
				$return						.=				'<div class="' . ( ! $canSearchItems ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
											.					'<div class="btn-group">'
											.						( $canCreateItems ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => ( $folder ? (int) $folders->get( 'id' ) : 0 ) ) ) . '\';" class="galleryButton galleryButtonNewItem btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'NEW_ITEM_TYPE', 'New [type]', array( '[type]' => $typeTranslated ) ) . '</button>' : null )
											.						( $canCreateFolders ? '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'folders', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ) . '\';" class="galleryButton galleryButtonNewItem btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'NEW_FOLDER_TYPE', 'New [type]', array( '[type]' => $folderType ) ) . '</button>' : null )
											.					'</div>'
											.				'</div>';
			}

			if ( $canSearchItems ) {
				$return						.=				'<div class="' . ( ! ( $canCreateFolders || $canCreateItems ) ? '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_items']
											.					'</div>'
											.				'</div>';
			}

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

		if ( $showFolders || ( ! $showItems ) ) {
			$return							.=			HTML_cbgalleryFolders::showFolders( $folders, $foldersPageNav, ( ! $showItems ? $itemsPageNav->total : 0 ), $type, $viewer, $user, $tab, $plugin );
		}

		if ( $showItems ) {
			if ( $showFolders && ( $canCreateItems || $canSearchItems ) ) {
				$return						.=			'<div class="galleryItemsHeader row" style="margin-bottom: 10px;">';

				if ( $canCreateItems ) {
					$return					.=				'<div class="' . ( ! $canSearchItems ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
											.					'<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'items', 'func' => 'new', 'type' => $type, 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ), 'folder' => ( $folder ? (int) $folders->get( 'id' ) : 0 ) ) ) . '\';" class="galleryButton galleryButtonNewItem btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'NEW_ITEM_TYPE', 'New [type]', array( '[type]' => $typeTranslated ) ) . '</button>'
											.				'</div>';
				}

				if ( $canSearchItems ) {
					$return					.=				'<div class="' . ( ! $canCreateItems ? '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_items']
											.					'</div>'
											.				'</div>';
				}

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

			switch( $type ) {
				case 'photos':
					$return					.=			HTML_cbgalleryPhotos::showPhotos( $items, $itemsPageNav, $folder, $itemsSearching, $viewer, $user, $tab, $plugin );
					break;
				case 'files':
					$return					.=			HTML_cbgalleryFiles::showFiles( $items, $itemsPageNav, $folder, $itemsSearching, $viewer, $user, $tab, $plugin );
					break;
				case 'videos':
					$return					.=			HTML_cbgalleryVideos::showVideos( $items, $itemsPageNav, $folder, $itemsSearching, $viewer, $user, $tab, $plugin );
					break;
				case 'music':
					$return					.=			HTML_cbgalleryMusic::showMusic( $items, $itemsPageNav, $folder, $itemsSearching, $viewer, $user, $tab, $plugin );
					break;
			}
		}

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

		return $return;
	}