00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 include_once( 'kernel/classes/ezpersistentobject.php' );
00042
00043 class eZForgotPassword extends eZPersistentObject
00044 {
00045
00046
00047
00048 function eZForgotPassword( $row = array() )
00049 {
00050 $this->eZPersistentObject( $row );
00051 }
00052
00053 function definition()
00054 {
00055 return array( "fields" => array( "id" => array( 'name' => 'ID',
00056 'datatype' => 'integer',
00057 'default' => 0,
00058 'required' => true ),
00059 "user_id" => array( 'name' => "UserID",
00060 'datatype' => 'integer',
00061 'default' => 0,
00062 'required' => true,
00063 'foreign_class' => 'eZUser',
00064 'foreign_attribute' => 'contentobject_id',
00065 'multiplicity' => '0..*' ),
00066 "hash_key" => array( 'name' => "HashKey",
00067 'datatype' => 'string',
00068 'default' => '',
00069 'required' => true ),
00070 "time" => array( 'name' => "Time",
00071 'datatype' => 'integer',
00072 'default' => 0,
00073 'required' => true ) ),
00074 "keys" => array( "id" ),
00075 "increment_key" => "id",
00076 "sort" => array( "id" => "asc" ),
00077 "class_name" => "eZForgotPassword",
00078 "name" => "ezforgot_password" );
00079 }
00080
00081 function createNew( $userID, $hashKey, $time)
00082 {
00083 return new eZForgotPassword( array( "user_id" => $userID,
00084 "hash_key" => $hashKey,
00085 "time" => $time ) );
00086 }
00087
00088 function fetchByKey( $hashKey )
00089 {
00090 return eZPersistentObject::fetchObject( eZForgotPassword::definition(),
00091 null,
00092 array( "hash_key" => $hashKey ),
00093 true );
00094 }
00095
00096
00097
00098
00099
00100 function cleanup()
00101 {
00102 $db =& eZDB::instance();
00103 $db->query( "DELETE FROM ezforgot_password" );
00104 }
00105
00106
00107
00108
00109 function remove( $userID = false )
00110 {
00111 if ( $userID === false )
00112 {
00113 if ( get_class( $this ) == 'ezforgotpassword' )
00114 {
00115 eZPersistentObject::removeObject( eZForgotPassword::definition(),
00116 array( 'id' => $this->attribute( 'id' ) ) );
00117 }
00118 }
00119 else
00120 {
00121 eZPersistentObject::removeObject( eZForgotPassword::definition(),
00122 array( 'user_id' => $userID ) );
00123 }
00124 }
00125
00126 }
00127
00128 ?>