Example #1
0
 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 public function showVideoForm($editorName)
 {
     $ajax = new Ejax();
     $my = JFactory::getUser();
     if ($my->id <= 0) {
         $title = JText::_('COM_EASYBLOG_INFO');
         $callback = JText::_('COM_EASYBLOG_NO_PERMISSION_TO_PUBLISH_OR_UNPUBLISH_COMMENT');
         $width = '450';
         $height = 'auto';
         $ajax->alert($callback, $title, $width, $height);
         $ajax->send();
         return;
     }
     $theme = new CodeThemes(true);
     $theme->set('editorName', $editorName);
     $content = $theme->fetch('ajax.dialog.videos.add.php');
     $title = JText::_('COM_EASYBLOG_DASHBOARD_WRITE_INSERT_VIDEO_DIALOG_TITLE');
     $ajax->dialog(EasyBlogHelper::getHelper('DialogOptions')->set('title', $title)->set('content', $content)->toObject());
     return $ajax->send();
 }
Example #4
0
 public function showForm($type, $id = '')
 {
     $my = JFactory::getUser();
     $ajax = new Ejax();
     $config = EasyBlogHelper::getConfig();
     $registration = JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0 ? 0 : $config->get('main_registeronsubscribe');
     $acl = EasyBlogACLHelper::getRuleSet();
     if (empty($my->id) && !$config->get('main_allowguestsubscribe')) {
         $ajax->alert(JText::_('COM_EASYBLOG_SUBSCRIPTION_PLEASE_LOGIN'), JText::_('COM_EASYBLOG_ERROR_DIALOG_LOGIN_TITLE'), '450');
         return $ajax->send();
     }
     if (!$acl->rules->allow_subscription) {
         // For the sake of Joomla 1.5, as they don't have guest group for ACL, we need to ensure that the form doesn't show this when "Allow guest to subscribe" is enabled.
         if (EasyBlogHelper::getJoomlaVersion() >= '1.6' || EasyBlogHelper::getJoomlaVersion() < '1.6' && !$config->get('main_allowguestsubscribe')) {
             $ajax->alert(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_SUBSCRIBE_BLOG'), JText::_('COM_EASYBLOG_ERROR_DIALOG_TITLE'), '450');
             return $ajax->send();
         }
     }
     // Someone may try to do something funny.
     if (!is_string($type)) {
         return;
     }
     // Additional permission checks only if exists
     $method = 'allowSubscribe' . ucfirst($type);
     if (method_exists($this, $method)) {
         if (!$this->{$method}($id)) {
             $ajax->alert(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_SUBSCRIBE_BLOG'), JText::_('COM_EASYBLOG_ERROR_DIALOG_TITLE'), '450');
             return $ajax->send();
         }
     }
     switch ($type) {
         case EBLOG_SUBSCRIPTION_BLOGGER:
             $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_BLOGGER_DIALOG_TITLE');
             $message = JText::_('COM_EASYBLOG_SUBSCRIBE_BLOGGER_INFORMATION');
             break;
         case EBLOG_SUBSCRIPTION_CATEGORY:
             $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_CATEGORY_DIALOG_TITLE');
             $message = JText::_('COM_EASYBLOG_SUBSCRIBE_CATEGORY_INFORMATION');
             break;
         case EBLOG_SUBSCRIPTION_TEAMBLOG:
             $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_TEAMBLOG_DIALOG_TITLE');
             $message = JText::_('COM_EASYBLOG_SUBSCRIBE_TEAM_INFORMATION');
             break;
         case EBLOG_SUBSCRIPTION_ENTRY:
             $title = JText::_('COM_EASYBLOG_SUBSCRIPTION_ENTRY_DIALOG_TITLE');
             $message = JText::_('COM_EASYBLOG_SUBSCRIBE_ENTRY_INFORMATION');
             break;
         default:
         case EBLOG_SUBSCRIPTION_SITE:
             $title = JText::_('COM_EASYBLOG_SUBSCRIPTIONS_SITE_DIALOG_TITLE');
             $message = JText::_('COM_EASYBLOG_SUBSCRIPTIONS_SITE_DIALOG_SUBSCRIPTION_DESC');
             break;
     }
     $theme = new CodeThemes();
     $theme->set('registration', $registration);
     $theme->set('id', $id);
     $theme->set('message', $message);
     $theme->set('type', $type);
     $content = $theme->fetch('ajax.dialog.subscribe.php');
     $ajax->dialog(EasyBlogHelper::getHelper('DialogOptions')->set('title', $title)->set('content', $content)->toObject());
     return $ajax->send();
 }
Example #5
0
 public function deleteComment($id)
 {
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $ajax = new Ejax();
     $acl = EasyBlogACLHelper::getRuleSet();
     JTable::addIncludePath(EBLOG_TABLES);
     $comment = EasyBlogHelper::getTable('Comment', 'Table');
     $comment->load($id);
     if (($my->id == 0 || $my->id != $comment->created_by || !$acl->rules->delete_comment) && !EasyBlogHelper::isSiteAdmin()) {
         $ajax->alert(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_COMMENT'), JText::_('COM_EASYBLOG_INFO'), '450', 'auto');
         return $ajax->send();
     }
     $tpl = new CodeThemes();
     $tpl->set('comment', $comment);
     $options = new stdClass();
     $options->title = JText::_('COM_EASYBLOG_DASHBOARD_DELETE_COMMENT');
     $options->content = $tpl->fetch('ajax.dialog.comments.delete.php');
     $ajax->dialog($options);
     $ajax->send();
 }
Example #6
0
 /**
  * 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;
 }
Example #7
0
 /**
  * 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;
 }
Example #8
0
 function editTagDialog($tagId)
 {
     $my = JFactory::getUser();
     $ajax = new Ejax();
     $acl = EasyBlogACLHelper::getRuleSet();
     if (!$acl->rules->create_tag) {
         $ajax->alert(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_TAG'), JText::_('COM_EASYBLOG_INFO'), '450', 'auto');
         return $ajax->send();
     }
     $tag = EasyBlogHelper::getTable('Tag', 'Table');
     $tag->load($tagId);
     if ($tag->created_by != $my->id) {
         $ajax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), '', '450');
         return $ajax->send();
     }
     $tpl = new CodeThemes('dashboard');
     $tpl->set('tag', $tag);
     $options = new stdClass();
     $options->title = JText::_('COM_EASYBLOG_DASHBOARD_EDIT_TAG');
     $options->content = $tpl->fetch('ajax.dialog.tags.edit.php');
     $ajax->dialog($options);
     return $ajax->send();
 }