Code

Updated registration template
[gosa.git] / gosa-core / plugins / generic / dashBoard / Register / class_RegisterGOsa.inc
1 <?php
5 /* Missing functions, validate registration
6  *
7  */
9 class GOsaRegistration extends plugin
10 {
11     protected $defaultRegistrationType = "registered";
12     protected $isRegistered = FALSE; 
13     protected $step = 0;
15     public $attrs = array('mailAddress','surname','givenName', 'company', 'clients', 'knownFrom');
16     protected $values = array();
18     function __construct(&$config)
19     {
20         $this->config = $config;    
21         $this->isRegistered = GOsaRegistration::isRegistered($this->config);
23         foreach($this->attrs as $attr) $this->values[$attr] = "";
24     }
27    
28     function execute()
29     {
30         $smarty = get_smarty();
31         $smarty->assign("default", $this->defaultRegistrationType);
32         $smarty->assign("step", $this->step);
36         foreach($this->attrs as $attr) $smarty->assign($attr, $this->values[$attr]);
39         return($smarty->fetch(get_template_path("Register/register.tpl", TRUE))); 
40     } 
43     function save_object()
44     {
45         if(isset($_POST['registrationType']))  $this->defaultRegistrationType = get_post('registrationType');
46         if(isset($_POST['startRegistration'])) $this->step = 1;
48         if(isset($_POST['stepBack'])) $this->step -= 1;
49     }
50     
53     static function registerGOsa($config, $uuid, $type, $userData = array())
54     {
55         echo "<br>Register GOsa.";
56         print_a(func_get_args());
57     }
60     static function getRegistrationType($config)
61     {
62         return($config->configRegistry->getPropertyValue('GOsaRegistration','registerStatus'));
63     }    
66     static function isRegistered($config, $uuid = NULL)
67     {
68         $status = $config->configRegistry->getPropertyValue('GOsaRegistration','registerStatus');
69         if(!$uuid){
70             $uuid = $config->configRegistry->getPropertyValue('GOsaRegistration','registeredUUID');
71         }       
73         // Not yet registered 
74         if(!$status) return(FALSE);
75         
76         // Registered, but backend status not confirmed.
77         echo "<br>Validate registration";
78     }
81     public static function getRegisterStatusValues()
82     {
83         $ret= array();
84         $ret[''] = _("not registered");
85         $ret['anonymous'] = _("anonym");
86         $ret['registered'] = _("registered");
87         return($ret);
88     }
90    
91     public static function checkRegisteredUUID($message,$class,$name,$value, $type)
92     {
93         // Add check here later 
94         $valid = TRUE;
96         // Display the reason for failing this check.
97         if($message && !$valid){
98             msg_dialog::display(_("Warning"),
99                     sprintf(_("The given registration UUID '%s' specified for '%s:%s' is invalid!"),
100                         bold($value),bold($class),bold($name)),
101                     WARNING_DIALOG);
102         }
104         return($valid);
105     }
107  
108     static function plInfo()
109     {
110         return (array(
111                     "plProperties"  => array(
112                         array(
113                             "name"          => "registerStatus",
114                             "type"          => "switch",
115                             "default"       => "",
116                             "defaults"      => "GOsaRegistration::getRegisterStatusValues",
117                             "description"   => _("The GOsa registration status."),
118                             "check"         => "",
119                             "migrate"       => "",
120                             "group"         => "registerGOsa",
121                             "mandatory"     => FALSE),
122                         array(
123                             "name"          => "registeredUUID",
124                             "type"          => "string",
125                             "default"       => "",
126                             "description"   => _("The UUID of the current GOsa installation. This UUID is used to identify the installation, once you've registered GOsa."),
127                             "check"         => "GOsaRegistration::checkRegisteredUUID",
128                             "migrate"       => "",
129                             "group"         => "registerGOsa",
130                             "mandatory"     => FALSE)
131                         )));
132     }
134 ?>