Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wal5hy

Pages: [1]
1
Older versions / DataObject->validateMaxValueOf($column, $max) bug
« on: March 02, 2010, 11:29:20 am »
I'm pretty sure that there is a small bug in the DataObject->validateMaxValueOf($column, $max) function. (line 1108 of DataObject.class.php in environment/classes/dataaccess)

The problem is that the function does not work when validating ints and floats (however it does work with string), the reason is that in the code the wrong variables are being compared

line 1114 onwards reads:
       // Get value...
       $value = $this->getColumnValue($column);
       
       // Integer and float...
       if(is_int($value) || is_float($column)) {
         return $column <= $max;
       }

line 1118 should read:
       if(is_int($value) || is_float($value)) {
         return $value <= $max; 
       }
not:
       if(is_int($value) || is_float($column)) {
         return $column <= $max;
       }

This same error (comparing a column name to an integer) is repeated on lines 1126, and again in the function validateMinValueOf lines 1149 and line 1157

hope this helps

bug applies to version 1.6.2

2
Development / Re: Request for additional hook
« on: January 23, 2010, 12:37:36 pm »
Yup not a problem I will add it to the wiki.

3
Development / Request for additional hook
« on: January 22, 2010, 12:55:25 pm »
Hi All,

I'm developing a plugin for fengoffice which provides the ability to add a location to an event using google maps.

I'm integrating with Feng Office using the following hooks:

object_edit_categories : add an additional category to edit location to ProjectEvent

render_object_properties : when viewing an event add a static map to the properties section

object_validate : when an event is being saved, validate my location object too, if it doesnt validate then the event object wont save either, great!

My problem is that my location database table needs to use the ProjectEvent id as a foreign key, so i can't save my location object before the Projectevent has been saved and given an Id.

Really need an extra hook:  'after_object_save' to be added to DataObject.class.php line 420 so it reads something like this:

     function save() {
       $errors = $this->doValidate();
      
       if(is_array($errors)) {
         throw new DAOValidationError($this, $errors);
       } // if
      
       Hook::fire('before_object_save', $this, $ret);
       $didSave = $this->doSave();
          Hook::fire('after_object_save', $this, $didSave);
       return $didSave;
     } // save

Unless im missing something?

I'm developing the plugin for a client but hope to opensource it and add it to the feng office plugins list in the future. Will write a blog post describing how to write a plugin too if anyone's interested (although i may be missing a few things still at the moment)

Pages: [1]