示例#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
文件: 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);
 }
示例#3
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);
         $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.'));
     }
 }
示例#4
0
 /**
  * List down files and folders from a given path.
  *
  * @access	public
  * @param	null
  *
  */
 public function listItems()
 {
     $ajax = EasyBlogHelper::getHelper('Ajax');
     // force loading frontend language file.
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     // This let's us know the type of folder we should lookup to
     $place = JRequest::getString('place');
     if ($place == 'jomsocial') {
         return $this->listJomSocialItems();
     }
     if ($place == 'easysocial') {
         return $this->listEasySocialItems();
     }
     if ($place == 'flickr') {
         return $this->listFlickrItems();
     }
     // The source of the original image
     $source = JRequest::getVar('path');
     if ($source == DIRECTORY_SEPARATOR) {
         $source = '';
     }
     // Let's us know if we need to get the image variation.
     $variation = JRequest::getVar('variation') == '1' ? true : false;
     // Detect if there's any filter
     $filters = JRequest::getVar('filters', '');
     // @task: Create the media object.
     $media = new EasyBlogMediaManager();
     // @task: Let's find the exact path first as there could be 2 possibilities here.
     // 1. Shared folder
     // 2. User folder
     $absolutePath = EasyBlogMediaManager::getAbsolutePath($source, $place);
     $absoluteURI = EasyBlogMediaManager::getAbsoluteURI($source, $place);
     // @task: Let's test if the source item really exist.
     if (!$media->exists($absolutePath) || !$absolutePath) {
         return $ajax->fail(JText::_('COM_EASYBLOG_FILE_OR_FOLDER_DOES_NOT_EXIST'));
     }
     $withFileSize = $variation ? true : false;
     $items = $media->getItem($absolutePath, $absoluteURI, $source, $variation, $place, false, false, $withFileSize)->toArray();
     require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php';
     $json = new Services_JSON();
     // Get a list of paginated items here.
     $paginatedItems = $media->getItem($absolutePath, $absoluteURI, $source, $variation, $place, false, true, $withFileSize)->toArray();
     $table = EasyBlogHelper::getTable('MediaManager');
     $table->load($absolutePath, 'files');
     $table->set('path', $absolutePath);
     $table->set('type', 'files');
     $table->set('params', $json->encode($paginatedItems));
     $table->store();
     return $ajax->success($items);
 }
示例#5
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');
     }
 }
示例#6
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);
 }
示例#7
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);
 }