SimplePortal
Customization => Blocks and Modifications => Topic started by: Kryzen on August 09, 2011, 10:05:01 AM
-
Quick PM
v1.0.4.1
Quick PM was originally created for Dream Portal, but I decided to port it to SP. This module allows users to send quick PM's. I would like to say thanks to SoLoGHoST, SlammedDime, Labradoodle-360, Ccbtimewiz, Phantomm, Miss all Sunday and DoctorMalboro. The current version is 1.0.4.1 and I hope to release v1.1 soon.
Installing is very simple. Just create a new PHP code block and use this code:
/**
Quick PM modification by Dr. Deejay
Module originally created for Dream Portal
Ported to SimplePortal by Dr. Deejay
Version 1.0.4.1
Thanks to: SoLoGHoST, SlammedDime, Labradoodle-360, Ccbtimewiz, Phantomm, Miss all Sunday and DoctorMalboro
*/
global $txt, $buttons, $scripturl, $smcFunc, $context;
/*Config*/
$txt['quick_pm_block_not_allowed'] = 'You are not allowed to access this block';
$txt['quick_pm_block_default_user'] = 'Select user';
$txt['quick_pm_block_send'] = 'Send';
$query = $smcFunc['db_query']('', '
SELECT real_name, id_member
FROM {db_prefix}members
WHERE is_activated={int:activated}
ORDER BY real_name ASC',
array(
'activated' => 1,
)
);
$context['fastpm']['members'] = array();
while ($row = $smcFunc['db_fetch_assoc']($query))
{
$context['fastpm']['members'][$row['id_member']] = $row['real_name'];
}
$smcFunc['db_free_result']($query);
// Wait.. We DO have permissions for it, or don't we?
if (!allowedTo('pm_send'))
{
echo '',$txt['quick_pm_block_not_allowed'],'';
return;
}
// Are we allowed to view the memberlist? If yes, begin with the select box
echo '
<form action="#" method="post">
<select name="u" onchange="if (this.value) window.location.href=this.value">
<option value="0" selected="selected" disabled="disabled">',$txt['quick_pm_block_default_user'],'</option>';
foreach ($context['fastpm']['members'] as $key => $value)
echo '
<option value="', $scripturl, '?action=pm;sa=send;u=', $key, '">', $value, '</option>';
echo ' </select>
<input type="submit" value="',$txt['quick_pm_block_send'],'">
</form>';
// If we submitted the form, redirect to the messages section
if(isset($_POST['u']))
redirectexit('action=pm;sa=send;u=' . $_POST['u']);
Enjoy!
Dr. Deejay
-
Looks cool :)
the only thing is that if you have thousands of members, the select list will be huge :P
-
Thanks 130850! :D
Yes, that's true lol :P Dunno how to solve that without letting it lose it's functionality, but I'll try and thanks for the comments :)
-
Well you could limit the list to show only the users buddies or use the 2.0 user auto-suggest ajax thing, the user then will just need to type the other user's name.
-
Hmm great idea :) I'll change it in 1.1 ;)
-
Very nice.
-
Thanks Shadow Queen :)
-
Your welcome :)
-
if(isset($_POST['u']))
header("Location: ".$scripturl."?action=pm;sa=send;u=".$_POST['u']);
Can replace with:
if(isset($_POST['u']))
redirectexit('?action=pm;sa=send;u=' . $_POST['u']);
-
Thanks for the tip ccbtimewiz, I'll change it in 1.0.2 (which will be released asap) :)
-
Bug here:
if ($context['user']['is_guest'])
{
echo '</div>You are not allowed to access this module';
return;
}
Don't need a closing div if there was never an open div in the first place. Also, SimplePortal uses the term "Block", not "Module". In addition, you aren't checking if the user can even send a PM, just that if they're not a guest. Could make use of the allowedTo() function and use the appropriate permission.
Such as;
if (!allowedTo('send_pm'))
{
echo 'You are not allowed to access this block';
return;
}
-
Thanks ccbtimewiz, I've fixed both issues :)
-
one more fix, change:
if (!allowedTo('send_pm'))
to if (!allowedTo('pm_send'))
http://simpleportal.net/index.php?topic=11817.0
-
I thought no one would reply to a thread that was a year old, but I guess I was wrong. Anyway Phantomm said I should make my suggestion here. Not expecting anything really, just a suggestion because I find this particular code very useful but might not if I had a huge number of members, so I wonder if there might not be another way to do this at that point that would work as well.
My suggestion was..
It would be great if someone could change this a bit and have it only show contacts of that persons buddy list, so that at some point the drop down doesn't become so long it's difficult to use. Hope that made sense. Or maybe there is another way to do it so that the drop down list of members would not become so long it would not longer be convenient.
It would also be nice if when you clicked on the members name in the drop down it immediately took you to the reply box before you even had to hit send.
-
This code is nice... I used it at the bottom of my custom menu... however... the poor guy who is at #1 spot has his name showing at all time by default... that guy is geting a ton of PM's from the "idiot crowd"... any way to make a BLANK DEFAULT requiring someone click on the drop down menu to select a user?
-
I replaced:
<form action="" method="post">
<select name="u">
to
<form action="" method="post">
<select name="u">
<option value="0" selected="selected">Select user</option>';
:)
-
Works perfect. Thank you!
-
I removed this for a while because i got tired of the error log filling up over it. Then yesterday I thought I would try it again, but removed the only other custom block for latest posts which doesn't throw any errors. Then I put this back as the only custom block and used it to pm just one person, then I checked the error logs and sure enough there they were. I can't believe a small bit of code like this could be so problematic. lol
Anyway doesn't look like anyone really cares about this mod but me at this point..
Heres the errors in case someone takes an interest one day. I sure would like it to work with out errors, works with them but I'm always nervousness when I have errors in admin.
/index.php?action=admin;area=portalblocks;sa=edit
2: fclose() expects parameter 1 to be resource, boolean given
File: Sources/Subs-PortalAdmin.php Line: 401
/index.php?action=admin;area=portalblocks;sa=edit
2: fwrite() expects parameter 1 to be resource, boolean given
File: Sources/Subs-PortalAdmin.php Line: 400
/index.php?action=admin;area=portalblocks;sa=edit
2: fopen(/public_html/sp_tmp_1349028364.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied
File: Sources/Subs-PortalAdmin.php Line: 399
And here is the code being used:
/**
Quick PM modification by Dr. Deejay
Module originally created for Dream Portal
Ported to SimplePortal by Dr. Deejay
Version 1.0.2
Thanks to: SoLoGHoST, SlammedDime, Labradoodle-360, Ccbtimewiz, Miss all Sunday and DoctorMalboro
*/
global $txt, $buttons, $scripturl, $smcFunc, $context;
$query = $smcFunc['db_query']('', '
SELECT real_name, id_member
FROM {db_prefix}members
WHERE is_activated={int:activated}
ORDER BY real_name ASC',
array(
'activated' => 1,
)
);
$context['fastpm']['members'] = array();
while ($row = $smcFunc['db_fetch_assoc']($query))
{
$context['fastpm']['members'][$row['id_member']] = $row['real_name'];
}
$smcFunc['db_free_result']($query);
// Wait.. We DO have permissions for it, or don't we?
if (!allowedTo('pm_send'))
{
echo 'You are not allowed to access this block';
return;
}
// Are we allowed to view the memberlist? If yes, begin with the select box
echo '<form action="" method="post">
<select name="u">
<option value="0" selected="selected">Select user ....</option>';
foreach ($context['fastpm']['members'] as $key => $value)
echo ' <option value="', $key, '">', $value, '</option>';
echo ' </select>
<input type="submit" value="Send">
</form>';
// If we submitted the form, redirect to the messages section
if(isset($_POST['u']))
redirectexit('action=pm;sa=send;u=' . $_POST['u']);
-
one more fix, change: if (!allowedTo('send_pm'))
to if (!allowedTo('pm_send'))
http://simpleportal.net/index.php?topic=11817.0
Thank you for the fix, I'll release a 1.0.3 this afternoon. :)
It would be great if someone could change this a bit and have it only show contacts of that persons buddy list, so that at some point the drop down doesn't become so long it's difficult to use. Hope that made sense. Or maybe there is another way to do it so that the drop down list of members would not become so long it would not longer be convenient.
It would also be nice if when you clicked on the members name in the drop down it immediately took you to the reply box before you even had to hit send.
Thank you for the suggestions, I totally agree. I think only showing the buddies would be great, I'll take a look at that. Second idea would just take a few seconds to implement, so I'll add that too. Thanks again for the suggestions. :)
any way to make a BLANK DEFAULT requiring someone click on the drop down menu to select a user?
Sure, thanks for the suggestion, will do that too. ;D
Works perfect. Thank you!
You're welcome. :)
Heres the errors in case someone takes an interest one day. I sure would like it to work with out errors, works with them but I'm always nervousness when I have errors in admin.
/index.php?action=admin;area=portalblocks;sa=edit
2: fclose() expects parameter 1 to be resource, boolean given
File: Sources/Subs-PortalAdmin.php Line: 401
/index.php?action=admin;area=portalblocks;sa=edit
2: fwrite() expects parameter 1 to be resource, boolean given
File: Sources/Subs-PortalAdmin.php Line: 400
/index.php?action=admin;area=portalblocks;sa=edit
2: fopen(/home/cafeweco/public_html/sp_tmp_1349028364.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied
File: Sources/Subs-PortalAdmin.php Line: 399
Weird, the code is not using fwrite, fopen or fclose, so I'll point the team to this topic. Thanks for the report, though. :)
-
Version 1.0.3 released!
! Fixing wrong permission name (Thanks, Phantom!)
! Add default option (Thanks, Phantom!)
- Go to the send pm page automatically when you select a user
I couldn't find a way to show buddies only and I wanted to provide a patch as soon as possible, so I didn't include it in the 1.0.3 release. I'm still trying to find a way to show buddies only, though, but I'm afraid it could take some time.
-
small suggestion, maybe you can use $txt instead of 'hardcoded' text?
I'm using this code:
/**
Quick PM modification by Dr. Deejay
Module originally created for Dream Portal
Ported to SimplePortal by Dr. Deejay
Version 1.0.3
Thanks to: SoLoGHoST, SlammedDime, Labradoodle-360, Ccbtimewiz, Phantomm, Miss all Sunday and DoctorMalboro
*/
global $txt, $buttons, $scripturl, $smcFunc, $context;
/*Config*/
$txt['quick_pm_block_not_allowed'] = 'You are not allowed to access this block';
$txt['quick_pm_block_default_user'] = 'Select user';
$txt['quick_pm_block_send'] = 'Send';
$query = $smcFunc['db_query']('', '
SELECT real_name, id_member
FROM {db_prefix}members
WHERE is_activated={int:activated}
ORDER BY real_name ASC',
array(
'activated' => 1,
)
);
$context['fastpm']['members'] = array();
while ($row = $smcFunc['db_fetch_assoc']($query))
{
$context['fastpm']['members'][$row['id_member']] = $row['real_name'];
}
$smcFunc['db_free_result']($query);
// Wait.. We DO have permissions for it, or don't we?
if (!allowedTo('pm_send'))
{
echo '',$txt['quick_pm_block_not_allowed'],'';
return;
}
// Are we allowed to view the memberlist? If yes, begin with the select box
echo '
<form action="#" method="post">
<select name="u" onchange="if (this.value) window.location.href=this.value">
<option value="0" selected="selected" disabled="disabled">',$txt['quick_pm_block_default_user'],'</option>';
foreach ($context['fastpm']['members'] as $key => $value)
echo '
<option value="', $scripturl, '?action=profile;u=', $key, '">', $value, '</option>';
echo ' </select>
<input type="submit" value="',$txt['quick_pm_block_send'],'">
</form>';
// If we submitted the form, redirect to the messages section
if(isset($_POST['u']))
redirectexit('action=pm;sa=send;u=' . $_POST['u']);
Would be better for new users, if they can translate strings in one place than searching it inside PHP code :)
-
Thanks for the suggestion. :) Would you mind me using your code for a 1.0.4 release?
-
yeah, you can use it :)
-
Thank you, I'll release a 1.0.4 release within a few minutes. ;D
-
1.0.4 released!
! Use $txt strings rather than hardcoded text (Thanks, Phantomm :))
-
Strange behavior from 1.0.4...
When I select a persons name, it automatically takes me to their profile... not allowing me to hit send to take me to a PM?
-
In block code:
<option value="', $scripturl, '?action=profile;u=', $key, '">', $value, '</option>';
<option value="', $scripturl, '?action=pm;sa=send;u=', $key, '">', $value, '</option>';
:)
But then you don't need 'Send' button :)
-
Heres the errors in case someone takes an interest one day. I sure would like it to work with out errors, works with them but I'm always nervousness when I have errors in admin.
/index.php?action=admin;area=portalblocks;sa=edit
2: fclose() expects parameter 1 to be resource, boolean given
File: Sources/Subs-PortalAdmin.php Line: 401
/index.php?action=admin;area=portalblocks;sa=edit
2: fwrite() expects parameter 1 to be resource, boolean given
File: Sources/Subs-PortalAdmin.php Line: 400
/index.php?action=admin;area=portalblocks;sa=edit
2: fopen(public_html/sp_tmp_1349028364.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied
File: Sources/Subs-PortalAdmin.php Line: 399
Weird, the code is not using fwrite, fopen or fclose, so I'll point the team to this topic. Thanks for the report, though. :)
I have no idea how to track a error like this. The only other block might be recent posts with preview. Thanks, hope the team can give me some clue as to where to look and what to look for.
Thanks for fixing the pm mod, I love this mod. Now it works perfect, goes right to the reply box with out the go button. Yippee! I'm keeping this for admin and mods, hopefully you'll create one for buddies one day..
-
In block code:
<option value="', $scripturl, '?action=profile;u=', $key, '">', $value, '</option>';
<option value="', $scripturl, '?action=pm;sa=send;u=', $key, '">', $value, '</option>';
:)
But then you don't need 'Send' button :)
Works awesome... and send button removed.
-
boo2 -- In Subs-PortalAdmin.php, function sp_validate_php does open a file, write the code to be validated to the file, and then checks for the file. Those 3 error lines indicate that the function was unable to write to or close a file because the file was never opened. The third one says it was unable to open the file for writing. This may be because of a permission problem, or for some other reason.
-
I'm sorry, I must have been asleep when adding the url. :( It has been fixed now, thanks for the patch Phantomm. :).
In Subs-PortalAdmin.php, function sp_validate_php does open a file, write the code to be validated to the file, and then checks for the file.
Ah good to know, thanks for jumping in. :)
-
boo2 -- In Subs-PortalAdmin.php, function sp_validate_php does open a file, write the code to be validated to the file, and then checks for the file. Those 3 error lines indicate that the function was unable to write to or close a file because the file was never opened. The third one says it was unable to open the file for writing. This may be because of a permission problem, or for some other reason.
That went right over my head. lol Anyway which permissions, the one in the forums or the permissions on the server that I have to set and reset ever time I install with package manager?
-
nice, thx
-
boo2 -- the permissions on the server. Just like you need permission set permissively enough to create files during mod installation, you need them set permissively enough to permit creating files when you use this feature.