Code

Updated registriation process.
[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     function registerNow()
28     {
29         $this->step = 200; // Awaiting verification
30     }
32    
33     function execute()
34     {
35         // Registration request.
36         if(isset($_POST['registerNow'])){
37             $msgs = $this->check();
38             if(count($msgs)){
39                 msg_dialog::displayChecks($msgs); 
40             }else{
41                 $this->registerNow();
42             }
43         }
46         $smarty = get_smarty();
47         $smarty->assign("default", $this->defaultRegistrationType);
48         $smarty->assign("step", $this->step);
50         foreach($this->attrs as $attr) $smarty->assign($attr, set_post($this->values[$attr]));
53         return($smarty->fetch(get_template_path("Register/register.tpl", TRUE))); 
54     } 
57     function save_object()
58     {
59         if(isset($_POST['registrationType']))  $this->defaultRegistrationType = get_post('registrationType');
60         if(isset($_POST['startRegistration'])) $this->step = 1;
61         if(isset($_POST['stepBack'])) $this->step -= 1;
63         foreach($this->attrs as $attr){
64             if(isset($_POST[$attr])) $this->values[$attr] = get_post($attr);
65         }
66     }
67     
70     static function registerGOsa($config, $uuid, $type, $userData = array())
71     {
72         echo "<br>Register GOsa.";
73         print_a(func_get_args());
74     }
77     static function getRegistrationType($config)
78     {
79         return($config->configRegistry->getPropertyValue('GOsaRegistration','registerStatus'));
80     }    
83     static function isRegistered($config, $uuid = NULL)
84     {
85         $status = $config->configRegistry->getPropertyValue('GOsaRegistration','registerStatus');
86         if(!$uuid){
87             $uuid = $config->configRegistry->getPropertyValue('GOsaRegistration','registeredUUID');
88         }       
90         // Not yet registered 
91         if(!$status) return(FALSE);
92         
93         // Registered, but backend status not confirmed.
94         echo "<br>Validate registration";
95     }
98     public static function getRegisterStatusValues()
99     {
100         $ret= array();
101         $ret[''] = _("not registered");
102         $ret['anonymous'] = _("anonym");
103         $ret['registered'] = _("registered");
104         return($ret);
105     }
107    
108     public static function checkRegisteredUUID($message,$class,$name,$value, $type)
109     {
110         // Add check here later 
111         $valid = TRUE;
113         // Display the reason for failing this check.
114         if($message && !$valid){
115             msg_dialog::display(_("Warning"),
116                     sprintf(_("The given registration UUID '%s' specified for '%s:%s' is invalid!"),
117                         bold($value),bold($class),bold($name)),
118                     WARNING_DIALOG);
119         }
121         return($valid);
122     }
124  
125     static function plInfo()
126     {
127         return (array(
128                     "plProperties"  => array(
129                         array(
130                             "name"          => "registerStatus",
131                             "type"          => "switch",
132                             "default"       => "",
133                             "defaults"      => "GOsaRegistration::getRegisterStatusValues",
134                             "description"   => _("The GOsa registration status."),
135                             "check"         => "",
136                             "migrate"       => "",
137                             "group"         => "registerGOsa",
138                             "mandatory"     => FALSE),
139                         array(
140                             "name"          => "registeredUUID",
141                             "type"          => "string",
142                             "default"       => "",
143                             "description"   => _("The UUID of the current GOsa installation. This UUID is used to identify the installation, once you've registered GOsa."),
144                             "check"         => "GOsaRegistration::checkRegisteredUUID",
145                             "migrate"       => "",
146                             "group"         => "registerGOsa",
147                             "mandatory"     => FALSE)
148                         )));
149     }
151 ?>