Pman.php
[Pman.Core] / Pman.php
1 <?php
2
3 /*
4  * this is loaded by the pman admin..
5  *
6  * it checks that required variables are set...
7  *
8  */
9 class Pman_Core_Pman {
10     
11     
12     function init ($pg)
13     {
14         if(!empty($_REQUEST['_core_skip_check'])){
15             return;
16         }
17         
18         $group = DB_DataObject::factory('groups');
19         
20         // group should be auto created - by update-database...
21         
22         if(!$group->get('name', 'core-person-signup-bcc')){
23             die("group core-person-signup-bcc does not exist : add ?_core_skip_check=1 to bypass this check");
24         }
25         
26         $p = DB_DataObject::factory('Person');
27         
28         
29         $member = DB_DataObject::factory('group_members');
30         $member->group_id = $group->id;
31         if ($member->count()) {
32             return;
33         }
34         
35         // not got members..
36         
37         // if we only have one member - then add it .... (it's the admin, and they can modify this later.. - after they get annoyed with it..
38         if ($p->count() == 1) {
39             $p->find(true);
40             $member = DB_DataObject::factory('group_members');
41             $member->group_id = $group->id;
42             $member->person_id = $p->id;
43             $member->insert();
44             return;
45         }
46         
47         // only display if we have members..
48         die("group core-person-signup-bcc does not have any members : add ?_core_skip_check=1 to bypass this check");
49     
50         
51         
52     }
53     
54     
55     
56 }