Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Developing Attachments 2.0

2»

Comments

  • save them with userid instead of discussionid?
  • itchy it wont work, as i assume to show them it runs a query as if discussionid = 2 then show attachment or something.
  • i think i asked you this before - but why don't you save the images named userID.filename.ext, and then put the links/html code in the actual body of the comment, instead of running new queries? they could still be managed by the user since they'd be tied to userID.
  • pbearpbear New
    edited July 2006
    1. Have a preference in the Admin account after enabling the extension to select what path the uploads should go to. That way it could be a folder in the vanilla directory, or one on the same level as the directory, or wherever. Thought I saw some note about the second option being more secure (??? anyways...).
    2. Have an option in each user's account to "Enable Attachments." When checked, it creates a folder in the above specified path with the name being the UserID (or what ever is unique to that account and valid as a directory name). If unchecked I guess it could delete the folder, or better yet just leave it there. It's an additional step, but it means you don't have to go about creating folders on the spot for all 1000 of your users when only 20 ever upload attachments. Also allows admins to delete all of an account's stuff if they want to remove the user.
      Edit: you can't upload at all until you create the folder, just to be clear.
    3. bonus idea: set up a tab with Filebrowser to navigate around the uploads folder. People can find the url there to link stuff into their posts.
  • edited July 2006
    I've given it some more thought. I wanted to save attachments to a discussion folder with a commentID in the filename. This way I could save and retrieve files without having to use database queries... But to speed things up and make it more extendable, I'm going to create a LUM_Attachments table. This way I can easily implement download counters, user quotas, filebrowser tab, etc. So, back to the drawing table :)
  • While your at that drawing table, put in the ability to put notes next to (under?) attachments. That way some text could describe things like installation instructions, picture descriptions etc.

    And how about an ajaxy upload so that the image thumbnail can be viewed while that descriptive text is being typed.
  • Yeah a notes thing would be brilliant!
  • What are the possibilities of accepting ALL file types? That way, I don't have to code in every single file type I want to accept (which happens daily with the client management tool). I just want to accept them all.
  • NickENickE New
    edited August 2006
    You'd have to edit both the attachment extension and library/Framework/Framework.Class.Uploader.php. I haven't actually tested this, but it should work: in the latter file, there should be a block of code that looks like this around line 47:
    // Ensure that the file's type is allowed
    if (!array_key_exists($FileType, $this->AllowedFileTypes)) {
    	$this->Context->WarningCollector->Add('You are not allowed to upload ('.$FileName.') the requested file type: '.$FileType);
    } else {
    	// Now make sure that the file type has the proper extension
    	if (!in_array($FileExtension, $this->AllowedFileTypes[$FileType])) {
    		$Message = '';
    		for ($i = 0; $i < count($this->AllowedFileTypes[$FileType]); $i++) {
    			if ($Message != '') $Message .= ', ';
    			$Message .= $this->AllowedFileTypes[$FileType][$i];
    		}
    		$Message = 'The file you attempted to upload ('.$FileName.') was of type "'.$FileType.'", but the file extension "'.$FileExtension.'" did not match the accepted extensions for this type of file: '
    			.$Message;
    		$this->Context->WarningCollector->Add($Message);
    	}
    }
    Change that to the following:
    if(is_array($this->AllowedFileTypes) && $this->AllowedFileTypes != '*')
    {
    	// Ensure that the file's type is allowed
    	if (!array_key_exists($FileType, $this->AllowedFileTypes)) {
    		$this->Context->WarningCollector->Add('You are not allowed to upload ('.$FileName.') the requested file type: '.$FileType);
    	} else {
    		// Now make sure that the file type has the proper extension
    		if (!in_array($FileExtension, $this->AllowedFileTypes[$FileType])) {
    			$Message = '';
    			for ($i = 0; $i < count($this->AllowedFileTypes[$FileType]); $i++) {
    				if ($Message != '') $Message .= ', ';
    				$Message .= $this->AllowedFileTypes[$FileType][$i];
    			}
    			$Message = 'The file you attempted to upload ('.$FileName.') was of type "'.$FileType.'", but the file extension "'.$FileExtension.'" did not match the accepted extensions for this type of file: '
    				.$Message;
    			$this->Context->WarningCollector->Add($Message);
    		}
    	}
    }
    Then open Attachments/default.php and change
    	$Configuration['ATTACHMENT_ALLOWED_FILETYPES'] = array (
    		'image/gif'						=> array('gif', 'GIF'),
    		'image/png'						=> array('png', 'PNG'),
    		'image/jpeg'					=> array('jpg', 'jpeg', 'JPG', 'JPEG'),
    		'image/pjpeg'					=> array('jpg', 'jpeg', 'JPG', 'JPEG'),
    		'application/pdf'				=> array('pdf', 'PDF'),
    		'application/x-pdf'				=> array('pdf', 'PDF'),
    		'application/msword'			=> array('doc', 'DOC', 'rtf', 'RTF'),
    		'application/zip'				=> array('zip', 'ZIP'),
    		'application/x-zip-compressed'	=> array('zip', 'ZIP'),
    		'application/octet-stream'		=> array('rar', 'RAR'),
    		'text/plain'					=> array('txt', 'TXT'),
    		'application/x-gzip'			=> array('gz', 'GZ', 'tar.gz', 'TAR.GZ'),
    		'application/download'			=> array('rar', 'RAR')
    	);
    To $Configuration['ATTACHMENT_ALLOWED_FILETYPES'] = '*';
  • has anyone tested this?
  • It works now.
  • Nice solution SirNot... too bad you have to change Vanilla core files to get the effect... But as I use the Uploader class, I guess there is no other way :) (Ofcourse there are, like building my own class, but the cool thing is to use core classes so you don't have to program them yourself :)
This discussion has been closed.