if ($id != SITEID) {
         displaydir($uuid, $wdir, $id);
     } else {
         displaydir($uuid, $wdir);
     }
     html_footer();
     break;
 }
 // We need to get the last location we were browsing files from in order to upload the file there.
 if (($uuid = $repo->get_repository_location($id, $userid, $shared, $oid)) !== false) {
     if (isset($_FILES['userfile'])) {
         $issafe = true;
         // Determine if this user has enough storage space left in their quota to upload this file.
         if (!alfresco_quota_check($_FILES['userfile']['size'], $USER)) {
             $issafe = false;
             if ($quotadata = alfresco_quota_info($USER->username)) {
                 $a = new stdClass();
                 $a->current = display_size($quotadata->current);
                 $a->max = display_size($quotadata->quota);
                 $msg = '<p class="errormessage">' . get_string('erroruploadquotasize', 'repository_alfresco', $a) . '</p>';
             } else {
                 $msg = '<p class="errormessage">' . get_string('erroruploadquotasize', 'repository_alfresco') . '</p>';
             }
             print_simple_box($msg, '', '', '', '', 'errorbox');
         }
         // Make sure that the uploaded filename does not exist in the destination directory.
         if ($dir = $repo->read_dir($uuid)) {
             if (!empty($dir->files)) {
                 foreach ($dir->files as $file) {
                     if ($file->title == $_FILES['userfile']['name']) {
                         $issafe = false;
Beispiel #2
0
/**
 * Check if a given file size (in bytes) will run over a user's quota limit on Alfresco.
 *
 * @uses $USER
 * @param unknown_type $size
 * @param unknown_type $user
 * @return bool True if the size will not run over the user's quota, False otherwise.
 */
function alfresco_quota_check($filesize, $user = null)
{
    if ($user == null) {
        $user = $USER;
    }
    if (($userdata = alfresco_quota_info($user->username)) === false) {
        return false;
    }
    // If the user has no quota set or the filesize will not run over their current quota, return true.
    return $userdata->quota == -1 || $userdata->current + $filesize <= $userdata->quota;
}