public function __construct() { parent::__construct(); \ipinga\acl::$userTableName = 'users'; \ipinga\acl::$usernameFieldName = 'email'; $mgr = \ipinga\ipinga::getInstance()->manager; $mgr->userIsLoggedIn(false); // determine if the user is logged in or not $this->template->logo_url = \ipinga\options::get('logo_url'); $this->template->showLoginFormInTopBanner = false; $u = new \ipinga\table('users'); if ($mgr->isLoggedIn == true) { $u->loadById($mgr->loggedInDetails['USER_ID']); $mgr->update($u->id); } $this->template->loggedInUser = $u; // will be a bunch of null data if the user isn't logged in $this->template->manager = $mgr; $this->template->menuHtml = ''; if (\ipinga\cookie::keyExists('message_for_next_screen') == true) { $this->template->message_for_next_screen = \ipinga\cookie::keyValue('message_for_next_screen'); \ipinga\cookie::drop('message_for_next_screen'); } $this->template->title = \ipinga\options::get('site_title'); $this->template->activePanel = 0; $this->template->skin = \ipinga\options::get('skin'); }
public function loadByFieldsMatching($fields = array(), $orderBy = 'id') { $w = ''; foreach ($fields as $fieldName => $desiredValue) { if (empty($w) == false) { $w .= ' AND '; } $w .= $fieldName . ' = :' . $fieldName; } if (empty($w) == true) { $sql = sprintf('select id from %s order by %s', $this->tableName, $orderBy); } else { $sql = sprintf('select id from %s where %s order by %s', $this->tableName, $w, $orderBy); } $this->lastSql = $sql; try { $stmt = \ipinga\ipinga::getInstance()->pdo()->prepare($sql); foreach ($fields as $fieldName => $desiredValue) { $stmt->bindValue(':' . $fieldName, $desiredValue); } $stmt->execute(); while ($r = $stmt->fetch(\PDO::FETCH_ASSOC)) { $tbl = new \ipinga\table($this->tableName); $tbl->loadById($r['id']); $this->records[] = $tbl; } } catch (\PDOException $e) { echo $e->getMessage() . '<br>' . $sql . '<br><hr>'; $this->saved = false; } }