Esempio n. 1
0
 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'));
 }
Esempio n. 2
0
 /**
  * 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);
     }
 }
Esempio n. 3
0
}
// import joomla controller library
jimport('joomla.application.component.controller');
require_once JPATH_ROOT . DS . 'components' . DS . 'com_bookpro' . DS . 'libraries' . DS . 'rad' . DS . 'bootstrap.php';
require_once JPATH_ROOT . DS . 'components' . DS . 'com_bookpro' . DS . 'libraries' . DS . 'base' . DS . 'libs' . DS . 'basic.php';
include JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_bookpro' . DS . 'helpers' . DS . 'importer.php';
include JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'log.php';
$siteUrl = 'var siteURL = "' . JURI::base() . '";';
JHtml::_('bootstrap.framework');
$doc = JFactory::getDocument();
$doc->addScript(JURI::root() . 'components/com_bookpro/assets/js/bookpro.js');
$doc->addScriptDeclaration($siteUrl);
$doc->addStyleSheet(JURI::base() . 'components/com_bookpro/assets/css/bookpro.css');
$error_lifetime = JFactory::getApplication()->getUserState('com_bookpro.errors.lifetime', 0, 'int');
$error_lifetime = $error_lifetime > time() ? 1 : 0;
JBLog::init($error_lifetime);
$language = JFactory::getLanguage();
/* @var $language JLanguage */
//$language->load('com_bookpro.common', JPATH_ADMINISTRATOR);
AImporter::defines();
AImporter::css('common');
$controller = JRequest::getCmd('controller');
$view = JRequest::getCmd('view');
if (!$controller) {
    $controller = JControllerLegacy::getInstance('BookPro');
} else {
    if (file_exists(JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php')) {
        require_once JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php';
    } else {
        JError::raiseError(403, JText::_('Access Forbidden'));
    }