diff --git a/action.defaultadmin.php b/action.defaultadmin.php index 7cdf7848226ad2359709d93e97c387304f72019f..beac39144b74f1f41a68f64913fcdd8df9ab9ecf 100644 --- a/action.defaultadmin.php +++ b/action.defaultadmin.php @@ -11,19 +11,11 @@ * API, and that everything's safe to continue: */ // require_once 'lib/class.Group.php'; -if (!isset($gCms)) exit; - +//if (!isset($gCms)) exit; +if( !defined('CMS_VERSION') ) exit; //echo '<pre>'; print_r($params); echo '</pre>'; -/** - * For separated methods, you won't be able to do permission checks in - * the DoAction method, so you'll need to do them as needed in your - * method: -*/ -/* if (! $this->CheckPermission('Use ReglerAddress')) { */ -/* return $this->DisplayErrorPage($id, $params, $returnid, */ -/* 'ReglerAddress access denied.'); */ -/* } */ + $canChangeRecord = $this->CheckPermission('Use ReglerAddress'); /** * After this, the code is identical to the code that would otherwise be @@ -31,11 +23,10 @@ $canChangeRecord = $this->CheckPermission('Use ReglerAddress'); */ $groups = Groups::getGroupList(); -//echo '<pre>'; print_r($groups); echo '</pre>'; exit; $addrDB = AddressDB::getDB(); + $smarty = $this->smarty; -// echo '<pre>'; print_r($params); echo '</pre>'; $place = $this->CreateFormStart($id, 'defaultadmin', $returnid); $smarty->assign('start_form', $place); diff --git a/action.printGroup.php b/action.printGroup.php index ac2faa3a0491603c1ca6029d0b7653ad1aabb7a9..e28e35bfce489395faf05c74ab919042aa8ad0c5 100644 --- a/action.printGroup.php +++ b/action.printGroup.php @@ -1,5 +1,5 @@ <?php -if (!isset($gCms)) exit; +if( !defined('CMS_VERSION') ) exit; //echo '<pre>'; print_r($params); echo '</pre>'; $ID = $params['ID']; diff --git a/lib/class.AddressDB.php b/lib/class.AddressDB.php index f3940a2cc211be545db7cd0ceb7dc7ebec18362a..829c9e63469a0dde927fe89f39ae0c69732db116 100644 --- a/lib/class.AddressDB.php +++ b/lib/class.AddressDB.php @@ -6,15 +6,15 @@ class AddressDB { private static $database = 'NyAdresser'; private function __construct() { - global $gCms; - if (!isset($gCms)) exit; - $config =& $gCms->GetConfig(); + if( !defined('CMS_VERSION') ) exit; + $config = cms_utils::get_config(); $this->PDB = ADONewConnection($config['dbms'], 'pear:date:extend:transaction'); $result = $this->PDB->Connect($config['db_hostname'], $config['db_username'], $config['db_password'], self::$database); + if ($result) { $result = $this->PDB->Execute("SET NAMES 'utf8'"); } else { @@ -24,6 +24,7 @@ class AddressDB { } public static function getDB() { + if( !defined('CMS_VERSION') ) exit; if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c; @@ -32,6 +33,7 @@ class AddressDB { } public static function getFields($tableName) { + if( !defined('CMS_VERSION') ) exit; $db = self::getDB(); $query = 'select column_name from information_schema.columns where ' . 'table_schema="'. self::$database . '" and table_name=?'; diff --git a/lib/class.Groups.php b/lib/class.Groups.php index f3c191b6b28c9ae1f1e5772194b712ee1c55f1ff..1997ee7b332aa9eb7690fe25fbe9e99f96b14c25 100644 --- a/lib/class.Groups.php +++ b/lib/class.Groups.php @@ -45,7 +45,7 @@ EOS; private static $list = array(); public function __construct($param = NULL) { - global $gCms; if (!isset($gCms)) exit; + // global $gCms; if (!isset($gCms)) exit; if (!isset(self::$groupFields)) { self::$groupFields = AddressDB::getFields('Grupper'); } @@ -109,14 +109,19 @@ EOS; public static function getGroupList() { if (count(self::$list) > 0) return self::$list; - global $gCms; if (!isset($gCms)) exit; + // global $gCms; if (!isset($gCms)) exit; $c = __CLASS__; $db = AddressDB::getDB(); + // echo '<pre>'; print_r($db); echo '</pre>'; $result = $db->Execute(self::$queryList,array()); + //echo '<pre>'; print_r($result); echo '</pre>'; if ($result === false) { die("Database error!<br>" . $db->ErrorMsg());} while ($row = $result->FetchRow()) { + // echo '<pre>'; print_r($row); echo '</pre>'; self::$list[] = new $c($row); } + //echo '<pre>'; print_r(self::$list); echo '</pre>'; + return self::$list; } diff --git a/lib/class.Person.php b/lib/class.Person.php index fe6f8fd59bb1706f968b8c8fff465724d5ab4a5d..c73a233ea83ad9e57d57ac853c18ceb613bb6915 100644 --- a/lib/class.Person.php +++ b/lib/class.Person.php @@ -33,7 +33,8 @@ EOS; private static $personFields; public function __construct($param = NULL) { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; + // global $gCms; if (!isset($gCms)) exit; if (!isset(self::$personFields)) { self::$personFields = AddressDB::getFields('Adresser'); } @@ -55,7 +56,8 @@ EOS; } private function fromDB($adressID) { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; + // global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $values = array($adressID); $result = $db->Execute(self::$queryOne,$values); @@ -69,7 +71,7 @@ EOS; $row = $result->FetchRow(); $nn = self::$personFields; foreach ($nn as $field) { - if (isset($row[$field])) $this->$field = $row[$field]; + if (isset($row[$field])) $this->$field = $row[$field]; } break; default: @@ -81,7 +83,8 @@ EOS; } private function getGroups($adressID) { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; + //global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $values = array($adressID); $result = $db->Execute(self::$queryGroups,$values); @@ -92,6 +95,7 @@ EOS; } private function createRecord() { + if( !defined('CMS_VERSION') ) exit; $db = AddressDB::getDB(); $query = 'insert into Adresser set Andrad=null'; // $values = array('Förnamn'); @@ -103,7 +107,8 @@ EOS; public function updateRecord() { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; + // global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $query = 'update Adresser set '; $qfields = array(); $values = array(); @@ -127,7 +132,8 @@ EOS; } public static function searchPersons($formValues) { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; + // global $gCms; if (!isset($gCms)) exit; $andQuery = array(); $orQuery = ''; $andValues = array(); $orValues = array(); foreach ($formValues as $key => $value) { @@ -177,7 +183,8 @@ EOS; return $records; } public static function getGroupMembers($groupID) { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; +// global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $class = __CLASS__; $records = array(); @@ -187,7 +194,7 @@ EOS; while ($row = $result->FetchRow()) { $person = new $class(); foreach ($row as $key => $value) { - $person->$key = $value; + $person->$key = $value; } $records[] = $person; } @@ -195,7 +202,8 @@ EOS; } public static function deleteRecord($ID = null) { - global $gCms; if (!isset($gCms)) exit; + if( !defined('CMS_VERSION') ) exit; + // global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); if (is_null($ID)) die('Strange error in deleteRecord. No ID.'.PHP_EOL); $values = array($ID);