public
Description: Blog Modules for CMS Made Simple 2.0
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsms-blog.git
wishy (author)
Tue Apr 08 07:38:46 -0700 2008
commit  152d572f05e09fde11a744326fe200ced0fe35a7
tree    97757d18effd003c36428e9c00af1e6e7a98efcd
parent  3aef452680351b0d4f2343fd4fbd0aa68bbf9255
cmsms-blog / action.editpost.php
100644 54 lines (44 sloc) 1.609 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
54
<?php
if (!isset($gCms)) die("Can't call actions directly!");
 
if (array_key_exists('cancelpost', $params))
{
  $this->redirect($id, 'defaultadmin', $return_id, array('selected_tab' => 'manageposts'));
}
 
$blog_post = cms_orm('BlogPost')->find_by_id($params['blog_post_id']);
if ($blog_post == null)
{
  $this->redirect($id, 'defaultadmin', $return_id, array('selected_tab' => 'manageposts'));
}
 
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->redirect($id, 'defaultadmin', $return_id, array('selected_tab' => 'manageposts'));
  }
}
 
$smarty->assign('categories', cms_orm('BlogCategory')->find_all(array('order' => 'name ASC')));
$smarty->assign('processors', CmsTextProcessor::list_processors_for_dropdown());
 
$smarty->assign('form_action', 'editpost');
$smarty->assign('post_date_prefix', $id . 'post_date_');
$smarty->assign('blog_post', $blog_post);
echo $this->process_template('editpost.tpl', $id, $return_id);
 
# vim:ts=4 sw=4 noet
?>