Location: PHPKode > projects > PhpTimeClock > phptimeclock-2.0.0rc2/plugins/Punch_Board/edit.php
<?php
/***************************************************************************
 * Copyright (C) 2009 by                                                   *
 * PhpTimeClock team respective developers. http://www.PhpTimeClock.com/   *
 *                                                                         *
 * This program is free software: you can redistribute it and/or modify    *
 * it under the terms of the GNU Affero General Public License as          *
 * published by the Free Software Foundation, either version 3 of the      *
 * License, or (at your option) any later version.                         *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU Affero General Public License for more details.                     *
 *                                                                         *
 * You should have received a copy of the                                  *
 * GNU Affero General Public License along with this program.              *
 * If not, see http://www.gnu.org/licenses/.                               *
 ***************************************************************************/

function plugin_options() {
    $options = array();

    $options[] = array(OPTION_INFORMATION, 'Punch Board Display Options', 'These options change the behaviour for the punch board.');
    $options['show_department_times_only'] = 'show_department_times_only';
    $options['display_all_punches'] = 'display_all_punches';
    $options['display_name'] = 'display_name';
    $options['display_status'] = 'display_status';
    $options['display_status_option'] = 'display_status_option';
    $options['display_date'] = 'display_date';
    $options['display_time'] = 'display_time';
    $options['display_department'] = 'display_department';
    $options['display_notes'] = 'display_notes';
    $options['display_header'] = 'display_header';
    return $options;
}

function plugin_option_descriptions() {
    $options = array();

    $options[] = OPTION_INFORMATION;
    $options['show_department_times_only'] = 'Only display the punches from departments the current user is a member in?';
    $options['display_all_punches'] = 'Only display the activity for the current day\'s punches?';
    $options['display_name'] = 'Display the user who made the punch?';
    $options['display_status'] = 'Display the user punch status name?';
    $options['display_status_option'] = 'Method of displaying the punch status name. Image displays an image the punch status type only. Text displays the name of the punch status name only. Both will display the image and text of the punch status.';
    $options['display_date'] = 'Display the date of the punch?';
    $options['display_time'] = 'Display the time of the punch?';
    $options['display_department'] = 'Display the office and department the user punched into?';
    $options['display_notes'] = 'Display any notes entered for the punch?';
    $options['display_header'] = 'Display title header?';
    return $options;
}

function plugin_option_values() {
    if (@include_once PLUGIN_CONFIGURATION_FILE_NAME) {
        $options = array();

        $options[] = OPTION_INFORMATION;
        $options['show_department_times_only'] = $show_department_times_only;
        $options['display_all_punches'] = $display_all_punches;
        $options['display_name'] = $display_name;
        $options['display_status'] = $display_status;
        $options['display_status_option'] = $display_status_option;
        $options['display_date'] = $display_date;
        $options['display_time'] = $display_time;
        $options['display_department'] = $display_department;
        $options['display_notes'] = $display_notes;
        $options['display_header'] = $display_header;
        return $options;
    } else {
        return plugin_option_defaults();
    }
}

function plugin_option_defaults() {
    $options = array();

    $options[] = OPTION_INFORMATION;
    $options['show_department_times_only'] = OPTION_NO;
    $options['display_all_punches'] = OPTION_NO;
    $options['display_name'] = OPTION_YES;
    $options['display_status'] = OPTION_YES;
    $options['display_status_option'] = 'Both';
    $options['display_date'] = OPTION_YES;
    $options['display_time'] = OPTION_YES;
    $options['display_department'] = OPTION_NO;
    $options['display_notes'] = OPTION_YES;
    $options['display_header'] = OPTION_YES;
    return $options;
}

function plugin_option_field_types() {
    $options = array();

    $options[] = OPTION_INFORMATION;
    $options['show_department_times_only'] = 'radio';
    $options['display_all_punches'] = 'radio';
    $options['display_name'] = 'radio';
    $options['display_status'] = 'radio';
    $options['display_status_option'] = 'radio';
    $options['display_date'] = 'radio';
    $options['display_time'] = 'radio';
    $options['display_department'] = 'radio';
    $options['display_notes'] = 'radio';
    $options['display_header'] = 'radio';
    return $options;
}

function plugin_option_choices() {
    $options = array();

    $options[] = OPTION_INFORMATION;
    $options['show_department_times_only'] = array(OPTION_YES, OPTION_NO);
    $options['display_all_punches'] = array(OPTION_YES, OPTION_NO);
    $options['display_name'] = array(OPTION_YES, OPTION_NO);
    $options['display_status'] = array(OPTION_YES, OPTION_NO);
    $options['display_status_option'] = array('Image', 'Text', 'Both');
    $options['display_date'] = array(OPTION_YES, OPTION_NO);
    $options['display_time'] = array(OPTION_YES, OPTION_NO);
    $options['display_department'] = array(OPTION_YES, OPTION_NO);
    $options['display_notes'] = array(OPTION_YES, OPTION_NO);
    $options['display_header'] = array(OPTION_YES, OPTION_NO);
    return $options;
}

function plugin_options_validate($options) {
    $valid_result = true;

    foreach ($options as $option => $option_value) {
        if ('show_department_times_only' == $option) {
            if (empty($option_value)) {
                output_error_message('Show department times only on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Show department times only on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_all_punches' == $option) {
            if (empty($option_value)) {
                output_error_message('Display all punches value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display all punches contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_name' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s name on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display user\'s name on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_status' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s status on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display user\'s status on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_status_option' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s status options on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != 'Image') and ($option_value != 'Text') and ($option_value != 'Both')) {
                output_error_message('User-name drop-down only contains invalid settings! Must be set to either \'Image\', \'Text\', or \'Both\'.');
                $valid_result = false;
            }
        } elseif ('display_date' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s punch date on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display user\'s punch date on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_time' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s punch time on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display user\'s punch time on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_department' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s punch department on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display user\'s punch department on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_notes' == $option) {
            if (empty($option_value)) {
                output_error_message('Display user\'s punch notes on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display user\'s punch notes on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } elseif ('display_header' == $option) {
            if (empty($option_value)) {
                output_error_message('Display header on punch display value is not set!');
                $valid_result = false;
            } elseif (($option_value != OPTION_YES) and ($option_value != OPTION_NO)) {
                output_error_message('Display header on punch display contains invalid settings! Must be set to either \'Yes\' or \'No\'.');
                $valid_result = false;
            }
        } else {
            output_error_message('Invalid option supplied! '.$option.' is not recognised as a valid option.');
            $valid_result = false;
        }
    }
    return $valid_result;
}

function write_plugin_options($file_pointer, $plugin_options) {
    return write_configuration_options($file_pointer, $plugin_options);
}

?>
Return current item: PhpTimeClock