Changeset 222


Ignore:
Timestamp:
Dec 22, 2006 11:00:07 PM (17 years ago)
Author:
quinn
Message:

Q - added fileuploaded() to FormValidator?.

Location:
tags/2.0.2/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/2.0.2/lib/FormValidator.inc.php

    r221 r222  
    598598
    599599    /**
     600     * Check whether a file was selected for uploading. If file is missing, it's an error.
     601     *
     602     * @param  string $form_name the name of the incoming form variable
     603     * @param  string $msg       the message to display on error
     604     *
     605     * @return bool   true if no errors found, false otherwise
     606     */
     607    function fileUploaded($form_name, $msg='')
     608    {
     609        if (!isset($_FILES[$form_name]['name']) || empty($_FILES[$form_name]['name'])) {
     610            $this->addError($form_name, $msg);
     611            return false;
     612        }
     613       
     614        if (is_array($_FILES[$form_name]['name'])) {
     615            foreach($_FILES[$form_name]['name'] as $f) {
     616                if ('' == $f) {
     617                    $this->addError($form_name, $msg);
     618                    return false;
     619                }
     620            }
     621        } else {
     622            if ('' == $_FILES[$form_name]['name']) {
     623                $this->addError($form_name, $msg);
     624                return false;
     625            }
     626        }
     627       
     628        return true;
     629    }
     630
     631    /**
    600632     * Check whether uploaded file is valid.
    601633     *
     
    605637     * @return bool   true if no errors found, false otherwise
    606638     */
    607     function validateFile($form_name, $msg='')
    608     {
    609         if (isset($_FILES[$form_name]['tmp_name']) && '' == trim($_FILES[$form_name]['tmp_name'])) {
    610             $this->addError($form_name, $msg);
    611             return false;
    612         } else {
    613             return true;
    614         }
    615     }
     639    // function validateFile($form_name, $msg='')
     640    // {
     641    //     if (isset($_FILES[$form_name]['tmp_name']) && '' == trim($_FILES[$form_name]['tmp_name'])) {
     642    //         $this->addError($form_name, $msg);
     643    //         return false;
     644    //     } else {
     645    //         return true;
     646    //     }
     647    // }
    616648
    617649} // THE END
  • tags/2.0.2/lib/Utilities.inc.php

    r221 r222  
    472472 * @return string         Comma list of array values.
    473473 */
    474 function escapedList($in)
     474function escapedList($in, $separator="', 's")
    475475{
    476476    if (is_array($in) && !empty($in)) {
    477         return "'" . join("', '", array_map(array('DB', 'escapeString'), $in)) . "'";
     477        return join($separator, array_map(array('DB', 'escapeString'), $in));
    478478    } else {
    479479        return DB::escapeString($in);
Note: See TracChangeset for help on using the changeset viewer.