Commit 9ad0fdcc authored by Evonne Cheung evonne@catalyst.net.nz's avatar Evonne Cheung evonne@catalyst.net.nz Committed by Nigel McNie nigel@catalyst.net.nz
Browse files
parents e40cdf7e 59f23831
mahara (0.3.1-1) unstable; urgency=low
* Bugfix release
* Add question about SMTP hosts to config
* Fixed Martyn's e-mail address
-- Nigel McNie <nigel@catalyst.net.nz> Mon, 15 Jan 2007 13:14:50 +1300
mahara (0.3-1) unstable; urgency=low
* New release
-- Martyn Smith <martyn@flange.wgtn.cat-it.co.nz> Fri, 12 Jan 2007 21:52:46 +1300
-- Martyn Smith <martyn@catalyst.net.nz> Fri, 12 Jan 2007 21:52:46 +1300
mahara (0.2-2) unstable; urgency=low
* Added servername to the config file
* Added simple mod_expires directives for the default theme and js
-- Martyn Smith <martyn@flange.wgtn.cat-it.co.nz> Fri, 12 Jan 2007 09:22:16 +1300
-- Martyn Smith <martyn@catalyst.net.nz> Fri, 12 Jan 2007 09:22:16 +1300
mahara (0.2-1) unstable; urgency=low
......
......@@ -50,13 +50,10 @@ if (!call_static_method($classname, 'has_config')) {
$form = call_static_method($classname, 'get_config_options');
if (isset($form['submitfunction'])) {
$submitfunction = $form['submitfunction'];
}
if (isset($form['validatefunction'])) {
$validatefunction = $form['validatefunction'];
}
$form['plugintype'] = $plugintype;
$form['pluginname'] = $pluginname;
$form['name'] = 'pluginconfig';
$form['pluginconfigform'] = true;
$form['jsform'] = true;
$form['successcallback'] = 'pluginconfig_submit';
$form['validatecallback'] = 'pluginconfig_validate';
......@@ -72,6 +69,10 @@ $form['elements']['type'] = array(
'type' => 'hidden',
'value' => $type
);
$form['elements']['save'] = array(
'type' => 'submit',
'value' => get_string('save'),
);
$smarty = smarty();
$smarty->assign('form', pieform($form));
......@@ -83,18 +84,14 @@ $smarty->display('admin/extensions/pluginconfig.tpl');
function pluginconfig_submit(Pieform $form, $values) {
$success = false;
global $submitfunction, $plugintype, $pluginname, $classname;
if (!empty($submitfunction)) {
try {
call_static_method($classname, $submitfunction, $values);
$success = true;
}
catch (Exception $e) {
$success = false;
}
global $plugintype, $pluginname, $classname;
try {
call_static_method($classname, 'save_config_options', $values);
$success = true;
}
else {
// call set_plugin_config and stuffs
catch (Exception $e) {
$success = false;
}
if ($success) {
......@@ -106,9 +103,10 @@ function pluginconfig_submit(Pieform $form, $values) {
}
function pluginconfig_validate(PieForm $form, $values) {
global $validatefunction, $plugintype, $pluginname, $classname;
if (!empty($validatefunction)) {
call_static_method($classname, $validatefunction, $form, $values);
global $plugintype, $pluginname, $classname;
if (method_exists($classname, 'validate_config_options')) {
call_static_method($classname, 'validate_config_options', $form, $values);
}
}
?>
......@@ -26,6 +26,7 @@
defined('INTERNAL') || die();
$string['blog'] = 'Blog';
$string['addblog'] = 'Add Blog';
$string['addpost'] = 'Add Post';
$string['attach'] = 'Attach';
......
......@@ -388,7 +388,23 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
}
public static function get_config_options() {
return array(); // @todo
$defaultquota = get_config_plugin('artefact', 'file', 'defaultquota');
if (empty($defaultquota)) {
$defaultquota = 1024 * 1024 * 10;
}
return array(
'elements' => array(
'defaultquota' => array(
'title' => get_string('defaultquota', 'artefact.file'),
'type' => 'bytes',
'defaultvalue' => $defaultquota,
),
),
);
}
public static function save_config_options($values) {
set_config_plugin('artefact', 'file', 'defaultquota', $values['defaultquota']);
}
}
......
......@@ -229,13 +229,7 @@ class ArtefactTypeProfile extends ArtefactType {
$public = self::get_public_fields();
$alwaysmandatory = self::get_always_mandatory_fields();
$form = array(
'name' => 'profileprefs',
'method' => 'post',
'ajaxpost' => true,
'plugintype' => 'artefact',
'pluginname' => 'internal',
'renderer' => 'multicolumntable',
'submitfunction' => 'save_config_options',
'elements' => array(
'mandatory' => array(
'title' => ' ',
......@@ -300,10 +294,6 @@ class ArtefactTypeProfile extends ArtefactType {
)
);
$form['elements']['submit'] = array(
'type' => 'submit',
'value' =>get_string('save')
);
return $form;
}
......
......@@ -167,7 +167,7 @@ function forgotpasschange_validate(Pieform $form, $values) {
// password_validate to maharalib, use it in places specified, test with a drop/create run
// support autofocus => (true|'id'), remove stuff doing autofocus from where it is, focus error fields
// commit stuff
function forgotpasschange_submit($values) {
function forgotpasschange_submit(Pieform $form, $values) {
global $SESSION, $USER;
if (!$user = get_record('usr', 'id', $values['user'])) {
......
......@@ -371,6 +371,7 @@ $string['View'] = 'View';
$string['watchlistupdated'] = 'Your watchlist has been updated';
// communities
$string['createcommunity'] = 'Create Community';
$string['communitymemberrequests'] = 'Pending membership requests';
$string['addcommunity'] = 'Add new community';
$string['sendinvitation'] = 'Send invite';
......
......@@ -488,24 +488,38 @@ function byteserving_send_file($filename, $mimetype, $ranges) {
}
/**
* Given a file path, retrieves the mime type of the file.
*
* This is only implemented for non-windows based operating systems. Mahara
* does not support windows at this time.
*
* @param string $file The file to check
* @return string The mimetype of the file
*/
function get_mime_type($file) {
switch (strtolower(PHP_OS)) {
case 'win' :
throw new SystemException('retrieving filetype not supported in windows');
default :
list($output,) = split(';', exec(get_config('pathtofile') . ' -ib ' . escapeshellarg($file)));
}
case 'win' :
throw new SystemException('retrieving filetype not supported in windows');
default :
list($output,) = split(';', exec(get_config('pathtofile') . ' -ib ' . escapeshellarg($file)));
}
return $output;
}
/**
* Given a mimetype (perhaps returned by {@link get_mime_type}, returns whether
* Mahara thinks it is a valid image file.
*
* Not all image types are valid for Mahara. Mahara supports JPEG, PNG and GIF.
*
* @param string $type The mimetype to check
* @return boolean Whether the type is a valid image type for Mahara
*/
function is_image_mime_type($type) {
return in_array($type, array('image/jpeg', 'image/jpg', 'image/gif', 'image/png'));
}
/**
* Given a path under dataroot, an ID and a size, return the path to a file
* matching all criteria.
......@@ -542,6 +556,7 @@ function get_dataroot_image_path($path, $id, $size) {
switch (get_mime_type($originalimage)) {
case 'image/jpeg':
case 'image/jpg':
$oldih = imagecreatefromjpeg($originalimage);
break;
case 'image/png':
......@@ -585,4 +600,48 @@ function get_dataroot_image_path($path, $id, $size) {
return false;
}
/**
* Deletes an image, including all resized versions of it, from dataroot.
*
* This function does not delete anything from anywhere else - it is your
* responsibility to delete any database records.
*
* @param string $path The path in dataroot of the base directory where the
* image resides.
* @param int $id The id of the image to delete.
* @return boolean Whether the image was deleted successfully.
*/
function delete_image($path, $id) {
// Check that the image exists.
$dataroot = get_config('dataroot');
$imagepath = $dataroot . $path;
if (!is_dir($imagepath) || !is_readable($imagepath)) {
return false;
}
$originalimage = $imagepath . '/' . ($id % 256) . "/$id";
if (!is_readable($originalimage)) {
return false;
}
unlink($originalimage);
// Check the size subdirectories
$dh = opendir($imagepath);
while (false !== ($file = readdir($dh))) {
$path = $imagepath . '/' . $file;
if (!preg_match('/\d+x\d+/', $file) || !is_dir($path)) {
continue;
}
$image = $path . '/' . ($id % 256) . '/' . $id;
if (is_readable($image)) {
unlink($image);
}
}
return true;
}
?>
<?php
/**
* This program is part of Pieforms
*
* 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 pieform
* @subpackage element
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz
*
*/
/**
* Provides a size chooser, with a text box for a number and a
* select box to choose the units, in bytes, kilobytes, or megabytes
*
* @param Pieform $form The form to render the element for
* @param array $element The element to render
* @return string The HTML for the element
*/
function pieform_element_bytes(Pieform $form, $element) {
$formname = $form->get_name();
$result = '';
$name = $element['name'];
if (!isset($element['defaultvalue'])) {
$element['defaultvalue'] = null;
}
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
// Get the value of the element for rendering.
if (isset($element['value'])) {
$bytes = $element['value'];
$values = pieform_element_bytes_get_bytes_from_bytes($element['value']);
}
else if (isset($global[$element['name']])
&& isset($global[$element['name'] . '_units'])) {
$values = array('number' => $global[$element['name']],
'units' => $global[$element['name'] . '_units']);
$bytes = $values['number'] * pieform_element_bytes_in($values['units']);
}
else if (isset($element['defaultvalue'])) {
$bytes = $element['defaultvalue'];
$values = pieform_element_bytes_get_bytes_from_bytes($bytes);
}
else {
$values = array('number' => '0', 'units' => 'bytes');
$bytes = 0;
}
// @todo probably create with an actual input element, as tabindex doesn't work here for one thing
// Same with the select. And do the events using mochikit signal instead of dom events
$numberinput = '<input';
$numberinput .= ' type="text" size="8" name="' . $name . '"';
$numberinput .= ' id="' . $formname . '_' . $name . '" value="' . $values['number'] . '" tabindex="' . $element['tabindex'] . '"';
$numberinput .= (isset($element['error']) ? ' class="error"' : '') . ">\n";
$uselect = '<select onchange="' . $name . '_change()" ';
$uselect .= 'name="' . $name . '_units" id="' . $formname . '_' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n";
foreach (pieform_element_bytes_get_bytes_units() as $u) {
$uselect .= "\t<option value=\"$u\"" . (($values['units'] == $u) ? ' selected="selected"' : '') . '>'
. $form->i18n('element', 'bytes', $u, $element) . "</option>\n";
}
$uselect .= "</select>\n";
return $numberinput . $uselect;
}
/**
* Gets the value of the expiry element and converts it to a time in seconds.
*
* @param Pieform $form The form the element is attached to
* @param array $element The element to get the value for
* @return int The number of seconds until expiry
*/
function pieform_element_bytes_get_value(Pieform $form, $element) {
$name = $element['name'];
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
$unit = $global[$name . '_units'];
$allunits = pieform_element_bytes_get_bytes_units();
$number = $global[$name];
if (!is_numeric($number)) {
$form->set_error($name, $form->i18n('element', 'bytes', 'invalidvalue', $element));
}
if (!in_array($unit,$allunits) || $number < 0) {
return null;
}
return $number * pieform_element_bytes_in($unit);
}
function pieform_element_bytes_in($units) {
switch ($units) {
case 'megabytes':
return 1048576;
break;
case 'kilobytes':
return 1024;
break;
default:
return 1;
break;
};
}
function pieform_element_bytes_i18n() {
return array(
'en.utf8' => array(
'bytes' => 'Bytes',
'kilobytes' => 'Kilobytes',
'megabytes' => 'Megabytes',
'invalidvalue' => 'Value must be a number',
),
);
}
function pieform_element_bytes_get_bytes_units() {
return array('bytes', 'kilobytes', 'megabytes');
}
function pieform_element_bytes_get_bytes_from_bytes($bytes) {
if ($bytes == null) {
return array('number' => '0', 'units' => 'bytes');
}
foreach (array('megabytes', 'kilobytes') as $units) {
if ( $bytes > pieform_element_bytes_in($units) ) {
return array('number' => $bytes / pieform_element_bytes_in($units) , 'units' => $units);
}
}
return array('number' => $bytes, 'units' => 'bytes');
}
?>
......@@ -78,9 +78,9 @@ tinyMCE.init({
editor_selector: 'wysiwyg',
button_tile_map: true,
theme: "advanced",
plugins: "table,emotions,iespell,inlinepopups",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,iespell,cleanup,separator,link,unlink",
theme_advanced_buttons2 : "tablecontrols,separator,cut,copy,paste",
plugins: "table,emotions,iespell,inlinepopups,paste",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,hr,emotions,iespell,cleanup,separator,link,unlink,separator,code",
theme_advanced_buttons2 : "tablecontrols,separator,cut,copy,paste,pasteword",
theme_advanced_buttons3 : "fontselect,separator,fontsizeselect,separator,formatselect",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
......@@ -170,7 +170,9 @@ EOF;
$smarty->compile_dir = get_config('dataroot').'smarty/compile';
$smarty->cache_dir = get_config('dataroot').'smarty/cache';
$smarty->assign('SITEMENU', site_menu());
if (get_config('installed')) {
$smarty->assign('SITEMENU', site_menu());
}
$smarty->assign('THEMEURL', get_config('themeurl'));
$smarty->assign('WWWROOT', $wwwroot);
......
......@@ -86,7 +86,7 @@
swapDOM(
div,
DIV({'class': 'validated'},
LABEL(null,
INPUT({'type': 'radio', 'name': '{{$name}}_selected', 'value': email}),
INPUT({'type': 'hidden', 'name': '{{$name}}_valid[]' , 'value': email}),
' ' + email,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment