public $__table = 'Person'; // table name
public $id; // int(11) not_null primary_key auto_increment
public $email; // string(128) not_null
+ public $alt_email;
public $company_id; // int(11)
public $office_id; // int(11)
function verifyAuth()
{
$ff= HTML_FlexyFramework::get();
- if (!empty($ff->Pman['auth_comptype']) && $ff->Pman['auth_comptype'] != $this->company()->comptype) {
+ if (!empty($ff->Pman['auth_comptype']) &&
+ (!$this->company_id || ($ff->Pman['auth_comptype'] != $this->company()->comptype))
+ ){
+
+ // force a logout - without a check on the isAuth - as this is called from there..
+ $db = $this->getDatabaseConnection();
+ $sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
+ $_SESSION[__CLASS__][$sesPrefix .'-auth'] = "";
+ return false;
+
$ff->page->jerr("Login not permited to outside companies");
}
return true;
$u = DB_DataObject::factory('Person');
if ($u->get($a->id)) { //&& strlen($u->passwd)) {
- $u->verifyAuth();
+
+ return $u->verifyAuth();
+
return true;
}
function login()
{
$this->isAuth(); // force session start..
- $this->verifyAuth();
+ if (!$this->verifyAuth()) {
+ return false;
+ }
$db = $this->getDatabaseConnection();
// use our magic search builder...
+ require_once 'Text/SearchParser.php';
+ $x = new Text_SearchParser($q['query']['search']);
+
+ $props = array(
+ "$tn_p.name",
+ "$tn_p.email",
+ "$tn_p.role",
+ "$tn_p.phone",
+ "$tn_p.remarks",
+ "join_company_id_id.name"
+ );
+
+ $str = $x->toSQL(array(
+ 'default' => $props,
+ 'map' => array(
+ 'company' => 'join_company_id_id.name',
+ //'country' => 'Clipping.country',
+ // 'media' => 'Clipping.media_name',
+ ),
+ 'escape' => array($this->getDatabaseConnection(), 'escapeSimple'), /// pear db or mdb object..
+
+ ));
- $s = $this->escape($q['query']['search']);
- $this->whereAdd("
+ $this->whereAdd($str); /*
$tn_p.name LIKE '%$s%' OR
$tn_p.email LIKE '%$s%' OR
$tn_p.role LIKE '%$s%' OR
$tn_p.phone LIKE '%$s%' OR
$tn_p.remarks LIKE '%$s%'
- ");
+ ");*/
}
//
function importFromArray($roo, $persons, $prefix)
{
+ if (!is_array($persons) || empty($persons)) {
+ $roo->jerr("error in the person data. - empty on not valid");
+ }
+ DB_DataObject::factory('groups')->initGroups();
+
foreach($persons as $person){
$p = DB_DataObject::factory('person');
if($p->get('name', $person['name'])){