Changeset 701 for trunk/app/models

Show
Ignore:
Timestamp:
08/08/08 16:03:49 (4 months ago)
Author:
aarkerio
Message:

New validates

Location:
trunk/app/models
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/models/answer.php

    r365 r701  
    88class Answer extends AppModel { 
    99    
    10   public $belongsTo = array('Question' => 
     10 public $belongsTo = array('Question' => 
    1111                                    array('className'  => 'Question', 
    1212                                          'conditions' => '', 
     
    1616                          ); 
    1717  
    18   public $validate = array( 
    19                 'comment'  => VALID_NOT_EMPTY,  
    20                 'user_id'  => VALID_NOT_EMPTY, 
    21                 'entry_id' => VALID_NOT_EMPTY, 
    22                 'username' => VALID_NOT_EMPTY 
    23                    ); 
    24     
     18 
     19 public $validate = array( 
     20  'answer' => array( 
     21                    'rule'       => array('minLength', 2), 
     22                    'message'    => 'Answer must be at least two characters long', 
     23            'allowEmpty' => false, 
     24                    'required'   => true  
     25            ), 
     26  'correct' => array( 
     27             'rule'       => 'numeric', 
     28                     'allowEmpty' => false, 
     29                     'required'   => true  
     30             ), 
     31  'question_id' => array( 
     32             'rule'       => 'numeric', 
     33                     'allowEmpty' => false, 
     34                     'required'   => true  
     35             ), 
     36  'user_id' => array( 
     37             'rule'       => 'numeric', 
     38                     'allowEmpty' => false, 
     39                     'required'   => true  
     40             ) 
     41   ); 
    2542} 
    2643?> 
  • trunk/app/models/catglossary.php

    r282 r701  
    88class Catglossary extends AppModel 
    99{ 
    10     public $name    = 'Catglossary'; 
     10  public $name    = 'Catglossary'; 
    1111     
    12     public $belongsTo = array('User' => 
     12  public $belongsTo = array('User' => 
    1313                         array('className'      => 'User', 
    1414                               'conditions'     => null, 
     
    2020                         ); 
    2121     
    22     public $hasMany = array('Glossary' => 
     22 public $hasMany = array('Glossary' => 
    2323                array('className'   => 'Glossary', 
    24                                   'foreignKey'  => 'catglossary_id' 
     24                                  'foreignKey'  => 'catglossary_id', 
     25                                  'order'       => 'item' 
    2526                         ) 
    2627                  ); 
    2728 
    2829     
    29     public $validate = array( 
    30       'title' => VALID_NOT_EMPTY, 
    31         'description' => VALID_NOT_EMPTY, 
    32       'user_id' => VALID_NOT_EMPTY, 
    33       'status' => VALID_NOT_EMPTY 
     30 public $validate = array( 
     31  'title' => array( 
     32                    'rule'       => array('minLength', 8), 
     33                    'message'    => 'Title must be at least 8 characters long', 
     34            'allowEmpty' => false, 
     35                    'required'   => true  
     36            ), 
     37       
     38  'description' => array( 
     39                    'rule'       => array('minLength', 8), 
     40                    'message'    => 'Title must be at least 8 characters long', 
     41            'allowEmpty' => false, 
     42                    'required'   => true  
     43            ) 
    3444   ); 
    35      
    3645} 
    37  
    3846?> 
  • trunk/app/models/entry.php

    r593 r701  
    55{ 
    66     
    7     public $belongsTo = array('User' => 
     7 public $belongsTo = array('User' => 
    88                           array('className'  => 'User', 
    99                                 'conditions' => '', 
     
    1919                     ); 
    2020     
    21     public $hasMany = array('Comment' => 
     21 public $hasMany = array('Comment' => 
    2222                         array('className'     => 'Comment', 
    2323                               'conditions'    =>  null, 
     
    3030                         ) 
    3131                  ); 
    32      
    33     public $validate = array( 
    34       'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    35       'user_id' => VALID_NOT_EMPTY, 
    36       'body' => VALID_NOT_EMPTY, 
    37       'status' => VALID_NOT_EMPTY 
     32 
     33 public $validate = array( 
     34  'title' => array( 
     35                    'rule'       => array('minLength', 4), 
     36                    'message'    => 'Title must be at least four characters long', 
     37            'allowEmpty' => false, 
     38                    'required'   => true  
     39            ), 
     40       
     41  'body' => array( 
     42                    'rule'       => array('minLength', 8), 
     43                    'message'    => 'Entry must be at least 8 characters long', 
     44            'allowEmpty' => false, 
     45                    'required'   => true  
     46            ) 
    3847   ); 
    3948 
    40 public function getComments($blogger_id) 
    41 { 
    42   
     49 public function getComments($blogger_id) 
     50 { 
    4351  $conditions   = array('Entry.user_id'=>$blogger_id); 
    4452  $fields       = array('Entry.title', 'Entry.id'); 
  • trunk/app/models/lesson.php

    r632 r701  
    3737                 );   
    3838 
    39   public $validate = array( 
    40       'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    41       'body' => VALID_NOT_EMPTY, 
    42       'user_id' => VALID_NOT_EMPTY 
     39 public $validate = array( 
     40  'title' => array( 
     41                    'rule'       => array('minLength', 4), 
     42                    'message'    => 'Title must be at least four characters long', 
     43            'allowEmpty' => false, 
     44                    'required'   => true  
     45            ), 
     46       
     47  'body' => array( 
     48                    'rule'       => array('minLength', 8), 
     49                    'message'    => 'Entry must be at least 8 characters long', 
     50            'allowEmpty' => false, 
     51                    'required'   => true  
     52            ), 
     53  'user_id' => array( 
     54             'rule'       => 'numeric', 
     55                     'allowEmpty' => false, 
     56                     'required'   => true  
     57             ) 
    4358   ); 
    44 /* 
    45 public $validate = array( 
    46         'login' => array('alphanumeric' => array( 
    47                                                  'rule' => 'alphaNumeric', 
    48                                              'required' => true, 
    49                                                          'message' => 'Alphabets and numbers only' 
    50                                    ), 
    51                                 'between' => array( 
    52                                            'rule' => array('between', 5, 15), 
    53                                                                                'message' => 'Between 5 to 15 characters' 
    54                                            ) 
    55                                 ), 
    56                        'password' => array( 
    57                                    'rule' => array('minLength', '8'), 
    58                                                                'message' => 'Mimimum 8 characters long' 
    59                                    ), 
    60                        'email' => 'email', 
    61                        'born' => array( 
    62                                'rule' => 'date', 
    63                                'message' => 'Enter a valid date', 
    64                                                            'allowEmpty' => true 
    65                                ) 
    66                        ); */ 
    6759} 
    6860?> 
  • trunk/app/models/news.php

    r537 r701  
    3232                         ); 
    3333 
    34      public $validate = array( 
    35            'title' => VALID_NOT_EMPTY, 
    36            'user_id' => VALID_NOT_EMPTY, 
    37            'body' => VALID_NOT_EMPTY, 
    38            'status' => VALID_NOT_EMPTY 
    39      ); 
    40 /* 
    4134public $validate = array( 
    42         'login' => array('alphanumeric' => array( 
    43                                                  'rule' => 'alphaNumeric', 
    44                                              'required' => true, 
    45                                                          'message' => 'Alphabets and numbers only' 
    46                                    ), 
    47                                 'between' => array( 
    48                                            'rule' => array('between', 5, 15), 
    49                                                                                'message' => 'Between 5 to 15 characters' 
    50                                            ) 
    51                                 ), 
    52                        'password' => array( 
    53                                    'rule' => array('minLength', '8'), 
    54                                                                'message' => 'Mimimum 8 characters long' 
    55                                    ), 
    56                        'email' => 'email', 
    57                        'born' => array( 
    58                                'rule' => 'date', 
    59                                'message' => 'Enter a valid date', 
    60                                                            'allowEmpty' => true 
    61                                ) 
    62                        ); */  
     35  'title' => array( 
     36                   'rule'       => array('minLength', 4), 
     37                   'message'    => 'Title must be at least four characters long', 
     38           'allowEmpty' => false, 
     39                   'required'   => true  
     40          ), 
     41  'body'  => array( 
     42                   'rule'       => array('minLength', 8), 
     43                   'message'    => 'Entry must be at least 8 characters long', 
     44           'allowEmpty' => false, 
     45                   'required'   => true  
     46          ), 
     47   'reference' => array( 
     48             'rule' => 'url', 
     49                         'allowEmpty' => true, 
     50                         'required'   => false, 
     51                         'message'    => 'Your URL format lucks incorrect',  
     52   ), 
     53  'theme_id' => array( 
     54             'rule'       => 'numeric', 
     55                     'allowEmpty' => false, 
     56                     'required'   => true  
     57             ) 
     58  );  
    6359} 
    6460?>