Subject: Allow owner change of all items

Posted on: 09/11/04 06:17am
By: 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.



# 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;
 }





Allow owner change of all items

Posted on: 29/11/04 07:18am
By: Martinez

[QUOTE BY= tokyoahead] ... To try it, paste the code into a static page (return-type PHP) ... [/QUOTE]

Hmm... Strange, but when I try to save a new static page with this code, my browser hangs out 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 ) 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


Allow owner change of all items

Posted on: 29/11/04 07:35am
By: Anonymous

[QUOTE BY= Martinez]Strange, but when I try to save a new static page with this code, my browser hangs out And worse - I don't know why... [/QUOTE]

Just from saving it?

there must be something weird. It works fine here.

Allow owner change of all items

Posted on: 29/11/04 08:07am
By: Martinez

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 ). After that I try it again


Allow owner change of all items

Posted on: 29/11/04 01:26pm
By: vinny

[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 ). After that I try it again [/QUOTE]

Remember, "diff" is your friend!

-Vinny

Allow owner change of all items

Posted on: 20/01/05 02:39am
By: 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".

Allow owner change of all items

Posted on: 20/05/05 06:18am
By: Robin

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?

Allow owner change of all items

Posted on: 20/05/05 06:46am
By: Anonymous

try downloading this file:

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

Allow owner change of all items

Posted on: 20/05/05 08:12am
By: Robin

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 ?

Allow owner change of all items

Posted on: 20/05/05 08:28am
By: Robin

An example
original code (fragment)
      ."<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
     ."<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

Allow owner change of all items

Posted on: 20/05/05 08:35am
By: Robin

\\ just testing

Allow owner change of all items

Posted on: 20/05/05 08:57am
By: 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.

Allow owner change of all items

Posted on: 20/05/05 09:35am
By: Robin

[QUOTE BY= tokyoahead] very strange.[/QUOTE]
Does it mean it works elsewhere e.g your site?
I tried this at different locations etc. and no can do

Allow owner change of all items

Posted on: 20/05/05 09:40am
By: 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.

Allow owner change of all items

Posted on: 25/10/06 05:50am
By: 1000ideen

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' ?

# 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"

Allow owner change of all items

Posted on: 25/10/06 08:44am
By: Anonymous

The static page is supposed to have the id
changeowner


Allow owner change of all items

Posted on: 25/10/06 11:37am
By: 1000ideen

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.

Allow owner change of all items

Posted on: 25/10/06 07:08pm
By: Anonymous

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

Allow owner change of all items

Posted on: 26/10/06 03:25am
By: 1000ideen

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.

Allow owner change of all items

Posted on: 26/10/06 05:52am
By: 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.

Allow owner change of all items

Posted on: 26/10/06 04:26pm
By: 1000ideen

Yes, it would be a job for someone who has an overview. There are good tools already like the cedit.php which I use in the mentioned way: http://www.geeklog.net/forum/viewtopic.php?showtopic=71321 And some tools are pretty destructive.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=42980