/[drupal]/contributions/modules/captcha/captcha.module
ViewVC logotype

Diff of /contributions/modules/captcha/captcha.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.17, Wed Jan 11 17:41:40 2006 UTC revision 1.18, Thu Jan 12 23:34:58 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: captcha.module,v 1.16 2006/01/10 21:50:36 arnabdotorg Exp $  // $Id: captcha.module,v 1.17 2006/01/11 17:41:40 arnabdotorg Exp $
3    
4  function captcha_help($section = "admin/help#captcha") {  function captcha_help($section = "admin/help#captcha") {
5    $output = "";    $output = "";
# Line 54  function captcha_settings() { Line 54  function captcha_settings() {
54    
55      //check for TTF support      //check for TTF support
56      if (!function_exists(imagettftext))      if (!function_exists(imagettftext))
57        form_set_error('No TTF support', t('Your image library does not seem to have TrueType font support. Captcha will work, but will use the default inbuilt font.'));  
58          drupal_set_message(t('Your image library does not seem to have TrueType font support. Captcha will work, but will use the default inbuilt font.'),'status');
59    
60      else {      else {
61    
# Line 152  function captcha_user($type, &$edit, &$n Line 153  function captcha_user($type, &$edit, &$n
153  * Comment callback; adds captcha field to new comment form.  * Comment callback; adds captcha field to new comment form.
154  */  */
155  function captcha_comment($edit, $op) {  function captcha_comment($edit, $op) {
   global $user;  
156    
   // check if captcha is enabled for form type  
   //if ($user->uid == 0 && !_captcha_istrue("captcha_comment_anonymous")) return;  
   //if ($user->uid != 0 && !_captcha_istrue("captcha_comment_registered")) return;  
157    switch ($op) {    switch ($op) {
158      case 'validate': //this is redundant, not followed      case 'validate': //this is redundant, not followed
159        // only validate captcha once for a comment.        // only validate captcha once for a comment.
# Line 201  function _captcha_form() { Line 198  function _captcha_form() {
198    
199    
200  function captcha_form_alter($formid, &$form) {  function captcha_form_alter($formid, &$form) {
201    
202      global $user;
203    
204    switch($formid) {    switch($formid) {
205      case 'comment_form':      case 'comment_form':
206    
207          // check if captcha is enabled for form type
208          if ($user->uid == 0 && !_captcha_istrue("captcha_comment_anonymous")) return;
209          if ($user->uid != 0 && !_captcha_istrue("captcha_comment_registered")) return;
210    
211        // include logic to remove captcha if the current entry is a valid captcha        // include logic to remove captcha if the current entry is a valid captcha
212        if (!$_SESSION['captcha_comment_correct'] && !($_POST['edit']['captcha_word'] != '' && _captcha_validate($_POST['edit']['captcha_word']))) {        if (!$_SESSION['captcha_comment_correct'] && !($_POST['edit']['captcha_word'] != '' && _captcha_validate($_POST['edit']['captcha_word']))) {
213          $form['captcha'] = _captcha_form();          $form['captcha'] = _captcha_form();

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.2