Changeset 44

Show
Ignore:
Timestamp:
12/21/05 16:24:53 (3 years ago)
Author:
ben
Message:

Restricts commenting privileges to logged in users by default, and provides a tool in account settings to combat this.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/units/users/userdetails_actions.php

    r36 r44  
    3636                                                                                                                                } 
    3737                                                                                                                                $messages[] = gettext("Email address updated."); 
     38                                                                                                                        } 
     39                                                                                                                } 
     40                                                                                                                 
     41                                                                                                                if ($usertype == 'person' && isset($_REQUEST['publiccomments'])) { 
     42                                                                                                                        if ($_REQUEST['publiccomments'] == "yes") { 
     43                                                                                                                                run("users:flags:set",array("publiccomments",$id,"1")); 
     44                                                                                                                                $messages[] = gettext("Public comments and discussion set to 'on'."); 
     45                                                                                                                        } else { 
     46                                                                                                                                run("users:flags:unset",array("publiccomments",$id)); 
     47                                                                                                                                $messages[] = gettext("Public comments and discussion set to 'off'."); 
    3848                                                                                                                        } 
    3949                                                                                                                } 
  • devel/units/users/userdetails_edit.php

    r42 r44  
    5757                ); 
    5858 
     59                $emailReplies = gettext("Make comments public"); 
     60                $emailRules = gettext("Set this to 'yes' if you would like anyone to be able to comment on your resources (by default only logged-in users can). Note that this may make you vulnerable to spam."); 
     61                 
     62                $body .= <<< END 
     63                 
     64                <h5>$emailReplies</h5> 
     65                <p> 
     66                        $emailRules 
     67                </p> 
     68                 
     69END; 
     70 
     71        $emailreplies = run("users:flags:get",array("publiccomments",$page_owner)); 
     72        if ($emailreplies) { 
     73                $body .= run("templates:draw", array( 
     74                        'context' => 'databox', 
     75                        'name' => gettext("Public comments: "), 
     76                        'column1' => "<label><input type=\"radio\" name=\"publiccomments\" value=\"yes\" checked=\"checked\" /> " . gettext("Yes") . "</label> <label><input type=\"radio\" name=\"publiccomments\" value=\"no\" /> " . gettext("No") . "</label>" 
     77                ) 
     78                ); 
     79        } else { 
     80                $body .= run("templates:draw", array( 
     81                        'context' => 'databox', 
     82                        'name' => gettext("Public comments: "), 
     83                        'column1' => "<label><input type=\"radio\" name=\"publiccomments\" value=\"yes\" /> " . gettext("Yes") . "</label> <label><input type=\"radio\" name=\"publiccomments\" value=\"no\" checked=\"checked\" /> " . gettext("No") . "</label>" 
     84                ) 
     85                ); 
     86        } 
     87                 
    5988                $emailReplies = gettext("Receive email messages"); 
    6089                $emailRules = gettext("Set this to 'yes' if you would like to receive comments, replies and interesting discussion through your email. You can also access them by clicking on <a href=\"". url ."_activity/\">view your activity</a>."); 
  • devel/units/weblogs/weblogs_actions.php

    r38 r44  
    138138                                                                                                                                $owner = (int) $_SESSION['userid']; 
    139139                                                                                                                                $posted = time(); 
    140                                                                                                                                 db_query("insert into weblog_comments 
    141                                                                                                                                                         set body = '$body', 
    142                                                                                                                                                                 posted = $posted, 
    143                                                                                                                                                                 postedname = '$postedname', 
    144                                                                                                                                                                 owner = $owner, 
    145                                                                                                                                                                 post_id = $post_id"); 
    146                                                                                                                                 if (run("users:flags:get",array("emailreplies",$post->owner))) { 
    147                                                                                                                                         $email = db_query("select email,username from users where ident = " . ((int) $post->owner)); 
    148                                                                                                                                         if (sizeof($email) > 0) { 
    149                                                                                                                                                 $username = $email[0]->username; 
    150                                                                                                                                                 $email = $email[0]->email; 
    151                                                                                                                                                 $message = gettext(sprintf("You have received a comment from %s on your blog post '%s'. It reads as follows:",$_REQUEST['postedname'],stripslashes($post->title))); 
    152                                                                                                                                                 $message .= "\n\n\n" . $_REQUEST['new_weblog_comment'] . "\n\n\n"; 
    153                                                                                                                                                 $message .= gettext(sprintf("To reply and see other comments on this blog post, click here: %s", url . $username . "/weblog/" . $post->ident . ".html")); 
    154                                                                                                                                                 $message = wordwrap($message); 
    155                                                                                                                                                 mail(stripslashes($email),stripslashes($post->title),$message,"From: " . sitename . "<" . email . ">"); 
     140                                                                                                                                if (logged_on || run("users:flags:get",array("publiccomments",$post->owner))) { 
     141                                                                                                                                        db_query("insert into weblog_comments 
     142                                                                                                                                                                set body = '$body', 
     143                                                                                                                                                                        posted = $posted, 
     144                                                                                                                                                                        postedname = '$postedname', 
     145                                                                                                                                                                        owner = $owner, 
     146                                                                                                                                                                        post_id = $post_id"); 
     147                                                                                                                                        if (run("users:flags:get",array("emailreplies",$post->owner))) { 
     148                                                                                                                                                $email = db_query("select email,username from users where ident = " . ((int) $post->owner)); 
     149                                                                                                                                                if (sizeof($email) > 0) { 
     150                                                                                                                                                        $username = $email[0]->username; 
     151                                                                                                                                                        $email = $email[0]->email; 
     152                                                                                                                                                        $message = gettext(sprintf("You have received a comment from %s on your blog post '%s'. It reads as follows:",$_REQUEST['postedname'],stripslashes($post->title))); 
     153                                                                                                                                                        $message .= "\n\n\n" . $_REQUEST['new_weblog_comment'] . "\n\n\n"; 
     154                                                                                                                                                        $message .= gettext(sprintf("To reply and see other comments on this blog post, click here: %s", url . $username . "/weblog/" . $post->ident . ".html")); 
     155                                                                                                                                                        $message = wordwrap($message); 
     156                                                                                                                                                        mail(stripslashes($email),stripslashes($post->title),$message,"From: " . sitename . "<" . email . ">"); 
     157                                                                                                                                                } 
    156158                                                                                                                                        } 
    157                                                                                                                                 } else { 
    158                                                                                                                                         $messages[] = run("users:flags:get",array("emailreplies",$post->owner)) . "#" . $post->owner; 
    159                                                                                                                                 } 
    160                                                                     $messages[] = gettext("Your comment has been added."); // gettext variable 
     159                                                                            $messages[] = gettext("Your comment has been added."); // gettext variable 
     160                                                                } 
    161161                                                                                                                        } else { 
    162162                                                                                                                                $messages[] = gettext("Your comment could not be posted. The system thought it was spam."); 
  • devel/units/weblogs/weblogs_posts_view.php

    r40 r44  
    155155                                                                ); 
    156156 
    157                         $run_result .= run("weblogs:comments:add",$post); 
     157                        if (logged_on || run("users:flags:get",array("publiccomments",$post->owner))) { 
     158                                $run_result .= run("weblogs:comments:add",$post); 
     159                        } else { 
     160                                $run_result .= "<p>" . gettext("You must be logged in to post a comment.") . "</p>"; 
     161                        } 
    158162                         
    159163                } else {