/** * Method to add an exception message to the log with short debug. * * @param Exception $e * @param integer $priority Message priority. * @param int $limit number of showed * * @return void */ public static function addException(Exception $e, $priority = JLog::ERROR, $limit = 2) { static $logged; if (!isset($logged)) { $logged = array(); } //memory usage improve if (version_compare(phpversion(), "5.4.0", ">=")) { $deb = debug_backtrace(false, $limit); } else { $deb = debug_backtrace(false); } $message = $e->getMessage() . ' :|: '; //create hash for error message and priority $hash = md5($message . $priority); //gal last n function calls from debug for ($i = $limit; $i > 0; $i--) { if ($i != $limit) { $message .= ' -> '; } if (array_key_exists($i, $deb)) { $message .= $deb[$i]['file'] . ':: ' . $deb[$i]['line'] . ':' . $deb[$i]['function'] . '()'; } } //if message is new, log it if (!array_key_exists($hash, $logged)) { $logged[$hash] = true; JBLog::add($message, $priority); } }
function save($apply = false) { JRequest::checkToken() or jexit('Invalid Token'); $mainframe = JFactory::getApplication(); /* @var $mainframe JApplication */ $user = JFactory::getUser(); /* @var $user JUser */ $config = JBFactory::getConfig(); $post = JRequest::get('post'); AImporter::model('customer'); $model = new BookProModelCustomer(); if ($user->id) { $customer = $model->getItemByUser(); $post['id'] = $customer->id; } else { $post['id'] = 0; } $isNew = $post['id'] == 0; $id = $model->save($post); if ($id !== false) { $mainframe->enqueueMessage(JText::_('Successfully saved'), 'message'); } else { $mainframe->enqueueMessage(JText::_('Save failed'), 'error'); JBLog::add('Can not save customer info'); } $mainframe->redirect('index.php?option=com_bookpro&view=account&form=profile&Itemid=' . JRequest::getVar('Itemid')); }