/** * This is the return URL for the payment provider. * Will be called when payment raches a final state, so control is handed over to our * app again from the payment processor. */ function PostPayment() { // we just display the $_REQUEST data for now. in fact this is the point where some processing // should take place: send email to the team, that prepares the items for shipping, send email(s) to customer,... log_debug("PostPayment", $_REQUEST); $this->content("<h1>Payment processed</h1>"); $this->content("Provider returned this data:<br/><pre>" . render_var($_REQUEST) . "</pre>"); }
/** * @internal Used to add some new/unknown strings to the translation system */ function translation_add_unknown_strings($unknown_constants) { global $CONFIG; if ($CONFIG['translation']['sync']['datasource']) { $ds = model_datasource($CONFIG['translation']['sync']['datasource']); $ds->ExecuteSql("CREATE TABLE IF NOT EXISTS wdf_unknown_strings (\n\t\t\tterm VARCHAR(150) NOT NULL,\n\t\t\tlast_hit DATETIME NOT NULL,\n\t\t\thits INT DEFAULT 0,\n\t\t\tdefault_val TEXT,\n\t\t\tPRIMARY KEY (term))"); $now = $ds->Driver->Now(); $sql1 = "INSERT OR IGNORE INTO wdf_unknown_strings(term,last_hit,hits,default_val)VALUES(?,{$now},0,?);"; $sql2 = "UPDATE wdf_unknown_strings SET last_hit={$now}, hits=hits+1 WHERE term=?;"; foreach ($unknown_constants as $uc) { $def = cfg_getd('translation', 'default_strings', $uc, ''); $ds->Execute($sql1, array($uc, $def)); $ds->Execute($sql2, $uc); } } else { log_debug("Unknown text constants: " . render_var(array_values($unknown_constants))); } }
/** * Returns the last statement and the error info * * Will combine that into a string for easy output * @return string SQL[newline]ErrorInfo */ public function ErrorOutput() { return $this->_sql_used . "\n" . render_var($this->_stmt->errorInfo()); }
/** * Saves this model to the database. * * New datasets will be inserted, loaded ones will be updated automatically. * If $columns_to_update is given only those columns will be stored. This may be useful to avoid DB conflicts in multithread scenarios. * @param array $columns_to_update If given only these fields will be updated. If not Model tries to detect changed columns automatically. * @return boolean In fact always true, WdfDbException will be thrown in error case */ public function Save($columns_to_update = false) { $args = array(); $stmt = $this->_ds->Driver->getSaveStatement($this, $args, $columns_to_update); if (!$stmt) { return true; } // nothing to save if (!$stmt->execute($args)) { WdfDbException::Raise(render_var($stmt->ErrorOutput())); } $pkcols = $this->GetPrimaryColumns(); if (count($pkcols) == 1) { $id = $pkcols[0]; if (!isset($this->{$id})) { $this->{$id} = $this->_ds->LastInsertId(); } } $this->__init_db_values(); return true; }
/** * @param string $label Item label * @param mixed $controller Controller object or id * @param string $event Handler method * @param mixed $data Array or urlencoded string containing additional data to be passed */ function __initialize($label, $controller, $event = "", $data = array()) { parent::__initialize("li"); $this->class = ""; if ($event == '$is_link$') { $this->content(new Anchor($controller, $label)); } else { $this->content(new Anchor(buildQuery($controller, $event, $data), $label)); } $this->controller = strtolower($controller); if ($event) { $this->event = strtolower($event); } $this->data = md5(render_var($data)); }
/** * @internal SysAdmin cache manager. * @attribute[RequestParam('search','string',false)] * @attribute[RequestParam('show_info','bool',false)] * @attribute[RequestParam('kind','string','Search key')] */ function Cache($search, $show_info, $kind) { $this->content("<h1>Cache contents</h1>"); $form = $this->content(new Form()); $form->AddText('search', $search); $form->AddSubmit('Search key')->name = 'kind'; $form->AddSubmit('Search content')->name = 'kind'; $form->content(' '); $form->content(new Anchor(buildQuery('sysadmin', 'cacheclear'), 'Clear the complete cache')); if (system_is_module_loaded('globalcache')) { $form->content(' '); $form->content(new Anchor(buildQuery('sysadmin', 'cache', 'show_info=1'), 'Global cache info')); } $form->content('<div><b>Predefined searches:</b><br/>'); foreach ($this->PrefedinedCacheSearches as $s) { $form->content(new Anchor(buildQuery('sysadmin', 'cache', "search={$s}"), "{$s}")); $form->content(' '); } $form->content('</div>'); if (!isset($_SESSION['admin_handler_last_cache_searches'])) { $_SESSION['admin_handler_last_cache_searches'] = array(); } if (count($_SESSION['admin_handler_last_cache_searches']) > 0) { $form->content('<div><b>Last searches:</b><br/>'); foreach ($_SESSION['admin_handler_last_cache_searches'] as $s) { list($k, $s) = explode(":", $s); $form->content(new Anchor(buildQuery('sysadmin', 'cache', "search={$s}" . ($k != 'key' ? '&kind=Search content' : '')), "{$k}:{$s}")); $form->content(' '); } $form->content('</div>'); } if ($show_info && system_is_module_loaded('globalcache')) { $form->content("<pre>" . globalcache_info() . "</pre>"); } if ($search) { if (!in_array($search, $this->PrefedinedCacheSearches)) { $_SESSION['admin_handler_last_cache_searches'][] = $kind == 'Search content' ? "content:{$search}" : "key:{$search}"; $_SESSION['admin_handler_last_cache_searches'] = array_unique($_SESSION['admin_handler_last_cache_searches']); } $this->content("<br/>"); $tabform = $this->content(new Form()); $tabform->action = buildQuery('sysadmin', 'cachedelmany'); $tab = $tabform->content(new Table())->addClass('bordered'); $tab->SetHeader('', 'key', 'action'); $q = buildQuery('sysadmin', 'cachedel'); foreach (cache_list_keys() as $key) { $found = $kind == 'Search content' ? stripos(render_var(cache_get($key, "")), $search) !== false : stripos($key, $search) !== false; if ($found) { $cb = new CheckBox('keys[]'); $cb->value = $key; $del = new Anchor('', 'delete'); $del->onclick = "\$.post('{$q}',{key:'" . addslashes($key) . "'},function(){ \$('#{$del->id}').parents('.tr').fadeOut(function(){ \$(this).remove(); }); })"; $tab->AddNewRow($cb, $key, $del); } } $footer = $tab->Footer()->NewCell(); $footer->colspan = 2; $footer->content(new Anchor('', 'all'))->onclick = "\$('#{$tab->id} .tbody input').prop('checked',true);"; $footer->content(' '); $footer->content(new Anchor('', 'none'))->onclick = "\$('#{$tab->id} .tbody input').prop('checked',false)"; $footer = $tab->Footer()->NewCell(); $footer->content(new Anchor('', 'delete'))->onclick = "\$('#{$tabform->id}').submit()"; } }