Changeset 973

Show
Ignore:
Timestamp:
07/25/08 18:19:04 (3 months ago)
Author:
bermiferrer
Message:

Merging changes from trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/action_mailer/lib/Ak.php

    r972 r973  
    11271127        foreach ($array as $key => $value) { 
    11281128            $key = is_numeric($key) ? $parent : $key; 
    1129             $value = is_array($value) ? "\r\n".xmlFromArray($value, '', $key) : $value; 
     1129            $value = is_array($value) ? "\r\n".Ak::array_to_xml($value, '', $key) : $value; 
    11301130            $_tags[$key] = $key; 
    11311131            $xml .= sprintf("<%s>%s</%s>\r\n", $key, $value, $key); 
  • branches/action_mailer/lib/AkActiveRecord.php

    r821 r973  
    957957    function &_findEvery($options) 
    958958    { 
    959         $limit = isset($options['limit']) ? $options['limit'] : null; 
    960         $offset = isset($options['offset']) ? $options['offset'] : null; 
    961  
    962         $sql = $this->constructFinderSql($options); 
    963         if(!empty($options['bind']) && is_array($options['bind']) && strstr($sql,'?')){ 
    964             $sql = array_merge(array($sql),$options['bind']); 
    965         } 
    966  
    967959        if((!empty($options['include']) && $this->hasAssociations())){ 
    968960            $result =& $this->findWithAssociations($options); 
    969961        }else{ 
     962            $sql = $this->constructFinderSql($options); 
     963            if(!empty($options['bind']) && is_array($options['bind']) && strstr($sql,'?')){ 
     964                $sql = array_merge(array($sql),$options['bind']); 
     965            } 
     966             
    970967            $result =& $this->findBySql($sql); 
    971968        } 
     
    10311028            return false; 
    10321029        } 
    1033         $valid_keys = array('conditions', 'include', 'joins', 'limit', 'offset', 'order', 'sort', 'bind', 'select','select_prefix', 'readonly'); 
     1030        $valid_keys = array('conditions', 'include', 'joins', 'limit', 'offset', 'group', 'order', 'sort', 'bind', 'select','select_prefix', 'readonly'); 
    10341031        foreach (array_keys($options) as $key){ 
    10351032            if (!in_array($key,$valid_keys)){ 
     
    10951092        } 
    10961093         
    1097     } 
    1098  
    1099     function _validateFindOptions(&$options) 
    1100     { 
    1101         $valid_keys = array('conditions', 'include', 'joins', 'limit', 'offset', 'order', 'bind', 'select','select_prefix', 'readonly'); 
    1102         foreach (array_keys($options) as $key){ 
    1103             if (!in_array($key,$valid_keys)) unset($options[$key]); 
    1104         } 
    11051094    } 
    11061095 
     
    13571346        } 
    13581347 
    1359         $sql  .= !empty($options['order']) ? ' ORDER BY  '.$options['order'] : ''; 
     1348        $sql .= !empty($options['group']) ? ' GROUP BY '.$options['group'] : '';  
     1349        $sql .= !empty($options['order']) ? ' ORDER BY '.$options['order'] : ''; 
    13601350 
    13611351        $this->_db->addLimitAndOffset($sql,$options); 
     
    39933983        $attribute_names = Ak::toArray($attribute_names); 
    39943984        foreach ($attribute_names as $attribute_name){ 
    3995             if( 
    3996             $allow_null ? 
    3997             ( 
    3998             isset($this->$attribute_name) ? 
    3999             ( 
    4000             $only_integer ? 
    4001             !is_integer(@$this->$attribute_name) : 
    4002             !is_numeric(@$this->$attribute_name) 
    4003             ) : 
    4004             false 
    4005             ) : 
    4006             ( 
    4007             isset($this->$attribute_name) ? 
    4008             ($only_integer ? !is_integer(@$this->$attribute_name) : !is_numeric(@$this->$attribute_name)) : 
    4009             true 
    4010             ) 
    4011             ) 
    4012             { 
     3985            if (isset($this->$attribute_name)){ 
     3986                $value = $this->$attribute_name; 
     3987                if ($only_integer){ 
     3988                    $is_int = is_numeric($value) && (int)$value == $value; 
     3989                    $has_error = !$is_int; 
     3990                }else{ 
     3991                    $has_error = !is_numeric($value); 
     3992                } 
     3993            }else{ 
     3994                $has_error = $allow_null ? false : true; 
     3995            } 
     3996 
     3997            if ($has_error){ 
    40133998                $this->addError($attribute_name, $message); 
    40143999            } 
  • branches/action_mailer/lib/AkActiveRecord/AkAssociatedActiveRecord.php

    r660 r973  
    343343            return $objects; 
    344344        } 
     345        $result =& $this->_generateObjectGraphFromResultSet($results,$included_associations,$virtual_limit); 
     346        return $result; 
     347    } 
     348     
     349    /** 
     350     * Pass hand-made sql directly to _db->execute and generate the OG with this method. 
     351     * 
     352     * @param ADOResultSet $results            a result set from Db->execute 
     353     * @param array $included_associations     just like in ->find(); $options['include']; but in fact unused 
     354     * @param mixed $virtual_limit             int or false; unsure if this works                      
     355     * @return array                           ObjectGraph as an array 
     356     */ 
     357    function &_generateObjectGraphFromResultSet($results,$included_associations = array(), $virtual_limit = false) 
     358    { 
     359        $objects = array(); 
    345360         
    346361        $i = 0; 
  • branches/action_mailer/lib/AkPlugin/AkPluginManager.php

    r822 r973  
    215215    function guessBestInstallMethod($options = array()) 
    216216    { 
    217         if(is_dir($options['parameters'])){ 
     217        if(!empty($options['parameters']) && is_dir($options['parameters'])){ 
    218218            return 'local directory'; 
    219219        }elseif($this->canUseSvn()){ 
  • branches/action_mailer/lib/utils/generators/scaffold/sintags_templates/controller.php

    r647 r973  
    1111    function index() 
    1212    { 
    13         $this->performAction('listing'); 
     13        $this->redirectToAction('listing'); 
    1414    } 
    1515 
  • branches/action_mailer/lib/utils/generators/scaffold/templates/controller.php

    r647 r973  
    1111    function index() 
    1212    { 
    13         $this->performAction('listing'); 
     13        $this->redirectToAction('listing'); 
    1414    } 
    1515 
  • branches/action_mailer/test/unit/lib/AkActiveRecord/AkValidation.php

    r468 r973  
    671671        $Person->validatesNumericalityOf('age'); 
    672672        $this->assertFalse($Person->hasErrors()); 
     673         
     674        $Person->clearErrors(); 
     675        $Person->age = '18'; 
     676        $Person->validatesNumericalityOf('age','not_valid',true); 
     677        $this->assertFalse($Person->hasErrors()); 
    673678 
    674679        $Person->clearErrors(); 
     
    677682        $this->assertFalse($Person->hasErrors()); 
    678683 
     684        $Person->clearErrors(); 
     685        $Person->age = null; 
     686        $Person->validatesNumericalityOf('age', 'not_valid',false, false); 
     687        $this->assertTrue($Person->hasErrors()); 
    679688    } 
    680689