public
Description: Blog Modules for CMS Made Simple 2.0
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsms-blog.git
cmsms-blog / action.defaultadmin.php
100644 53 lines (43 sloc) 1.762 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
if (!isset($gCms)) die("Can't call actions directly!");
 
//Set for the new blog posting
$blog_post = new BlogPost();
$blog_post->author_id = CmsLogin::get_current_user()->id;
 
if (isset($params['submitpost']) || isset($params['submitpublish']))
{
  $blog_post->update_parameters($params['blog_post']);
  
  if (isset($params['post_date_Month']))
  {
    $blog_post->post_date = new CmsDateTime(mktime($params['post_date_Hour'], $params['post_date_Minute'], $params['post_date_Second'], $params['post_date_Month'], $params['post_date_Day'], $params['post_date_Year']));
  }
  
  if (isset($params['submitpublish']))
  {
    $blog_post->status = 'publish';
  }
 
  if ($blog_post->save())
  {
    if (isset($params['blog_post']['category']))
    {
      $blog_post->clear_categories();
      foreach ($params['blog_post']['category'] as $k => $v)
      {
        if ($v == 1)
          $blog_post->set_category($k);
      }
    }
 
    $this->blog_post = new BlogPost();
    $blog_post->author_id = CmsLogin::get_current_user()->id;
  }
}
 
$smarty->assign('selected_tab', coalesce_key($params, 'selected_tab', 'writepost'));
$smarty->assign('form_action', 'defaultadmin');
$smarty->assign('blog_post', $blog_post);
$smarty->assign('post_date_prefix', $id . 'post_date_');
 
$smarty->assign('posts', cms_orm('BlogPost')->find_all(array('order' => 'id desc')));
$smarty->assign('categories', cms_orm('BlogCategory')->find_all(array('order' => 'name ASC')));
$smarty->assign('processors', CmsTextProcessor::list_processors_for_dropdown());
 
$smarty->assign('writepost', $this->process_template('editpost.tpl', $id, $return_id));
$smarty->assign('manageposts', $this->process_template('listposts.tpl', $id, $return_id));
echo $this->process_template('defaultadmin.tpl', $id, $return_id);
 
# vim:ts=4 sw=4 noet
?>