Welcome to Geeklog, Anonymous Friday, November 29 2024 @ 02:36 am EST

Geeklog Forums

changing story author code


Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
ever wanted to change the author to your stories? I know you have Shocked
so here it is. This code is not very thick, but it works--tested on 1.3.10.

couple things to note:
* permissions are based upon the owner id not the author id, AFAICS
* this code will only altar the author and not the owner of a story.
* up to this point the author and the owner are based on the same id--not any more.
* this all means that no matter who you change the author to be, if that user has no permission to access the story (view/edit/etc.) they will still have no permission to access the story. Those settings can be set using the story perms and/or groups admin. As I said, this only altars the display in the byline. It seems to me that is all you guys were asking for.

3 changes to make
in /public_html/admin/story.php, approx. line 148, change this:
Text Formatted Code
        $A['old_sid'] = $A['sid'];
    } elseif (!empty($sid) && $mode == 'editsubmission') {

 
to this:
Text Formatted Code
        $A['old_sid'] = $A['sid'];
        //inserted by machinai to get proper author and provide the ability to change authors
        $A['uid'] = DB_getItem ($_TABLES['stories'], 'uid', "sid = '$sid'");
    } elseif (!empty($sid) && $mode == 'editsubmission') {

 

and at approx. line 271, change this:
Text Formatted Code
    $story_templates->set_var('lang_author', $LANG24[7]);
    $story_templates->set_var ('story_author', DB_getItem ($_TABLES['users'],
                               'username', "uid = {$A['uid']}"));
    $story_templates->set_var('story_uid', $A['uid']);

    // user access info

 
to this:
Text Formatted Code
    $story_templates->set_var('lang_author', $LANG24[7]);
    $authorA = DB_query("SELECT uid, username FROM {$_TABLES['users']} WHERE uid > '1'");
    $author_option = '';
    while($authrow= DB_fetchArray($authorA)){
        $author_option .= '<option value="' . $authrow['uid'] . '"';
        if($authrow['uid'] == $A['uid']){
            $author_option .= ' selected="selected"';
        } else $cur_author = '';
        $author_option .= '>' . $authrow['username'] . '</option>' . LB;
    }
    $author_dropdown = '<select name="uid">' . $author_option . '</select>';
    $story_templates->set_var ('author_dropdown', $author_dropdown);

    // user access info

 
I guess I could've used the author list function from the top of the file... maybe next time.

Also make this change in your /layout/professional/admin/storyeditor.thtml at approx. line 20, from this:
Text Formatted Code
                                    <tr>
                                        <td align="right">{lang_author}:</td>
                                        <td>{story_author}<input type="hidden" name="uid" value="{story_uid}"></td>
                                    </tr>

 
to this:
Text Formatted Code
                                    <tr>
                                        <td align="right">{lang_author}:</td>
                                        <td>
                                            {author_dropdown}
                                        </td>
                                    </tr>

 
I used the professional theme. your theme's storyeditor.thtml may be a bit different.

If you don't make backups of these files before you make these changes, you have no one to blame when you have unexplained errors returned and your wife begins to nag you for sitting in front of the computer for too long....
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512

I neglected to mention that if you are editing an anonymous submission, the author dropdown doesn't allow anonymous so an author will be applied. obviously this is unexceptable. easy to fix. just throw in another if/else.

maybe i'll do that tomorrow.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512

Shocked I just realized that Tokyoahead did up a staticpage for this plus more...
oh well, here is that file link.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by machinari: I guess I could've used the author list function from the top of the file... maybe next time.

The problem with that function is that it takes a long time to load when you have a lot of users (there are Geeklog sites that have a 6-digit number of users ...).

I had the option to change the story's author in CVS at one point, but reverted it, mainly due to this problem. Entering the username or uid didn't look like a viable option to me then.

bye, Dirk
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
yes yes, I hadn't thought of the slow down caused by so many rows being returned. I only have about 6 users so...
 Quote

tokyoahead

Anonymous
I have released a new version of my plugin.
It reduces the maximum numbers of lines displayed to 100.
if there is more than 100 items or users, there is a filter displayed:

A
B
C
...

you click on the letter, and if there are more than 100 users/items with A*... it will display

AA
AB
AC
...

(of course only those that exist will be diplayed)
please check it out at my site here. I will upload it also here.
 Quote

All times are EST. The time is now 02:36 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