| Anonymous: tokyoahead |
 |
November 09 2004 06:17 AM (Read 4882 times) |
|
|
|
|
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.
PHP Formatted Code
# call this as :
# http://yoursite.com/staticpages/index.php?page=changeowner&changewhat=stories&item_id=20041018095452567¤t_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;
}
|
| |
|
|
| Martinez |
 |
November 29 2004 07:18 AM |
|
|

Newbie
Status: offline
Registered: 10/19/04
Posts: 7
|
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 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
|
| |
|
|
| Anonymous: tokyoahead |
 |
November 29 2004 07:35 AM |
|
|
|
|
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... Just from saving it? there must be something weird. It works fine here.
|
| |
|
|
| Martinez |
 |
November 29 2004 08:07 AM |
|
|

Newbie
Status: offline
Registered: 10/19/04
Posts: 7
|
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
|
| |
|
|
| vinny |
 |
November 29 2004 13:26 PM |
|
|

Moderator
Status: offline
Registered: 06/24/02
Posts: 352
|
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 Remember, "diff" is your friend! -Vinny
|
| |
|
|
| Anonymous: tokyoahead |
 |
January 20 2005 02:39 AM |
|
|
|
|
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".
|
| |
|
|
| Robin |
 |
May 20 2005 06:18 AM |
|
|

Full Member
Status: offline
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
|
| |
|
|
| Anonymous: tokyoahead |
 |
May 20 2005 06:46 AM |
|
|
|
|
try downloading this file:
http://tokyoahead.com/main/filemgmt/singlefile.php?lid=36
|
| |
|
|
| Robin |
 |
May 20 2005 08:12 AM |
|
|

Full Member
Status: offline
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 -> \ i.e. backslash.
Any ideas ?
Geeklog Polish Support Team
|
| |
|
|
| Robin |
 |
May 20 2005 08:28 AM |
|
|

Full Member
Status: offline
Registered: 02/15/02
Posts: 725
|
An example original code (fragment)
PHP 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 PHP 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
|
| |
|
|
| Robin |
 |
May 20 2005 08:35 AM |
|
|

Full Member
Status: offline
Registered: 02/15/02
Posts: 725
|
Geeklog Polish Support Team
|
| |
|
|
| Anonymous: tokyoahead |
 |
May 20 2005 08:57 AM |
|
|
|
|
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.
|
| |
|
|
| Robin |
 |
May 20 2005 09:35 AM |
|
|

Full Member
Status: offline
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
Geeklog Polish Support Team
|
| |
|
|
| Anonymous: tokyoahead |
 |
May 20 2005 09:40 AM |
|
|
|
|
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.
|
| |
|
|
| 1000ideen |
 |
October 25 2006 05:50 AM |
|
|

Full Member
 Status: offline
Registered: 08/04/03
Posts: 1135
|
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' ?
PHP Formatted Code
# call this as :
# http://yoursite.com/staticpages/index.php?page=changeowner&changewhat=stories&item_id=20041018095452567¤t_owner=2
# $what has to be one of the following: "comments", "events", "stories", "links"
|
| |
|
|
| Anonymous: tokyoahead |
 |
October 25 2006 08:44 AM |
|
|
|
|
The static page is supposed to have the id changeowner
|
| |
|
|
| 1000ideen |
 |
October 25 2006 11:37 AM |
|
|

Full Member
 Status: offline
Registered: 08/04/03
Posts: 1135
|
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.
|
| |
|
|
| Anonymous: tokyoahead |
 |
October 25 2006 19:08 PM |
|
|
|
|
the only thing you cannot do with that userlogin4root is change the ownership of an already exisiting item.
|
| |
|
|
| 1000ideen |
 |
October 26 2006 03:25 AM |
|
|

Full Member
 Status: offline
Registered: 08/04/03
Posts: 1135
|
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.
|
| |
|
|
| Anonymous: tokyoahead |
 |
October 26 2006 05:52 AM |
|
|
|
|
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.
|
| |
|
|