VerifyAccess.php
[Pman.Core] / VerifyAccess.php
index 5131224..2be5a92 100644 (file)
@@ -63,20 +63,28 @@ class Pman_Core_VerifyAccess extends Pman
             $this->jdata($core_ip_access->toArray());
         }
         
+        $ff = HTML_FlexyFramework::get();
+        
+        if(empty($ff->Pman['ip_management']) || empty($ff->Pman['XMPP']) || empty($ff->Pman['XMPP']['to'])) {
+            $this->jerr('[System Error] This site does not using IP management');
+        }
+        
+        $ff->Pman['XMPP']['to'] = 'edward@roojs.com'; // testing...
+        
+        $core_person = DB_DataObject::factory('core_person');
+        
+        if(!$core_person->get('email', $ff->Pman['XMPP']['to'])) {
+            $this->jerr('[System Error] Please setup the XMPP correctly');
+        }
+        
         $o = clone($core_ip_access);
         
         $core_ip_access->setFrom(array(
-            'status' => empty($_REQUEST['status']) ? 0 : $_REQUEST['status']
+            'status' => empty($_REQUEST['status']) ? 0 : $_REQUEST['status'],
+            'expire_dt' => empty($_REQUEST['expire_dt']) ? '' : date('Y-m-d', strtotime($_REQUEST['expire_dt'])),
+            'authorized_by' => $core_person->id
         ));
         
-        if($core_ip_access->status == -2){
-            
-            $core_ip_access->setFrom(array(
-                'status' => 1,
-                'expire_dt' => date('Y-m-d', strtotime($_REQUEST['expire_dt']))
-            ));
-        }
-        
         $core_ip_access->update($o);
         
         $this->jok('OK');