Skip to content

Commit

Permalink
Merge pull request chilek#222 from maciejlew/oop
Browse files Browse the repository at this point in the history
Constructors, properties and methods visibility in new PHP5 style for some LMS base classes
  • Loading branch information
chilek committed May 15, 2014
2 parents 830ff02 + da0587c commit f7f90a6
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 450 deletions.
66 changes: 33 additions & 33 deletions lib/Auth.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@

class Auth {

var $id;
var $login;
var $logname;
var $passwd;
var $islogged = FALSE;
var $nousers = FALSE;
var $passverified = FALSE;
var $hostverified = FALSE;
var $access = FALSE;
var $accessfrom = FALSE;
var $accessto = FALSE;
var $swekeyauthenticated = FALSE;
var $swekeyid;
var $last;
var $ip;
var $lastip;
var $passwdrequiredchange = FALSE;
var $error;
var $_version = '1.11-git';
var $_revision = '$Revision$';
var $DB = NULL;
var $SESSION = NULL;
var $SYSLOG = NULL;

function Auth(&$DB, &$SESSION, &$SYSLOG) {
public $id;
public $login;
public $logname;
public $passwd;
public $islogged = FALSE;
public $nousers = FALSE;
public $passverified = FALSE;
public $hostverified = FALSE;
public $access = FALSE;
public $accessfrom = FALSE;
public $accessto = FALSE;
public $swekeyauthenticated = FALSE;
public $swekeyid;
public $last;
public $ip;
public $lastip;
public $passwdrequiredchange = FALSE;
public $error;
public $_version = '1.11-git';
public $_revision = '$Revision$';
public $DB = NULL;
public $SESSION = NULL;
public $SYSLOG = NULL;

public function __construct(&$DB, &$SESSION, &$SYSLOG) {
$this->DB = &$DB;
$this->SESSION = &$SESSION;
$this->SYSLOG = &$SYSLOG;
Expand Down Expand Up @@ -150,11 +150,11 @@ function Auth(&$DB, &$SESSION, &$SYSLOG) {
}
}

function _postinit() {
public function _postinit() {
return TRUE;
}

function LogOut() {
public function LogOut() {
if ($this->islogged) {
writesyslog('User ' . $this->login . ' logged out.', LOG_INFO);
if ($this->SYSLOG) {
Expand All @@ -167,15 +167,15 @@ function LogOut() {
$this->SESSION->finish();
}

function VerifyPassword($dbpasswd = '') {
public function VerifyPassword($dbpasswd = '') {
if (crypt($this->passwd, $dbpasswd) == $dbpasswd)
return TRUE;

$this->error = trans('Wrong password or login.');
return FALSE;
}

function VerifyAccess($access) {
public function VerifyAccess($access) {
$access = intval($access);
if (empty($access)) {
$this->error = trans('Account is disabled');
Expand All @@ -184,7 +184,7 @@ function VerifyAccess($access) {
else return TRUE;
}

function VerifyAccessFrom($access) {
public function VerifyAccessFrom($access) {
$access = intval($access);
if (empty($access)) return TRUE;
if ($access < time()) return TRUE;
Expand All @@ -194,7 +194,7 @@ function VerifyAccessFrom($access) {
}
}

function VerifyAccessTo($access) {
public function VerifyAccessTo($access) {
$access = intval($access);
if (empty($access)) return TRUE;
if ($access > time()) return TRUE;
Expand All @@ -204,7 +204,7 @@ function VerifyAccessTo($access) {
}
}

function VerifyHost($hosts = '') {
public function VerifyHost($hosts = '') {
if (!$hosts)
return TRUE;

Expand Down Expand Up @@ -237,7 +237,7 @@ function VerifyHost($hosts = '') {
return FALSE;
}

function VerifyUser() {
public function VerifyUser() {
global $CONFIG;

$this->islogged = false;
Expand Down
48 changes: 24 additions & 24 deletions lib/ExecStack.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@

class ExecStack
{
var $version = '1.11-git';
var $_MODINFO = array();
var $_BINDTABLE = array();
var $_EXECSTACK = array();
var $_STATUS = array();
var $module;
var $action;
var $modules_dir;
public $version = '1.11-git';
public $_MODINFO = array();
public $_BINDTABLE = array();
public $_EXECSTACK = array();
public $_STATUS = array();
public $module;
public $action;
public $modules_dir;

function ExecStack($directory = 'modules/', $module, $action)
public function __construct($directory = 'modules/', $module, $action)
{
$this->module = $module;
$this->action = $action;
Expand All @@ -44,7 +44,7 @@ function ExecStack($directory = 'modules/', $module, $action)
$this->buildExecStack($module, $action);
}

function loadModules($modules_dir)
public function loadModules($modules_dir)
{
$this->modules_dir = $modules_dir;
$this->_MODINFO = array();
Expand Down Expand Up @@ -106,23 +106,23 @@ function loadModules($modules_dir)
return $this->_MODINFO;
}

function getDefaultModule()
public function getDefaultModule()
{
if($this->_MODINFO)
foreach($this->_MODINFO as $module_name => $module_info)
if($module_info['default'] === TRUE)
return $module_name;
}

function getDefaultAction($module)
public function getDefaultAction($module)
{
if(isset($this->_MODINFO[$module]) && $this->_MODINFO[$module]['actions'])
foreach($this->_MODINFO[$module]['actions'] as $action_name => $action_info)
if($action_info['default'] === TRUE)
return $action_name;
}

function buildBindTable()
public function buildBindTable()
{
$this->_BINDTABLE = array(
'pre/*:*' => array(),
Expand All @@ -140,22 +140,22 @@ function buildBindTable()
return $this->_BINDTABLE;
}

function needExec($module, $action)
public function needExec($module, $action)
{
return ! $this->_MODINFO[$module]['actions'][$action]['dontexec'];
}

function needTemplate($module, $action)
public function needTemplate($module, $action)
{
return ! $this->_MODINFO[$module]['actions'][$action]['notemplate'];
}

function getTemplate($module, $action)
public function getTemplate($module, $action)
{
return $this->_MODINFO[$module]['actions'][$action]['template'];
}

function replaceTemplate($src_mod, $src_tpl, $dst_mod, $dst_tpl)
public function replaceTemplate($src_mod, $src_tpl, $dst_mod, $dst_tpl)
{
foreach($this->_EXECSTACK['templates'] as $idx => $template)
if($template['module'] == $src_mod && $template['template'] == $src_tpl)
Expand All @@ -165,7 +165,7 @@ function replaceTemplate($src_mod, $src_tpl, $dst_mod, $dst_tpl)
}
}

function dropTemplate($module, $template)
public function dropTemplate($module, $template)
{
$templates = $this->_EXECSTACK['templates'];
foreach($templates as $idx => $tpl)
Expand All @@ -176,7 +176,7 @@ function dropTemplate($module, $template)
}
}

function dropAction($module, $action)
public function dropAction($module, $action)
{
$actions = $this->_EXECSTACK['actions'];
foreach($actions as $idx => $act)
Expand All @@ -187,27 +187,27 @@ function dropAction($module, $action)
}
}

function moduleExists($module)
public function moduleExists($module)
{
return isset($this->_MODINFO[$module]) && is_array($this->_MODINFO[$module]) && is_readable($this->modules_dir.'/'.$module.'/modinfo.php');
}

function moduleIsPublic($module)
public function moduleIsPublic($module)
{
return ! $this->_MODINFO[$module]['notpublic'];
}

function actionExists($module, $action)
public function actionExists($module, $action)
{
return is_array($this->_MODINFO[$module]['actions'][$action]) && ($this->needExec($module, $action) ? is_readable($this->modules_dir.'/'.$module.'/actions/'.$action.'.php') : TRUE);
}

function actionIsPublic($module, $action)
public function actionIsPublic($module, $action)
{
return ! $this->_MODINFO[$module]['actions'][$action]['notpublic'];
}

function buildExecStack($module, $action, $depth = 0)
public function buildExecStack($module, $action, $depth = 0)
{
if($depth == 0)
{
Expand Down
Loading

0 comments on commit f7f90a6

Please sign in to comment.