2009-10-22 08:23:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
2009-10-22 08:29:01 +00:00
|
|
|
/*
|
|
|
|
|
This file is part of myTinyTodo.
|
2010-02-10 11:27:44 +00:00
|
|
|
(C) Copyright 2009-2010 Max Pozdeev <maxpozdeev@gmail.com>
|
2009-10-22 08:29:01 +00:00
|
|
|
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-10-22 08:23:24 +00:00
|
|
|
require_once('./init.php');
|
|
|
|
|
|
2010-02-06 17:35:39 +00:00
|
|
|
$lang = Lang::instance();
|
2009-12-15 14:49:32 +00:00
|
|
|
|
2009-10-22 08:23:24 +00:00
|
|
|
if($needAuth && !is_logged())
|
|
|
|
|
{
|
2010-06-08 14:34:58 +00:00
|
|
|
die("Access denied!<br/> Disable password protection or Log in.");
|
2009-10-22 08:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isset($_POST['save']))
|
|
|
|
|
{
|
|
|
|
|
stop_gpc($_POST);
|
|
|
|
|
$t = array();
|
|
|
|
|
$langs = getLangs();
|
|
|
|
|
Config::$params['lang']['options'] = array_keys($langs);
|
2009-11-30 17:59:16 +00:00
|
|
|
Config::set('lang', _post('lang'));
|
|
|
|
|
if(isset($_POST['password']) && $_POST['password'] != '') Config::set('password', $_POST['password']);
|
|
|
|
|
elseif(!_post('allowpassword')) Config::set('password', '');
|
|
|
|
|
Config::set('smartsyntax', (int)_post('smartsyntax'));
|
|
|
|
|
Config::set('autotz', (int)_post('autotz'));
|
|
|
|
|
Config::set('autotag', (int)_post('autotag'));
|
|
|
|
|
Config::set('session', _post('session'));
|
|
|
|
|
Config::set('firstdayofweek', (int)_post('firstdayofweek'));
|
|
|
|
|
Config::set('duedateformat', (int)_post('duedateformat'));
|
|
|
|
|
Config::set('clock', (int)_post('clock'));
|
|
|
|
|
Config::set('dateformat', _post('dateformat'));
|
|
|
|
|
Config::set('dateformatshort', _post('dateformatshort'));
|
|
|
|
|
Config::set('title', trim(_post('title')));
|
2010-02-10 17:28:31 +00:00
|
|
|
Config::set('showdate', (int)_post('showdate'));
|
2009-11-30 17:59:16 +00:00
|
|
|
Config::save();
|
2009-10-22 08:23:24 +00:00
|
|
|
$t['saved'] = 1;
|
|
|
|
|
echo json_encode($t);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _c($key)
|
|
|
|
|
{
|
2009-11-30 17:59:16 +00:00
|
|
|
return Config::get($key);
|
2009-10-22 08:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLangs()
|
|
|
|
|
{
|
2010-02-06 17:35:39 +00:00
|
|
|
if (!$h = opendir(MTTPATH. 'lang')) return false;
|
2009-10-22 08:23:24 +00:00
|
|
|
$a = array();
|
|
|
|
|
while(false !== ($file = readdir($h)))
|
|
|
|
|
{
|
|
|
|
|
if(preg_match('/(.+)\.php$/', $file, $m) && $file != 'class.default.php') {
|
|
|
|
|
$a[$m[1]] = $m[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir($h);
|
|
|
|
|
return $a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectOptions($a, $value, $default=null)
|
|
|
|
|
{
|
|
|
|
|
if(!$a) return '';
|
|
|
|
|
$s = '';
|
|
|
|
|
if($default !== null && !isset($a[$value])) $value = $default;
|
|
|
|
|
foreach($a as $k=>$v) {
|
2010-06-08 14:34:58 +00:00
|
|
|
$s .= '<option value="'.htmlspecialchars($k).'" '.($k===$value?'selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
|
2009-10-22 08:23:24 +00:00
|
|
|
}
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
2010-08-18 08:09:18 +00:00
|
|
|
<div><a href="#" class="mtt-back-button"><?php _e('go_back');?></a></div>
|
|
|
|
|
|
2009-12-15 14:49:32 +00:00
|
|
|
<h3><?php _e('set_header');?></h3>
|
2009-10-22 08:23:24 +00:00
|
|
|
|
|
|
|
|
<div id="settings_msg" style="display:none"></div>
|
|
|
|
|
|
2010-06-08 14:34:58 +00:00
|
|
|
<form id="settings_form" method="post" action="settings.php">
|
2009-10-22 08:23:24 +00:00
|
|
|
|
|
|
|
|
<table class="mtt-settings-table">
|
|
|
|
|
|
2009-11-04 18:45:28 +00:00
|
|
|
<tr>
|
2010-06-08 14:34:58 +00:00
|
|
|
<th><?php _e('set_title');?>:<br/><span class="descr"><?php _e('set_title_descr');?></span></th>
|
|
|
|
|
<td> <input name="title" value="<?php echo htmlspecialchars(_c('title'));?>" class="in350" /> </td>
|
2009-11-04 18:45:28 +00:00
|
|
|
</tr>
|
|
|
|
|
|
2009-10-22 08:23:24 +00:00
|
|
|
<tr>
|
2009-12-15 14:49:32 +00:00
|
|
|
<th><?php _e('set_language');?>:</th>
|
2010-06-08 14:34:58 +00:00
|
|
|
<td> <select name="lang"><?php $langs = getLangs(); echo selectOptions($langs, _c('lang')); ?></select> </td>
|
2009-10-22 08:23:24 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2009-12-15 14:49:32 +00:00
|
|
|
<th><?php _e('set_protection');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<label><input type="radio" name="allowpassword" value="1" <?php if(_c('password')!='') echo 'checked="checked"'; ?> onclick='$(this.form).find("input[name=password]").attr("disabled",false)' /><?php _e('set_enabled');?></label> <br/>
|
|
|
|
|
<label><input type="radio" name="allowpassword" value="0" <?php if(_c('password')=='') echo 'checked="checked"'; ?> onclick='$(this.form).find("input[name=password]").attr("disabled","disabled")' /><?php _e('set_disabled');?></label> <br/>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-06-08 14:34:58 +00:00
|
|
|
<th><?php _e('set_newpass');?>:<br/><span class="descr"><?php _e('set_newpass_descr');?></span></th>
|
|
|
|
|
<td> <input type="password" name="password" <?php if(_c('password')=='') echo "disabled"; ?> /> </td>
|
2009-10-22 08:23:24 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-06-08 14:34:58 +00:00
|
|
|
<th><?php _e('set_smartsyntax');?>:<br/><span class="descr"><?php _e('set_smartsyntax_descr');?></span></th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<label><input type="radio" name="smartsyntax" value="1" <?php if(_c('smartsyntax')) echo 'checked="checked"'; ?> /><?php _e('set_enabled');?></label> <br/>
|
|
|
|
|
<label><input type="radio" name="smartsyntax" value="0" <?php if(!_c('smartsyntax')) echo 'checked="checked"'; ?> /><?php _e('set_disabled');?></label>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-06-08 14:34:58 +00:00
|
|
|
<th><?php _e('set_autotz');?>:<br/><span class="descr"><?php _e('set_autotz_descr');?></span></th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<label><input type="radio" name="autotz" value="1" <?php if(_c('autotz')) echo 'checked="checked"'; ?> /><?php _e('set_enabled');?></label> <br/>
|
|
|
|
|
<label><input type="radio" name="autotz" value="0" <?php if(!_c('autotz')) echo 'checked="checked"'; ?> /><?php _e('set_disabled');?></label>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-06-08 14:34:58 +00:00
|
|
|
<th><?php _e('set_autotag');?>:<br/><span class="descr"><?php _e('set_autotag_descr');?></span></th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<label><input type="radio" name="autotag" value="1" <?php if(_c('autotag')) echo 'checked="checked"'; ?> /><?php _e('set_enabled');?></label> <br/>
|
|
|
|
|
<label><input type="radio" name="autotag" value="0" <?php if(!_c('autotag')) echo 'checked="checked"'; ?> /><?php _e('set_disabled');?></label>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-02-10 17:28:31 +00:00
|
|
|
<th><?php _e('set_sessions');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<label><input type="radio" name="session" value="default" <?php if(_c('session')=='default') echo 'checked="checked"'; ?> /><?php _e('set_sessions_php');?></label> <br/>
|
|
|
|
|
<label><input type="radio" name="session" value="files" <?php if(_c('session')=='files') echo 'checked="checked"'; ?> /><?php _e('set_sessions_files');?></label> <span class="descr">(<mytinytodo_dir>/tmp/sessions)</span>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-02-10 17:28:31 +00:00
|
|
|
<th><?php _e('set_firstdayofweek');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<select name="firstdayofweek"><?php echo selectOptions(__('days_long'), _c('firstdayofweek')); ?></select>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-02-10 17:28:31 +00:00
|
|
|
<th><?php _e('set_duedate');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<select name="duedateformat"><?php echo selectOptions(array(1=>'yyyy-mm-dd ('.date('Y-m-d').')', 2=>'m/d/yyyy ('.date('n/j/Y').')', 3=>'dd.mm.yyyy ('.date('d.m.Y').')', 4=>'dd/mm/yyyy ('.date('d/m/Y').')'), _c('duedateformat')); ?></select>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-02-10 17:28:31 +00:00
|
|
|
<th><?php _e('set_date');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<input name="dateformat" value="<?php echo htmlspecialchars(_c('dateformat'));?>" />
|
|
|
|
|
<select onchange="if(this.value!=0) this.form.dateformat.value=this.value;">
|
2009-12-15 14:49:32 +00:00
|
|
|
<?php echo selectOptions(array('F j, Y'=>formatTime('F j, Y'), 'M d, Y'=>formatTime('M d, Y'), 'j M Y'=>formatTime('j M Y'), 'd F Y'=>formatTime('d F Y'),
|
|
|
|
|
'n/j/Y'=>formatTime('n/j/Y'), 'd.m.Y'=>formatTime('d.m.Y'), 'j. F Y'=>formatTime('j. F Y'), 0=>'Custom'), _c('dateformat'), 0); ?>
|
2010-06-08 14:34:58 +00:00
|
|
|
</select>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-02-10 17:28:31 +00:00
|
|
|
<th><?php _e('set_shortdate');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<input name="dateformatshort" value="<?php echo htmlspecialchars(_c('dateformatshort'));?>" />
|
|
|
|
|
<select onchange="if(this.value!=0) this.form.dateformatshort.value=this.value;">
|
2009-12-15 14:49:32 +00:00
|
|
|
<?php echo selectOptions(array('M d'=>formatTime('M d'), 'j M'=>formatTime('j M'), 'n/j'=>formatTime('n/j'), 'd.m'=>formatTime('d.m'), 0=>'Custom'), _c('dateformatshort'), 0); ?>
|
2010-06-08 14:34:58 +00:00
|
|
|
</select>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
2010-02-10 17:28:31 +00:00
|
|
|
<th><?php _e('set_clock');?>:</th>
|
2009-10-22 08:23:24 +00:00
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<select name="clock"><?php echo selectOptions(array(12=>__('set_12hour').' ('.date('g:i A').')', 24=>__('set_24hour').' ('.date('H:i').')'), _c('clock')); ?></select>
|
2009-10-22 08:23:24 +00:00
|
|
|
</td></tr>
|
|
|
|
|
|
2010-02-10 17:28:31 +00:00
|
|
|
<tr>
|
|
|
|
|
<th><?php _e('set_showdate');?>:</th>
|
|
|
|
|
<td>
|
2010-06-08 14:34:58 +00:00
|
|
|
<label><input type="radio" name="showdate" value="1" <?php if(_c('showdate')) echo 'checked="checked"'; ?> /><?php _e('set_enabled');?></label> <br/>
|
|
|
|
|
<label><input type="radio" name="showdate" value="0" <?php if(!_c('showdate')) echo 'checked="checked"'; ?> /><?php _e('set_disabled');?></label>
|
2010-02-10 17:28:31 +00:00
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
2009-10-22 08:23:24 +00:00
|
|
|
<tr><td colspan="2" class="form-buttons">
|
|
|
|
|
|
2010-06-08 14:34:58 +00:00
|
|
|
<input type="submit" value="<?php _e('set_submit');?>" />
|
2010-08-18 08:09:18 +00:00
|
|
|
<input type="button" class="mtt-back-button" value="<?php _e('set_cancel');?>" />
|
2009-10-22 08:23:24 +00:00
|
|
|
|
|
|
|
|
</td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
</form>
|