Changeset 1378
- Timestamp:
- 02/19/08 03:16:04 (22 months ago)
- Location:
- branches/release-30
- Files:
-
- 4 modified
-
lib/MT/App/CMS.pm (modified) (1 diff)
-
lib/MT/CMS/Entry.pm (modified) (3 diffs)
-
lib/MT/CMS/User.pm (modified) (1 diff)
-
tmpl/cms/include/entry_table.tmpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-30/lib/MT/App/CMS.pm
r1369 r1378 204 204 'dialog_select_sysadmin' => "${pkg}User::dialog_select_sysadmin", 205 205 'dialog_grant_role' => "${pkg}User::dialog_grant_role", 206 'dialog_select_author' => "${pkg}User::dialog_select_author", 206 207 207 208 ## AJAX handlers -
branches/release-30/lib/MT/CMS/Entry.pm
r1369 r1378 1936 1936 my ( $date_format, $datetime_format ); 1937 1937 1938 ## Load list of users for display in filter pulldown (and selection1939 ## pulldown on power edit page).1940 my ( @a_data, %authors );1941 1938 if ($is_power_edit) { 1942 1943 # FIXME: Scaling issue for lots of authors on one blog1944 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;1967 1939 $date_format = "%Y.%m.%d"; 1968 1940 $datetime_format = "%Y-%m-%d %H:%M:%S"; … … 1973 1945 } 1974 1946 1975 my ( @cat_list, @auth_list );1947 my @cat_list; 1976 1948 if ($is_power_edit) { 1977 1949 @cat_list = 1978 1950 sort { $cats{$a}->{category_index} <=> $cats{$b}->{category_index} } 1979 1951 keys %cats; 1980 @auth_list = sort { $authors{$a} cmp $authors{$b} } keys %authors;1981 1952 } 1982 1953 … … 2080 2051 $row->{row_category_loop} = \@this_c_data; 2081 2052 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 } 2105 2063 } 2106 2064 if ( my $blog = $blogs{ $obj->blog_id } ||= -
branches/release-30/lib/MT/CMS/User.pm
r1369 r1378 1171 1171 } 1172 1172 1173 sub dialog_select_author { 1174 my $app = shift; 1175 1176 my $hasher = sub { 1177 my ( $obj, $row ) = @_; 1178 $row->{label} = $row->{name}; 1179 $row->{description} = $row->{nickname}; 1180 }; 1181 1182 $app->listing( 1183 { 1184 type => 'author', 1185 terms => { 1186 type => MT::Author::AUTHOR(), 1187 status => MT::Author::ACTIVE(), 1188 }, 1189 args => { 1190 sort => 'name', 1191 join => MT::Permission->join_on( 1192 'author_id', 1193 { 1194 permissions => "\%'create_post'\%", 1195 blog_id => $app->blog->id, 1196 }, 1197 { 'like' => { 'permissions' => 1 } } 1198 ), 1199 }, 1200 code => $hasher, 1201 template => 'dialog/select_users.tmpl', 1202 params => { 1203 dialog_title => 1204 $app->translate("Select a entry author"), 1205 items_prompt => 1206 $app->translate("Selected author"), 1207 search_prompt => $app->translate( 1208 "Type a username to filter the choices below."), 1209 panel_label => $app->translate("Entry author"), 1210 panel_description => $app->translate("Name"), 1211 panel_type => 'author', 1212 panel_multi => defined $app->param('multi') 1213 ? $app->param('multi') 1214 : 0, 1215 panel_searchable => 1, 1216 panel_first => 1, 1217 panel_last => 1, 1218 list_noncron => 1, 1219 idfield => $app->param('idfield'), 1220 namefield => $app->param('namefield'), 1221 }, 1222 } 1223 ); 1224 } 1225 1173 1226 sub dialog_select_sysadmin { 1174 1227 my $app = shift; -
branches/release-30/tmpl/cms/include/entry_table.tmpl
r1260 r1378 168 168 <td class="author"> 169 169 <mt:if name="is_editable"> 170 <select name="author_id_<$mt:var name="id"$>"> 171 <mt:unless name="author_id"> 172 <option value=""><__trans phrase="None"></option> 173 </mt:unless> 174 <mt:loop name="row_author_loop"> 175 <option value="<$mt:var name="author_id"$>"<mt:if name="author_is_selected"> selected="selected"</mt:if>><$mt:var name="author_name"$></option> 176 </mt:loop> 177 </select> 170 <input type="hidden" name="author_id_<$mt:var name="id"$>" value="<$mt:var name="row_author_id"$>" id="entry_author_id_<$mt:var name="id"$>"> 171 <a href="javascript:void(0)" onclick="return openDialog(this.form, 'dialog_select_author', 'blog_id=<$mt:var name="blog_id"$>&multi=0&idfield=entry_author_id_<$mt:var name="id"$>&namefield=entry_author_name_<$mt:var name="id"$>')"><span id="entry_author_name_<$mt:var name="id"$>"><$mt:var name="row_author_name"$></span></a> 178 172 <mt:else> 179 173 <$mt:var name="author_name"$>
