Set the current site ID, and ``is_public`` based on the setting
        ``COMMENTS_DEFAULT_APPROVED``.
975941
def save(self, *args, **kwargs):
        
        if not self.id:
            self.is_public = settings.COMMENTS_DEFAULT_APPROVED
            self.site_id = current_site_id()
        super(ThreadedComment, self).save(*args, **kwargs)
84811
def upload_site(self):
        """"""
        if not os.path.isdir(self._config['build_dir']):
            message = 'Site not built at {0}'.format(self._config['build_dir'])
            self._logger.error(message)
            raise RuntimeError(message)

        ltdclient.upload(self._config)
139262
def update_trackers(self):
        
        self.posts_count = self.posts.filter(approved=True).count()
        first_post = self.posts.all().order_by('created').first()
        last_post = self.posts.filter(approved=True).order_by('-created').first()
        self.first_post = first_post
        self.last_post = last_post
        self.last_post_on = last_post.created if last_post else None
        self._simple_save()
        # Trigger the forum-level trackers update
        self.forum.update_trackers()
1204856
def set_to_public(self, request, queryset):
        
        queryset.update(is_public=True, modified=now())
851012
public function init(){
		// set the htmleditor "content_css" based on the active site
		$htmlEditorConfig = HtmlEditorConfig::get_active();
		$site = Multisites::inst()->getActiveSite();
		if($site && $theme = $site->getSiteTheme()){

			$editorCSS = Config::inst()->get(CMSMain::class, 'multisites_editor_css_dir');
			if (isset($editorCSS[$theme])) {
				$cssFile = THEMES_DIR . "/$theme/" . $editorCSS[$theme] . "/editor.css";
			} else {
				$cssFile = THEMES_DIR . "/$theme/css/editor.css";
			}
			
			if(file_exists(BASE_PATH . '/' . $cssFile)){
				// NOTE: This ensures editor.css is invalided properly when it's updated.
				$cssFile = $cssFile.'?m='.filemtime(BASE_PATH.'/'.$cssFile);
				
				$htmlEditorConfig->setOption('content_css', $cssFile);
				
				if($this->owner->getRequest()->isAjax() && $this->owner instanceof CMSPageEditController){
					// Add editor css path to header so javascript can update ssTinyMceConfig.content_css
					$this->owner->getResponse()->addHeader('X-HTMLEditor_content_css', $cssFile);	
				}
				
			}	
		}
	}
464474
def set_uri(self, uri):
        '''
        
        '''
        publicObj = self.get_public()
        if publicObj is not None:
            publicObj.set_uri(uri)
        else:
            publicObj = Cpublic()
            publicObj.set_uri(uri)
            self.set_public(publicObj)
673490
def allow(self, comment, content_object, request):
        
        # Parent class check
        if not super(FluentCommentsModerator, self).allow(comment, content_object, request):
            return False

        # Akismet check
        if self.akismet_check:
            akismet_result = akismet_check(comment, content_object, request)
            if self.akismet_check_action == 'delete' and akismet_result in (SpamStatus.ProbableSpam, SpamStatus.DefiniteSpam):
                return False  # Akismet marked the comment as spam.
            elif self.akismet_check_action == 'auto' and akismet_result == SpamStatus.DefiniteSpam:
                return False  # Clearly spam

        return True
978885
def _valid(m, comment=VALID_RESPONSE, out=None):
    '''
    
    '''
    return _set_status(m, status=True, comment=comment, out=out)
296668
public function populateDefaults()
    {
        $defaults = $this->owner->config()->get('defaults');

        // Set if comments should be enabled by default
        if (isset($defaults['ProvideComments'])) {
            $this->owner->ProvideComments = $defaults['ProvideComments'];
        } else {
            $this->owner->ProvideComments = $this->owner->getCommentsOption('enabled') ? 1 : 0;
        }

        // If moderation options should be configurable via the CMS then
        if (isset($defaults['ModerationRequired'])) {
            $this->owner->ModerationRequired = $defaults['ModerationRequired'];
        } elseif ($this->owner->getCommentsOption('require_moderation')) {
            $this->owner->ModerationRequired = 'Required';
        } elseif ($this->owner->getCommentsOption('require_moderation_nonmembers')) {
            $this->owner->ModerationRequired = 'NonMembersOnly';
        } else {
            $this->owner->ModerationRequired = 'None';
        }

        // Set login required
        if (isset($defaults['CommentsRequireLogin'])) {
            $this->owner->CommentsRequireLogin = $defaults['CommentsRequireLogin'];
        } else {
            $this->owner->CommentsRequireLogin = $this->owner->getCommentsOption('require_login') ? 1 : 0;
        }
    }
1289908
def _set_siteinfo(self):
        
        data = self._load_response('siteinfo').get('query')

        mostviewed = data.get('mostviewed')
        self.data['mostviewed'] = []
        for item in mostviewed[1:]:
            if item['ns'] == 0:
                self.data['mostviewed'].append(item)

        general = data.get('general')

        self.params.update({'title': general.get('sitename')})
        self.params.update({'lang': general.get('lang')})
        self.data['site'] = general.get('wikiid')

        info = {}
        for item in general:
            ginfo = general.get(item)
            if ginfo:
                info[item] = ginfo
        self.data['info'] = info

        siteviews = data.get('siteviews')
        if siteviews:
            values = [x for x in siteviews.values() if x]
            if values:
                self.data['siteviews'] = int(sum(values) / len(values))
            else:
                self.data['siteviews'] = 0

        stats = data.get('statistics')
        for item in stats:
            self.data[item] = stats[item]
590956
def from_id(reddit_session, subreddit_id):
        """"""
        pseudo_data = {'id': subreddit_id,
                       'permalink': '/comments/{0}'.format(subreddit_id)}
        return Submission(reddit_session, pseudo_data)
843919
def reject_source(ident, comment):
    ''''''
    source = get_source(ident)
    source.validation.on = datetime.now()
    source.validation.comment = comment
    source.validation.state = VALIDATION_REFUSED
    if current_user.is_authenticated:
        source.validation.by = current_user._get_current_object()
    source.save()
    return source
227697
def add_comment(self, post=None, name=None, email=None, pub_date=None,
                    website=None, body=None):
        
        if post is None:
            if not self.posts:
                raise CommandError("Cannot add comments without posts")
            post = self.posts[-1]
        post["comments"].append({
            "user_name": name,
            "user_email": email,
            "submit_date": pub_date,
            "user_url": website,
            "comment": body,
        })
57566
def edit
      security_transgression_unless @comment.can_be_edited_by?(@user)

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js
      end
    end
17499
public function doAddSite() {
		$site = $this->owner->getNewItem('new-' . Site::class .'-0', false);
		$site->write();

		return $this->owner->redirect(
			singleton(CMSPageEditController::class)->Link("show/$site->ID")
		);
	}
1295650
def decide
      @site = current_account.sites.find_or_initialize_by_url(checkid_request.trust_root)
      @site.persona = current_account.personas.find(params[:persona_id] || :first) if sreg_request || ax_store_request || ax_fetch_request
    end
98679
public function change()
    {
		$table = $this->table('comment');
        $table->addColumn('external', 'boolean', array(
            'null' => false,
            'after' => 'article',
			'default' => 0,
		))
		->addColumn('pending', 'boolean', array(
            'null' => false,
            'after' => 'active',
			'default' => 0,
			'comment' => 'Pending approval',
        ))
        ->addColumn('spam', 'boolean', array(
            'null' => false,
            'after' => 'active',
			'default' => 0,
        ))
        ->addColumn('name', 'string', array(
            'null' => true,
            'after' => 'user',
            'length' => 32,
        ))
        ->addColumn('ip', 'string', array(
            'null' => true,
            'after' => 'timestamp',
            'length' => 30,
        ))
        ->addColumn('referer', 'string', array(
            'null' => true,
            'after' => 'ip',
            'length' => 300,
        ))
        ->addColumn('useragent', 'string', array(
            'null' => true,
            'after' => 'referer',
            'length' => 300,
        ))
        ->addColumn('email', 'string', array(
            'null' => true,
            'after' => 'useragent',
            'length' => 300,
        ))
		->addIndex(array('name'))
		->addIndex(array('pending'))
        ->save(); 
    }