Fatal error: Call to a member function getUserStateFromRequest() on a non-object in administrator\components\com_jquarks\models\quizzes.php on line 60 - joomla2.5

i am using joomla 2.5 and i want to create some tests for my students, so that's why i just downloaded JQuarks plugin and installed. But when i go to Components/JQuarks through administration panel it shows me this error!!
Fatal error: Call to a member function getUserStateFromRequest() on a non-object in administrator\components\com_jquarks\models\quizzes.php on line 60
So, i go to on line 60 .
Here's the code:
function getQuizzes()
{
if (empty( $this->_quizzes ))
{
global $mainframe ;
$context = 'com_jquarks.quizzes.list.' ;
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int') ;
$this->_filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'title', 'cmd' );
$this->_filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
$orderby = '' ;
if($this->_filter_order_Dir) {
$orderby = ' ORDER BY '.$this->_filter_order.' '.$this->_filter_order_Dir ;
}
$query = ' SELECT quizzes.*, g.name AS groupname' .
' FROM #__jquarks_quizzes AS quizzes' .
' LEFT JOIN #__groups AS g ON g.id = quizzes.access_id' .
$orderby ;
$total = $this->_getListCount($query) ;
jimport('joomla.html.pagination') ;
$this->_pageNav = new JPagination( $total, $limitstart, $limit ) ;
$this->_db->setQuery($query) ;
$this->_quizzes = $this->_getList( $query, $this->_pageNav->limitstart, $this->_pageNav->limit );
if ($this->_db->getErrorNum()) {
return false;
}
}
return $this->_quizzes ;
}
Please help to fix this problem!!!
Thanks in advance.

I fixed a problem. Problem is the version of the Jquarks plugin was 0.2.4 and my joomla's version is 2.5. So i looked up from internet ,JQuarks 0.2.4 is for joomla 1.5 version not for joomla 2.5 . Then i just downloaded another plugin called ARI Quiz Lite to create some exams for my students. This plugin is for joomla 1.5,2.5 and 3.0 . Now its working.....:)

Related

My Opencart shows php warning undefined array key

I have a problem with a language extension I recently installed. Now I cannot login in the admin panel and I see these logs:
2022-12-30 16:30:17 - PHP Warning: Undefined array key "" in /var/www/html/opencart/admin-084AQ/controller/startup/language.php on line 21
2022-12-30 16:30:17 - PHP Warning: Trying to access array offset on value of type null in /var/www/html/opencart/admin-084AQ/controller/startup/language.php on line 21
2022-12-30 16:30:17 - PHP Warning: Undefined array key "" in /var/www/html/opencart/admin-084AQ/controller/startup/language.php on line 27
The language.php is:
<?php
namespace Opencart\Admin\Controller\Startup;
class Language extends \Opencart\System\Engine\Controller {
public function index(): void {
$language_data = [];
$this->load->model('localisation/language');
$results = $this->model_localisation_language->getLanguages();
foreach ($results as $result) $language_data[$result['code']] = $result;
// Language not available then use default
$code = $this->config->get('config_language_admin');
if (isset($this->request->cookie['language']) && array_key_exists($this->request->cookie['language'], $language_data)) {
$code = $this->request->cookie['language'];
}
// Set the config language_id
$this->config->set('config_language_id', $language_data[$code]['language_id']);
$this->config->set('config_language_admin', $code);
// Language
$language = new \Opencart\System\Library\Language($code);
if (!$language_data[$code]['extension']) {
$language->addPath(DIR_LANGUAGE);
} else {
$language->addPath(DIR_EXTENSION . $language_data[$code]['extension'] . '/admin/language/');
}
$language->load($code);
$this->registry->set('language', $language);
}
}
Opencart 4.0.1.1
PHP 8.0
Opencart expects the config_language_admin value in the key field of the oc_settings table. But it is most likely saved as config_admin_language there.
So the fix would be to rename config_admin_language to config_language_admin in the database.

Doctrine Querybuilder, binding Parameters

My Select function of my QueryManager:
/**
* Führt eine SELECT - Query durch
*
* #param $select = array( array(column, [...]), table, shortcut )
* $orderby = array(column, sorting-type)
* $where = array( array( column, value, type[or, and] ), [...] )
* $innerjoin = array( table, shortcut, condition )
* $pagination = array( page, limit )
*
* #return array $data
*/
public function select($select,$orderby, $where, $innerjoin, $pagination)
{
$qb = $this->conn->createQueryBuilder()
->select($select[0])
->from($select[1], $select[2])
;
if ($orderby) {
$qb->orderBy($orderby);
}
if ($where) {
foreach($where as $cond) {
$x = 0;
if ( key($cond) == 0 ) {
$qb
->where($cond[0] . ' = ?')
->setParameter($x,$cond[1]);
}
elseif ( $cond[2] == 'and' ) {
$qb
->andWhere($cond[0] . ' = ?')
->setParameter($x,$cond[1]);
}
elseif ( $cond[2] == 'and' ) {
$qb
->orWhere($cond[0] . ' = :' . $x)
->setParameter($x,$cond[1]);
}
$x++;
}
}
if ($innerjoin) {
$qb->join($select[2],$innerjoin);
}
$this->sql = $qb->getSQL();
$this->totalRowCount = count( $qb->execute() ) ;
if ($pagination) {
$max = $pagination[0] * $pagination[1];
$first = $max - $limit;
$qb
->setFirstResult($first)
->setMaxResults($max)
;
}
$stmt = $qb->execute();
return $stmt->fetchAll();
}
I don't know why, but in action, this function produces a select query without inserted values for the parameters:
/**
* Lädt einen User nach dessen Username
*
* #param $username
* #return User $user | null
*/
public function getUser($username)
{
if($data = $this->select(array('*','users','u'), null, array( array('username',$username) ), null,null)) {
return $user = $this->hydrate($data);
}
return null;
}
I didn't get a result, and the query is not setup correctly:
array(0) { }
SELECT * FROM users u WHERE username = ?
In my opinion the Builder doesn't supstitute my parameters with the provided values ...
I got the latest version of Doctrine DBAL (2.4) and this version should support this features!
Thanks for Help and Suggestions :)
I also had this Problem. I have readed here doctrine 2 querybuilder with set parameters not working that:
You cant bind parameters to QueryBuilder, only to Query
But im creating SQL conditions as collected AND & OR experssions in deep nested objects, and the toppest object creates the query object. So i cant create the query object before, i always return expression objects.
So i solved the problem with direct including the variable into the prepared variable's position.
$qb->where($cond[0] . '=' . $cond[1]);
And because i expect strings there i added hard coded quotes. This is not the desired way, but at the moment i dont know how to solve that in an other way with binding parameters to the QueryBuilder object.
$expr = $d_qb->expr()->between($t_c, "'" . $date_from . "'", "'" . $date_from . "'");
Other suggestions?
Following codes results:
$expr = $d_qb->expr()->between($t_c, ':from', ':to');
$d_qb->setParameter('from', 1);
$d_qb->setParameter('to', 1);
or
$expr = $d_qb->expr()->between($t_c, ':from', ':to');
$d_qb->setParameter(':from', 1);
$d_qb->setParameter(':to', 1);
Results:
e0_.created BETWEEN ? AND ?

VirtueMart 2.6.6 custom field (cart variable) not displayed in the order details

I programmed a custom field plugin for Virtuemart 2.6.6, which show some parameters on the product page for example "size", and that parameter is a cart variable either.
A huge help was this article:
https://www.spiralscripts.co.uk/Joomla-Tips/custom-plugin-fields-in-virtuemart-2-2.html
And of course stackoverflow forum and factory default VM custom plugins.
Everything is working (the size is displayed in product details view, and in the cart, when you added the product to it) but one thing:
after sending the order the parameter has not displayed in the order details, so I don't know what size of product was bought.
I placed following functions into my plugin, but not solved my problem:
function plgVmOnViewCart($product, $row, &$html)
{
if (empty($product->productCustom->custom_element) or $product->productCustom->custom_element != $this->_name) return '';
if (!$plgParam = $this->GetPluginInCart($product)) return false ;
$html .= '<div class="parameterek_attributes">';
foreach ($plgParam as $attributes) {
foreach ($attributes as $k => $attribute) {
if ($k =='child_id') continue;
if ($k == 'custom_param_default3') $name = 'Veľkosť'; else $name = '';
$html .='<span class="parameterek_attribute"> '.$name.': '.JText::_($attribute).' </span>';
}
}
$html.='</div>';
return true;
}
/**
*
* shopper order display BackEnd
*/
function plgVmDisplayInOrderBE($item, $row,&$html)
{
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
if(!empty($productCustom)){
$item->productCustom = $productCustom;
}
$this->plgVmOnViewCart($item, $row,$html);
}
/**
*
* shopper order display FrontEnd
*/
function plgVmDisplayInOrderFE($item, $row,&$html)
{
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
$this->plgVmOnViewCart($item, $row,$html);
}
Into database table called #__virtuemart_order_items were saved values: something like:
{"357":"5"}
but it should be something like:
{"357":"size M"}
I see that the key function is GetPluginInCart($product), and when I printed out the $product->param in that function I've got this output, when I go through checkout process:
Array
(
[0] => Array
(
[parameterek] => Array
(
[custom_param_default3] => L
)
)
)
but after I finish the order and go into order details the $product->param has this value:
Array
(
[357] => 5
)
So I think, before I finish the order I have to somehow handle the
chosen product parameter and transform it into the correct form, but
I don't know how.
On the following site
https://dev.virtuemart.net/projects/virtuemart/wiki/Product_Plugins
I found a function:
plgVmOnViewCartOrder($product, $param,$productCustom, $row)
handel $param before adding it in the order
return $param;
but when I searched for the string "plgVmOnViewCartOrder" in the whole virtuemart installation, it was not found, so it means it is not launched (?)
If anybody could help me or send a fair documentation would be very good. Thank you!
I think, I solved my problem, what was:
in function plgVmOnDisplayProductVariantFE I made a mistake, I didn't use layout renderer, which generates an object $viewData with variable virtuemart_customfield_id.
Then in your plugin's layout, input field name has to be as follows:
<input
class="parameterekInput"
type="radio"
id="plugin_param['.$viewData[0]->virtuemart_customfield_id.']['.$this->_name.']['.$c.']"
name="customPlugin['.$viewData[0]->virtuemart_customfield_id.']['.$this->_name.'][custom_param_default3]"
value="'.$size.'" />
so the name attribute should be always:
customPlugin['.$viewData[0]->virtuemart_customfield_id.']['.$this->_name.'][whatever]
The right usage of plgVmOnDisplayProductVariantFE function is to use expression:
$group->display .= $this->renderByLayout('default',array($field,&$idx,&$group )
Here the whole function with the right expresion:
function plgVmOnDisplayProductVariantFE ($field, &$idx, &$group) {
if ($field->custom_element != $this->_name) return '';
$this->getCustomParams($field);
$this->getPluginCustomData($field, $field->virtuemart_product_id);
$group->display .= $this->renderByLayout('default',array($field,&$idx,&$group ) );
return true;
}
Now when I print_r -ing $product->param in function GetPluginInCart($product), I get this:
Array
(
[273] => Array //previously the key was Zero, now it is 273, value of virtuemart_customfield_id
(
[parameterek] => Array
(
[custom_param_default3] => L
)
)
)
...and now I'm glad, that I can move on in my project :)

Class 'SQLiteDatabase' not found in includes\modules\ultimate_seo_urls5\cache_system\sqlite.php on line 99

in oscommerce we used ULTIMATE Seo Urls 5 Plugin , in this we are facing a issue like When we go to
admin->
Configuration->Seo url5->select your chosen cache system we changed mysql to sqlite when changed home page client site shows Class 'SQLiteDatabase' not found in includes\modules\ultimate_seo_urls5\cache_system\sqlite.php on line 99
at this line i found
protected static function createDatabase() {
if ( !is_readable( self::$sqlite_db_file ) ) {
self::$db = new SQLiteDatabase( self::$sqlite_db_file, 0666, $error )
or trigger_error( 'Failed: ' . $error, E_USER_WARNING );
self::createTables();
} else {
self::$db = new SQLiteDatabase( self::$sqlite_db_file, 0666, $error )
or trigger_error( 'Failed: ' . $error, E_USER_WARNING );
}
}
this how to solve this
In file
includes\modules\ultimate_seo_urls5\cache_system\sqlite.php,
at line 99 Use
self::$db = new SQLite3( self::$sqlite_db_file, 0666, $error );
For both lines for php 5.4 and above
In file
includes/modules/ultimate_seo_urls5/main/usu5.php
at line no 308 use fetchArray() rather fetch() function.
$row = $result->fetchArray();
I have faced the same problem and corrected it by this way. oscommerce version 2.3

Why is my plugin for Joomla 2.5 not executed?

I am developing a plugin (still a newby to development for 2.5) but somehow I don't even get the beast to do the most basic thing - it seems it is not launched at all. However, PHP's parsor-errors are shown on the Frontend, but when this code is triggered nothing happens - none of diagnostice message are shown on screen or in my logfile...
Where's the problem?
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.plugin.plugin');
class plgContentSIMPLE_Plugin extends JPlugin
{
function plgContentSIMPLE_Plugin( &$subject , $config ) {
echo "constructor!";
parent::__construct( $subject , $config );
}
function onPrepareContent ($article , $params, $limitstart)
{
oBDC ("oPC",$article , $params, $limitstart);
}
function onBeforeDisplayContent ($article , $params, $limitstart)
{
oBDC ("oBDC",$article , $params, $limitstart);
}
function onAfterDisplayContent ($article , $params, $limitstart)
{
oBDC ("oADC",$article , $params, $limitstart);
}
function oBDC($whoscalling,$article , $params, $limitstart)
{
echo "whoscalling = " . $whoscalling;
$myFile = "./obdc.log";
$fh = fopen($myFile, 'a'); // or die("can't open file");
$stringData = "\n whoscalling = " . $whoscalling;
fwrite($fh, $stringData);
fclose($fh);
}
}
How are you installing the plugin? Have you read the Joomla Plugin tutorial? Here is a pretty good tutorial, try getting this to work first -
https://www.inmotionhosting.com/support/edu/joomla-25/create-plugin
Several issues:
Naming conventions:
class plgContentSimple extends JPlugin
{
function __construct( &$subject , $config ) {
Event is called "onContentAfterDisplay"...