/**
* Table Definition for Person
*/
-require_once 'DB/DataObject.php';
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
class Pman_Core_DataObjects_Core_person extends DB_DataObject
$decoder = new Mail_mimeDecode($mailtext);
$parts = $decoder->getSendArray();
- if (PEAR::isError($parts)) {
+ if (is_a($parts,'PEAR_Error')) {
return $parts;
//echo "PROBLEM: {$parts->message}";
//exit;
if (!empty($_SESSION[get_class($this)][$sesPrefix .'-auth'])) {
// in session...
$a = unserialize($_SESSION[get_class($this)][$sesPrefix .'-auth']);
-
-
+
$u = DB_DataObject::factory($this->tableName());
if ($a->id && $u->get($a->id)) { //&& strlen($u->passwd)) {
$_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize($u);
return true;
}
-
+ //die("test init");
if (!$this->canInitializeSystem()) {
+ // die("can not init");
return false;
}
if (!empty($ff->Pman['local_autoauth']) &&
($ff->Pman['local_autoauth'] === true) &&
(!empty($_SERVER['SERVER_ADDR'])) &&
- ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
- ($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
+ (
+ (
+ $_SERVER['SERVER_ADDR'] == '127.0.0.1' &&
+ $_SERVER['REMOTE_ADDR'] == '127.0.0.1'
+ )
+ ||
+ (
+ $_SERVER['SERVER_ADDR'] == '::1' &&
+ $_SERVER['REMOTE_ADDR'] == '::1'
+ )
+ )
) {
$group = DB_DataObject::factory('core_group');
$group->get('name', 'Administrators');
if (!empty($ff->Pman['local_autoauth']) &&
(!empty($_SERVER['SERVER_ADDR'])) &&
- ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
- ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') &&
+ (
+ (
+ $_SERVER['SERVER_ADDR'] == '127.0.0.1' &&
+ $_SERVER['REMOTE_ADDR'] == '127.0.0.1'
+ )
+ ||
+ (
+ $_SERVER['SERVER_ADDR'] == '::1' &&
+ $_SERVER['REMOTE_ADDR'] == '::1'
+ )
+ ) &&
($default_admin || $u->get('email', $ff->Pman['local_autoauth']))
) {
$_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize($default_admin ? $default_admin : $u);
$u->whereAdd(' LENGTH(passwd) > 0');
$n = $u->count();
$_SESSION[get_class($this)][$sesPrefix .'-empty'] = $n;
- $error = PEAR::getStaticProperty('DB_DataObject','lastError');
- if ($error) {
- die($error->toString()); // not really a good thing to do...
+ if (class_exists('PEAR')) {
+ $error = PEAR::getStaticProperty('DB_DataObject','lastError');
+ if ($error) {
+ die($error->toString()); // not really a good thing to do...
+ }
}
if (!$n){ // authenticated as there are no users in the system...
return true;
function canInitializeSystem()
{
+
return !strcasecmp(get_class($this) , __CLASS__);
}
}
// open up iptables at login..
- $dbname = $this->database();
+ $dbname = $this->databaseNickname();
touch( '/tmp/run_pman_admin_iptables-'.$dbname);
// refresh admin group if we are logged in as one..
function checkPassword($val)
{
+
if (substr($this->passwd,0,1) == '$') {
-
+ if (function_exists('pasword_verify')) {
+ return password_verify($val, $this->passwd);
+ }
return crypt($val,$this->passwd) == $this->passwd ;
}
// old style md5 passwords...- cant be used with courier....
function setPassword($value)
{
+ if (function_exists('pasword_hash')) {
+ return password_hash($value);
+ }
+
$salt='';
while(strlen($salt)<9) {
$salt.=chr(rand(64,126));
// perms + groups.
$aur['perms'] = $this->getPerms();
- $g = DB_DataObject::Factory('group_members');
+ $g = DB_DataObject::Factory('core_group_member');
$aur['groups'] = $g->listGroupMembership($this, 'name');
$aur['passwd'] = '';
// ------ INIITIALIZE IF NO GROUPS ARE SET UP.
- $g = DB_DataObject::Factory('group_rights');
+ $g = DB_DataObject::Factory('core_group_right');
if (!$g->count()) {
$g->genDefault();
}
return $g->adminRights(); // system is not set up - so they get full rights.
}
//DB_DataObject::debugLevel(1);
- $g = DB_DataObject::Factory('group_members');
+ $g = DB_DataObject::Factory('core_group_member');
$g->whereAdd('group_id is NOT NULL AND user_id IS NOT NULL');
if (!$g->count()) {
// add the current user to the admin group..
- $g = DB_DataObject::Factory('Groups');
+ $g = DB_DataObject::Factory('core_group');
if ($g->get('name', 'Administrators')) {
- $gm = DB_DataObject::Factory('group_members');
+ $gm = DB_DataObject::Factory('core_group_member');
$gm->group_id = $g->id;
$gm->user_id = $this->id;
$gm->insert();
// ------ STANDARD PERMISSION HANDLING.
$isOwner = $this->company()->comptype == 'OWNER';
- $g = DB_DataObject::Factory('group_members');
+ $g = DB_DataObject::Factory('core_group_member');
$grps = $g->listGroupMembership($this);
//var_dump($grps);
- $isAdmin = $g->inAdmin;
+ $isAdmin = $g->inAdmin; //??? what???
//echo '<PRE>'; print_r($grps);var_dump($isAdmin);
// the load all the perms for those groups, and add them all together..
// then load all those
- $g = DB_DataObject::Factory('group_rights');
+ $g = DB_DataObject::Factory('core_group_right');
$ret = $g->listPermsFromGroupIds($grps, $isAdmin, $isOwner);
//echo '<PRE>';print_r($ret);
return $ret;
function groups($what=false)
{
- $g = DB_DataObject::Factory('group_members');
+ $g = DB_DataObject::Factory('core_group_member');
$grps = $g->listGroupMembership($this);
- $g = DB_DataObject::Factory('Groups');
+ $g = DB_DataObject::Factory('core_group');
$g->whereAddIn('id', $grps, 'int');
return $g->fetchAll($what);
$this->active = 1;
}
$tn_p = $this->tableName();
- $tn_gm = DB_DataObject::Factory('group_members')->tableName();
- $tn_g = DB_DataObject::Factory('Groups')->tableName();
+ $tn_gm = DB_DataObject::Factory('core_group_member')->tableName();
+ $tn_g = DB_DataObject::Factory('core_group')->tableName();
///---------------- Group views --------
if (!empty($q['query']['in_group'])) {
}
+ if(!empty($q['in_group_name'])){
+
+ $v = $this->escape($q['in_group_name']);
+
+ $this->whereAdd("
+ $tn_p.id IN (
+ SELECT
+ DISTINCT(user_id) FROM $tn_gm
+ LEFT JOIN
+ $tn_g
+ ON
+ $tn_g.id = $tn_gm.group_id
+ WHERE
+ $tn_g.name = '{$v}'
+ )"
+ );
+ }
+
// #2307 Search Country!!
if (!empty($q['query']['in_country'])) {
// DB_DataObject::debugLevel(1);
}
function setFromRoo($ar, $roo)
{
- $this->setFrom($ar);
+ $this->setFrom($ar);
if (!empty($ar['passwd1'])) {
$this->setPassword($ar['passwd1']);
}
-
if ( $this->id &&
($this->email == $roo->old->email)&&
($this->company_id == $roo->old->company_id)
if (empty($this->email)) {
return true;
}
+ // this only applies to our owner company..
+ $c = $this->company();
+ if (empty($c->comptype_name) || $c->comptype_name != 'OWNER') {
+ return true;
+ }
+
+
$xx = DB_Dataobject::factory($this->tableName());
$xx->setFrom(array(
'email' => $this->email,
* this is called after checkPerm..
*/
- function beforeDelete()
+ function beforeDelete($dependants_array, $roo)
{
$e = DB_DataObject::Factory('Events');
function beforeInsert($req, $roo)
{
- $p = DB_DataObject::factory('person');
+ $p = DB_DataObject::factory('core_person');
if ($roo->authUser->id > -1 || $p->count() > 1) {
return;
}
function onInsert($req, $roo)
{
- $p = DB_DataObject::factory('person');
+ $p = DB_DataObject::factory('core_person');
if ($roo->authUser->id < 0 && $p->count() == 1) {
// this seems a bit risky...
- $g = DB_DataObject::factory('Groups');
+ $g = DB_DataObject::factory('core_group');
$g->initGroups();
$g->type = 0;
$g->get('name', 'Administrators');
- $p = DB_DataObject::factory('group_members');
+ $p = DB_DataObject::factory('core_group_member');
$p->group_id = $g->id;
$p->user_id = $this->id;
if (!$p->count()) {
if (!is_array($persons) || empty($persons)) {
$roo->jerr("error in the person data. - empty on not valid");
}
- DB_DataObject::factory('groups')->initGroups();
+ DB_DataObject::factory('core_group')->initGroups();
foreach($persons as $person){
- $p = DB_DataObject::factory('person');
+ $p = DB_DataObject::factory('core_person');
if($p->get('name', $person['name'])){
continue;
}
$p->setFrom($person);
- $companies = DB_DataObject::factory('companies');
+ $companies = DB_DataObject::factory('core_company');
if(!$companies->get('comptype', 'OWNER')){
$roo->jerr("Missing OWNER companies!");
}
// if $person->groups is set.. then
// add this person to that group eg. groups : [ 'Administrator' ]
if(!empty($person['groups'])){
- $groups = DB_DataObject::factory('groups');
+ $groups = DB_DataObject::factory('core_group');
if(!$groups->get('name', $person['groups'])){
$roo->jerr("Missing groups : {$person['groups']}");
}
- $gm = DB_DataObject::factory('group_members');
+ $gm = DB_DataObject::factory('core_group_member');
$gm->change($p, $groups, true);
}
$appname = empty($ff->appNameShort) ? $ff->project : $ff->project . '-' . $ff->appNameShort;
- $db = $this->getDatabaseConnection();
+ $dname = method_exists($this, 'getDatabaseConnection') ? $this->getDatabaseConnection()->dsn['database'] : $this->databaseNickname();
- $sesPrefix = $appname.'-' .get_class($this) .'-'.$db->dsn['database'] ;
+ $sesPrefix = $appname.'-' .get_class($this) .'-' . $dname;
return $sesPrefix;
}
+ function loginPublic()
+ {
+ $this->isAuth(); // force session start..
+
+ $db = $this->getDatabaseConnection();
+
+ $ff = HTML_FlexyFramework::get();
+
+ if(empty($ff->Pman) || empty($ff->Pman['login_public'])){
+ return false;
+ }
+
+ $sesPrefix = $ff->Pman['login_public'] . '-' .get_class($this) .'-'.$db->dsn['database'] ;
+
+ $p = DB_DAtaObject::Factory($this->tableName());
+ $p->get($this->pid());
+
+ $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize((object)$p->toArray());
+
+ return true;
+ }
+
}