/**
* 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));
}
+ 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);
$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');
$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;
}
}