Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
7018f9eb
Commit
7018f9eb
authored
Nov 14, 2006
by
Nigel McNie
Committed by
Nigel McNie
Nov 14, 2006
Browse files
Merge with
git+ssh://git.catalyst.net.nz/var/git/mahara.git#master
parents
4dbbefea
20db2aad
Changes
7
Hide whitespace changes
Inline
Side-by-side
htdocs/admin/editmenu.php
View file @
7018f9eb
...
...
@@ -256,15 +256,16 @@ function setmenu(menu) {
var
pub
=
get_string
(
'loggedoutmenu'
);
var
priv
=
get_string
(
'loggedinmenu'
);
if
(
menu
==
'public'
)
{
priv
=
A
({
'href'
:
'
#
'
},
priv
);
priv
.
onclick
=
function
(
e
)
{
stop
(
e
);
setmenu
(
'private'
);};
priv
=
A
({
'href'
:
''
},
priv
);
priv
.
onclick
=
function
()
{
return
setmenu
(
'private'
);};
}
else
{
pub
=
A
({
'href'
:
'
#
'
},
pub
);
pub
.
onclick
=
function
(
e
)
{
stop
(
e
);
setmenu
(
'public'
);};
pub
=
A
({
'href'
:
''
},
pub
);
pub
.
onclick
=
function
()
{
return
setmenu
(
'public'
);};
}
replaceChildNodes
(
$
(
'menuselect'
),
[
pub
,
priv
]);
getitems
();
return
false
;
}
var
selectedmenu
=
'public'
;
...
...
htdocs/admin/editsitepage.php
View file @
7018f9eb
...
...
@@ -91,9 +91,11 @@ function editsitepage_submit($values) {
exit
;
}
$js
=
array
();
if
(
use_html_editor
())
{
array_unshift
(
$js
,
'tinymce'
);
$js
=
array
(
'tinymce'
);
}
else
{
$js
=
array
();
}
$ijs
=
<<<
EOJS
...
...
htdocs/admin/options/index.php
View file @
7018f9eb
...
...
@@ -29,9 +29,111 @@ define('ADMIN',1);
define
(
'MENUITEM'
,
'siteoptions'
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
require_once
(
'form.php'
);
$smarty
=
smarty
();
$langoptions
=
get_languages
();
$themeoptions
=
get_themes
();
$yesno
=
array
(
true
=>
get_string
(
'yes'
),
false
=>
get_string
(
'no'
));
$siteoptionform
=
form
(
array
(
'name'
=>
'siteoptions'
,
'method'
=>
'post'
,
'action'
=>
''
,
'ajaxpost'
=>
true
,
'elements'
=>
array
(
'language'
=>
array
(
'type'
=>
'select'
,
'title'
=>
get_string
(
'language'
),
'description'
=>
get_string
(
'sitelanguagedescription'
),
'defaultvalue'
=>
get_config
(
'language'
),
'options'
=>
$langoptions
,
),
'theme'
=>
array
(
'type'
=>
'select'
,
'title'
=>
get_string
(
'theme'
),
'description'
=>
get_string
(
'sitethemedescription'
),
'defaultvalue'
=>
get_config
(
'theme'
),
'options'
=>
$themeoptions
,
),
'viruschecking'
=>
array
(
'type'
=>
'checkbox'
,
'title'
=>
get_string
(
'viruschecking'
),
'description'
=>
get_string
(
'viruscheckingdescription'
),
'defaultvalue'
=>
get_config
(
'viruschecking'
),
),
'pathtoclam'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'pathtoclam'
),
'description'
=>
get_string
(
'pathtoclamdescription'
),
'defaultvalue'
=>
get_config
(
'pathtoclam'
),
),
'sessionlifetime'
=>
array
(
'type'
=>
'text'
,
'size'
=>
4
,
'title'
=>
get_string
(
'sessionlifetime'
),
'description'
=>
get_string
(
'sessionlifetimedescription'
),
'defaultvalue'
=>
get_config
(
'session_timeout'
)
/
60
,
),
'allowpublicviews'
=>
array
(
'type'
=>
'select'
,
'title'
=>
get_string
(
'allowpublicviews'
),
'description'
=>
get_string
(
'allowpublicviewsdescription'
),
'defaultvalue'
=>
get_config
(
'allowpublicviews'
),
'options'
=>
$yesno
,
),
'artefactviewinactivitytime'
=>
array
(
'type'
=>
'expiry'
,
'title'
=>
get_string
(
'artefactviewinactivitytime'
),
'description'
=>
get_string
(
'artefactviewinactivitytimedescription'
),
'defaultvalue'
=>
get_config
(
'artefactviewinactivitytime'
),
),
'contactaddress'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'contactaddress'
),
'description'
=>
get_string
(
'contactaddressdescription'
),
'defaultvalue'
=>
get_config
(
'contactaddress'
),
'rules'
=>
array
(
'email'
=>
true
)
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'updatesiteoptions'
)
),
)
));
function
siteoptions_fail
(
$field
)
{
$result
[
'error'
]
=
'local'
;
$result
[
'message'
]
=
get_string
(
'setsiteoptionsfailed'
,
$field
);
error_log
(
$result
[
'message'
]);
json_headers
();
echo
json_encode
(
$result
);
exit
;
}
function
siteoptions_submit
(
$values
)
{
$fields
=
array
(
'language'
,
'theme'
,
'viruschecking'
,
'pathtoclam'
,
'allowpublicviews'
,
'artefactviewinactivitytime'
,
'contactaddress'
);
foreach
(
$fields
as
$field
)
{
if
(
!
set_config
(
$field
,
$values
[
$field
]))
{
siteoptions_fail
(
$field
);
}
}
if
(
!
set_config
(
'session_timeout'
,
$values
[
'sessionlifetime'
]
*
60
))
{
siteoptions_fail
(
$field
);
}
$result
[
'error'
]
=
false
;
$result
[
'message'
]
=
get_string
(
'siteoptionsset'
);
error_log
(
$result
[
'message'
]);
json_headers
();
echo
json_encode
(
$result
);
exit
;
}
$smarty
=
smarty
(
array
(),
array
(),
array
(
'siteoptionsset'
));
$smarty
->
assign
(
'SITEOPTIONFORM'
,
$siteoptionform
);
$smarty
->
display
(
'admin/options/index.tpl'
);
?>
htdocs/lang/en.utf8/mahara.php
View file @
7018f9eb
...
...
@@ -103,6 +103,36 @@ $string['forgotpassemailmessagehtml'] = '<p>Dear $fullname,</p>
<p><a href="'
.
get_config
(
'wwwroot'
)
.
'forgotpass.php?key=%s">'
.
get_config
(
'wwwroot'
)
.
'forgotpass.php?key=%s</a></p>'
;
// Site options
$string
[
'allowpublicviews'
]
=
'Allow public views'
;
$string
[
'allowpublicviewsdescription'
]
=
'If set to yes, views are accessable by the public. If set to no, only logged in users will be able to look at views'
;
$string
[
'artefactviewinactivitytime'
]
=
'Artefact view inactivity time'
;
$string
[
'artefactviewinactivitytimedescription'
]
=
'The time after which an inactive view or artefact will be moved to the InactiveContent area'
;
$string
[
'contactaddress'
]
=
'Contact address'
;
$string
[
'contactaddressdescription'
]
=
'The email address to which messages from the Contact Us form will be sent'
;
$string
[
'language'
]
=
'Language'
;
$string
[
'sitelanguagedescription'
]
=
'The default language for the site'
;
$string
[
'pathtoclam'
]
=
'Path to clam'
;
$string
[
'pathtoclamdescription'
]
=
'The filesystem path to clamscan or clamdscan'
;
$string
[
'sessionlifetime'
]
=
'Session lifetime'
;
$string
[
'sessionlifetimedescription'
]
=
'Time in minutes after which an inactive logged in user will be automatically logged out'
;
$string
[
'theme'
]
=
'Theme'
;
$string
[
'sitethemedescription'
]
=
'The theme for the site'
;
$string
[
'viruschecking'
]
=
'Virus checking'
;
$string
[
'viruscheckingdescription'
]
=
'If checked, virus checking will be enabled for all uploaded files using ClamAV'
;
$string
[
'updatesiteoptions'
]
=
'Update site options'
;
$string
[
'siteoptionsset'
]
=
'Site options have been updated'
;
$string
[
'setsiteoptionsfailed'
]
=
'Failed setting the %s option'
;
// Expiry times
$string
[
'noenddate'
]
=
'No end date'
;
$string
[
'days'
]
=
'days'
;
$string
[
'weeks'
]
=
'weeks'
;
$string
[
'months'
]
=
'months'
;
$string
[
'years'
]
=
'years'
;
// Boolean site option
$string
[
'no'
]
=
'no'
;
$string
[
'yes'
]
=
'yes'
;
// Admin menu editor
//$string['menueditor'] = 'Menu editor';
$string
[
'adminfile'
]
=
'Admin file'
;
...
...
htdocs/lib/form.php
View file @
7018f9eb
...
...
@@ -466,6 +466,15 @@ class Form {
return
$this
->
method
;
}
/**
* Is the form being submitted by ajax?
*
* @return bool
*/
public
function
get_ajaxpost
()
{
return
$this
->
ajaxpost
;
}
/**
* Returns the renderer used on to render the form
*
...
...
htdocs/lib/form/elements/expiry.php
0 → 100644
View file @
7018f9eb
<?php
/**
* This program is part of Mahara
*
* This program 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 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage form-element
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined
(
'INTERNAL'
)
||
die
();
/**
* Provides a duration chooser, with a text box for a number and a
* select box to choose the units, in days, weeks, months, years, or 'no end date'.
*
* @param array $element The element to render
* @param Form $form The form to render the element for
* @return string The HTML for the element
*/
function
form_render_expiry
(
$element
,
Form
$form
)
{
$result
=
''
;
$name
=
$element
[
'name'
];
if
(
!
isset
(
$element
[
'defaultvalue'
]))
{
$element
[
'defaultvalue'
]
=
null
;
}
$global
=
(
$form
->
get_method
()
==
'get'
)
?
$_GET
:
$_POST
;
// Get the value of the element for rendering. The values of the
// two inputs are rendered, and the total time in seconds is
// stored in a hidden input.
if
(
isset
(
$element
[
'value'
]))
{
$seconds
=
$element
[
'value'
];
$values
=
get_expiry_from_seconds
(
$element
[
'value'
]);
}
else
if
(
isset
(
$global
[
$element
[
'name'
]
.
'_number'
])
&&
isset
(
$global
[
$element
[
'name'
]
.
'_units'
]))
{
$values
=
array
(
'number'
=>
$global
[
$element
[
'name'
]
.
'_number'
],
'units'
=>
$global
[
$element
[
'name'
]
.
'_units'
]);
$seconds
=
$values
[
'number'
]
*
seconds_in
(
$values
[
'units'
]);
}
else
if
(
isset
(
$element
[
'defaultvalue'
]))
{
$seconds
=
$element
[
'defaultvalue'
];
$values
=
get_expiry_from_seconds
(
$seconds
);
}
else
{
$values
=
array
(
'number'
=>
''
,
'units'
=>
'noenddate'
);
$seconds
=
null
;
}
$numberinput
=
'<input '
.
(
$form
->
get_ajaxpost
()
?
'onchange="'
.
$name
.
'_change()" '
:
''
);
$numberinput
.
=
'type="text" size="4" '
.
'name="'
.
$name
.
'_number" '
;
$numberinput
.
=
'id="'
.
$name
.
'_number" value="'
.
$values
[
'number'
]
.
"
\"
>
\n
"
;
$allunits
=
get_expiry_units
();
$uselect
=
'<select '
.
(
$form
->
get_ajaxpost
()
?
'onchange="'
.
$name
.
'_change()" '
:
''
);
$uselect
.
=
'name="'
.
$name
.
'_units" id="'
.
$name
.
'_units"'
.
">
\n
"
;
foreach
(
$allunits
as
$u
)
{
$uselect
.
=
"
\t
<option value=
\"
$u
\"
"
.
((
$values
[
'units'
]
==
$u
)
?
' selected="selected"'
:
''
)
.
'>'
.
get_string
(
$u
)
.
"</option>
\n
"
;
}
$uselect
.
=
"</select>
\n
"
;
// The hidden input contains the value of the expiry in seconds
$hidden
=
'<input type="hidden" name="'
.
$name
.
'" id="'
.
$name
.
'" value="'
.
$seconds
.
"
\"
>
\n
"
;
// Every time one of the two inputs is changed, update the number
// of seconds in the hidden input.
if
(
$form
->
get_ajaxpost
())
{
$script
=
<<<
EOJS
<
script
type
=
"text/javascript"
language
=
"javascript"
>
function
{
$name
}
_change
()
{
var
seconds
=
null
;
if
(
$
(
'{$name}_number'
)
.
value
>
0
)
{
var
mult
=
$
(
'{$name}_number'
)
.
value
*
60
*
60
*
24
;
if
(
$
(
'{$name}_units'
)
.
value
==
'days'
)
{
seconds
=
mult
;
}
else
if
(
$
(
'{$name}_units'
)
.
value
==
'weeks'
)
{
seconds
=
mult
*
7
;
}
else
if
(
$
(
'{$name}_units'
)
.
value
==
'months'
)
{
seconds
=
mult
*
30
;
}
else
if
(
$
(
'{$name}_units'
)
.
value
==
'years'
)
{
seconds
=
mult
*
365
;
}
}
$
(
'{$name}'
)
.
value
=
seconds
;
}
</
script
>
EOJS
;
}
else
{
$script
=
''
;
}
return
$numberinput
.
$uselect
.
$hidden
.
$script
;
}
function
get_expiry_units
()
{
return
array
(
'days'
,
'weeks'
,
'months'
,
'years'
,
'noenddate'
);
}
function
seconds_in
(
$unit
)
{
$dayseconds
=
60
*
60
*
24
;
switch
(
$unit
)
{
case
'days'
:
return
$dayseconds
;
case
'weeks'
:
return
$dayseconds
*
7
;
case
'months'
:
return
$dayseconds
*
30
;
case
'years'
:
return
$dayseconds
*
365
;
default
:
return
null
;
}
}
function
get_expiry_from_seconds
(
$seconds
)
{
if
(
$seconds
==
null
)
{
return
array
(
'number'
=>
''
,
'units'
=>
'noenddate'
);
}
// This needs work to produce sensible values; at the moment it will convert
// 60 days into 2 months; 70 days into 7 weeks, etc.
$yearseconds
=
seconds_in
(
'years'
);
if
(
$seconds
%
$yearseconds
==
0
&&
$seconds
>
0
)
{
return
array
(
'number'
=>
(
int
)
(
$seconds
/
$yearseconds
),
'units'
=>
'years'
);
}
$monthseconds
=
seconds_in
(
'months'
);
if
(
$seconds
%
$monthseconds
==
0
&&
$seconds
>
0
)
{
return
array
(
'number'
=>
(
int
)
(
$seconds
/
$monthseconds
),
'units'
=>
'months'
);
}
$weekseconds
=
seconds_in
(
'weeks'
);
if
(
$seconds
%
$weekseconds
==
0
&&
$seconds
>
0
)
{
return
array
(
'number'
=>
(
int
)
(
$seconds
/
$weekseconds
),
'units'
=>
'weeks'
);
}
$dayseconds
=
seconds_in
(
'days'
);
if
(
$seconds
%
$dayseconds
==
0
)
{
return
array
(
'number'
=>
(
int
)
(
$seconds
/
$dayseconds
),
'units'
=>
'days'
);
}
return
null
;
}
// /** gets the value explicitly from the request */
// function form_get_value_expiry($element, Form $form) {
// $name = $element['name'];
// $global = ($form->get_method() == 'get') ? $_GET : $_POST;
// return $global[$name];
// //$unit = $global[$name . '_units'];
// //if ($unit == 'noenddate') {
// // return null;
// //}
// //$allunits = get_expiry_units();
// //$number = $global[$name . '_number'];
// //if (!in_array($unit,$allunits) || $number < 0) {
// // return null;
// //}
// //return $number * seconds_in($unit);
// }
?>
htdocs/theme/default/templates/admin/options/index.tpl
View file @
7018f9eb
...
...
@@ -2,12 +2,6 @@
<h2>
AdminSiteOptions
</h2>
<p>
Screens in this section:
</p>
<ul>
<li><a
href=
"authentication.php"
>
AdminOptionsAuthentication
</a></li>
</ul>
<p><a
href=
".."
>
parent
</a></p>
{
$SITEOPTIONFORM
}
{
include
file
=
"footer.tpl"
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment