DataObjects/core.sql
[Pman.Core] / DataObjects / Person.php
index 6c3a712..faf18b6 100644 (file)
@@ -306,13 +306,15 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
              
         }
         
+        
+        
         $u = DB_DataObject::factory('Person');
         $u->whereAdd(' LENGTH(passwd) > 0');
         if (!$u->count()){
             
             // fake person - open system..
-            $ce = DB_DataObject::factory('core_enum');
-            $ce->initEnums();
+            //$ce = DB_DataObject::factory('core_enum');
+            //$ce->initEnums();
             
             
             $u = DB_DataObject::factory('Person');
@@ -382,6 +384,15 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
        
     }      
     
+    function generatePassword() // genearte a password (add set 'rawPasswd' to it's value)
+    {
+        require_once 'Text/Password.php';
+        $this->rawPasswd = strtr(ucfirst(Text_Password::create(5)).ucfirst(Text_Password::create(5)), array(
+        "a"=>"4", "e"=>"3",  "i"=>"1",  "o"=>"0", "s"=>"5",  "t"=>"7"));
+        $this->setPassword($this->rawPasswd);
+        return $this->rawPasswd;
+    }
+    
     function company()
     {
         $x = DB_DataObject::factory('Companies');
@@ -810,12 +821,13 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     function onInsert($req, $roo)  
     {
          
-        
+        $p = DB_DataObject::factory('person');
         if ($roo->authUser->id < 0 && $p->count() == 1) {
             // this seems a bit risky...
             
             $g = DB_DataObject::factory('Groups');
             $g->initGroups();
+            
             $g->type = 0;
             $g->get('name', 'Administrators');