source: trunk/core/lib_content.php @ 782

Revision 782, 2.7 KB checked in by r2, 13 months ago (diff)

копирайты

  • Property svn:executable set to *
Line 
1<?php
2/******************************************************************************/
3//                                                                            //
4//                             InstantCMS v1.8                                //
5//                        http://www.instantcms.ru/                           //
6//                                                                            //
7//                   written by InstantCMS Team, 2007-2010                    //
8//                produced by InstantSoft, (www.instantsoft.ru)               //
9//                                                                            //
10//                        LICENSED BY GNU/GPL v2                              //
11//                                                                            //
12/******************************************************************************/
13
14if(!defined('VALID_CMS') && !defined('VALID_CMS_ADMIN')) { die('ACCESS DENIED'); }
15
16function cmsAutoCreateThread($article, $content_cfg){
17
18    $inCore     = cmsCore::getInstance();
19    $inDB       = cmsDatabase::getInstance();
20
21    if (!$content_cfg['af_on']){ return false; }
22    if (!$content_cfg['af_forum_id']){ return false; }
23    if ($article['category_id'] == $content_cfg['af_hidecat_id']) { return false; }
24
25    $inCore->loadModel('forum');
26    $model_forum = new cms_model_forum();
27
28    $seolink    = $inDB->get_field('cms_content', "id={$article['id']}", 'seolink');
29
30    $link       = '[URL=http://'.$_SERVER['HTTP_HOST'].'/'.$seolink.'.html]'.$article['title'].'[/URL]';
31
32    $post   = 'Â ýòîé òåìå ôîðóìà îáñóæäàåì ñòàòüþ &quot;'.$link.'&quot;';
33
34        $threadlastid = $model_forum->addThread(array(
35                        'forum_id' => $content_cfg['af_forum_id'],
36                        'user_id' => $article['user_id'],
37                        'title' => $article['title'],
38                        'description' => '',
39                        'is_hidden' => '0',
40                        'rel_to' => 'content',
41                        'rel_id' => $article['id']
42        ));
43
44        $lastid = $model_forum->addPost(array(
45                                        'thread_id' => $threadlastid,
46                                        'user_id' => $article['user_id'],
47                                        'message' => $post
48        ));
49        //ðåãèñòðèðóåì ñîáûòèå
50        $forum_title = $inDB->get_field('cms_forums', "id={$content_cfg['af_forum_id']}", 'title');
51        cmsActions::log('add_thread', array(
52                                'object' => $article['title'],
53                                'user_id' => $article['user_id'],
54                                'object_url' => '/forum/thread'.$threadlastid.'.html',
55                                'object_id' => $threadlastid,
56                                'target' => $forum_title,
57                                'target_url' => '/forum/'.$content_cfg['af_forum_id'],
58                                'target_id' => $content_cfg['af_forum_id'], 
59                                'description' => 'Â ýòîé òåìå ôîðóìà îáñóæäàåì ñòàòüþ &quot;<a href="http://'.$_SERVER['HTTP_HOST'].'/'.$seolink.'.html">'.$article['title'].'</a>&quot;'
60        ));     
61
62    return $threadlastid;
63}
64
65?>
Note: See TracBrowser for help on using the repository browser.