Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K6.4 #9752

Merged
merged 11 commits into from
Oct 8, 2024
Prev Previous commit
Next Next commit
[K6.4] remove CMSObject from KunenaSession
Signed-off-by: Sven Schultschik <sven@schultschik.de>
  • Loading branch information
svanschu committed Oct 7, 2024
commit ad6ae8f84310c87198a2685bcf84fe87b292c22a
55 changes: 43 additions & 12 deletions src/libraries/kunena/src/Session/KunenaSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Object\CMSObject;
use Joomla\Database\DatabaseInterface;
use Kunena\Forum\Libraries\Factory\KunenaFactory;
use Kunena\Forum\Libraries\Forum\Category\User\KunenaCategoryUserHelper;
Expand All @@ -28,13 +27,19 @@
*
* @since Kunena 6.0
*/
class KunenaSession extends CMSObject
class KunenaSession
{
/**
* @var mixed
* @since Kunena 6.0
* @var integer
* @since Kunena 6.0
*/
private static $_instance;
public $userid;

/**
* @var string
* @since Kunena 6.4
*/
public $allowed;

/**
* @var integer|string
Expand All @@ -46,15 +51,20 @@ class KunenaSession extends CMSObject
* @var integer|string
* @since Kunena 6.0
*/
public $currvisit;
public $readtopics;

/**
* @var integer|string
* @since Kunena 6.0
*/
public $readtopics;
public $currvisit;

public $userid;

/**
* @var mixed
* @since Kunena 6.0
*/
private static $_instance;

/**
* @var boolean
Expand Down Expand Up @@ -98,8 +108,20 @@ public function __construct($identifier)
$userCategory = KunenaCategoryUserHelper::get(0, (int) $identifier);
$this->allreadtime = $userCategory->allreadtime ? $userCategory->allreadtime : $this->lasttime;
}
}

parent::__construct($identifier);
/**
* Bind the data
* @param array $properties
* @return bool
*/
public function bind(array $properties)
{
foreach ((array) $properties as $k => $v) {
$this->$k = $v;
}

return true;
}

/**
Expand All @@ -123,7 +145,7 @@ public function load(int $userid): bool
}

// Assuming all is well at this point lets bind the data
$this->setProperties($table->getProperties());
$this->bind($table->getProperties());
$this->userid = $userid;

return true;
Expand Down Expand Up @@ -163,7 +185,7 @@ public function getTable($type = 'Kunena\\Forum\\Libraries\\Tables\\', $prefix =

/**
* @param bool $update update
* @param null $userid userid
* @param int|null $userid userid
*
* @return KunenaSession
* @throws Exception
Expand Down Expand Up @@ -240,7 +262,16 @@ public function save($updateOnly = false): bool

// Create the user table object
$table = $this->getTable();
$table->bind($this->getProperties());

$properties = [
'userid' => $this->userid,
'allowed' => $this->allowed,
'lasttime' => $this->lasttime,
'readtopics' => $this->readtopics,
'currvisit' => $this->currvisit
];

$table->bind($properties);
$table->exists($this->_exists);

// Check and store the object.
Expand Down