| 1942 | | |
| 1943 | | # FIXME: Scaling issue for lots of authors on one blog |
| 1944 | | my $auth_iter = MT::Author->load_iter( |
| 1945 | | { type => MT::Author::AUTHOR() }, |
| 1946 | | { |
| 1947 | | 'join' => MT::Permission->join_on( |
| 1948 | | 'author_id', { blog_id => $blog_id } |
| 1949 | | ), |
| 1950 | | limit => 51, |
| 1951 | | } |
| 1952 | | ); |
| 1953 | | while ( my $author = $auth_iter->() ) { |
| 1954 | | $authors{ $author->id } = $author->name; |
| 1955 | | push @a_data, |
| 1956 | | { |
| 1957 | | author_id => $author->id, |
| 1958 | | author_name => encode_js( $author->name ) |
| 1959 | | }; |
| 1960 | | } |
| 1961 | | @a_data = sort { $a->{author_name} cmp $b->{author_name} } @a_data; |
| 1962 | | my $i = 0; |
| 1963 | | for my $row (@a_data) { |
| 1964 | | $row->{author_index} = $i++; |
| 1965 | | } |
| 1966 | | $param->{author_loop} = \@a_data; |
| 2082 | | my @this_a_data; |
| 2083 | | my $this_author_id = $obj->author_id; |
| 2084 | | for my $a_id (@auth_list) { |
| 2085 | | push @this_a_data, |
| 2086 | | { |
| 2087 | | author_name => $authors{$a_id}, |
| 2088 | | author_id => $a_id |
| 2089 | | }; |
| 2090 | | $this_a_data[-1]{author_is_selected} = $this_author_id |
| 2091 | | && $this_author_id == $a_id ? 1 : 0; |
| 2092 | | } |
| 2093 | | unless ( $obj->author ) { |
| 2094 | | push @this_a_data, |
| 2095 | | { |
| 2096 | | author_name => $app->translate( |
| 2097 | | '(user deleted - ID:[_1])', |
| 2098 | | $obj->author_id |
| 2099 | | ), |
| 2100 | | author_id => $obj->author_id, |
| 2101 | | author_is_selected => 1, |
| 2102 | | }; |
| 2103 | | } |
| 2104 | | $row->{row_author_loop} = \@this_a_data; |
| | 2053 | if ( $obj->author ) { |
| | 2054 | $row->{row_author_name} = $obj->author->name; |
| | 2055 | $row->{row_author_id} = $obj->author->id; |
| | 2056 | } else { |
| | 2057 | $row->{row_author_name} = $app->translate( |
| | 2058 | '(user deleted - ID:[_1])', |
| | 2059 | $obj->author_id |
| | 2060 | ); |
| | 2061 | $row->{row_author_id} = $obj->author_id, |
| | 2062 | } |