public function appendPending() { $db = EasyBlogHelper::db(); // Get total reported items $query = 'SELECT COUNT(1) FROM #__easyblog_drafts'; $query .= ' WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('pending_approval') . '=' . $db->Quote(1); $db->setQuery($query); $totalPending = $db->loadResult(); $ajax = new Ejax(); if ($totalPending > 0) { $ajax->script("\$('#submenu li' ).eq( 4 ).find( 'a' ).append( '<b>" . $totalPending . "</b>' );"); } else { $ajax->script('[]'); } $ajax->send(); }
public function vote($value, $uid, $type, $elementId) { $ajax = new Ejax(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $blog = EasyBlogHelper::getTable('Blog', 'Table'); $blog->load($uid); if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) { if (!EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) { echo 'Invalid Access.'; exit; } } $rating = EasyBlogHelper::getTable('Ratings', 'Table'); // Do not allow guest to vote, or if the voter already voted. if ($rating->fill($my->id, $uid, $type, JFactory::getSession()->getId()) || $my->id < 1 && !$config->get('main_ratings_guests')) { // We wouldn't allow user to vote more than once so don't do anything here $ajax->send(); } $rating->set('created_by', $my->id); $rating->set('type', $type); $rating->set('uid', $uid); $rating->set('ip', @$_SERVER['REMOTE_ADDR']); $rating->set('value', (int) $value); $rating->set('sessionid', JFactory::getSession()->getId()); $rating->set('created', EasyBlogHelper::getDate()->toMySQL()); $rating->set('published', 1); $rating->store(); $model = EasyBlogHelper::getModel('Ratings'); $ratingValue = $model->getRatingValues($uid, $type); $total = $ratingValue->total; $rating = $ratingValue->ratings; // Assign badge for users that report blog post. // Only give points if the viewer is viewing another person's blog post. EasyBlogHelper::getHelper('EasySocial')->assignBadge('blog.rate', JText::_('COM_EASYBLOG_EASYSOCIAL_BADGE_RATED_BLOG')); $ajax->script('eblog.loader.doneLoading("' . $elementId . '-command .ratings-text")'); $ajax->script('eblog.ratings.update("' . $elementId . '", "' . $type . '" , "' . $rating . '" , "' . JText::_('COM_EASYBLOG_RATINGS_RATED_THANK_YOU') . '");'); $ajax->assign($elementId . ' .ratings-value', '<i></i>' . $total . '<b>√</b>'); if (EasyBlogHelper::isAUPEnabled()) { $id = AlphaUserPointsHelper::getAnyUserReferreID($my->id); AlphaUserPointsHelper::newpoints('plgaup_easyblog_rate_blog', $id, '', JText::sprintf('COM_EASYBLOG_AUP_BLOG_RATED'), ''); } $ajax->send(); }
public function search($query = '') { $ajax = new Ejax(); $model = $this->getModel('Search'); $result = $model->searchText($query); if (empty($result)) { $ajax->script('$("#editor-content .search-results-content").height(24);'); $ajax->assign('editor-content .search-results-content', JText::_('COM_EASYBLOG_DASHBOARD_WRITE_SEARCH_NO_RESULT')); return $ajax->send(); } $count = count($result); if ($count > 10) { $height = "240"; } else { $height = "24" * $count; } $theme = new CodeThemes('dashboard'); $theme->set('result', $result); $ajax->assign('editor-content .search-results-content', $theme->fetch('dashboard.write.search.result.php')); $ajax->script('$("#editor-content .search-results-content").height(' . $height . ');'); $ajax->script('$("#editor-content .search-results-content").show();'); // $ajax->script( 'eblog.fileManager.setDockLayout();' ); return $ajax->send(); }
function loadCalendar($position = 'module', $itemId = '0', $size = 'small', $type = 'blog', $timestamp = '') { $my = JFactory::getUser(); $ajax = new Ejax(); $config = EasyBlogHelper::getConfig(); $tpl = new CodeThemes(); $model = new EasyBlogModelArchive(); $allowed = array('module', 'component'); if (!in_array($position, $allowed)) { return; } if (!empty($itemId)) { JRequest::setVar('Itemid', $itemId); } //get date. $date = EasyBlogCalendarHelper::processDate($timestamp); //get the required data to build the calendar. $data = EasyBlogCalendarHelper::prepareData($date); //get the postcount //$postCount = $model->getArchivePostCountByMonth($date['month'], $date['year']); $postData = $model->getArchivePostByMonth($date['month'], $date['year']); switch ($position) { case 'module': $namespace = 'mod_easyblogcalendar'; $preFix = 'mod_easyblog'; $ajax->script('mod_easyblogcalendar.calendar.setItemId("' . $itemId . '");'); break; case 'component': $namespace = 'eblog'; $preFix = 'com_easyblog'; break; } $previous = $namespace . '.calendar.reload( \'archive\' , \'loadCalendar\', \'' . $position . '\', \'' . $itemId . '\', \'' . $size . '\', \'' . $type . '\', \'' . $data->previous . '\');'; $next = $namespace . '.calendar.reload( \'archive\' , \'loadCalendar\', \'' . $position . '\', \'' . $itemId . '\', \'' . $size . '\', \'' . $type . '\', \'' . $data->next . '\');'; $tpl->set('calendar', $data); $tpl->set('date', $date); $tpl->set('postData', $postData); $tpl->set('previous', $previous); $tpl->set('next', $next); $tpl->set('namespace', $namespace); $tpl->set('preFix', $preFix); $tpl->set('itemId', $itemId); $layout = $tpl->fetch('calendar.' . $size . '.php'); $ajax->assign('easyblogcalendar-' . $position . '-wrapper', $layout); $ajax->send(); return; }
public function testMailboxConnection($server, $port, $service, $ssl, $mailbox, $user, $pass) { $ajax = new Ejax(); // sanity check $filter = JFilterInput::getInstance(); $server = $filter->clean($server, 'string'); $port = $filter->clean($port, 'integer'); $service = $filter->clean($service, 'string'); $ssl = $filter->clean($ssl, 'integer'); $mailbox = $filter->clean($mailbox, 'string'); $server = $filter->clean($server, 'string'); $user = $filter->clean($user, 'username'); $pass = $filter->clean($pass, 'string'); // variable check if ($server == '' || $port == '' || $mailbox == '' || $user == '' || $pass == '') { $result = JText::_('COM_EASYBLOG_EMAIL_CREDENTIALS_INCOMPLETE'); } else { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'mailbox.php'; $result = EasyblogMailbox::testConnect($server, $port, $service, $ssl, $mailbox, $user, $pass); } $ajax->script("\$('#remote_test_result').html('{$result}');"); return $ajax->send(); }
/** * comment save function used by cb.easyblog plugin. */ function saveCBcomment($post) { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'constants.php'; $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $ajax = new Ejax(); if (JString::strlen($post['comment']) == 0) { $ajax->script('easyblogApp.comment.notify("' . $post['id'] . '","' . JText::_('Comment is empty') . '","' . 'error' . '")'); $ajax->script('easyblogApp.spinner.hide()'); $ajax->script('easyblogApp.element.focus("comment")'); return $ajax->send(); } // We don't require a title here. $post['title'] = ''; //real work start here. $isModerate = false; $parentId = "0"; $commentDepth = $post['comment_depth']; $blogId = $post['id']; //we need to rename the esname and esemail back to name and email. $post['url'] = ''; $post['name'] = $post['esname']; $post['email'] = $post['esemail']; unset($post['esname']); unset($post['esemail']); JTable::addIncludePath(EBLOG_TABLES); $db = EasyBlogHelper::db(); $comment = EasyBlogHelper::getTable('Comment', 'Table'); $comment->bindPost($post); $now = EasyBlogHelper::getDate(); $totalComment = empty($post['totalComment']) ? 1 : $post['totalComment']; $comment->created = $now->toMySql(); $comment->modified = $now->toMySql(); $comment->published = 1; $comment->parent_id = $parentId; $comment->created_by = $my->id; if ($my->id != 0 && $config->get('comment_moderatecomment') == 1 || $my->id == 0 && $config->get('comment_moderateguestcomment') == 1) { $comment->published = 0; $isModerate = true; } jimport('joomla.application.component.model'); JLoader::import('Comment', EBLOG_ROOT . DIRECTORY_SEPARATOR . 'models'); $model = JModel::getInstance('Comment', 'EasyBlogModel'); $latestComment = $model->getLatestComment($blogId, $parentId); $left = 1; $right = 2; if (!empty($latestComment)) { $left = $latestComment->rgt + 1; $right = $latestComment->rgt + 2; $model->updateCommentSibling($blogId, $latestComment->rgt); } $comment->lft = $left; $comment->rgt = $right; if (!$comment->store()) { $ajax->script('easyblogApp.comment.notify("' . $post['id'] . '","' . JText::_('Comment add failed') . '","' . 'error' . '")'); $ajax->script('easyblogApp.spinner.hide()'); $ajax->{$ajax}('easyblogApp.element.focus("comment")'); return $ajax->send(); } $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($comment->created_by); $comment->creator = $profile; $date = EasyBlogDateHelper::dateWithOffSet($comment->created); $comment->formattedDate = $date->toFormat($config->get('layout_dateformat', '%A, %d %B %Y')); $text = JString::strlen($comment->comment) > 50 ? JString::substr(strip_tags($comment->comment), 0, 50) . '...' : strip_tags($comment->comment); $commentText = ' <li> <div class="blog-comment-avatar"> <a href="' . $comment->creator->getProfileLink() . '"><img src="' . $comment->creator->getAvatar() . '" width="32" /></a> </div> <div class="blog-comment-item eztc"> <div class="small"> <a href="' . $comment->creator->getProfileLink() . '">' . $comment->creator->getName() . '</a> ' . JText::_('on') . ' <span class="small">' . $comment->formattedDate . '</span> </div> ' . $text . ' </div> <div style="clear: both;"></div> </li>'; $ajax->prepend('comments-wrapper' . $blogId, $commentText); $ajax->script('easyblogApp.comment.cancel("' . $blogId . '")'); $ajax->script('easyblogApp.spinner.hide()'); $ajax->script('easyblogApp.comment.notify("' . $blogId . '","' . JText::_('Comment Added') . '","' . 'success' . '")'); return $ajax->send(); }
public function display($cacheable = false, $urlparams = false) { JFactory::getApplication()->enqueueMessage('You are using Komento free version. <a href="http://stackideas.com/komento/plans.html" target="_blank">Upgrade to Komento Pro</a> to enjoy our priority support and more. <a href="http://stackideas.com/komento/plans.html" target="_blank" style="padding: 5px 10px; background-color: #C02828; color: #FFFFFF;">Upgrade now!</a>', 'notice'); // free version text (for reference only) // JFactory::getApplication()->enqueueMessage( 'You are using Komento free version. <a href="http://stackideas.com/komento/plans.html" target="_blank">Upgrade to Komento Pro</a> to enjoy our priority support and more. <a href="http://stackideas.com/komento/plans.html" target="_blank" style="padding: 5px 10px; background-color: #C02828; color: #FFFFFF;">Upgrade now!</a>', 'notice' ); $document = JFactory::getDocument(); // Set the layout $viewType = $document->getType(); $viewName = JRequest::getCmd('view', $this->getName()); $viewLayout = JRequest::getCmd('layout', 'default'); $view = $this->getView($viewName, $viewType, ''); $view->setLayout($viewLayout); $format = JRequest::getCmd('format', 'html'); // Test if the call is for Ajax if (!empty($format) && $format == 'ajax') { // Ajax calls. if (!JRequest::checkToken('GET')) { $ejax = new Ejax(); $ejax->script('alert("' . JText::_('Not allowed here') . '");'); $ejax->send(); } // Process Ajax call $data = JRequest::get('POST'); $arguments = array(); foreach ($data as $key => $value) { if (JString::substr($key, 0, 5) == 'value') { if (is_array($value)) { $arrVal = array(); foreach ($value as $val) { $item =& $val; $item = stripslashes($item); $item = rawurldecode($item); $arrVal[] = $item; } $arguments[] = $arrVal; } else { $val = stripslashes($value); $val = rawurldecode($val); $arguments[] = $val; } } } // if(!method_exists( $view , $viewLayout ) ) // { // $ejax = new Ejax(); // $ejax->script( 'alert("' . JText::sprintf( 'Method %1$s does not exists in this context' , $viewLayout ) . '");'); // $ejax->send(); // return; // } // Execute method call_user_func_array(array($view, $viewLayout), $arguments); } else { // Non ajax calls. if ($viewLayout != 'default') { if ($cacheable) { $cache = JFactory::getCache('com_komento', 'view'); $cache->get($view, $viewLayout); } else { if (!method_exists($view, $viewLayout)) { $view->display(); } else { // @todo: Display error about unknown layout. $view->{$viewLayout}(); } } } else { $view->display(); } // Add necessary buttons to the site. if (method_exists($view, 'registerToolbar')) { $view->registerToolbar(); } // Override submenu if needed if (method_exists($view, 'registerSubmenu') && $view->registerSubmenu() != '') { $this->loadSubmenu($view->getName(), $view->registerSubmenu()); } // @task: Append hidden token into the page. echo '<span id="komento-token" style="display:none;"><input type="hidden" name="' . Komento::_('getToken') . '" value="1" /></span>'; } }
/** * Remove an item as featured * * @param string $type The type of this item * @param int $postId The unique id of the item * * @return string Json string **/ function removeFeaturedx($type, $postId) { $ajax = new Ejax(); $acl = EB::acl(); EasyBlogHelper::removeFeatured($type, $postId); $idName = ''; $message = ''; switch ($type) { case 'blogger': $idName = '#blogger_title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED'); break; case 'teamblog': $idName = '#teamblog_title_' . $postId; $message = JText::_('COM_EASYBLOG_TEAMBLOG_UNFEATURED'); break; case 'post': default: $idName = '#title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOG_UNFEATURED'); break; } $ajax->script('$("' . $idName . '").removeClass("featured-item");'); $ajax->alert($message, JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); $ajax->send(); return; }
public function copyFiles($folder, $filename, $fileCounter = 0) { $ajax = new Ejax(); JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator'); // This is where the patch files are stored. $storage = JPATH_ROOT . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $folder; // This is where the path file should be extracted into. $filePath = $storage . DIRECTORY_SEPARATOR . $filename; $result = JFile::read($storage . DIRECTORY_SEPARATOR . 'info.json'); require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php'; require_once EBLOG_CLASSES . DS . 'json.php'; $json = new Services_JSON(); $info = $json->decode($result); $files = $info->files; $each = 75 / count($files); if ($fileCounter == 0) { $startProgress = 25 + $each; } else { $startProgress = $fileCounter * $each + $each + 25; } $startProgress = min(round($startProgress), 100); if (!isset($files[$fileCounter])) { $ajax->script('$("#progress-box").find("i.bar-loader").remove();'); $ajax->script('$("#result-holder").append("<div>' . JText::_('COM_EASYBLOG_UPDATER_PATCH_PROCESS_COMPLETED') . '</div>");'); $ajax->script('$("#bar-progress").css("width" , "' . $startProgress . '%");'); $ajax->send(); } // @rule: Now we got the info, copy the files and replace them accordingly. if (is_array($files)) { $file = $files[$fileCounter]; $filePath = $file->file; // Replace all forward slashes (/) to proper directory separator. $filePath = str_ireplace('/', DIRECTORY_SEPARATOR, $filePath); $localSource = JPATH_ROOT . DIRECTORY_SEPARATOR . $filePath; $patchSource = $storage . DIRECTORY_SEPARATOR . $filePath; $backupSource = JPATH_ROOT . DIRECTORY_SEPARATOR . $filePath . '.backup'; // @rule: Test for sql queries that needs to be executed. if (stristr($file->file, 'administrator/components/com_easyblog/upgrades/') !== false) { // We just want to include this file so that the script get's executed. include_once $patchSource; $ajax->script('$("#result-holder").append("<div>' . JText::sprintf('COM_EASYBLOG_UPDATER_EXECUTE_SCRIPT', $file->file) . '</div>");'); } else { if (stristr($file->file, 'administrator/components/com_easyblog/query/') !== false) { $query = JFile::read($patchSource); $db = EasyBlogHelper::db(); $db->setQuery($query); $db->queryBatch(); $ajax->script('$("#result-holder").append("<div>' . JText::sprintf('COM_EASYBLOG_UPDATER_EXECUTE_SQL', $file->file) . '</div>");'); } else { switch ($file->status) { // File is modified, update accordingly. case 'M': // @rule: Make backups first. JFile::copy($localSource, $backupSource); // Overwrite the files if (JFile::copy($patchSource, $localSource)) { $ajax->script('$("#result-holder").append("<div>' . JText::sprintf('COM_EASYBLOG_UPDATER_FILE_UPDATED', $file->file) . '</div>");'); } // @task: For language files, we need to replace it with the appropriate quote fixes. if (stristr($file->file, 'language/') !== false && EasyBlogHelper::getJoomlaVersion() < '1.6') { // @task: We need to do a search and replace of the local file for "_QQ_" since the source server stores the language file as "_QQ_" $contents = JFile::read($localSource); $contents = str_ireplace('"_QQ_"', '\\"', $contents); JFile::write($localSource, $contents); } break; case 'A': // @rule: Create necessary folders $this->createFolders($filePath); // Overwrite the files if (JFile::copy($patchSource, $localSource)) { $ajax->script('$("#result-holder").append("<div>' . JText::sprintf('COM_EASYBLOG_UPDATER_FILE_ADDED', $file->file) . '</div>");'); } break; // File is removed, remove existing files. // File is removed, remove existing files. case 'R': // @rule: Make backups first. JFile::copy($localSource, $backupSource); if (JFile::exists($localSource)) { if (JFile::delete($localSource)) { $ajax->script('$("#result-holder").append("<div>' . JText::sprintf('COM_EASYBLOG_UPDATER_FILE_Deleted', $file->file) . '</div>");'); } } break; } } } // Note: This logic is wrong, it never goes in. if ($fileCounter + 1 > count($files)) { // @rule: Once the patch is completed, remove loader image. $ajax->script('$("#progress-box").find("i.bar-loader").remove();'); $ajax->script('$("#result-holder").append("<div>' . JText::_('COM_EASYBLOG_UPDATER_PATCH_PROCESS_COMPLETED') . '</div>");'); } else { $x = $fileCounter + 1; $ajax->script('ejax.load("updater", "copyFiles" , "' . $folder . '","' . $filename . '","' . $x . '");'); } } $startProgress = min(round($startProgress), 100); $ajax->script('$("#bar-progress #progress-indicator").html("' . $startProgress . '%");'); $ajax->script('$("#bar-progress").css("width" , "' . $startProgress . '%");'); $ajax->send(); }
/** * Override parent's display method * * @since 0.1 */ function display($cachable = false, $urlparams = false) { $document = JFactory::getDocument(); $viewType = $document->getType(); $viewName = JRequest::getCmd('view', $this->getName()); $viewLayout = JRequest::getCmd('layout', 'default'); $view = $this->getView($viewName, $viewType, ''); // Set the layout $view->setLayout($viewLayout); $format = JRequest::getCmd('format', 'html'); // Test if the call is for Ajax if (!empty($format) && $format == 'ejax') { // Ajax calls. if (!JRequest::checkToken('GET')) { $ejax = new Ejax(); $ejax->script('alert("' . JText::_('Not allowed here') . '");'); $ejax->send(); } $data = JRequest::get('POST'); $arguments = array(); foreach ($data as $key => $value) { if (JString::substr($key, 0, 5) == 'value') { if (is_array($value)) { $arrVal = array(); foreach ($value as $val) { $item = $val; $item = stripslashes($item); $item = rawurldecode($item); $arrVal[] = $item; } $arguments[] = $arrVal; } else { $val = stripslashes($value); $val = rawurldecode($val); $arguments[] = $val; } } } if (!method_exists($view, $viewLayout)) { $ejax = new Ejax(); $ejax->script('alert("' . JText::sprintf('Method %1$s does not exists in this context', $viewLayout) . '");'); $ejax->send(); return; } // Execute method call_user_func_array(array($view, $viewLayout), $arguments); } else { // Non ajax calls. // Get/Create the model if ($model = $this->getModel($viewName)) { // Push the model into the view (as default) $view->setModel($model, true); } ob_start(); if ($viewLayout != 'default') { if ($cachable) { $cache = JFactory::getCache('com_easyblog', 'view'); $cache->get($view, $viewLayout); } else { if (!method_exists($view, $viewLayout)) { $view->display(); } else { // @todo: Display error about unknown layout. $view->{$viewLayout}(); } } } else { $view->display(); } $html = ob_get_contents(); ob_end_clean(); $class = EasyBlogHelper::getJoomlaVersion() >= '3.0' ? 'eb-bootstrap' : 'eb-joomla'; // @task: Set additional wrapper for dashboard views if (JRequest::getVar('view') == 'blog') { $wrapper = '<script type="text/javascript">'; $wrapper .= 'EasyBlog.require()'; $wrapper .= ' .script("dashboard","admin")'; $wrapper .= ' .done(function($){'; $wrapper .= ' $("#ezblog-dashboard")'; $wrapper .= ' .implement(EasyBlog.Controller.Dashboard, {});'; $wrapper .= ' });'; $wrapper .= '</script>'; $wrapper .= '<div id="ezblog-dashboard" class="' . $class . '">'; $wrapper .= $html; $wrapper .= '<span id="easyblog-token" style="display:none;"><input type="hidden" name="' . EasyBlogHelper::getHelper('Token')->get() . '" value="1" /></span>'; $wrapper .= '</div>'; echo $wrapper; } else { echo '<div class="' . $class . '">'; echo '<script type="text/javascript">'; echo 'EasyBlog.require().script("admin").done()'; echo '</script>'; echo $html; echo '<span id="easyblog-token" style="display:none;"><input type="hidden" name="' . EasyBlogHelper::getHelper('Token')->get() . '" value="1" /></span>'; echo '</div>'; } // Add necessary buttons to the site. if (method_exists($view, 'registerToolbar')) { $view->registerToolbar(); } // Override submenu if needed if (method_exists($view, 'registerSubmenu')) { $this->_loadSubmenu($view->getName(), $view->registerSubmenu()); } } }
public function confirmAutopost($type, $id) { $ajax = new Ejax(); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_AUTOPOST_DIALOG_INFO'); $action = EasyBlogHelper::getJoomlaVersion() >= '1.6' ? 'Joomla.submitbutton(\'autopost\');' : 'submitbutton(\'autopost\')'; ob_start(); ?> <p><?php echo JText::sprintf('COM_EASYBLOG_AUTOPOST_DIALOG_DESC', ucfirst($type)); ?> </p> <div class="dialog-actions"> <input type="button" onclick="ejax.closedlg();" name="edialog-cancel" id="edialog-cancel" class="button" value="<?php echo JText::_('COM_EASYBLOG_CANCEL_BUTTON'); ?> "> <input type="button" class="button" value="<?php echo JText::_('COM_EASYBLOG_SHARE_BUTTON'); ?> " onclick="<?php echo $action; ?> "> </div> <?php $options->content = ob_get_contents(); ob_end_clean(); $ajax->script('$("#adminForm input[name=autopost_type]").val("' . $type . '");'); $ajax->script('$("#adminForm input[name=autopost_selected]").val("' . $id . '");'); $ajax->dialog($options); $ajax->send(); }
/** * Responsible to submit a new team request. */ function addJoinRequest($post) { $ajax = new Ejax(); $app = JFactory::getApplication(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $now = EasyBlogHelper::getDate(); if (empty($post['id']) || $post['userid'] != $my->id || $my->id == 0) { $ajax->script('eblog.system.loader(false);'); $ajax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), JText::_('COM_EASYBLOG_ERROR'), '450', 'auto'); $ajax->send(); } $id = (int) $post['id']; $teamUser = EasyBlogHelper::getTable('TeamBlogUsers'); $teamUser->set('team_id', $id); $teamUser->set('user_id', $my->id); if ($teamUser->exists()) { $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_INFO'))->set('content', JText::_('COM_EASYBLOG_TEAMBLOG_ALREADY_MEMBER'))->toObject(); $ajax->dialog($options); return $ajax->send(); } $request = EasyBlogHelper::getTable('TeamBlogRequest'); $request->team_id = $id; $request->user_id = $my->id; $request->ispending = '1'; $request->created = $now->toMySQL(); if ($request->exists()) { $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_INFO'))->set('content', JText::_('COM_EASYBLOG_TEAMBLOG_REQUEST_ALREADY_SENT'))->toObject(); $ajax->dialog($options); return $ajax->send(); } if (!$request->store()) { $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_ERROR'))->set('content', $request->getError())->toObject(); $ajax->dialog($options); return $ajax->send(); } // @rule: Send moderation emails out. $request->sendModerationEmail(); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_INFO'))->set('content', JText::_('COM_EASYBLOG_TEAMBLOG_REQUEST_SENT'))->toObject(); $ajax->dialog($options); $ajax->script('eblog.system.loader(false);'); $ajax->send(); return; }
public function search($query = '', $elementId = '') { $ajax = new Ejax(); $lang = JFactory::getLanguage(); $lang->load('com_easyblog', JPATH_ROOT); $model = EasyBlogHelper::getModel('Search'); $posts = $model->searchText($query); if (empty($elementId)) { $elementId = 'write_content'; } if (empty($posts)) { $ajax->script('$("#editor-' . $elementId . ' .search-results-content").height(24);'); $ajax->assign('editor-' . $elementId . ' .search-results-content', JText::_('No results found')); return $ajax->send(); } $count = count($posts); if ($count > 10) { $height = "240"; } else { $height = "24" * $count; } $config = EasyBlogHelper::getConfig(); ob_start(); ?> <ul class="blog-search-items reset-ul"> <?php foreach ($posts as $entry) { $postLink = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $entry->id); $externalLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $entry->id, false, true); ?> <li> <input type="button" onclick="eblog.editor.search.insert('<?php echo $externalLink; ?> ', '<?php echo $entry->title; ?> ', '<?php echo $elementId; ?> ');return false;" value="<?php echo JText::_('COM_EASYBLOG_DASHBOARD_EDITOR_INSERT_LINK'); ?> " class="ui-button float-r mts" /> <div class="tablecell"> <a href="<?php echo $externalLink; ?> " target="_BLANK"><?php echo $entry->title; ?> </a> <?php echo JText::_('COM_EASYBLOG_ON'); ?> <?php echo $this->formatDate($config->get('layout_dateformat'), $entry->created); ?> </div> <div class="clear"></div> </li> <?php } ?> </ul> <?php $html = ob_get_contents(); ob_end_clean(); $ajax->assign('editor-content .search-results-content', $html); $ajax->script('$("#editor-content .search-results-content").height(' . $height . ');'); $ajax->script('$("#editor-content .search-results-content").show();'); return $ajax->send(); }
function quickSaveDraft($params, $content) { $ajax = new Ejax(); $my = JFactory::getUser(); $acl = EasyBlogACLHelper::getRuleSet(); if (empty($acl->rules->add_entry) || $my->id == 0) { $ajax->script('eblog.dashboard.quickpost.notify("error" , "' . JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG') . '");'); $ajax->script('eblog.loader.doneLoading( "quickpost-loading" );'); return $ajax->send(); } if (empty($params['title']) || $params['title'] == JText::_('COM_EASYBLOG_DASHBOARD_QUICKPOST_TITLE_INSTRUCTIONS')) { $ajax->script('eblog.dashboard.quickpost.notify("error" , "' . JText::_('COM_EASYBLOG_DASHBOARD_QUICKPOST_NO_TITLE_ERROR') . '");'); $ajax->script('eblog.loader.doneLoading( "quickpost-loading" );'); return $ajax->send(); } if (empty($params['content'])) { $ajax->script('eblog.dashboard.quickpost.notify("error" , "' . JText::_('COM_EASYBLOG_DASHBOARD_QUICKPOST_NO_CONTENT_ERROR') . '");'); $ajax->script('eblog.loader.doneLoading( "quickpost-loading" );'); return $ajax->send(); } // Try to load this draft to see if it exists $draft = EasyBlogHelper::getTable('Draft', 'Table'); $draft->bind($params, true); $draft->content = $content; $draft->created_by = $my->id; $my = JFactory::getUser(); $draft->store(); $ajax->script('eblog.dashboard.quickpost.notify("success" , "' . JText::sprintf('COM_EASYBLOG_DASHBOARD_QUICKPOST_SAVED_DRAFT_SUCCESS') . '");'); $ajax->script('$( "#reset-form" ).click();'); $ajax->script('eblog.editor.tag.clear("' . JText::_('COM_EASYBLOG_TAG_NO_SELECTED_TAGS') . '");'); $ajax->script('eblog.loader.doneLoading( "quickpost-loading" );'); return $ajax->send(); }
/** * Remove an item as featured * * @param string $type The type of this item * @param int $postId The unique id of the item * * @return string Json string **/ function removeFeatured($type, $postId) { $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleset(); // Only super admins can feature items if (!EasyBlogHelper::isSiteAdmin() && !$acl->rules->feature_entry) { $ajax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), '', '450'); $ajax->send(); return; } EasyBlogHelper::removeFeatured($type, $postId); $idName = ''; $message = ''; switch ($type) { case 'blogger': $idName = '#blogger_title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED'); break; case 'teamblog': $idName = '#teamblog_title_' . $postId; $message = JText::_('COM_EASYBLOG_TEAMBLOG_UNFEATURED'); break; case 'post': default: $idName = '#title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOG_UNFEATURED'); break; } $ajax->script('$("' . $idName . '").removeClass("featured-item");'); $ajax->alert($message, JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); $ajax->send(); return; }