public $company_id; // int(11)
public $office_id; // int(11)
- public $honor; // VARCHAR(256) NULL;
public $name; // string(128) not_null
public $firstname; // string(128) not_null
public $lastname; // string(128) not_null
@session_start();
+
if (!empty($_SESSION[__CLASS__][$sesPrefix .'-auth'])) {
// in session...
$a = unserialize($_SESSION[__CLASS__][$sesPrefix .'-auth']);
$db = $this->getDatabaseConnection();
$sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
+
+
if (!empty($_SESSION[__CLASS__][$sesPrefix .'-auth'])) {
$a = unserialize($_SESSION[__CLASS__][$sesPrefix .'-auth']);
}
}
+
+ function importFromArray($roo, $persons, $prefix)
+ {
+ foreach($persons as $person){
+ $p = DB_DataObject::factory('person');
+ if($p->get('name', $person['name'])){
+ continue;
+ }
+ $p->setFrom($person);
+
+ $companies = DB_DataObject::factory('companies');
+ if(!$companies->get('comptype', 'OWNER')){
+ $roo->jerr("Missing OWNER companies!");
+ }
+ $p->company_id = $companies->pid();
+ // strip the 'spaces etc.. make lowercase..
+ $name = strtolower(str_replace(' ', '', $person['name']));
+ $p->setPassword("$prefix$name");
+ $p->insert();
+ // set up groups
+ // if $person->groups is set.. then
+ // add this person to that group eg. groups : [ 'Administrator' ]
+ if(!empty($person['groups'])){
+ $groups = DB_DataObject::factory('groups');
+ if(!$groups->get('name', $person['groups'])){
+ $roo->jerr("Missing groups : {$person['groups']}");
+ }
+ $gm = DB_DataObject::factory('group_members');
+ $gm->change($p, $groups, true);
+ }
+
+ $p->onInsert(array(), $roo);
+ }
+ }
}