Dotclear

source: admin/blog_pref.php @ 1537:a3ac778e9132

Revision 1537:a3ac778e9132, 21.5 KB checked in by Lepeltier kévin, 11 years ago (diff)

Ticket #1406 : on encapsule new dcMedia dans des try catch pour crriger plusieurs bug.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13$standalone = !isset($edit_blog_mode);
14
15$blog_id = false;
16
17if ($standalone)
18{
19     require dirname(__FILE__).'/../inc/admin/prepend.php';
20     dcPage::check('admin');
21     $blog_id = $core->blog->id;
22     $blog_status = $core->blog->status;
23     $blog_name = $core->blog->name;
24     $blog_desc = $core->blog->desc;
25     $blog_settings = $core->blog->settings;
26     $blog_url = $core->blog->url;
27     
28     $action = 'blog_pref.php';
29     $redir = 'blog_pref.php?upd=1';
30}
31else
32{
33     dcPage::checkSuper();
34     try
35     {
36          if (empty($_REQUEST['id'])) {
37               throw new Exception(__('No given blog id.'));
38          }
39          $rs = $core->getBlog($_REQUEST['id']);
40         
41          if (!$rs) {
42               throw new Exception(__('No such blog.'));
43          }
44         
45          $blog_id = $rs->blog_id;
46          $blog_status = $rs->blog_status;
47          $blog_name = $rs->blog_name;
48          $blog_desc = $rs->blog_desc;
49          $blog_settings = new dcSettings($core,$blog_id);
50          $blog_url = $rs->blog_url ; 
51     }
52     catch (Exception $e)
53     {
54          $core->error->add($e->getMessage());
55     }
56     
57     $action = 'blog.php';
58     $redir = 'blog.php?id=%s&upd=1';
59}
60
61# Language codes
62$langs = l10n::getISOcodes(1,1);
63foreach ($langs as $k => $v) {
64     $lang_avail = $v == 'en' || is_dir(DC_L10N_ROOT.'/'.$v);
65     $lang_combo[] = new formSelectOption($k,$v,$lang_avail ? 'avail10n' : '');
66}
67
68# Status combo
69foreach ($core->getAllBlogStatus() as $k => $v) {
70     $status_combo[$v] = (string) $k;
71}
72
73# URL scan modes
74$url_scan_combo = array(
75     'PATH_INFO' => 'path_info',
76     'QUERY_STRING' => 'query_string'
77);
78
79# Post URL combo
80$post_url_combo = array(
81     __('year/month/day/title') => '{y}/{m}/{d}/{t}',
82     __('year/month/title') => '{y}/{m}/{t}',
83     __('year/title') => '{y}/{t}',
84     __('title') => '{t}',
85     __('post id/title') => '{id}/{t}',
86     __('post id') => '{id}'
87);
88if (!in_array($blog_settings->system->post_url_format,$post_url_combo)) {
89     $post_url_combo[html::escapeHTML($blog_settings->system->post_url_format)] = html::escapeHTML($blog_settings->system->post_url_format);
90}
91
92# Note title tag combo
93$note_title_tag_combo = array(
94     __('H4') => 0,
95     __('H3') => 1,
96     __('P') => 2
97);
98
99# Image title combo
100$img_title_combo = array(
101     __('(none)') => '',
102     __('Title') => 'Title ;; separator(, )',
103     __('Title, Date') => 'Title ;; Date(%b %Y) ;; separator(, )',
104     __('Title, Country, Date') => 'Title ;; Country ;; Date(%b %Y) ;; separator(, )',
105     __('Title, City, Country, Date') => 'Title ;; City ;; Country ;; Date(%b %Y) ;; separator(, )',
106);
107if (!in_array($blog_settings->system->media_img_title_pattern,$img_title_combo)) {
108     $img_title_combo[html::escapeHTML($blog_settings->system->media_img_title_pattern)] = html::escapeHTML($blog_settings->system->media_img_title_pattern);
109}
110
111# Image default size combo
112$img_default_size_combo = array();
113try {
114     $media = new dcMedia($core);
115     $img_default_size_combo[__('original')] = 'o';
116     foreach ($media->thumb_sizes as $code => $size) {
117          $img_default_size_combo[__($size[2])] = $code;
118     }
119} catch (Exception $e) {
120     $core->error->add($e->getMessage());
121}
122
123# Image default alignment combo
124$img_default_alignment_combo = array(
125     __('None') => 'none',
126     __('Left') => 'left',
127     __('Right') => 'right',
128     __('Center') => 'center'
129);
130
131# Robots policy options
132$robots_policy_options = array(
133     'INDEX,FOLLOW' => __("I would like search engines and archivers to index and archive my blog's content."),
134     'INDEX,FOLLOW,NOARCHIVE' => __("I would like search engines and archivers to index but not archive my blog's content."),
135     'NOINDEX,NOFOLLOW,NOARCHIVE' => __("I would like to prevent search engines and archivers from indexing or archiving my blog's content."),
136);
137
138# Update a blog
139if ($blog_id && !empty($_POST) && $core->auth->check('admin',$blog_id))
140{
141     $cur = $core->con->openCursor($core->prefix.'blog');
142     if ($core->auth->isSuperAdmin()) {
143          $cur->blog_id = $_POST['blog_id'];
144          $cur->blog_url = preg_replace('/\?+$/','?',$_POST['blog_url']); 
145          if (in_array($_POST['blog_status'],$status_combo)) {
146               $cur->blog_status = (integer) $_POST['blog_status'];
147          }
148     }
149     $cur->blog_name = $_POST['blog_name'];
150     $cur->blog_desc = $_POST['blog_desc'];
151     
152     $media_img_t_size = abs((integer) $_POST['media_img_t_size']);
153     if ($media_img_t_size < 0) { $media_img_t_size = 100; }
154     
155     $media_img_s_size = abs((integer) $_POST['media_img_s_size']);
156     if ($media_img_s_size < 0) { $media_img_s_size = 240; }
157     
158     $media_img_m_size = abs((integer) $_POST['media_img_m_size']);
159     if ($media_img_m_size < 0) { $media_img_m_size = 448; }
160     
161     $nb_post_per_page = abs((integer) $_POST['nb_post_per_page']);
162     if ($nb_post_per_page <= 1) { $nb_post_per_page = 1; }
163     
164     $nb_post_per_feed = abs((integer) $_POST['nb_post_per_feed']);
165     if ($nb_post_per_feed <= 1) { $nb_post_per_feed = 1; }
166     
167     $nb_comment_per_feed = abs((integer) $_POST['nb_comment_per_feed']);
168     if ($nb_comment_per_feed <= 1) { $nb_comment_per_feed = 1; }
169     
170     try
171     {
172          if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
173               $rs = $core->getBlog($cur->blog_id);
174               
175               if ($rs) {
176                    throw new Exception(__('That blog Id is already in use.'));
177               }
178          }
179         
180          # --BEHAVIOR-- adminBeforeBlogUpdate
181          $core->callBehavior('adminBeforeBlogUpdate',$cur,$blog_id);
182         
183          if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_POST['lang'])) {
184               throw new Exception(__('Invalid language code'));
185          }
186         
187          $core->updBlog($blog_id,$cur);
188         
189          # --BEHAVIOR-- adminAfterBlogUpdate
190          $core->callBehavior('adminAfterBlogUpdate',$cur,$blog_id);
191         
192          if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
193               if ($blog_id == $core->blog->id) {
194                    $core->setBlog($cur->blog_id);
195                    $_SESSION['sess_blog_id'] = $cur->blog_id;
196                    $blog_settings = $core->blog->settings;
197               } else {
198                    $blog_settings = new dcSettings($core,$cur->blog_id);
199               }
200               
201               $blog_id = $cur->blog_id;
202          }
203         
204         
205          $blog_settings->addNameSpace('system');
206         
207          $blog_settings->system->put('editor',$_POST['editor']);
208          $blog_settings->system->put('copyright_notice',$_POST['copyright_notice']);
209          $blog_settings->system->put('post_url_format',$_POST['post_url_format']);
210          $blog_settings->system->put('lang',$_POST['lang']);
211          $blog_settings->system->put('blog_timezone',$_POST['blog_timezone']);
212          $blog_settings->system->put('date_format',$_POST['date_format']);
213          $blog_settings->system->put('time_format',$_POST['time_format']);
214          $blog_settings->system->put('comments_ttl',abs((integer) $_POST['comments_ttl']));
215          $blog_settings->system->put('trackbacks_ttl',abs((integer) $_POST['trackbacks_ttl']));
216          $blog_settings->system->put('allow_comments',!empty($_POST['allow_comments']));
217          $blog_settings->system->put('allow_trackbacks',!empty($_POST['allow_trackbacks']));
218          $blog_settings->system->put('comments_pub',empty($_POST['comments_pub']));
219          $blog_settings->system->put('trackbacks_pub',empty($_POST['trackbacks_pub']));
220          $blog_settings->system->put('comments_nofollow',!empty($_POST['comments_nofollow']));
221          $blog_settings->system->put('wiki_comments',!empty($_POST['wiki_comments']));
222          $blog_settings->system->put('enable_xmlrpc',!empty($_POST['enable_xmlrpc']));
223          $blog_settings->system->put('note_title_tag',$_POST['note_title_tag']);
224         
225          $blog_settings->system->put('nb_post_per_page',$nb_post_per_page);
226          $blog_settings->system->put('use_smilies',!empty($_POST['use_smilies']));
227          $blog_settings->system->put('media_img_t_size',$media_img_t_size);
228          $blog_settings->system->put('media_img_s_size',$media_img_s_size);
229          $blog_settings->system->put('media_img_m_size',$media_img_m_size);
230          $blog_settings->system->put('media_img_title_pattern',$_POST['media_img_title_pattern']);
231          $blog_settings->system->put('media_img_use_dto_first',!empty($_POST['media_img_use_dto_first']));
232          $blog_settings->system->put('media_img_default_size',$_POST['media_img_default_size']);
233          $blog_settings->system->put('media_img_default_alignment',$_POST['media_img_default_alignment']);
234          $blog_settings->system->put('media_img_default_link',!empty($_POST['media_img_default_link']));
235          $blog_settings->system->put('nb_post_per_feed',$nb_post_per_feed);
236          $blog_settings->system->put('nb_comment_per_feed',$nb_comment_per_feed);
237          $blog_settings->system->put('short_feed_items',!empty($_POST['short_feed_items']));
238         
239          if (isset($_POST['robots_policy'])) {
240               $blog_settings->system->put('robots_policy',$_POST['robots_policy']);
241          }
242         
243          # --BEHAVIOR-- adminBeforeBlogSettingsUpdate
244          $core->callBehavior('adminBeforeBlogSettingsUpdate',$blog_settings);
245         
246          if ($core->auth->isSuperAdmin() && in_array($_POST['url_scan'],$url_scan_combo)) {
247               $blog_settings->system->put('url_scan',$_POST['url_scan']);
248          }
249         
250          http::redirect(sprintf($redir,$blog_id));
251     }
252     catch (Exception $e)
253     {
254          $core->error->add($e->getMessage());
255     }
256}
257
258dcPage::open(__('Blog settings'),
259     '<script type="text/javascript">'."\n".
260     "//<![CDATA["."\n".
261     dcPage::jsVar('dotclear.msg.warning_path_info',
262          __('Warning: except for special configurations, it is generally advised to have a trailing "/" in your blog URL in PATH_INFO mode.'))."\n".
263     dcPage::jsVar('dotclear.msg.warning_query_string',
264          __('Warning: except for special configurations, it is generally advised to have a trailing "?" in your blog URL in QUERY_STRING mode.'))."\n".
265     "//]]>".
266     "</script>".
267     dcPage::jsConfirmClose('blog-form').
268     dcPage::jsLoad('js/_blog_pref.js').
269     
270     
271     # --BEHAVIOR-- adminBlogPreferencesHeaders
272     $core->callBehavior('adminBlogPreferencesHeaders').
273     
274     dcPage::jsPageTabs()
275);
276
277if ($blog_id)
278{
279     echo '<h2>'.(!$standalone ? '<a href="blogs.php">'.__('Blogs').'</a> &rsaquo; ' : '').
280     html::escapeHTML($blog_name).' &rsaquo; <span class="page-title">'.
281     __('Blog settings').'</span></h2>';
282     
283     if (!empty($_GET['add'])) {
284          dcPage::message(__('Blog has been successfully created.'));
285     }
286     
287     if (!empty($_GET['upd'])) {
288          dcPage::message(__('Blog has been successfully updated.'));
289     }
290     
291     echo
292     '<div class="multi-part" id="params" title="'.__('Parameters').'">'.
293     '<h3>'.__('Parameters').'</h3>'.
294     '<form action="'.$action.'" method="post" id="blog-form">';
295     
296     echo
297     '<fieldset><legend>'.__('Blog details').'</legend>'.
298     $core->formNonce();
299     
300     if ($core->auth->isSuperAdmin())
301     {
302          echo
303          '<p><label for="blog_id" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog ID:').
304          form::field('blog_id',30,32,html::escapeHTML($blog_id)).'</label></p>'.
305          '<p class="form-note">'.__('At least 2 characters using letters, numbers or symbols.').'</p> '.
306          '<p class="form-note warn">'.__('Please note that changing your blog ID may require changes in your public index.php file.').'</p>';
307     }
308     
309     echo
310     '<p><label for="blog_name" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog name:').
311     form::field('blog_name',30,255,html::escapeHTML($blog_name)).'</label></p>';
312     
313     if ($core->auth->isSuperAdmin())
314     {
315          echo
316          '<p><label for="blog_url" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog URL:').
317          form::field('blog_url',30,255,html::escapeHTML($blog_url)).'</label></p>'.
318         
319          '<p><label for="url_scan">'.__('URL scan method:').
320          form::combo('url_scan',$url_scan_combo,$blog_settings->system->url_scan).'</label></p>'.
321         
322          '<p><label for="blog_status">'.__('Blog status:').
323          form::combo('blog_status',$status_combo,$blog_status).'</label></p>';
324     }
325     
326     echo
327     '<p class="area"><label for="blog_desc">'.__('Blog description:').'</label>'.
328     form::textarea('blog_desc',60,5,html::escapeHTML($blog_desc)).'</p>'.
329     '</fieldset>';
330     
331     
332     echo
333     '<fieldset><legend>'.__('Blog configuration').'</legend>'.
334     '<div class="two-cols">'.
335     '<div class="col">'.
336     '<p><label for="editor">'.__('Blog editor name:').
337     form::field('editor',30,255,html::escapeHTML($blog_settings->system->editor)).
338     '</label></p>'.
339     
340     '<p><label for="lang">'.__('Default language:').
341     form::combo('lang',$lang_combo,$blog_settings->system->lang,'l10n').
342     '</label></p>'.
343     
344     '<p><label for="blog_timezone">'.__('Blog timezone:').
345     form::combo('blog_timezone',dt::getZones(true,true),html::escapeHTML($blog_settings->system->blog_timezone)).
346     '</label></p>'.
347
348     '<p><label for="copyright_notice">'.__('Copyright notice:').
349     form::field('copyright_notice',30,255,html::escapeHTML($blog_settings->system->copyright_notice)).
350     '</label></p>'.
351     '</div>'.
352     
353     '<div class="col">'.
354     '<p><label for="post_url_format">'.__('New post URL format:').
355     form::combo('post_url_format',$post_url_combo,html::escapeHTML($blog_settings->system->post_url_format)).
356     '</label></p>'.
357
358     '<p><label for="note_title_tag">'.__('Note title HTML tag:').
359     form::combo('note_title_tag',$note_title_tag_combo,$blog_settings->system->note_title_tag).
360     '</label></p>'.
361         
362     '<p><label for="enable_xmlrpc" class="classic">'.
363     form::checkbox('enable_xmlrpc','1',$blog_settings->system->enable_xmlrpc).
364     __('Enable XML/RPC interface').'</label></p>';
365
366     echo
367          '<p class="form-note">'.__('XML/RPC interface allows you to edit your blog with an external client.').'</p>'; 
368
369     if ($blog_settings->system->enable_xmlrpc) {
370          echo
371          '<p>'.__('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:').'</p>'.
372          '<ul>'.
373          '<li>'.__('Server URL:').' <strong><code>'.
374          sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id).
375          '</code></strong></li>'.
376          '<li>'.__('Blogging system:').' <strong><code>Movable Type</code></strong></li>'.
377          '<li>'.__('User name:').' <strong><code>'.$core->auth->userID().'</code></strong></li>'.
378          '<li>'.__('Password:').' <strong><code>&lt;'.__('your password').'&gt;</code></strong></li>'.
379          '<li>'.__('Blog ID:').' <strong><code>1</code></strong></li>'.
380          '</ul>';
381     }
382
383     echo
384     '</div>'.
385     '</div>'.
386     '<br class="clear" />'. //Opera sucks
387     '</fieldset>';
388     
389     echo
390     '<fieldset><legend>'.__('Comments and trackbacks').'</legend>'.
391     '<div class="two-cols">'.
392     '<div class="col">'.
393     '<p><label for="allow_comments" class="classic">'.
394     form::checkbox('allow_comments','1',$blog_settings->system->allow_comments).
395     __('Accept comments').'</label></p>'.
396     
397     '<p><label for="comments_pub" class="classic">'.
398     form::checkbox('comments_pub','1',!$blog_settings->system->comments_pub).
399     __('Moderate comments').'</label></p>'.
400     
401     '<p><label for="comments_ttl" class="classic">'.sprintf(__('Leave comments open for %s days'),
402     form::field('comments_ttl',2,3,$blog_settings->system->comments_ttl)).
403     '</label></p>'.
404     '<p class="form-note">'.__('Leave blank to disable this feature.').'</p>'.
405     
406     '<p><label for="wiki_comments" class="classic">'.
407     form::checkbox('wiki_comments','1',$blog_settings->system->wiki_comments).
408     __('Wiki syntax for comments').'</label></p>'.
409     '</div>'.
410     
411     '<div class="col">'.
412     '<p><label for="allow_trackbacks" class="classic">'.
413     form::checkbox('allow_trackbacks','1',$blog_settings->system->allow_trackbacks).
414     __('Accept trackbacks').'</label></p>'.
415     
416     '<p><label for="trackbacks_pub" class="classic">'.
417     form::checkbox('trackbacks_pub','1',!$blog_settings->system->trackbacks_pub).
418     __('Moderate trackbacks').'</label></p>'.
419     
420     '<p><label for="trackbacks_ttl" class="classic">'.sprintf(__('Leave trackbacks open for %s days'),
421     form::field('trackbacks_ttl',2,3,$blog_settings->system->trackbacks_ttl)).'</label></p>'.
422     '<p class="form-note">'.__('Leave blank to disable this feature.').'</p>'.
423     
424     '<p><label for="comments_nofollow" class="classic">'.
425     form::checkbox('comments_nofollow','1',$blog_settings->system->comments_nofollow).
426     __('Add "nofollow" relation on comments and trackbacks links').'</label></p>'.
427     '</div>'.
428     '</div>'.
429     '<br class="clear" />'. //Opera sucks
430     '</fieldset>';
431     
432     echo
433     '<fieldset><legend>'.__('Blog presentation').'</legend>'.
434     '<div class="two-cols">'.
435     '<div class="col">'.
436     '<p><label for="date_format">'.__('Date format:').
437     form::field('date_format',30,255,html::escapeHTML($blog_settings->system->date_format)).
438     '</label></p>'.
439     
440     '<p><label for="time_format">'.__('Time format:').
441     form::field('time_format',30,255,html::escapeHTML($blog_settings->system->time_format)).
442     '</label></p>'.
443     
444     '<p><label for="use_smilies" class="classic">'.
445     form::checkbox('use_smilies','1',$blog_settings->system->use_smilies).
446     __('Display smilies on entries and comments').'</label></p>'.
447     '</div>'.
448     
449     '<div class="col">'.
450     '<p><label for="nb_post_per_page" class="classic">'.sprintf(__('Display %s entries per page'),
451     form::field('nb_post_per_page',2,3,$blog_settings->system->nb_post_per_page)).
452     '</label></p>'.
453     
454     '<p><label for="nb_post_per_feed" class="classic">'.sprintf(__('Display %s entries per feed'),
455     form::field('nb_post_per_feed',2,3,$blog_settings->system->nb_post_per_feed)).
456     '</label></p>'.
457     
458     '<p><label for="nb_comment_per_feed" class="classic">'.sprintf(__('Display %s comments per feed'),
459     form::field('nb_comment_per_feed',2,3,$blog_settings->system->nb_comment_per_feed)).
460     '</label></p>'.
461     
462     '<p><label for="short_feed_items" class="classic">'.
463     form::checkbox('short_feed_items','1',$blog_settings->system->short_feed_items).
464     __('Truncate feeds').'</label></p>'.
465     '</div>'.
466    '</div>'.
467     '<br class="clear" />'. //Opera sucks
468     '</fieldset>';
469     
470     echo
471     '<fieldset><legend>'.__('Media and images').'</legend>'.
472     '<div class="two-cols">'.
473     '<div class="col">'.
474     '<h4>'.__('Generated image sizes (in pixels)').'</h4>'.
475     '<p class="field"><label for="media_img_t_size">'.__('Thumbnails:').' '.
476     form::field('media_img_t_size',3,3,$blog_settings->system->media_img_t_size).'</label></p>'.
477     
478     '<p class="field"><label for="media_img_s_size">'.__('Small:').' '.
479     form::field('media_img_s_size',3,3,$blog_settings->system->media_img_s_size).'</label></p>'.
480     
481     '<p class="field"><label for="media_img_m_size">'.__('Medium:').' '.
482     form::field('media_img_m_size',3,3,$blog_settings->system->media_img_m_size).'</label></p>'.
483     '</div>'.
484     
485     '<div class="col">'.
486     '<h4><label for="media_img_title_pattern">'.__('Inserted image title').'</label></h4>'.
487     '<p>'.__('This defines image tag title when you insert it in a post from the media manager. It is retrieved from the picture\'s metadata.').'</p>'.
488     '<p>'.form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).'</p>'.
489     '<p><label for="media_img_use_dto_first" class="classic">'.
490     form::checkbox('media_img_use_dto_first','1',$blog_settings->system->media_img_use_dto_first).
491     __('Use original media date if possible').'</label></p>'.
492
493     '<h4>'.__('Default image insertion attributes').'</h4>'.
494     '<p><label for="media_img_default_size">'.__('Image size:').
495     form::combo('media_img_default_size',$img_default_size_combo,
496          (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')).
497     '</label></p>'.
498     '<p><label for="media_img_default_alignment">'.__('Image alignment').
499     form::combo('media_img_default_alignment',$img_default_alignment_combo,html::escapeHTML($blog_settings->system->media_img_default_alignment)).
500     '</label></p>'.
501     '<p><label for="media_img_default_link" class="classic">'.
502     form::checkbox('media_img_default_link','1',$blog_settings->system->media_img_default_link).
503     __('As a link to original image').'</label></p>'.
504     '</div>'.
505     '</div>'.
506
507     '</fieldset>';
508     
509     echo
510     '<fieldset><legend>'.__('Search engines robots policy').'</legend>';
511     
512     $i = 0;
513     foreach ($robots_policy_options as $k => $v)
514     {
515          echo '<p><label for="robots_policy-'.$i.'" class="classic">'.
516          form::radio(array('robots_policy','robots_policy-'.$i),$k,$blog_settings->system->robots_policy == $k).' '.$v.'</label></p>';
517          $i++;
518     }
519     
520     echo '</fieldset>';
521     
522     
523     # --BEHAVIOR-- adminBlogPreferencesForm
524     $core->callBehavior('adminBlogPreferencesForm',$core,$blog_settings);
525     
526     echo
527     '<p><input type="submit" accesskey="s" value="'.__('Save').'" />'.
528     (!$standalone ? form::hidden('id',$blog_id) : '').
529     '</p>'.
530     '</form>';
531     
532     if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id)
533     {
534          echo
535          '<form action="blog_del.php" method="post">'.
536          '<p><input type="submit" class="delete" value="'.__('Delete this blog').'" />'.
537          form::hidden(array('blog_id'),$blog_id).
538          $core->formNonce().'</p>'.
539          '</form>';
540     } else {
541          if ($blog_id == $core->blog->id) {
542               echo '<p class="message">'.__('The current blog cannot be deleted').'</p>';
543          } else {
544               echo '<p class="message">'.__('Only superadmin can delete a blog').'</p>';
545          }
546     }
547     
548     echo '</div>';
549     
550     #
551     # Users on the blog (with permissions)
552     
553     $blog_users = $core->getBlogPermissions($blog_id,$core->auth->isSuperAdmin());
554     $perm_types = $core->auth->getPermissionsTypes();
555     
556     echo
557     '<div class="multi-part" id="users" title="'.__('Users').'">'.
558     '<h3>'.__('Users on this blog').'</h3>';
559     
560     if (empty($blog_users))
561     {
562          echo '<p>'.__('No users').'</p>';
563     }
564     else
565     {
566          if ($core->auth->isSuperAdmin()) {
567               $user_url_p = '<a href="user.php?id=%1$s">%1$s</a>';
568          } else {
569               $user_url_p = '%1$s';
570          }
571         
572          foreach ($blog_users as $k => $v)
573          {
574               if (count($v['p']) > 0)
575               {
576                    echo
577                    '<h4>'.sprintf($user_url_p,html::escapeHTML($k)).
578                    ' ('.html::escapeHTML(dcUtils::getUserCN(
579                         $k, $v['name'], $v['firstname'], $v['displayname']
580                    )).')</h4>';
581                   
582                    echo '<ul>';
583                    if ($v['super']) {
584                         echo '<li>'.__('Super administrator').'</li>';
585                    } else {
586                         foreach ($v['p'] as $p => $V) {
587                              echo '<li>'.__($perm_types[$p]).'</li>';
588                         }
589                    }
590                    echo '</ul>';
591                   
592                    if (!$v['super'] && $core->auth->isSuperAdmin()) {
593                         echo 
594                         '<form action="users_actions.php" method="post">'.
595                         '<p><input type="submit" value="'.__('Change permissions').'" />'.
596                         form::hidden(array('redir'),'blog_pref.php?id='.$k).
597                         form::hidden(array('action'),'perms').
598                         form::hidden(array('users[]'),$k).
599                         form::hidden(array('blogs[]'),$blog_id).
600                         $core->formNonce().
601                         '</p>'.
602                         '</form>';
603                    }
604               }
605          }
606     }
607     
608     echo '</div>';
609}
610
611dcPage::helpBlock('core_blog_pref');
612dcPage::close();
613?>
Note: See TracBrowser for help on using the repository browser.

Sites map