function owner()
{
- $p = DB_DataObject::Factory($this->tableName());
+ // this might be a Person in some old code?
+ $p = DB_DataObject::Factory('core_person');
$p->get($this->owner_id);
return $p;
}
// ---------------- authentication / passwords and keys stuff ----------------
function isAuth()
{
- @session_start();
+ // do not start a session if we are using http auth...
+ if (empty($_SERVER['PHP_AUTH_USER'])) {
+ @session_start();
+ }
$ff= HTML_FlexyFramework::get();
function company()
{
+ if (empty($this->company_id)) {
+ return false;
+ }
$x = DB_DataObject::factory('core_company');
$x->autoJoin();
$x->get($this->company_id);
'person_id' => $this->id
));
- foreach ($core_person_settings->fetchAll() as $k => $v) {
- $aur['core_person_settings'][$v->scope] = $v->toArray();
- }
+ $aur['core_person_settings'] = $core_person_settings->fetchAll('scope', 'data');
return $aur;
}
LENGTH({$this->tableName()}.oath_key) AS length_oath_key
");
}
+ if (isset($q['_with_group_membership'])) {
+ $this->selectAddGroupMemberships();
+ }
-
+ }
+
+ function selectAddGroupMemberships()
+ {
+ $this->selectAdd("
+
+ COALESCE((
+ SELECT
+ GROUP_CONCAT( core_group.name separator '\n')
+ FROM
+ core_group_member
+ LEFT JOIN
+ core_group
+ ON
+ core_group.id = core_group_member.group_id
+ WHERE
+ core_group_member.user_id = core_person.id
+ ), '') as member_of");
}
function setFromRoo($ar, $roo)
{
- $this->setFrom($ar);
+ $this->setFrom($ar);
if(!empty($ar['_enable_oath_key'])){
$oath_key = $this->generateOathKey();
}
// this only applies to our owner company..
$c = $this->company();
- if (empty($c->comptype_name) || $c->comptype_name != 'OWNER') {
+ if (empty($c) || empty($c->comptype_name) || $c->comptype_name != 'OWNER') {
return true;
}