public function __construct() { $db = PVars::getObj('config_rdbms'); if (!$db) { throw new PException('DB config error!'); } $dao = PDB::get($db->dsn, $db->user, $db->password); $this->dao =& $dao; }
/** * @param string $category optional value to set the page of the texts * we're looking for (this needs an additional column in the * words table) */ public function __construct($category = null) { $this->_lang = PVars::get()->lang; $this->WordMemcache = new MOD_bw_memcache("words", "Sentence", "code"); if (!empty($category)) { $this->_whereCategory = ' `category`=\'' . $category . '\''; } if (isset($_SESSION['IdLanguage'])) { $this->_langWrite = $_SESSION['IdLanguage']; } else { $this->_langWrite = 0; } $db_vars = PVars::getObj('config_rdbms'); if (!$db_vars) { throw new PException('DB config error!'); } $dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password); $this->_dao =& $dao; $R = MOD_right::get(); if ($R->hasRight("Words", $this->_lang)) { $this->_offerTranslationLink = true; } // read translation mode from $_SESSION['tr_mode'] if (array_key_exists("tr_mode", $_SESSION)) { $this->_trMode = $_SESSION['tr_mode']; } else { if (array_key_exists("tr_mode", $_SESSION)) { $this->_trMode = $_SESSION['tr_mode']; } else { if ($this->_offerTranslationLink) { $this->_trMode = 'translate'; } else { $this->_trMode = 'browse'; } } } switch ($this->_trMode) { case 'browse': case 'proofread': // not yet implemented break; case 'edit': case 'translate': if ($this->_offerTranslationLink) { break; } default: if ($this->_offerTranslationLink) { $this->_trMode = 'translate'; } else { $this->_trMode = 'browse'; } } }
/** * Constructor */ public function __construct() { // instantiate the dao $db = PVars::getObj('config_rdbms'); if (!$db) { throw new PException('DB config error!'); } $dao = PDB::get($db->dsn, $db->user, $db->password); $this->dao =& $dao; MOD_params::get()->loadParams(); }
/** * @param int $tablename name of table expressed as an integer, * e.g. MOD_enc::TABLE_NAME_REF_MEMBER * @param int $rownumber number of row in the table afore mentioned * @return void */ public function __construct($tablename, $rownumber, $idMember, $keyMember) { $db = PVars::getObj('config_rdbms'); if (!$db) { throw new PException('DB config error!'); } $dao = PDB::get($db->dsn, $db->user, $db->password); $this->dao =& $dao; parent::__construct($tablename, $rownumber, $keyMember); $this->_idMember = $idMember; }
/** * constructor... * * @return nothing */ function __construct() { $this->baseuri = PVars::getObj('env')->baseuri; $this->IdTriggerer = 0; //TODO: set this to bot id $this->words = new MOD_words(); $this->messages_model = new MessagesModel(); $this->members_model = new MembersModel(); // setup DB access $db_vars = PVars::getObj('config_rdbms'); if (!$db_vars) { throw new PException('DB config error!'); } $this->dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password); }
private function __construct() { $db = PVars::getObj('config_rdbms'); if (!$db) { throw new PException('DB config error!'); } $dao = PDB::get($db->dsn, $db->user, $db->password); $this->dao =& $dao; global $_SYSHCVOL; if (isset($_SYSHCVOL['WhoIsOnlineDelayInMinutes'])) { $this->online_interval = $_SYSHCVOL['WhoIsOnlineDelayInMinutes']; } else { $this->online_interval = 5; } }
/** * returns the handle from a TB user, given tb user id * * @param int $user_id id of user * * @access public * @return string */ public static function getUserHandle($user_id) { // insanity lies in the details. Any design where you have to do // boilerplate code like this should be thrown out immediately // after design $db = PVars::getObj('config_rdbms'); if (!$db) { throw new PException('DB config error!'); } $dao = PDB::get($db->dsn, $db->user, $db->password); $result = $dao->query("SELECT handle FROM user WHERE id = " . intval($user_id)); if ($result && ($fetched = $result->fetch(PDB::FETCH_OBJ))) { return $fetched->handle; } return ''; }
public function getLanguages() { $db_vars = PVars::getObj('config_rdbms'); if (!$db_vars) { throw new PException('DB config error!'); } $dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password); $dbresult = $dao->query(' SELECT DISTINCT languages.* FROM languages, words WHERE languages.id = words.IdLanguage AND words.code = \'WelcomeToSignup\' ORDER BY FlagSortCriteria '); $langs = array(); while ($row = $dbresult->fetch(PDB::FETCH_OBJ)) { $langs[] = $row; } return $langs; }
/** * content of the middle column - this is the most important part */ protected function column_col3() { echo ' <h3>The hello universe middle column</h3> using the class HellouniverseSimplePage.<br> More beautiful in <a href="hellouniverse/advanced">hellouniverse/advanced</a>!<br> With tabs in <a href="hellouniverse/tab1">hellouniverse/tab1</a>!<br><br>'; require_once SCRIPT_BASE . 'modules/i18n/lib/words2.lib.php'; $db_vars = PVars::getObj('config_rdbms'); if (!$db_vars) { throw new PException('DB config error!'); } $dao = PDB::get($db_vars->dsn, $db_vars->user, $db_vars->password); $spoken_languages = array((object) array('id' => 6, 'ShortCode' => 'de'), (object) array('id' => 0, 'ShortCode' => 'en')); $print_strategy_map = array(); $print_strategy_map['successful'] = new WordPrintStrategy_translateClickFullText(); $print_strategy_map['obsolete'] = new WordPrintStrategy_translate(); $print_strategy_map['missing_word'] = new WordPrintStrategy_translate(); $print_strategy_map['missing_translation'] = new WordPrintStrategy_translateClickFullText(); $words_gateway = new WordsGateway($dao); $translation_module = new TranslationModule($spoken_languages, $print_strategy_map, $words_gateway); echo $translation_module->translate('FindMembers', 'ww', array()); }
public static function getImage($paramIdMember = 0) { if ($paramIdMember == 0) { $IdMember = $_SESSION['IdMember']; } else { $IdMember = $paramIdMember; } if ($IdMember == 0) { return MOD_User::getDummyImage(); } $db = PVars::getObj('config_rdbms'); if (!$db) { throw new PException('DB config error!'); } $dao = PDB::get($db->dsn, $db->user, $db->password); $localDao =& $dao; $result = $localDao->query("\nSELECT\n FilePath\nFROM\n membersphotos\nWHERE\n IdMember = {$IdMember} AND\n SortOrder = 0\n "); $record = $result->fetch(PDB::FETCH_OBJ); if (isset($record->FilePath)) { return $path = PVars::getObj('env')->baseuri . $record->FilePath; } else { $result = $localDao->query("\nSELECT\n Gender,\n HideGender\nFROM\n members\nWHERE\n id = {$IdMember}\n "); $record = $result->fetch(PDB::FETCH_OBJ); return MOD_User::getDummyImage($record->Gender, $record->HideGender); } }
/** * normally the $dao should be injected. * If it's not, this function creates a new one out of the blue.. */ protected function get_dao() { if (!($dbconfig = PVars::getObj('config_rdbms'))) { throw new PException('DB config error!'); } return PDB::get($dbconfig->dsn, $dbconfig->user, $dbconfig->password); }
private function save() { if ($this->_callback && is_array($this->_callback)) { foreach ($this->_callback as $key => $callback) { if (!array_key_exists($key, $_POST)) { continue; } foreach ($_POST as $k => $v) { if (is_string($v)) { $v = trim($v); $v = stripslashes($v); } $this->_vars[$key][$k] = $v; } $this->_activeKey = $key; $callback = $this->_callback[$key]; unset($this->_callback[$key]); break; } $ret = false; $db = PVars::getObj('config_rdbms'); $dao = PDB::get($db->dsn, $db->user, $db->password); $c = new $callback[0]($dao); $cbRet = call_user_func(array(&$c, $callback[1])); if ($cbRet) { $ret = $cbRet; } $_SESSION['PostHandler'] = serialize($this); if ($ret) { $ret = parse_url($ret); $query = array(); if (isset($ret['query'])) { parse_str($ret['query'], $query); } if (is_array($query) && array_key_exists(session_name(), $query)) { continue; } $query[session_name()] = session_id(); $queries = array(); foreach ($query as $k => $q) { $queries[] = $k . '=' . $q; } $ret['query'] = implode('&', $queries); $ret = PFunctions::glueParsedUrl($ret); session_write_close(); header('Location: ' . $ret); PPHP::PExit(); } return TRUE; } }