Пример #1
0
 public function __construct()
 {
     // Define Joomla's app
     $this->app = JFactory::getApplication();
     $this->input = $this->app->input;
     // Load configuration object.
     $config = FD::config();
     $jConfig = FD::jconfig();
     // Define the current logged in user or guest
     if (is_null(self::$user)) {
         self::$user = FD::user();
     }
     // Define the current logged in user's access.
     if (is_null(self::$userAccess)) {
         self::$userAccess = FD::access();
     }
     if (is_null(self::$tmplMode)) {
         self::$tmplMode = $this->input->get('tmpl', '', 'default');
     }
     // Get the current access
     $this->my = self::$user;
     $this->access = self::$userAccess;
     // Define our own configuration
     $this->config = $config;
     // Define template's own configuration
     if (is_null(self::$templateConfig)) {
         self::$templateConfig = $this->getConfig();
     }
     $this->template = self::$templateConfig;
     // Define Joomla's configuration so the world can use it.
     $this->jConfig = $jConfig;
     // Determine if the current request has tmpl=xxx
     $this->tmpl = self::$tmplMode;
 }
Пример #2
0
 public function getAjaxUrl()
 {
     static $url;
     if (isset($url)) {
         return $url;
     }
     $uri = JFactory::getURI();
     $language = $uri->getVar('lang', 'none');
     // Remove any ' or " from the language because language should only have -
     $app = JFactory::getApplication();
     $input = $app->input;
     $language = $input->get('lang', '', 'cmd');
     $jConfig = FD::jconfig();
     // Get the router
     $router = $app->getRouter();
     // It could be admin url or front end url
     $url = rtrim(JURI::base(), '/');
     // Append the url with the extension
     $url = $url . '/index.php?option=com_easysocial&lang=' . $language;
     // During SEF mode, we need to ensure that the URL is correct.
     $languageFilterEnabled = JPluginHelper::isEnabled("system", "languagefilter");
     if ($router->getMode() == JROUTER_MODE_SEF && $languageFilterEnabled) {
         // Determines if the mod_rewrite is enabled on Joomla
         $rewrite = $jConfig->getValue('sef_rewrite');
         // Replace the path if it's on subfolders
         $base = str_ireplace(JURI::root(true), '', $uri->getPath());
         if ($rewrite) {
             $path = $base;
         } else {
             $path = JString::substr($base, 10);
         }
         // Remove trailing / from the url
         $path = JString::trim($path, '/');
         $parts = explode('/', $path);
         if ($parts) {
             // First segment will always be the language filter.
             $language = reset($parts);
         } else {
             $language = 'none';
         }
         if ($rewrite) {
             $url = rtrim(JURI::root(), '/') . '/' . $language . '/?option=com_easysocial';
         } else {
             $url = rtrim(JURI::root(), '/') . '/index.php/' . $language . '/?option=com_easysocial';
         }
     }
     $menu = JFactory::getApplication()->getmenu();
     if (!empty($menu)) {
         $item = $menu->getActive();
         if (isset($item->id)) {
             $url .= '&Itemid=' . $item->id;
         }
     }
     // Some SEF components tries to do a 301 redirect from non-www prefix to www prefix. Need to sort them out here.
     $currentURL = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
     if (!empty($currentURL)) {
         // When the url contains www and the current accessed url does not contain www, fix it.
         if (stristr($currentURL, 'www') === false && stristr($url, 'www') !== false) {
             $url = str_ireplace('www.', '', $url);
         }
         // When the url does not contain www and the current accessed url contains www.
         if (stristr($currentURL, 'www') !== false && stristr($url, 'www') === false) {
             $url = str_ireplace('://', '://www.', $url);
         }
     }
     return $url;
 }
Пример #3
0
 /**
  * Crops an image
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return	SocialImage
  */
 public function crop($top = null, $left = null, $width = null, $height = null)
 {
     // Use the current image that was already loaded
     $image = $this->image;
     // Get the width and height of the photo
     $imageWidth = $image->getWidth();
     $imageHeight = $image->getHeight();
     if (!is_null($top) && !is_null($left) && !is_null($width) && !is_null($height)) {
         $actualX = $imageWidth * $left;
         $actualY = $imageHeight * $top;
         $actualWidth = $imageWidth * $width;
         $actualHeight = $imageHeight * $height;
         // Now we'll need to crop the image
         $image->crop($actualX, $actualY, $actualWidth, $actualHeight);
     } else {
         // If caller didn't provide a crop ratio, we crop the avatar to square
         // Get the correct positions
         if ($imageWidth > $imageHeight) {
             $x = ($imageWidth - $imageHeight) / 2;
             $y = 0;
             $image->crop($x, $y, $imageHeight, $imageHeight);
         } else {
             $x = 0;
             $y = ($imageHeight - $imageWidth) / 2;
             $image->crop($x, $y, $imageWidth, $imageWidth);
         }
     }
     // We want to store the temporary image somewhere so that the image library could manipulate this file.
     $tmpImagePath = md5(FD::date()->toMySQL()) . $image->getExtension();
     $jConfig = FD::jconfig();
     // Save the temporary cropped image
     $tmpImagePath = $jConfig->getValue('tmp_path') . '/' . $tmpImagePath;
     // Now, we'll want to save this temporary image.
     $image->save($tmpImagePath);
     // Unset the image to free up some memory
     unset($image);
     // Reload the image again to get the correct resource pointing to the cropped image.
     $image = FD::image();
     $image->load($tmpImagePath);
     $this->image = $image;
     return $tmpImagePath;
 }
Пример #4
0
 /**
  * Displays the field input for user when they edit their account.
  *
  * @since	1.0
  * @access	public
  * @param	array
  * @param	SocialTableRegistration
  * @return	string	The html output.
  *
  * @author	Jason Rey <*****@*****.**>
  */
 public function onEdit(&$post, &$user, $errors)
 {
     $value = '';
     // Get value.
     $jConfig = FD::jconfig();
     $tmp = $jConfig->editor;
     if (!empty($tmp)) {
         $value = $tmp;
     }
     $tmp = $user->getParam('editor');
     if (!empty($tmp)) {
         $value = $tmp;
     }
     if (!empty($post[$this->inputName])) {
         $value = $post[$this->inputName];
     }
     // Set value.
     $this->set('value', $value);
     // Get editors.
     $editors = SocialEditorHelper::getEditors();
     // Set editors.
     $this->set('editors', $editors);
     // Check for errors.
     $error = $this->getError($errors);
     // Set errors.
     $this->set('error', $error);
     // Output the edit template.
     return $this->display();
 }
Пример #5
0
 /**
  * Sends an email out.
  *
  * @param	Array	An array of SocialTableMailer object.
  * @return	bool	The state of sending the mails out.
  */
 public function send($mails = array())
 {
     // Retrieve configs
     $config = FD::config();
     $jConfig = FD::jconfig();
     // If there's no email to send out, we should just return ehre.
     if (!$mails) {
         return false;
     }
     $defaultSenderName = $config->get('email.sender.name', $jConfig->getValue('fromname'));
     $defaultSenderEmail = $config->get('email.sender.email', $jConfig->getValue('mailfrom'));
     foreach ($mails as $mail) {
         // Set the sender's information
         $senderEmail = empty($mail->sender_email) ? $defaultSenderEmail : $mail->sender_email;
         $senderName = empty($mail->sender_name) ? $defaultSenderName : $mail->sender_name;
         $sender = array($senderEmail, $senderName);
         // Get the mailer
         $mailer = JFactory::getMailer();
         // Set the sender's info.
         $mailer->setSender($sender);
         // We need to load the language accordingly.
         $lang = FD::language();
         // If language is empty, we use the site's language instead
         $mailLanguage = !empty($mail->language) ? $mail->language : null;
         // Load site and admin languages
         $lang->load('joomla', JPATH_ROOT, $mailLanguage, true, true);
         $lang->loadSite($mail->language, true, true);
         $lang->loadAdmin($mail->language, true, true);
         // Split the template parts
         $templateParts = explode('/', $mail->template);
         // Get the location
         $templateLocation = array_shift($templateParts);
         // Set the reply to info.
         $replyToEmail = empty($mail->replyto_email) ? $jConfig->getValue('mailfrom') : $mail->replyto_email;
         $mailer->addReplyTo($replyToEmail);
         // Set the recipient properties.
         $mailer->addRecipient($mail->recipient_email);
         // Set mail's subject.
         $title = $this->translate($mail->title, $mail->params);
         $mailer->setSubject($title);
         $output = $this->getEmailContents($mail);
         if ($mail->html) {
             $mailer->isHtml(true);
         }
         // @debug
         // echo $output;exit;
         // Set the body output.
         $mailer->setBody($output);
         // @TODO: support attachments in the future.
         //$this->mailer->addAttachment();
         // Try to send the mail.
         $state = $mailer->send();
         // The mail might not be from the queue.
         if (!is_null($mail->id)) {
             // Set the state for this mail.
             $mail->state = $state;
             $mail->response = JText::_('COM_EASYSOCIAL_MAILER_MAIL_SENT_SUCCESSFULLY');
             // If there's an error, we want to know what went wrong
             if (!$state) {
                 $mail->response = JText::_('COM_EASYSOCIAL_MAILER_UNABLE_TO_SEND_EMAIL');
             }
             $mail->store();
         }
     }
     return true;
 }
Пример #6
0
 /**
  * START OF STRING RETURN FUNCTIONS
  */
 public function debug()
 {
     $jConfig = FD::jconfig();
     $prefix = $jConfig->getValue('dbprefix');
     $query = $this->buildSql();
     return str_ireplace('#__', $prefix, $query);
 }
Пример #7
0
 /**
  * Get the alias of the user.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAlias($withId = true)
 {
     $config = FD::config();
     // Default permalink to use.
     $name = $config->get('users.aliasName') == 'realname' ? $this->name : $this->username;
     // If sef is not enabled or running SH404, just return the ID-USERNAME prefix.
     jimport('joomla.filesystem.file');
     $jConfig = FD::jconfig();
     $sh404 = JFile::exists(JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.php');
     $mijoSef = JFile::exists(JPATH_ADMINISTRATOR . '/components/com_mijosef/mijosef.php');
     if (!$jConfig->getValue('sef') || $sh404) {
         return ($withId ? $this->id . ':' : '') . JFilterOutput::stringURLSafe($name);
     }
     $name = ($withId ? $this->id . ':' : '') . $name;
     // Check if the permalink is set
     if ($this->permalink && !empty($this->permalink)) {
         $name = $this->permalink;
         if ($mijoSef) {
             return ($withId ? $this->id . ':' : '') . JFilterOutput::stringURLSafe($name);
         }
     }
     // If alias exists and permalink doesn't we use the alias
     if ($this->alias && !empty($this->alias) && !$this->permalink) {
         $name = ($withId ? $this->id . ':' : '') . JFilterOutput::stringURLUnicodeSlug($this->alias);
     }
     // If the name is in the form of an e-mail address, fix it here by using the ID:permalink syntax
     if (JMailHelper::isEmailAddress($name)) {
         return ($withId ? $this->id . ':' : '') . JFilterOutput::stringURLSafe($name);
     }
     // Ensure that the name is a safe url.
     $name = JFilterOutput::stringURLSafe($name);
     return $name;
 }
Пример #8
0
echo JText::_('COM_EASYSOCIAL_FRIENDS_INVITE_EMAIL_ADDRESSES_NOTE');
?>
					</div>
				</div>
			</div>


			<div class="control-group">
				<label class="control-label"><?php 
echo JText::_('COM_EASYSOCIAL_FRIENDS_INVITE_MESSAGE');
?>
: </label>

				<div class="controls">
					<?php 
echo $editor->display('message', JText::sprintf('COM_EASYSOCIAL_FRIENDS_INVITE_MESSAGE_CONTENT', FD::jconfig()->sitename), '100%', '200', '10', '5', array('image', 'pagebreak', 'ninjazemanta'), null, 'com_easysocial');
?>
				</div>

				<div class="controls">
					<div class="help-block small mt-5">
						<strong><?php 
echo JText::_('COM_EASYSOCIAL_NOTE');
?>
:</strong> <?php 
echo JText::_('COM_EASYSOCIAL_FRIENDS_INVITE_MESSAGE_NOTE');
?>
					</div>
				</div>
			</div>
Пример #9
0
 /**
  * Overrides the parent's implementation of store
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function store($pk = null)
 {
     $isNew = !$this->id;
     // Save this into the table first
     parent::store($pk);
     // Add this into the mail queue
     if ($isNew) {
         $jconfig = FD::jconfig();
         $mailer = FD::mailer();
         $template = $mailer->getTemplate();
         $sender = FD::user($this->user_id);
         $params = new stdClass();
         $params->senderName = $sender->getName();
         $params->message = $this->message;
         $params->siteName = $jconfig->getValue('sitename');
         $params->manageAlerts = false;
         $params->link = FRoute::registration(array('invite' => $this->id, 'external' => true));
         $template->setSender($sender->getName(), $sender->email);
         $template->setReplyTo($sender->email);
         $template->setRecipient('', $this->email);
         $template->setTitle(JText::sprintf('COM_EASYSOCIAL_FRIENDS_INVITE_MAIL_SUBJECT', $jconfig->getValue('sitename')));
         $template->setTemplate('site/friends/invite', $params);
         $mailer->create($template);
         // Assign points to the user that created this invite
         $points = FD::points();
         $points->assign('friends.invite', 'com_easysocial', $this->user_id);
     }
 }
Пример #10
0
 /**
  * Processes the installation package from directory method.
  *
  * @since	1.0
  * @access	public
  * @return	null
  *
  * @author	Mark Lee <*****@*****.**>
  **/
 public function installFromDirectory($path = '')
 {
     // Check for request forgeries.
     FD::checkToken();
     if (empty($path)) {
         $path = JRequest::getVar('package-directory', '');
     }
     $view = $this->getCurrentView();
     $jConfig = FD::jconfig();
     $info = FD::info();
     // Try to detect if the temporary path is the same as the default path.
     if ($path == $jConfig->getValue('tmp_path') || empty($path)) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_INSTALLER_PLEASE_SPECIFY_DIRECTORY'), SOCIAL_MSG_ERROR);
         return $view->call('install');
     }
     // Retrieve the installer library.
     $installer = FD::get('Installer');
     // Try to load the installation from path.
     $state = $installer->load($path);
     // If there's an error, we need to log it down.
     if (!$state) {
         FD::logError(__FILE__, __LINE__, 'APPS: Unable to install apps from directory ' . $path . ' because of the error ' . $installer->getError());
         $view->setMessage($installer->getError(), SOCIAL_MSG_ERROR);
         return $view->call('install');
     }
     // Let's try to install it now.
     $app = $installer->install();
     // If there's an error installing, log this down.
     if ($app === false) {
         FD::logError(__FILE__, __LINE__, 'APPS: Unable to install apps from directory ' . $path . ' because of the error ' . $installer->getError());
         $view->setMessage($installer->getError(), SOCIAL_MSG_ERROR);
         return $view->call('install');
     }
     return $view->installCompleted($app);
 }
Пример #11
0
 /**
  * Get's a list of folder and determines if the folder is writable.
  *
  * @since	1.0
  * @access	public
  * @return	Array	An array of stdClass objects.
  *
  */
 public function getDirectoryPermissions()
 {
     $jConfig = FD::jconfig();
     // Get a list of folders.
     $folders = array($jConfig->getValue('tmp_path'), SOCIAL_MEDIA, SOCIAL_APPS . '/fields', SOCIAL_APPS . '/user');
     $directories = array();
     foreach ($folders as $folder) {
         $obj = new stdClass();
         $obj->path = $folder;
         $obj->writable = is_writable($folder);
         $directories[] = $obj;
     }
     return $directories;
 }
Пример #12
0
 public function bind($data, $ignore = array())
 {
     $state = parent::bind($data);
     $jConfig = FD::jconfig();
     // @TODO: Admin can create multiple emails from in the future.
     if (is_null($this->sender_name)) {
         $this->sender_name = $jConfig->getValue('fromname');
     }
     if (is_null($this->sender_email)) {
         $this->sender_email = $jConfig->getValue('mailfrom');
     }
     if (is_null($this->created)) {
         $this->created = FD::get('Date')->toMySQL();
     }
     if (is_null($this->priority)) {
         $this->priority = SOCIAL_MAILER_PRIORITY_NORMAL;
     }
     return $state;
 }