Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 07:47 am EDT

Geeklog Forums

Allow owner change of all items

Page navigation


tokyoahead

Anonymous
This is a first draft of a function (static page) that can change the owner of any internatal item. To try it, paste the code into a static page (return-type PHP) and call it with a link as described in the first lines of the code, adapted with a valid item's id.

Please tell me what you think. This could become a plugin, but I rather count on it beeing implemented into the core.

to implement this, one could either simply write another function that lets you choose the item to change from here. Otherwise, one would have to edit the admin pages and insert a link that would point to this function.

Text Formatted Code



# call this as :
# http://yoursite.com/staticpages/index.php?page=changeowner&changewhat=stories&item_id=20041018095452567&current_owner=2
# $what has to be one of the following: "comments", "events", "stories", "links"

$action=$_GET['action'];
if (!SEC_inGroup('Root')) {exit;}
if (empty($action)) {$action="select_new_owner";}

return $action();


function select_new_owner()
 {
 global $_TABLES;
 $what=$_GET['changewhat'];
 $item_id=$_GET['item_id'];
 $current_owner=$_GET['current_owner'];
 $table=$_TABLES[$what];

 $out.=COM_startBlock("Please select a new Owner of this $what:");
 $user_sql="SELECT * FROM {$_TABLES['users']} ORDER by `username`;";
 $user_records=DB_query($user_sql);

 $out.="<FORM action=\"./index.php\" method=\"GET\">\n";
 $out.="<input type=\"hidden\" name=\"page\" value=\"changeowner\">\n";
 $out.="<input type=\"hidden\" name=\"table\" value=\"$what\">\n";
 $out.="<input type=\"hidden\" name=\"action\" value=\"save_new_owner\">\n";
 $out.="<input type=\"hidden\" name=\"item_id\" value=\"$item_id\">\n";
 $out.="Username: <select name=\"new_uid\">\n";
 for ($i=0;$i<DB_numRows($user_records);$i++)
  {
  $A=DB_fetchArray($user_records);
  $username=$A['username'];
  $u_id=$A['uid'];
  if ($current_owner==$u_id) {$sel=" selected";} else {$sel="";}
  $out.="<option value=\"$u_id\"$sel>$username</option>\n";
  }
 $out.="</select><input type=\"submit\"></form>";
 $out.=COM_endBlock();
 return $out;
}

function save_new_owner()
 {
 global $_TABLES;
 $what=$_GET['table'];
 $table_id=substr($what,0,1) . "id";
 $table=$_TABLES[$what];
 $item_id=$_GET['item_id'];
 $new_uid=$_GET['new_uid'];
 $update_sql="UPDATE $table SET uid=$new_uid WHERE $table_id='$item_id' LIMIT 1";
 DB_query($update_sql);
 $out="The ID has been changed!";
 return $out;
 }




 
 Quote

Status: offline

Martinez

Forum User
Newbie
Registered: 10/19/04
Posts: 7
Location:Poland - Zakopane
Quote by tokyoahead: ... To try it, paste the code into a static page (return-type PHP) ...

Hmm... Strange, but when I try to save a new static page with this code, my browser hangs out Confused And worse - I don't know why... Writing simple static page works fine. Even static page with Your code to list inactive users (found on forum somewhere Wink) works and browser doesn't hangs while saving that page.


Maybe plugin (if no core implementation is made in the future) is a better way to implement this function Smile

 Quote

tokyoahead

Anonymous
Quote by Martinez:Strange, but when I try to save a new static page with this code, my browser hangs out Confused And worse - I don't know why...


Just from saving it?

there must be something weird. It works fine here.
 Quote

Status: offline

Martinez

Forum User
Newbie
Registered: 10/19/04
Posts: 7
Location:Poland - Zakopane

Yes, I know that's weird, cause It looks fine for me too.


I've must upgrade my geeklog to 1.3.10 final release first (RC1 using), but I don't have time (I've made some modification in core files without proper documentation and looks, like I've must do it again after upgrade Doh! - that was a mistake ). After that I try it again Smile

 Quote

Status: offline

vinny

Site Admin
Admin
Registered: 06/24/02
Posts: 352
Location:Colorado, USA
Quote by Martinez:
I've must upgrade my geeklog to 1.3.10 final release first (RC1 using), but I don't have time (I've made some modification in core files without proper documentation and looks, like I've must do it again after upgrade Doh! - that was a mistake ). After that I try it again Smile


Remember, "diff" is your friend!

-Vinny
 Quote

tokyoahead

Anonymous
If you get an error message like

Access to this page is denied. Either the page has been moved/removed or you do not have sufficient permissions.

make sure you set the ID of the static page to "changeowner".
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
I'm having a hard time with this script because after saving the static page the backslashes are stripped and the page returns errors.

Running GL 1.3.11.
Anyone else has the same issue?
Geeklog Polish Support Team
 Quote

tokyoahead

Anonymous
try downloading this file:

http://tokyoahead.com/main/filemgmt/singlefile.php?lid=36
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
Thanks for the tip but it's the same story.
It's not the problem with you script (which BTW is a great addon) but with staticpages that strip this -&gt; \ i.e. backslash.
Any ideas ?
Geeklog Polish Support Team
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
An example
original code (fragment)
Text Formatted Code
      ."<FORM action=\"{$_CONF['site_url']}/staticpages/index.php\" method=\"GET\">\n"
      ."<input type=\"hidden\" name=\"page\" value=\"$page\">\n"
      ."<input type=\"hidden\" name=\"action\" value=\"select_object\">\n"
      ."What do you want to change: <select name=\"what\">\n"
      ."<option value=\"stories\">story</option>\n"



 


after saving you have this
Text Formatted Code
     ."<FORM action="{$_CONF['site_url']}/staticpages/index.php" method="GET">n"
      ."<input type="hidden" name="page" value="$page">n"
      ."<input type="hidden" name="action" value="select_object">n"
      ."What do you want to change: <select name="what">n"
      ."<option value="stories">story</option>n"

 


and the following error appears after clicking on this page

Parse error: parse error, unexpected '{' in /my/path/to/geeklog/web/html/staticpages/index.php(56) : eval()'d code on line 44

Geeklog Polish Support Team
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
\\ just testing
Geeklog Polish Support Team
 Quote

tokyoahead

Anonymous
very strange.

You could alter the code and change the out double quotes that concatenate into single quotes and remove then the slashes in front of the inner double quotes.
 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
Quote by tokyoahead: very strange.

Does it mean it works elsewhere e.g your site?
I tried this at different locations etc. and no can do Sad
Geeklog Polish Support Team
 Quote

tokyoahead

Anonymous
I have installed this at multiple locations and it works fine

anyhow its completely new to me that a PHP-enable static page would strip ANYTHING.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
O.k. fist I had problems because of the $_CONF['censormode'] = 1; being on. Turned it off, then saving worked fine.

Next problem is what is that link supposed to be called? Is the example id=20041018095452567 the id of the static page or the item to be changed?

Is the '$what' is the word 'what' in 'changewhat' ?

Text Formatted Code

# call this as :
# http://yoursite.com/staticpages/index.php?page=changeowner&changewhat=stories&item_id=20041018095452567&current_owner=2
# $what has to be one of the following: "comments", "events", "stories", "links"
 
 Quote

tokyoahead

Anonymous
The static page is supposed to have the id
changeowner

 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
O.k. it worked. I just wonder if that is still necessary now after having this tool: http://sourceforge.net/project/showfiles.php?group_id=121539&package_id=208088

Changing the owner is just one part of the game. The other one is "I don`t see any blocks (-> help me with my account settings)" or "I can`t upload my userpic."

So I think the root user acting as user is an ideal tool and should solve all of the problems before.
 Quote

tokyoahead

Anonymous
the only thing you cannot do with that userlogin4root is change the ownership of an already exisiting item.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
It seems that the wish to change the owner was mostly based on the problem that the admin wanted to submit stories, links etc on behalve of an unexperienced user. I suppose it would be extremely rare to change anything afterwards. An unexperienced admin might just write the story again being logged in as the user this time.

Anyway, I think that a bunch of online tech tools for the admin would be very nice. Maybe one could design a block with tools like the Admin Toolbox: http://gplugs.pigstye.net/staticpages/index.php/20030301113613982

There are a few more tools like the 'group access tool' or the 'bulk group admin' or your 'owner change tool' and maybe 'Staticpage to Access error.log' http://www.geeklog.net/article.php/ErrorLogHack

The point is the more you deal with the details the more you dare looking into the MySQL itself.
 Quote

tokyoahead

Anonymous
The problem with such a toolbox is that some of the tools are old and from different admins, some things are in the core now in newer version and some of the old code does not work anymore. Its an effort to maintain all these tools and so they will stay as single applications, coming from different authors and developed for different versions of geeklog.
 Quote

Page navigation

All times are EDT. The time is now 07:47 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content