Ejemplo n.º 1
0
 /**
  * Overrides parent's delete method to add our own logic.
  *
  * @return boolean
  * @param object $db
  */
 public function delete($pk = null)
 {
     EB::loadLanguages(JPATH_ADMINISTRATOR);
     $config = EB::config();
     // If the table contains posts, do not allow them to delete the category.
     if ($this->getCount()) {
         $this->setError(JText::sprintf('COM_EASYBLOG_CATEGORIES_DELETE_ERROR_POST_NOT_EMPTY', $this->title));
         return false;
     }
     // If the table contains subcategories, do not allow them to delete the parent.
     if ($this->getChildCount()) {
         $this->setError(JText::sprintf('COM_EASYBLOG_CATEGORIES_DELETE_ERROR_CHILD_NOT_EMPTY', $this->title));
         return false;
     }
     // If the current user deleting this is the creator of the category, remove the points too.
     $my = JFactory::getUser();
     if ($this->created_by == $my->id) {
         EB::loadLanguages(JPATH_ROOT);
         // Integrations with EasyDiscuss.
         EB::easydiscuss()->log('easyblog.delete.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_CATEGORY', $this->title));
         EB::easydiscuss()->addPoint('easyblog.delete.category', $my->id);
         EB::easydiscuss()->addBadge('easyblog.delete.category', $my->id);
         // Integrations with EasySocial
         EB::easysocial()->assignPoints('category.remove', $this->created_by);
         // Integrations with JomSocial
         EB::jomsocial()->assignPoints('com_easyblog.category.remove', $this->created_by);
         // Integrations with AUP
         EB::aup()->assignPoints('plgaup_easyblog_delete_category', $this->created_by, JText::sprintf('COM_EASYBLOG_AUP_CATEGORY_DELETED', $this->title));
     }
     // Remove avatar if previously already uploaded.
     $this->removeAvatar();
     $state = parent::delete();
     return $state;
 }
Ejemplo n.º 2
0
 function delete($pk = null)
 {
     if (parent::delete($pk)) {
         $this->deleteMembers();
         return true;
     }
 }
Ejemplo n.º 3
0
 /**
  * Deletes a custom field group
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     // Require the parent to delete the group
     $state = parent::delete($pk);
     // Remove custom fields associated with the group
     $model = EB::model('Fields');
     $model->deleteGroupAssociation($this->id);
     return $state;
 }
Ejemplo n.º 4
0
 /**
  * Overrides parent's delete method to add our own logic.
  *
  * @return boolean
  * @param object $db
  */
 function delete($pk = null)
 {
     $db = $this->getDBO();
     $query = 'SELECT COUNT(1) FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post') . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('category_id') . '=' . $db->Quote($this->id);
     $db->setQuery($query);
     $count = $db->loadResult();
     if ($count > 0) {
         return false;
     }
     return parent::delete($pk);
 }
Ejemplo n.º 5
0
 /**
  * Override the parent's delete method as we want to apply our own logics
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     $state = parent::delete($pk);
     // After deleting the team, delete the team members and groups access as well
     $model = EB::model('TeamBlogs');
     // Delete members
     $this->deleteMembers();
     // Delete groups
     $model->deleteGroupRelations($this->id);
     return $state;
 }
Ejemplo n.º 6
0
 /**
  * Overrides the parent's delete method
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     // Try to delete the comment item first
     $state = parent::delete($pk);
     // Get the current logged in user
     $my = JFactory::getUser();
     // Remove comment's stream
     $this->removeStream();
     if ($this->created_by != 0 && $this->published == '1') {
         // Get the blog post
         $post = $this->getBlog();
         // Load language
         EB::loadLanguages();
         $config = EB::config();
         // Integrations with EasyDiscuss
         EB::easydiscuss()->log('easyblog.delete.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_COMMENT', $post->title));
         EB::easydiscuss()->addPoint('easyblog.delete.comment', $this->created_by);
         EB::easydiscuss()->addBadge('easyblog.delete.comment', $this->created_by);
         // AlphaUserPoints
         EB::aup()->assign('plgaup_easyblog_delete_comment', $this->created_by, JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED'));
         // Assign EasySocial points
         EB::easysocial()->assignPoints('comments.remove', $this->created_by);
         // Deduct points from the comment author
         EB::jomsocial()->assignPoints('com_easyblog.comments.remove', $this->created_by);
         // Deduct points from the blog post author
         if ($my->id != $post->created_by) {
             // Deduct EasySocial points
             EB::easysocial()->assignPoints('comments.remove.author', $post->created_by);
             // JomSocial
             EB::jomsocial()->assignPoints('com_easyblog.comments.removeblogger', $post->created_by);
             // AUP
             EB::aup()->assignPoints('plgaup_easyblog_delete_comment_blogger', $post->created_by, JText::sprintf('COM_EASYBLOG_AUP_COMMENT_DELETED_BLOGGER', $url, $post->title));
         }
     }
     return $state;
 }
Ejemplo n.º 7
0
 /**
  * delete revision
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     // before we delete, we need to know if this revision is a draft or not.
     // if yes, we need to check is this revision is a brand new doc or not. if yes,
     // we need to delete item in easyblog_post as well.
     $postId = $this->post_id;
     // we need to load from jtable directly instead of post lib to avoid
     // same revision item being treated as blog item.
     $blog = EB::table('Blog');
     $blog->load($postId);
     if ($blog->published == EASYBLOG_POST_BLANK || $blog->published == EASYBLOG_POST_DRAFT) {
         $blog->delete();
     }
     $state = parent::delete($pk);
     return $state;
 }
Ejemplo n.º 8
0
 /**
  * Override delete routine from the parent as we need to run
  * some custom routines in our deletion
  */
 public function delete($pk = null)
 {
     // @rule: Delete reports that are associated to this group since the blog post is deleted, it shouldn't be tied to any reports.
     $this->deleteReports();
     // @rule: Delete relationships from jomsocial stream
     $this->removeStream();
     $status = parent::delete($pk);
     $config = EasyBlogHelper::getConfig();
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     // Run some cleanup for our own plugins
     $dispatcher->trigger('onAfterEasyBlogDelete', array(&$this));
     // Delete all relations
     $this->deleteBlogTags();
     $this->deleteMetas();
     $this->deleteComments();
     $this->deleteTeamContribution();
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     // Deduct points from respective systems
     // @rule: Integrations with EasyDiscuss
     EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.blog', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_BLOG', $this->title));
     EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.blog', $this->created_by);
     EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.blog', $this->created_by);
     // Assign EasySocial points
     $easysocial = EasyBlogHelper::getHelper('EasySocial');
     $easysocial->assignPoints('blog.remove', $this->created_by);
     // @task: Integrations with Jomsocial. Remove points necessarily.
     if ($config->get('main_jomsocial_userpoint')) {
         $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php';
         if (JFile::exists($path)) {
             require_once $path;
             CUserPoints::assignPoint('com_easyblog.blog.remove', $this->created_by);
         }
     }
     // @rule: Mighty Touch karma points
     EasyBlogHelper::getHelper('MightyTouch')->setKarma($this->created_by, 'remove_blog');
     // @since 1.2
     // AlphaUserPoints integrations. Remove points necessarily
     if (EasyBlogHelper::isAUPEnabled()) {
         AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_blog', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_BLOG_DELETED', $this->title));
     }
     // Delete group relations
     EasyBlogHelper::getHelper('Groups')->deleteContribution($this->id);
     if ($status) {
         //activity logging.
         $activity = new stdClass();
         $activity->actor_id = $this->created_by;
         $activity->target_id = '0';
         $activity->context_type = 'post';
         $activity->context_id = $this->id;
         $activity->verb = 'delete';
         $activity->uuid = $this->title;
         EasyBlogHelper::activityLog($activity);
     }
     return $status;
 }
Ejemplo n.º 9
0
 /**
  * Overrides parent's delete method to add our own logic.
  *
  * @return boolean
  * @param object $db
  */
 function delete($pk = null)
 {
     $db = $this->getDBO();
     $config = EasyBlogHelper::getConfig();
     $query = 'SELECT COUNT(1) FROM ' . EasyBlogHelper::getHelper('SQL')->nameQuote('#__easyblog_post') . ' ' . 'WHERE ' . EasyBlogHelper::getHelper('SQL')->nameQuote('category_id') . '=' . $db->Quote($this->id);
     $db->setQuery($query);
     $count = $db->loadResult();
     if ($count > 0) {
         return false;
     }
     $my = JFactory::getUser();
     if ($this->created_by != 0 && $this->created_by == $my->id) {
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $config = EasyBlogHelper::getConfig();
         // @rule: Integrations with EasyDiscuss
         EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.category', $my->id, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_CATEGORY', $this->title));
         EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.category', $my->id);
         EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.category', $my->id);
         // Assign EasySocial points
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         $easysocial->assignPoints('category.remove', $this->created_by);
         if ($config->get('main_jomsocial_userpoint')) {
             $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php';
             if (JFile::exists($path)) {
                 require_once $path;
                 CUserPoints::assignPoint('com_easyblog.category.remove', $this->created_by);
             }
         }
         // @since 1.2
         // AlphaUserPoints
         if (EasyBlogHelper::isAUPEnabled()) {
             AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_category', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_CATEGORY_DELETED', $this->title));
         }
     }
     /* TODO */
     //remove avatar if previously already uploaded.
     $avatar = $this->avatar;
     if ($avatar != 'cdefault.png' && !empty($avatar)) {
         $avatar_config_path = $config->get('main_categoryavatarpath');
         $avatar_config_path = rtrim($avatar_config_path, '/');
         $avatar_config_path = JString::str_ireplace('/', DIRECTORY_SEPARATOR, $avatar_config_path);
         $upload_path = JPATH_ROOT . DIRECTORY_SEPARATOR . $avatar_config_path;
         $target_file_path = $upload_path;
         $target_file = JPath::clean($target_file_path . DIRECTORY_SEPARATOR . $avatar);
         if (JFile::exists($target_file)) {
             JFile::delete($target_file);
         }
     }
     //activity logging.
     $activity = new stdClass();
     $activity->actor_id = $my->id;
     $activity->target_id = '0';
     $activity->context_type = 'category';
     $activity->context_id = $this->id;
     $activity->verb = 'delete';
     $activity->uuid = $this->title;
     $return = parent::delete();
     if ($return) {
         EasyBlogHelper::activityLog($activity);
     }
     return $return;
 }
Ejemplo n.º 10
0
 public function delete($cid = null)
 {
     $state = parent::delete($cid);
     $my = JFactory::getUser();
     // @rule: Remove comment's stream
     $this->removeStream();
     if ($this->created_by != 0 && $this->published == '1') {
         $blog = EasyBlogHelper::getTable('Blog');
         $blog->load($this->post_id);
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $config = EasyBlogHelper::getConfig();
         // @rule: Integrations with EasyDiscuss
         EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.comment', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_DELETE_COMMENT', $blog->title));
         EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.comment', $this->created_by);
         EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.comment', $this->created_by);
         // @since 1.2
         // AlphaUserPoints
         if (EasyBlogHelper::isAUPEnabled()) {
             AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::_('COM_EASYBLOG_AUP_COMMENT_DELETED'));
             // @rule: Add comment for blog author
             if ($blog->created_by != $this->created_by) {
                 AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_comment_blogger', AlphaUserPointsHelper::getAnyUserReferreID($blog->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_COMMENT_DELETED_BLOGGER', $url, $blog->title));
             }
         }
         // Assign EasySocial points
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         $easysocial->assignPoints('comments.remove', $this->created_by);
         // @rule: Deduct points from the comment author
         EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.remove', $this->created_by);
         // @rule: Give points to the blog author
         if ($my->id != $blog->created_by) {
             // Assign EasySocial points
             $easysocial->assignPoints('comments.remove.author', $blog->created_by);
             EasyBlogHelper::addJomsocialPoint('com_easyblog.comments.removeblogger', $blog->created_by);
         }
     }
     return $state;
 }
Ejemplo n.º 11
0
 /**
  * Override parent's logics
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function delete($pk = null)
 {
     // Request parent to delete items first
     $state = parent::delete($pk);
     // When a custom field is deleted from the site, delete the values too
     $model = EB::model('Fields');
     $model->deleteFieldValue($this->id);
     return $state;
 }
Ejemplo n.º 12
0
 /**
  * Overrides parent's delete method to add our own logic.
  *
  * @return boolean
  * @param object $db
  */
 function delete($pk = null)
 {
     $db = $this->getDBO();
     // Ensure that tag associations are removed
     $this->deletePostTag();
     if ($this->created_by != 0) {
         JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
         $config = EasyBlogHelper::getConfig();
         // @rule: Integrations with EasyDiscuss
         EasyBlogHelper::getHelper('EasyDiscuss')->log('easyblog.delete.tag', $this->created_by, JText::sprintf('COM_EASYBLOG_EASYDISCUSS_HISTORY_NEW_TAG', $this->title));
         EasyBlogHelper::getHelper('EasyDiscuss')->addPoint('easyblog.delete.tag', $this->created_by);
         EasyBlogHelper::getHelper('EasyDiscuss')->addBadge('easyblog.delete.tag', $this->created_by);
         // Assign EasySocial points
         $easysocial = EasyBlogHelper::getHelper('EasySocial');
         $easysocial->assignPoints('tag.remove', $this->created_by);
         if ($config->get('main_jomsocial_userpoint')) {
             $jsUserPoint = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'userpoints.php';
             if (JFile::exists($jsUserPoint)) {
                 require_once $jsUserPoint;
                 CUserPoints::assignPoint('com_easyblog.tag.remove', $this->created_by);
             }
         }
         // AlphaUserPoints
         // since 1.2
         if (EasyBlogHelper::isAUPEnabled()) {
             AlphaUserPointsHelper::newpoints('plgaup_easyblog_delete_tag', AlphaUserPointsHelper::getAnyUserReferreID($this->created_by), '', JText::sprintf('COM_EASYBLOG_AUP_TAG_DELETED', $this->title));
         }
     }
     $my = JFactory::getUser();
     //activity logging.
     $activity = new stdClass();
     $activity->actor_id = $my->id;
     $activity->target_id = '0';
     $activity->context_type = 'tag';
     $activity->context_id = $this->id;
     $activity->verb = 'delete';
     $activity->uuid = $this->title;
     $state = parent::delete();
     if ($state) {
         EasyBlogHelper::activityLog($activity);
     }
     return $state;
 }