function addSubscription($post) { $ejax = new Ejax(); $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $isModerate = false; $userId = $post['userid']; $email = $post['email']; $bloggerId = $post['id']; if (JString::trim($email) == '') { $ejax->alert(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_EMAIL_IS_EMPTY'), JText::_('COM_EASYBLOG_ERROR'), '450', 'auto'); $ejax->send(); return; } //check if userid not empty (site member) //check the userid exists in table. If exists, just do a update incase user email has been updated. //if userid empty (non-site member) //check if the email address already in table. //if yes, show message say the email already in. //if not, add the email into table $model = $this->getModel('Blogger'); $sid = ''; if ($userId == 0) { $sid = $model->isBloggerSubscribedEmail($bloggerId, $email); if ($sid != '') { //user found. // show message. $ejax->alert(JText::_('COM_EASYBLOG_SUBSCRIBE_BLOGGER_ALREADY_SUBSCRIBED'), JText::_('COM_EASYBLOG_WARNING'), '450', 'auto'); $ejax->send(); return; } else { $model->addBloggerSubscription($bloggerId, $email); } } else { $sid = $model->isBloggerSubscribedUser($bloggerId, $userId); if ($sid != '') { // user found. // update the email address $model->updateBloggerSubscriptionEmail($sid, $email); } else { //add new subscription. $model->addBloggerSubscription($bloggerId, $email, $userId); } } $ejax->alert(JText::_('COM_EASYBLOG_SUBSCRIBE_BLOGGER_SUCCESS'), JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); $ejax->send(); return; // echo '<pre>'; // print_r($post); // echo '</pre>'; // exit; }
/** * 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; }
function updateDisplayDate($eleId, $dateString) { $ajax = new Ejax(); $config = EasyBlogHelper::getConfig(); $date = EasyBlogHelper::getDate($dateString); $now = EasyBlogDateHelper::toFormat($date, $config->get('layout_dateformat')); $ajax->assign('datetime_' . $eleId . ' .datetime_caption', $now); return $ajax->send(); }
function confirmRejectBlog($draftId) { $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); $ids = $draftId; if (!is_array($ids)) { $ids = array($ids); } JTable::addIncludePath(EBLOG_TABLES); foreach ($ids as $id) { $blog = EasyBlogHelper::getTable('Draft', 'Table'); $blog->load($id); // @rule: Check if the blog is really under pending if ($blog->pending_approval != 1) { $options = new stdClass(); $options->content = JText::_('COM_EASYBLOG_NOT_ALLOWED'); $ajax->dialog($options); return $ajax->send(); } } $content = ''; $content .= '<p>' . JText::_('COM_EASYBLOG_PENDING_REJECT_PENDING_ENTRIES_MESSAGE') . '</p>'; $content .= '<form name="reject-post" id="reject-post" action="' . JRoute::_('index.php?option=com_easyblog&c=pending&task=reject') . '" method="post">'; $content .= '<div class="mtm">'; $content .= ' <label for="message">' . JText::_('COM_EASYBLOG_PENDING_SPECIFY_REASON') . '</label>'; $content .= ' <textarea class="full" id="message" name="message"></textarea>'; $content .= '</div>'; $content .= '<div class="dialog-actions">'; $content .= JHTML::_('form.token'); foreach ($ids as $id) { $content .= ' <input type="hidden" name="draft_id[]" value="' . $id . '" />'; } $content .= ' <input type="button" value="' . JText::_('COM_EASYBLOG_PENDING_CANCEL_BUTTON') . '" class="button" id="edialog-cancel" name="edialog-cancel" onclick="ejax.closedlg();" />'; $content .= ' <input type="submit" value="' . JText::_('COM_EASYBLOG_PENDING_PROCEED_BUTTON') . '" class="button" />'; $content .= '</div>'; $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_PENDING_DIALOG_CONFIRM_REJECT_TITLE'); $options->content = $content; $ajax->dialog($options); return $ajax->send(); }
public function preview($blogId) { $ajax = new Ejax(); $mailq = EasyBlogHelper::getTable('Mailqueue'); $mailq->load($blogId); $url = JURI::root() . 'administrator/index.php?option=com_easyblog&c=spools&task=preview&id=' . $mailq->id . '&' . EasyBlogHelper::getToken() . '=1'; $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_EMAIL_PREVIEW'); $options->content = '<iframe src="' . $url . '" width="100%" height="500"></iframe>'; $options->width = '750'; $ajax->dialog($options); $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(); }
public function showVoters($elementId, $type) { $ajax = new Ejax(); $model = $this->getModel('Ratings'); $config = EasyBlogHelper::getConfig(); $voters = $model->getRatingUsers($elementId, $type, $config->get('main_ratings_display_raters_max')); $guests = false; $theme = new CodeThemes(); $theme->set('guests', $guests); $theme->set('voters', $voters); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_DIALOG_TITLE_RECENT_VOTERS'); $options->content = $theme->fetch('ratings.users.php'); $ajax->dialog($options); 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 preview($blogId) { $ajax = new Ejax(); $mailq = DiscussHelper::getTable('Mailqueue'); $mailq->load($blogId); $options = new stdClass(); $options->title = JText::_('COM_EASYDISCUSS_EMAIL_PREVIEW'); $options->content = $mailq->body; $buttons = array(); $button = new stdClass(); $button->title = JText::_('COM_EASYDISCUSS_OK'); $button->action = 'disjax.closedlg();'; $button->className = 'btn-primary'; $buttons[] = $button; $options->buttons = $buttons; $ajax->dialog($options); $ajax->send(); }
function import() { $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); ob_start(); ?> <form name="import" id="import-settings" method="post" enctype="multipart/form-data"> <div class="mtm"> <label for="file"><?php echo JText::_('Exported File'); ?> </label> <input type="file" name="file" /> </div> <div class="dialog-actions"> <?php echo JHTML::_('form.token'); ?> <input type="hidden" name="option" value="com_easyblog" /> <input type="hidden" name="c" value="settings" /> <input type="hidden" name="task" value="import" /> <input type="button" value="<?php echo JText::_('COM_EASYBLOG_CANCEL_BUTTON'); ?> " class="button" id="edialog-cancel" name="edialog-cancel" onclick="ejax.closedlg();" /> <input type="submit" value="<?php echo JText::_('COM_EASYBLOG_IMPORT_BUTTON'); ?> " class="button" /> </div> </form> <?php $contents = ob_get_contents(); ob_end_clean(); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_PENDING_DIALOG_CONFIRM_REJECT_TITLE'); $options->content = $contents; $ajax->dialog($options); return $ajax->send(); }
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(); }
public function submitForm($type, $post) { $ejax = new Ejax(); $mainframe = JFactory::getApplication(); $my = JFactory::getUser(); $config = EasyBlogHelper::getConfig(); $acl = EasyBlogACLHelper::getRuleSet(); $id = isset($post['id']) ? $post['id'] : ''; if (empty($acl->rules->allow_subscription) && (empty($my->id) && !$config->get('main_allowguestsubscribe'))) { $theme = new CodeThemes(); $theme->set('message', JText::_('COM_EASYBLOG_NO_PERMISSION_TO_SUBSCRIBE_BLOG')); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } $isModerate = false; $userId = isset($post['userid']) ? $post['userid'] : ''; $email = JString::trim($post['email']); //registration $register = isset($post['esregister']) ? true : false; $fullname = isset($post['esfullname']) ? $post['esfullname'] : ''; $username = isset($post['esusername']) ? $post['esusername'] : ''; $newId = ''; $msg = ''; if (JString::trim($email) == '') { $theme = new CodeThemes(); $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_EMPTY_ERROR')); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } else { if (!EasyBlogHelper::getHelper('Email')->isValidInetAddress($email)) { $theme = new CodeThemes(); $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_INVALID_ERROR')); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } } if (JString::trim($fullname) == '') { $theme = new CodeThemes(); $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_NAME_EMPTY_ERROR')); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } if ($register && $my->id == 0) { if (JString::trim($username) == '') { $theme = new CodeThemes(); $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_USERNAME_EMPTY_ERROR')); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } $registor = EasyBlogHelper::getRegistor(); $options = array('username' => $username, 'email' => $email); $validate = $registor->validate($options); if ($validate !== true) { $theme = new CodeThemes(); $theme->set('message', $validate); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } else { $options['fullname'] = $fullname; $newId = $registor->addUser($options); if (!is_numeric($newId)) { // registration failed. $msg = $newId; } else { $userId = $newId; } } } // Real logic operation goes here. $method = 'subscribe' . ucfirst($type); // @rule: Process mailchimp subscriptions here. EasyBlogHelper::getHelper('Mailchimp')->subscribe($email, $fullname); if (!$this->{$method}($id, $userId, $email, $fullname)) { $theme = new CodeThemes(); $theme->set('message', JText::_('COM_EASYBLOG_SUBSCRIPTION_ALREADY_SUBSCRIBED_ERROR')); $theme->set('type', $type); $theme->set('id', $id); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_ERROR_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.error.php'))->toObject(); $ejax->dialog($options); return $ejax->send(); } // message if ($register && is_numeric($newId)) { $message = JText::sprintf('COM_EASYBLOG_YOU_SUCCESSFULLY_SUBSCRIBED_AND_REGISTERED_AS_MEMBER'); } else { $message = JText::sprintf('COM_EASYBLOG_SUBSCRIPTION_SUBSCRIBED_SUCCESS', $email); } $theme = new CodeThemes(); $theme->set('message', $message); $options = EasyBlogHelper::getHelper('DialogOptions')->set('title', JText::_('COM_EASYBLOG_SUBSCRIPTION_SUCCESS_DIALOG_TITLE'))->set('content', $theme->fetch('ajax.dialog.subscribe.success.php'))->toObject(); $ejax->dialog($options); // Send email to notify admin upon successful subscriptions $user = EasyBlogHelper::getTable('Profile'); $user->load($userId); $date = EasyBlogDateHelper::getDate(); $subscriberName = $my->id == 0 ? $post['esfullname'] : $user->getName(); $data = array('title' => JText::_('COM_EASYBLOG_SUBSCRIPTION_SUCCESS_DIALOG_TITLE'), 'subscriber' => $subscriberName, 'subscriberLink' => EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $user->id, false, true), 'subscriberAvatar' => $user->getAvatar(), 'subscriberDate' => EasyBlogDateHelper::toFormat($date, '%A, %B %e, %Y'), 'type' => $type); if ($type == 'entry') { $data['reviewLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $id, false, true); } if ($type == 'category') { $data['reviewLink'] = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $id, false, true); } $emailTitle = JText::_('COM_EASYBLOG_NEW') . ' ' . JText::_('COM_EASYBLOG_SUBSCRIPTION_TYPE_' . strtoupper($type)) . ' ' . strtolower(JText::_('COM_EASYBLOG_SUBSCRIPTION')); $emails = array(); $notification = EasyBlogHelper::getHelper('Notification'); $config = EasyBlogHelper::getConfig(); // @rule: if custom_email_as_admin is enabled, use custom email as admin email if ($config->get('custom_email_as_admin')) { // @rule: Send to custom email addresses $notification->getCustomEmails($emails); } else { // @rule: Send to administrator's on the site. $notification->getAdminEmails($emails); } $notification->send($emails, $emailTitle, 'email.subscriptions', $data); return $ejax->send(); }
public function getNews() { $news = EasyBlogHelper::getRecentNews(); $content = ''; ob_start(); if ($news) { foreach ($news as $item) { ?> <li> <b><span><?php echo $item->title . ' - ' . $item->date; ?> </span></b> <div><?php echo $item->desc; ?> </div> </li> <?php } } else { ?> <li><?php echo JText::_('Unable to contact news server'); ?> </li> <?php } $content = ob_get_contents(); @ob_end_clean(); $ajax = new Ejax(); $ajax->assign('news-items', $content); // $ajax->script( "$('#news-items").html(\'' . addslashes( $content ) . '\');'); $ajax->send(); }
public function confirmUnsubscribeBlog($subscriptionId, $blogId) { $my = JFactory::getUser(); $ajax = new Ejax(); if ($my->id == 0 || !$subscriptionId || !$blogId) { $options = new stdClass(); $options->content = JText::_('COM_EASYBLOG_NOT_ALLOWED'); $ajax->dialog($options); return $ajax->send(); } $themes = new CodeThemes(); $themes->set('subscription_id', $subscriptionId); $themes->set('blog_id', $blogId); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_UNSUBSCRIBE_BLOG_DIALOG_CONFIRM_DELETE_TITLE'); $options->content = $themes->fetch('ajax.dialog.blog.unsubscribe.php'); $ajax->dialog($options); //$ajax->script( 'easyblogApp.element.focus("subscribtion-message).hide()' ); 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; }
/** * 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(); }
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(); }
/** * 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 editComment($id) { $config = EasyBlogHelper::getConfig(); $my = JFactory::getUser(); $ajax = new Ejax(); $acl = EB::acl(); JTable::addIncludePath(EBLOG_TABLES); $comment = EB::table('Comment'); $comment->load($id); $tpl = EB::template(); $tpl->set('comment', $comment); $options = new stdClass(); $options->title = JText::_('COM_EASYBLOG_DASHBOARD_EDIT_COMMENT'); $options->content = $tpl->output('site/comments/dialog.edit'); $ajax->dialog($options); $ajax->send(); }