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 static function location($location, $options = '') { $uid = uniqid(); $classname = 'es-location-' . $uid; $selector = '.' . $classname; if (empty($location)) { $location = Foundry::table('Location'); } $theme = Foundry::get('Themes'); $theme->set('uid', $uid); $theme->set('classname', $classname); $theme->set('selector', $selector); $theme->set('location', $location); return $theme->output('admin/html/grid.location'); }
/** * 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; } }
public function prepareCreateMilestoneStream(SocialStreamItem $item, $includePrivacy = true) { $params = FD::registry($item->params); $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); // Get the group data FD::load('group'); $group = new SocialGroup(); $group->bind($params->get('group')); // Get the actor $actor = $item->actor; // We need to get the task app for the group $app = Foundry::table('App'); $app->load(array('element' => 'tasks', 'group' => 'group')); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); $this->set('permalink', $permalink); $this->set('milestone', $milestone); $this->set('actor', $actor); $this->set('group', $group); $item->title = parent::display('streams/tasks/create.milestone.title'); $item->content = parent::display('streams/tasks/create.milestone.content'); }
public function onBeforeCommentSave(&$comment) { // This is so that comment posted on the article can be linked back to the stream item. $allowed = array('article.user.create', 'article.user.update', 'article.user.read'); if (!in_array($comment->element, $allowed)) { return; } $segments = $comment->element; list($element, $group, $verb) = explode('.', $segments); $streamItem = Foundry::table('streamitem'); $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $comment->uid)); if (!$state) { return; } if (empty($comment->stream_id)) { $comment->stream_id = $streamItem->uid; } return true; }
function _getESOptions($fields) { $db = JFactory::getDBO(); $socialadshelper = new socialadshelper(); $eschk = $socialadshelper->eschk(); if (!empty($eschk)) { for ($i = 0; $i < count($fields); $i++) { if ($fields[$i]->mapping_fieldtype != 'textbox') { $field_option = array(); require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; $field = Foundry::table('Field'); $field->load($fields[$i]->mapping_fieldid); $filed_array = new stdclass(); $filed_array->id = $fields[$i]->mapping_fieldid; $options_value = Foundry::fields()->getOptions($field); /* if(empty($options_value)) { $model = Foundry::model( 'Fields' ); $options_value = $model->getOptions($fields[$i]->mapping_fieldid); $options_value=$options_value['items']; } */ $options = implode("\n", $options_value); $filed_array->options = $options; $field_option[] = $filed_array; $mapping_options[] = $field_option; } } } if (!empty($mapping_options)) { return $mapping_options; } }
/** * Saves a configuration item * * @since 1.0 * @access public * @param string The key to save * @param mixed The data to save * @return */ public function updateConfig($key, $value) { $this->foundry(); $config = Foundry::config(); $config->set($key, $value); $jsonString = $config->toString(); $configTable = Foundry::table('Config'); if (!$configTable->load('site')) { $configTable->type = 'site'; } $configTable->set('value', $jsonString); $configTable->store(); }
public function onDisplay($user) { if (empty($this->value)) { return; } if (!$this->allowedPrivacy($user)) { return; } $json = FD::json(); $result = $json->decode($this->value); if (!is_array($result) || empty($result)) { return; } $field = $this->field; $values = array(); foreach ($result as $r) { $r = trim($r); if (empty($r)) { continue; } $option = Foundry::table('fieldoptions'); $option->load(array('parent_id' => $this->field->id, 'key' => 'items', 'value' => $r)); if ($field->searchable) { $params = array('layout' => 'advanced'); $params['criterias[]'] = $field->unique_key . '|' . $field->element; $params['operators[]'] = 'contain'; $params['conditions[]'] = $v; $advsearchLink = FRoute::search($params); $option->advancedsearchlink = $advsearchLink; } $values[] = $option; } if (empty($values)) { return; } $this->set('values', $values); return $this->display(); }
public function removeLike( $comment ) { if( !$this->exists() ) { return false; } if( !empty( $comment->params->social->stream ) ) { $likeTable = Foundry::table( 'likes' ); $liked = $likeTable->load( array( 'type' => 'komento.user', 'uid' => $comment->params->social->stream, 'created_by' => Foundry::user()->id ) ); if( $liked ) { $likeTable->delete(); } } }
private function getObject($item, $type) { $obj = new stdClass(); if ($type == 'album') { $obj->type = 'folder'; // @task: Get the media item's title. $obj->title = $item->title; // @task: Get the mime type $obj->mime = ''; // @task: Determine the filesize of this item (Bytes). $obj->filesize = ''; // Set the current place. $obj->place = 'easysocial'; // @task: Get the absolute URI to the item. $obj->uri = rtrim(JURI::root(), '/') . str_ireplace(JPATH_ROOT, '', $item->getStoragePath()); // @task: Get the creation date of the item. $obj->creationDate = EasyBlogHelper::getDate($item->created)->toMySQL(); // @task: Get the contents // @todo $obj->path = DIRECTORY_SEPARATOR . $item->id; $obj->icon = new stdClass(); $obj->icon->url = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/gallery.png'; $obj->contents = ''; } else { if ($type == 'photo') { $obj->type = 'image'; // @task: Get the media item's title. $obj->title = $item->caption; $album = Foundry::table('Album'); $album->load($item->album_id); $path = $item->getSource('original'); $path = str_ireplace(JURI::root(), JPATH_ROOT . '/', $path); $info = @getimagesize($path); // @task: Get the media item's width. $obj->width = $info[0]; // @task: Get the media item's height. $obj->height = $info[1]; // @task: Get the mime type $obj->mime = $info['mime']; // @task: Determine the filesize of this item (Bytes). $obj->filesize = filesize($path); // Set the current place. $obj->place = 'easysocial'; // @task: Get the absolute URI to the item. $obj->url = $item->getSource('original'); // @task: Get the creation date of the item. $obj->creationDate = EasyBlogHelper::getDate($item->created)->toMySQL(); // @task: Set the thumbnail $obj->thumbnail = new stdClass(); $obj->thumbnail->url = $item->getSource('thumbnail'); // @task: Set the thumbnail $obj->icon = new stdClass(); $obj->icon->url = $item->getSource('thumbnail'); // @task: Get the contents $obj->path = '/' . $item->album_id . '/' . $item->id; } } return $obj; }
public function prepareCreatedTaskStream(SocialStreamItem $streamItem, $includePrivacy = true) { $params = FD::registry($streamItem->params); // Get the tasks available from the cached data $items = $params->get('tasks'); $tasks = array(); $taskId = ''; foreach ($items as $item) { $task = FD::table('Task'); $task->load($item->id); $tasks[] = $task; $taskId = $task->id; } // Get the milestone $milestone = FD::table('Milestone'); $milestone->bind($params->get('milestone')); // Get the group data FD::load('group'); $group = new SocialGroup(); $group->bind($params->get('group')); // We need to get the task app for the group $app = Foundry::table('App'); $app->load(array('element' => 'tasks', 'group' => 'group')); $permalink = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $app->getAlias(), 'milestoneId' => $milestone->id)); $this->set('permalink', $permalink); $this->set('stream', $streamItem); $this->set('milestone', $milestone); $this->set('total', count($tasks)); $this->set('actor', $streamItem->actor); $this->set('group', $group); $this->set('tasks', $tasks); $streamItem->title = parent::display('streams/tasks/create.task.title'); $streamItem->content = parent::display('streams/tasks/create.task.content'); // Append the likes action on the stream if (!$streamItem->contextIds[0]) { $likes = Foundry::likes(); $likes->get($taskId, $streamItem->context, $streamItem->verb, SOCIAL_TYPE_GROUP, $streamItem->uid); $streamItem->likes = $likes; // Append the comment action on the stream $comments = Foundry::comments($taskId, $streamItem->context, $streamItem->verb, SOCIAL_TYPE_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid))), $streamItem->uid); $streamItem->comments = $comments; } }