示例#1
0
 public function getIconImage()
 {
     // This let's us know the type of folder we should lookup to
     $place = JRequest::getString('place');
     // Flat list can only be searched from the root.
     $source = JRequest::getVar('path');
     // @task: Create the media object.
     $media = new EasyBlogMediaManager();
     // @task: Let's find the exact path first as there could be 3 possibilities here.
     // 1. Shared folder
     // 2. User folder
     $absolutePath = EasyBlogMediaManager::getAbsolutePath($source, $place);
     $absoluteURI = EasyBlogMediaManager::getAbsoluteURI($source, $place);
     // @task: Test if the thumbnail exists in the system.
     $basePath = dirname($absolutePath);
     $fileName = basename($absolutePath);
     $iconFileName = EBLOG_SYSTEM_VARIATION_PREFIX . '_icon_' . $fileName;
     $iconFilePath = $basePath . DIRECTORY_SEPARATOR . $iconFileName;
     // @task: Create the thumbnail
     if (!JFile::exists($iconFilePath)) {
         $media->createThumbnail($fileName, $absolutePath, $iconFilePath);
     }
     $info = getimagesize($iconFilePath);
     $this->output($info['mime'], $iconFilePath);
 }
示例#2
0
文件: folder.php 项目: Tommar/vino2
 public function getContents($foldersOnly = false, $paginated = false)
 {
     $folderName = $this->getTitle();
     $uri = $this->baseURI . '/' . ltrim($folderName, '/\\');
     $relativePath = $this->getRelativePath();
     $media = new EasyBlogMediaManager();
     $contents = $media->getItems($this->file, $uri, $relativePath, $this->includeVariation, false, array('index.html', '.svn', 'CVS', '.DS_Store', '__MACOSX'), $foldersOnly, $this->place, $paginated)->toArray();
     return $contents;
 }
示例#3
0
 /**
  * Retrieves a list of items from a given uri
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getItems($uri, $includeVariations = false)
 {
     // List down posts from the site
     $model = EB::model('MediaManager');
     $posts = $model->getPosts();
     // Get path and folder
     $folder = $this->getFolderItem($uri);
     // Get the absolute path to the main "articles" folder
     $folderPath = EasyBlogMediaManager::getPath($folder->uri);
     if (!$posts) {
         return $folder;
     }
     // Filegroup is the array where files are stored.
     // Sort arrays are used to speed up file sorting.
     $filegroup = EasyBlogMediaManager::filegroup();
     // The strategy used here is to use a single loop that build:
     // - data that is ready-to-use
     // - sort arrays so sorting becomes cheap.
     // - variations
     $variations = array();
     $total = 0;
     foreach ($posts as $post) {
         // Get the folder path of the article
         $articlePath = $folderPath . '/' . $post->id;
         // Get the uri for the article
         $uri = 'post:' . $post->id;
         $items = parent::getItems($uri);
         $filegroup['folder'][] = $items;
         $total++;
     }
     // Set the folder contents
     $folder->contents = $filegroup;
     $folder->total = $total;
     return $folder;
 }
示例#4
0
文件: media.php 项目: Tommar/vino2
 public function upload()
 {
     $app = JFactory::getApplication();
     $my = JFactory::getUser();
     $cfg = EasyBlogHelper::getConfig();
     $acl = EasyBlogACLHelper::getRuleSet();
     // @rule: Only allowed users are allowed to upload images.
     if ($my->id == 0 || empty($acl->rules->upload_image)) {
         $sessionid = JRequest::getVar('sessionid');
         if ($sessionid) {
             $session = JTable::getInstance('Session');
             $session->load($sessionid);
             if (!$session->userid) {
                 $this->output($this->getMessageObj(EBLOG_MEDIA_SECURITY_ERROR, JText::_('COM_EASYBLOG_NOT_ALLOWED')));
             }
             $my = JFactory::getUser($session->userid);
         } else {
             $this->output($this->getMessageObj(EBLOG_MEDIA_SECURITY_ERROR, JText::_('COM_EASYBLOG_NOT_ALLOWED')));
         }
     }
     // Let's get the path for the current request.
     $file = JRequest::getVar('file', '', 'FILES', 'array');
     $place = JRequest::getVar('place');
     // The user might be from a subfolder?
     $source = urldecode(JRequest::getVar('path', '/'));
     // @task: Let's find the exact path first as there could be 3 possibilities here.
     // 1. Shared folder
     // 2. User folder
     $absolutePath = EasyBlogMediaManager::getAbsolutePath($source, $place);
     $absoluteURI = EasyBlogMediaManager::getAbsoluteURI($source, $place);
     // @TODO: Test if user is allowed to upload this image
     $message = $this->getMessageObj();
     $allowed = EasyImageHelper::canUploadFile($file, $message);
     if ($allowed !== true) {
         return $this->output($message);
     }
     $media = new EasyBlogMediaManager();
     $result = $media->upload($absolutePath, $absoluteURI, $file, $source, $place);
     // This should be an error if the $result is not an MMIM object.
     if (!is_object($result)) {
         $message = $this->getMessageObj('404', $result);
     } else {
         $message = $this->getMessageObj(EBLOG_MEDIA_UPLOAD_SUCCESS, JText::_('COM_EASYBLOG_IMAGE_MANAGER_UPLOAD_SUCCESS'), $result);
     }
     return $this->output($message);
 }
示例#5
0
 public function post()
 {
     //old  code
     /*$controller = new EasyBlogControllerMedia;
     		$op = $controller->upload();
     		*/
     $input = JFactory::getApplication()->input;
     $log_user = $this->plugin->get('user')->id;
     $res = new stdClass();
     // Let's get the path for the current request.
     $file = JRequest::getVar('file', '', 'FILES', 'array');
     if ($file['name']) {
         $place = 'user:'******'user')->id;
         // The user might be from a subfolder?
         $source = urldecode('/' . $file['name']);
         // @task: Let's find the exact path first as there could be 3 possibilities here.
         // 1. Shared folder
         // 2. User folder
         //$absolutePath 		= EasyBlogMediaManager::getAbsolutePath( $source , $place );
         //$absoluteURI		= EasyBlogMediaManager::getAbsoluteURI( $source , $place );
         $absolutePath = EasyBlogMediaManager::getPath($source);
         $absoluteURI = EasyBlogMediaManager::getUrl($source);
         $allowed = EasyImageHelper::canUploadFile($file, $message);
         if ($allowed !== true) {
             $res->status = 0;
             $res->message = 'Upload is not allowed';
             return $res;
         }
         $media = new EasyBlogMediaManager();
         $upload_result = $media->upload($absolutePath, $absoluteURI, $file, $source, $place);
         //adjustment
         $upload_result->key = $place . $source;
         $upload_result->group = 'files';
         $upload_result->parentKey = $place . '|/';
         $upload_result->friendlyPath = 'My Media/' . $source;
         unset($upload_result->variations);
         $this->plugin->setResponse($upload_result);
         return $upload_result;
     } else {
         $this->plugin->setResponse($this->getErrorResponse(404, __FUNCTION__ . ' Upload unsuccessfull.'));
     }
 }
示例#6
0
 /**
  * Generates a skeleton folder object
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function folder($uri, $contents = array())
 {
     $folder = new stdClass();
     $folder->place = $uri;
     $folder->title = EasyBlogMediaManager::getPlaceName($uri);
     $folder->url = $uri;
     $folder->uri = $uri;
     $folder->key = self::getKey($uri);
     $folder->type = 'folder';
     $folder->icon = '';
     $folder->root = true;
     $folder->scantime = 0;
     $folder->contents = $contents;
     return $folder;
 }
示例#7
0
 /**
  * Retrieves a list of items from a given uri
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getItems($uri, $includeVariations = false)
 {
     // Retrieve a list of authors from the site.
     $model = EB::model('Blogger');
     $result = $model->getBloggers();
     // Get path and folder
     $folder = $this->getFolderItem($uri);
     // Get the absolute path to the main "articles" folder
     $folderPath = EasyBlogMediaManager::getPath($folder->uri);
     if (!$result) {
         return $folder;
     }
     // Filegroup is the array where files are stored.
     // Sort arrays are used to speed up file sorting.
     $filegroup = EasyBlogMediaManager::filegroup();
     // The strategy used here is to use a single loop that build:
     // - data that is ready-to-use
     // - sort arrays so sorting becomes cheap.
     // - variations
     $variations = array();
     $total = 0;
     // Map them with the profile table
     $authors = array();
     if ($result) {
         foreach ($result as $row) {
             $author = EB::user($row->id);
             $authorPath = $folderPath . '/' . $row->id;
             $uri = 'user:'******'folder'][] = $items;
             $total++;
         }
     }
     // Set the folder contents
     $folder->contents = $filegroup;
     $folder->total = $total;
     return $folder;
 }
示例#8
0
 function _migrateBloggerImage($image, $userid, $content)
 {
     jimport('joomla.utilities.error');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $config = EasyBlogHelper::getConfig();
     $main_image_path = $config->get('main_image_path');
     $main_image_path = rtrim($main_image_path, '/');
     $rel_upload_path = $main_image_path . '/' . $userid;
     $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . str_ireplace('/', DIRECTORY_SEPARATOR, $main_image_path . DIRECTORY_SEPARATOR . $userid);
     $folder = JPath::clean($userUploadPath);
     $dir = $userUploadPath . DIRECTORY_SEPARATOR;
     $tmp_dir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
     if (!JFolder::exists($dir)) {
         JFolder::create($dir);
     }
     //now let get the image from remove url.
     $segments = explode('/', $image);
     $fileName = $segments[count($segments) - 1];
     $fileName = JFile::makesafe($fileName);
     $tmpFileName = $tmp_dir . $fileName;
     $file['name'] = $fileName;
     $file['tmp_name'] = $tmpFileName;
     // write to JOOMLA tmp folder
     file_put_contents($tmpFileName, file_get_contents($image));
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
     $media = new EasyBlogMediaManager();
     $result = $media->upload($file, 'user:'******'tmp_name']);
     if (isset($result->type)) {
         $relativeImagePath = $rel_upload_path . '/' . $file['name'];
         // lets replace the image from the content to this uploaded one.
         $content = str_replace($image, $relativeImagePath, $content);
     }
     return $content;
 }
示例#9
0
        </div>
    </div>

    <div class="eb-composer-viewport push-bottom" data-scrolly="y">
        <div class="eb-composer-viewport-content" data-scrolly-viewport>

            <div class="eb-mm-folder-content-panel">

                <div class="eb-mm-filegroup type-folder" data-eb-mm-filegroup>
                    <div class="eb-mm-filegroup-body">
                        <div class="eb-mm-filelist view-list">
                            <?php 
foreach ($authors as $author) {
    ?>
                            <div data-type="user" data-key="<?php 
    echo EasyBlogMediaManager::getKey('user:' . $author->id);
    ?>
" data-eb-mm-file="" class="eb-mm-file type-folder is-search-result">
                                <img src="<?php 
    echo $author->getAvatar();
    ?>
" width="16" />&nbsp;
                                <span data-eb-mm-file-title><?php 
    echo $author->getName();
    ?>
</span>
                                <b class="fa fa-angle-right"></b>
                            </div>
                            <?php 
}
?>
示例#10
0
文件: xmlrpc.php 项目: Tommar/vino2
 function newMediaObject($blogid, $username, $password, $file)
 {
     jimport('joomla.utilities.error');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     global $xmlrpcerruser, $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue;
     EasyBlogXMLRPCHelper::loginUser($username, $password);
     $user = JUser::getInstance($username);
     $acl = EasyBlogACLHelper::getRuleSet($user->id);
     if (empty($acl->rules->upload_image)) {
         return new xmlrpcresp(0, $xmlrpcerruser + 2, JText::_('YOU DO NOT HAVE IMAGE UPLOAD RIGHT'));
     }
     $config = EasyBlogHelper::getConfig();
     $main_image_path = $config->get('main_image_path');
     $main_image_path = rtrim($main_image_path, '/');
     $rel_upload_path = $main_image_path . '/' . $user->id;
     $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . str_ireplace('/', DIRECTORY_SEPARATOR, $main_image_path . DIRECTORY_SEPARATOR . $user->id);
     $folder = JPath::clean($userUploadPath);
     $dir = $userUploadPath . DIRECTORY_SEPARATOR;
     $tmp_dir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
     if (!JFolder::exists($dir)) {
         JFolder::create($dir);
     }
     if (strpos($file['name'], '/') !== FALSE) {
         $file['name'] = substr($file['name'], strrpos($file['name'], '/') + 1);
     } elseif (strpos($file['name'], '\\' !== FALSE)) {
         $file['name'] = substr($file['name'], strrpos($file['name'], '\\') + 1);
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file['name'] = JFile::makesafe($file['name']);
     //$file['name']	= substr($file['name'], 0, -4) . rand() . '.' . JFile::getExt($file['name']);
     $file['name'] = substr($file['name'], 0, -4) . '.' . JFile::getExt($file['name']);
     // write to temp folder
     $file['tmp_name'] = $tmp_dir . $file['name'];
     @JFile::write($file['tmp_name'], $file['bits']);
     $file['size'] = 0;
     $error = '';
     $allowed = EasyImageHelper::canUploadFile($file);
     if ($allowed !== true) {
         @JFile::delete($file['tmp_name']);
         return new xmlrpcresp(0, $xmlrpcerruser + 1, 'The file is not valid');
     }
     // @JFile::write( $dir . $file['name'], $file['bits']);
     // @task: Ensure that images goes through the same resizing format when uploading via media manager.
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
     $media = new EasyBlogMediaManager();
     $result = $media->upload($dir, $userUploadPath, $file, '/', 'user');
     @JFile::delete($file['tmp_name']);
     $file['name'] = EasyBlogXMLRPCHelper::cleanImageName($file['name']);
     $fileUrl = rtrim(JURI::root(), '/') . '/' . $rel_upload_path . '/' . $file['name'];
     return new xmlrpcresp(new xmlrpcval(array('url' => new xmlrpcval($fileUrl)), 'struct'));
 }
示例#11
0
 /**
  * Returns a list of JomSocial albums and photos
  *
  * @access	public
  * @param	null
  * @return	null
  */
 public function listFlickrItems()
 {
     $ajax = EasyBlogHelper::getHelper('Ajax');
     $cfg = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $profile = EasyBlogHelper::getTable('Profile');
     $profile->load($my->id);
     // Show an error message if someone tries to force their way in.
     if (!$cfg->get('layout_media_flickr')) {
         return $ajax->fail(JText::_('COM_EASYBLOG_THIS_FEATURED_IS_DISABLED'));
     }
     // @rule: Test if the user is really logged in or not.
     if ($my->id <= 0) {
         return $ajax->fail(JText::_('COM_EASYBLOG_THIS_FEATURED_IS_DISABLED'));
     }
     // @rule: Test if the user is already associated with Flickr
     $oauth = EasyBlogHelper::getTable('Oauth');
     $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
     if (!$associated) {
         return $ajax->fail(JText::_('Please associate your account with Flickr first.'));
     }
     $path = str_ireplace(array('/', '\\'), '', JRequest::getVar('path'));
     // If fromPath is passed in the query, we know that the user is querying an item instead.
     if (!empty($path)) {
         $media = new EasyBlogMediaManager(EBLOG_MEDIA_SOURCE_FLICKR);
         $item = $media->getItem($path, '')->toArray();
         return $ajax->success($item);
     }
     $media = new EasyBlogMediaManager(EBLOG_MEDIA_SOURCE_FLICKR);
     $items = $media->getItems('', '')->toArray();
     return $ajax->success($items);
 }
示例#12
0
// User variations
foreach ($file->variations as $key => $variation) {
    // Skip non-user variations
    if (!preg_match("/^user/ui", $key)) {
        continue;
    }
    ?>
        <div class="eb-list-item eb-mm-variation-item"
             data-eb-mm-variation-item
             data-key="<?php 
    echo $key;
    ?>
"
             data-size="<?php 
    if (isset($variation->size)) {
        echo EasyBlogMediaManager::formatSize($variation->size);
    }
    ?>
">
            <div>
                <span><?php 
    echo ucfirst($variation->name);
    ?>
</span>
                <?php 
    if (isset($variation->width) && isset($variation->height)) {
        ?>
                <small><?php 
        echo $variation->width . 'x' . $variation->height;
        ?>
</small>
示例#13
0
 /**
  * Handles photo uploads via the microblogging page.
  *
  * @access	public
  * @param	null
  **/
 public function uploadPhoto()
 {
     $my = JFactory::getUser();
     $config = EasyBlogHelper::getConfig();
     if (!$my->id) {
         return $this->outputJSON(array('type' => 'error', 'message' => JText::_('You need to be logged in first')));
     }
     $file = JRequest::getVar('photo-source', '', 'files', 'array');
     if (!isset($file['tmp_name'])) {
         return $this->outputJSON(array('type' => 'error', 'message' => JText::_('There is an error when uploading the image to the server. Perhaps the temporary folder <strong>upload_tmp_path</strong> was not configured correctly.')));
     }
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'image.php';
     // @rule: Photos should be stored in the user's home folder by default.
     $imagePath = str_ireplace(array("/", "\\"), DIRECTORY_SEPARATOR, rtrim($config->get('main_image_path'), '/'));
     $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $imagePath . DIRECTORY_SEPARATOR . $my->id);
     $storageFolder = JPath::clean($userUploadPath);
     // @rule: Get the image URI
     $imageURI = rtrim(str_ireplace('\\', '/', $config->get('main_image_path')), '/') . '/' . $my->id;
     $imageURI = rtrim(JURI::root(), '/') . '/' . $imageURI;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Make the filename safe
     jimport('joomla.filesystem.file');
     $file['name'] = JFile::makeSafe($file['name']);
     // After making the filename safe, and the first character begins with . , we need to rename this file. Perhaps it's a unicode character
     $file['name'] = trim($file['name']);
     $filename = strtolower($file['name']);
     if (strpos($filename, '.') === false) {
         $filename = EB::date()->toFormat("%Y%m%d-%H%M%S") . '.' . $filename;
     } else {
         if (strpos($filename, '.') == 0) {
             $filename = EB::date()->toFormat("%Y%m%d-%H%M%S") . $filename;
         }
     }
     // remove the spacing in the filename.
     $filename = str_ireplace(' ', '-', $filename);
     $storagePath = JPath::clean($storageFolder . DIRECTORY_SEPARATOR . $filename);
     // 		// @task: try to rename the file if another image with the same name exists
     // 		if( JFile::exists( $storagePath ) )
     // 		{
     // 			$i	= 1;
     // 			while( JFile::exists( $storagePath ) )
     // 			{
     // 				$tmpName	= $i . '_' . EB::date()->toFormat( "%Y%m%d-%H%M%S" ) . '_' . $filename;
     // 				$storagePath	= JPath::clean( $storageFolder . DIRECTORY_SEPARATOR . $tmpName );
     // 				$i++;
     // 			}
     // 			$filename	= $tmpName;
     // 		}
     $allowed = EasyImageHelper::canUploadFile($file);
     if ($allowed !== true) {
         return $this->outputJSON(array('type' => 'error', 'message' => $allowed));
     }
     // @rule: Pass to EasyBlogImageHelper to upload the image
     // $result		= EasyImageHelper::upload( $storageFolder , $filename , $file , $imageURI , $storagePath );
     // 		// @task: Ensure that images goes through the same resizing format when uploading via media manager.
     $result = new stdClass();
     $result->message = JText::_('COM_EASYBLOG_IMAGE_MANAGER_UPLOAD_ERROR');
     $result->item = '';
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
     $media = new EasyBlogMediaManager();
     $uploaded = $media->upload($file, 'user:'******'COM_EASYBLOG_IMAGE_MANAGER_UPLOAD_SUCCESS');
         $result->item = $uploaded;
     } else {
         // failed.
         $result->item->url = '';
     }
     return $this->outputJSON(array('type' => 'success', 'message' => $result->message, 'uri' => $result->item->url));
 }
示例#14
0
 public function processMailbox()
 {
     /*
      * Check enabled
      */
     $config = EasyBlogHelper::getConfig();
     $debug = JRequest::getBool('debug', false);
     if (!$config->get('main_remotepublishing_mailbox') && !$config->get('main_comment_email')) {
         return;
     }
     /*
      * Check Prerequisites setting
      */
     $userid = 0;
     if ($config->get('main_remotepublishing_mailbox_userid') == 0 && !$config->get('main_remotepublishing_mailbox_syncuser')) {
         echo 'Mailbox: Unspecified default user id.' . "<br />\n";
         return false;
     }
     /*
      * Check time interval
      */
     $interval = (int) $config->get('main_remotepublishing_mailbox_run_interval');
     $nextrun = (int) $config->get('main_remotepublishing_mailbox_next_run');
     $nextrun = EasyBlogHelper::getDate($nextrun)->toUnix();
     $timenow = EasyBlogHelper::getDate()->toUnix();
     if ($nextrun !== 0 && $timenow < $nextrun) {
         if (!$debug) {
             echo 'time now: ' . EasyBlogHelper::getDate($timenow)->toMySQL() . "<br />\n";
             echo 'next email run: ' . EasyBlogHelper::getDate($nextrun)->toMySQL() . "<br />\n";
             return;
         }
     }
     $txOffset = EasyBlogDateHelper::getOffSet();
     $newnextrun = EasyBlogHelper::getDate('+ ' . $interval . ' minutes', $txOffset)->toUnix();
     // use $configTable to avoid variable name conflict
     $configTable = EasyBlogHelper::getTable('configs');
     $configTable->load('config');
     $parameters = EasyBlogHelper::getRegistry($configTable->params);
     $parameters->set('main_remotepublishing_mailbox_next_run', $newnextrun);
     $configTable->params = $parameters->toString('ini');
     $configTable->store();
     /*
      * Connect to mailbox
      */
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'mailbox.php';
     $mailbox = new EasyblogMailbox();
     if (!$mailbox->connect()) {
         $mailbox->disconnect();
         echo 'Mailbox: Could not connect to mailbox.';
         return false;
     }
     /*
      * Get data from mailbox
      */
     $total_mails = $mailbox->getMessageCount();
     if ($total_mails < 1) {
         // No mails in mailbox
         $mailbox->disconnect();
         echo 'Mailbox: No emails found.';
         return false;
     }
     // Let's get the correct mails
     $prefix = $config->get('main_remotepublishing_mailbox_prefix');
     $search_criteria = 'UNSEEN';
     if (!empty($prefix)) {
         $search_criteria .= ' SUBJECT "' . $prefix . '"';
     }
     $sequence_list = $mailbox->searchMessages($search_criteria);
     if ($sequence_list === false) {
         // Email with matching subject not found
         $mailbox->disconnect();
         echo 'Mailbox: No matching mails found. ' . $search_criteria;
         echo $debug ? ' criteria: ' . $search_criteria . ' ' : '';
         return false;
     }
     /*
      * Found the mails according to prefix,
      * Let's process each of them
      */
     $total = 0;
     $enable_attachment = $config->get('main_remotepublishing_mailbox_image_attachment');
     $format = $config->get('main_remotepublishing_mailbox_format');
     $limit = $config->get('main_remotepublishing_mailbox_fetch_limit');
     // there's not limit function for imap, so we work around with the array
     // get the oldest message first
     sort($sequence_list);
     $sequence_list = array_slice($sequence_list, 0, $limit);
     foreach ($sequence_list as $sequence) {
         // first, extract from the header
         $msg_info = $mailbox->getMessageInfo($sequence);
         if ($msg_info === false) {
             echo 'Mailbox: Could not get message header.';
             echo $debug ? ' sequence:' . $sequence . ' ' : '';
             continue;
         }
         $uid = $msg_info->message_id;
         $date = $msg_info->MailDate;
         $udate = $msg_info->udate;
         $size = $msg_info->Size;
         $subject = $msg_info->subject;
         $from = '';
         if (isset($msg_info->from)) {
             $senderInfo = $msg_info->from[0];
             if (!empty($senderInfo->mailbox) && !empty($senderInfo->host)) {
                 $from = $senderInfo->mailbox . '@' . $senderInfo->host;
             }
         }
         if (empty($from)) {
             $from = $msg_info->fromemail;
         }
         // @rule: Try to map the sender's email to a user email on the site.
         if ($config->get('main_remotepublishing_mailbox_syncuser')) {
             $db = EasyBlogHelper::db();
             $query = 'SELECT ' . $db->nameQuote('id') . ' FROM ' . $db->nameQuote('#__users') . ' ' . 'WHERE ' . $db->nameQuote('email') . '=' . $db->Quote($from);
             $db->setQuery($query);
             $userid = $db->loadResult();
             // Check if they have permissions
             if ($userid) {
                 $acl = EasyBlogACLHelper::getRuleSet($userid);
                 if (!$acl->rules->add_entry) {
                     continue;
                 }
             }
         } else {
             // sync user email is not require. use the default selected user.
             $userid = $config->get('main_remotepublishing_mailbox_userid');
         }
         if ($userid == 0) {
             echo 'Mailbox: Unable to detect the user based on the email ' . $from . "<br />\n";
             echo $debug ? ' sequence:' . $sequence . ' ' : '';
             continue;
         }
         $date = EasyBlogHelper::getDate($date);
         $date = $date->toMySQL();
         $subject = str_ireplace($prefix, '', $subject);
         $filter = JFilterInput::getInstance();
         $subject = $filter->clean($subject, 'string');
         // @task: If subject is empty, we need to append this with a temporary string. Otherwise user can't edit it from the back end.
         if (empty($subject)) {
             $subject = JText::_('COM_EASYBLOG_MICROBLOG_EMPTY_SUBJECT');
         }
         // filter email according to the whitelist
         $filter = JFilterInput::getInstance();
         $whitelist = $config->get('main_remotepublishing_mailbox_from_whitelist');
         $whitelist = $filter->clean($whitelist, 'string');
         $whitelist = trim($whitelist);
         if (!empty($whitelist)) {
             // Ok. I bluffed we only accept comma seperated values. *wink*
             $pattern = '([\\w\\.\\-]+\\@(?:[a-z0-9\\.\\-]+\\.)+(?:[a-z0-9\\-]{2,4}))';
             preg_match_all($pattern, $whitelist, $matches);
             $emails = $matches[0];
             if (!in_array($from, $emails)) {
                 echo 'Mailbox: Message sender is block: #' . $sequence . ' ' . $subject;
                 continue;
             }
         }
         // this is the magic
         $message = new EasyblogMailboxMessage($mailbox->stream, $sequence);
         $message->getMessage();
         $html = $message->getHTML();
         $plain = $message->getPlain();
         $plain = nl2br($plain);
         $body = $format == 'html' ? $html : $plain;
         $body = $body ? $body : $plain;
         // If plain text is empty, just fall back to html
         if (empty($plain)) {
             $body = nl2br(strip_tags($html));
         }
         $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1);
         // JFilterInput doesn't strip css tags
         $body = preg_replace("'<style[^>]*>.*?</style>'si", '', $body);
         $body = $safeHtmlFilter->clean($body, 'html');
         $body = trim($body);
         $attachments = array();
         if ($enable_attachment) {
             $attachments = $message->getAttachment();
             // process attached images
             if (!empty($attachments)) {
                 $config = EasyBlogHelper::getConfig();
                 $main_image_path = $config->get('main_image_path');
                 $main_image_path = rtrim($main_image_path, '/');
                 $rel_upload_path = $main_image_path . '/' . $userid;
                 $userUploadPath = JPATH_ROOT . DIRECTORY_SEPARATOR . $main_image_path . DIRECTORY_SEPARATOR . $userid;
                 $userUploadPath = JPath::clean($userUploadPath);
                 $dir = $userUploadPath . DIRECTORY_SEPARATOR;
                 $tmp_dir = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
                 $uri = JURI::base() . $main_image_path . '/' . $userid . '/';
                 if (!JFolder::exists($dir)) {
                     JFolder::create($dir);
                 }
                 foreach ($attachments as $attachment) {
                     // clean up file name
                     if (strpos($attachment['name'], '/') !== FALSE) {
                         $attachment['name'] = substr($attachment['name'], strrpos($attachment['name'], '/') + 1);
                     } elseif (strpos($attachment['name'], '\\' !== FALSE)) {
                         $attachment['name'] = substr($attachment['name'], strrpos($attachment['name'], '\\') + 1);
                     }
                     // @task: check if the attachment has file extension. ( assuming is images )
                     $imgExts = array('jpg', 'png', 'gif', 'JPG', 'PNG', 'GIF', 'jpeg', 'JPEG');
                     $imageSegment = explode('.', $attachment['name']);
                     if (!in_array($imageSegment[count($imageSegment) - 1], $imgExts)) {
                         $attachment['name'] = $attachment['name'] . '.jpg';
                     }
                     // @task: Store the file into a temporary location first.
                     $attachment['tmp_name'] = $tmp_dir . $attachment['name'];
                     JFile::write($attachment['tmp_name'], $attachment['data']);
                     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
                     // @task: Ensure that images goes through the same resizing format when uploading via media manager.
                     $media = new EasyBlogMediaManager();
                     $result = $media->upload($dir, $uri, $attachment, '/', 'user');
                     // get the image file name and path
                     if (is_object($result) && property_exists($result, 'title')) {
                         $atmTitle = $result->title;
                         $atmURL = $result->url;
                     } else {
                         $atmTitle = $attachment['name'];
                         $atmURL = $uri . $attachment['name'];
                     }
                     // @task: Once the attachment is processed, delete the temporary file.
                     JFile::delete($attachment['tmp_name']);
                     // now we need to replace the img tag in the email which the source is an attachment id :(
                     $attachId = $attachment['id'];
                     if (!empty($attachId)) {
                         $attachId = str_replace('<', '', $attachId);
                         $attachId = str_replace('>', '', $attachId);
                         $imgPattern = array('/<div><img[^>]*src="[A-Za-z0-9:^>]*' . $attachId . '"[^>]*\\/><\\/div>/si', '/<img[^>]*src="[A-Za-z0-9:^>]*' . $attachId . '"[^>]*\\/>/si');
                         $imgReplace = array('', '');
                         $body = preg_replace($imgPattern, $imgReplace, $body);
                     }
                     // insert image into blog post
                     $body .= '<p><a class="easyblog-thumb-preview" href="' . $atmURL . '" title="' . $atmTitle . '"><img width="' . $config->get('main_thumbnail_width') . '" title="' . $atmTitle . '." alt="" src="' . $atmURL . '" /></a></p>';
                 }
             }
         }
         if ($format == 'plain') {
             $body = nl2br($body);
         }
         // tidy up the content so that the content do not contain incomplete html tag.
         $body = EasyBlogHelper::getHelper('string')->tidyHTMLContent($body);
         $type = $config->get('main_remotepublishing_mailbox_type');
         // insert $body, $subject, $from, $date
         $blog = EasyBlogHelper::getTable('Blog', 'Table');
         // @task: Store the blog post
         $blog->set('title', $subject);
         $blog->set('permalink', EasyBlogHelper::getPermalink($blog->title));
         $blog->set('source', 'email');
         $blog->set('created_by', $userid);
         $blog->set('created', $date);
         $blog->set('modified', $date);
         $blog->set('publish_up', $date);
         $blog->set($type, $body);
         $blog->set('category_id', $config->get('main_remotepublishing_mailbox_categoryid'));
         $blog->set('published', $config->get('main_remotepublishing_mailbox_publish'));
         $blog->set('frontpage', $config->get('main_remotepublishing_mailbox_frontpage'));
         $blog->set('send_notification_emails', $config->get('main_remotepublishing_mailbox_publish'));
         $blog->set('issitewide', true);
         // @task: Set the blog's privacy here.
         $blog->set('private', $config->get('main_remotepublishing_mailbox_privacy'));
         // Store the blog post
         if (!$blog->store()) {
             echo 'Mailbox: Message store failed. > ' . $subject . ' :: ' . $blog->getError();
             continue;
         }
         if ($mailbox->service == 'pop3') {
             $mailbox->deleteMessage($sequence);
         }
         if ($mailbox->service == 'imap') {
             $mailbox->setMessageFlag($sequence, '\\Seen');
         }
         // @rule: Autoposting to social network sites.
         if ($blog->published == POST_ID_PUBLISHED) {
             $blog->autopost(array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER), array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER));
             $blog->notify(false);
         }
         $total++;
     }
     /*
      * Disconnect from mailbox
      */
     $mailbox->disconnect();
     /*
      * Generate report
      */
     echo JText::sprintf('%1s blog posts fetched from mailbox: ' . $config->get('main_remotepublishing_mailbox_remotesystemname') . '.', $total);
 }
示例#15
0
 /**
  * Remove all image variations from the site
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function deleteVariations($uri)
 {
     // Accepts uri or item.
     if (is_string($uri)) {
         $item = $this->getItem($uri);
     } else {
         $item = $uri;
     }
     $errors = array();
     foreach ($item->variations as $key => $variation) {
         // Skip original variation
         if ($key == 'system/original') {
             continue;
         }
         // Get the variations path
         $file = EasyBlogMediaManager::getPath($variation->uri);
         if (!JFile::exists($file)) {
             $errors[] = $file;
             continue;
         }
         $state = JFile::delete($file);
         if (!$state) {
             $errors[] = $file;
         }
     }
     if (count($errors)) {
         // TODO: Language
         return EB::exception('Unable to remove the following image variations: ' . implode(', ', $errors) . '.');
     }
     return true;
 }
示例#16
0
 /**
  * Load media configuration
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function mediaConfiguration()
 {
     $ajax = EB::ajax();
     // Require login
     EB::requireLogin();
     $user = EB::user($this->my->id);
     $tpl = EB::template();
     $blogger_id = $user->id;
     $tpl->set('blogger_id', $blogger_id);
     // @since: 3.6
     // Media manager options
     $tpl->set('session', JFactory::getSession());
     $mediamanager = EB::mediamanager();
     $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
     $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
     $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
     $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
     $tpl->set('userFolders', $userFolders);
     $tpl->set('userFiles', $userFiles);
     $tpl->set('sharedFolders', $sharedFolders);
     $tpl->set('sharedFiles', $sharedFiles);
     // @rule: Test if the user is already associated with Flickr
     $oauth = EB::table('OAuth');
     $associated = $oauth->loadByUser($this->my->id, EBLOG_OAUTH_FLICKR);
     $tpl->set('flickrAssociated', $associated);
     // Retrieve flickr's data
     $flickr = $this->getFlickrData();
     // Retrieve dropbox's data
     $dropbox = $this->getDropboxData();
     $tpl->set('flickr', $flickr);
     $tpl->set('dropbox', $dropbox);
     $html = $tpl->output('site/media/configuration');
     $ajax->resolve($html);
 }
示例#17
0
文件: image.php 项目: Tommar/vino2
 /**
  * Retrieves a list of system variations for the image type.
  */
 public function getSystemVariations()
 {
     $variations = array('thumbnail', 'icon');
     $fileName = $this->getTitle();
     $result = array();
     $uri = dirname($this->getURI());
     // @task: Get all new 3.5 image items that has a prefix of EBLOG_SYSTEM_VARIATION_PREFIX
     foreach ($variations as $variation) {
         $systemVariationFile = dirname($this->file) . DIRECTORY_SEPARATOR . EBLOG_SYSTEM_VARIATION_PREFIX . '_' . $variation . '_' . $fileName;
         // @Legacy: Prior to 3.5 !IMPORTANT!
         // @task: Check if there are any missing items like thumbnail or icon. If it's missing, we need to fix this.
         if (!JFile::exists($systemVariationFile)) {
             $systemVariationFile = dirname($this->file) . DIRECTORY_SEPARATOR . 'thumb_' . $fileName;
             // If the legacy thumb item still doesn't exist, we just fall back to the original image :(
             // Otherwise we have nothing to show to the user.
             if (!JFile::exists($systemVariationFile)) {
                 $systemVariationFile = $this->file;
             }
         }
         // @task: Get more information about the image variation.
         if (!$this->includeDimension) {
             $width = 0;
             $height = 0;
         } else {
             $info = @getimagesize($systemVariationFile);
             $width = $info[0];
             $height = $info[1];
         }
         $media = new EasyBlogMediaManager();
         $data = $media->getItem($systemVariationFile, $uri, $this->relativePath, false, $this->place, false, false, true)->toObject();
         $variationObj = $this->getVariationObject($data, $variation, $width, $height, false, $variation == 'thumbnail');
         $result[] = $variationObj;
     }
     // @task: The original file is also treated as a variation
     if (!$this->includeDimension) {
         $width = 0;
         $height = 0;
     } else {
         $info = @getimagesize($this->file);
         $width = $info[0];
         $height = $info[1];
     }
     $media = new EasyBlogMediaManager();
     $data = $media->getItem($this->file, dirname($this->getURI()), $this->relativePath, false, $this->place, false, false, true)->toObject();
     $result[] = $this->getVariationObject($data, 'original', $width, $height, false, false);
     return $result;
 }
示例#18
0
 function write()
 {
     $document = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $mainframe = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $siteAdmin = EasyBlogHelper::isSiteAdmin();
     $my = JFactory::getUser();
     // set the editor title based on operation
     $editorTitle = '';
     // just to inform the view that this is edit operation
     $showDraftStatus = true;
     $isEdit = false;
     if (!EasyBlogHelper::isLoggedIn()) {
         EasyBlogHelper::showLogin();
         return;
     }
     if (!EasyBlogRouter::isCurrentActiveMenu('dashboard')) {
         $this->setPathway(JText::_('COM_EASYBLOG_DASHBOARD_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard'));
     }
     $this->setPathway(JText::_('COM_EASYBLOG_DASHBOARD_WRITE_BREADCRUMB'));
     if (!$acl->rules->add_entry) {
         $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard', false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
         $mainframe->close();
     }
     // enable datetime picker
     EasyBlogDateHelper::enableDateTimePicker();
     // Add the Calendar includes to the document <head> section
     JHTML::_('behavior.calendar');
     // Add modal behavior
     JHTML::_('behavior.modal');
     // Load the JEditor object
     if ($config->get('layout_editor_author')) {
         // Get user's parameters
         $userParams = EasyBlogHelper::getRegistry($my->params);
         $editorType = $userParams->get('editor', $config->get('layout_editor'));
         $editor = JFactory::getEditor($editorType);
     } else {
         $editor = JFactory::getEditor($config->get('layout_editor'));
     }
     $user = EasyBlogHelper::getTable('Profile', 'Table');
     $user->setUser($my);
     $model = $this->getModel('Blog');
     $categoriesModel = $this->getModel('Categories');
     $publishedOnly = true;
     $categoryItems = $categoriesModel->getParentCategories('', 'all', $publishedOnly, true);
     $categories = array();
     if ($categoryItems) {
         foreach ($categoryItems as $categoryItem) {
             $category = EasyBlogHelper::getTable('Category');
             $category->bind($categoryItem);
             $categories[] = $category;
         }
     }
     $trackbacksModel = $this->getModel('TrackbackSent');
     $blogContributed = '';
     $trackbacks = '';
     $external = '';
     $extGroupId = '';
     // @task: See if there's any uid in the query string.
     // @since 3.5
     $source = JRequest::getVar('source');
     $uid = JRequest::getInt('uid');
     // get blogid if exists
     $blogId = JRequest::getVar('blogid', '');
     // Test if draft id exists
     $draftId = JRequest::getVar('draft_id', '');
     // test if this is a under approval post or not.
     $underApproval = JRequest::getVar('approval', '');
     // Load blog table
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($blogId);
     // Test if this blog belongs to the team and the current browser is the team admin.
     $teamblogModel = $this->getModel('TeamBlogs');
     $teamContribution = $teamblogModel->getBlogContributed($blog->id);
     // Check if the person has access to create a new blog post
     if ($blog->id && $blog->created_by != $my->id && !$siteAdmin && empty($acl->rules->moderate_entry) && !$teamContribution) {
         $url = 'index.php?option=com_easyblog&view=dashboard';
         $mainframe->redirect(EasyBlogRouter::_($url, false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
     }
     // This will be the team blog checking
     $isCurrentTeamAdmin = false;
     if ($teamContribution && !$siteAdmin && empty($acl->rules->moderate_entry)) {
         $isCurrentTeamAdmin = $teamblogModel->checkIsTeamAdmin($my->id, $teamContribution->team_id);
         // Test if the user has access to this team posting.
         if (!$isCurrentTeamAdmin && $blog->created_by != $my->id) {
             $url = 'index.php?option=com_easyblog&view=dashboard';
             $mainframe->redirect(EasyBlogRouter::_($url, false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
         }
     }
     $tmpBlogData = EasyBlogHelper::getSession('tmpBlogData');
     $loadFromSession = false;
     $blogSource = '';
     if (isset($tmpBlogData)) {
         $loadFromSession = true;
         $blog->bind($tmpBlogData);
         // reprocess the date offset here.
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($blog->created)) {
             $date = EasyBlogHelper::getDate($blog->created, $tzoffset);
             $blog->created = $date->toMySQL();
         }
         if (!empty($blog->publish_up) && $blog->publish_up != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_up, $tzoffset);
             $blog->publish_up = $date->toMySQL();
         }
         if (!empty($blog->publish_down) && $blog->publish_down != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_down, $tzoffset);
             $blog->publish_down = $date->toMySQL();
         }
         //bind the content from previous form
         $blog->content = $tmpBlogData['write_content'];
         $blog->tags = array();
         if (isset($tmpBlogData['tags'])) {
             $blog->tags = $this->bindTags($tmpBlogData['tags']);
         }
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = isset($tmpBlogData['keywords']) ? $tmpBlogData['keywords'] : '';
         $meta->description = isset($tmpBlogData['description']) ? $tmpBlogData['description'] : '';
         if (isset($tmpBlogData['blog_contribute'])) {
             $blogContributed = $this->bindContribute($tmpBlogData['blog_contribute']);
         }
         $contributionSource = isset($tmpBlogData['blog_contribute_source']) ? $tmpBlogData['blog_contribute_source'] : '';
         if (!empty($contributionSource) && $contributionSource != 'easyblog' && !$uid) {
             $external = true;
             $extGroupId = $tmpBlogData['blog_contribute'];
             $blogSource = 'group';
         }
         if (!empty($contributionSource) && $contributionSource != 'easyblog' && $uid && $source == 'jomsocial.event') {
             $external = true;
             $uid = $tmpBlogData['blog_contribute'];
             $blogSource = 'event';
         }
     }
     // Check if this is an edited post and if it has draft.
     $draft = EasyBlogHelper::getTable('Draft', 'Table');
     $isDraft = false;
     if (!empty($draftId)) {
         $draft->load($draftId);
         $blog->load($draft->entry_id);
         $blog->bind($draft);
         $blog->tags = empty($draft->tags) ? array() : $this->bindTags(explode(',', $draft->tags));
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = $draft->metakey;
         $meta->description = $draft->metadesc;
         if (!empty($draft->trackbacks)) {
             $blog->unsaveTrackbacks = $draft->trackbacks;
         }
         if ($draft->blog_contribute) {
             $blogContributed = $this->bindContribute($draft->blog_contribute);
         }
         $blog->tags = array();
         if (!empty($draft->tags)) {
             $blog->tags = $this->bindTags(explode(',', $draft->tags));
         }
         $blog->set('id', $draft->entry_id);
         $blogId = $blog->id;
         $isDraft = true;
     } else {
         // We only want to load drafts that has a blog id.
         if ($blog->id) {
             $draft->loadByEntry($blog->id);
         }
     }
     // set page title
     if (!empty($blogId)) {
         $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_EDIT_POST'));
         // @task: Set the page title
         parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend'));
         $editorTitle = JText::_('COM_EASYBLOG_DASHBOARD_EDIT_POST');
         // check if previous status is not Draft
         if ($blog->published == POST_ID_DRAFT) {
             $showDraftStatus = true;
         }
         $isEdit = true;
         //perform some title string formatting
         $blog->title = $this->escape($blog->title);
     } else {
         $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_DASHBOARD_WRITE_POST'));
         // @task: Set the page title
         parent::setPageTitle($title, false, $config->get('main_pagetitle_autoappend'));
         $editorTitle = JText::_('COM_EASYBLOG_DASHBOARD_WRITE_POST');
         // set the default publishing status only if it is a brand new creation page.
         if (!$loadFromSession && !$isDraft) {
             // by default, all new post MUST BE set to draft
             $blog->published = $config->get('main_blogpublishing', '3');
         }
     }
     //get all tags ever created.
     $newTagsModel = $this->getModel('Tags');
     $blog->newtags = $newTagsModel->getTags();
     //prepare initial blog settings.
     $isPrivate = $config->get('main_blogprivacy', '0');
     $allowComment = $config->get('main_comment', 1);
     $allowSubscribe = $config->get('main_subscription', 1);
     $showFrontpage = $config->get('main_newblogonfrontpage', 0);
     $sendEmails = $config->get('main_sendemailnotifications', 1);
     $isSiteWide = isset($blog->issitewide) ? $blog->issitewide : '1';
     $teamblogModel = $this->getModel('TeamBlogs');
     $teams = !empty($blog->created_by) ? $teamblogModel->getTeamJoined($blog->created_by) : $teamblogModel->getTeamJoined($my->id);
     if (!empty($blog->id)) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $config->get('main_subscription') ? $blog->subscription : 0;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
         //get user teamblog
         $teams = $teamblogModel->getTeamJoined($blog->created_by);
         //@task: List all trackbacks
         $trackbacks = $trackbacksModel->getSentTrackbacks($blogId);
     }
     if ($loadFromSession || $isDraft) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
     }
     $author = null;
     //if site admin then get get blog creator and include a javascript function to change author.
     if ($siteAdmin || !empty($acl->rules->moderate_entry) || isset($teamContribution) && $isCurrentTeamAdmin) {
         if (!empty($blog->created_by)) {
             $creator = JFactory::getUser($blog->created_by);
             $author = EasyBlogHelper::getTable('Profile', 'Table');
             $author->setUser($creator);
             unset($creator);
         }
     }
     //check if can upload image or not.
     $useImageManager = $config->get('main_media_manager', 1);
     if (!isset($meta)) {
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = '';
         $meta->description = '';
     }
     if (empty($blog->created_by) || $blog->created_by == $my->id || $siteAdmin || !empty($acl->rules->moderate_entry) || $teamContribution) {
         $blog->tags = isset($blog->tags) && !empty($blog->tags) ? $blog->tags : array();
         if (!$loadFromSession && !$isDraft) {
             // get the tag only if it is not loaded from the session value
             if ($blogId) {
                 $tagsModel = $this->getModel('PostTag');
                 $blog->tags = $tagsModel->getBlogTags($blogId);
                 // get meta tags
                 $metaModel = $this->getModel('Metas');
                 $meta = $metaModel->getPostMeta($blogId);
             }
         }
         $onlyPublished = empty($blogId) ? true : false;
         $isFrontendWrite = true;
         $nestedCategories = '';
         $defaultCategory = JRequest::getInt('categoryId');
         $menu = JFactory::getApplication()->getMenu()->getActive();
         if ($menu && isset($menu->params)) {
             $param = EasyBlogHelper::getRegistry();
             $param->load($menu->params);
             $catId = $param->get('categoryId');
             if ($catId) {
                 $defaultCategory = $catId;
             }
         }
         // @task: If blog is being edited, it should contain a category_id property.
         $defaultCategory = empty($blog->category_id) ? $defaultCategory : $blog->category_id;
         if ($config->get('layout_dashboardcategoryselect') == 'select') {
             $nestedCategories = EasyBlogHelper::populateCategories('', '', 'select', 'category_id', $defaultCategory, true, $onlyPublished, $isFrontendWrite);
         }
         echo $this->showToolbar(__FUNCTION__, $user);
         $tpl = new CodeThemes('dashboard');
         $blogger_id = !isset($blog->created_by) ? $user->id : $blog->created_by;
         $content = $blog->intro;
         // Append the readmore if necessary
         if (!empty($blog->intro) && !empty($blog->content)) {
             $content .= '<hr id="system-readmore" />';
         }
         $content .= $blog->content;
         $defaultCategoryName = '';
         if (empty($defaultCategory)) {
             //get default category if configured.
             $defaultCategory = EasyBlogHelper::getDefaultCategoryId();
         }
         if (!empty($defaultCategory)) {
             $categoryTbl = EasyBlogHelper::getTable('Category');
             $categoryTbl->load($defaultCategory);
             $defaultCategoryName = $categoryTbl->title;
         }
         if ($draft->id != 0 && $isDraft) {
             if (!empty($draft->external_source)) {
                 $external = true;
                 $extGroupId = $draft->external_group_id;
             }
         } else {
             if (!$loadFromSession) {
                 // If writing is for an external source, we need to tell the editor to strip down some unwanted features
                 $external = JRequest::getVar('external', false);
                 //check if this is a external group contribution.
                 $extGroupId = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id);
                 if (!empty($extGroupId)) {
                     $external = $extGroupId;
                     $blogSource = 'group';
                 }
                 if (!empty($uid)) {
                     $external = $uid;
                     $blogSource = 'event';
                 }
                 $externalEventId = EasyBlogHelper::getHelper('Event')->getContribution($blog->id);
                 if (!empty($externalEventId)) {
                     $external = $externalEventId;
                     $blogSource = 'event';
                 }
             }
         }
         // If there's a tag (maybe from the draft area, we need to add the tags data back)
         if ($isDraft && !empty($blog->tags)) {
             $blog->newtags = array_merge($blog->newtags, $blog->tags);
         }
         // Add the breadcrumbs
         $breadcrumbs = array($editorTitle => '');
         $tpl->set('teamContribution', $teamContribution);
         $tpl->set('isCurrentTeamAdmin', $isCurrentTeamAdmin);
         $tpl->set('breadcrumbs', $breadcrumbs);
         $tpl->set('external', $external);
         $tpl->set('extGroupId', $extGroupId);
         $tpl->set('defaultCategory', $defaultCategory);
         $tpl->set('defaultCategoryName', $defaultCategoryName);
         $tpl->set('content', $content);
         $tpl->set('blogger_id', $blogger_id);
         $tpl->set('draft', $draft);
         $tpl->set('isDraft', $isDraft);
         $tpl->set('isPending', $underApproval);
         $tpl->set('isEdit', $isEdit);
         $tpl->set('showDraftStatus', $showDraftStatus);
         $tpl->set('editorTitle', $editorTitle);
         $tpl->set('meta', $meta);
         $tpl->set('editor', $editor);
         $tpl->set('trackbacks', $trackbacks);
         $tpl->set('categories', $categories);
         $tpl->set('blog', $blog);
         $tpl->set('user', $user);
         $tpl->set('isPrivate', $isPrivate);
         $tpl->set('allowComment', $allowComment);
         $tpl->set('subscription', $allowSubscribe);
         $tpl->set('trackbacks', $trackbacks);
         $tpl->set('frontpage', $showFrontpage);
         $tpl->set('author', $author);
         $tpl->set('useImageManager', $useImageManager);
         $tpl->set('nestedCategories', $nestedCategories);
         $tpl->set('teams', $teams);
         $tpl->set('isSiteWide', $isSiteWide);
         $tpl->set('send_notification_emails', $sendEmails);
         // @since: 3.5
         // The unique external source and id.
         $tpl->set('blogSource', $blogSource);
         $tpl->set('source', $source);
         $tpl->set('uid', $uid);
         // @since: 3.6
         // Media manager options
         $tpl->set('session', JFactory::getSession());
         // Load media manager and get info about the files.
         require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
         $mediamanager = new EasyBlogMediaManager();
         $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
         $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
         $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
         $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
         $tpl->set('userFolders', $userFolders);
         $tpl->set('userFiles', $userFiles);
         $tpl->set('sharedFolders', $sharedFolders);
         $tpl->set('sharedFiles', $sharedFiles);
         // @rule: Test if the user is already associated with Flickr
         $oauth = EasyBlogHelper::getTable('Oauth');
         $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
         $tpl->set('flickrAssociated', $associated);
         echo $tpl->fetch('dashboard.write.php');
     } else {
         $mainframe->redirect(EasyBlogRouter::_('index.php?option=com_easyblog&view=dashboard', false), JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG'), 'error');
     }
 }
示例#19
0
 function display($tpl = null)
 {
     // @rule: Test for user access if on 1.6 and above
     if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
         if (!JFactory::getUser()->authorise('easyblog.manage.blog', 'com_easyblog')) {
             JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             JFactory::getApplication()->close();
         }
     }
     // Load the front end language file.
     $lang = JFactory::getLanguage();
     $lang->load('com_easyblog', JPATH_ROOT);
     // Initial variables.
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $acl = EasyBlogACLHelper::getRuleSet();
     $config = EasyBlogHelper::getConfig();
     // Load the JEditor object
     $editor = JFactory::getEditor($config->get('layout_editor', 'tinymce'));
     // Enable datetime picker
     EasyBlogDateHelper::enableDateTimePicker();
     // required variable initiation.
     $meta = null;
     $blogContributed = array();
     $tags = null;
     $external = '';
     $extGroupId = '';
     // Event id state.
     $externalEventId = '';
     //Load blog table
     $blogId = JRequest::getVar('blogid', '');
     $blog = EasyBlogHelper::getTable('Blog', 'Table');
     $blog->load($blogId);
     $tmpBlogData = EasyBlogHelper::getSession('tmpBlogData');
     $loadFromSession = false;
     // Initialize default tags.
     $blog->tags = array();
     if (isset($tmpBlogData)) {
         $loadFromSession = true;
         $blog->bind($tmpBlogData);
         // reprocess the date offset here.
         $tzoffset = EasyBlogDateHelper::getOffSet();
         if (!empty($blog->created)) {
             $date = EasyBlogHelper::getDate($blog->created, $tzoffset);
             $blog->created = $date->toMySQL();
         }
         if (!empty($blog->publish_up) && $blog->publish_up != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_up, $tzoffset);
             $blog->publish_up = $date->toMySQL();
         }
         if (!empty($blog->publish_down) && $blog->publish_down != '0000-00-00 00:00:00') {
             $date = EasyBlogHelper::getDate($blog->publish_down, $tzoffset);
             $blog->publish_down = $date->toMySQL();
         }
         //bind the content from previous form
         $blog->content = $tmpBlogData['write_content'];
         if (isset($tmpBlogData['tags'])) {
             $blog->tags = $this->bindTags($tmpBlogData['tags']);
         }
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = isset($tmpBlogData['keywords']) ? $tmpBlogData['keywords'] : '';
         $meta->description = isset($tmpBlogData['description']) ? $tmpBlogData['description'] : '';
         if (isset($tmpBlogData['blog_contribute'])) {
             $blogContributed = $this->bindContribute($tmpBlogData['blog_contribute']);
         }
         $contributionSource = isset($tmpBlogData['blog_contribute_source']) ? $tmpBlogData['blog_contribute_source'] : '';
         if (!empty($contributionSource) && $contributionSource != 'easyblog') {
             $external = true;
             $extGroupId = $tmpBlogData['blog_contribute'];
             $externalEventId = $tmpBlogData['blog_contribute'];
         }
         $blog->unsaveTrackbacks = '';
         if (!empty($tmpBlogData['trackback'])) {
             $blog->unsaveTrackbacks = $tmpBlogData['trackback'];
         }
     }
     $draft = EasyBlogHelper::getTable('Draft', 'Table');
     $draft_id = JRequest::getVar('draft_id', '');
     $isDraft = false;
     $pending_approval = JRequest::getVar('approval', '');
     if (!empty($draft_id)) {
         //first check if the logged in user have the required acl or not.
         if (empty($acl->rules->add_entry) || empty($acl->rules->publish_entry) || empty($acl->rules->manage_pending)) {
             $message = JText::_('COM_EASYBLOG_BLOGS_BLOG_NO_PERMISSION_TO_CREATE_BLOG');
             $app->enqueueMessage($message, 'error');
             $app->redirect(JRoute::_('index.php?option=com_easyblog&view=blogs', false));
         }
         $draft->load($draft_id);
         $blog->load($draft->entry_id);
         $blog->bind($draft);
         $blog->tags = $this->bindTags(explode(',', $draft->tags));
         $blog->newtags = $blog->tags;
         $tags = $blog->tags;
         // metas
         $meta = new stdClass();
         $meta->id = '';
         $meta->keywords = $draft->metakey;
         $meta->description = $draft->metadesc;
         $blog->unsaveTrackbacks = '';
         if (!empty($draft->trackbacks)) {
             $blog->unsaveTrackbacks = $draft->trackbacks;
         }
         if ($draft->blog_contribute) {
             $blogContributed = $this->bindContribute($draft->blog_contribute);
         }
         $blog->set('id', $draft->entry_id);
         $blogId = $blog->id;
         $isDraft = true;
     }
     // set page title
     if (!empty($blogId)) {
         $doc->setTitle(JText::_('COM_EASYBLOG_BLOGS_EDIT_POST') . ' - ' . $config->get('main_title'));
         $editorTitle = JText::_('COM_EASYBLOG_BLOGS_EDIT_POST');
         // check if previous status is not Draft
         if ($blog->published != POST_ID_DRAFT) {
             $isEdit = true;
         }
     } else {
         $doc->setTitle(JText::_('COM_EASYBLOG_BLOGS_NEW_POST'));
         $editorTitle = JText::_('COM_EASYBLOG_BLOGS_NEW_POST');
         if (!$loadFromSession && !$isDraft) {
             // set to 'publish' for new blog in backend.
             $blog->published = $config->get('main_blogpublishing', '1');
         }
     }
     $author = null;
     if (!empty($blog->created_by)) {
         $creator = JFactory::getUser($blog->created_by);
         $author = EasyBlogHelper::getTable('Profile', 'Table');
         $author->setUser($creator);
         unset($creator);
     } else {
         $creator = JFactory::getUser($my->id);
         $author = EasyBlogHelper::getTable('Profile', 'Table');
         $author->setUser($creator);
         unset($creator);
     }
     //Get tag
     if (!$loadFromSession && !$isDraft) {
         $tagModel = EasyBlogHelper::getModel('PostTag', true);
         $tags = $tagModel->getBlogTags($blogId);
     }
     $tagsArray = array();
     if ($tags) {
         foreach ($tags as $data) {
             $tagsArray[] = $data->title;
         }
         $tagsString = implode(",", $tagsArray);
     }
     //prepare initial blog settings.
     $isPrivate = $config->get('main_blogprivacy', '0');
     $allowComment = $config->get('main_comment', 1);
     $allowSubscribe = $config->get('main_subscription', 1);
     $showFrontpage = $config->get('main_newblogonfrontpage', 0);
     $sendEmails = $config->get('main_sendemailnotifications', 0);
     $isSiteWide = isset($blog->issitewide) ? $blog->issitewide : '1';
     $tbModel = EasyBlogHelper::getModel('TeamBlogs', true);
     $teamBlogJoined = $tbModel->getTeamJoined($author->id);
     if (!empty($blog->id)) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
         //get user teamblog
         $teamBlogJoined = $tbModel->getTeamJoined($blog->created_by);
         if (!$isDraft) {
             $blogContributed = $tbModel->getBlogContributed($blog->id);
         }
     }
     if ($loadFromSession || $isDraft) {
         $isPrivate = $blog->private;
         $allowComment = $blog->allowcomment;
         $allowSubscribe = $blog->subscription;
         $showFrontpage = $blog->frontpage;
         $sendEmails = $blog->send_notification_emails;
     }
     if (count($blogContributed) > 0 && $blogContributed) {
         for ($i = 0; $i < count($teamBlogJoined); $i++) {
             $joined = $teamBlogJoined[$i];
             if ($joined->team_id == $blogContributed->team_id) {
                 $joined->selected = 1;
                 continue;
             }
         }
     }
     //get all tags ever created.
     $newTagsModel = EasyBlogHelper::getModel('Tags');
     if (isset($blog->newtags)) {
         $blog->newtags = array_merge($blog->newtags, $newTagsModel->getTags());
     } else {
         $blog->newtags = $newTagsModel->getTags();
     }
     //get tags used in this blog post
     if (!$loadFromSession && !$isDraft && $blogId) {
         $tagsModel = EasyBlogHelper::getModel('PostTag');
         $blog->tags = $tagsModel->getBlogTags($blogId);
     }
     //@task: List all trackbacks
     $trackbacksModel = EasyBlogHelper::getModel('TrackbackSent');
     $trackbacks = $trackbacksModel->getSentTrackbacks($blogId);
     // get meta tags
     if (!$loadFromSession && !$isDraft) {
         $metaModel = EasyBlogHelper::getModel('Metas');
         $meta = $metaModel->getPostMeta($blogId);
     }
     //perform some title string formatting
     $blog->title = $this->escape($blog->title);
     $blogger_id = !isset($blog->created_by) ? $my->id : $blog->created_by;
     $defaultCategory = empty($blog->category_id) ? EasyBlogHelper::getDefaultCategoryId() : $blog->category_id;
     $category = EasyBlogHelper::getTable('Category');
     $category->load($defaultCategory);
     $content = $blog->intro;
     // Append the readmore if necessary
     if (!empty($blog->intro) && !empty($blog->content)) {
         $content .= '<hr id="system-readmore" />';
     }
     $content .= $blog->content;
     //check if this is a external group contribution.
     $blog_contribute_source = 'easyblog';
     $external = false;
     $extGroupId = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id);
     $externalEventId = EasyBlogHelper::getHelper('Event')->getContribution($blog->id);
     $extGroupName = '';
     if (!empty($extGroupId)) {
         $external = $extGroupId;
         $blog_contribute_source = EasyBlogHelper::getHelper('Groups')->getGroupSourceType();
         $extGroupName = EasyBlogHelper::getHelper('Groups')->getGroupContribution($blog->id, $blog_contribute_source, 'name');
     }
     if (!empty($externalEventId)) {
         $external = $externalEventId;
         $blog_contribute_source = EasyBlogHelper::getHelper('Event')->getSourceType();
     }
     //site wide or team contribution
     $teamblogModel = EasyBlogHelper::getModel('TeamBlogs');
     $teams = !empty($blog->created_by) ? $teamblogModel->getTeamJoined($blog->created_by) : $teamblogModel->getTeamJoined($my->id);
     $this->assignRef('teams', $teams);
     $this->assignRef('isDraft', $isDraft);
     $joomlaVersion = EasyBlogHelper::getJoomlaVersion();
     $my = JFactory::getUser();
     $blogger_id = $my->id;
     $nestedCategories = '';
     $categoryselecttype = $config->get('layout_dashboardcategoryselect') == 'multitier' ? 'select' : $config->get('layout_dashboardcategoryselect');
     if ($categoryselecttype == 'select') {
         $nestedCategories = EasyBlogHelper::populateCategories('', '', 'select', 'category_id', $blog->category_id, true, true, false);
     }
     // Load media manager and get info about the files.
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'mediamanager.php';
     $mediamanager = new EasyBlogMediaManager();
     $userFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'folders');
     $userFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'user'), 'files');
     $sharedFolders = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'folders');
     $sharedFiles = $mediamanager->getInfo(EasyBlogMediaManager::getAbsolutePath('', 'shared'), 'files');
     // @rule: Test if the user is already associated with Flickr
     $oauth = EasyBlogHelper::getTable('Oauth');
     $associated = $oauth->loadByUser($my->id, EBLOG_OAUTH_FLICKR);
     $jConfig = EasyBlogHelper::getJConfig();
     $this->set('flickrAssociated', $associated);
     $this->assignRef('userFolders', $userFolders);
     $this->assignRef('userFiles', $userFiles);
     $this->assignRef('sharedFolders', $sharedFolders);
     $this->assignRef('sharedFiles', $sharedFiles);
     $this->assignRef('jConfig', $jConfig);
     $this->assignRef('my', $my);
     $this->assignRef('content', $content);
     $this->assignRef('category', $category);
     $this->assignRef('blogger_id', $blogger_id);
     $this->assignRef('joomlaversion', $joomlaVersion);
     $this->assignRef('isEdit', $isEdit);
     $this->assignRef('editorTitle', $editorTitle);
     $this->assignRef('blog', $blog);
     $this->assignRef('meta', $meta);
     $this->assignRef('editor', $editor);
     $this->assignRef('tagsString', $tagsString);
     $this->assignRef('acl', $acl);
     $this->assignRef('isPrivate', $isPrivate);
     $this->assignRef('allowComment', $allowComment);
     $this->assignRef('subscription', $allowSubscribe);
     $this->assignRef('frontpage', $showFrontpage);
     $this->assignRef('trackbacks', $trackbacks);
     $this->assignRef('author', $author);
     $this->assignRef('nestedCategories', $nestedCategories);
     $this->assignRef('teamBlogJoined', $teamBlogJoined);
     $this->assignRef('isSiteWide', $isSiteWide);
     $this->assignRef('draft', $draft);
     $this->assignRef('config', $config);
     $this->assignRef('pending_approval', $pending_approval);
     $this->assignRef('external', $external);
     $this->assignRef('extGroupId', $extGroupId);
     $this->assignRef('externalEventId', $externalEventId);
     $this->assignRef('extGroupName', $extGroupName);
     $this->assignRef('blog_contribute_source', $blog_contribute_source);
     $this->assignRef('categoryselecttype', $categoryselecttype);
     $this->assignRef('send_notification_emails', $sendEmails);
     parent::display($tpl);
 }
示例#20
0
        </div>
    </div>

    <div class="eb-composer-viewport" data-scrolly="y">
        <div class="eb-composer-viewport-content" data-scrolly-viewport>

            <div class="eb-mm-folder-content-panel">
                <div class="eb-mm-filegroup type-folder" data-eb-mm-filegroup>
                    <div class="eb-mm-filegroup-body">
                        <div class="eb-mm-filelist view-list">
                            <?php 
foreach ($posts as $post) {
    ?>
                            <div data-key="<?php 
    echo EasyBlogMediaManager::getKey('post:' . $post->id);
    ?>
" data-eb-mm-file="" class="eb-mm-file type-folder">
                                <i class="fa fa-file"></i>
                                <span>
                                    <?php 
    if ($post->title) {
        ?>
                                        <?php 
        echo $post->title;
        ?>
                                    <?php 
    } else {
        ?>
                                        <?php 
        echo JText::sprintf('COM_EASYBLOG_MM_PLACE_POST_UNTITLED', $post->id);