Merge branch 'master' into speed_tweaks

This commit is contained in:
green-ponies (jgen)
2012-02-07 23:21:56 -05:00
52 changed files with 478 additions and 3723 deletions

View File

@@ -1,5 +1,5 @@
<?php
/*
/**
* Name: Uploader
* Author: Shish
* Description: Allows people to upload files to the website
@@ -122,7 +122,7 @@ class Upload extends SimpleExtension {
}
// check if the user is an administrator and can upload files.
if(!$user->is_admin()) {
if(!$user->can("replace_image")) {
$this->theme->display_permission_denied($page);
}
else {
@@ -224,14 +224,28 @@ class Upload extends SimpleExtension {
}
// }}}
// do things {{{
/**
* Check if a given user can upload.
* @param $user The user to check.
* @retval bool
*/
private function can_upload(User $user) {
global $config;
return ($config->get_bool("upload_anon") || !$user->is_anonymous());
}
// Helper function based on the one from the online PHP Documentation
// which is licensed under Creative Commons Attribution 3.0 License
// TODO: Make these messages user/admin editable
/**
* Returns a descriptive error message for the specified PHP error code.
*
* This is a helper function based on the one from the online PHP Documentation
* which is licensed under Creative Commons Attribution 3.0 License
*
* TODO: Make these messages user/admin editable
*
* @param $error_code PHP error code (int)
* @retval String
*/
private function upload_error_message($error_code) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
@@ -253,6 +267,10 @@ class Upload extends SimpleExtension {
}
}
/**
* Handle an upload.
* @retval bool TRUE on upload successful.
*/
private function try_upload($file, $tags, $source, $replace='') {
global $page;
global $config;
@@ -299,6 +317,10 @@ class Upload extends SimpleExtension {
return $ok;
}
/**
* Handle an transload.
* @retval bool TRUE on transload successful.
*/
private function try_transload($url, $tags, $source, $replace='') {
global $page;
global $config;
@@ -314,7 +336,7 @@ class Upload extends SimpleExtension {
}
// Checks if user is admin > check if you want locked.
if($user->is_admin() && !empty($_GET['locked'])){
if($user->can("lock_image") && !empty($_GET['locked'])){
$locked = bool_escape($_GET['locked']);
}