function add_entry_interface()
 {
     global $log, $db, $page;
     $log->add_to_log('Guestbook::add_entry_interface()', 'add_entry_interface() called', 'guestbook');
     $tmp = 0;
     $form = new Form2($GLOBALS[PHP_SELF], 'post', 'guestbook', $action = $GLOBALS[action]);
     $fields = array();
     $fields[$tmp++] = array('name' => 'name', 'type' => 'text', 'title' => 'Name:', 'important' => 1, 'attribs' => array(0 => array('name' => 'title', 'value' => 'Ihr Name'), 1 => array('name' => 'size', 'value' => '20')));
     $fields[$tmp++] = array('name' => 'email', 'type' => 'text', 'title' => 'E-Mail:', 'important' => 0, 'attribs' => array(0 => array('name' => 'title', 'value' => 'Ihre E-Mail-Adresse'), 1 => array('name' => 'size', 'value' => '20'), 2 => array('name' => 'onBlur', 'value' => 'chkMailaddress(email)')));
     $fields[$tmp++] = array('name' => 'homepage', 'type' => 'text', 'title' => 'Homepage: http://', 'important' => 0, 'attribs' => array(0 => array('name' => 'title', 'value' => 'Ihre Homepage'), 1 => array('name' => 'size', 'value' => '20'), 2 => array('name' => 'onBlur', 'value' => 'chkMailaddress(email)')));
     $fields[$tmp++] = array('name' => 'message', 'type' => 'textarea', 'title' => 'Nachricht:', 'important' => 1, 'attribs' => array(0 => array('name' => 'title', 'value' => 'Hier bitte ein paar Sätze eingeben!'), 1 => array('name' => 'cols', 'value' => '60'), 2 => array('name' => 'rows', 'value' => '20')));
     $fields[$tmp++] = array('type' => 'hidden', 'important' => 0, 'selections' => array(0 => array('value' => 'add_entry', 'name' => 'action')));
     $fields[$tmp++] = array('type' => 'buttons', 'important' => 0, 'selections' => array(0 => array('value' => 'speichern>>', 'type' => 'submit', 'name' => 'submit'), 1 => array('value' => 'Zurücksetzen', 'type' => 'reset', 'name' => 'reset')));
     $form->load_form($fields);
     $form->precheck_form();
     if (!$GLOBALS[submit]) {
         $form->set_precheck_error();
     }
     if ($form->is_form_error()) {
         $message = $form->build_form();
         $width = '50%';
         $title = 'Neuer Eintrag';
     } else {
         $data = array('name' => $form->return_submitted_field('name'), 'email' => $form->return_submitted_field('email'), 'homepage' => 'http://' . $form->return_submitted_field('homepage'), 'message' => $form->return_submitted_field('message'));
         if ($this->add_entry($data)) {
             $message = '<p align=center class=ok>Vielen Dank f&uuml;r Ihren Eintrag! (o:</P>';
             $title = 'Nachricht gespeichert';
             $bottom_menu = array();
             $bottom_menu[0][text] = 'Zur&uuml;ck zur &Uuml;bersicht';
             $bottom_menu[0][link] = $GLOBALS[PHP_SELF];
         } else {
             $log->add_to_log('Guestbook::add_entry_interface()', 'add_entry_interface() error!! add_entry() returned 0! Aborting', 'guestbook');
             $message = 'Whoups! Beim Eintragen der Nachricht ist ein Fehler aufgetreten, haben sie möglicherweise zweimal auf "speichern" geklickt??';
             $title = 'Fehler';
         }
     }
     return $page->dialog_box($title, $message, 0, $bottom_menu, '50%');
 }
 function create_userlist_interface($id, $action, $type, $preset = 0)
 {
     global $log, $db, $page;
     require_once 'inc/classes/class_form2.inc.php';
     $form = new Form2($GLOBALS[PHP_SELF], 'get', 'create_userlist', $action, $id);
     $fields = $this->create_userlist_dialog('abspeichern&gt;&gt;', $action);
     $form->load_form($fields);
     $form->precheck_form();
     if (!$GLOBALS[submit]) {
         $form->set_precheck_error();
     }
     if ($form->is_form_error()) {
         $message = $form->build_form();
         $width = '50%';
         $title = 'Liste anlegen';
     } else {
         $width = '50%';
         if ($this->create_userlist($id)) {
             $title = 'Liste angelegt';
             $message = '<p class=ok>Liste wurde angelegt!</p>';
             $menu = array();
             switch ($type) {
                 case 'report':
                     $menu[0][text] = 'Zum Bericht';
                     $menu[0][link] = $GLOBALS[PHP_SELF] . '?action=report_read&id=' . $id;
                     break;
                 case 'date':
                     $menu[0][text] = 'Zum Termin';
                     $menu[0][link] = $GLOBALS[PHP_SELF] . '?action=date_view&id=' . $id;
                     break;
                 default:
             }
             $form->form_shutdown();
         } else {
             $title = 'Fehler';
             $message = '<p class=error>Fehler beim anlegen der Userliste! (logfiles?)</p>';
         }
     }
     return $page->dialog_box($title, $message, 0, $menu, $width);
 }
 function edit_user_interface($id, $action, $restricted = 1, $finish_menu = 0)
 {
     global $log, $db, $page, $session;
     $log->add_to_log('User::edit_user_interface()', 'edit_user_interface() called!', 'debug');
     /*******************************************************************************
      * Zuerstmal die Userdaten holen:
      *******************************************************************************/
     if ($this->load_user($id)) {
         $log->add_to_log('User::edit_user_interface()', 'Ok, userdata loaded successfuly, commencing!', 'debug');
         $form = new Form2($GLOBALS[PHP_SELF], 'get', 'user_create');
         $fields = $this->user_form('abspeichern', $action, $id, 1, $restricted);
         $presets = array('geburtstag' => $this->user_info('geburtstag'), 'email' => $this->user_info('email'), 'name' => $this->user_info('name'), 'vorname' => $this->user_info('vorname'), 'funktion' => array(0 => $this->user_info('rang')), 'einheit' => array(0 => $this->user_info('ref_einheit_id')));
         $form->load_presets($presets);
         $form->load_form($fields);
         $form->precheck_form();
         $password = 0;
         if ($form->return_submitted_field('old_password') or !$restricted and $form->return_submitted_field('new_password')) {
             // $log->add_to_log('User::edit_user_interface()', 'Requesting password-change!', 'debug');
             /*******************************************************************************
              * Hossa, da will jemand sein Passwort ändern:
              ******************************************************************************/
             if ($form->return_submitted_field('new_password') != $this->user_info('password')) {
                 if ($form->return_submitted_field('old_password') == $this->user_info('password') or !$restricted) {
                     if ($form->return_submitted_field('new_password') == $form->return_submitted_field('new_password_confirm')) {
                         $password = $form->return_submitted_field('new_password');
                         $message = '<b class=ok>Passwort wurde geändert!</b>';
                     } else {
                         $form->set_precheck_error();
                         $message = '<b class=error>Die beiden neuen Passwörter stimmen nicht überein!</b>';
                     }
                 } else {
                     $form->set_precheck_error();
                     $message = '<b class=error>Das eingegebene Passwort ist nicht richtig!</b>';
                 }
             }
         }
         if (!$GLOBALS[submit]) {
             $form->set_precheck_error();
         }
         if ($form->is_form_error()) {
             $title = 'User editieren';
             $message .= $form->build_form();
         } else {
             $tmp = explode('.', $form->return_submitted_field('geburtstag'));
             $geburtstag = $tmp[2] . '-' . $tmp[1] . '-' . $tmp[0];
             $user_data = array();
             if (!$restricted) {
                 $user_data[] = array('name' => 'name', 'value' => trim($form->return_submitted_field('name')));
                 $user_data[] = array('name' => 'vorname', 'value' => trim($form->return_submitted_field('vorname')));
                 $user_data[] = array('name' => 'rang', 'value' => trim($form->return_submitted_field('funktion')));
                 $user_data[] = array('name' => 'ref_einheit_id', 'value' => trim($form->return_submitted_field('einheit')));
             }
             $user_data[] = array('name' => 'email', 'value' => trim($form->return_submitted_field('email')));
             $user_data[] = array('name' => 'geburtstag', 'value' => $geburtstag);
             if ($password) {
                 $user_data[] = array('name' => 'password', 'value' => $password);
             }
             if ($this->update_user($id, $user_data) > 0) {
                 $title = 'User geändert!';
                 $message = 'Die Änderungen wurden erfolgreich abgespeichert!';
                 if ($finish_menu) {
                     $bottom_menu = $finish_menu;
                 } else {
                     $bottom_menu = array();
                     $bottom_menu[0][text] = 'Zum User';
                     $bottom_menu[0][link] = $GLOBALS[PHP_SELF] . '?action=administration_user_view&auswahl=' . $id;
                 }
             } else {
                 $log->add_to_log('User::edit_user_interface()', 'Error while saving user (ID: ' . $id . ')! User::update_user() returned < 0!! Aborting!', 'error');
                 $title = 'Fehler';
                 $message = 'Urgs! Beim abspeichern der Änderungen ist etwas schiefgelaufen!! (logfiles?)';
                 $bottom_menu = array();
                 $bottom_menu[0][text] = '&lt;&lt;User nochmal editieren';
                 $bottom_menu[0][link] = $GLOBALS[PHP_SELF] . '?action=' . $action . '&id=' . $id;
             }
             $form->form_shutdown();
         }
         return $page->dialog_box($title, $message, $menu, $bottom_menu, '100%');
     } else {
         $log->add_to_log('User::edit_user_interface()', 'Error while loading user! User::load_user() returned 0!! Aborting!', 'error');
         return $page->dialog_box('Fehler', 'Whoups!! Konnte den gewählten User (ID: <b>' . $id . '</b>) nicht finden... breche ab!', 0, 0, '100%');
     }
 }
    function edit_link_interface($id)
    {
        global $log, $db, $session, $page;
        $log->add_to_log('Link::edit_link_interface()', 'edit_link_interface() called...', 'debug');
        require_once 'inc/classes/class_form2.inc.php';
        $form = new Form2($GLOBALS[PHP_SELF], $method, 'edit_link_interface');
        $fields = $this->link_form('Los&gt;&gt;', 'intern_link_edit', $id);
        $form->load_form($fields);
        $sql = '
				select
					' . TB_LINKS . '.id,
					ref_object_id,
					uri,
					ref_category_id,
					description,
					date_format(' . TB_OBJECT . '.date_create, "%d.%m.%Y %H:%i") as date_create_readable,
					' . TB_OBJECT . '.flag_public
				from
					' . TB_LINKS . ',
					' . TB_OBJECT . '
				where
					' . TB_OBJECT . '.id = ' . $id . '
					and
					' . TB_OBJECT . '.id = ' . TB_LINKS . '.ref_object_id
				order by
					date_create desc
				limit 10
			';
        $raw = $db->query($sql);
        if ($db->num_rows($raw)) {
            $current = $db->fetch_array($raw);
            $presets = array('uri' => $current[uri], 'description' => $current[description], 'flag_public' => $current[flag_public], 'ref_category_id' => $current[ref_category_id]);
            $form->load_presets($presets);
            $form->precheck_form();
            if (!$GLOBALS[submit]) {
                $form->set_precheck_error();
            }
            if ($form->is_form_error()) {
                $message .= $form->build_form();
                $width = '50%';
                $title = 'Link editieren';
            } else {
                $message = 'Der Link wird abgespeichert...';
                $link_data = array(0 => array('name' => 'flag_public', 'value' => $form->return_submitted_field('flag_public')));
                $this->update_tb_object($link_data);
                $link_data = array(0 => array('name' => 'uri', 'value' => trim($form->return_submitted_field('uri'))), 1 => array('name' => 'description', 'value' => htmlentities(trim($form->return_submitted_field('description')))), 2 => array('name' => 'ref_category_id', 'value' => $form->return_submitted_field('ref_category_id')));
                $title = 'Link gespeichert!';
                if ($db->update_row($current[id], TB_LINKS, $link_data)) {
                    $message .= '<b class=ok>OK</b>';
                } else {
                    $message .= '<b class=warning><br>Warnung</b>! Es wurden keine Datensätze geändert! Evtl. hast du gar nix geändert!...(siehe logfiles)';
                }
                $menu = array();
                $menu[0][text] = '&lt;&lt;Zur Link übersicht';
                $menu[0][link] = $GLOBALS[PHP_SELF] . '?action=intern_link';
                $form->form_shutdown();
            }
            $width = '50%';
        } else {
            $title = 'Fehler';
            $message = 'Whoups! Der ausgewählte Link wurde nicht gefunden... *urgs*';
            $width = '50%';
            $menu = array();
            $menu[0][text] = '&lt;&lt;Zur Link übersicht';
            $menu[0][link] = $GLOBALS[PHP_SELF] . '?action=intern_link';
        }
        return $page->dialog_box($title, $message, 0, $menu, $width);
    }
 $fields[$tmp++] = array('type' => 'separator', 'value' => '<b>Infos zum Termin</b>');
 $fields[$tmp] = array('name' => 'terminart', 'type' => 'select', 'title' => 'Termintyp', 'important' => 1, 'selections' => array(), 'attribs' => array(0 => array('name' => 'title', 'value' => 'Bitte den <b>Termintyp</b> auswählen!!'), 1 => array('name' => 'size', 'value' => '1')));
 for ($i = 0; $i < count($DATE_TYPES); $i++) {
     $fields[$tmp][selections][$i][title] = $DATE_TYPES[$i + 1][name];
     $fields[$tmp][selections][$i][value] = $i + 1;
 }
 $tmp++;
 $fields[$tmp++] = array('name' => 'flag_kueche', 'type' => 'checkbox', 'title' => 'Küchenrelevant:', 'important' => 0, 'selections' => array(0 => array('name' => 'value', 'value' => '1')), 'attribs' => array(0 => array('name' => 'title', 'value' => 'Wird bei diesem Termin Verpflegung durch die OV-Küche angefordert?')));
 $fields[$tmp++] = array('name' => 'kommentar', 'type' => 'textarea', 'title' => 'Kommentar:', 'important' => 1, 'attribs' => array(0 => array('name' => 'title', 'value' => 'Kurzer Kommentar worum es in dem Dienst geht!'), 1 => array('name' => 'cols', 'value' => '40'), 2 => array('name' => 'rows', 'value' => '10')));
 $fields[$tmp++] = array('type' => 'hidden', 'important' => 0, 'selections' => array(0 => array('value' => 'date_create', 'name' => 'action')));
 $fields[$tmp++] = array('type' => 'buttons', 'important' => 0, 'selections' => array(0 => array('value' => 'Termin anlegen&gt;&gt;', 'type' => 'submit', 'name' => 'submit'), 1 => array('value' => 'Reset', 'type' => 'reset', 'name' => 'reset')));
 $form->load_form($fields);
 // Formular laden
 $form->precheck_form();
 if (!$GLOBALS[submit]) {
     $form->set_precheck_error();
 }
 if ($form->is_form_error()) {
     $message = $form->build_form();
     $width = '60%';
 } else {
     // Fertig!!! Daten eintragen!!!!!
     $width = '50%';
     $date = new tb_termin();
     if (!$flag_kueche) {
         $flag_kueche = 0;
     }
     $date_data = array('date_begin' => datestring2unix($date_begin), 'date_end' => datestring2unix($date_end), 'flag_public' => $public, 'kommentar' => trim($kommentar), 'flag_edit' => 1, 'terminart' => $terminart, 'flag_kueche' => $flag_kueche);
     $last_id = $date->add_tb_termin($date_data);
     $message = 'Der Termin wurde gespeichert...';
     $message .= '<br>