Esempio n. 1
0
 public function onUserAfterSave($user, $isnew, $success, $msg)
 {
     if ($isnew) {
         // Initialise EasySocial's Foundry Framework
         // Include main file.
         jimport('joomla.filesystem.file');
         $path = JPATH_ROOT . '/administrator/components/com_easysocial/includes/foundry.php';
         if (!JFile::exists($path)) {
             return false;
         }
         // Include the foundry engine
         require_once $path;
         $success = true;
         // Check if Foundry exists
         if (!Foundry::exists()) {
             Foundry::language()->loadSite();
             echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING');
             return;
         }
         if (!$success) {
             return false;
         }
         // Things that need to do here
         // 1. Insert user record into #__social_users
         // 2. Get the default profile
         // 3. Insert mapping into #__social_profiles_maps
         $userTable = Foundry::table('users');
         $state = $userTable->load($user['id']);
         // If no user is found in #__social_users, then only we insert
         // If user is found, means the registration is coming from EasySocial itself.
         // The purpose here is to insert the user data if the registration is handled by other services
         if (!$state) {
             // Assign the user id
             $userTable->user_id = $user['id'];
             // Filter the username so that it becomes a valid alias
             $alias = JFilterOutput::stringURLSafe($user['username']);
             // Check if the alias exists.
             $userModel = Foundry::model('Users');
             // Keep the original state of the alias
             $tmp = $alias;
             while ($userModel->aliasExists($alias, $user['id'])) {
                 // Generate a new alias for the user.
                 $alias = $tmp . '-' . rand(1, 150);
             }
             $userTable->alias = $alias;
             $userTable->state = $user['block'] === SOCIAL_JOOMLA_USER_BLOCKED ? SOCIAL_USER_STATE_PENDING : SOCIAL_USER_STATE_ENABLED;
             $userTable->type = 'joomla';
             $userTable->store();
             $profileModel = Foundry::model('Profiles');
             $defaultProfile = $profileModel->getDefaultProfile();
             if ($defaultProfile) {
                 $defaultProfile->addUser($user['id']);
             }
             $controller = JRequest::getCmd('controller', '');
             if ($controller != 'registration') {
                 // if this user saving is coming from registration, then we dont add the user into finder. let the registration controller do the job.
                 // Get the user object now
                 $esUser = Foundry::user($user['id']);
                 // Sync the index
                 $esUser->syncIndex();
             }
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Returns the comment counter
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getCommentCount($blog)
 {
     if (!$this->exists()) {
         return;
     }
     Foundry::language()->load('com_easysocial', JPATH_ROOT);
     $url = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id);
     $comments = Foundry::comments($blog->id, 'blog', SOCIAL_APPS_GROUP_USER, $url);
     return $comments->getCount();
 }
Esempio n. 3
0
 /**
  * Displays the category form for groups
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function categoryForm($tpl = null)
 {
     // Perhaps this is an edited category
     $id = JRequest::getInt('id');
     $category = FD::table('GroupCategory');
     $category->load($id);
     // Set the structure heading here.
     if ($category->id) {
         $this->setHeading($category->get('title'));
         $this->setDescription(JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_EDIT_GROUP_CATEGORY_DESC'));
     } else {
         $this->setHeading(JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_CREATE_GROUP_CATEGORY'));
         $this->setDescription(JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_CREATE_GROUP_CATEGORY_DESC'));
         // By default the published state should be published.
         $category->state = SOCIAL_STATE_PUBLISHED;
     }
     // Set page icon.
     $this->setIcon('ies-folder-3');
     // Load front end's language file
     Foundry::language()->loadSite();
     JToolbarHelper::apply('applyCategory', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_SAVE'), false, false);
     JToolbarHelper::save('saveCategory', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_SAVE_AND_CLOSE'));
     JToolbarHelper::save2new('saveCategoryNew', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_SAVE_AND_NEW'));
     JToolbarHelper::divider();
     JToolbarHelper::cancel('cancel', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_CANCEL'));
     $activeTab = JRequest::getWord('activeTab', 'settings');
     $createAccess = '';
     // Set properties for the template.
     $this->set('activeTab', $activeTab);
     $this->set('category', $category);
     if ($category->id) {
         $options = array('type' => SOCIAL_APPS_TYPE_FIELDS, 'group' => SOCIAL_TYPE_GROUP, 'state' => SOCIAL_STATE_PUBLISHED);
         // Get the available custom fields for groups
         $appsModel = FD::model('Apps');
         $defaultApps = $appsModel->getApps($options);
         // Get the steps for this id
         $stepsModel = FD::model('Steps');
         $steps = $stepsModel->getSteps($category->id, SOCIAL_TYPE_CLUSTERS);
         // Get the fields for this id
         $fieldsModel = FD::model('Fields');
         $fields = $fieldsModel->getCustomFields(array('uid' => $category->id, 'state' => 'all', 'group' => SOCIAL_TYPE_GROUP));
         // Empty array to pass to the trigger.
         $data = array();
         // Get the fields sample output
         $lib = FD::fields();
         $lib->trigger('onSample', SOCIAL_TYPE_GROUP, $fields, $data, array($lib->getHandler(), 'getOutput'));
         // Create a temporary storage
         $tmpFields = array();
         // Group the fields to each workflow properly
         if ($steps) {
             foreach ($steps as $step) {
                 $step->fields = array();
                 if (!empty($fields)) {
                     foreach ($fields as $field) {
                         if ($field->step_id == $step->id) {
                             $step->fields[] = $field;
                         }
                         $tmpFields[$field->app_id] = $field;
                     }
                 }
             }
         }
         // We need to know the amount of core apps and used core apps
         // 1.3 Update, we split out unique apps as well
         $coreAppsCount = 0;
         $usedCoreAppsCount = 0;
         $uniqueAppsCount = 0;
         $usedUniqueAppsCount = 0;
         // hide the apps if it is a core app and it is used in the field
         if ($defaultApps) {
             foreach ($defaultApps as $app) {
                 $app->hidden = false;
                 // If app is core, increase the coreAppsCount counter
                 if ($app->core) {
                     $coreAppsCount++;
                 }
                 // If app is NOT core and unique, increase the coreAppsCount counter
                 // This is because core apps are definitely unique, so we do not want to include core apps here
                 if (!$app->core && $app->unique) {
                     $uniqueAppsCount++;
                 }
                 // Test if this app has already been assigned to the $tmpFields
                 if (isset($tmpFields[$app->id]) && $app->core) {
                     $usedCoreAppsCount++;
                     $app->hidden = true;
                 }
                 // Test if this app is NOT core and unique and has already been assigned
                 // This is because core apps are definitely unique, so we do not want to include core apps here
                 if (isset($tmpFields[$app->id]) && !$app->core && $app->unique) {
                     $usedUniqueAppsCount++;
                     $app->hidden = true;
                 }
             }
         }
         unset($tmpFields);
         // Get the creation access
         $createAccess = $category->getAccess('create');
         // We need to know if there are any core apps remain
         $coreAppsRemain = $usedCoreAppsCount < $coreAppsCount;
         // We need to know if there are any unique apps remain
         $uniqueAppsRemain = $usedUniqueAppsCount < $uniqueAppsCount;
         // Set the profiles allowed to create groups
         $this->set('createAccess', $createAccess);
         // Set the flag of coreAppsRemain
         $this->set('coreAppsRemain', $coreAppsRemain);
         // Set the flag of uniqueAppsRemain
         $this->set('uniqueAppsRemain', $uniqueAppsRemain);
         // Set the default apps to the template.
         $this->set('defaultApps', $defaultApps);
         // Set the steps for the template.
         $this->set('steps', $steps);
         // Set the fields to the template
         $this->set('fields', $fields);
         // Set the field group type to the template
         $this->set('fieldGroup', SOCIAL_FIELDS_GROUP_GROUP);
         // Render the access form.
         $accessModel = FD::model('Access');
         $accessForm = $accessModel->getForm($category->id, SOCIAL_TYPE_CLUSTERS, 'access');
         $this->set('accessForm', $accessForm);
     }
     // Set the profiles allowed to create groups
     $this->set('createAccess', $createAccess);
     echo parent::display('admin/groups/form.category');
 }
Esempio n. 4
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item)
 {
     // Load up the config object
     $config = FD::config();
     if ($item->context != 'badges' || !$config->get('badges.enabled')) {
         return;
     }
     // Check if the app should be able to generate the stream.
     $params = $this->getParams();
     if (!$params->get('stream_achieved', true)) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     // check if the actor is ESAD profile or not, if yes, we skip the rendering.
     if (!$actor->hasCommunityAccess()) {
         $item->title = '';
         return;
     }
     // Test if stream item is allowed
     if (!$this->onStreamValidatePrivacy($item)) {
         return;
     }
     // Try to get the badge object from the params
     $raw = $item->params;
     $badge = FD::table('Badge');
     $badge->load($item->contextId);
     // lets load 3rd party component's language file if this is not a core badge
     if ($badge->extension && $badge->extension != 'com_easysocial') {
         Foundry::language()->load($badge->extension, JPATH_ROOT);
     }
     // Set the display mode to be full.
     $item->display = SOCIAL_STREAM_DISPLAY_FULL;
     $item->color = '#FEBC9D';
     $item->fonticon = 'ies-crown';
     $item->label = FD::_('APP_USER_BADGES_STREAM_TOOLTIP', true);
     // Format the likes for the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
     $item->comments = $comments;
     $this->set('badge', $badge);
     $this->set('actor', $actor);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = parent::display('streams/' . $item->verb . '.content');
     return true;
 }
Esempio n. 5
0
 /**
  * Returns an array of folders / albums in a given folder since jomsocial only stores user images here.
  *
  * @access	public
  * @param	string	$path	The path that contains the items.
  * @param	int 	$depth	The depth level to search for child items.
  */
 public function getItems($uri)
 {
     if (!$this->exists()) {
         return false;
     }
     // load easysocial language files.
     Foundry::language()->load('com_easysocial', JPATH_ROOT);
     // Determines if we are trying to view a single album or all albums
     $parts = explode(':', $uri);
     $viewAll = count($parts) == 1;
     // Let's build the photos URL now.
     $items = EBMM::filegroup();
     // Viewing of all albums
     if ($viewAll) {
         $model = FD::model('Albums');
         $result = $model->getAlbums($this->my->id, SOCIAL_TYPE_USER);
         if ($result) {
             foreach ($result as $row) {
                 $items['folder'][] = $this->decorateFolder($row);
             }
         }
         // Folder
         $folder = new stdClass();
         $folder->place = 'easysocial';
         $folder->title = JText::_('COM_EASYBLOG_MM_PLACE_EASYSOCIAL');
         $folder->url = 'easysocial';
         $folder->uri = 'easysocial';
         $folder->key = 'easysocial';
         $folder->type = 'folder';
         $folder->icon = EasyBlogMediaManager::$icons['place/easysocial'];
         $folder->root = true;
         $folder->scantime = 0;
         $folder->contents = $items;
         $folder->total = count($items['folder']);
     } else {
         // Get the album id it is trying to view
         $albumId = (int) $parts[1];
         $album = FD::table('Album');
         $album->load($albumId);
         // Render the photos model
         $model = FD::model('Photos');
         $options = array('album_id' => $albumId, 'pagination' => false);
         // Get the photos
         $photos = $model->getPhotos($options);
         if ($photos) {
             foreach ($photos as $photo) {
                 $items['image'][] = $this->decorateImage($photo, $album);
             }
         }
         // Folder
         $folder = new stdClass();
         $folder->place = 'easysocial';
         $folder->title = JText::_($album->get('title'));
         $folder->url = 'easysocial';
         $folder->uri = 'easysocial';
         $folder->key = 'easysocial';
         $folder->type = 'folder';
         $folder->icon = EBMM::$icons['place/easysocial'];
         $folder->root = true;
         $folder->scantime = 0;
         $folder->contents = $items;
         $folder->total = count($items);
     }
     return $folder;
 }
Esempio n. 6
0
	/**
	 * Initializes EasySocial
	 *
	 * @since	1.0
	 * @access	public
	 * @param	string
	 * @return
	 */
	public function init()
	{
		static $loaded 	= false;

		if( $this->exists() && !$loaded )
		{
			require_once( $this->file );

			$document 	= JFactory::getDocument();

			if( $document->getType() == 'html' )
			{
				// We also need to render the styling from EasySocial.
				$doc 		= Foundry::document();
				$doc->init();

				$page 		= Foundry::page();
				$page->processScripts();

			}

			Foundry::language()->loadSite();

			$loaded 	= true;
		}

		return $loaded;
	}