Dotclear


Ignore:
Timestamp:
11/04/12 12:06:02 (11 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

add publication date validation on post and page editing forms, fixes #817

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/post.php

    r933 r957  
    8888unset($rs); 
    8989 
     90# Validation flag 
     91$bad_dt = false; 
    9092 
    9193# Get entry informations 
     
    167169          $post_dt = ''; 
    168170     } else { 
    169           $post_dt = strtotime($_POST['post_dt']); 
    170           $post_dt = date('Y-m-d H:i',$post_dt); 
     171          try 
     172          { 
     173               $post_dt = strtotime($_POST['post_dt']); 
     174               if ($post_dt == false || $post_dt == -1) { 
     175                    $bad_dt = true; 
     176                    throw new Exception(__('Invalid publication date')); 
     177               } 
     178               $post_dt = date('Y-m-d H:i',$post_dt); 
     179          } 
     180          catch (Exception $e) 
     181          { 
     182               $core->error->add($e->getMessage()); 
     183          } 
    171184     } 
    172185      
     
    190203 
    191204# Create or update post 
    192 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post) 
     205if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 
    193206{ 
    194207     $cur = $core->con->openCursor($core->prefix.'post'); 
     
    427440      
    428441     '<p><label for="post_dt">'.__('Published on:'). 
    429      form::field('post_dt',16,16,$post_dt). 
     442     form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 
    430443     '</label></p>'. 
    431444      
Note: See TracChangeset for help on using the changeset viewer.

Sites map