DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • May 17, 2013, 10:28:00 PM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: 1 [2]   Go Down
  Print  
Author Topic: Suggestion: In Chat Options!  (Read 2443 times)
0 Members and 1 Guest are viewing this topic.
HunterD
Captain of the Guard
***
Offline Offline

Posts: 101



View Profile WWW
« Reply #15 on: April 23, 2012, 07:26:14 AM »

Only because I feel I should...
For you AJAX users... in /ajaxcommentary.php
Code:
FIND:
$outputcomments=array();
$sect="x";

for(;$i>-1;$i--){
$out="";
Code:
INSERT THIS CODE BELOW THE $out=""; :
 if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
              $out .= "`2[<a href='runmodule.php?module=comedit&op=edit&id={$commentids[$i]}'>E</a>`2]`0&nbsp;";
              addnav("", "runmodule.php?module=comedit&op=edit&id={$commentids[$i]}");
              $sql = "UPDATE " . db_prefix("commentary") . " SET comment='" . $comment . "', author=" . $author . ", section='" . $section . "' WHERE commentid=$id";
            }
            if ($session['user']['superuser'] & SU_EDIT_COMMENTS && !$session['user']['superuser'] & SU_EDIT_USERS) {
                $out .= "`2[<a href='" . $return . $one . "removecomment={$commentids[$i]}&section=$section&returnpath=" . URLEncode($return) . "'>D</a>`2]`0&nbsp;";
                addnav("", $return . $one . "removecomment={$commentids[$i]}&section=$section&returnpath=" . URLEncode($return) . "");
            }
            if ($session['user']['superuser'] & SU_EDIT_USERS && !$session['user']['superuser'] & SU_EDIT_COMMENTS) {
                $out .= "`2[<a href='user.php?op=edit&userid={$auth[$i]}'>UE</a>`2]`0&nbsp;";
                addnav("", "user.php?op=edit&userid={$auth[$i]}");
            }
            if ($session['user']['superuser'] & SU_EDIT_USERS && $session['user']['superuser'] & SU_EDIT_COMMENTS) {
                $out .= "`2[<a href='" . $return . $one . "removecomment={$commentids[$i]}&section=$section&returnpath=" . URLEncode($return) . "'>D</a> `&|`0&nbsp;";
                addnav("", $return . $one . "removecomment={$commentids[$i]}&section=$section&returnpath=" . URLEncode($return) . "");
                $out .= "<a href='user.php?op=edit&userid={$auth[$i]}'>UE</a>`2]`0&nbsp;";
                addnav("", "user.php?op=edit&userid={$auth[$i]}");
            }

However.. someone should check this for me... I know it works for my UE staff, but my mods only get Edit.

Best I can do, it's a step in the right direction.
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 823


View Profile WWW
« Reply #16 on: April 23, 2012, 12:40:23 PM »

First of all the code should be as follows...

Code:
if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
              $out .= "`2[<a href='runmodule.php?module=comedit&op=edit&id={$commentids[$i]}'>Edit</a>`2]`0&nbsp;";
              addnav("", "runmodule.php?module=comedit&op=edit&id={$commentids[$i]}");
              $sql = "UPDATE " . db_prefix("commentary") . " SET comment='" . $comment . "', author=" . $author . ", section='" . $section . "'

WHERE commentid=$id";
            }
               if ($session['user']['superuser'] & SU_EDIT_USERS && $session['user']['superuser'] & SU_EDIT_COMMENTS) {
                $out .= "`2[<a href='" . $return . $one . "removecomment={$commentids[$i]}&section=$section&returnpath=" . URLEncode

($return) . "'>Del</a>`2]`0&nbsp;";
                addnav("", $return . $one . "removecomment={$commentids[$i]}&section=$section&returnpath=" . URLEncode($return) . "");
                $out .= "`2[<a href='user.php?op=edit&userid={$auth[$i]}'>UE</a>`2]`0&nbsp;";
                addnav("", "user.php?op=edit&userid={$auth[$i]}");
            }


Secondly it makes a white page that says:

Not Found

The requested URL /test/removecomment=11&section=superuser&returnpath= was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Logged

(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination
HunterD
Captain of the Guard
***
Offline Offline

Posts: 101



View Profile WWW
« Reply #17 on: April 23, 2012, 12:45:31 PM »

The code requires certain variables... like these:
Code:

    $scriptname = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
    $pos        = strpos($_SERVER['REQUEST_URI'], "?");
    $return     = $scriptname . ($pos == false ? "" : substr($_SERVER['REQUEST_URI'], $pos));
    $one        = (strstr($return, "?") == false ? "?" : "&");

However, the return URI is for the ajaxcommentary, not for the actual village.  So it will show the raw code as the return, and not delete the comment.  Frustrating.  I'm going to just keep the edit commentary and UE features for now, until we can figure out how to get the delete to return to the correct village.

Thanks, Aeolus, for suggesting/adding the module call, and I hope my code here helps you towards your goal.  If you figure it out, share!

~H
Logged

Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 823


View Profile WWW
« Reply #18 on: April 23, 2012, 12:52:30 PM »

But it works fine plugged into the lib/commentary.php  Odd. 
Logged

(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination
staticobj
Militia
**
Offline Offline

Posts: 90

Keep it Simple Stupid


View Profile WWW
« Reply #19 on: April 23, 2012, 01:13:09 PM »

Stop thinking of the code as if it were synchronous.

The actual page request for the village occurs first and is then followed by each sequential request to the file that supplies the messages. Neither of these occur at the same time. So the only state PHP is made aware of is that of the file that responds with the messages.

This would simply imply that $_SERVER is only going to give you information related to those requests.

The solution is to get the SCRIPT_NAME/REQUEST_URI during the first synchronous to village.php, etc. Store that or pass it so long as it is available in the scope of the file that supplies the messages.

All of this has long since been resolved in the ZCL module.
« Last Edit: April 23, 2012, 01:20:42 PM by staticobj » Logged

Want a custom template? Private Message me for a quote.
Click here for web hosting offer. I'm willing to work with you. Please send a Private Message for further details.
www.legacyofdragon.com
HunterD
Captain of the Guard
***
Offline Offline

Posts: 101



View Profile WWW
« Reply #20 on: April 23, 2012, 01:31:44 PM »

Stop thinking of the code as if it were synchronous.

Synchronous Hunter is synchronous. xD 

Quote
The actual page request for the village occurs first and is then followed by each sequential request to the file that supplies the messages. Neither of these occur at the same time. So the only state PHP is made aware of is that of the file that responds with the messages.

Ok.. so if I read that right, PHP only grabs the ajaxcommentary.php as the last state,  NOT the village, superuser, whatever.

Quote
This would simply imply that $_SERVER is only going to give you information related to those requests.

The solution is to get the SCRIPT_NAME/REQUEST_URI during the first synchronous to village.php, etc. Store that or pass it so long as it is available in the scope of the file that supplies the messages.

Alrighty... so this would have to be pulled before AJAX refreshes the chat... any idea on the procedure and/or location to do this?  I'm no Superman... I get by with a little help from my friends.. *wink*

Quote
All of this has long since been resolved in the ZCL module.
Which is being tested on my testbox. xD

Thanks for any and all input folks.  This will help those of us left in the dust on the AJAX project get a bit more control and ease of moderation for our active chats. xD
Logged

staticobj
Militia
**
Offline Offline

Posts: 90

Keep it Simple Stupid


View Profile WWW
« Reply #21 on: April 23, 2012, 01:40:21 PM »

Right.

I kept it simple by grabbing the REQUEST_URI, encoding it, and copying it to the session.
Code: (PHP)
<?php
$session
['ret'] = urlencode($_SERVER['REQUEST_URI']);
// or
$_SESSION['ret'] = urlencode($_SERVER['REQUEST_URI']);

Then access the session data with the REQUEST_URI later to return to the village.php, superuser.php, etc.
Logged

Want a custom template? Private Message me for a quote.
Click here for web hosting offer. I'm willing to work with you. Please send a Private Message for further details.
www.legacyofdragon.com
Megan|SaraBeth
Mod God
*****
Offline Offline

Posts: 823


View Profile WWW
« Reply #22 on: April 23, 2012, 01:46:33 PM »

In that bit of code I posted, the updated version to Hunter's, where would one put that code you just told us?
Logged

(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination
staticobj
Militia
**
Offline Offline

Posts: 90

Keep it Simple Stupid


View Profile WWW
« Reply #23 on: April 23, 2012, 01:54:45 PM »

That could be a rather complicated question in this situation as it will need to go into the comedit module as a return link. Both the User Editor and Remove Comment links you'd just supply the $ret variable to the returnpath argument of the URI.

Code: (PHP)
<?php
$ret 
$_SESSION['ret'];
....
other code...
$out .= "....&returnpath={$ret}";

The actual line of code I posted will need to go into lib/commentary.php or be added to a hook such as blockcommentarea, etc.
Logged

Want a custom template? Private Message me for a quote.
Click here for web hosting offer. I'm willing to work with you. Please send a Private Message for further details.
www.legacyofdragon.com
HunterD
Captain of the Guard
***
Offline Offline

Posts: 101



View Profile WWW
« Reply #24 on: April 23, 2012, 02:57:26 PM »

Thanks, Static.  Been thinking... perhaps the need for the refresh would slow down an accidental deletion.  RPing staff and all. xD

As such, I've given up on adding Del functionality.

Thanks for all of your help... and if someone else picks up the ball and runs with this.. share? xD
Logged

Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #25 on: June 30, 2012, 06:39:26 AM »

Thanks for all of your help... and if someone else picks up the ball and runs with this.. share? xD

And that is what I most certainly shall do! Grin After hours of slaving over this computer, I finally worked it out! xD My thanks to Static and Hunter for their earlier help too - it played a major part in getting this to work.
« Last Edit: June 30, 2012, 06:43:19 AM by Aeolus » Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
23 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search