$headers['Date'] = date('r');
return array(
- 'recipents' => $recipents,
+ 'recipients' => $recipents,
'headers' => $headers,
'body' => $body
);
{
$ar = $this->buildMail($templateFile, $args);
-
+
+
//print_r($recipents);exit;
$mailOptions = PEAR::getStaticProperty('Mail','options');
$mail = Mail::factory("SMTP",$mailOptions);
if (PEAR::isError($mail)) {
return $mail;
}
- $oe = error_reporting(E_ALL ^ E_NOTICE);
- $ret = $mail->send($ar['recipents'],$ar['headers'],$ar['body']);
+ $oe = error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
+ $ret = $mail->send($ar['recipients'],$ar['headers'],$ar['body']);
error_reporting($oe);
return $ret;
}
+
+
+
+
function getEmailFrom()
{
return '"' . addslashes($this->name) . '" <' . $this->email . '>';
function isAuth()
{
$db = $this->getDatabaseConnection();
- $sesPrefix = $db->dsn['database'];
+ // we combine db + project names,
+ // otherwise if projects use different 'auth' objects
+ // then we get unserialize issues.
+ $sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
+
+
@session_start();
if (!empty($_SESSION[__CLASS__][$sesPrefix .'-auth'])) {
// in session...
$a = unserialize($_SESSION[__CLASS__][$sesPrefix .'-auth']);
+
$u = DB_DataObject::factory('Person');
if ($u->get($a->id)) { //&& strlen($u->passwd)) {
$u->verifyAuth();
($_SERVER['REMOTE_ADDR'] == '127.0.0.1') &&
$u->get('email', $ff->Pman['local_autoauth'])
) {
- $db = $this->getDatabaseConnection();
- $sesPrefix = $db->dsn['database'];
$_SESSION[__CLASS__][$sesPrefix .'-auth'] = serialize($u);
return true;
}
return false;
}
$db = $this->getDatabaseConnection();
- $sesPrefix = $db->dsn['database'];
+ $sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
+
if (!empty($_SESSION[__CLASS__][$sesPrefix .'-auth'])) {
$a = unserialize($_SESSION[__CLASS__][$sesPrefix .'-auth']);
$this->isAuth(); // force session start..
$this->verifyAuth();
$db = $this->getDatabaseConnection();
-
-
// refresh admin group if we are logged in as one..
//DB_DataObject::debugLevel(1);
$g = DB_DataObject::factory('Groups');
$gr = DB_DataObject::Factory('Group_Rights');
$gr->applyDefs($g, 0);
}
-
-
-
- $sesPrefix = $db->dsn['database'];
+
+ $sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
$_SESSION[__CLASS__][$sesPrefix .'-auth'] = serialize($this);
}
{
$this->isAuth(); // force session start..
$db = $this->getDatabaseConnection();
- $sesPrefix = $db->dsn['database'];
+ $sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
$_SESSION[__CLASS__][$sesPrefix .'-auth'] = "";
}
$x->get($this->company_id);
return $x;
}
-
+ function loadCompany()
+ {
+ $this->company = $this->company();
+ }
function active()
{
/**
*Basic group fetching - probably needs to filter by type eventually.
*
+ *@param String $what - fetchall() argument - eg. 'name' returns names of all groups that they are members of.
*/
- function groups()
+ function groups($what=false)
{
$g = DB_DataObject::Factory('Group_Members');
$grps = $g->listGroupMembership($this);
$g = DB_DataObject::Factory('Groups');
$g->whereAddIn('id', $grps, 'int');
- return $g->fetchAll();
+ return $g->fetchAll($what);
}
}
// ------------ROO HOOKS------------------------------------
- function applyFilters($q, $au)
+ function applyFilters($q, $au, $roo)
{
//DB_DataObject::DebugLevel(1);
if (!empty($q['query']['person_not_internal'])) {
$this->whereAdd(" join_company_id_id.isOwner = 0 ");
}
+
+
if (!empty($q['query']['person_internal_only_all'])) {
$tn_p = $this->tableName();
$tn_gm = DB_DataObject::Factory('Group_Members')->tableName();
$tn_g = DB_DataObject::Factory('Groups')->tableName();
-
+
///---------------- Group views --------
if (!empty($q['query']['in_group'])) {
// DB_DataObject::debugLevel(1);
}
+
if ( $q['query']['not_in_directory'] > -1) {
+ $tn_pd = DB_DataObject::Factory('ProjectDirectory')->tableName();
// can list current - so that it does not break!!!
- $x->whereAdd('Person.id NOT IN
- ( SELECT distinct person_id FROM ProjectDirectory WHERE
- project_id = ' . $q['query']['not_in_directory'] . ' AND
- company_id = ' . $this->company_id . ')');
+ $x->whereAdd("$tn_p.id NOT IN
+ ( SELECT distinct person_id FROM $tn_pd WHERE
+ project_id = " . $q['query']['not_in_directory'] . " AND
+ company_id = " . $this->company_id . ')');
}
}
//DB_DataObject::debugLevel(1);
$do = DB_DataObject::factory('ProjectDirectory');
$do->project_id = $q['query']['project_member_of'];
-
+ $tn_pd = DB_DataObject::Factory('ProjectDirectory')->tableName();
$this->joinAdd($do,array('joinType' => 'LEFT', 'useWhereAsOn' => true));
- $this->selectAdd('IF(ProjectDirectory.id IS NULL, 0, ProjectDirectory.id ) as is_member');
+ $this->selectAdd("IF($tn_pd.id IS NULL, 0, $tn_pd.id ) as is_member");
if (!empty($q['query']['project_member_filter'])) {
if (!empty($q['query']['search'])) {
$s = $this->escape($q['query']['search']);
$this->whereAdd("
- Person.name LIKE '%$s%' OR
- Person.email LIKE '%$s%' OR
- Person.role LIKE '%$s%' OR
- Person.remarks LIKE '%$s%'
+ $tn_p.name LIKE '%$s%' OR
+ $tn_p.email LIKE '%$s%' OR
+ $tn_p.role LIKE '%$s%' OR
+ $tn_p.remarks LIKE '%$s%'
");
}
// extra case change passwod?
case 'P': //??? password
// standard perms -- for editing + if the user is dowing them selves..
- $ret = $isStaff ? $au->hasPerm("Core.Person", "E") : $au->hasPerm("Core.Staff", "E");
+ $ret = $isStaff ? $au->hasPerm("Core.Staff", "E") : $au->hasPerm("Core.Person", "E");
return $ret || $au->id == $this->id;
- case 'S': // list..
- return $au->hasPerm("Core.Person", "S");
-
- case 'E': // edit
- return $isStaff ? $au->hasPerm("Core.Person", "E") : $au->hasPerm("Core.Staff", "E");
-
- case 'A': // add
- return $isStaff ? $au->hasPerm("Core.Person", "A") : $au->hasPerm("Core.Staff", "A");
-
- case 'D': // add
- return $isStaff ? $au->hasPerm("Core.Person", "D") : $au->hasPerm("Core.Staff", "D");
+ default:
+ return $isStaff ? $au->hasPerm("Core.Staff", $lvl) : $au->hasPerm("Core.Person", $lvl);
}
return false;