/** * Responsible to display the generic login form. * * @since 1.0 * @access public */ public function display($tpl = null) { $my = FD::user(); // If user is already logged in, they should not see this page. if ($my->id > 0) { return $this->redirect(FRoute::dashboard(array(), false)); } // Add page title FD::page()->title(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_TITLE')); // Add breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_BREADCRUMB')); // Facebook codes. $facebook = FD::oauth('Facebook'); $config = FD::config(); $loginMenu = $config->get('general.site.login'); // Get any callback urls. $return = FD::getCallback(); // If return value is empty, always redirect back to the dashboard if (!$return) { // Determine if there's a login redirection $urlFromCaller = FD::input()->getVar('return', ''); if ($urlFromCaller) { $return = $urlFromCaller; } else { if ($loginMenu != 'null') { $return = FRoute::getMenuLink($loginMenu); } else { $return = FRoute::dashboard(array(), false); } $return = base64_encode($return); } } else { $return = base64_encode($return); } if ($config->get('registrations.enabled')) { $profileId = $config->get('registrations.mini.profile', 'default'); if ($profileId === 'default') { $profileId = Foundry::model('profiles')->getDefaultProfile()->id; } $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId); $fieldsModel = Foundry::model('fields'); $fields = $fieldsModel->getCustomFields($options); if (!empty($fields)) { FD::language()->loadAdmin(); $fieldsLib = FD::fields(); $session = JFactory::getSession(); $registration = FD::table('Registration'); $registration->load($session->getId()); $data = $registration->getValues(); $args = array(&$data, &$registration); $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args); $this->set('fields', $fields); } } $this->set('return', $return); $this->set('facebook', $facebook); return parent::display('site/login/default'); }
/** * Responsible to display the generic login form via ajax * * @since 1.0 * @access public */ public function form($tpl = null) { $ajax = FD::ajax(); $my = FD::user(); // If user is already logged in, they should not see this page. if ($my->id > 0) { $this->setMessage(JText::_('COM_EASYSOCIAL_LOGIN_ALREADY_LOGGED_IN'), SOCIAL_MSG_ERROR); return $ajax->reject($this->getMessage()); } // Facebook codes. $facebook = FD::oauth('Facebook'); // Get any callback urls. $return = FD::getCallback(); // If return value is empty, always redirect back to the dashboard if (!$return) { $return = FRoute::dashboard(array(), false); } // Determine if there's a login redirection $config = FD::config(); $loginMenu = $config->get('general.site.login'); if ($loginMenu != 'null') { $return = FD::get('toolbar')->getRedirectionUrl($loginMenu); } $return = base64_encode($return); $this->set('return', $return); $this->set('facebook', $facebook); if ($config->get('registrations.enabled')) { $profileId = $config->get('registrations.mini.profile', 'default'); if ($profileId === 'default') { $profileId = Foundry::model('profiles')->getDefaultProfile()->id; } $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId); $fieldsModel = FD::model('Fields'); $fields = $fieldsModel->getCustomFields($options); if (!empty($fields)) { FD::language()->loadAdmin(); $fieldsLib = FD::fields(); $session = JFactory::getSession(); $registration = FD::table('Registration'); $registration->load($session->getId()); $data = $registration->getValues(); $args = array(&$data, &$registration); $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args); $this->set('fields', $fields); } } $contents = parent::display('site/login/dialog.login'); return $ajax->resolve($contents); }
/** * 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() { if (!$this->exists) { return false; } $my = JFactory::getUser(); // @rule: Get user's albums require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $model = Foundry::model('Albums'); $albums = $model->getAlbums($my->id, SOCIAL_TYPE_USER); if (!$albums) { $obj = new stdClass(); $obj->title = JText::_('COM_EASYBLOG_MM_MY_ALBUMS'); $obj->type = 'folder'; $obj->place = 'easysocial'; $obj->path = DIRECTORY_SEPARATOR; $obj->contents = array(); return $obj; } $data = array(); $photosModel = Foundry::model('Photos'); foreach ($albums as $album) { $container = array(); // Get a list of photos from this album $photos = $photosModel->getPhotos(array('album_id' => $album->id, 'pagination' => false)); // Get the album object. $albumObj = $this->getObject($album, 'album'); $photosData = array(); foreach ($photos as $photo) { // Get the photo object. $photoObj = $this->getObject($photo, 'photo'); $photosData[] = $photoObj; } $albumObj->contents = $photosData; $data[] = $albumObj; } $obj = new stdClass(); $obj->type = 'folder'; $obj->contents = $data; $obj->place = 'easysocial'; $obj->path = DIRECTORY_SEPARATOR; return $obj; }
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; }
public function buildPrivacyQuery($alias = 'a') { $db = EasyBlogHelper::db(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $esFriends = Foundry::model('Friends'); $friends = $esFriends->getFriends($my->id, array('idonly' => true)); if ($friends) { array_push($friends, $my->id); } $alias = $alias . '.'; // Insert query here. $queryWhere = ' AND ('; $queryWhere .= ' ( ' . $alias . '`private`= 0 ) OR'; $queryWhere .= ' ( (' . $alias . '`private` = 10) AND (' . $db->Quote($my->id) . ' > 0 ) ) OR'; if (empty($friends)) { $queryWhere .= ' ( ( ' . $alias . '`private` = 30 ) AND ( 1 = 2 ) ) OR'; } else { $queryWhere .= ' ( ( ' . $alias . '`private` = 30) AND ( ' . $alias . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . ' IN (' . implode(',', $friends) . ') ) ) OR'; } $queryWhere .= ' ( (' . $alias . '`private` = 40) AND ( ' . $alias . EasyBlogHelper::getHelper('SQL')->nameQuote('created_by') . '=' . $my->id . ') )'; $queryWhere .= ' )'; return $queryWhere; }
/** * Processes a legacy album tag into it's html counterpart * * @since 5.0 * @access public * @param string * @return */ public function process($content, $userId = '') { // Match the following tags $pattern = '/\\[embed=album\\](.*)\\[\\/embed\\]/i'; preg_match_all($pattern, $content, $matches, PREG_SET_ORDER); if (!empty($matches)) { $cfg = EasyBlogHelper::getConfig(); foreach ($matches as $match) { // The full text of the matched content. $text = $match[0]; // The json string $jsonString = $match[1]; // Let's parse the JSON string and get the result. $obj = json_decode($jsonString); // @task: When there's nothing there, we just return the original content. if ($obj === false) { // @TODO: Remove the gallery tag. return $content; } $albumId = $obj->file; // @task: Ensure that the id is properly sanitized. $albumId = str_ireplace(array('/', '\\'), '', $albumId); $albumId = (int) $albumId; if ($obj->place == 'easysocial') { if (!$this->includeEasySocial()) { continue; } $model = Foundry::model('Photos'); $photos = $model->getPhotos(array('album_id' => $albumId, 'pagination' => false)); if (!$photos) { continue; } $images = array(); foreach ($photos as $photo) { $image = new stdClass(); $image->title = $photo->caption; $image->original = $photo->getSource('original'); $image->thumbnail = $photo->getSource('thumbnail'); $images[] = $image; } } else { if (!$this->includeJomSocial()) { continue; } // Let's get a list of photos from this particular album. $model = CFactory::getModel('photos'); // Always retrieve the list of albums first $photos = $model->getAllPhotos($albumId); if (!$photos) { continue; } $images = array(); foreach ($photos as $photo) { $image = new stdClass(); $image->title = $photo->caption; $image->original = rtrim(JURI::root(), '/') . '/' . str_ireplace('\\', '/', $photo->image); $image->thumbnail = rtrim(JURI::root(), '/') . '/' . str_ireplace('\\', '/', $photo->thumbnail); $images[] = $image; } } $theme = EB::template(); $theme->set('uid', uniqid()); $theme->set('images', $images); $output = $theme->output('site/blogs/latest/blog.album'); // Now, we'll need to alter the original contents. $content = str_ireplace($text, $output, $content); } } return $content; }
/** * Triggered when a comment save occurs * * @since 1.0 * @access public * @param SocialTableComments The comment object * @return */ public function onAfterCommentSave(&$comment) { $allowed = array('photos.user.upload', 'albums.user.create', 'stream.user.upload', 'photos.user.add', 'photos.user.uploadAvatar', 'photos.user.updateCover'); if (!in_array($comment->element, $allowed)) { return; } // For likes on albums when user uploads multiple photos within an album if ($comment->element == 'albums.user.create') { // Since the uid is tied to the album we can get the album object $album = Foundry::table('Album'); $album->load($comment->uid); // Get the actor of the likes $actor = Foundry::user($comment->created_by); // Set the email options $emailOptions = array('title' => 'APP_USER_PHOTOS_EMAILS_COMMENT_ALBUM_ITEM_SUBJECT', 'template' => 'apps/user/photos/comment.album.item', 'permalink' => $album->getPermalink(true, true), 'comment' => $comment->comment, 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true)); $systemOptions = array('context_type' => $comment->element, 'context_ids' => $comment->uid, 'url' => $album->getPermalink(false, false, 'item', false), 'actor_id' => $comment->created_by, 'uid' => $comment->id, 'aggregate' => true); // Notify the owner of the photo first if ($comment->created_by != $album->user_id) { Foundry::notify('comments.item', array($album->user_id), $emailOptions, $systemOptions); } // Get a list of recipients to be notified for this stream item // We exclude the owner of the note and the actor of the like here $recipients = $this->getStreamNotificationTargets($comment->uid, 'albums', 'user', 'create', array(), array($album->user_id, $comment->created_by)); $emailOptions['title'] = 'APP_USER_PHOTOS_EMAILS_COMMENT_ALBUM_INVOLVED_SUBJECT'; $emailOptions['template'] = 'apps/user/photos/comment.album.involved'; // Notify other participating users Foundry::notify('comments.involved', $recipients, $emailOptions, $systemOptions); return; } // For comments made on photos $allowed = array('photos.user.upload', 'stream.user.upload', 'photos.user.add', 'photos.user.uploadAvatar', 'photos.user.updateCover'); if (in_array($comment->element, $allowed)) { // Get the actor of the likes $actor = Foundry::user($comment->created_by); // Set the email options $emailOptions = array('template' => 'apps/user/photos/comment.photo.item', 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'comment' => $comment->comment); $systemOptions = array('context_type' => $comment->element, 'context_ids' => $comment->uid, 'actor_id' => $comment->created_by, 'uid' => $comment->id, 'aggregate' => true); // Standard email subject $ownerTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PHOTO_ITEM_SUBJECT'; $involvedTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PHOTO_INVOLVED_SUBJECT'; // If this item is multiple share on the stream, we need to get the photo id here. if ($comment->element == 'stream.user.upload') { // Since this item is tied to the stream, we need to load the stream object $stream = Foundry::table('Stream'); $stream->load($comment->uid); // Get the photo object from the context id of the stream $model = Foundry::model('Stream'); $origin = $model->getContextItem($comment->uid); $photo = Foundry::table('Photo'); $photo->load($origin->context_id); // Get the permalink to the photo $emailOptions['permalink'] = $stream->getPermalink(true, true); $systemOptions['url'] = $stream->getPermalink(false, false, false); $element = 'stream'; $verb = 'upload'; } // For single photo items on the stream if ($comment->element == 'photos.user.upload' || $comment->element == 'photos.user.add' || $comment->element == 'photos.user.uploadAvatar' || $comment->element == 'photos.user.updateCover') { // Get the photo object $photo = Foundry::table('Photo'); $photo->load($comment->uid); // Get the permalink to the photo $emailOptions['permalink'] = $photo->getPermalink(true, true); $systemOptions['url'] = $photo->getPermalink(false, false, 'item', false); $element = 'photos'; $verb = 'upload'; } if ($comment->element == 'photos.user.uploadAvatar') { $verb = 'uploadAvatar'; $ownerTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_PICTURE_ITEM_SUBJECT'; $involvedTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_PICTURE_INVOLVED_SUBJECT'; } if ($comment->element == 'photos.user.updateCover') { $verb = 'updateCover'; $ownerTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_COVER_ITEM_SUBJECT'; $involvedTitle = 'APP_USER_PHOTOS_EMAILS_COMMENT_PROFILE_COVER_INVOLVED_SUBJECT'; } $emailOptions['title'] = $ownerTitle; // @points: photos.like // Assign points for the author for liking this item $photo->assignPoints('photos.comment.add', $comment->created_by); // Notify the owner of the photo first if ($photo->user_id != $comment->created_by) { Foundry::notify('comments.item', array($photo->user_id), $emailOptions, $systemOptions); } // Get additional recipients since photos has tag $additionalRecipients = array(); $this->getTagRecipients($additionalRecipients, $photo); // Get a list of recipients to be notified for this stream item // We exclude the owner of the note and the actor of the like here $recipients = $this->getStreamNotificationTargets($comment->uid, $element, 'user', $verb, $additionalRecipients, array($photo->user_id, $comment->created_by)); $emailOptions['title'] = $involvedTitle; $emailOptions['template'] = 'apps/user/photos/comment.photo.involved'; // Notify other participating users Foundry::notify('comments.involved', $recipients, $emailOptions, $systemOptions); return; } }
/** * Displays the application output in the canvas. * * @since 1.0 * @access public * @param int The user id that is currently being viewed. * @return string Layout path */ public function display($userId = null, $docType = null) { $lang = JFactory::getLanguage(); $lang->load('plg_app_user_q2c_boughtproducts', JPATH_ADMINISTRATOR); $path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helper.php'; if (!class_exists('comquick2cartHelper')) { JLoader::register('comquick2cartHelper', $path); JLoader::load('comquick2cartHelper'); } $product_path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php'; if (!class_exists('productHelper')) { JLoader::register('productHelper', $product_path); JLoader::load('productHelper'); } // Get the user params $params = $this->getUserParams($userId); // Get the app params $appParams = $this->app->getParams(); // Get the blog model $no_of_porducts = $params->get('total', '10'); $privacy = $params->get('profile_show_friends', 'onlyme'); $pin_width = (int) $appParams->get('pin_width', 145); $pin_padding = (int) $appParams->get('pin_padding', 3); // Get profile id $model = new productHelper(); // $target_data = $model->getUserStores($user->id,$no_of_stores); $no_authorize = ''; $target_data = ''; $my = Foundry::user(); $logged_id = $my->id; if ($privacy === 'onlyme') { if ($logged_id == $userId) { $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts); } else { $no_authorize = 'no'; $this->set('no_authorize', $no_authorize); } } elseif ($privacy === 'friend') { $check = Foundry::model('Friends')->isFriends($logged_id, $userId); if ($check == 1 || $logged_id == $userId) { $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts); } else { $no_authorize = 'no'; $this->set('no_authorize', $no_authorize); } } elseif ($privacy === 'fof') { // $my = Foundry::user($userId); $check_friend = Foundry::model('Friends')->isFriends($logged_id, $userId); $friendlist = Foundry::model('Friends')->getFriends($userId); foreach ($friendlist as $ids) { $check_fof = Foundry::model('Friends')->isFriends($logged_id, $ids->id); if ($check_fof == 1 || $logged_id == $userId) { $check_friendoffriend = 1; } } if ($check_friend == 1 || $logged_id == $userId && $check_friendoffriend == 1) { $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts); } else { $no_authorize = 'no'; $this->set('no_authorize', $no_authorize); } } elseif ($privacy === 'all') { $target_data = $model->getUserRecentlyBoughtproducts($userId, $no_of_porducts); } else { $target_data = ''; } $this->set('no_authorize', $no_authorize); $this->set('target_data', $target_data); $this->set('userId', $userId); $this->set('privacy', $privacy); $this->set('pin_width', $pin_width); $this->set('pin_padding', $pin_padding); echo parent::display('profile/default'); }