Source for file passwdfield.php

Documentation is available at passwdfield.php

  1. <?php
  2. /**
  3. * a text field that is designed to hold passwords
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage FormsLibrary
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. /** parent object */
  17. require_once 'textfield.php';
  18. /** username and password checks */
  19. require_once 'inc/passwords.php';
  20.  
  21. /**
  22. * a text field that is designed to hold passwords
  23. *
  24. @package    Bumblebee
  25. @subpackage FormsLibrary
  26. @todo //TODO:  js to check double entry passwd is the same
  27. */
  28. class PasswdField extends TextField {
  29.   /** @var string  algorithm used to encrypt the data  */
  30.   var $crypt_method = 'md5_compat';
  31.  
  32.   /**
  33.   *  Create a new password field object
  34.   *
  35.   * @param string $name   the name of the field (db name, and html field name
  36.   * @param string $longname  long name to be used in the label of the field in display
  37.   * @param string $description  used in the html title or longdesc for the field
  38.   */
  39.   function PasswdField($name$longname=''$description=''{
  40.     //$this->DEBUG = 10;
  41.     parent::TextField($name$longname$description);
  42.   }
  43.  
  44.   function selectable({
  45.     $t  '<input type="password" name="'.$this->namebase.$this->name.'" ';
  46.     $t .= (isset($this->attr['size']'size="'.$this->attr['size'].'" ' '');
  47.     $t .= (isset($this->attr['maxlength']'maxlength="'.$this->attr['maxlength'].'" ' '');
  48.     $t .= '/>';
  49.     return $t;
  50.   }
  51.  
  52.   /**
  53.   * Don't return data...
  54.   *
  55.   * We shouldn't give up our data too easily.
  56.   */
  57.   function getValue({
  58.     return '';
  59.   }
  60.  
  61.   /**
  62.   * Update the value of the field from user-supplied data, but only if the field was filled in
  63.   *
  64.   * Empty values don't count -- that way an unfilled passwd field will never count as changed
  65.   * @param array $data  list of field_name => value pairs
  66.   */
  67.   function update($data{
  68.     if (parent::update($data)) {
  69.       return ($this->changed = ($this->value != ''));
  70.     }
  71.     return false;
  72.   }
  73.  
  74.   /**
  75.   * return a SQL-injection-cleansed string that can be used in an SQL
  76.   * UPDATE or INSERT statement. i.e. "name='Stuart'".
  77.   *
  78.   * @param string $name the field name to be used
  79.   * @return string  in SQL assignable form
  80.   */
  81.   function sqlSetStr($name=''$force=false{
  82.     if (empty($name)) {
  83.       $name $this->name;
  84.     }
  85.     if ($this->sqlHidden && $this->value != ''{
  86.       $pass makePasswordHash($this->value);
  87.       return $name ."='$pass'";
  88.     else {
  89.       return '';
  90.     }
  91.   }
  92.  
  93.  
  94.  
  95. // class PasswdField
  96.  
  97.  
  98. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:48 +0000 by phpDocumentor 1.3.0