From b711d444653e2494063a4a858d1db9891f178b00 Mon Sep 17 00:00:00 2001 From: Leif Andersson <leif.andersson@control.lth.se> Date: Mon, 16 May 2016 23:10:26 +0200 Subject: [PATCH] =?UTF-8?q?=C3=84ndringar=20f=C3=B6r=20att=20passa=20versi?= =?UTF-8?q?on=202.1.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.defaultadmin.php | 3 ++- lib/class.AddressDB.php | 4 +--- lib/class.Groups.php | 21 ++------------------- lib/class.Person.php | 9 +++------ 4 files changed, 8 insertions(+), 29 deletions(-) diff --git a/action.defaultadmin.php b/action.defaultadmin.php index 7cdf784..1435e47 100644 --- a/action.defaultadmin.php +++ b/action.defaultadmin.php @@ -29,7 +29,7 @@ $canChangeRecord = $this->CheckPermission('Use ReglerAddress'); * After this, the code is identical to the code that would otherwise be * wrapped in the DisplayAdminPanel() method in the module body. */ - + $groups = Groups::getGroupList(); //echo '<pre>'; print_r($groups); echo '</pre>'; exit; @@ -104,6 +104,7 @@ foreach ($params as $key => $value) { } $Persons = array(); if (count($formValues) > 0) $Persons = Person::searchPersons($formValues); +//echo '<pre>'; print_r($formValues); echo '</pre>'; foreach ($Persons as $person) { $params = array('ID' => $person->ID) + $hiddenParameters; $person->link = $this->CreateLink($id, 'add_edit', '', 'Visa', $params); diff --git a/lib/class.AddressDB.php b/lib/class.AddressDB.php index f3940a2..b54920c 100644 --- a/lib/class.AddressDB.php +++ b/lib/class.AddressDB.php @@ -6,9 +6,7 @@ class AddressDB { private static $database = 'NyAdresser'; private function __construct() { - global $gCms; - if (!isset($gCms)) exit; - $config =& $gCms->GetConfig(); + $config = cms_utils::get_config(); $this->PDB = ADONewConnection($config['dbms'], 'pear:date:extend:transaction'); $result = $this->PDB->Connect($config['db_hostname'], diff --git a/lib/class.Groups.php b/lib/class.Groups.php index f3c191b..f7ac55f 100644 --- a/lib/class.Groups.php +++ b/lib/class.Groups.php @@ -45,8 +45,7 @@ EOS; private static $list = array(); public function __construct($param = NULL) { - global $gCms; if (!isset($gCms)) exit; - if (!isset(self::$groupFields)) { + if (!isset(self::$groupFields)) { self::$groupFields = AddressDB::getFields('Grupper'); } foreach (self::$groupFields as $field) {$this->$field = '';} @@ -88,7 +87,6 @@ EOS; } public function updateRecord() { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); if ($this->ID == '') { $this->createRecord(); } @@ -109,7 +107,6 @@ EOS; public static function getGroupList() { if (count(self::$list) > 0) return self::$list; - global $gCms; if (!isset($gCms)) exit; $c = __CLASS__; $db = AddressDB::getDB(); $result = $db->Execute(self::$queryList,array()); @@ -120,17 +117,7 @@ EOS; return self::$list; } - /* global $gCms; */ - /* if (!isset($gCms)) exit; */ - /* $ADB = AddressDB::getDB(); */ - /* $result = $ADB->Execute(self::$queryList,array()); */ - /* while ($row = $result->FetchRow()) { */ - /* $this->list[$row['Gruppnamn']] = $row['ID']; */ - /* } */ - /* } */ - public static function getMembers($GruppID) { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $result = $db->Execute(self::$queryMembership,array($GruppID)); if ($result === false) { die("Database error!<br>" . $db->ErrorMsg()); } @@ -153,7 +140,6 @@ EOS; } public static function setMember($ID,$GroupID) { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $values = array($ID, $GroupID); $result = $db->Execute(self::$querySetGroup,$values); @@ -161,7 +147,6 @@ EOS; } public static function unsetMember($ID,$GroupID) { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $values = array($ID, $GroupID); // echo '<pre>'; print_r($queryUnsetGroup); print_r($values); echo '</pre>';exit; @@ -171,8 +156,7 @@ EOS; } public static function setMailLists() { - global $gCms; if (!isset($gCms)) exit; - $config =& $gCms->GetConfig(); + $config = cms_utils::get_config(); $maildir = $config['root_path'] . '/uploads/mailinglists'; $db = AddressDB::getDB(); $groups = self::getGroupList(); @@ -200,7 +184,6 @@ EOS; // exit; } public static function removeAddress($AdressID = null) { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); if (is_null($AdressID)) die('Strange error in removeAddress. No ID.'.PHP_EOL); diff --git a/lib/class.Person.php b/lib/class.Person.php index fe6f8fd..989e4a1 100644 --- a/lib/class.Person.php +++ b/lib/class.Person.php @@ -33,7 +33,6 @@ EOS; private static $personFields; public function __construct($param = NULL) { - global $gCms; if (!isset($gCms)) exit; if (!isset(self::$personFields)) { self::$personFields = AddressDB::getFields('Adresser'); } @@ -55,7 +54,6 @@ EOS; } private function fromDB($adressID) { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $values = array($adressID); $result = $db->Execute(self::$queryOne,$values); @@ -81,7 +79,6 @@ EOS; } private function getGroups($adressID) { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $values = array($adressID); $result = $db->Execute(self::$queryGroups,$values); @@ -103,7 +100,6 @@ EOS; public function updateRecord() { - global $gCms; if (!isset($gCms)) exit; $db = AddressDB::getDB(); $query = 'update Adresser set '; $qfields = array(); $values = array(); @@ -127,7 +123,6 @@ EOS; } public static function searchPersons($formValues) { - global $gCms; if (!isset($gCms)) exit; $andQuery = array(); $orQuery = ''; $andValues = array(); $orValues = array(); foreach ($formValues as $key => $value) { @@ -166,13 +161,16 @@ EOS; $class = __CLASS__; $records = array(); $result = $db->Execute($query,$values); + if (!$result) { die("Database error!<br>" . $db->ErrorMsg()); } while ($row = $result->FetchRow()) { $person = new $class(); + //echo '<pre>'; print_r($person); echo '</pre>'; foreach ($row as $key => $value) { $person->$key = $value; } $records[] = $person; + //echo '<pre>'; print_r($records); echo '</pre>'; } return $records; } @@ -195,7 +193,6 @@ EOS; } public static function deleteRecord($ID = null) { - 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); -- GitLab