CB Activity new use for spots display

2 years 4 months ago #327166 by activha
CB Activity new use for spots display was created by activha
Hi

Following the thread on CB activity css in a new post.

My wish would be to simplify our website by slowing phasing out hotspots component for CB activity use only (and we would display a map for spots later on an iOS/android application map via api to retrieve CB info)

It seems like this could be feasible with all CB triggers and features but I would like to have your ideas before on all this.

Main point is that I’d like to use the main CB activity post area for everything, thus combining hotspots creation and community activity.

My idea is that when clicking on What’s on your mind ? this would display a new area or big button called « Activate something you know »

Clicking on this area would :
- 1 open a click or drag and drop zone to uploads photos/videos/ (compulsory to have one photo at least)

- 2 at the same time automatically record the location of the user or if geolocation is not authorized open the share location area for the user to insert the address (compulsory area)

- 3 show a title field and a message field (both compulsory to fill)

- 5 show a CB field select field cb_marketevents

- 6 show a select field for an hotspots category retrieved via API (see under) (later on will be a CB field CB_hotspot_category) (compulsory)

- 7 leave the user the ability to add other features from CB activity (theme, doing, feeling, share files etc)

Post processing would :
- save the images/media as usual in CB but with linked geolocation, address, and CB fields saved (message, title, event, category …)

- give it a special asset number, for instance : hotspots.idhotspots.ideventsselected.idCBcategoryselected

- display the asset in a special modal page with the linked event and cb fields also displayed when clicking on media/images/title. We need to customize this page to add explanations or use a new external page on which we’ll add the event and informations (example : activ-ha.com/c/86:conseils-societes-de-services/4271:safigec)

- (for now and for transition) send the images and data to hotspots API with activ-ha.com/index.php?option=com_hotspots&view=api&request=marker&format=raw&onlyLoggedIn=true (that’s for the use of hotspots component)

Our idea would be to slowly move from hotspots to CB activity only and then later on retrieve all CB activity data spots to be displayed on a iOS/android application map.

Moving to a single CB component would be much more easier to maintain if this is feasible.

Can you tell me your feeling on all this ? Is this feasible with CB ? and what would be the trigger to use ?

Thanks a lot


API hotspots data function and category retrieval :
	public function save()
	{
		$user = JFactory::getUser();

		$data   = $this->input->get('data', '', 'raw');
		$images = $this->input->get('images', '', 'raw');

		if (empty($data))
		{
			return $this->getError(404, 'Error No data for field creation');
		}

		if (empty($images))
		{
			$images = array();
		}

		$table = JTable::getInstance('Marker', 'Table');

		$hotspot = json_decode($data, true);
		$images  = json_decode($images);

		$isOwn = true;
		$isNew = empty($hotspot->id);

		if (empty($hotspot['created_by']))
		{
			$hotspot['created_by'] = $user->id;
		}
		else if ($hotspot['created_by'] != $user->id)
		{
			$isOwn = false;
		}

		if (empty($hotspot['id']) && !HotspotsHelperSecurity::authorise('create'))
		{
			return $this->getError(403, 'No permission to save / update hotspot.');
		}
		else if (!empty($hotspot['id']) && $isOwn && !HotspotsHelperSecurity::authorise('edit.own', $hotspot))
		{
			return $this->getError(403, 'No permission to edit own hotspot.');
		}
		else if (!empty($hotspot['id']) && !HotspotsHelperSecurity::authorise('edit', $hotspot))
		{
			return $this->getError(403, 'No permission to edit not own hotspot.');
		}

		// Import the appropriate plugin group.
		JPluginHelper::importPlugin('hotspots');

		$appl = JFactory::getApplication();

		if (!$table->bind($hotspot))
		{
			return array('error', $table->getError());
		}

		$appl->triggerEvent('onContentBeforeSave', array('com_hotspots.hotspot', $hotspot));

		// Alias Handling
		if (empty($table->alias))
		{
			if (JFactory::getConfig()->get('unicodeslugs') == 1)
			{
				$table->alias = JFilterOutput::stringURLUnicodeSlug($table->title);
			}
			else
			{
				$table->alias = JFilterOutput::stringURLSafe($table->title);
			}
		}

		$hotspotTable = JTable::getInstance('Marker', 'Table');

		while ($hotspotTable->load(array('alias' => $table->alias, 'catid' => $table->catid)))
		{
			$table->alias = StringHelper::increment($table->alias, 'dash');
		}

		if (!$table->store())
		{
			return array('error', $table->getError());
		}

		$appl->triggerEvent('onContentAfterSave', array('com_hotspots.hotspot', $hotspot, $isNew));

		$table->checkIn();

		$hotspotId  = $table->id;
		$targetPath = JPATH_CACHE . '/com_hotspots.multimedia/lib_compojoom.multimedia/';

		if (!JFolder::exists($targetPath))
		{
			JFolder::create($targetPath);
		}

		JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hotspots/models');
		JPluginHelper::importPlugin('hotspots');

		/** @var HotspotsModelMultimedia $multimediaModel */
		$multimediaModel = JModelLegacy::getInstance('Multimedia', 'HotspotsModel');

		// Save images first
		foreach ($images as $image)
		{
			$fileName = $image->filename;
			$content  = $image->content;

			list($type, $content) = explode(';', $content);
			list(, $content) = explode(',', $content);
			$content = base64_decode($content);

			// We use file put content here
			$imageFile = $targetPath . '/' . $fileName;
			file_put_contents($imageFile, $content);

			$meta = array();

			$meta[$fileName]['title']       = $fileName;
			$meta[$fileName]['description'] = '';

			$appl->triggerEvent('onMultimediaBeforeUpload', array($table->get('id'), array($fileName), $meta));

			$multimediaModel->uploadPermanent($hotspotId, array($fileName), $meta);

			$appl->triggerEvent('onMultimediaAfterUpload', array($table->get('id'), array($fileName), $meta));
		}

		return array('id' => $hotspotId);
	}

	protected function loadCategories($search = null, $catId = null, $offset = 0, $limit = 0, $orderBy = 'c.title ASC')
	{
		$query = $this->db->getQuery(true);

		$query->select('c.*')
			->from('#__categories as c')
			->where('c.published = 1');

		if (!empty($search))
		{
			$query->where('c.title LIKE \'%' . $this->db->escape($search) . '%\'');
		}

		if (!empty($catId))
		{
			if (is_array($catId))
			{
				$catId = implode(',', $catId);
			}

			$query->where('c.id IN (' . $catId . ')');
		}

		// Permissions
		$groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());

		$query->where('c.access IN (' . $groups . ')');

		// Filter only for categories of Matukio
		$query->where("c.extension = 'com_hotspots'");

		$query->order($this->db->escape($orderBy));

		$this->db->setQuery($query, $offset, $limit);

		return $this->db->loadObjectList();
	}

	/**
	 * Remove things we don't want to expose through the API
	 *
	 * @param   array  $categories  Categories
	 *
	 * @return  array
	 *
	 * @since  6.1.2
	 */
	protected function cleanupCategories($categories)
	{
		if (empty($categories))
		{
			return null;
		}

		// Files
		foreach ($categories as $category)
		{
			unset($category->lft);
			unset($category->rgt);
			unset($category->asset_id);
			unset($category->note);
			unset($category->checked_out);
			unset($category->checked_out_time);
			unset($category->created_user_id);
			unset($category->created_time);
			unset($category->modified_user_id);
			unset($category->modified_time);
			unset($category->hits);
		}

		return $categories;
	}

Please Log in to join the conversation.

2 years 4 months ago #327172 by krileon
Replied by krileon on topic CB Activity new use for spots display
That's for outside the scope of what CB Activity is intended to be. You've basically described a completely different extension.

What is a hotspot supposed to be for you exactly? Checking JED it just looks like you're tagging locations on a map (e.g. custom map markers). Seams like some improvements to the Location feature might be a better option here. Maybe a map they can tag with a site wide map to see all the tagged locations or something. I'm not entirely sure.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 4 months ago - 2 years 4 months ago #327176 by activha
Replied by activha on topic CB Activity new use for spots display
You're right... That's really tagging a location/company/business/shop/... (by geolocating the user IF outside or manually by reverse locating the address he enters if at home) and associate to the location at least one photo/video (this part could be optional but that's important to attract people and make them come to the page), a small title/message and an event/video (from GJ events for now)

Seeing all the tagged locations is also iimportant and your suggestion of a site wide display is fine, but that's not the main thing for us.

Main thing for the (tagging) user is to be able to share the CB activity post on a standalone page with other modules or information displayed (ie acymailing module to get emails/phone/names of interested tagged people or visitors).

Can we imagine a first display in the modal as of today, but with added things (modules/data) to the modal, and especially a map view for the location and a button/link to display the modal outside on a standalone page, and a button to share outside on external networks (email, facebook, linkedin...)

Our main idea is :
A user thinks that a company/shop/business/person may be interested by a marketing video event (that he has spotted on our website in the events area). He snaps a photo of the shop/business, get the location, associate the event/video and then share it to the company/shop/business/person by mail, bluetooth, qr code, url, sms, note on a paper, telepathy, etc... ;-)

If the tagged person/business receiving it acknowledges its interest for the product in the video, or subscribes to our plan (when our own video is used) to make savings for its company, then the tagging user can get from 2 € to 120 € (This part is taken care of with our affiliation component)

That's our way to redistribute money from big businesses to small ones and people who need it.

For now we use hotspots for this, but that's a bit heavy for this use. And if we could merge CB activity posting area and this feature, that could simplify things for users and enhance the whole community use as they are used to facebook, linkedin etc etc

I could use a CB activity action id for instance. When this id is detected and a new CB activity post is created, then we could in a first step transfer the data to hotspots by auto action, and in a later step output a special CB Modal gallery with the information needed (map location, modules, etc). But what's lacking is a way to display this modal on a standalone page in order for not registered users to access it and say if yes or no they are interested

This was my thinking

Then I have the following questions/remarks regarding CB Activity 6 :
  • Clicking on geolocate me could open a modal showing the coordinates found and allowing to change the position. Maybe coordinates say nothing for the user
  • Is it possible to change the buttons order in the posting area and make some of them dependent. For instance if I feel happy then a new cb field appears and I can geolocate me only in this case
  • Is it possible to change the order of CB Galery display ? for instance if I add a post with a message and an action, then add a media, this has to be a post display and not a gallery item display : meaning it should display user made this action and in the body the image is displayed. And not user added a gallery item first.
  • That would be good to be able to display a post in an outside page also for it to be shareable and seo friendly.
  • Is it possible to have a CB activity page which is public but with private posts reserved to registered users ?
  • Is it possible to have different posting features depending on the viewed activity page ? For instance only three buttons on one page and all on another?
  • Is it possible to have on the media modal, also the ability to display other informations from the post ie location, link to external display of the post, link to share it, other modules

Please Log in to join the conversation.

2 years 4 months ago - 2 years 4 months ago #327182 by krileon
Replied by krileon on topic CB Activity new use for spots display

Clicking on geolocate me could open a modal showing the coordinates found and allowing to change the position. Maybe coordinates say nothing for the user

Implementing map support for the Location feature is planned. Unsure if that will make it into 6.0.0, but will be trying.

Is it possible to change the buttons order in the posting area and make some of them dependent. For instance if I feel happy then a new cb field appears and I can geolocate me only in this case

No.

Is it possible to change the order of CB Galery display ? for instance if I add a post with a message and an action, then add a media, this has to be a post display and not a gallery item display : meaning it should display user made this action and in the body the image is displayed. And not user added a gallery item first.

No.

That would be good to be able to display a post in an outside page also for it to be shareable and seo friendly.

A Share feature is planned to allow easy direct linking to an individual activity post as well as option to "repost" something to your profile. Unsure how exactly I want to handle this because there's access permissions to contend with.

Is it possible to have different posting features depending on the viewed activity page ? For instance only three buttons on one page and all on another?

Yes, you configure 2 different streams with the same Asset and each stream can have a different set of features. In CB Activity 6.0.0 this will be a lot easier since streams will be stored in the database and you'll have a backend management page for configuring all your streams in 1 place. Activity will also begin keeping track of what stream it belongs to so the activity can be rebuilt safely with all the feature checks applied.

Is it possible to have on the media modal, also the ability to display other informations from the post ie location, link to external display of the post, link to share it, other modules

If you're talking about the media modal from CB Gallery that's already possible and is exactly how Likes/Comments are being added to CB Gallery via CB Auto Actions. If you mean for the media modal for raw images being linked in a post there's no such functionality or plans for such functionality at this time since there isn't really any information to utilize to display something there (it's just a URL link; we've no data beyond that).


From your description CB Activity is unfortunately never going to 100% cover your needs. It's far too specific to your business. You need a custom implementation for that. The best approach is to stop trying to use what's there and write a plugin to add the feature you want to CB Activity. This is similar to how CB Gallery adds support for stream uploads. You'd basically add a new button that asks for all your required information and handle all of its storage yourself. All can be done from triggers.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 4 months ago - 2 years 4 months ago #327185 by activha
Replied by activha on topic CB Activity new use for spots display

The best approach is to stop trying to use what's there and write a plugin to add the feature you want to CB Activity.


Yes this seems to be the best. Could you recommend a team or a dev which is used to CB for this ?

This is similar to how CB Gallery adds support for stream uploads. You'd basically add a new button that asks for all your required information and handle all of its storage yourself. All can be done from triggers.


Do you achieve the support by auto action ? I did not find it

BTW what's the planned timetable for CB Activity 6 ?

CB Activity is unfortunately never going to 100% cover your needs


Yes maybe but I really like the way your software is built and the way you intend to go :-)

The main reason was to use CB Gallery to display things inside its modal and start from there, provided that it can be reached by a standalone url later.

Some other questions to think about what is doable or not :

During this dev, how can I add a simple button to the post area opening a component modal with our com hotspots form page ?

Is there a trigger/autoaction to add a specific asset like spot.%.profile.%.hscid.%.action.11 to a post if the user chooses the action #11 for instance ?

Is there a trigger/autoaction to add a CB select field in the post area and display area if action #11 is selected for instance ?

Can I add a menu link to a CB activity specific asset like hotspot.4197.event.26.profile.1444 ? in this case I would only have to change the id to display the post in a standalone page and we’re pretty there ?

Please Log in to join the conversation.

2 years 4 months ago #327188 by krileon
Replied by krileon on topic CB Activity new use for spots display

Yes this seems to be the best. Could you recommend a team or a dev which is used to CB for this ?

I don't have anyone to recommend, sorry.

Do you achieve the support by auto action ? I did not find it

It's handled internally in CB Gallery and not by an auto action, but it's being done entirely with triggers so it can be done with auto actions. Sorry for the confusion.

The below file contains all the logic side of things for CB Gallery to extend CB Activity.

components/com_comprofiler/plugin/user/plug_cbgallery/library/Trigger/ActivityTrigger.php

Specifically the extendParameters, activityUploadNew, activityUploadEdit, and activityUploadSave functions. They are being called with the below trigger bindings.

$_PLUGINS->registerFunction( 'activity_onActivity', 'extendParameters', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onComments', 'extendParameters', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onDisplayStreamActivityNew', 'activityUploadNew', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onDisplayStreamCommentNew', 'activityUploadNew', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onDisplayStreamActivityEdit', 'activityUploadEdit', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onDisplayStreamCommentEdit', 'activityUploadEdit', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onBeforeUpdateStreamActivity', 'activityUploadSave', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onBeforeCreateStreamActivity', 'activityUploadSave', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onBeforeUpdateStreamComment', 'activityUploadSave', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );
$_PLUGINS->registerFunction( 'activity_onBeforeCreateStreamComment', 'activityUploadSave', '\CB\Plugin\Gallery\Trigger\ActivityTrigger' );

The above covers both comments and activity. If you only need activity you can just not bind to the comment ones.

BTW what's the planned timetable for CB Activity 6 ?

To be honest I've no idea. I hoped it'd have released as Beta by now, but the amount of work is a lot more than I expected. It's effectively in a "when it's done" state. I'm still holding out hope for a Beta/RC before end of this year, but likely won't release as Stable until next year. It's A LOT of work rewriting everything while maintaining backwards compatibility so I don't destroy everyone's sites, lol.

During this dev, how can I add a simple button to the post area opening a component modal with our com hotspots form page ?

I guess the same way CB Gallery does to add its button. You'd act on the new/edit display triggers and just add your button. Specifically the below.

$_PLUGINS->trigger( 'activity_onDisplayStreamActivityEdit', array( &$row, &$buttons, $viewer, $stream, $output ) );
$_PLUGINS->trigger( 'activity_onDisplayStreamActivityNew', array( &$buttons, $viewer, $stream, $output ) );

As you can see you can directly insert buttons via the $button variable. Your triggers return will insert a new input row like where the Action, Location, etc.. inputs are displayed.

Is there a trigger/autoaction to add a CB select field in the post area and display area if action #11 is selected for instance ?

Yes, the above triggers should allow you to do that.

Can I add a menu link to a CB activity specific asset like hotspot.4197.event.26.profile.1444 ? in this case I would only have to change the id to display the post in a standalone page and we’re pretty there ?

You can already directly link to activity. There just isn't a clean way to give users those URLs yet until the Share feature is implemented. The below should work though.

index.php?option=com_comprofiler&view=pluginclass&plugin=cbactivity&action=activity&id=ACTIVITY_ID_HERE


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.229 seconds

Facebook Twitter LinkedIn