public function processEdit(Zikula_ProcessHook $hook) { // will need this to update URLs in table // get db table and column for where statement ModUtil::dbInfoLoad('EZComments'); $tables = DBUtil::getTables(); $column = $tables['EZComments_column']; $mod = DataUtil::formatForStore($hook->getCaller()); $objectid = DataUtil::formatForStore($hook->getId()); $areaid = DataUtil::formatForStore($hook->getAreaId()); $where = "{$column['modname']} = '{$mod}' AND {$column['objectid']} = '{$objectid}' AND {$column['areaid']} = '{$areaid}'"; $objUrl = $hook->getUrl()->getUrl(null, null, false, false); // objecturl provided by subscriber // the fourth arg is forceLang and if left to default (true) then the url is malformed - core bug as of 1.3.0 $comment = array('url' => System::getHomepageUrl() . DataUtil::formatForStore($objUrl)); DBUtil::updateObject($comment, 'EZComments', $where); }
/** * Example process update hook handler. * * This should be executed only if the validation has succeeded. * This is used for both new and edit actions. We can determine which * by the presence of an ID field or not. * * Subject is the object being created/edited that we're attaching to. * args[id] Is the ID of the subject. * args[caller] the module who notified of this event. * * @param Zikula_ProcessHook $hook The hookable event. * * @return void */ public function process_update(Zikula_ProcessHook $hook) { if (!$this->validation) { return; } $object = $this->validation->getObject(); if (!$hook->getId()) { $urlData = $hook->getUrl()->serialize(); $areaId = $hook->getAreaId(); $caller = $hook->getCaller(); // new so do an INSERT including the $urlData, and $hook->getAreaId(); } else { // existing so do an UPDATE } }