Example #1
0
 public function reportBlog()
 {
     $app = JFactory::getApplication();
     // Get the composite keys
     $log_user = $this->plugin->get('user')->id;
     $id = $app->input->get('id', 0, 'int');
     $type = $app->input->get('type', '', 'POST');
     $reason = $app->input->get('reason', '', 'STRING');
     if (!$reason) {
         $message = "Reason is empty";
         $final_result['message'] = $message;
         $final_result['status'] = false;
         return $final_result;
     }
     $report = EB::table('Report');
     $report->obj_id = $id;
     $report->obj_type = $type;
     $report->reason = $reason;
     $report->created = EB::date()->toSql();
     $report->created_by = $log_user;
     $state = $report->store();
     if (!$state) {
         $message = "Cant store your report";
         $final_result['message'] = $message;
         $final_result['status'] = false;
         return $final_result;
     }
     // Notify the site admin when there's a new report made
     $post = EB::post($id);
     $report->notify($post);
     $final_result['message'] = "Report logged successfully!";
     $final_result['status'] = true;
     return $final_result;
 }
Example #2
0
 /**
  * Method to process redirections from google
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function grant()
 {
     // Get the oauth client
     $client = EB::oauth()->getClient('Facebook');
     // Get the code that facebook provided
     $code = $this->input->get('code', '', 'default');
     // Determines if this is a system request
     $system = $this->input->get('system', false, 'bool');
     // Exchange the code for an access token
     $result = $client->exchangeToken($code);
     // Load the Facebook oauth table
     $oauth = EB::table('OAuth');
     if ($system) {
         $oauth->load(array('type' => 'facebook', 'system' => true));
     } else {
         $oauth->load(array('type' => 'facebook', 'user_id' => $this->my->id, 'system' => false));
     }
     $oauth->created = EB::date()->toSql();
     $oauth->expires = $result->expires;
     $oauth->access_token = json_encode($result);
     $oauth->store();
     // Since the page that is redirected to here is a popup, we need to close the window
     $this->info->set(JText::_('COM_EASYBLOG_AUTOPOSTING_FACEBOOK_AUTHORIZED_SUCCESS'), 'success');
     echo '<script type="text/javascript">window.opener.doneLogin();window.close();</script>';
     exit;
 }
Example #3
0
 public function store($updateNulls = false)
 {
     if (!$this->created) {
         $this->created = EB::date()->toMySQL();
     }
     return parent::store($updateNulls);
 }
Example #4
0
 /**
  * Retrieves the authorization url and redirect accordingly
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function authorize()
 {
     // Get the client
     $client = EB::oauth()->getClient('LinkedIn');
     // Determines if this is for the centralized section
     $system = $this->input->get('system', false, 'bool');
     // Get the user id
     $userId = $this->input->get('userId', null, 'default');
     if (is_null($userId)) {
         $userId = $this->my->id;
     }
     // Get the redirection url
     $token = $client->getRequestToken();
     $url = $client->getAuthorizeURL($token->token);
     // Because twitter is being a PITA, we need to store these request tokens locally first.
     // Create a new table for record
     $table = EB::table('OAuth');
     if ($system) {
         $table->load(array('type' => 'linkedin', 'system' => true));
     } else {
         $table->load(array('type' => 'linkedin', 'user_id' => $userId, 'system' => false));
     }
     $table->user_id = $userId;
     $table->type = 'linkedin';
     $table->created = EB::date()->toSql();
     if ($system) {
         $table->system = 1;
     }
     // Store the request tokens here
     $table->request_token = json_encode($token);
     $table->store();
     $this->app->redirect($url);
 }
Example #5
0
 /**
  * Processes requests to join the team
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function join()
 {
     // Check for request forgeries
     EB::checkToken();
     // Only allow registered users
     EB::requireLogin();
     $return = $this->input->get('return', '', 'default');
     if ($return) {
         $return = base64_decode($return);
     }
     // Default return url
     if (!$return) {
         $return = EB::_('index.php?option=com_easyblog&view=teamblog', false);
     }
     // Get the team data
     $id = $this->input->get('id', 0, 'int');
     $team = EB::table('TeamBlog');
     $team->load($id);
     if (!$id || !$team->id) {
         $this->info->set('COM_EASYBLOG_TEAMBLOG_INVALID_ID_PROVIDED', 'error');
         return $this->app->redirect($return);
     }
     $model = EB::model('TeamBlogs');
     $isMember = $model->isMember($team->id, $this->my->id);
     // Check if the user already exists
     if ($isMember) {
         $this->info->set('COM_EASYBLOG_TEAMBLOG_ALREADY_MEMBER', 'error');
         return $this->app->redirect($return);
     }
     // If the user is a site admin, they are free to do whatever they want
     if (EB::isSiteAdmin()) {
         $map = EB::table('TeamBlogUsers');
         $map->user_id = $this->my->id;
         $map->team_id = $team->id;
         $map->store();
         $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_JOINED', 'success');
     } else {
         // Create a new request
         $request = EB::table('TeamBlogRequest');
         $request->team_id = $team->id;
         $request->user_id = $this->my->id;
         $request->ispending = true;
         $request->created = EB::date()->toSql();
         // If request was already made previously, skip this
         if ($request->exists()) {
             $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_ALREADY_SENT', 'error');
             return $this->app->redirect($return);
         }
         // Store the request now
         $state = $request->store();
         if (!$state) {
             $this->info->set($request->getError(), 'error');
             return $this->app->redirect($return);
         }
         // Send moderation emails
         $request->sendModerationEmail();
         $this->info->set('COM_EASYBLOG_TEAMBLOG_REQUEST_SENT', 'success');
     }
     return $this->app->redirect($return);
 }
Example #6
0
 /**
  * Retrieve stats for blog posts created the past week
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getPostsHistory()
 {
     // Get dbo
     $db = EB::db();
     // Get the past 7 days
     $today = EB::date();
     $dates = array();
     for ($i = 0; $i < 7; $i++) {
         $date = EB::date('-' . $i . ' day');
         $dates[] = $date->format('Y-m-d');
     }
     // Reverse the dates
     $dates = array_reverse($dates);
     // Prepare the main result
     $result = new stdClass();
     $result->dates = $dates;
     $result->count = array();
     $i = 0;
     foreach ($dates as $date) {
         $query = array();
         $query[] = 'SELECT COUNT(1) FROM ' . $db->quoteName('#__easyblog_post');
         $query[] = 'WHERE DATE_FORMAT(' . $db->quoteName('created') . ', GET_FORMAT(DATE, "ISO")) =' . $db->Quote($date);
         $query[] = 'AND ' . $db->quoteName('published') . '=' . $db->Quote(EASYBLOG_POST_PUBLISHED);
         $query[] = 'AND ' . $db->quoteName('state') . '=' . $db->Quote(EASYBLOG_POST_NORMAL);
         $query = implode(' ', $query);
         $db->setQuery($query);
         $total = $db->loadResult();
         $result->count[$i] = $total;
         $i++;
     }
     return $result;
 }
Example #7
0
 static function getLatestComment(&$params)
 {
     $mainframe = JFactory::getApplication();
     $db = EB::db();
     $count = (int) trim($params->get('count', 5));
     $showprivate = $params->get('showprivate', true);
     $query = 'SELECT ' . $db->qn('b.title') . ' as `blog_title`, ' . $db->qn('b.created_by') . ' as `author_id`, ' . $db->qn('b.category_id') . ' as `category_id`, a.*';
     $query .= ' from `#__easyblog_comment` as a';
     $query .= '   left join `#__easyblog_post` as b';
     $query .= '   on a.`post_id` = b.`id`';
     $query .= ' where b.`published` = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
     $query .= ' and b.`state` = ' . $db->Quote(EASYBLOG_POST_NORMAL);
     $query .= ' and a.`published`=' . $db->Quote('1');
     $query .= ' and b.`source_id` = ' . $db->Quote('0');
     if (!$showprivate) {
         $query .= ' and b.`access` = ' . $db->Quote('0');
     }
     $query .= ' order by a.`created` desc';
     $query .= ' limit ' . $count;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (count($result) > 0) {
         for ($i = 0; $i < count($result); $i++) {
             $row =& $result[$i];
             $row->author = EB::user($row->created_by);
             $date = EB::date($row->created)->dateWithOffSet();
             $row->dateString = EB::date($row->created)->toFormat(JText::_('DATE_FORMAT_LC3'));
         }
     }
     return $result;
 }
Example #8
0
 /**
  * Override the implementation of store
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function store($updateNulls = false)
 {
     // Check if creation date have been set
     if (!$this->created) {
         $this->created = EB::date()->toSql();
     }
     return parent::store($updateNulls);
 }
Example #9
0
 public static function getHTML()
 {
     $captcha = EB::table('Captcha');
     $captcha->created = EB::date()->toMySQL();
     $captcha->store();
     $theme = EB::template();
     $theme->set('id', $captcha->id);
     return $theme->output('site/comments/captcha');
 }
Example #10
0
 /**
  * Delete the outdated entries.
  */
 function clear()
 {
     $db = EasyBlogHelper::db();
     $date = EB::date();
     $query = 'DELETE FROM `#__easyblog_captcha` WHERE `created` <= DATE_SUB( ' . $db->Quote($date->toMySQL()) . ', INTERVAL 12 HOUR )';
     $db->setQuery($query);
     $db->query();
     return true;
 }
Example #11
0
 /**
  * Default method to format normal posts
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function execute()
 {
     // Result
     $result = array();
     // Cache data and preload posts
     if ($this->cache) {
         EB::cache()->insert($this->items);
     }
     // Preload all featured posts for posts
     $featuredItems = array();
     // Do a simple test to see if preload featured items is require or not
     if (!isset($this->items[0]->featured)) {
         $featuredItems = $this->preloadFeaturedItems();
     }
     $i = 0;
     foreach ($this->items as $item) {
         // Load up the post library
         $post = EB::post();
         $post->load($item->id);
         // Get the list of categories for this particular blog post
         $post->category = $post->getPrimaryCategory();
         $post->categories = $post->getCategories();
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $post->author = $post->getAuthor();
         // Determines if the blog post is featured
         if (isset($item->featured)) {
             $post->isFeatured = $item->featured;
         } else {
             if (isset($featuredItems[$post->id])) {
                 $post->isFeatured = $featuredItems[$post->id];
             } else {
                 $post->isFeatured = 0;
             }
         }
         // Password verifications
         $this->password($post);
         // Get custom fields
         $post->fields = $post->getCustomFields();
         // Format microblog postings
         if ($post->posttype) {
             $this->formatMicroblog($post);
         } else {
             $post->posttype = 'standard';
         }
         // Assign tags to the custom properties.
         $post->tags = $post->getTags();
         // Prepare nice date for the list
         $post->date = EB::date($post->created)->format(JText::_('DATE_FORMAT_LC'));
         $result[] = $post;
         $i++;
     }
     return $result;
 }
Example #12
0
 public static function getCurrentDate()
 {
     //This gets today's date
     $jdate = EB::date();
     $now = $jdate->toUnix();
     //This puts the day, month, and year in seperate variables
     $date['day'] = date('d', $now);
     $date['month'] = date('m', $now);
     $date['year'] = date('Y', $now);
     return $date;
 }
Example #13
0
 /**
  * Formats a given date string with a given date format
  *
  * @since   1.0
  * @access  public
  * @param   string      The current timestamp
  * @param   string      The language string format or the format for Date
  * @param   bool        Determine if it should be using the appropriate offset or GMT
  * @return  
  */
 public static function date($timestamp, $format = '', $withOffset = true)
 {
     // Get the current date object based on the timestamp provided.
     $date = EB::date($timestamp, $withOffset);
     // If format is not provided, we should use DATE_FORMAT_LC2 by default.
     $format = empty($format) ? 'DATE_FORMAT_LC2' : $format;
     // Get the proper format.
     $format = JText::_($format);
     $dateString = $date->format($format);
     return $dateString;
 }
Example #14
0
 function display($tmpl = null)
 {
     if (!$this->config->get('main_rss')) {
         return;
     }
     $model = EB::model('Blog');
     $data = $model->getFeaturedBlog();
     $document = JFactory::getDocument();
     $document->link = EBR::_('index.php?option=com_easyblog&view=featured');
     $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE'));
     $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root()));
     if (empty($data)) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($data as $row) {
         $blog = EB::table('Blog');
         $blog->load($row->id);
         $profile = EB::user($row->created_by);
         $created = EB::date($row->created);
         $row->created = $created->toSql();
         if ($this->config->get('main_rss_content') == 'introtext') {
             $row->text = !empty($row->intro) ? $row->intro : $row->content;
             //read more for feed
             $row->text .= '<br /><a href=' . EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>';
         } else {
             $row->text = $row->intro . $row->content;
         }
         $row->text = EB::videos()->strip($row->text);
         $row->text = EB::adsense()->stripAdsenseCode($row->text);
         $category = EB::table('Category');
         // Get primary category
         $primaryCategory = $blog->getPrimaryCategory();
         $category->load($primaryCategory->id);
         // Assign to feed item
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
         $item->description = $row->text;
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $row->created;
         $item->category = $category->getTitle();
         $item->author = $profile->getName();
         $item->authorEmail = $this->getRssEmail($profile);
         $document->addItem($item);
     }
 }
Example #15
0
 public function execute()
 {
     if ($this->cache) {
         //preload posts information
         EB::cache()->insert($this->items);
     }
     // For featured items we wouldn't want to process comments
     $comment = true;
     // For featured items we want to remove featured image
     $removeFeaturedImage = true;
     // For featured items we do not want to load videos
     $video = false;
     // For featured items we do not want to process gallery
     $gallery = false;
     // Ensure that the content does not exceed the introtext limit for featured items
     $contentLimit = $this->config->get('layout_featured_intro_limit');
     $result = array();
     foreach ($this->items as &$item) {
         $blog = EB::post($item->id);
         // Load the author's profile
         $author = EB::user($blog->created_by);
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $blog->author = $author;
         $blog->blogger = $author;
         // Password verifications
         $this->password($blog);
         // Format microblog postings
         if ($blog->posttype) {
             $this->formatMicroblog($blog);
         }
         // Detect if content requires read more link
         $blog->readmore = $this->hasReadmore($blog);
         // // Truncate content
         // $this->truncate($blog);
         // EB::truncateContent($blog, $loadVideo, $frontpage, $loadGallery);
         // Format the content for the featured items
         if (empty($blog->intro)) {
             $blog->intro = $blog->content;
         }
         // We wouldn't want to display html codes in the content
         $blog->intro = strip_tags($blog->intro);
         // Get the content length
         $length = JString::strlen($blog->intro);
         if ($length > $contentLimit) {
             $blog->intro = JString::substr($blog->intro, 0, $contentLimit);
         }
         // Prepare nice date for the featured area
         $blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC'));
         $result[] = $blog;
     }
     return $result;
 }
Example #16
0
 /**
  * Displays the comment output
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function html(EasyBlogPost &$blog)
 {
     // Load up template file
     $theme = EB::template();
     // Get comments
     $result = $this->prepareComments($blog);
     $comments = isset($result->comments) ? $result->comments : array();
     $pagination = isset($result->pagination) ? $result->pagination : false;
     // Retrieve the pagination for the blog entry comment view
     $pagination = $pagination->getPagesLinks();
     // Get user's information
     $profile = EB::user($this->my->id);
     // Retrieve blog posts url
     $url = base64_encode($blog->getPermalink());
     // Retrieve login url
     $loginUrl = EB::getLoginLink($url);
     // check if the user has subcribed to this thread
     $subscribed = false;
     if (!$this->my->guest) {
         $model = EB::model('Blog');
         $subscribed = $model->isBlogSubscribedUser($blog->id, $this->my->id, $this->my->email);
     }
     // Determines if the user can register while commenting
     $registration = $this->canRegister();
     $date = EB::date();
     // Determines if we should show the website field
     $website = false;
     if ($this->config->get('comment_show_website') || $this->config->get('comment_required_website')) {
         $website = true;
     }
     // Determines if we should show the email field
     $email = false;
     if ($this->config->get('comment_show_email') || $this->config->get('comment_require_email') || $registration) {
         $email = true;
     }
     $language = JFactory::getLanguage();
     $rtl = $language->isRTL();
     $theme->set('rtl', $rtl);
     $theme->set('email', $email);
     $theme->set('website', $website);
     $theme->set('date', $date);
     $theme->set('user', $profile);
     $theme->set('loginURL', $loginUrl);
     $theme->set('blog', $blog);
     $theme->set('comments', $comments);
     $theme->set('pagination', $pagination);
     $theme->set('registration', $registration);
     $theme->set('subscribed', $subscribed);
     $output = $theme->output('site/comments/default');
     return $output;
 }
Example #17
0
 public static function calendar($name, $value = '', $format = '%Y-%m-%d %H:%M:%S')
 {
     $theme = EB::template();
     $date = EB::date($value);
     $value = $date->format($format);
     // Generate a uniqid
     $hash = strtolower($name);
     $theme->set('hash', $hash);
     $theme->set('name', $name);
     $theme->set('value', $value);
     $theme->set('format', $format);
     $output = $theme->output('admin/html/form.calendar');
     return $output;
 }
Example #18
0
 public function execute()
 {
     if ($this->cache) {
         //preload posts information
         EB::cache()->insert($this->items);
     }
     // For featured items we wouldn't want to process comments
     $comment = true;
     // For featured items we want to remove featured image
     $removeFeaturedImage = true;
     // For featured items we do not want to load videos
     $video = false;
     // For featured items we do not want to process gallery
     $gallery = false;
     // Ensure that the content does not exceed the introtext limit for featured items
     $contentLimit = $this->config->get('layout_featured_intro_limit');
     $result = array();
     foreach ($this->items as &$item) {
         $blog = EB::post($item->id);
         // Load the author's profile
         $author = EB::user($blog->created_by);
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $blog->author = $author;
         $blog->blogger = $author;
         // Password verifications
         $this->password($blog);
         // Format microblog postings
         if ($blog->posttype) {
             $this->formatMicroblog($blog);
         }
         // Get featured image
         if ($blog->hasImage()) {
             $blog->image = $blog->getImage($this->config->get('cover_featured_size', 'large'));
         } else {
             $tmp = $blog->getContentImage();
             if ($tmp) {
                 $blog->image = $tmp;
             } else {
                 $blog->image = '';
             }
         }
         // Detect if content requires read more link
         $blog->readmore = $this->hasReadmore($blog);
         // Prepare nice date for the featured area
         $blog->date = EB::date($blog->created)->format(JText::_('DATE_FORMAT_LC'));
         $result[] = $blog;
     }
     return $result;
 }
Example #19
0
 function request()
 {
     $mainframe = JFactory::getApplication();
     if (!EasyBlogHelper::isLoggedIn()) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_YOU_MUST_LOGIN_FIRST'), 'error');
         $this->setRedirect(EBR::_('index.php?option=com_easyblog', false));
         return;
     }
     $redirect = JRequest::getVar('redirect', '');
     $type = JRequest::getCmd('type');
     if (!empty($redirect)) {
         $redirect = '&redirect=' . $redirect;
     }
     $userId = JRequest::getVar('id');
     // Flickr integration does not require user id.
     if (empty($userId)) {
         $mainframe->enqueueMessage(JText::_('Error, User not found.'), 'error');
         $redirect = JRoute::_('index.php?option=com_easyblog&view=users', false);
         $this->setRedirect($redirect);
         return;
     }
     $call = JRequest::getWord('call');
     $callUri = !empty($call) ? '&call=' . $call . '&id=' . $userId : '&id=' . $userId;
     $config = EasyBlogHelper::getConfig();
     $key = $config->get('integrations_' . $type . '_api_key');
     $secret = $config->get('integrations_' . $type . '_secret_key');
     $callback = rtrim(JURI::root(), '/') . '/administrator/index.php?option=com_easyblog&c=oauth&task=grant&type=' . $type . $redirect . $callUri;
     $consumer = EasyBlogOauthHelper::getConsumer($type, $key, $secret, $callback);
     $request = $consumer->getRequestToken();
     if (empty($request->token) || empty($request->secret)) {
         $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_OAUTH_KEY_INVALID'), 'error');
         $redirect = JRoute::_('index.php?option=com_easyblog&view=users', false);
         $this->setRedirect($redirect);
         return;
     }
     $oauth = EB::table('Oauth');
     $oauth->user_id = $userId;
     $oauth->type = $type;
     $oauth->created = EB::date()->toMySQL();
     // Bind the request tokens
     $param = EB::registry();
     $param->set('token', $request->token);
     $param->set('secret', $request->secret);
     $oauth->request_token = $param->toString();
     $oauth->store();
     $this->setRedirect($consumer->getAuthorizationURL($request->token, false, 'popup'));
 }
Example #20
0
 public function addUser($values, $source = 'subscribe')
 {
     $userComponent = 'com_users';
     $config = EB::config();
     $usersConfig = JComponentHelper::getParams('com_users');
     $canRegister = $source == 'comment' ? $config->get('comment_registeroncomment', 0) : $config->get('main_registeronsubscribe', 0);
     if ($usersConfig->get('allowUserRegistration') == '0' || !$canRegister) {
         return JText::_('COM_EASYBLOG_REGISTRATION_DISABLED');
     }
     $username = $values['username'];
     $email = $values['email'];
     $fullname = $values['name'];
     $mainframe = JFactory::getApplication();
     $jConfig = EasyBlogHelper::getJConfig();
     $authorize = JFactory::getACL();
     $document = JFactory::getDocument();
     $user = clone JFactory::getUser();
     $pwdClear = $username . '123';
     $newUsertype = $usersConfig->get('new_usertype', 2);
     $userArr = array('username' => $username, 'name' => $fullname, 'email' => $email, 'password' => $pwdClear, 'password2' => $pwdClear, 'groups' => array($newUsertype), 'gid' => '0', 'id' => '0');
     if (!$user->bind($userArr, 'usertype')) {
         return $user->getError();
     }
     $date = EB::date();
     $user->set('registerDate', $date->toSql());
     //check if user require to activate the acct
     $useractivation = $usersConfig->get('useractivation');
     if ($useractivation == '1' || $useractivation == '2') {
         jimport('joomla.user.helper');
         $user->set('activation', md5(JUserHelper::genRandomPassword()));
         $user->set('block', '1');
     }
     JPluginHelper::importPlugin('user');
     $user->save();
     // Send registration confirmation mail
     $password = $pwdClear;
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     //Disallow control chars in the email
     //load com_user language file
     $lang = JFactory::getLanguage();
     $lang->load('com_users');
     // Get the user id.
     $userId = $user->id;
     $this->sendMail($user, $password);
     return $userId;
 }
Example #21
0
 /**
  * Processes the content
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function bind(&$blog)
 {
     $title = $this->input->get('title', '', 'default');
     $video = $this->input->get('content', '', 'default');
     // Since title is optional, we generate a random name for the video title
     if (!$title) {
         $title = JText::sprintf('COM_EASYBLOG_MICROBLOG_VIDEO_TITLE_GENERIC', EB::date()->format(JText::_('DATE_FORMAT_LC2')));
     }
     // Get the default settings
     $width = $this->config->get('dashboard_video_width');
     $height = $this->config->get('dashboard_video_height');
     // Now we need to embed the image URL into the blog content.
     $content = '[embed=videolink]{"video":"' . $video . '","width":"' . $width . '","height":"' . $height . '"}[/embed]';
     $blog->title = $title;
     $blog->content = $content;
     $blog->posttype = EBLOG_MICROBLOG_VIDEO;
 }
Example #22
0
 /**
  * Map the data from request to the post library
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function bind(EasyBlogPost &$post)
 {
     // Get the data from the request
     $content = $this->input->get('content', '', 'default');
     $title = $this->input->get('title', '', 'default');
     $link = $this->input->get('link', '', 'default');
     // If title wasn't set, use the link as the title
     if (!$title) {
         $title = $link;
     }
     $content = nl2br($content);
     if (!$content) {
         $date = EB::date();
         $content = '<p>' . JText::sprintf('COM_EASYBLOG_MICROBLOG_LINK_CONTENT_GENERIC', $date->format(JText::_('DATE_FORMAT_LC2'))) . '</p>';
     }
     $post->title = $title;
     $post->content = $content;
     $post->posttype = EBLOG_MICROBLOG_LINK;
 }
Example #23
0
 /**
  * save post templates
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     $id = $this->input->get('id', '', 'int');
     $template = EB::table('PostTemplate');
     $template->load($id);
     $title = $this->input->get('title', '', 'default');
     $content = $this->input->get('template_content', '', 'raw');
     $data['content'] = $content;
     $template->title = $title;
     $template->data = json_encode($data);
     $template->user_id = $this->my->id;
     $template->created = EB::date()->toSql();
     $template->store();
     $this->info->set('COM_EASYBLOG_DASHBOARD_TEMPLATES_SAVED_SUCCESS', 'success');
     $redirect = EB::_('index.php?option=com_easyblog&view=dashboard&layout=templates', false);
     return $this->app->redirect($redirect);
 }
Example #24
0
 /**
  * Installs a new theme
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function install($file)
 {
     $source = $file['tmp_name'];
     $fileName = md5($file['name'] . EB::date()->toMySQL());
     $fileExtension = '_themes_install.zip';
     $destination = JPATH_ROOT . '/tmp/' . $fileName . $fileExtension;
     // Upload the zip archive
     $state = JFile::upload($source, $destination);
     if (!$state) {
         $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_COPY_FROM_PHP'));
         return false;
     }
     // Extract the zip
     $extracted = dirname($destination) . '/' . $fileName . '_themes_install';
     $state = JArchive::extract($destination, $extracted);
     // Once it is extracted, delete the zip file
     JFile::delete($destination);
     // Get the configuration file.
     $manifest = $extracted . '/config/template.json';
     $manifest = JFile::read($manifest);
     // Get the theme object
     $theme = json_decode($manifest);
     // Move it to the appropriate folder
     $themeDestination = EBLOG_THEMES . '/' . strtolower($theme->element);
     $exists = JFolder::exists($themeDestination);
     // If folder exists, overwrite it. For now, just throw an error.
     if ($exists) {
         // Delete teh etracted folder
         JFolder::delete($extracted);
         $this->setError(JText::sprintf('COM_EASYBLOG_THEMES_INSTALLER_ERROR_SAME_THEME_FOLDER_EXISTS', $theme->element));
         return false;
     }
     // Move extracted folder
     $state = JFolder::move($extracted, $themeDestination);
     if (!$state) {
         // Delete the etracted folder
         JFolder::delete($extracted);
         $this->setError(JText::_('COM_EASYBLOG_THEMES_INSTALLER_ERROR_MOVING_FOLDER_TO_THEMES_FOLDER'));
         return false;
     }
     return true;
 }
Example #25
0
 /**
  * Exchanges the request token with the access token
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAccess()
 {
     // Get the verifier codes
     $verifier = $this->getVerifier();
     $access = parent::retrieveTokenAccess($this->request_token, $this->request_secret, $verifier);
     if (isset($access['linkedin']['oauth_problem'])) {
         return false;
     }
     $obj = new stdClass();
     $obj->token = $access['linkedin']['oauth_token'];
     $obj->secret = $access['linkedin']['oauth_token_secret'];
     $obj->params = '';
     $obj->expires = EB::date();
     // If the expiry date is given
     if (isset($access['linkedin']['oauth_expires_in'])) {
         $expires = $access['linkedin']['oauth_expires_in'];
         // Set the expiry date with proper date data
         $obj->expires = EB::date(strtotime('now') + $expires)->toSql();
     }
     return $obj;
 }
Example #26
0
 /**
  * Saves an uploaded webcam picture
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function saveWebcam()
 {
     // Check for request forgeries
     EB::checkToken();
     // Ensure that the user user must be logged into the site
     EB::requireLogin();
     $image = $this->input->get('image', '', 'default');
     $image = imagecreatefrompng($image);
     ob_start();
     imagepng($image, null, 9);
     $contents = ob_get_contents();
     ob_end_clean();
     // Store this in a temporary location
     $file = md5(EB::date()->toSql()) . '.png';
     $tmp = JPATH_ROOT . '/tmp/' . $file;
     $uri = JURI::root() . 'tmp/' . $file;
     JFile::write($tmp, $contents);
     $result = new stdClass();
     $result->file = $file;
     $result->url = $uri;
     $this->ajax->resolve($result);
 }
Example #27
0
 /**
  * Allows site admin to edit a comment from the back end
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function form($tpl = null)
 {
     $this->setHeading('COM_EASYBLOG_COMMENTS_FORM_TITLE', '', 'fa-comments');
     // Get the comment item
     $id = $this->input->get('id', '', 'int');
     $comment = EB::table('Comment');
     $comment->load($id);
     // Set default values for new entries.
     if (!$comment->id) {
         $comment->created = EB::date()->format();
         $comment->published = true;
     }
     // If this comment was posted by a user on the site, pre-fill in the values
     if ($comment->created_by) {
         $author = $comment->getAuthor();
         $comment->name = $author->getName();
         $comment->email = $author->user->email;
         $comment->website = $author->getWebsite();
     }
     $this->set('comment', $comment);
     parent::display('comments/form');
 }
Example #28
0
 /**
  * Allows caller to submit a report
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function submit()
 {
     // Check for request forgeries
     EB::checkToken();
     // Get the composite keys
     $id = $this->input->get('id', 0, 'int');
     $type = $this->input->get('type', '', 'cmd');
     // Initialize redirection link
     $redirect = EB::_('index.php?option=com_easyblog&view=entry&id=' . $id, false);
     // Check if guest is allowed to report or not.
     if ($this->my->guest && !$this->config->get('main_reporting_guests')) {
         $this->info->set('COM_EASYBLOG_CATEGORIES_FOR_REGISTERED_USERS_ONLY', 'error');
         return $this->app->redirect($redirect);
     }
     // Ensure that the report reason is not empty.
     $reason = $this->input->get('reason', '', 'default');
     if (!$reason) {
         EB::info()->set(JText::_('COM_EASYBLOG_REPORT_PLEASE_SPECIFY_REASON'), 'error');
         return $this->app->redirect($redirect);
     }
     $report = EB::table('Report');
     $report->obj_id = $id;
     $report->obj_type = $type;
     $report->reason = $reason;
     $report->created = EB::date()->toSql();
     $report->created_by = $this->my->id;
     $report->ip = @$_SERVER['REMOTE_ADDR'];
     $state = $report->store();
     if (!$state) {
         $this->info->set($report->getError());
         return $this->app->redirect($redirect);
     }
     // Notify the site admin when there's a new report made
     $post = EB::post($id);
     $report->notify($post);
     $message = JText::_('COM_EASYBLOG_THANKS_FOR_REPORTING');
     $this->info->set($message, 'success');
     return $this->app->redirect($redirect);
 }
Example #29
0
 public function updateComment()
 {
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $acl = EB::acl();
     $id = JRequest::getInt('commentId');
     $post = JRequest::get('POST');
     //add here so that other component with the same comment.php jtable file will not get reference.
     JTable::addIncludePath(EBLOG_TABLES);
     $comment = EB::table('Comment');
     $comment->load($id);
     $redirect = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $comment->post_id, false);
     if (($my->id != $comment->created_by || !$acl->get('delete_comment')) && !EasyBlogHelper::isSiteAdmin() && !$acl->get('manage_comment') || $my->id == 0) {
         EB::info()->set(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_UPDATE_COMMENT'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     $comment->bindPost($post);
     if (!$comment->validate('title')) {
         EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_TITLE_IS_EMPTY'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     if (!$comment->validate('comment')) {
         EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_IS_EMPTY'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     $comment->modified = EB::date()->toMySQL();
     if (!$comment->store()) {
         EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_FAILED_TO_SAVE'), 'error');
         $mainframe->redirect($redirect);
         $mainframe->close();
     }
     EB::info()->set(JText::_('COM_EASYBLOG_COMMENT_UPDATED_SUCCESS'), 'success');
     $mainframe->redirect($redirect);
     $mainframe->close();
 }
Example #30
0
 /**
  * Allows caller to import feeds
  *
  * @since	4.0
  * @access	public
  */
 public function download()
 {
     // Get the id's from the request.
     $id = $this->input->get('id', 0, 'int');
     // Load the feed data
     $feed = EB::table('Feed');
     $feed->load($id);
     if (!$id || !$feed->id) {
         return $this->ajax->reject(JText::_('COM_EASYBLOG_FEEDS_INVALID_FEED_ID_PROVIDED'));
     }
     // Set this into processing mode first.
     $feed->flag = true;
     // $feed->store();
     // Import the feed
     $result = EB::feeds()->import($feed);
     // Set the last import date
     $feed->last_import = EB::date()->toSql();
     // Reset the flag
     $feed->flag = false;
     // Store the feed item now
     $feed->store();
     return $this->ajax->resolve($result);
 }