SimplePortal

Support => English Support => Topic started by: boo2 on September 19, 2012, 05:01:43 AM

Title: Problem with Quick Pm only seen by admin
Post by: boo2 on September 19, 2012, 05:01:43 AM
The topic for quick pm is a bit old, so I wasn't sure if I should address it there or start a new topic..

For some reason this block can only be seen by admin, no one else. I've been at this for hours, setting and resetting the permissions different ways and still no one but admin can see it. The message inside the box says: You are not allowed to access this block

Can someone help me with this? I really love how this works but it's not too much use if only admins can use it.

Here is the code:
Code: [Select]
/**
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('send_pm'))
{
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">';
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']);

Title: Re: Problem with Quick Pm only seen by admin
Post by: phantomm on September 19, 2012, 09:42:35 AM
hmm.. try change:
Code: [Select]
if (!allowedTo('send_pm')) to
Code: [Select]
if (!allowedTo('pm_send'))
Can you give link to topic with this code?

found it => http://simpleportal.net/index.php?topic=9406.0
Title: Re: Problem with Quick Pm only seen by admin
Post by: AngelinaBelle on September 19, 2012, 10:22:09 AM
phantomm -- if you can test and confirm this for SMF 2.0.2/SimplePortal 2.3.5, can you submit this to the tracker, with fix?
Title: Re: Problem with Quick Pm only seen by admin
Post by: phantomm on September 19, 2012, 11:05:08 AM
It works, but this is custom PHP code not built-in feature in SP :)
Title: Re: Problem with Quick Pm only seen by admin
Post by: boo2 on September 19, 2012, 12:39:06 PM
Sorry, was up all night trying to figure this thing out. Just woke up and didn't expect an answer quite so quickly. I see you found the link to where I found the code. Please forgive me for not thinking of that.

Yes that works like a charm. It also reminds me not to be so stubborn. I could have saved myself some hair pulling if I had just asked after the first couple of hours. LOL

Hard to believe that it was something this simple.

If I may ask just one more related question. Originally I put this code and another found here http://simpleportal.net/index.php?topic=9138.0 in the same block to save space and it worked beautifully just for admin of course. After several hours of not figuring out why it didn't work for others, I then put them in separate blocks and realized it was quick pm preventing the whole block from being seen by others.

With your fix I now have them both back in one block which makes it very convenient on the site. Is it ok to have more than one block of code in the same portal block? I mean it works but is there any reason why I shouldn't?

I am attaching how I have it in one block so you can see what I mean.

---------------

Just a suggestion, this quick pm is really quite useful, however as someone else said it could be a problem with hundreds of members which I DO NOT have, but hope to one day. 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 it 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.

I do appreciate you help Phantomm.

Title: Re: Problem with Quick Pm only seen by admin
Post by: phantomm on September 19, 2012, 12:53:27 PM
If it works I don't see anything against it, but in my opinion it is more convenient to have in one block one custom PHP code, and if you want to save some space - just disable title for this block.

About suggestions related to Quick PM block, best place to post them is in topic where block was published => http://simpleportal.net/index.php?topic=9406.0 ;)

I'm glad that I could help :)
Title: Re: Problem with Quick Pm only seen by admin
Post by: boo2 on September 19, 2012, 01:38:57 PM
If it works I don't see anything against it, but in my opinion it is more convenient to have in one block one custom PHP code, and if you want to save some space - just disable title for this block.

About suggestions related to Quick PM block, best place to post them is in topic where block was published => http://simpleportal.net/index.php?topic=9406.0 ;)

I'm glad that I could help :)

Thanks Phantomm, I just posted over there.
Title: Re: Problem with Quick Pm only seen by admin
Post by: AngelinaBelle on September 20, 2012, 03:50:34 PM
I'm glad that workd.

phantomm -- oops.  I was not reading carefully.  I hope Dr. Deejay will be able to incorporate your fix.
SimplePortal 2.3.8 © 2008-2024, SimplePortal