]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/File.php
add some info about plugins
[quix0rs-gnu-social.git] / classes / File.php
index b98c9e665faede2082577995b96c4468da11596b..56d9f982783a8e6815fae7e8b07ec89724223e21 100644 (file)
@@ -91,9 +91,10 @@ class File extends Memcached_DataObject
         $given_url = File_redirection::_canonUrl($given_url);
         if (empty($given_url)) return -1;   // error, no url to process
         $file = File::staticGet('url', $given_url);
-        if (empty($file->id)) {
+        if (empty($file)) {
             $file_redir = File_redirection::staticGet('url', $given_url);
-            if (empty($file_redir->id)) {
+            if (empty($file_redir)) {
+                common_debug("processNew() '$given_url' not a known redirect.\n");
                 $redir_data = File_redirection::where($given_url);
                 $redir_url = $redir_data['url'];
                 if ($redir_url === $given_url) {
@@ -121,17 +122,17 @@ class File extends Memcached_DataObject
         return $x;
     }
 
-    function isRespectsQuota($user) {
-        if ($_FILES['attach']['size'] > common_config('attachments', 'file_quota')) {
+    function isRespectsQuota($user,$fileSize) {
+        if ($fileSize > common_config('attachments', 'file_quota')) {
             return sprintf(_('No file may be larger than %d bytes ' .
                              'and the file you sent was %d bytes. Try to upload a smaller version.'),
-                           common_config('attachments', 'file_quota'), $_FILES['attach']['size']);
+                           common_config('attachments', 'file_quota'), $fileSize);
         }
 
         $query = "select sum(size) as total from file join file_to_post on file_to_post.file_id = file.id join notice on file_to_post.post_id = notice.id where profile_id = {$user->id} and file.url like '%/notice/%/file'";
         $this->query($query);
         $this->fetch();
-        $total = $this->total + $_FILES['attach']['size'];
+        $total = $this->total + $fileSize;
         if ($total > common_config('attachments', 'user_quota')) {
             return sprintf(_('A file this large would exceed your user quota of %d bytes.'), common_config('attachments', 'user_quota'));
         }
@@ -139,7 +140,7 @@ class File extends Memcached_DataObject
         $query .= ' month(modified) = month(now()) and year(modified) = year(now())';
         $this->query($query);
         $this->fetch();
-        $total = $this->total + $_FILES['attach']['size'];
+        $total = $this->total + $fileSize;
         if ($total > common_config('attachments', 'monthly_quota')) {
             return sprintf(_('A file this large would exceed your monthly quota of %d bytes.'), common_config('attachments', 'monthly_quota'));
         }
@@ -192,5 +193,18 @@ class File extends Memcached_DataObject
 
         return 'http://'.$server.$path.$filename;
     }
+
+    function isEnclosure(){
+        if(isset($this->filename)){
+            return true;
+        }
+        $notEnclosureMimeTypes = array('text/html','application/xhtml+xml');
+        $mimetype = strtolower($this->mimetype);
+        $semicolon = strpos($mimetype,';');
+        if($semicolon){
+            $mimetype = substr($mimetype,0,$semicolon);
+        }
+        return(! in_array($mimetype,$notEnclosureMimeTypes));
+    }
 }