Formatting
[memberdb.git] / include / members.php
index df11e84..92fcffc 100644 (file)
@@ -7,8 +7,7 @@ $DIRECTDEBIT_STATES = array(
     3  => 'SEPA Folgeeinzug'
 );
 
-/* DB functions {{{ */
-
+// DB functions
 function db_create_member($member)
 {
     unset($member['id']);
@@ -40,7 +39,7 @@ function db_get_member_with_id($member_id)
 }
 
 function db_get_next_free_member_number()
-{/*{{{*/
+{
     $row = db_select_single('SELECT MAX(number) AS number FROM `members`');
     if (!isset($row)) {
         return 2;
@@ -61,18 +60,13 @@ function db_get_next_free_member_number()
     return $number;
 }
 
-;/*}}}*/
-
-
 function db_get_member_with_number($member_number)
 {
     return db_select_single('SELECT * FROM `members` WHERE NUMBER=? LIMIT 1', [$member_number]);
 }
 
-/* }}} */
-
 function validate_member($userdata, &$dbdata, &$validation)
-{/*{{{*/
+{
     $fields = array(
         'id'               => 'number',
         'number'           => 'number',
@@ -113,8 +107,8 @@ function validate_member($userdata, &$dbdata, &$validation)
         }
         $dbdata[$name] = $userdata[$name];
     }
-//      ids must be equal
-//      number must be equal. if changed - check if free and allowed
+    // ids must be equal
+    // number must be equal. if changed - check if free and allowed
     if (isset($orig['id'])) {
         if ($dbdata['id'] != $orig['id']) {
             $validation[] = 'Irgendwas ist sehr sehr komisch.';
@@ -128,10 +122,10 @@ function validate_member($userdata, &$dbdata, &$validation)
         $validation[] = 'Die Mitgliedsnummer ist schon vergeben.';
     }
     return (count($validation) == 0);
-}/*}}}*/
+}
 
 function validate_member_number($member_number, $member_id = null)
-{/*{{{*/
+{
     $member = db_get_member_with_number($member_number);
 
     // theres no member with this number
@@ -145,10 +139,10 @@ function validate_member_number($member_number, $member_id = null)
     }
 
     return false;
-}/*}}}*/
+}
 
 function action_export_ibanhin()
-{/*{{{*/
+{
     $members = db_get_members();
     if (empty($members)) {
         return;
@@ -172,7 +166,7 @@ function action_export_ibanhin()
     <div id="password_popup" class="modal_window">
         <fieldset>
             <legend>Passwortabfrage</legend>
-            <?= html_password_field('Passwort', 'password') ?>
+            <?php echo html_password_field('Passwort', 'password') ?>
             <input class="submit" type="button" name="btn_export_ibanhin" value="IBAN-hin erzeugen"
                    onclick="export_ibanhin()"/>
             <input class="submit" type="button" name="btn_cancel" value="Abbrechen"
@@ -188,9 +182,7 @@ function action_export_ibanhin()
     </div>
 
     <script type="text/javascript">
-
-        var members = new Array(<?=join(",\n", array_map('json_encode', $members)) ?>);
-
+        var members = new Array(<?php echo join(",\n", array_map('json_encode', $members)) ?>);
 
         $(document).ready(function () {
             $('#password').keypress(function (event) {
@@ -201,26 +193,19 @@ function action_export_ibanhin()
             $('#btn_ibanhin').focus();
         });
 
-
-        function ask_for_password() {/*{{{*/
+        function ask_for_password() {
             modal_window_show($("#password_popup"));
             $("#password").focus();
             return;
         }
 
-        /*}}}*/
-
-        function cancel_ask_for_password() {/*{{{*/
+        function cancel_ask_for_password() {
             modal_window_hide();
             $("#btn_ibanhin").focus();
             return;
         }
 
-        /*}}}*/
-
-
-        function export_ibanhin() {/*{{{*/
-
+        function export_ibanhin() {
             var ibanhin_content = "";
 
             var password = $('#password').val();
@@ -258,35 +243,26 @@ function action_export_ibanhin()
                     }
                 }
 
-                $('#ibanhin_content').val(ibanhin_content);
-                $('#ibanhin_content').focus();
-                $('#ibanhin_content').select();
+                var iban_hin_content = $('#ibanhin_content');
+                iban_hin_content.val(ibanhin_content);
+                iban_hin_content.focus();
+                iban_hin_content.select();
 
             });
 
         }
 
-        /*}}}*/
-
-        function ibanhin_close() {/*{{{*/
+        function ibanhin_close() {
             modal_window_hide();
             $("#ibanhin_content").val('');
         }
-
-        /*}}}*/
-
-
     </script>
-
     <?php
-
-}/*}}}*/
-
+}
 
 function action_list_members()
-{/*{{{*/
+{
     $members = db_get_members();
-    $count = 0;
     $regular = 0;
     $patron = 0;
     $honorary = 0;
@@ -318,11 +294,11 @@ function action_list_members()
             }
             ?>
             <tr <?php if (empty($membership_info['is_member'])) : ?>class="inactive"<?php endif ?>>
-                <td><a href="<?= html_escape(link_to('view_member',
-                        array('id' => $member['id']))) ?>"><?= html_escape($member['number']) ?></a></td>
-                <td><?= html_escape($member['nickname']) ?></td>
-                <td><?= html_escape($member['firstname']) ?></td>
-                <td><?= html_escape($member['lastname']) ?></td>
+                <td><a href="<?php echo html_escape(link_to('view_member',
+                        array('id' => $member['id']))) ?>"><?php echo html_escape($member['number']) ?></a></td>
+                <td><?php echo html_escape($member['nickname']) ?></td>
+                <td><?php echo html_escape($member['firstname']) ?></td>
+                <td><?php echo html_escape($member['lastname']) ?></td>
             </tr>
         <?php endforeach ?>
     </table>
@@ -332,22 +308,22 @@ function action_list_members()
 endif;
     $count = $regular + $honorary + $patron;
     ?>
-    <p>Derzeit gibt es <?= $count ?> Vereinsmitglieder. Davon:
+    <p>Derzeit gibt es <?php echo $count ?> Vereinsmitglieder. Davon:
     <ul>
-        <li><?= $regular ?> ordentliche Mitglieder</li>
-        <li><?= $honorary ?> Ehrenmitglieder</li>
-        <li style="font-weight: bold;"><?= $regular + $honorary ?> stimmberechtigte Mitglieder</li>
-        <li><?= $patron ?> Fördermitglieder</li>
+        <li><?php echo $regular ?> ordentliche Mitglieder</li>
+        <li><?php echo $honorary ?> Ehrenmitglieder</li>
+        <li style="font-weight: bold;"><?php echo $regular + $honorary ?> stimmberechtigte Mitglieder</li>
+        <li><?php echo $patron ?> Fördermitglieder</li>
     </ul>
     </p>
-    <a href="<?= link_to('create_member') ?>">Neues Mitglied</a>
-    <a href="<?= link_to('export_email') ?>">E-Mail-Adressen</a>
-    <a href="<?= link_to('export_members') ?>">XLS Export</a>
+    <a href="<?php echo link_to('create_member') ?>">Neues Mitglied</a>
+    <a href="<?php echo link_to('export_email') ?>">E-Mail-Adressen</a>
+    <a href="<?php echo link_to('export_members') ?>">XLS Export</a>
     <?php
-}/*}}}*/
+}
 
 function action_view_member()
-{/*{{{*/
+{
     if (!isset($_REQUEST['id'])) {
         redirect(link_to());
     }
@@ -358,10 +334,10 @@ function action_view_member()
     form_member($member, true);
     action_list_events($member);
     action_create_event($member);
-}/*}}}*/
+}
 
 function action_create_member()
-{/*{{{*/
+{
     $member = array();
     $log_messages = array();
     if (isset($_POST['submit'])) {
@@ -386,10 +362,10 @@ function action_create_member()
         }
     }
     form_member($member, false, $log_messages);
-}/*}}}*/
+}
 
 function action_change_member()
-{/*{{{*/
+{
     if (!isset($_REQUEST['id'])) {
         redirect(link_to());
     }
@@ -418,11 +394,10 @@ function action_change_member()
         }
     }
     form_member($member, false, $log_messages);
-}/*}}}*/
-
+}
 
 function action_export_email()
-{/*{{{*/
+{
     $members = db_get_members();
     $first = true;
     ?>
@@ -431,13 +406,12 @@ function action_export_email()
     <?php foreach ($members as $member) : ?><?php $membership_info = fees_info_for_member($member['id'],
         time()); ?><?php if (!empty($membership_info['is_member'])) : ?><?php if (empty($member['email'])) {
         continue;
-    } ?><?php if ($first) : $first = false; else : ?>,<?php endif ?> <?= $member['email'] ?><?php endif ?><?php endforeach ?>
+    } ?><?php if ($first) : $first = false; else : ?>,<?php endif ?><?php echo $member['email'] ?><?php endif ?><?php endforeach ?>
 <?php else : ?>
     <p>Bisher gibt's noch keine Mitglieder.</p>
 <?php endif ?>
     <?php
-}/*}}}*/
-
+}
 
 function html_member_list_box($label, $name, $selected, $readonly = false, $id = null, $tag_params = '')
 {
@@ -452,15 +426,15 @@ function html_member_list_box($label, $name, $selected, $readonly = false, $id =
 }
 
 function form_member($member = array(), $readonly = false, $log_messages = array())
-{/*{{{*/
-
+{
     global $DIRECTDEBIT_STATES;
 
     $keys = db_get_crypto_keys();
     if (empty($keys)) {
         ?>
         <p class="error">
-            <strong>Achtung:</strong> Bitte zuerst <a href="<?= link_to('cryptography') ?>">Kryptographie einrichten</a>.
+            <strong>Achtung:</strong> Bitte zuerst <a href="<?php echo link_to('cryptography') ?>">Kryptographie
+                einrichten</a>.
         </p>
         <?php
         return;
@@ -484,21 +458,21 @@ function form_member($member = array(), $readonly = false, $log_messages = array
 <?php endif ?>
     <?php log_messages($log_messages); ?>
     <form action="" method="post" class="clearfix">
-        <?php if (isset($member['id']) && !$readonly) : ?><?= html_hidden_field('id', $member) ?><?php endif ?>
+        <?php if (isset($member['id']) && !$readonly) : ?><?php echo html_hidden_field('id', $member) ?><?php endif ?>
         <fieldset>
             <legend>Allgemein</legend>
-            <?= html_text_field('Mitgliedsnummer', 'number', $member, $readonly) ?>
+            <?php echo html_text_field('Mitgliedsnummer', 'number', $member, $readonly) ?>
             <?php if (!$readonly) : ?>
                 <small>Wird automatisch vergeben wenn leer.</small><?php endif ?>
-            <?= html_text_field('Nickname', 'nickname', $member, $readonly) ?>
-            <?= html_text_field('E-Mail', 'email', $member, $readonly) ?>
+            <?php echo html_text_field('Nickname', 'nickname', $member, $readonly) ?>
+            <?php echo html_text_field('E-Mail', 'email', $member, $readonly) ?>
         </fieldset>
         <fieldset id="bank_details">
             <legend>Bankverbindung</legend>
-            <?= html_text_field('Kontoinhaber', 'accountholder', $member, true) ?>
-            <?= html_text_field('Kontonummer/IBAN', 'accountnumber', $member, true) ?>
-            <?= html_text_field('Bankleitzahl/BIC', 'bankcode', $member, true) ?>
-            <?= html_text_field('Name der Bank', 'bankname', $member, true) ?>
+            <?php echo html_text_field('Kontoinhaber', 'accountholder', $member, true) ?>
+            <?php echo html_text_field('Kontonummer/IBAN', 'accountnumber', $member, true) ?>
+            <?php echo html_text_field('Bankleitzahl/BIC', 'bankcode', $member, true) ?>
+            <?php echo html_text_field('Name der Bank', 'bankname', $member, true) ?>
             <?php if (!isset($member['id'])) : ?>
                 <input class="submit" type="button" name="btn_bank_details" value="Bankverbindung erfassen"
                        onclick="bank_details_ask_pass()" id="btn_bank_details"/>
@@ -509,7 +483,7 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 <input class="submit" type="button" name="btn_bank_details" value="Bankverbindung &auml;ndern"
                        onclick="bank_details_ask_pass()" id="btn_bank_details"/>
             <?php endif ?>
-            <?= html_list_box('Beitragseinzug', 'directdebit', $DIRECTDEBIT_STATES, $member, $readonly) ?>
+            <?php echo html_list_box('Beitragseinzug', 'directdebit', $DIRECTDEBIT_STATES, $member, $readonly) ?>
             <?php
             if ((!isset($member['ddmandatesigdate'])) ||
                 ($member['ddmandatesigdate'] == '') ||
@@ -519,36 +493,36 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 $member['ddmandatesigdate'] = html_escape(format_date(db_date2unixtime($member['ddmandatesigdate'])));
             }
             ?>
-            <?= html_text_field('Mandatsunterschrift', 'ddmandatesigdate', $member, $readonly) ?>
+            <?php echo html_text_field('Mandatsunterschrift', 'ddmandatesigdate', $member, $readonly) ?>
         </fieldset>
         <fieldset style="clear: left;">
             <legend>Anschrift</legend>
-            <?= html_text_field('Vorname', 'firstname', $member, $readonly) ?>
-            <?= html_text_field('Nachname', 'lastname', $member, $readonly) ?>
-            <?= html_text_field('Straße', 'street', $member, $readonly) ?>
-            <?= html_text_field('Hausnummer', 'housenumber', $member, $readonly) ?>
-            <?= html_text_field('PLZ', 'postcode', $member, $readonly) ?>
-            <?= html_text_field('Ort', 'city', $member, $readonly) ?>
-            <?= html_text_field('Land', 'country', $member, $readonly) ?>
+            <?php echo html_text_field('Vorname', 'firstname', $member, $readonly) ?>
+            <?php echo html_text_field('Nachname', 'lastname', $member, $readonly) ?>
+            <?php echo html_text_field('Straße', 'street', $member, $readonly) ?>
+            <?php echo html_text_field('Hausnummer', 'housenumber', $member, $readonly) ?>
+            <?php echo html_text_field('PLZ', 'postcode', $member, $readonly) ?>
+            <?php echo html_text_field('Ort', 'city', $member, $readonly) ?>
+            <?php echo html_text_field('Land', 'country', $member, $readonly) ?>
         </fieldset>
         <fieldset>
             <legend>Sonstiges</legend>
-            <?= html_text_field('Telefon', 'phone', $member, $readonly) ?>
-            <?= html_text_field('Fax', 'fax', $member, $readonly) ?>
-            <?= html_text_field('Handy', 'mobile', $member, $readonly) ?>
-            <?= html_text_field('Jabber', 'jabber', $member, $readonly) ?>
-            <?= html_text_field('ICQ', 'icq', $member, $readonly) ?>
-            <?= html_text_field('MSN', 'msn', $member, $readonly) ?>
-            <?= html_text_field('AIM', 'aim', $member, $readonly) ?>
-            <?= html_text_field('Skype', 'skype', $member, $readonly) ?>
-            <?= html_text_field('Website', 'url', $member, $readonly) ?>
-            <?= html_text_field('Twitter', 'twitter', $member, $readonly) ?>
+            <?php echo html_text_field('Telefon', 'phone', $member, $readonly) ?>
+            <?php echo html_text_field('Fax', 'fax', $member, $readonly) ?>
+            <?php echo html_text_field('Handy', 'mobile', $member, $readonly) ?>
+            <?php echo html_text_field('Jabber', 'jabber', $member, $readonly) ?>
+            <?php echo html_text_field('ICQ', 'icq', $member, $readonly) ?>
+            <?php echo html_text_field('MSN', 'msn', $member, $readonly) ?>
+            <?php echo html_text_field('AIM', 'aim', $member, $readonly) ?>
+            <?php echo html_text_field('Skype', 'skype', $member, $readonly) ?>
+            <?php echo html_text_field('Website', 'url', $member, $readonly) ?>
+            <?php echo html_text_field('Twitter', 'twitter', $member, $readonly) ?>
         </fieldset>
         <?php if (!$readonly) : ?>
             <input class="submit" type="submit" name="submit" value="Speichern"/>
         <?php else : ?>
             <br style="clear: left;"/>
-            <a href="<?= html_escape(link_to('change_member', array('id' => $member['id']))) ?>">Mitglied
+            <a href="<?php echo html_escape(link_to('change_member', array('id' => $member['id']))) ?>">Mitglied
                 &auml;ndern</a>
         <?php endif ?>
     </form>
@@ -558,7 +532,7 @@ function form_member($member = array(), $readonly = false, $log_messages = array
     <div id="password_popup2" class="modal_window">
         <fieldset>
             <legend>Passwortabfrage</legend>
-            <?= html_password_field('Passwort', 'password2') ?>
+            <?php echo html_password_field('Passwort', 'password2') ?>
             <input class="submit" type="button" name="btn_import_qrcode2" value="QR-Code importieren"
                    onclick="import_qrcode()"/>
             <input class="submit" type="button" name="btn_cancel_import_qrcode" value="Abbrechen"
@@ -577,7 +551,7 @@ function form_member($member = array(), $readonly = false, $log_messages = array
     <div id="password_popup" class="modal_window">
         <fieldset>
             <legend>Passwortabfrage</legend>
-            <?= html_password_field('Passwort', 'password1') ?>
+            <?php echo html_password_field('Passwort', 'password1') ?>
             <input class="submit" type="button" name="btn_decrypt_bank_details" value="Bankdaten entschl&uuml;sseln"
                    onclick="decrypt_bank_details()"/>
             <input class="submit" type="button" name="btn_cancel" value="Abbrechen"
@@ -587,10 +561,10 @@ function form_member($member = array(), $readonly = false, $log_messages = array
     <div id="bank_detail_popup" class="modal_window">
         <fieldset>
             <legend>Bankverbindung</legend>
-            <?= html_text_field('Kontoinhaber', 'tmp_accountholder', $member, $readonly) ?>
-            <?= html_text_field('Kontonummer/IBAN', 'tmp_accountnumber', $member, $readonly) ?>
-            <?= html_text_field('Bankleitzahl/BIC', 'tmp_bankcode', $member, $readonly) ?>
-            <?= html_text_field('Name der Bank', 'tmp_bankname', $member, $readonly) ?>
+            <?php echo html_text_field('Kontoinhaber', 'tmp_accountholder', $member, $readonly) ?>
+            <?php echo html_text_field('Kontonummer/IBAN', 'tmp_accountnumber', $member, $readonly) ?>
+            <?php echo html_text_field('Bankleitzahl/BIC', 'tmp_bankcode', $member, $readonly) ?>
+            <?php echo html_text_field('Name der Bank', 'tmp_bankname', $member, $readonly) ?>
             <?php if (!isset($member['id'])) : ?>
                 <input class="submit" type="button" name="btn_bank_details_save" value="&Uuml;bernehmen"
                        onclick="bank_details_save()"/>
@@ -608,8 +582,6 @@ function form_member($member = array(), $readonly = false, $log_messages = array
         </fieldset>
     </div>
     <script type="text/javascript">
-
-
         var the_masterkey;
 
         $(document).ready(function () {
@@ -643,42 +615,32 @@ function form_member($member = array(), $readonly = false, $log_messages = array
             <?php endif ?>
         });
 
-        function bank_details_ask_pass() {/*{{{*/
+        function bank_details_ask_pass() {
             modal_window_show($("#password_popup"));
             $("#password1").focus();
             return;
         }
 
-        /*}}}*/
-
-
-        function import_qrcode_ask_pass() {/*{{{*/
+        function import_qrcode_ask_pass() {
             modal_window_show($("#password_popup2"));
             $("#password2").focus();
             return;
         }
 
-        /*}}}*/
-
-        function cancel_change_bank_details() {/*{{{*/
+        function cancel_change_bank_details() {
             modal_window_hide();
             $("#btn_bank_details").focus();
             $("#password1").val('');
             return;
         }
 
-        /*}}}*/
-
-        function cancel_import_qrcode() {/*{{{*/
+        function cancel_import_qrcode() {
             modal_window_hide();
             $("#password2").val('');
             return;
         }
 
-        /*}}}*/
-
-        function decrypt_bank_details() {/*{{{*/
-
+        function decrypt_bank_details() {
             var password = $('#password1').val();
             $("#password1").val('');
 
@@ -712,13 +674,9 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 }
                 the_masterkey = masterkey; // cache masterkey until popup is closed
             });
-
         }
 
-        /*}}}*/
-
-        function import_qrcode() {/*{{{*/
-
+        function import_qrcode() {
             var password = $('#password2').val();
             $("#password2").val('');
 
@@ -728,13 +686,9 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 modal_window_replace($("#qrcode_popup"));
                 the_masterkey = masterkey; // cache masterkey until popup is closed
             });
-
         }
 
-        /*}}}*/
-
-        function qrcode_close() {/*{{{*/
-
+        function qrcode_close() {
             modal_window_hide();
 
             var qrcode_content = $('#qrcode_content').val();
@@ -761,7 +715,6 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 // XXX amount unused - wurde erst am 4.5. ergänzt, war vorher leer.
             }
 
-
             // 4.2 Encrypt/Decrypt data using AES with masterkey
             if (accountholder != "") {
                 $('#accountholder').val(Crypto.AES.encrypt(Crypto.charenc.UTF8.stringToBytes(accountholder), the_masterkey));
@@ -784,13 +737,9 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 $('#bankname').val('');
             }
             the_masterkey = '';
-
         }
 
-        /*}}}*/
-
-        function bank_details_save() {/*{{{*/
-
+        function bank_details_save() {
             modal_window_hide();
 
             var accountholder = $('#tmp_accountholder').val();
@@ -826,13 +775,9 @@ function form_member($member = array(), $readonly = false, $log_messages = array
                 $('#bankname').val('');
             }
             the_masterkey = '';
-
         }
 
-        /*}}}*/
-
-        function bank_details_cancel() {/*{{{*/
-
+        function bank_details_cancel() {
             modal_window_hide();
 
             $("#tmp_accountholder").val('');
@@ -842,9 +787,6 @@ function form_member($member = array(), $readonly = false, $log_messages = array
 
             the_masterkey = '';
         }
-
-        /*}}}*/
-
     </script>
     <?php
-}/*}}}*/
+}