/** * Method to save a vote. * * @return void * @since 1.8 */ function vote() { // Check for request forgeries. JRequest::checkToken() or $this->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); $app = JFactory::getApplication(); $user_rating = JRequest::getInt('user_rating', -1); if ($user_rating > -1) { $id = JRequest::getInt('id', 0); $viewName = JRequest::getString('view', $this->default_view); $model = $this->getModel($viewName); $r = new JObject(); $success = $model->storeVote($id, $user_rating); $item = &$model->getItem($id); $r->rating = intval($item->rating); $r->rating_count = intval($item->rating_count); if ($success) { $app->enqueueMessage(JText::_('COM_CONTENT_ARTICLE_VOTE_SUCCESS')); } else { $error = JError::getError(); if (!$error) { $app->enqueueMessage(JText::_('COM_CONTENT_ARTICLE_VOTE_FAILURE')); } } $this->sendJsonResponse($r); } }
/** * Method to store a file to the FTP server * * @param string $local Path to local file to store on the FTP server * @param string $remote FTP path to file to create * * @throws Exception * * @return boolean True if successful */ public function store($local, $remote = null) { //-- Avoid all this mess by throwing appropriate exceptions !! if (false === parent::store($local, $remote)) { throw new Exception(JError::getError()); } }
/** * @covers JError::getError */ public function testGetError() { JErrorInspector::manipulateStack(array()); $this->assertThat(JError::getError(), $this->isFalse(), 'There was no error on the error stack but getError did not return false'); // we normally couldn't have strings, but this is only a test JErrorInspector::manipulateStack(array('Error1', 'Error2')); $this->assertThat(JError::getError(), $this->equalTo('Error1'), 'We did not get the proper value back from getError - it should have returned our fake error'); $this->assertThat(JErrorInspector::inspectStack(), $this->equalTo(array('Error1', 'Error2')), 'The stack was changed by getError even though unset was false'); $this->assertThat(JError::getError(true), $this->equalTo('Error1'), 'We did not get the proper value back from getError - it should have returned our fake error'); $this->assertThat(JErrorInspector::inspectStack(), $this->equalTo(array('Error2')), 'The stack was either not changed or changed the wrong way by getError (with unset true)'); // here we remove any junk left on the error stack JErrorInspector::manipulateStack(array()); }
public function loadUserByCredentials($user, $pass) { jimport('joomla.user.authentication'); $authenticate = JAuthentication::getInstance(); $response = $authenticate->authenticate(array('username' => $user, 'password' => $pass)); if ($response->status === JAuthentication::STATUS_SUCCESS) { $instance = JUser::getInstance($response->username); if ($instance === false) { $this->setError(JError::getError()); return false; } } else { if (isset($response->error_message)) { $this->setError($response->error_message); } else { $this->setError($response->getError()); } return false; } return $instance; }
<label for="modlgn_username"><?php echo JText::_('Username'); ?> </label> <input name="username" id="modlgn_username" type="text" class="inputbox" size="15" /> </p> <p id="form-login-password"> <label for="modlgn_passwd"><?php echo JText::_('Password'); ?> </label> <input name="passwd" id="modlgn_passwd" type="password" class="inputbox" size="15" /> </p> <?php if ($error = JError::getError(true)) { echo '<p id="login-error-message">'; echo $error->get('message'); echo '<p>'; } ?> <p id="form-login-lang" style="clear: both;"> <label for="lang"><?php echo JText::_('Language'); ?> </label> <?php echo $langs; ?> </p> <div class="button_holder">
protected function cleanBogusError() { $errors = array(); while (($error = JError::getError(true)) !== false) { if (!($error->get('code') == 1 && $error->get('level') == 2 && $error->get('message') == JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE'))) { $errors[] = $error; } } foreach ($errors as $error) { JError::addToStack($error); } $app =& JFactory::getApplication(); $enqueued_messages = $app->get('_messageQueue'); $other_messages = array(); if (!empty($enqueued_messages) && is_array($enqueued_messages)) { foreach ($enqueued_messages as $enqueued_message) { if (!($enqueued_message['message'] == JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE') && $enqueued_message['type']) == 'error') { $other_messages[] = $enqueued_message; } } } $app->set('_messageQueue', $other_messages); }
/** * Method to add product in cart * * @return void */ public function add() { $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $post = JRequest::get('post'); $parent_accessory_productid = $post['product_id']; $Itemid = JRequest::getVar('Itemid'); $producthelper = new producthelper(); $redhelper = new redhelper(); $Itemid = $redhelper->getCartItemid(); $model = $this->getModel('cart'); // Call add method of modal to store product in cart session $userfiled = JRequest::getVar('userfiled'); JPluginHelper::importPlugin('redshop_product'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeAddProductToCart', array(&$post)); $result = $this->_carthelper->addProductToCart($post); if (is_bool($result) && $result) { } else { $errmsg = $result ? $result : JText::_("COM_REDSHOP_PRODUCT_NOT_ADDED_TO_CART"); if (AJAX_CART_BOX == 1) { echo "`0`" . $errmsg; die; } else { $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $post['product_id']); if (count($ItemData) > 0) { $prdItemid = $ItemData->id; } else { $prdItemid = $redhelper->getItemid($post['product_id']); } $link = JRoute::_("index.php?option=" . $option . "&view=product&pid=" . $post["product_id"] . "&Itemid=" . $prdItemid, false); $app->Redirect($link, $errmsg); } } $session = JFactory::getSession(); $cart = $session->get('cart'); if (isset($cart['AccessoryAsProduct'])) { $attArr = $cart['AccessoryAsProduct']; if (ACCESSORY_AS_PRODUCT_IN_CART_ENABLE) { $data['accessory_data'] = $attArr[0]; $data['acc_quantity_data'] = $attArr[1]; $data['acc_attribute_data'] = $attArr[2]; $data['acc_property_data'] = $attArr[3]; $data['acc_subproperty_data'] = $attArr[4]; if (isset($data['accessory_data']) && ($data['accessory_data'] != "" && $data['accessory_data'] != 0)) { $accessory_data = explode("@@", $data['accessory_data']); $acc_quantity_data = explode("@@", $data['acc_quantity_data']); $acc_attribute_data = explode("@@", $data['acc_attribute_data']); $acc_property_data = explode("@@", $data['acc_property_data']); $acc_subproperty_data = explode("@@", $data['acc_subproperty_data']); for ($i = 0; $i < count($accessory_data); $i++) { $accessory = $producthelper->getProductAccessory($accessory_data[$i]); $post = array(); $post['parent_accessory_product_id'] = $parent_accessory_productid; $post['product_id'] = $accessory[0]->child_product_id; $post['quantity'] = $acc_quantity_data[$i]; $post['category_id'] = 0; $post['sel_wrapper_id'] = 0; $post['attribute_data'] = $acc_attribute_data[$i]; $post['property_data'] = $acc_property_data[$i]; $post['subproperty_data'] = $acc_subproperty_data[$i]; $result = $this->_carthelper->addProductToCart($post); $cart = $session->get('cart'); if (is_bool($result) && $result) { } else { $errmsg = $result ? $result : JText::_("COM_REDSHOP_PRODUCT_NOT_ADDED_TO_CART"); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } if (AJAX_CART_BOX == 1) { echo "`0`" . $errmsg; die; } else { $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $post['product_id']); if (count($ItemData) > 0) { $prdItemid = $ItemData->id; } else { $prdItemid = $redhelper->getItemid($post['product_id']); } $link = JRoute::_("index.php?option=" . $option . "&view=product&pid=" . $post["product_id"] . "&Itemid=" . $prdItemid, false); $app->Redirect($link, $errmsg); } } } } } if (!DEFAULT_QUOTATION_MODE || DEFAULT_QUOTATION_MODE && SHOW_QUOTATION_PRICE) { $this->_carthelper->carttodb(); } $this->_carthelper->cartFinalCalculation(); unset($cart['AccessoryAsProduct']); } else { if (!DEFAULT_QUOTATION_MODE || DEFAULT_QUOTATION_MODE && SHOW_QUOTATION_PRICE) { $this->_carthelper->carttodb(); } $this->_carthelper->cartFinalCalculation(); } if (!$userfiled) { if (AJAX_CART_BOX == 1 && isset($post['ajax_cart_box'])) { $link = JRoute::_('index.php?option=' . $option . '&view=cart&ajax_cart_box=' . $post['ajax_cart_box'] . '&tmpl=component&Itemid=' . $Itemid, false); $app->Redirect($link); } else { if (ADDTOCART_BEHAVIOUR == 1) { $link = JRoute::_('index.php?option=' . $option . '&view=cart&Itemid=' . $Itemid, false); $app->Redirect($link); } else { $link = JRoute::_($_SERVER['HTTP_REFERER'], false); if ($cart['notice_message'] != "") { $msg = $cart['notice_message'] . "<br>"; } $msg .= JTEXT::_('COM_REDSHOP_PRODUCT_ADDED_TO_CART'); $app->Redirect($link, $msg); } } } else { $link = JRoute::_('index.php?option=' . $option . '&view=product&pid=' . $post['p_id'] . '&Itemid=' . $Itemid, false); $app->Redirect($link); } }
function register($from_cb = 0, $freeCourse = false) { global $Itemid, $JLMS_DB, $JLMS_CONFIG, $JLMS_SESSION, $version, $task, $my; $reg_success = false; $msg = ''; $username = JRequest::getVar('username'); $password = JRequest::getVar('password'); $usersConfig =& JComponentHelper::getParams('com_users'); $app =& JFactory::getApplication(); if ($from_cb) { global $task; $task = 'saveregisters'; $_REQUEST['task'] = 'saveregisters'; $_GET['task'] = 'saveregisters'; $_POST['task'] = 'saveregisters'; JRequest::setVar('task', $task); ob_start(); global $ueConfig; $_CB_joomla_adminpath = $JLMS_CONFIG->get('absolute_path') . "/administrator"; $_CB_adminpath = $_CB_joomla_adminpath . "/components/com_comprofiler"; include_once $_CB_adminpath . "/ue_config.php"; if ($usersConfig->get('allowUserRegistration')) { $allowUserRegistration = true; } else { $allowUserRegistration = false; } // check if CB registration is allowed if (!$allowUserRegistration && (!isset($ueConfig['reg_admin_allowcbregistration']) || $ueConfig['reg_admin_allowcbregistration'] != '1') || $my->id) { $msg = _JLMS_REGISTRATION_DISABLED; $reg_success = false; } else { $existingUser = null; $query = "SELECT * " . "\n FROM #__users u " . "\n WHERE u.username = '******'"; $JLMS_DB->setQuery($query); $existingUser = $JLMS_DB->loadObjectList(); // new registration will be failed if user with such username is already exists. if (isset($existingUser[0])) { $reg_success = false; } require_once JPATH_SITE . '/components/com_comprofiler/comprofiler.html.php'; require_once JPATH_SITE . '/components/com_comprofiler/comprofiler.php'; $msg = @ob_get_contents(); $msg = str_replace('<br />', '**br**', $msg); $msg = str_replace('</div><div', '**br**', $msg); $msg = strip_tags($msg); $msg = str_replace('**br**', '<br />', $msg); $msg = trim($msg); if (substr($msg, 0, 6) == 'alert(') { preg_match('`alert\\(\'(.*)\'\\);(.*)`isU', $msg, $matches2); # <script...>(#our_content#)</script> areas if (isset($matches2[1])) { $msg = $matches2[1]; } } @ob_end_clean(); $filter =& JFilterInput::getInstance(); if ($filter->clean($msg) == $filter->clean(_UE_REG_COMPLETE)) { $msg = ''; $reg_success = true; } } } else { if (JLMS_Jversion() == 2) { if (JLMS_J16version()) { $lang =& JFactory::getLanguage(); $lang->load('com_users'); require_once JPATH_SITE . DS . 'components' . DS . 'com_users' . DS . 'models' . DS . 'registration.php'; // Create the controller $model = new UsersModelRegistration(); $requestData = JRequest::getVar('jform', array(), 'post', 'array'); $username = $requestData['username']; $password = $requestData['password1']; JForm::addFormPath(JPATH_SITE . '/components/com_users/models/forms'); JForm::addFieldPath(JPATH_SITE . '/components/com_users/models/fields'); $form = $model->getForm(); $return = $model->validate($form, $requestData); // Save the data in the session. if ($return === false) { $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { $msg .= '<br />' . $errors[$i]; } $app->setUserState('users.registration.form.data', $requestData); } else { $return = $model->register($requestData); if ($return === false) { $msg .= '<br />' . JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $model->getError()); $app->setUserState('users.registration.form.data', $requestData); } } if ($return === 'adminactivate') { $reg_complete_activate_found = true; } else { if ($return === 'useractivate') { $reg_complete_activate_found = true; } else { if ($return !== false) { $reg_success = true; $reg_complete_found = true; } } } } else { $lang =& JFactory::getLanguage(); $lang->load('com_user'); require_once JPATH_SITE . '/components/com_user/controller.php'; require_once JPATH_SITE . '/components/com_user/views/register/view.html.php'; // Create the controller $controller = new UserController(); $controller->_basePath = JPATH_SITE . '/components/com_user'; ob_start(); $controller->execute('register_save'); ob_end_clean(); $t = JError::getError(true); $reg_complete_found = false; $reg_complete_activate_found = false; // this variable is not used yet... for future if (isset($t->message) && $t->message == JText::_('REG_COMPLETE')) { $reg_success = true; $reg_complete_found = true; } elseif (isset($t->message) && $t->message == JText::_('REG_COMPLETE_ACTIVATE')) { $reg_complete_activate_found = true; } elseif (isset($controller->_message) && $controller->_message == JText::_('REG_COMPLETE')) { $reg_success = true; $reg_complete_found = true; } elseif (isset($controller->_message) && $controller->_message == JText::_('REG_COMPLETE_ACTIVATE')) { $reg_complete_activate_found = true; } } } } $login_success = false; if ($reg_success) { $login_success = JLMS_UserSessions::doLogin($username, $password); } $app->set('_messageQueue', null); if ($reg_success && $login_success) { if ($freeCourse) { $msg .= '<br />' . _JLMS_REGISTRATION_COMPLETE . "<br />" . _JLMS_LOGIN_SUCCESS . "<br />" . _JLMS_SUBSCRIBE_CONTINUE; } else { $msg .= '<br />' . _JLMS_REGISTRATION_COMPLETE . "<br />" . _JLMS_LOGIN_SUCCESS . "<br />"; } } elseif ($reg_success) { $msg .= '<br />' . _JLMS_REGISTRATION_COMPLETE; } else { if ($usersConfig->get('useractivation') && !$reg_success) { $msg .= '<br />' . _JLMS_REGISTRATION_ACTIVATION; } } return $msg; }
/** * Load the connection associated with the table * * @return object database object using connection details false if connection error */ function &getDb() { static $dbs; if (!isset($dbs)) { $dbs = array(); } $cn = $this->getConnection(); $session = JFactory::getSession(); if (JRequest::getCmd('task') == 'test') { $session->clear('fabrik.connection.' . $cn->id); $dbs = array(); $this->_connection = null; $cn = $this->getConnection(); } if (!array_key_exists($cn->id, $dbs)) { // $$$rob lets see if we have an exact config match with J db if so just return that $conf = JFactory::getConfig(); $host = $conf->get('host'); $user = $conf->get('user'); $password = $conf->get('password'); $database = $conf->get('db'); $prefix = $conf->get('dbprefix'); $driver = $conf->get('dbtype'); $debug = $conf->get('debug'); $default_options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $options = $this->getConnectionOptions($cn); if ($this->_compareConnectionOpts($default_options, $options)) { $dbs[$cn->id] = FabrikWorker::getDbo(); } else { $dbs[$cn->id] = JDatabase::getInstance($options); } if (JError::isError($dbs[$cn->id]) || is_a($dbs[$cn->id], 'JException') || $dbs[$cn->id]->getErrorNum() !== 0) { /** * $$$Rob - not sure why this is happening on badmintonrochelais.com (mySQL 4.0.24) but it seems like * you can only use one connection on the site? As JDatabase::getInstance() forces a new connection if its options * signature is not found, then fabrik's default connection won't be created, hence defaulting to that one */ if ($cn->default == 1 && JRequest::getCmd('task') !== 'test') { $dbs[$cn->id] = FabrikWorker::getDbo(); // $$$rob remove the error from the error stack // if we dont do this the form is not rendered JError::getError(true); } else { $app = JFactory::getApplication(); if (!$app->isAdmin()) { JError::raiseError(E_ERROR, 'Could not connection to database', $default_options); jexit('Could not connection to database - possibly a menu item which doesn\'t link to a fabrik table'); } else { // $$$ rob - unset the connection as caching it will mean that changes we make to the incorrect connection in admin, will not result // in the test connection link informing the user that the changed connection properties are now correct if (JRequest::getCmd('task') == 'test') { $session->clear('fabrik.connection.' . $cn->id); $this->_connection = null; $level = E_NOTICE; } else { $level = E_ERROR; } return JError::raise($level, 500, 'Could not connection to database cid = ' . $cn->id); } } } } return $dbs[$cn->id]; }
/** * Returns contact details or user details as fall back * * @param int id key of user * @param string attrib Requested attribute of the user object * @return mixed row Attribute or row object */ public static function getContact($id, $attrib = 'Object') { $db = JFactory::getDBO(); static $rows = array(); if ($id <= 0) { return null; } if (!isset($rows[$id])) { $user = JFactory::getUser(); $rows[$id] = null; $query = "SELECT ju.id, ju.name, ju.username, ju.sendEmail, ju.email, cd.name as contactname, " . ' CASE WHEN CHAR_LENGTH(cd.alias) THEN CONCAT_WS(\':\', cd.id, cd.alias) ELSE cd.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(cat.alias) THEN CONCAT_WS(\':\', cat.id, cat.alias) ELSE cat.id END AS catslug ' . " \n FROM #__users AS ju" . "\n LEFT JOIN #__contact_details AS cd ON cd.user_id = ju.id " . "\n LEFT JOIN #__categories AS cat ON cat.id = cd.catid " . "\n WHERE block ='0'" . "\n AND cd.published =1 " . "\n AND cd.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND cat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND ju.id = " . $id; $db->setQuery($query); $rows[$id] = $db->loadObject(); if (is_null($rows[$id])) { // if the user has been deleted then try to suppress the warning // this causes a problem in Joomla 2.5.1 on some servers if (version_compare(JVERSION, '2.5', '>=')) { $rows[$id] = JEVHelper::getUser($id); } else { $handlers = JError::getErrorHandling(2); JError::setErrorHandling(2, "ignore"); $rows[$id] = JEVHelper::getUser($id); foreach ($handlers as $handler) { if (!is_array($handler)) { JError::setErrorHandling(2, $handler); } } if ($rows[$id]) { $error = JError::getError(true); } } } } if ($attrib == 'Object') { return $rows[$id]; } elseif (isset($rows[$id]->{$attrib})) { return $rows[$id]->{$attrib}; } else { return null; } }
/** * Show the debug info * */ function __destruct() { global $_PROFILER; // Do not render if debugging is not enabled if (!JDEBUG) { return; } if (!$_PROFILER instanceof JProfiler) { return; } // Load the language $this->loadLanguage(); // Capture output $contents = ob_get_contents(); ob_end_clean(); // No debug for Safari and Chrome redirection if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') { echo $contents; return; } $document = JFactory::getDocument(); $doctype = $document->getType(); // Only render for HTML output if ($doctype !== 'html') { echo $contents; return; } // If the user is not allowed to view the output then end here $filterGroups = (array) $this->params->get('filter_groups', null); if (!empty($filterGroups)) { $userGroups = JFactory::getUser()->get('groups'); if (!array_intersect($filterGroups, array_keys($userGroups))) { echo $contents; return; } } // Load language file $this->loadLanguage('plg_system_debug'); $profiler =& $_PROFILER; ob_start(); echo '<div id="system-debug" class="profiler">'; $errors = JError::getErrors(); if (!empty($errors)) { echo '<h4>' . JText::_('PLG_DEBUG_ERRORS') . '</h4><ol>'; while ($error = JError::getError(true)) { echo '<li>' . $error->getMessage() . '<br /><h4>' . JText::_('PLG_DEBUG_INFO') . '</h4><pre>' . print_r($error->get('info'), true) . '</pre><br /><h4>' . JText::_('PLG_DEBUG_BACKTRACE') . '</h4>' . JError::renderBacktrace($error) . '</li>'; } echo '</ol>'; } if ($this->params->get('profile', 1)) { echo '<h4>' . JText::_('PLG_DEBUG_PROFILE_INFORMATION') . '</h4>'; foreach ($profiler->getBuffer() as $mark) { echo '<div>' . $mark . '</div>'; } } if ($this->params->get('memory', 1)) { echo '<h4>' . JText::_('PLG_DEBUG_MEMORY_USAGE') . '</h4>'; $bytes = $profiler->getMemory(); echo JHtml::_('number.bytes', $bytes); echo ' (' . number_format($bytes) . ' Bytes)'; } if ($this->params->get('queries', 1)) { $newlineKeywords = '#\\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)\\b#i'; $db = JFactory::getDbo(); echo '<h4>' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $db->getTicker()) . '</h4>'; if ($log = $db->getLog()) { echo '<ol>'; $selectQueryTypeTicker = array(); $otherQueryTypeTicker = array(); foreach ($log as $k => $sql) { // Start Query Type Ticker Additions $fromStart = stripos($sql, 'from'); $whereStart = stripos($sql, 'where', $fromStart); if ($whereStart === false) { $whereStart = stripos($sql, 'order by', $fromStart); } if ($whereStart === false) { $whereStart = strlen($sql) - 1; } $fromString = substr($sql, 0, $whereStart); $fromString = str_replace("\t", " ", $fromString); $fromString = str_replace("\n", " ", $fromString); $fromString = trim($fromString); // Initialize the select/other query type counts the first time: if (!isset($selectQueryTypeTicker[$fromString])) { $selectQueryTypeTicker[$fromString] = 0; } if (!isset($otherQueryTypeTicker[$fromString])) { $otherQueryTypeTicker[$fromString] = 0; } // Increment the count: if (stripos($sql, 'select') === 0) { $selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1; unset($otherQueryTypeTicker[$fromString]); } else { $otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1; unset($selectQueryTypeTicker[$fromString]); } // Finish Query Type Ticker Additions $text = htmlspecialchars($sql, ENT_QUOTES); $text = preg_replace($newlineKeywords, '<br />  \\0', $text); echo '<li>' . $text . '</li>'; } echo '</ol>'; if ($this->params->get('query_types', 1)) { // Get the totals for the query types: $totalSelectQueryTypes = count($selectQueryTypeTicker); $totalOtherQueryTypes = count($otherQueryTypeTicker); $totalQueryTypes = $totalSelectQueryTypes + $totalOtherQueryTypes; echo '<h4>' . JText::sprintf('PLG_DEBUG_QUERY_TYPES_LOGGED', $totalQueryTypes) . '</h4>'; if ($totalSelectQueryTypes) { echo '<h5>' . JText::sprintf('PLG_DEBUG_SELECT_QUERIES') . '</h5>'; arsort($selectQueryTypeTicker); echo '<ol>'; foreach ($selectQueryTypeTicker as $table => $occurrences) { echo '<li>' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $table, $occurrences) . '</li>'; } echo '</ol>'; } if ($totalOtherQueryTypes) { echo '<h5>' . JText::sprintf('PLG_DEBUG_OTHER_QUERIES') . '</h5>'; arsort($otherQueryTypeTicker); echo '<ol>'; foreach ($otherQueryTypeTicker as $table => $occurrences) { echo '<li>' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $table, $occurrences) . '</li>'; } echo '</ol>'; } } } } // Show language debug only if enabled if (JFactory::getApplication()->getCfg('debug_lang')) { $lang = JFactory::getLanguage(); if ($this->params->get('language_errorfiles', 1)) { echo '<h4>' . JText::_('PLG_DEBUG_LANGUAGE_FILES_IN_ERROR') . '</h4>'; $errorfiles = $lang->getErrorFiles(); if (count($errorfiles)) { echo '<ul>'; foreach ($errorfiles as $file => $error) { echo "<li>{$error}</li>"; } echo '</ul>'; } else { echo '<pre>' . JText::_('JNONE') . '</pre>'; } } if ($this->params->get('language_files', 1)) { echo '<h4>' . JText::_('PLG_DEBUG_LANGUAGE_FILES_LOADED') . '</h4>'; echo '<ul>'; $extensions = $lang->getPaths(); foreach ($extensions as $extension => $files) { foreach ($files as $file => $status) { echo "<li>{$file} {$status}</li>"; } } echo '</ul>'; } if ($this->params->get('language_strings')) { $stripFirst = $this->params->get('strip-first'); $stripPref = $this->params->get('strip-prefix'); $stripSuff = $this->params->get('strip-suffix'); echo '<h4>' . JText::_('PLG_DEBUG_UNTRANSLATED_STRINGS') . '</h4>'; echo '<pre>'; $orphans = $lang->getOrphans(); if (count($orphans)) { ksort($orphans, SORT_STRING); $guesses = array(); foreach ($orphans as $key => $occurance) { if (is_array($occurance) and isset($occurance[0])) { $info =& $occurance[0]; $file = @$info['file']; if (!isset($guesses[$file])) { $guesses[$file] = array(); } // Prepare the key if (($pos = strpos($info['string'], '=')) > 0) { $parts = explode('=', $info['string']); $key = $parts[0]; $guess = $parts[1]; } else { $guess = str_replace('_', ' ', $info['string']); if ($stripFirst) { $parts = explode(' ', $guess); if (count($parts) > 1) { array_shift($parts); $guess = implode(' ', $parts); } } $guess = trim($guess); if ($stripPref) { $guess = trim(preg_replace(chr(1) . '^' . $stripPref . chr(1) . 'i', '', $guess)); } if ($stripSuff) { $guess = trim(preg_replace(chr(1) . $stripSuff . '$' . chr(1) . 'i', '', $guess)); } } $key = trim(strtoupper($key)); $key = preg_replace('#\\s+#', '_', $key); $key = preg_replace('#\\W#', '', $key); // Prepare the text $guesses[$file][] = $key . '="' . $guess . '"'; } } foreach ($guesses as $file => $keys) { echo "\n\n# " . ($file ? $file : JText::_('PLG_DEBUG_UNKNOWN_FILE')) . "\n\n"; echo implode("\n", $keys); } } else { echo JText::_('JNONE'); } echo '</pre>'; } } echo '</div>'; $debug = ob_get_clean(); $body = JResponse::getBody(); $body = str_replace('</body>', $debug . '</body>', $body); echo str_replace('</body>', $debug . '</body>', $contents); }
/** * Perform the action. * * @param EcrProjectZiper $ziper * * @return \EcrProjectAction */ public function run(EcrProjectZiper $ziper) { $ziper->logger->log('Executing FTP transfer'); $user = trim($this->user); $pass = trim($this->pass); if ('' == $user) { $text = 'FTP User'; $command = escapeshellcmd('DISPLAY=:0 XAUTHORITY=/home/elkuku/.Xauthority' . ' kdialog --title "' . $text . '" --inputbox "' . $text . '"'); $ziper->logger->log('Executing: ' . $command); $user = shell_exec($command . ' 2>&1'); if ('' == $user) { $ziper->logger->log('ERROR: No user name given', 'FTP user', JLog::ERROR); return $this; } } if ('' == $pass) { $text = 'FTP Password'; $command = escapeshellcmd('DISPLAY=:0 XAUTHORITY=/home/elkuku/.Xauthority' . ' kdialog --title "' . $text . '" --inputbox "' . $text . '"'); $ziper->logger->log('Executing: ' . $command); $pass = shell_exec($command . ' 2>&1'); if ('' == $pass) { $ziper->logger->log('ERROR: No password given', 'FTP user', JLog::ERROR); return $this; } } $ftp = EcrFtp::getClient($this->host, $this->port, null, $user, $pass); $files = explode(',', $this->files); $packages = $ziper->getCreatedFiles(); foreach ($files as $file) { $file = trim($file); $path = ''; $fileName = ''; switch ($file) { case 'package': $path = $packages[0]->path; break; default: $ziper->logger->log('ERROR: Unknown file type: ' . $file, 'FTP transfer', JLog::ERROR); } $remote = null; if ($this->folder) { $remote = $this->folder . '/' . basename($path); } if (false == $ftp->store($path, $remote)) { //@todo: deprecated JError $error = JError::getError(); $ziper->logger->log('ERROR: ' . $error, 'FTP transfer (JFTP)', JLog::ERROR); } else { $ziper->logger->log('File transfered: ' . $fileName); } } return $this; }
/** * Load the connection associated with the table * * @return object database object using connection details false if connection error */ public function &getDb() { if (!isset(self::$dbs)) { self::$dbs = array(); } $error = false; $cn = $this->getConnection(); $app = JFactory::getApplication(); $input = $app->input; if ($input->get('task') == 'test') { self::$dbs = array(); $this->connection = null; $cn = $this->getConnection(); } if (!array_key_exists($cn->id, self::$dbs)) { if ($this->isJdb()) { $db = FabrikWorker::getDbo(); } else { $options = $this->getConnectionOptions($cn); $db = $this->getDriverInstance($options); } try { $db->connect(); } catch (RuntimeException $e) { $error = true; } self::$dbs[$cn->id] = $db; if ($error) { /** * $$$Rob - not sure why this is happening on badmintonrochelais.com (mySQL 4.0.24) but it seems like * you can only use one connection on the site? As JDatabase::getInstance() forces a new connection if its options * signature is not found, then fabrik's default connection won't be created, hence defaulting to that one */ if ($cn->default == 1 && $input->get('task') !== 'test') { self::$dbs[$cn->id] = FabrikWorker::getDbo(); // $$$rob remove the error from the error stack // if we don't do this the form is not rendered JError::getError(true); } else { if (!$app->isAdmin()) { throw new RuntimeException('Could not connection to database', E_ERROR); } else { // $$$ rob - unset the connection as caching it will mean that changes we make to the incorrect connection in admin, will not result // in the test connection link informing the user that the changed connection properties are now correct if ($input->get('task') == 'test') { $this->connection = null; $level = E_NOTICE; } else { $level = E_ERROR; } throw new RuntimeException('Could not connection to database cid = ' . $cn->id, $level); } } } } return self::$dbs[$cn->id]; }
/** * Method to book invoice and send mail in E-conomic * * @access public * @return array */ public function bookInvoiceInEconomic($order_id, $checkOrderStatus = 1, $rmaCRMOrder = 0, $bookinvoicedate = 0) { $file = ''; if (ECONOMIC_INTEGRATION == 1) { $orderdetail = $this->_order_functions->getOrderDetails($order_id); if ($orderdetail->invoice_no != '' && $orderdetail->is_booked == 0) { if (ECONOMIC_INVOICE_DRAFT == 2 && $orderdetail->order_status == BOOKING_ORDER_STATUS || $checkOrderStatus == 0 || $rmaCRMOrder == 1) { $user_billinginfo = $this->_order_functions->getOrderBillingUserInfo($order_id); if ($user_billinginfo->is_company == 0 || !$user_billinginfo->ean_number && $user_billinginfo->is_company == 1) { $currency = CURRENCY_CODE; $eco['invoiceHandle'] = $orderdetail->invoice_no; $eco['debtorHandle'] = intVal($user_billinginfo->users_info_id); $eco['currency_code'] = $currency; $eco['amount'] = $orderdetail->order_total; $eco['order_number'] = $orderdetail->order_number; $eco['order_id'] = $orderdetail->order_id; $currectinvoiceData = $this->_dispatcher->trigger('checkDraftInvoice', array($eco)); if (count($currectinvoiceData) > 0 && trim($currectinvoiceData[0]->OtherReference) == $orderdetail->order_number) { $this->updateInvoiceDateInEconomic($orderdetail, $bookinvoicedate); if ($user_billinginfo->is_company == 1 && $user_billinginfo->company_name != '') { $eco['name'] = $user_billinginfo->company_name; } else { $eco['name'] = $user_billinginfo->firstname . " " . $user_billinginfo->lastname; } $paymentInfo = $this->_order_functions->getOrderPaymentDetail($orderdata->order_id); if (count($paymentInfo) > 0) { $paymentmethod = $this->_order_functions->getPaymentMethodInfo($paymentInfo[0]->payment_method_class); if (count($paymentmethod) > 0) { $paymentparams = new JRegistry($paymentmethod[0]->params); $eco['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id'); $eco['economic_design_layout'] = $paymentparams->get('economic_design_layout'); } } if (ECONOMIC_BOOK_INVOICE_NUMBER == 1) { $bookhandle = $this->_dispatcher->trigger('CurrentInvoice_Book', array($eco)); } else { $bookhandle = $this->_dispatcher->trigger('CurrentInvoice_BookWithNumber', array($eco)); } if (count($bookhandle) > 0 && isset($bookhandle[0]->Number)) { $bookinvoice_number = $eco['bookinvoice_number'] = $bookhandle[0]->Number; if (ECONOMIC_BOOK_INVOICE_NUMBER == 1) { $this->updateBookInvoiceNumber($order_id, $bookinvoice_number); } $bookinvoicepdf = $this->_dispatcher->trigger('bookInvoice', array($eco)); if (JError::isError(JError::getError())) { return $file; } elseif ($bookinvoicepdf != "") { $file = JPATH_ROOT . '/components/com_redshop/assets/orders/rsInvoice_' . $order_id . '.pdf'; JFile::write($file, $bookinvoicepdf); if (is_file($file)) { $this->updateBookInvoice($order_id); } } } } } } } } return $file; }
/** * Check validation * * @param string $users_info_id not used * * @return bool */ public function chkvalidation($users_info_id) { $model = $this->getModel('checkout'); $billingaddresses = $model->billingaddresses(); $shippingaddresses = $model->shipaddress($users_info_id); $extra_field = new extra_field(); $extrafield_name = ''; $return = 0; if (!$billingaddresses->is_company) { if ($billingaddresses->firstname == '') { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_FIRST_NAME'); JError::raiseWarning('', $msg); return $return; } elseif ($billingaddresses->lastname == '') { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_LAST_NAME'); JError::raiseWarning('', $msg); return $return; } } else { if ($billingaddresses->company_name == '') { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_COMPANY_NAME'); JError::raiseWarning('', $msg); return $return; } if ($billingaddresses->firstname == '') { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_FIRST_NAME'); JError::raiseWarning('', $msg); return $return; } elseif ($billingaddresses->lastname == '') { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_LAST_NAME'); JError::raiseWarning('', $msg); return $return; } elseif (ECONOMIC_INTEGRATION == 1 && trim($billingaddresses->ean_number) != '') { $economic = new economic(); $debtorHandle = $economic->createUserInEconomic($billingaddresses); if (JError::isError(JError::getError())) { $return = 1; $error = JError::getError(); $msg = $error->message; JError::raiseWarning('', $msg); return $return; } } } if (!trim($billingaddresses->address)) { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_ADDRESS'); JError::raiseWarning('', $msg); return $return; } elseif (!$billingaddresses->country_code) { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_SELECT_COUNTRY'); JError::raiseWarning('', $msg); return $return; } elseif (!$billingaddresses->zipcode) { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_ZIPCODE'); JError::raiseWarning('', $msg); return $return; } elseif (!$billingaddresses->phone) { $return = 1; $msg = JText::_('COM_REDSHOP_PLEASE_ENTER_PHONE'); JError::raiseWarning('', $msg); return $return; } if ($billingaddresses->is_company == 1) { $extrafield_name = $extra_field->chk_extrafieldValidation(8, $billingaddresses->users_info_id); if (!empty($extrafield_name)) { $return = 1; $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED'); JError::raiseWarning('', $msg); return $return; } } else { $extrafield_name = $extra_field->chk_extrafieldValidation(7, $billingaddresses->users_info_id); if (!empty($extrafield_name)) { $return = 1; $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED'); JError::raiseWarning('', $msg); return $return; } } if (SHIPPING_METHOD_ENABLE && $users_info_id != $billingaddresses->users_info_id) { if ($billingaddresses->is_company == 1) { $extrafield_name = $extra_field->chk_extrafieldValidation(15, $users_info_id); if (!empty($extrafield_name)) { $return = 2; $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED'); JError::raiseWarning('', $msg); return $return; } } else { $extrafield_name = $extra_field->chk_extrafieldValidation(14, $users_info_id); if (!empty($extrafield_name)) { $return = 2; $msg = $extrafield_name . JText::_('COM_REDSHOP_IS_REQUIRED'); JError::raiseWarning('', $msg); return $return; } } } return $return; }
public function storeRedshopUser($data, $user_id = 0, $admin = 0) { $redshopMail = new redshopMail(); $extra_field = new extra_field(); $helper = new redhelper(); $data['user_email'] = $data['email'] = $data['email1']; $data['name'] = $name = $data['firstname']; $data['address_type'] = 'BT'; $row = JTable::getInstance('user_detail', 'Table'); if (isset($data['users_info_id']) && $data['users_info_id'] != 0) { $isNew = false; $row->load($data['users_info_id']); $data["old_tax_exempt_approved"] = $row->tax_exempt_approved; $user_id = $row->user_id; } else { $isNew = true; $data['password'] = JRequest::getVar('password1', '', 'post', 'string', JREQUEST_ALLOWRAW); $app = JFactory::getApplication(); $is_admin = $app->isAdmin(); if ($data['is_company'] == 1) { if ($is_admin && $data['shopper_group_id'] != 0) { $data['shopper_group_id'] = $data['shopper_group_id']; } else { $data['shopper_group_id'] = SHOPPER_GROUP_DEFAULT_COMPANY != 0 ? SHOPPER_GROUP_DEFAULT_COMPANY : 2; } } else { if ($is_admin && isset($data['shopper_group_id']) && $data['shopper_group_id'] != 0) { $data['shopper_group_id'] = $data['shopper_group_id']; } else { $data['shopper_group_id'] = SHOPPER_GROUP_DEFAULT_PRIVATE != 0 ? SHOPPER_GROUP_DEFAULT_PRIVATE : 1; } } } if ($user_id > 0) { $joomlauser = new JUser($user_id); $data['username'] = $joomlauser->username; $data['name'] = $joomlauser->name; $data['email'] = $joomlauser->email; } if (SHOW_TERMS_AND_CONDITIONS == 1 && isset($data['termscondition']) && $data['termscondition'] == 1) { $data['accept_terms_conditions'] = 1; } $row->user_id = $data['user_id'] = $user_id; if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } if (USE_TAX_EXEMPT) { if (!$admin && $row->is_company == 1) { $row->requesting_tax_exempt = $data['tax_exempt']; if ($row->requesting_tax_exempt == 1) { $redshopMail->sendRequestTaxExemptMail($row, $data['username']); } } // Sending tax exempted mails (tax_exempt_approval_mail) if (!$isNew && $admin && isset($data["tax_exempt_approved"]) && $data["old_tax_exempt_approved"] != $data["tax_exempt_approved"]) { if ($data["tax_exempt_approved"] == 1) { $redshopMail->sendTaxExemptMail("tax_exempt_approval_mail", $data, $row->user_email); } else { $redshopMail->sendTaxExemptMail("tax_exempt_disapproval_mail", $data, $row->user_email); } } } if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // Update user info id if (ECONOMIC_INTEGRATION) { $economic = new economic(); $original_info_id = $row->users_info_id; if ($isNew) { $maxDebtor = $economic->getMaxDebtorInEconomic(); if (count($maxDebtor) > 0) { $maxDebtor = $maxDebtor[0]; if ($row->users_info_id <= $maxDebtor) { $nextId = $maxDebtor + 1; $sql = "UPDATE " . $this->_table_prefix . "users_info " . "SET users_info_id = " . (int) $nextId . " " . "WHERE users_info_id = " . (int) $row->users_info_id; $this->_db->setQuery($sql); $this->_db->Query(); $row->users_info_id = $nextId; } } } $debtorHandle = $economic->createUserInEconomic($row); if ($row->is_company && trim($row->ean_number) != '' && JError::isError(JError::getError())) { $msg = JText::_('PLEASE_ENTER_EAN_NUMBER'); JError::raiseWarning('', $msg); return false; } } $auth['users_info_id'] = $row->users_info_id; $this->_session->set('auth', $auth); // For non-registered customers if (!$row->user_id) { $row->user_id = 0 - $row->users_info_id; $row->store(); $u = JFactory::getUser(); $u->set('username', $row->user_email); $u->set('email', $row->user_email); $u->set('usertype', 'Registered'); $date = JFactory::getDate(); $u->set('registerDate', $date->toMySQL()); $data['user_id'] = $row->user_id; $data['username'] = $row->user_email; $data['email'] = $row->user_email; } if (isset($data['newsletter_signup']) && $data['newsletter_signup'] == 1) { $this->newsletterSubscribe($row->user_id, $data); } $billisship = 1; if (!isset($data['billisship'])) { $billisship = 0; } // Info: field_section 6 :Userinformations $list_field = $extra_field->extra_field_save($data, 6, $row->users_info_id); if ($row->is_company == 0) { // Info: field_section 7 :Userinformations $list_field = $extra_field->extra_field_save($data, 7, $row->users_info_id); } else { // Info: field_section 8 :Userinformations $list_field = $extra_field->extra_field_save($data, 8, $row->users_info_id); } if ($billisship != 1) { $rowShip = $this->storeRedshopUserShipping($data); } if (REGISTER_METHOD != 1 && $isNew && $admin == 0) { if (REGISTER_METHOD == 2) { if (isset($data['createaccount']) && $data['createaccount'] == 1) { $redshopMail->sendRegistrationMail($data); } } else { $redshopMail->sendRegistrationMail($data); } } if ($isNew) { JPluginHelper::importPlugin('highrise'); $dispatcher = JDispatcher::getInstance(); $hResponses = $dispatcher->trigger('oncreateHighriseUser', array()); } /** * redCRM includes */ if ($helper->isredCRM()) { $this->setoreredCRMDebtor($row); } return $row; }
/** * Converting the site URL to fit to the HTTP request * */ function onAfterRender() { global $_PROFILER; // Do not render if debugging is not enabled if (!JDEBUG) { return; } $document =& JFactory::getDocument(); $doctype = $document->getType(); // Only render for HTML output if ($doctype !== 'html') { return; } // If the user is not allowed to view the output then end here $filterGroups = (array) $this->params->get('filter_groups', null); if (!empty($filterGroups)) { $userGroups = JFactory::getUser()->get('groups'); if (!array_intersect($filterGroups, array_keys($userGroups))) { return; } } $profiler =& $_PROFILER; ob_start(); echo '<div id="system-debug" class="profiler">'; $errors = JError::getErrors(); if (!empty($errors)) { echo '<h4>' . JText::_('Errors') . '</h4><ol>'; while ($error = JError::getError(true)) { echo '<li>' . $error->getMessage() . '<br /><h4>' . JText::_('Info') . '</h4><pre>' . print_r($error->get('info'), true) . '</pre><br /><h4>' . JText::_('Backtrace') . '</h4>' . JError::renderBacktrace($error) . '</li>'; } echo '</ol>'; } if ($this->params->get('profile', 1)) { echo '<h4>' . JText::_('Debug_Profile_Information') . '</h4>'; foreach ($profiler->getBuffer() as $mark) { echo '<div>' . $mark . '</div>'; } } if ($this->params->get('memory', 1)) { echo '<h4>' . JText::_('Debug_Memory_Usage') . '</h4>'; echo number_format($profiler->getMemory()); } if ($this->params->get('queries', 1)) { $newlineKeywords = '#\\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)\\b#i'; $db =& JFactory::getDbo(); echo '<h4>' . JText::sprintf('Debug_Queries_logged', $db->getTicker()) . '</h4>'; if ($log = $db->getLog()) { echo '<ol>'; foreach ($log as $k => $sql) { $text = preg_replace($newlineKeywords, '<br /> \\0', $sql); echo '<li>' . $text . '</li>'; } echo '</ol>'; } } $lang =& JFactory::getLanguage(); if ($this->params->get('language_files', 1)) { echo '<h4>' . JText::_('Debug_Language_Files_Loaded') . '</h4>'; echo '<ul>'; $extensions = $lang->getPaths(); foreach ($extensions as $extension => $files) { foreach ($files as $file => $status) { echo "<li>{$file} {$status}</li>"; } } echo '</ul>'; } if ($this->params->get('language_strings')) { $stripFirst = $this->params->get('strip-first'); $stripPref = $this->params->get('strip-prefix'); $stripSuff = $this->params->get('strip-suffix'); echo '<h4>' . JText::_('Debug_Untranslated_Strings') . '</h4>'; echo '<pre>'; $orphans = $lang->getOrphans(); if (count($orphans)) { ksort($orphans, SORT_STRING); $guesses = array(); foreach ($orphans as $key => $occurance) { if (is_array($occurance) and isset($occurance[0])) { $info =& $occurance[0]; $file = @$info['file']; if (!isset($guesses[$file])) { $guesses[$file] = array(); } // Prepare the key if (($pos = strpos($info['string'], '=')) > 0) { $parts = explode('=', $info['string']); $key = $parts[0]; $guess = $parts[1]; } else { $guess = str_replace('_', ' ', $info['string']); if ($stripFirst) { $parts = explode(' ', $guess); if (count($parts) > 1) { array_shift($parts); $guess = implode(' ', $parts); } } $guess = trim($guess); if ($stripPref) { $guess = trim(preg_replace(chr(1) . '^' . $stripPref . chr(1) . 'i', '', $guess)); } if ($stripSuff) { $guess = trim(preg_replace(chr(1) . $stripSuff . '$' . chr(1) . 'i', '', $guess)); } } $key = trim(strtoupper($key)); $key = preg_replace('#\\s+#', '_', $key); $key = preg_replace('#\\W#', '', $key); // Prepare the text $guesses[$file][] = $key . '=' . $guess; } } foreach ($guesses as $file => $keys) { echo "\n\n# " . ($file ? $file : JText::_('Debug_Unknown_file')) . "\n\n"; echo implode("\n", $keys); } } else { echo JText::_('JNone'); } echo '</pre>'; } echo '</div>'; $debug = ob_get_clean(); $body = JResponse::getBody(); $body = str_replace('</body>', $debug . '</body>', $body); JResponse::setBody($body); }
/** * Testing GetInstance(). * * @return void */ public function testGetInstance() { include_once JPATH_BASE . '/libraries/joomla/plugin/helper.php'; include_once JPATH_BASE . '/libraries/joomla/user/user.php'; include_once JPATH_BASE . '/libraries/joomla/session/session.php'; $user = new JUser; /**$mockSession = $this->getMock('JSession', array( '_start', 'get')); $mockSession->expects($this->any())->method('get')->with($this->equalTo('user'))->will( $this->returnValue($user) );**/ $mockSession = new Mock_SessionJAuthenticate(); $mockSession->set('user', $user); JFactory::$session = $mockSession; $instance1 = JAuthentication::getInstance(); /*** * These calls involving getError cause really bad things to happen in certain circumstances on some setups. * Commenting them out until we can figure out what and why (or fix it so it doesn't happen) $error = JError::getError(); $this->assertThat( $error, $this->equalTo(null) ); */ $instance2 = JAuthentication::getInstance(); $error = JError::getError(); /*** * These calls involving getError cause really bad things to happen in certain circumstances on some setups. * Commenting them out until we can figure out what and why (or fix it so it doesn't happen) $this->assertThat( $error, $this->equalTo(null) ); */ $this->assertThat( $instance1, $this->equalTo($instance2) ); }
public function ajaxMemberReply($username = null, $password = null, $token = null) { $disjax = new Disjax(); $mainframe = JFactory::getApplication(); JRequest::setVar($token, 1); if (empty($username) || empty($password)) { $disjax->script("EasyDiscuss.\$('#usertype_status .msg_in').html('" . JText::_('COM_EASYDISCUSS_PLEASE_INSERT_YOUR_USERNAME_AND_PASSWORD') . "');"); $disjax->script("EasyDiscuss.\$('#usertype_status .msg_in').addClass('alert alert-error');"); $disjax->script("EasyDiscuss.\$('#edialog-member-reply').prop('disabled', false);"); $disjax->send(); return false; } // Check for request forgeries if (JRequest::checkToken('request')) { $credentials = array(); $credentials['username'] = $username; $credentials['password'] = $password; $result = $mainframe->login($credentials); if (!JError::isError($result)) { $token = DiscussHelper::getToken(); $disjax->script('EasyDiscuss.$(".easydiscuss-token").val("' . $token . '");'); $disjax->script('disjax.closedlg();'); $disjax->script('discuss.reply.submit();'); } else { $error = JError::getError(); $disjax->script('EasyDiscuss.$(\'#usertype_status .msg_in\').html(\'' . $error->message . '\');'); $disjax->script('EasyDiscuss.$(\'#usertype_status .msg_in\').addClass(\'alert alert-error\');'); $disjax->script('EasyDiscuss.$(\'#edialog-member-reply\').prop(\'disabled\', false);'); } } else { $token = DiscussHelper::getToken(); $disjax->script('discuss.login.token = "' . $token . '";'); $disjax->script('EasyDiscuss.$(\'#usertype_status .msg_in\').html(\'' . JText::_('COM_EASYDISCUSS_MEMBER_LOGIN_INVALID_TOKEN') . '\');'); $disjax->script('EasyDiscuss.$(\'#usertype_status .msg_in\').addClass(\'alert alert-error\');'); $disjax->script('EasyDiscuss.$(\'#edialog-reply\').prop(\'disabled\', false);'); } $disjax->send(); }
/** * method to update the component * * @param object parent installer application * * @return void */ function update($parent) { $manifest = $parent->get("manifest"); $parent = $parent->getParent(); $source = $parent->getPath("source"); $db = JFactory::getDbo(); $query = $db->getQuery(true); $install_html_file = __DIR__ . '/componentarchitect_install.html'; $buffer = ''; if (file_exists($install_html_file)) { $buffer .= file_get_contents($install_html_file); } $install_error = false; // Opening HTML ob_start(); ?> <div id="componentarchitectinstall-info"> <h1><?php echo JText::_('COM_COMPONENTARCHITECT_UPDATE_HEADER'); ?> </h1> <table id="componentarchitectinstall-table" class="adminlist"> <thead class="componentarchitectinstall-heading"> <tr> <th colspan="3"> <?php echo JText::_('COM_COMPONENTARCHITECT_UPDATE_HEADER'); ?> </th> </tr> </thead> <tbody> <tr class="componentarchitectinstall-subheading"> <th colspan="2"> <?php echo JText::_('COM_COMPONENTARCHITECT_EXTENSION_HEADER'); ?> </th> <th width="50%"> <?php echo JText::_('COM_COMPONENTARCHITECT_STATUS_HEADER'); ?> </th> </tr> <tr class="componentarchitectinstall-row"> <td colspan="2"> <?php echo JText::_('COM_COMPONENTARCHITECT'); ?> </td> <td class="componentarchitectinstall-success"> <?php echo JText::_('COM_COMPONENTARCHITECT_UPDATE_PACKAGE_SUCCESS'); ?> </td> </tr> <?php $buffer .= ob_get_clean(); // Install plugins if (count($manifest->plugins->plugin) > 0) { // Opening HTML ob_start(); ?> <tr class="componentarchitectinstall-subheading"> <th> <?php echo JText::_('COM_COMPONENTARCHITECT_PLUGIN_HEADER'); ?> </th> <th> <?php echo JText::_('COM_COMPONENTARCHITECT_PLUGIN_GROUP_HEADER'); ?> </th> <th width="50%"> <?php echo JText::_('COM_COMPONENTARCHITECT_STATUS_HEADER'); ?> </th> </tr> <?php $buffer .= ob_get_clean(); foreach ($manifest->plugins->plugin as $plugin) { $attributes = $plugin->attributes(); $plg = $source . '/' . $attributes['folder'] . '/' . $attributes['plugin']; // check if the plugin is a new version for this extension or a new plugin and either update or install $query->clear(); $query->select($db->quoteName('extension_id')); $query->from($db->quoteName('#__extensions')); $query->where($db->quoteName('name') . ' = ' . $db->quote($attributes['plugin'])); $query->where($db->quoteName('type') . ' = ' . $db->quote('plugin')); $db->setQuery($query->__toString()); $plg_id = $db->loadResult(); if ($plg_id) { $plg_type = 'update'; } else { $plg_type = 'install'; } $installer = new JInstaller(); if (!$installer->{$plg_type}($plg)) { $error_msg = ''; while ($error = JError::getError(true)) { $error_msg .= $error; $install_error = true; } $buffer .= $this->printError($attributes['plugin'], $attributes['group'], $plg_type, $error_msg); //$this->abort(); break; } else { $buffer .= $this->printSuccess($attributes['plugin'], $attributes['group'], $plg_type); } if ($plg_type == 'install') { $query->clear(); $query->update($db->quoteName('#__extensions')); //Set any other field values as required $query->set($db->quoteName('enabled') . ' = 1'); $query->where($db->quoteName('name') . ' = ' . $db->quote($attributes['plugin'])); $query->where($db->quoteName('type') . ' = ' . $db->quote('plugin')); $db->setQuery($query->__toString()); try { $db->execute(); $buffer .= $this->printSuccess($attributes['plugin'], $attributes['group'], 'publish'); } catch (RuntimeException $e) { $install_error = true; $buffer .= $this->printError($attributes['plugin'], $attributes['group'], 'publish', $e->getMessage()); } } } } // Install modules if (count($manifest->modules->module) > 0) { // Opening HTML ob_start(); ?> <tr class="componentarchitectinstall-subheading"> <th> <?php echo JText::_('COM_COMPONENTARCHITECT_MODULE_HEADER'); ?> </th> <th> <?php echo JText::_('COM_COMPONENTARCHITECT_MODULE_GROUP_HEADER'); ?> </th> <th width="50%"> <?php echo JText::_('COM_COMPONENTARCHITECT_STATUS_HEADER'); ?> </th> </tr> <?php $buffer .= ob_get_clean(); foreach ($manifest->modules->module as $module) { $error_msg = ''; $attributes = $module->attributes(); $mod = $source . '/' . $attributes['folder'] . '/' . $attributes['module']; // check if the module is a new version for this externsion or a new plugin and either update or install $query->clear(); $query->select($db->quoteName('extension_id')); $query->from($db->quoteName('#__extensions')); $query->where($db->quoteName('name') . ' = ' . $db->quote($attributes['module'])); $query->where($db->quoteName('type') . ' = ' . $db->quote('module')); $db->setQuery($query->__toString()); $mod_id = $db->loadResult(); if ($mod_id) { $mod_type = 'update'; } else { $mod_type = 'install'; } if (!$installer->{$mod_type}($mod)) { while ($error = JError::getError(true)) { $error_msg .= $error; $install_error = true; } $buffer .= $this->printError($attributes['module'], 'site', $mod_type, $error_msg); //$this->abort(); break; } else { $buffer .= $this->printSuccess($attributes['module'], 'site', $mod_type); } } } // Closing HTML ob_start(); ?> </tbody> <tfoot> <tr> <td colspan="3" text-align="center"> <?php if ($install_error) { ?> <div id="componentarchitectinstall-component-error"> <?php echo JText::_('COM_COMPONENTARCHITECT_UPDATE_COMPONENT_ERROR'); ?> </div> <?php } else { ?> <div id="componentarchitectinstall-component-success"> <?php echo JText::_('COM_COMPONENTARCHITECT_UPDATE_COMPONENT_SUCCESS'); ?> </div> <?php } ?> </td> </tr> </tfoot> </table> </div> <?php $buffer .= ob_get_clean(); // Return stuff echo $buffer; }
/** * Display errors. * * @return string * * @since 2.5 */ protected function displayErrors() { $html = array(); $html[] = '<ol>'; while ($error = JError::getError(true)) { $col = E_WARNING == $error->get('level') ? 'red' : 'orange'; $html[] = '<li>'; $html[] = '<b style="color: ' . $col . '">' . $error->getMessage() . '</b><br />'; $info = $error->get('info'); if ($info) { $html[] = '<pre>' . print_r($info, true) . '</pre><br />'; } $html[] = $this->renderBacktrace($error); $html[] = '</li>'; } $html[] = '</ol>'; return implode('', $html); }
/** * Initialise some settings */ public function runCron() { // Buffer all output to prevent conflicts with external software ob_start(); // Start the clock $starttime = time(); $db = JFactory::getDbo(); // First check if we deal with a valid user if ($this->Login()) { // Set some global values $jinput = JFactory::getApplication()->input; $jfilter = new JFilterInput(); // Get the parameters require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/settings.php'; $settings = new CsviSettings(); // Check if we are running cron mode and set some necessary variables $_SERVER['SERVER_ADDR'] = $_SERVER['HTTP_HOST'] = $settings->get('site.hostname'); $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['REQUEST_URI'] = '/'; $_SERVER['PHP_SELF'] = '/index.php'; // Get the task to do if (isset($this->_variables['task'])) { $task = $jfilter->clean($this->_variables['task']); } else { $task = ''; } // Perform the requested task switch ($task) { case 'maintenance': $jinput->set('task', 'maintenance.' . $this->_variables['operation']); // Fire CSVI VirtueMart $this->ExecuteJob(); break; default: // Second check if any template is set to process if (array_key_exists('template_id', $this->_variables)) { $template_id = $jfilter->clean($this->_variables['template_id'], 'int'); } else { $template_id = false; } if (array_key_exists('template_name', $this->_variables)) { $template_name = $jfilter->clean($this->_variables['template_name']); } else { $template_name = false; } if ($template_id || $template_name) { // There is a template_id or template name, get some details to streamline processing $where = empty($template_id) ? 'name=' . $db->Quote($template_name) : 'id=' . $template_id; // There is a template name, get some details to streamline processing $q = "SELECT id AS template_id, name AS template_name, settings\r\n\t\t\t\t\t\t\tFROM #__csvi_template_settings\r\n\t\t\t\t\t\t\tWHERE " . $where; $db->setQuery($q); $row = $db->loadObject(); if (is_object($row)) { echo JText::sprintf('COM_CSVI_PROCESSING_STARTED', date('jS F Y, g:i a')) . "\n"; echo JText::sprintf('COM_CSVI_TEMPLATE', $row->template_name) . "\n"; // Set the template ID $jinput->set('select_template', $row->template_id); $jinput->set('template_name', $row->template_name); // Set the settings if (array_key_exists('jform', $this->_variables)) { $settings = CsviHelper::arrayExtend(json_decode($row->settings, true), $this->_variables['jform']); } else { $settings = json_decode($row->settings, true); } // Set some export settings if ($settings['options']['action'] == 'export') { // Export settings $jinput->set('task', 'exportfile.process'); // Set export to if ($settings['general']['exportto'] == 'todownload') { $settings['general']['exportto'] = 'tofile'; } } else { if ($settings['options']['action'] == 'import') { // Import settings $jinput->set('task', 'importfile.doimport'); // Turn off preview $settings['general']['show_preview'] = 0; } } // Post the settings $jinput->set('jform', $settings, 'post'); // Fire CSVI $this->ExecuteJob(); } else { if ($template_name) { echo JText::sprintf('COM_CSVI_NO_TEMPLATE_FOUND', $template_name) . "\n"; } else { if ($template_id) { echo JText::sprintf('COM_CSVI_NO_TEMPLATE_FOUND', $template_id) . "\n"; } } } } else { echo JText::_('COM_CSVI_NO_TEMPLATE_SPECIFIED') . "\n"; } break; } } else { $error = JError::getError(); echo $error->message . "\n"; } echo sprintf(JText::_('COM_CSVI_PROCESSING_FINISHED'), date('jS F Y, g:i a')) . "\n"; $duration = time() - $starttime; if ($duration < 60) { echo sprintf(JText::_('COM_CSVI_PROCESSING_SECONDS'), $duration) . "\n"; } else { echo sprintf(JText::_('COM_CSVI_PROCESSING_MINUTES'), number_format($duration / 60, 2)) . "\n"; } // Done, lets log the user out $this->UserLogout(); // Display any generated messages $messages = ob_get_contents(); @ob_end_clean(); echo $messages; }
/** * @param $dir * * @throws Exception * @return array */ private function scan($dir) { static $list = array(); JLog::add('| ~~ ' . sprintf(jgettext('Scanning %s ...'), $dir)); $items = $this->ftp->listDetails($dir); if (false == $items) { throw new Exception(JError::getError()); } foreach ($items as $item) { if ($item['type'] == 1) { //-- It's a folder self::scan($dir . '/' . $item['name']); } else { //-- It's a file $d = str_replace($this->credentials->directory . '/', '', $dir); $list[$d . '/' . $item['name']] = JArrayHelper::toObject($item); } } return $list; }
/** * The main send of one letter to one or mode recipients. * The mail content generates for each user * * TODO: Need to refactor it all to: * sendNewsletterToSubscriber($nid, $sid, $options) * sentNewsletterToEmail($nid, array $emailAndName, $options) * sentLetterToEmail(array $letterData, array $emailAndName, $options) * * @param array $params newsletter_id, subscriber(object), type ('html'|'plain'), tracking(bool) * * @return object * @since 1.0 */ public function send($params = null) { // load letter to send.... if (empty($params['newsletter_id'])) { $msg = 'Newsletter id is absent. There is nothing to send.'; $this->setError($msg); throw new Exception($msg); } if (empty($params['subscriber'])) { $msg = 'Subscriber is absent. There is no one to send.'; $this->setError($msg); throw new Exception($msg); } if (empty($params['tracking'])) { $params['tracking'] = false; } // Load newsletter... $letter = JModel::getInstance('Newsletter', 'NewsletterModelEntity'); if (!$letter->load($params['newsletter_id'])) { $msg = 'Loading letter error or newsletter_id is not defined. Id:' . $params['newsletter_id']; $this->setError($msg); throw new Exception($msg); } // Load newsletter's SMTP profile... $smtpProfile = JModel::getInstance('Smtpprofile', 'NewsletterModelEntity'); if (!$smtpProfile->load($letter->smtp_profile_id)) { $msg = 'Cant load SMTP profile with id: ' . $letter->smtp_profile_id; $this->setError($msg); throw new Exception($msg); } // Load mailbox profile bound to loaded SMTP profile... $mailboxProfile = JModel::getInstance('Mailboxprofile', 'NewsletterModelEntity'); if (!$mailboxProfile->load($smtpProfile->mailbox_profile_id)) { LogHelper::addWarning('COM_NEWSLETTER_CANT_LOAD_MAILBOX_CANT_SET_SOME_HEADERS', LogHelper::CAT_MAILER, array('Mailbox profile id' => $smtpProfile->mailbox_profile_id, 'SMTP profile' => $smtpProfile->smtp_profile_name)); } // Now we have newsletter, subscriber, SMTP profile and, probably, Mailbox profile. // So we can start to send... // Use the phpMailer exceptions $sender = new MigurMailerSender(array('exceptions' => true)); $subscriber = $params['subscriber']; $type = MailHelper::filterType(!empty($params['type']) ? $params['type'] : null); if (!$type) { $msg = 'The type "' . $type . '" is not supported'; $this->setError($msg); throw new Exception($msg); } // emulate user environment SubscriberHelper::saveRealUser(); if (!SubscriberHelper::emulateUser(array('email' => $subscriber->email))) { $msg = 'The user "' . $subscriber->email . '" is absent'; $this->setError($msg); throw new Exception($msg); } PlaceholderHelper::setPlaceholder('newsletter id', $letter->newsletter_id); // render the content of letter for each user $letter->content = $this->render(array('type' => $type, 'newsletter_id' => $letter->newsletter_id, 'tracking' => true)); $letter->subject = $this->renderSubject($letter->subject); $letter->encoding = $letter->params->encoding; SubscriberHelper::restoreRealUser(); // Result object $res = new StdClass(); $res->state = false; $res->errors = array(); $res->content = $letter->content; if ($letter->content === false) { return $res; } // Add custom headers // Set the email to bounce if (!empty($mailboxProfile->username)) { $sender->AddCustomHeader('Return-Path:' . $mailboxProfile->username); $sender->AddCustomHeader('Return-Receipt-To:' . $mailboxProfile->username); $sender->AddCustomHeader('Errors-To:' . $mailboxProfile->username); } // Add info about newsleerter and subscriber $sender->AddCustomHeader(MailHelper::APPLICATION_HEADER); $sender->AddCustomHeader(MailHelper::EMAIL_NAME_HEADER . ':' . $letter->name); $sender->AddCustomHeader(MailHelper::NEWSLETTER_ID_HEADER . ':' . $params['newsletter_id']); $sender->AddCustomHeader(MailHelper::SUBSCRIBER_ID_HEADER . ':' . $subscriber->subscriber_id); // Get attachments $atts = DownloadHelper::getByNewsletterId($params['newsletter_id']); if (!$smtpProfile->isJoomlaProfile()) { $fromName = $smtpProfile->from_name; $fromEmail = $smtpProfile->from_email; $toName = $smtpProfile->reply_to_name; $toEmail = $smtpProfile->reply_to_email; } else { $jConfig = new JConfig(); $fromName = isset($letter->params->from_name) ? $letter->params->from_name : $jConfig->fromname; $fromEmail = isset($letter->params->from_email) ? $letter->params->from_email : $jConfig->mailfrom; $toName = isset($letter->params->to_name) ? $letter->params->to_name : $jConfig->fromname; $toEmail = isset($letter->params->to_email) ? $letter->params->to_email : $jConfig->mailfrom; } // Check if we dan determine all parameters... if (empty($fromName) || empty($fromEmail) || empty($toName) || empty($toEmail)) { LogHelper::addWarning('COM_NEWSLETTER_MAILER_CANT_DETERMINE SOME FROMTO', LogHelper::CAT_MAILER, array('From name' => $fromName, 'From email' => $fromEmail, 'Reply to name' => $toName, 'Reply to email' => $toEmail, 'SMTP profile' => $smtpProfile->smtp_profile_name, 'Newsletter' => $letter->name)); } try { // send the unique letter to each recipient $sendRes = $sender->send(array('letter' => $letter->toObject(), 'attach' => $atts, 'emails' => array($subscriber), 'smtpProfile' => $smtpProfile->toObject(), 'fromName' => $fromName, 'fromEmail' => $fromEmail, 'toName' => $toName, 'toEmail' => $toEmail, 'type' => $type, 'tracking' => $params['tracking'])); // If sending failed if (!$sendRes && !empty($sender->ErrorInfo)) { throw new Exception($sender->ErrorInfo); } } catch (Exception $e) { $error = JError::getError('unset'); if (!empty($error)) { $msg = $error->get('message'); $this->setError($msg); $res->errors[] = $msg; } $res->errors[] = $e->getMessage(); LogHelper::addError('COM_NEWSLETTER_MAILER_SEND_ERROR', LogHelper::CAT_MAILER, array('Error' => $e->getMessage(), 'Email' => $subscriber->email, 'Mail type' => $type, 'SMTP profile' => $smtpProfile->smtp_profile_name, 'Newsletter' => $letter->name)); return $res; } $res->state = true; return $res; }
/** * Display errors. * * @return string * @deprecated */ protected function displayErrors() { //$html = '<div class="debug-container" id="debug-errors">'; $html = '<ol>'; while ($error = \JError::getError(true)) { $col = E_WARNING == $error->get('level') ? 'dbg-error' : 'dbg-warning'; $html .= '<li>'; $html .= '<strong class="' . $col . '">' . $error->getMessage() . '</strong><br />'; $info = $error->get('info'); if ($info) { $html .= '<pre>' . print_r($info, true) . '</pre><br />'; } $html .= $this->renderBacktrace($error); $html .= '</li>'; } $html .= '</ol>'; //$html .= '</div>'; return $html; }
public function installFrameworkAction() { $packageFile = JFactory::getConfig()->get('tmp_path') . '/jsn-tpl_framework.zip'; // Checking downloaded template package if (!is_file($packageFile)) { throw new Exception(JText::_('JSN_TPLFW_ERROR_DOWNLOAD_PACKAGE_FILE_NOT_FOUND')); } // Load install library jimport('joomla.installer.helper'); // Turn off debug mode to catch install error $conf = JFactory::getConfig(); $conf->set('debug', 0); $unpackedInfo = JInstallerHelper::unpack($packageFile); $installer = new JInstaller(); $installer->setUpgrade(true); $installResult = $installer->install($unpackedInfo['dir']); // Clean up temporary data JInstallerHelper::cleanupInstall($packageFile, $unpackedInfo['dir']); // Clean up compressed files $this->_cleanCache(); // Send error if install is failure if (class_exists('JError')) { $error = JError::getError(); if (!empty($error)) { throw $error; } } }
/** * Reorder * * @return void */ public function reorder() { $app = JFactory::getApplication(); $session = JFactory::getSession(); $post = JRequest::get('post'); $order_id = isset($post['order_id']) ? $post['order_id'] : JRequest::getInt('order_id'); $Itemid = JRequest::getVar('Itemid'); $Itemid = $this->_redhelper->getCartItemid(); $returnmsg = ""; if ($order_id) { // First Empty Cart and then oder it again $cart['idx'] = 0; $session->set('cart', $cart); $orderItem = $this->_order_functions->getOrderItemDetail($order_id); for ($i = 0; $i < count($orderItem); $i++) { $row = (array) $orderItem[$i]; $subscription_id = 0; $row['quantity'] = $row['product_quantity']; if ($row['is_giftcard'] == 1) { $row['giftcard_id'] = $row['product_id']; $row['reciver_name'] = $row['giftcard_user_name']; $row['reciver_email'] = $row['giftcard_user_email']; } else { $product_data = $this->_producthelper->getProductById($row['product_id']); if ($product_data->product_type == 'subscription') { $productSubscription = $this->_producthelper->getUserProductSubscriptionDetail($row['order_item_id']); if ($productSubscription->subscription_id != "") { $subscription_id = $productSubscription->subscription_id; } } $generateAttributeCart = $this->_carthelper->generateAttributeFromOrder($row['order_item_id'], 0, $row['product_id'], $row['product_quantity']); $generateAccessoryCart = $this->_carthelper->generateAccessoryFromOrder($row['order_item_id'], $row['product_id'], $row['product_quantity']); $row['cart_attribute'] = $generateAttributeCart; $row['cart_accessory'] = $generateAccessoryCart; $row['subscription_id'] = $subscription_id; $row['sel_wrapper_id'] = $row['wrapper_id']; $row['category_id'] = 0; if (is_file(REDSHOP_FRONT_IMAGES_RELPATH . "orderMergeImages/" . $row['attribute_image'])) { $new_media = JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $row['attribute_image']; $old_media = JPATH_ROOT . '/components/com_redshop/assets/images/orderMergeImages/' . $row['attribute_image']; copy($old_media, $new_media); } $row['attributeImage'] = $row['attribute_image']; $row['reorder'] = 1; } $result = $this->_carthelper->addProductToCart($row); if (is_bool($result) && $result) { $returnmsg .= $row['order_item_name'] . ": " . JText::_("COM_REDSHOP_PRODUCT_ADDED_TO_CART") . "<br>"; } else { $ItemData = $this->_producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $row['product_id']); if (count($ItemData) > 0) { $Itemid = $ItemData->id; } else { $Itemid = $this->_redhelper->getItemid($row['product_id']); } $errmsg = $result ? $result : JText::_("COM_REDSHOP_PRODUCT_NOT_ADDED_TO_CART"); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } $returnmsg .= $row['order_item_name'] . ": " . $errmsg . "<br>"; $returnlink = "index.php?option=com_redshop&view=product&pid=" . $row["product_id"] . "&Itemid=" . $Itemid; } } $this->_carthelper->cartFinalCalculation(); } $cart = $session->get('cart'); if (!$cart || !array_key_exists("idx", $cart) || $cart && $cart['idx'] <= 0) { $app->redirect($returnlink); } else { $app->redirect("index.php?option=com_redshop&view=cart&Itemid=" . $Itemid, $returnmsg); } }
public function importStockFromEconomic() { // Add product stock from economic $cnt = JRequest::getInt('cnt', 0); $stockroom_id = JRequest::getInt('stockroom_id', 0); $totalprd = 0; $msg = ''; if (ECONOMIC_INTEGRATION == 1) { $economic = new economic(); $db = JFactory::getDbo(); $incNo = $cnt; $query = 'SELECT p.* FROM #__redshop_product AS p ' . 'LIMIT ' . $cnt . ', 10 '; $db->setQuery($query); $prd = $db->loadObjectlist(); $totalprd = count($prd); $responcemsg = ''; for ($i = 0; $i < count($prd); $i++) { $incNo++; $ecoProductNumber = $economic->importStockFromEconomic($prd[$i]); $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_PRODUCT_NUMBER') . " " . $prd[$i]->product_number . " -> "; if (count($ecoProductNumber) > 0 && isset($ecoProductNumber[0])) { $query = "UPDATE #__redshop_product_stockroom_xref " . "SET quantity='" . $ecoProductNumber[0] . "' " . "WHERE product_id='" . $prd[$i]->product_id . "' " . "AND stockroom_id='" . $stockroom_id . "' "; $db->setQuery($query); $db->Query(); $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_STOCK_FROM_ECONOMIC_SUCCESS') . "</span>"; } else { $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_STOCK_FROM_ECONOMIC'); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>"; } $responcemsg .= "</div>"; } if ($totalprd > 0) { $msg = $responcemsg; } else { $msg = JText::_("COM_REDSHOP_IMPORT_STOCK_FROM_ECONOMIC_IS_COMPLETED"); } } echo "<div id='sentresponse'>" . $totalprd . "`_`" . $msg . "</div>"; die; }
public function importatteco() { // Add product attribute to economic $cnt = JRequest::getInt('cnt', 0); $totalprd = 0; $msg = ''; if (ECONOMIC_INTEGRATION == 1 && ATTRIBUTE_AS_PRODUCT_IN_ECONOMIC == 1) { $economic = new economic(); $db = JFactory::getDbo(); $incNo = $cnt; $query = "SELECT ap.*, a.attribute_name, p.product_id, p.accountgroup_id " . "FROM #__redshop_product_attribute_property AS ap " . "LEFT JOIN #__redshop_product_attribute AS a ON a.attribute_id=ap.attribute_id " . "LEFT JOIN #__redshop_product AS p ON p.product_id=a.product_id " . "WHERE p.published=1 " . "AND p.product_id!='' " . "AND ap.property_number!='' " . "LIMIT " . $cnt . ", 10 "; $db->setQuery($query); $list = $db->loadObjectlist(); $totalprd = count($list); $responcemsg = ''; for ($i = 0; $i < count($list); $i++) { $incNo++; $prdrow = new stdClass(); $prdrow->product_id = $list[$i]->product_id; $prdrow->accountgroup_id = $list[$i]->accountgroup_id; $ecoProductNumber = $economic->createPropertyInEconomic($prdrow, $list[$i]); $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_PROPERTY_NUMBER') . " " . $list[$i]->property_number . " -> "; if (count($ecoProductNumber) > 0 && is_object($ecoProductNumber[0]) && isset($ecoProductNumber[0]->Number)) { $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_ATTRIBUTES_TO_ECONOMIC_SUCCESS') . "</span>"; } else { $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_ATTRIBUTES_TO_ECONOMIC'); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>"; } $responcemsg .= "</div>"; } $query = "SELECT sp.*, ap.property_id, ap.property_name, p.product_id, p.accountgroup_id FROM #__redshop_product_subattribute_color AS sp " . "LEFT JOIN #__redshop_product_attribute_property AS ap ON ap.property_id=sp.subattribute_id " . "LEFT JOIN #__redshop_product_attribute AS a ON a.attribute_id=ap.attribute_id " . "LEFT JOIN #__redshop_product AS p ON p.product_id=a.product_id " . "WHERE p.published=1 " . "AND p.product_id!='' " . "AND sp.subattribute_color_number!='' " . "LIMIT " . $cnt . ", 10 "; $db->setQuery($query); $list = $db->loadObjectlist(); $totalprd = $totalprd + count($list); for ($i = 0; $i < count($list); $i++) { $incNo++; $prdrow = new stdClass(); $prdrow->product_id = $list[$i]->product_id; $prdrow->accountgroup_id = $list[$i]->accountgroup_id; $ecoProductNumber = $economic->createSubpropertyInEconomic($prdrow, $list[$i]); $responcemsg .= "<div>" . $incNo . ": " . JText::_('COM_REDSHOP_SUBPROPERTY_NUMBER') . " " . $list[$i]->subattribute_color_number . " -> "; if (count($ecoProductNumber) > 0 && is_object($ecoProductNumber[0]) && isset($ecoProductNumber[0]->Number)) { $responcemsg .= "<span style='color: #00ff00'>" . JText::_('COM_REDSHOP_IMPORT_ATTRIBUTES_TO_ECONOMIC_SUCCESS') . "</span>"; } else { $errmsg = JText::_('COM_REDSHOP_ERROR_IN_IMPORT_ATTRIBUTES_TO_ECONOMIC'); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } $responcemsg .= "<span style='color: #ff0000'>" . $errmsg . "</span>"; } $responcemsg .= "</div>"; } if ($totalprd > 0) { $msg = $responcemsg; } else { $msg = JText::_("COM_REDSHOP_IMPORT_ATTRIBUTES_TO_ECONOMIC_IS_COMPLETED"); } } echo "<div id='sentresponse'>" . $totalprd . "`_`" . $msg . "</div>"; die; }