<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Version details
 *
 * @package    theme_oficial
 * @copyright  2015-2016 Jeremy Hopkins (Coventry University)
 * @copyright  2015-2016 Fernando Acedo (3-bits.com)
 * @copyright  2015 David Bezemer <info@davidbezemer.nl>, www.davidbezemer.nl
 * @copyright  2016 COMETE (Paris Ouest University)
 * @author     David Bezemer <info@davidbezemer.nl>, Bas Brands <bmbrands@gmail.com>, Gavin Henrick <gavin@lts.ie>, COMETE
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */

defined('MOODLE_INTERNAL') || die;

// Analytics section.
$temp = new admin_settingpage('theme_oficial_analytics', get_string('analyticssettings', 'theme_oficial'));
if ($ADMIN->fulltree) {
    $temp->add(new admin_setting_heading('theme_oficial_analytics', get_string('analyticssettingsheading', 'theme_oficial'),
        format_text(get_string('analyticssettingsdesc', 'theme_oficial'), FORMAT_MARKDOWN)));

    // Google Analytics Section.
    $name = 'theme_oficial/googleanalyticssettings';
    $heading = get_string('googleanalyticssettings', 'theme_oficial');
    $setting = new admin_setting_heading($name, $heading, '');
    $temp->add($setting);

    // Enable Google analytics.
    $name = 'theme_oficial/enableanalytics';
    $title = get_string('enableanalytics', 'theme_oficial');
    $description = get_string('enableanalyticsdesc', 'theme_oficial');
    $default = false;
    $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
    $temp->add($setting);

    // Anonymize Google analytics.
    $name = 'theme_oficial/anonymizega';
    $title = get_string('anonymizega', 'theme_oficial');
    $description = get_string('anonymizegadesc', 'theme_oficial');
    $default = true;
    $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
    $temp->add($setting);

    // Number of Analytics entries.
    $name = 'theme_oficial/analyticscount';
    $title = get_string('analyticscount', 'theme_oficial');
    $description = get_string('analyticscountdesc', 'theme_oficial');
    $default = THEME_OFICIAL_DEFAULT_ANALYTICSCOUNT;
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices0to12);
    $temp->add($setting);

    // If we don't have an analyticscount yet, default to the preset.
    $analyticscount = get_config('theme_oficial', 'analyticscount');
    if (!$analyticscount) {
        $alertcount = THEME_OFICIAL_DEFAULT_ANALYTICSCOUNT;
    }

    for ($analyticsindex = 1; $analyticsindex <= $analyticscount; $analyticsindex ++) {
        $name = 'theme_oficial/analyticstext' . $analyticsindex;
        $title = get_string('analyticstext', 'theme_oficial');
        $description = get_string('analyticstextdesc', 'theme_oficial');
        $default = '';
        $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_RAW);
        $temp->add($setting);

        $name = 'theme_oficial/analyticsprofilefield' . $analyticsindex;
        $title = get_string('analyticsprofilefield', 'theme_oficial');
        $description = get_string('analyticsprofilefielddesc', 'theme_oficial');
        $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_RAW);
        $temp->add($setting);
    }

    // Piwik Analytics Section.
    $name = 'theme_oficial/piwiksettings';
    $heading = get_string('piwiksettings', 'theme_oficial');
    $setting = new admin_setting_heading($name, $heading, '');
    $temp->add($setting);

    // Enable Piwik analytics.
    $name = 'theme_oficial/piwikenabled';
    $title = get_string('piwikenabled', 'theme_oficial');
    $description = get_string('piwikenableddesc', 'theme_oficial');
    $default = false;
    $temp->add(new admin_setting_configcheckbox($name, $title, $description, $default, true, false));

    // Piwik site ID.
    $name = 'theme_oficial/piwiksiteid';
    $title = get_string('piwiksiteid', 'theme_oficial');
    $description = get_string('piwiksiteiddesc', 'theme_oficial');
    $default = '1';
    $temp->add(new admin_setting_configtext($name, $title, $description, $default));

    // Piwik image track.
    $name = 'theme_oficial/piwikimagetrack';
    $title = get_string('piwikimagetrack', 'theme_oficial');
    $description = get_string('piwikimagetrackdesc', 'theme_oficial');
    $default = true;
    $temp->add(new admin_setting_configcheckbox($name, $title, $description, $default, true, false));

    // Piwik site URL.
    $name = 'theme_oficial/piwiksiteurl';
    $title = get_string('piwiksiteurl', 'theme_oficial');
    $description = get_string('piwiksiteurldesc', 'theme_oficial');
    $default = '';
    $temp->add(new admin_setting_configtext($name, $title, $description, $default));

    // Enable Piwik admins tracking.
    $name = 'theme_oficial/piwiktrackadmin';
    $title = get_string('piwiktrackadmin', 'theme_oficial');
    $description = get_string('piwiktrackadmindesc', 'theme_oficial');
    $default = false;
    $temp->add(new admin_setting_configcheckbox($name, $title, $description, $default, true, false));
}
$ADMIN->add('theme_oficial', $temp);
