Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Leif Andersson
ReglerAddress
Commits
f7d48966
Commit
f7d48966
authored
Sep 14, 2015
by
Leif Andersson
Browse files
A
parent
2d49438f
Changes
3
Hide whitespace changes
Inline
Side-by-side
action.defaultadmin.php
View file @
f7d48966
...
...
@@ -30,8 +30,8 @@ if (! $this->CheckPermission('Use ReglerAddress')) {
* wrapped in the DisplayAdminPanel() method in the module body.
*/
$groups
=
Group
::
getGroup
();
//echo '<pre>'; print_r($groups); echo '</pre>';
$groups
=
Group
::
getGroup
List
();
//echo '<pre>'; print_r($groups); echo '</pre>';
exit;
//file_put_contents("/tmp/defaultadmin.txt",print_r($params,TRUE));
$addrDB
=
AddressDB
::
getDB
();
...
...
@@ -72,7 +72,10 @@ $smarty->assign('newButton',$place);
$name
=
'Grupp'
;
$groupNames
=
array
(
' '
=>
'None'
)
+
$groups
;
$groupNames
=
array
(
' '
=>
'None'
);
foreach
(
$groups
as
$group
)
{
$groupNames
[
$group
->
Gruppnamn
]
=
$group
->
ID
;
}
$selected
=
array
();
if
(
isset
(
$params
[
$name
]))
$selected
[]
=
$params
[
$name
];
$place
=
$this
->
CreateInputSelectList
(
$id
,
$name
,
$groupNames
,
...
...
action.editGroups.php
0 → 100644
View file @
f7d48966
<?php
if
(
!
isset
(
$gCms
))
exit
;
//echo '<pre>'; print_r($params); echo '</pre>';
if
(
!
$this
->
CheckPermission
(
'Use ReglerAddress'
))
{
return
$this
->
DisplayErrorPage
(
$id
,
$params
,
$returnid
,
'ReglerAddress access denied.'
);
}
require_once
'lib/class.Group.php'
;
?>
lib/class.Group.php
View file @
f7d48966
...
...
@@ -2,11 +2,11 @@
class
Group
{
private
static
$maildir
=
'/
tmp
/maildir'
;
private
static
$maildir
=
'/
home/leif/slask
/maildir'
;
private
static
$queryList
=
<<<EOS
select ID, Gruppnamn from Grupper order by Gruppnamn
select ID, Gruppnamn
, GruppInfo
from Grupper order by Gruppnamn
EOS;
private
static
$queryMembership
=
<<<EOS
...
...
@@ -27,19 +27,44 @@ EOS;
Adresser.ID = AdressID and GruppID = ?
EOS;
private
static
$groupFields
=
array
(
'ID'
,
'Gruppnamn'
,
'GruppInfo'
);
private
static
$instance
;
private
$list
;
private
static
$list
=
array
();
private
function
__construct
(
$param
=
NULL
)
{
foreach
(
self
::
$groupFields
as
$field
)
{
$this
->
$field
=
''
;}
if
(
is_null
(
$param
))
return
;
if
(
is_array
(
$param
))
{
foreach
(
self
::
$groupFields
as
$field
)
{
$this
->
$field
=
$param
[
$field
];
}
}
}
private
function
__construct
()
{
global
$gCms
;
if
(
!
isset
(
$gCms
))
exit
;
$ADB
=
AddressDB
::
getDB
();
$result
=
$ADB
->
Execute
(
self
::
$queryList
,
array
());
public
static
function
getGroupList
()
{
if
(
count
(
self
::
$list
)
>
0
)
return
$list
;
global
$gCms
;
if
(
!
isset
(
$gCms
))
exit
;
$c
=
__CLASS__
;
$db
=
AddressDB
::
getDB
();
$result
=
$db
->
Execute
(
self
::
$queryList
,
array
());
if
(
$result
===
false
)
{
die
(
"Database error!<br>"
.
$db
->
ErrorMsg
());}
while
(
$row
=
$result
->
FetchRow
())
{
$this
->
list
[
$row
[
'Gruppnamn'
]]
=
$row
[
'ID'
]
;
self
::
$list
[]
=
new
$c
(
$row
)
;
}
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
;
...
...
@@ -55,7 +80,12 @@ EOS;
public
static
function
getNonMembers
(
$GruppID
)
{
$members
=
self
::
getMembers
(
$GruppID
);
$nonmembers
=
array_diff_assoc
(
self
::
getGroup
(),
$members
);
$allgroups
=
array
();
self
::
getGroupList
();
foreach
(
self
::
$list
as
$group
)
{
$allgroups
[
$group
->
Gruppnamn
]
=
$group
->
ID
;
}
$nonmembers
=
array_diff_assoc
(
$allgroups
,
$members
);
return
$nonmembers
;
}
...
...
@@ -77,24 +107,24 @@ 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 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
;
$db
=
AddressDB
::
getDB
();
$groups
=
self
::
getGroup
();
$groups
=
self
::
getGroup
List
();
if
(
!
is_dir
(
self
::
$maildir
))
mkdir
(
self
::
$maildir
,
'0755'
,
true
);
foreach
(
$groups
as
$
name
=>
$ID
)
{
$pos
=
strrpos
(
$nam
e
,
'.dis'
);
foreach
(
$groups
as
$
group
)
{
$pos
=
strrpos
(
$
group
->
Grupp
nam
n
,
'.dis'
);
if
(
$pos
===
false
)
continue
;
$epost
=
array
();
$values
=
array
(
$ID
);
$values
=
array
(
$
group
->
ID
);
$result
=
$db
->
Execute
(
self
::
$queryMail
,
$values
);
if
(
$result
===
false
)
{
die
(
"Database error!<br>"
.
$db
->
ErrorMsg
());
}
while
(
$row
=
$result
->
FetchRow
())
{
...
...
@@ -103,7 +133,7 @@ EOS;
}
if
(
count
(
$epost
)
>
0
)
{
// echo '<pre>'; print_r($epost); echo '</pre>';
$filename
=
self
::
$maildir
.
'/'
.
$nam
e
;
$filename
=
self
::
$maildir
.
'/'
.
$
group
->
Grupp
nam
n
;
$file
=
fopen
(
$filename
,
'w'
);
if
(
$file
===
false
)
die
(
'Cannot write '
.
$filename
);
foreach
(
$epost
as
$line
)
fwrite
(
$file
,
$line
.
PHP_EOL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment