diff --git a/action.add_edit_Group.php b/action.add_edit_Group.php index 0821c6b9851695f4e2905745c87b906d8b996e14..eb42f0c4e6851f835c1f29010b0fe5faac275a60 100644 --- a/action.add_edit_Group.php +++ b/action.add_edit_Group.php @@ -2,6 +2,17 @@ if (!isset($gCms)) exit; //echo '<pre>'; print_r($params); echo '</pre>'; +$ID=''; +$paramKeys = array_keys($params); +$print = 'print_'; +foreach ($paramKeys as $key) { + $pos = strpos($key,$print); + if ($pos === false) continue; + $ID = substr($key,strlen($print)); + $this->Redirect($id, 'printGroup', $returnid, array('ID'=>$ID)); + return; +} + if (! $this->CheckPermission('Use ReglerAddress')) { return $this->DisplayErrorPage($id, $params, $returnid, 'ReglerAddress access denied.'); diff --git a/action.printGroup.php b/action.printGroup.php new file mode 100644 index 0000000000000000000000000000000000000000..ac2faa3a0491603c1ca6029d0b7653ad1aabb7a9 --- /dev/null +++ b/action.printGroup.php @@ -0,0 +1,42 @@ +<?php +if (!isset($gCms)) exit; +//echo '<pre>'; print_r($params); echo '</pre>'; + +$ID = $params['ID']; + +$HEAD = <<<EOS +<!doctype html> +<html lang="en" dir="ltr"> +<head> +<meta charset="utf-8" /> +<title>Grupp $ID</title> +<meta http-equiv="Content-Type" content="text/plain"/> +</head> +EOS; + + +$members = Person::getGroupMembers($ID); +$addresses = array(); +foreach ($members as $member) { + $adr = ''; + if (trim($member->Namn)) $adr .= $member->Namn.PHP_EOL; + + if ($member->SkolaForetag) $adr .= $member->SkolaForetag.PHP_EOL; + if ($member->Avdelning) $adr .= $member->Avdelning.PHP_EOL; + if ($member->Adress) $adr .= $member->Adress.PHP_EOL; + $addresses[] = $adr; +} + + + + + +echo $HEAD; +echo '<body>'.PHP_EOL; +echo '<pre>'; +foreach ($addresses as $adr) echo $adr.PHP_EOL; + echo '</pre>'; +echo '</body></html>'; + +exit; +?> diff --git a/lib/class.Group.php b/lib/class.Group.php index 9aec894c0fa8376f4bd17e9ddb4852c525f6e44d..874b04b2ab0f21e8cd09bc8c59594348d8a4a209 100644 --- a/lib/class.Group.php +++ b/lib/class.Group.php @@ -2,9 +2,6 @@ class Group { - private static $maildir = '/home/leif/slask/maildir'; - - private static $queryList = <<<EOS select ID, Gruppnamn, GruppInfo from Grupper order by Gruppnamn EOS; @@ -165,14 +162,6 @@ EOS; if ($result === false) {die("Database error!<br>" . $db->ErrorMsg()); } } - /* public static function getGroup() { */ - /* if (!isset(self::$instance)) { */ - /* $c = __CLASS__; */ - /* self::$instance = new $c; */ - /* } */ - /* return self::$instance->list; */ - /* } */ - public static function setMailLists() { global $gCms; if (!isset($gCms)) exit; $config =& $gCms->GetConfig(); diff --git a/lib/class.Person.php b/lib/class.Person.php index bed50b0b29621e5c2898bc50b8346ceae4d618b5..e72b908112c0953cb233213430a0cb97970cf8c8 100644 --- a/lib/class.Person.php +++ b/lib/class.Person.php @@ -18,6 +18,11 @@ EOT; Grupper.ID=GruppID and AdressID = ? EOT; + private static $queryGroupMembers = <<<EOS + select distinct *, concat(Fornamn, ' ', Efternamn) as Namn + from Adresser,GruppAdress where Adresser.ID=AdressID and GruppID=? +EOS; + public static $firstFields = array( 'ID','fornamn', 'efternamn', 'foretag','avdelning', 'adress', 'Grupp'); @@ -167,5 +172,22 @@ EOT; } return $records; } + public static function getGroupMembers($groupID) { + global $gCms; if (!isset($gCms)) exit; + $db = AddressDB::getDB(); + $class = __CLASS__; + $records = array(); + $values = array($groupID); + $result = $db->Execute(self::$queryGroupMembers,$values); + if (!$result) { die("Database error!<br>" . $db->ErrorMsg()); } + while ($row = $result->FetchRow()) { + $person = new $class(); + foreach ($row as $key => $value) { + $person->$key = $value; + } + $records[] = $person; + } + return $records; + } } ?> \ No newline at end of file