function outputBody() { if ($this->timer) { $this->timer->setMarker(__CLASS__ . '::outputBody - start'); } $ff = HTML_FlexyFramework::get(); $proj = $ff->project; // DB_DataObject::debugLevel(1); $m = DB_DAtaObject::factory('Builder_modules'); $m->get('name', $proj); //var_dump($m->path);exit; // needs to modify the template directory?? // use the builder_module == app name // look for part with same name. if (empty($ff->Pman_Builder['from_filesystem'])) { $template_engine = new HTML_Template_Flexy(array('templateDir' => $m->path)); } else { $template_engine = new HTML_Template_Flexy(); } $template_engine->debug = 1; //print_R($template_engine); $template_engine->compile($this->template); if ($this->elements) { /* BC crap! */ $this->elements = HTML_Template_Flexy_Factory::setErrors($this->elements, $this->errors); } $template_engine->elements = $this->elements; if ($this->timer) { $this->timer->setMarker(__CLASS__ . '::outputBody - render template'); } //DB_DataObject::debugLevel(1); $template_engine->outputObject($this, $this->elements); if ($this->timer) { $this->timer->setMarker(__CLASS__ . '::outputBody - end'); } }
function passwordRequest($n) { $u = DB_DataObject::factory('core_person'); //$u->company_id = $this->company->id; $u->whereAdd('LENGTH(passwd) > 1'); $u->email = $n; $u->active = 1; if ($u->count() > 1 || !$u->find(true)) { $this->jerr('invalid User (1)'); } // got a avlid user.. if (!strlen($u->passwd)) { $this->jerr('invalid User (2)'); } // check to see if we have sent a request before.. if ($u->no_reset_sent > 3) { $this->jerr('We have issued to many resets - please contact the Administrator'); } // sort out sender. $cm = DB_DataObject::factory('core_email'); if (!$cm->get('name', 'ADMIN_PASSWORD_RESET')) { $this->jerr("no template ADMIN_PASSWORD_RESET exists - please run importer "); } /* $g = DB_DAtaObject::factory('Groups'); if (!$g->get('name', 'system-email-from')) { $this->jerr("no group 'system-email-from' exists in the system"); } $from_ar = $g->members(); if (count($from_ar) != 1) { $this->jerr(count($from_ar) ? "To many members in the 'system-email-from' group " : "'system-email-from' group does not have any members"); } */ // bcc.. $g = DB_DAtaObject::factory('core_group'); if (!$g->get('name', 'bcc-email')) { $this->jerr("no group 'bcc-email' exists in the system"); } $bcc = $g->members('email'); if (!count($bcc)) { $this->jerr("'bcc-email' group does not have any members"); } $this->authFrom = time(); $this->authKey = $u->genPassKey($this->authFrom); //$this->authKey = md5($u->email . $this->authFrom . $u->passwd); $this->person = $u; $this->bcc = $bcc; $this->rcpts = $u->getEmailFrom(); $ret = $cm->send($this); //$this->jerr(print_r($r->toData(),true)); if (is_object($ret)) { $this->addEvent('SYSERR', false, $ret->getMessage()); $this->jerr($ret->getMessage()); } $this->addEvent('PASSREQ', $u, $u->email); $uu = clone $u; $uu->no_reset_sent++; $uu->update($u); $this->jok("done"); }
function currentRates() { $this->loadRates(); // DB_DataObject::debugLevel(1); $c = DB_DAtaObject::factory('core_curr_rate'); $c->whereAdd('from_dt < NOW() AND to_dt > NOW()'); $c->find(); $ret = array(); while ($c->fetch()) { $ret[$c->curr] = $c->rate; } return $ret; }
function getAuthUser() { if (!$this->isAuth()) { return false; } $ff = HTML_FlexyFramework::get(); $sesPrefix = $this->sesPrefix(); //var_dump(array(get_class($this),$sesPrefix .'-auth')); if (!empty($_SESSION[get_class($this)][$sesPrefix . '-auth'])) { $a = unserialize($_SESSION[get_class($this)][$sesPrefix . '-auth']); $u = DB_DataObject::factory($this->tableName()); // allow extending this ... $u->autoJoin(); if ($u->get($a->id)) { /// && strlen($u->passwd)) { // should work out the pid .. really.. $_SESSION[get_class($this)][$sesPrefix . '-auth-timeout'] = time() + 30 * 60; // eg. 30 minutes setcookie('Pman.timeout', time() + 30 * 60, time() + 30 * 60, '/'); $user = clone $u; return clone $user; } unset($_SESSION[get_class($this)][$sesPrefix . '-auth']); unset($_SESSION[get_class($this)][$sesPrefix . '-timeout']); setcookie('Pman.timeout', -1, time() + 30 * 60, '/'); } if (!$this->canInitializeSystem()) { return false; } if (empty($_SESSION[get_class($this)][$sesPrefix . '-empty'])) { $u = DB_DataObject::factory($this->tableName()); $u->whereAdd(' LENGTH(passwd) > 0'); $_SESSION[get_class($this)][$sesPrefix . '-empty'] = $u->count(); } if (isset($_SESSION[get_class($this)][$sesPrefix . '-empty']) && $_SESSION[get_class($this)][$sesPrefix . '-empty'] < 1) { // fake person - open system.. //$ce = DB_DataObject::factory('core_enum'); //$ce->initEnums(); $u = DB_DataObject::factory($this->tableName()); $u->id = -1; // if a company has been created fill that in in company_id_id $c = DB_DAtaObject::factory('core_company')->lookupOwner(); if ($c) { $u->company_id_id = $c->pid(); $u->company_id = $c->pid(); } return $u; } return false; }
function listTriggerFunctions($table, $type) { static $cache = array(); if (!isset($cache[$table])) { $cache[$table] = array(); $q = DB_DAtaObject::factory('core_enum'); $q->query("SELECT\n SPECIFIC_NAME\n FROM\n information_schema.ROUTINES\n WHERE\n ROUTINE_SCHEMA = '{$q->escape($q->database())}'\n AND\n ROUTINE_NAME LIKE '" . $q->escape("{$table}_trigger_") . "%'\n AND\n ROUTINE_TYPE = 'PROCEDURE'\n \n "); while ($q->fetch()) { $cache[$table][] = $q->SPECIFIC_NAME; } } // now see which of the procedures match the specification.. $ret = array(); foreach ($cache[$table] as $cname) { $bits = explode("_before_{$type}_", $cname); if (count($bits) < 2) { continue; } $ret[$cname] = $bits[1]; } return $ret; }
function person() { $p = DB_DAtaObject::factory('core_person'); $p->get($this->person_id); return $p; }