J and Beyond 2013 | An International Joomla! Conference - May 31st - 2nd, 2013, Noordwijkerhout, The Netherlands
It is currently Mon May 20, 2013 9:52 pm

Trigger for editing an event before saving

Proposed new features of merit and bugs to be fixed. Messages are moved here from the main forum by moderators.

Gold and Silver members can add posts here directly.

Trigger for editing an event before saving

Postby spauldingsmails » Thu Jun 18, 2009 5:49 am

I was wondering if there is some way of intercepting a posted event in order to make changes to it prior to the event being saved? For example, we have heavily modified the add/edit event form but we have to use extensive amounts of client-side javascript to massage the data so that it matches the way saveicalevent::save stores the posted form. Even though we have used mootools to improve browser compatibility, there is still a concern that data may not be correctly manipulated and consequently, incorrect information will be stored.

If there is no currently existing method for manipulating the post, is there a possibility it could be incorporated into the icalevent::save and icalrepeat::save methods or saveicalevent::save; say, for example, via a trigger?

E.g.

Code: Select all
class SaveIcalEvent {
   
   function save($array, &$queryModel, $rrule){
      
      $cfg = & JEVConfig::getInstance();
      $db   =& JFactory::getDBO();
      $user =& JFactory::getUser();

               $dispatcher     =& JDispatcher::getInstance();
               JPluginHelper::importPlugin("jevents");
               $res = $dispatcher->trigger( 'onBeforeSaveEvent' , $array, $rrule);
      ...
   }


Cheers


Hayden
spauldingsmails
Posts: 15
Joined: Sun Apr 26, 2009 11:15 am

Re: Trigger for editing an event before saving

Postby Geraint » Thu Jun 18, 2009 8:32 am

No problem - I can add this to the next release.

Geraint
------------
JEvents club members can get priority forum support at the Support Forum. As well as access to a variety of custom JEvents addons and benefits.

Join the JEvents club today!
User avatar
Geraint
Posts: 30529
Joined: Fri Feb 15, 2008 6:14 pm

Re: Trigger for editing an event before saving

Postby spauldingsmails » Thu Jun 18, 2009 11:07 am

Thanks, that would be great.

May I extend my thoughts to the following;

1. An event that triggers before the event save (AdminIcaleventController::save);

E.g.

Code: Select all
        function save(){
                if (!JEVHelper::isEventCreator()){
                        JError::raiseError( 403, JText::_("ALERTNOTAUTH") );
                }

                // clean out the cache
                $cache = &JFactory::getCache('com_jevents');
                $cache->clean(JEV_COM_COMPONENT);

                // JREQUEST_ALLOWHTML requires at least Joomla 1.5 svn9979 (past 1.5 stable)
                $array = JRequest::get('request', JREQUEST_ALLOWHTML);

                $dispatcher =& JDispatcher::getInstance();
                JPluginHelper::importPlugin("jevents");
                $res = $dispatcher->trigger("onBeforeSaveIcalEvent", array(&$array));

                $rrule = SaveIcalEvent::generateRRule($array);


2. An event that triggers before the repeat save (AdminIcalrepeatController::save);

E.g.

Code: Select all
        function save(){
                ...
                $data["X-COLOR"]        =  JRequest::getVar(  "color","");

                $dispatcher =& JDispatcher::getInstance();
                JPluginHelper::importPlugin("jevents");
                $res = $dispatcher->trigger("onBeforeSaveIcalRepeat", array(&$data));

                $detail = iCalEventDetail::iCalEventDetailFromData($data);

                // if we already havea unique event detail then edit this one!
                if ($eventdetailid != $rpt->eventdetail_id){
                        $detail->evdet_id = $rpt->eventdetail_id;
                }
               
                ...
      }


The benefit above being that one can take alternative actions based on what is being updated.

Cheers


Hayden
spauldingsmails
Posts: 15
Joined: Sun Apr 26, 2009 11:15 am


Return to Feature Requests/Suggestions

Who is online

Users browsing this forum: No registered users

cron

Main Menu

User Menu

Hosted By


Who is online

In total there are 0 users online :: 0 registered and 0 hidden (based on users active over the past 5 minutes)
Most users ever online was 94 on Tue Sep 01, 2009 12:33 am

Users browsing this forum: No registered users

Login Form