Version: 1.00, by Admin (Coder)
Developer Last Online: Nov 2024
Version: 2.2.x
Rating:
Released: 03-01-2002
Last Update: Never
Installs: 54
No support by the author.
*drums* This hack is now out of beta! Safe to use.
My latest and one of the more extensive hacks -- Private Attachments!
This huge (I ain't kidding, it's pretty big) hack will allow your members to send private messages with attachments in them, so they don't need to use e-mail for that.
Since this hack requires a large number of edits, this is how I recommend installing it:
(a) Run the queries.
(b) Edit all the files, offline.
(c) When you are done with (b) upload all the files at once.
(d) Perform the template edits.
If you do all actions in this order your users shouldn't notice you are installing the hack.
All feature requests (except for limiting this for usergroups -- if you want that do it yourself it's not hard but I'm tired of adding permissions to the dreaded usergroup.php) are welcome before this goes out of beta.
As always, have fun.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Hope this makes up for the stupid question I asked a couple of post earlier....
This modification will allow to have private attachment to work with file attachment hack by PNP.
Follow the instruction as provided by the master hacker Firefly
But instead in attachment.php look for:
Quote:
if ($postid) {
$postid=verifyid("post",$postid);
} else {
$attachmentid=verifyid("attachment",$attachmentid) ;
}
$getforuminfo=$DB_site->query_first("SELECT forumid".
iif($postid,',attachmentid ','')."
FROM thread,post
WHERE post.threadid=thread.threadid ".
iif($postid,"AND post.postid='$postid'","AND post.attachmentid='$attachmentid'")."
");
$permissions=getpermissions($getforuminfo[forumid]);
if (!$permissions[canview] or !$permissions[cangetattachment]) {
show_nopermission();
}
if ($postid) {
$attachmentid=$getforuminfo[attachmentid];
}
if (!$attachmentinfo=$DB_site->query_first("SELECT filename,hash,filedata,dateline,visible
FROM attachment
WHERE attachmentid='$attachmentid'")){
$idname='attachment';
eval("standarderror(\"".gettemplate('error_invalid id')."\");");
exit;
}
if (!$privatemessageid) {
/* ### */
$getforuminfo=$DB_site->query_first("SELECT forumid".
iif($postid,',attachmentid ','')."
FROM thread,post
WHERE post.threadid=thread.threadid ".
iif($postid,"AND post.postid='$postid'","AND post.attachmentid='$attachmentid'")."
");
$permissions=getpermissions($getforuminfo[forumid]);
if (!$permissions[canview] or !$permissions[cangetattachment]) {
show_nopermission();
}
if ($postid) {
$attachmentid=$getforuminfo[attachmentid];
}
$privateok = 0;
/* ### */
} else {
/* ### */
$pminfo = $DB_site->query_first("SELECT * FROM privatemessage WHERE privatemessageid=$privatemessageid");
$attachmentid = $pminfo['attachmentid'];
if ($attachmentid == 0 or $pminfo['userid'] != $bbuserinfo['userid']) {
$idname='attachment';
eval("standarderror(\"".gettemplate('error_invalid id')."\");");
exit;
}
$privateok = 1;
/* ### */
}
if (!$attachmentinfo=$DB_site->query_first("SELECT filename,hash,filedata,dateline,visible
FROM attachment
WHERE attachmentid='$attachmentid'".iif($privateok==0, 'AND private=0', ''))){
$idname='attachment';
eval("standarderror(\"".gettemplate('error_invalid id')."\");");
exit;
}
also in function.php:
Quote:
$DB_site->query("INSERT INTO attachment (attachmentid,userid,dateline,filename,visible,has h) VALUES (NULL,$bbuserinfo[userid],".time().",'".addslashes($attachment_name)."','$v isible','$attachment_hash')");
and replace it with:
Quote:
$DB_site->query("INSERT INTO attachment (attachmentid,userid,dateline,filename,filedata,vi sible,hash,private) VALUES (NULL,$bbuserinfo[userid],".time().",'".addslashes($attachment_name)."','". addslashes($filestuff)."','$visible','$attachment_ hash','$private')");
This should do the trick...
Now if someone can help me figure out how to have the file removed with the deletion on the private message that be nice...
Keep in mind that I'm only beginner so there might be oversight, just let me know! :nervous:
You only ran part of the query, the full query is:
[codel]ALTER TABLE attachment ADD private TINYINT(1) UNSIGNED DEFAULT "0" NOT NULL AFTER visible;[/code]