Skip to content
Snippets Groups Projects
Commit f22a4277 authored by Leif Andersson's avatar Leif Andersson
Browse files

Added rudimentary action.defaultadmin, class.AddressDB, adminpanel.tpl

parent e5f940ab
Branches
No related tags found
No related merge requests found
<?php
/**
* DisplayAdminPanel($id, $params, $returnid, $message)
* NOT PART OF THE MODULE API
*
*/
/**
* For separated methods, you'll always want to start with the following
* line which check to make sure that method was called from the module
* API, and that everything's safe to continue:
*/
if (!isset($gCms)) exit;
/**
* For separated methods, you won't be able to do permission checks in
* the DoAction method, so you'll need to do them as needed in your
* method:
*/
if (! $this->CheckPermission('Use ReglerAddress')) {
return $this->DisplayErrorPage($id, $params, $returnid,
'ReglerAddress access denied.');
}
/**
* After this, the code is identical to the code that would otherwise be
* wrapped in the DisplayAdminPanel() method in the module body.
*/
if (FALSE == empty($params['active_tab']))
{
$tab = $params['active_tab'];
} else {
$tab = '';
}
//file_put_contents("/tmp/defaultadmin.txt",print_r($params,TRUE));
$semDB = AddressDB::getDB();
/* $orderby = ' date desc, start desc'; */
/* $wheredate = ' date > SUBDATE(CURDATE(), 30) '; */
/* $currentYear = date('Y'); */
/* if (isset($params['year'])) { */
/* $year = $params['year']; */
/* $yearstart = $semDB->Quote(sprintf('%s-01-01',$year)); */
/* $yearend = $semDB->Quote(sprintf('%s-12-31',$year)); */
/* $wheredate = sprintf(' date > %s and date < %s', $yearstart, $yearend); */
/* $previousYear = $year - 1; */
/* $nextYear = $year + 1; */
/* $place = $this->CreateInputSubmit($id, 'year', $previousYear); */
/* $smarty->assign('previousSelect', $place); */
/* if ($nextYear <= $currentYear) { */
/* $place = $this->CreateInputSubmit($id, 'year', $nextYear); */
/* $smarty->assign('nextSelect', $place); */
/* } */
/* } else { */
/* $place = $this->CreateInputSubmit($id, 'year', $currentYear); */
/* $smarty->assign('previousSelect', $place); */
/* } */
/* $wheredate = $wheredate . ' and seminars.type=types.id '; */
/* $records = Seminar::getSeminars($wheredate,$orderby); */
/* foreach ($records as $rec) { */
/* $link = $this->CreateFrontendLink($id, $returnid, 'add_edit','%s', */
/* array('seminarID'=>$rec->id)); */
/* $rec->setAdminLink($link); */
/* } */
/* // Expose the list to smarty. Use "by_ref" to save memory. */
/* $smarty->assign_by_ref('records',$records); */
/* // and a count of records */
/* $smarty->assign('title_num_records', */
/* $this->Lang('title_num_records',array(count($records)))); */
$place = $this->CreateFormStart($id, 'defaultadmin', $returnid);
$smarty->assign('start_form', $place);
$smarty->assign('end_form', $this->CreateFormEnd());
$title_fornamn = 'Förnamn';
$place = $this->CreateInputText($id,'Fornamn', $fornamn,40);
$input_fornamn = $place;
$title_efternamn = 'Efternamn';
$place = $this->CreateInputText($id,'Efternamn', $efternamn,40);
$input_efternamn = $place;
/* $place = $this->CreateFormStart($id, 'add_edit', $returnid); */
/* $smarty->assign('start_form', $place); */
/* $types = array_flip(Util::$seminarTypes); */
/* array_shift($types); */
/* $place = $this->CreateInputSelectList($id,'numericType', */
/* $types, */
/* array(1),4,NULL,FALSE); */
/* $smarty->assign('seminarType', $place); */
/* $place = $this->CreateInputSubmit($id, 'newSeminar', 'New Seminar'); */
/* $smarty->assign('submit', $place); */
/* if (isset($params['module_message'])) { */
/* $this->smarty->assign('module_message',$params['module_message']); */
/* } else { */
/* $this->smarty->assign('module_message',''); */
/* } */
/* // Display the populated template */
/* $smarty->assign('end_form', $this->CreateFormEnd()); */
/* $place = $this->CreateFormStart($id, 'composeLetter', $returnid); */
/* $smarty->assign('start_letter_form', $place); */
/* $place = $this->CreateInputSubmit($id, 'composeLetter', 'Compose Letter'); */
/* $smarty->assign('submit_letter', $place); */
/* $smarty->assign('end_letter_form', $this->CreateFormEnd()); */
echo $this->ProcessTemplate('adminpanel.tpl');
?>
\ No newline at end of file
<?php
class SeminarDB {
private static $instance;
private $PDB;
private $database = 'addresses';
private function __construct() {
global $gCms;
if (!isset($gCms)) exit;
$config =& $gCms->GetConfig();
$this->PDB = ADONewConnection($config['dbms'],
'pear:date:extend:transaction');
$result = $this->PDB->Connect($config['db_hostname'],
$config['db_username'],
$config['db_password'],
$database);
if ($result) {
$result = $this->PDB->Execute("SET NAMES 'utf8'");
} else {
echo "Database error!<br>" . $this->PDB->ErrorMsg();
exit;
}
}
public static function getDB() {
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance->PDB;
}
}
{$start_form}
<table><tbody>
<tr><td style="text-align:right;">{$title_fornamn}</td>
<td>{$input_fornamn}</td></tr>
<tr><td style="text-align:right;">{$title_efternamn}</td>
<td>{$input_efternamn}</td></tr>
</tbody></table>
{$end_form}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment