コード例 #1
0
 public static function delete_article($articleid)
 {
     $db = cmsms()->GetDb();
     //Now remove the article
     $query = "DELETE FROM " . cms_db_prefix() . "module_news WHERE news_id = ?";
     $db->Execute($query, array($articleid));
     // Delete it from the custom fields
     $query = 'DELETE FROM ' . cms_db_prefix() . 'module_news_fieldvals WHERE news_id = ?';
     $db->Execute($query, array($articleid));
     // delete any files...
     $config = cmsms()->GetConfig;
     $p = cms_join_path($config['uploads_path'], 'news', 'id', $articleid);
     if (is_dir($p)) {
         recursive_delete($p);
     }
     news_admin_ops::delete_static_route($articleid);
     //Update search index
     $mod = cms_utils::get_module('News');
     $module = cms_utils::get_module('Search');
     if ($module != FALSE) {
         $module->DeleteWords($mod->GetName(), $articleid, 'article');
     }
     @$mod->SendEvent('NewsArticleDeleted', array('news_id' => $articleid));
     // put mention into the admin log
     audit($articleid, 'News: ' . $articleid, 'Article deleted');
 }
コード例 #2
0
}
# Setup default email template and email preferences
$this->SetPreference('email_subject', $this->Lang('subject_newnews'));
$this->SetTemplate('email_template', $this->GetDfltEmailTemplate());
# Other preferences
$this->SetPreference('allowed_upload_types', 'gif,png,jpeg,jpg');
$this->SetPreference('auto_create_thumbnails', 'gif,png,jpeg,jpg');
# Setup General category
$catid = $db->GenID(cms_db_prefix() . "module_news_categories_seq");
$query = 'INSERT INTO ' . cms_db_prefix() . 'module_news_categories (news_category_id, news_category_name, parent_id, create_date, modified_date) VALUES (?,?,?,' . $db->DBTimeStamp(time()) . ',' . $db->DBTimeStamp(time()) . ')';
$db->Execute($query, array($catid, 'General', -1));
# Setup initial news article
$articleid = $db->GenID(cms_db_prefix() . "module_news_seq");
$query = 'INSERT INTO ' . cms_db_prefix() . 'module_news ( NEWS_ID, NEWS_CATEGORY_ID, AUTHOR_ID, NEWS_TITLE, NEWS_DATA, NEWS_DATE, SUMMARY, START_TIME, END_TIME, STATUS, ICON, CREATE_DATE, MODIFIED_DATE ) VALUES (?,?,?,?,?,' . $db->DBTimeStamp(time()) . ',?,?,?,?,?,' . $db->DBTimeStamp(time()) . ',' . $db->DBTimeStamp(time()) . ')';
$db->Execute($query, array($articleid, $catid, 1, 'News Module Installed', 'The news module was installed.  Exciting. This news article is not using the Summary field and therefore there is no link to read more. But you can click on the news heading to read only this article.', null, null, null, 'published', null));
news_admin_ops::UpdateHierarchyPositions();
# Setup permissions
$perm_id = $db->GetOne("SELECT permission_id FROM " . cms_db_prefix() . "permissions WHERE permission_name = 'Modify News'");
$group_id = $db->GetOne("SELECT group_id FROM " . cms_db_prefix() . "groups WHERE group_name = 'Admin'");
$count = $db->GetOne("SELECT count(*) FROM " . cms_db_prefix() . "group_perms WHERE group_id = ? AND permission_id = ?", array($group_id, $perm_id));
if (isset($count) && intval($count) == 0) {
    $new_id = $db->GenID(cms_db_prefix() . "group_perms_seq");
    $query = "INSERT INTO " . cms_db_prefix() . "group_perms (group_perm_id, group_id, permission_id, create_date, modified_date) VALUES (" . $new_id . ", " . $group_id . ", " . $perm_id . ", " . $db->DBTimeStamp(time()) . ", " . $db->DBTimeStamp(time()) . ")";
    $db->Execute($query);
}
$group_id = $db->GetOne("SELECT group_id FROM " . cms_db_prefix() . "groups WHERE group_name = 'Editor'");
$count = $db->GetOne("SELECT count(*) FROM " . cms_db_prefix() . "group_perms WHERE group_id = ? AND permission_id = ?", array($group_id, $perm_id));
if (isset($count) && intval($count) == 0) {
    $new_id = $db->GenID(cms_db_prefix() . "group_perms_seq");
    $query = "INSERT INTO " . cms_db_prefix() . "group_perms (group_perm_id, group_id, permission_id, create_date, modified_date) VALUES (" . $new_id . ", " . $group_id . ", " . $perm_id . ", " . $db->DBTimeStamp(time()) . ", " . $db->DBTimeStamp(time()) . ")";
    $db->Execute($query);
コード例 #3
0
    echo $this->EndTab();
    echo $this->StartTab('detail_template', $params);
    echo '<h3>' . $this->Lang('title_available_templates') . '</h3>';
    news_admin_ops::AdminCreateTemplateList($id, $returnid, 'detail', 'default_detail_template_contents', 'detail_template', 'current_detail_template', $this->Lang('title_detail_template'));
    echo $this->EndTab();
    echo $this->StartTab('form_template', $params);
    echo '<h3>' . $this->Lang('title_available_templates') . '</h3>';
    news_admin_ops::AdminCreateTemplateList($id, $returnid, 'form', 'default_form_template_contents', 'form_template', 'current_form_template', $this->Lang('title_form_template'));
    echo $this->EndTab();
    echo $this->StartTab('browsecat_template', $params);
    echo '<h3>' . $this->Lang('title_available_templates') . '</h3>';
    news_admin_ops::AdminCreateTemplateList($id, $returnid, 'browsecat', 'default_browsecat_template_contents', 'browsecat_template', 'current_browsecat_template', $this->Lang('title_browsecat_template'));
    echo $this->EndTab();
    echo $this->StartTab('default_templates');
    echo '<p>' . $this->Lang('info_sysdefault2') . '</p>';
    news_admin_ops::AdminEditDefaultTemplateForm($id, $returnid, 'default_summary_template_contents', 'default_templates', $this->Lang('title_summary_sysdefault'), 'orig_summary_template.tpl', $this->Lang('info_sysdefault'));
    echo '<hr/>';
    news_admin_ops::AdminEditDefaultTemplateForm($id, $returnid, 'default_detail_template_contents', 'default_templates', $this->Lang('title_detail_sysdefault'), 'orig_detail_template.tpl', $this->Lang('info_sysdefault'));
    echo '<hr/>';
    news_admin_ops::AdminEditDefaultTemplateForm($id, $returnid, 'default_form_template_contents', 'default_templates', $this->Lang('title_form_sysdefault'), 'orig_form_template.tpl', $this->Lang('info_sysdefault'));
    echo '<hr/>';
    news_admin_ops::AdminEditDefaultTemplateForm($id, $returnid, 'default_browsecat_template_contents', 'default_templates', $this->Lang('title_browsecat_sysdefault'), 'browsecat.tpl', $this->Lang('info_sysdefault'));
    echo $this->EndTab();
}
if ($this->CheckPermission('Modify Site Preferences')) {
    echo $this->StartTab('options', $params);
    include dirname(__FILE__) . '/function.admin_optionstab.php';
    echo $this->EndTab();
}
echo $this->EndTabContent();
# vim:ts=4 sw=4 noet
コード例 #4
0
            $query = 'UPDATE ' . cms_db_prefix() . 'module_news_categories SET news_category_name = ?, parent_id = ?, modified_date = ' . $db->DBTimeStamp(time()) . ' WHERE news_category_id = ?';
            $parms = array($name, $parentid);
            $parms[] = $catid;
            $db->Execute($query, $parms);
            news_admin_ops::UpdateHierarchyPositions();
            @$this->SendEvent('NewsCategoryEdited', array('category_id' => $catid, 'name' => $name, 'origname' => $origname));
            $params = array('tab_message' => 'categoryupdated', 'active_tab' => 'categories');
            $this->Redirect($id, 'defaultadmin', $returnid, $params);
        }
    } else {
        echo $this->ShowErrors($this->Lang('nonamegiven'));
    }
} else {
    $query = 'SELECT * FROM ' . cms_db_prefix() . 'module_news_categories WHERE news_category_id = ?';
    $row = $db->GetRow($query, array($catid));
    if ($row) {
        $name = $row['news_category_name'];
        $parentid = (int) $row['parent_id'];
    }
}
#Display template
$smarty->assign('startform', $this->CreateFormStart($id, 'editcategory', $returnid));
$smarty->assign('endform', $this->CreateFormEnd());
$smarty->assign('nametext', $this->Lang('name'));
$smarty->assign('inputname', $this->CreateInputText($id, 'name', $name, 20, 255));
$smarty->assign('parentdropdown', news_admin_ops::CreateParentDropdown($id, $catid, $parentid));
$smarty->assign('hidden', $this->CreateInputHidden($id, 'catid', $catid) . $this->CreateInputHidden($id, 'origname', $name));
$smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', lang('submit')));
$smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', lang('cancel')));
$smarty->assign('parenttext', lang('parent'));
echo $this->ProcessTemplate('editcategory.tpl');
コード例 #5
0
        // put mention into the admin log
        audit($name, 'News custom: ' . $name, 'Field definition edited');
        $this->Redirect($id, 'defaultadmin', $returnid, $params);
    }
} else {
    $query = 'SELECT * FROM ' . cms_db_prefix() . 'module_news_fielddefs WHERE id = ?';
    $row = $db->GetRow($query, array($fdid));
    if ($row) {
        $name = $row['name'];
        $type = $row['type'];
        $max_length = $row['max_length'];
        $origname = $row['name'];
        $public = $row['public'];
        $extra = unserialize($row['extra']);
        if (isset($extra['options'])) {
            $options = news_admin_ops::array_to_optionstext($extra['options']);
        }
    }
}
#Display template
$smarty->assign('title', $this->Lang('editfielddef'));
$smarty->assign('startform', $this->CreateFormStart($id, 'admin_editfielddef', $returnid));
$smarty->assign('endform', $this->CreateFormEnd());
$smarty->assign('nametext', $this->Lang('name'));
$smarty->assign('typetext', $this->Lang('type'));
$smarty->assign('maxlengthtext', $this->Lang('maxlength'));
$smarty->assign('showinputtype', false);
$smarty->assign('inputtype', $this->CreateInputHidden($id, 'type', $type));
$smarty->assign('info_maxlength', $this->Lang('info_maxlength'));
$smarty->assign('userviewtext', $this->Lang('public'));
$smarty->assign('name', $name);
コード例 #6
0
ファイル: action.fesubmit.php プロジェクト: RTR-ITF/usse-cms
 if ($content == '') {
     $error = true;
     $smarty->assign('error', $this->Lang('nocontentgiven'));
 }
 // generate a new article id
 $articleid = $db->GenID(cms_db_prefix() . "module_news_seq");
 if ($error == false) {
     // test file upload custom fields
     $qu = "SELECT id,name,type FROM " . cms_db_prefix() . "module_news_fielddefs \n                WHERE type='file'";
     $fields = $db->GetArray($qu);
     foreach ($fields as $onefield) {
         $elem = $id . 'news_customfield_' . $onefield['id'];
         if (isset($_FILES[$elem]) && $_FILES[$elem]['name'] != '') {
             if ($_FILES[$elem]['error'] == 0 && $_FILES[$elem]['tmp_name'] != '') {
                 $error = '';
                 $value = news_admin_ops::handle_upload($articleid, $elem, $error);
                 if ($value === FALSE) {
                     $error = true;
                     $smarty->assign('error', $error);
                 }
                 $params['news_customfield_' . $onefield['id']] = $value;
             } else {
                 // error with upload
                 // abort the whole thing
                 $error = true;
                 $smarty->assign('error', $this->Lang('error_upload'));
             }
         }
     }
 }
 if ($error == false) {
コード例 #7
0
         if ($value == '') {
             continue;
         }
         $query = "INSERT INTO " . cms_db_prefix() . "module_news_fieldvals (news_id,fielddef_id,value,create_date,modified_date) VALUES (?,?,?,?,?)";
         $dbr = $db->Execute($query, array($articleid, $fldid, $value, $now, $now));
         if (!$dbr) {
             die('FATAL SQL ERROR: ' . $db->ErrorMsg() . '<br/>QUERY: ' . $db->sql);
         }
     }
 }
 // if
 if (!$error && $status == 'published' && $news_url != '') {
     // todo: if not expired
     // register the route.
     news_admin_ops::delete_static_route($articleid);
     news_admin_ops::register_static_route($news_url, $articleid);
 }
 if (!$error && $status == 'published') {
     //Update search index
     $module = cms_utils::get_search_module();
     if (is_object($module)) {
         $text = '';
         if (isset($params['customfield'])) {
             foreach ($params['customfield'] as $fldid => $value) {
                 if (strlen($value) > 1) {
                     $text .= $value . ' ';
                 }
             }
         }
         $text .= $content . ' ' . $summary . ' ' . $title . ' ' . $title;
         $module->AddWords($this->GetName(), $articleid, 'article', $text, $useexp == 1 && $this->GetPreference('expired_searchable', 0) == 0 ? $enddate : NULL);
コード例 #8
0
ファイル: News.module.php プロジェクト: Alexkuva/Beaupotager
 public function CreateStaticRoutes()
 {
     $db = cmsms()->GetDb();
     $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)\\/d,(?P<detailtemplate>.*?)$/', $this->GetName());
     cms_route_manager::add_static($route);
     $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)\\/(?P<junk>.*?)$/', $this->GetName());
     cms_route_manager::add_static($route);
     $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)\\/(?P<returnid>[0-9]+)$/', $this->GetName());
     cms_route_manager::add_static($route);
     $route = new CmsRoute('/[nN]ews\\/(?P<articleid>[0-9]+)$/', $this->GetName());
     cms_route_manager::add_static($route);
     $query = 'SELECT news_id,news_url FROM ' . cms_db_prefix() . 'module_news
           WHERE status = ? AND news_url != ? AND ' . '(' . $db->ifNull('start_time', $db->DbTimeStamp(1)) . ' < NOW()) AND ' . '((' . $db->IfNull('end_time', $db->DbTimeStamp(1)) . ' = ' . $db->DbTimeStamp(1) . ') OR (end_time > NOW()))';
     $query .= ' ORDER BY news_date DESC';
     $tmp = $db->GetArray($query, array('published', ''));
     if (is_array($tmp)) {
         foreach ($tmp as $one) {
             news_admin_ops::register_static_route($one['news_url'], $one['news_id']);
         }
     }
 }
コード例 #9
0
<?php

if (!isset($gCms)) {
    exit;
}
if (!$this->CheckPermission('Delete News')) {
    echo $this->ShowErrors($this->Lang('needpermission', array('Modify News')));
    return;
}
$articleid = '';
if (isset($params['articleid'])) {
    $articleid = $params['articleid'];
}
news_admin_ops::delete_article($articleid);
$params = array('tab_message' => 'articledeleted', 'active_tab' => 'articles');
$this->Redirect($id, 'defaultadmin', $returnid, $params);
コード例 #10
0
if (isset($params['type'])) {
    $type = $params['type'];
}
$max_length = 255;
if (isset($params['max_length'])) {
    $max_length = (int) $params['max_length'];
}
$public = 0;
if (isset($params['public'])) {
    $public = (int) $params['public'];
}
$arr_options = array();
$options = '';
if (isset($params['options'])) {
    $options = trim($params['options']);
    $arr_options = news_admin_ops::optionstext_to_array($options);
}
$userid = get_userid();
if (isset($params['submit'])) {
    $error = false;
    if ($name == '') {
        $error = $this->Lang('nonamegiven');
    }
    if (!$error && $type == 'dropdown' && count($arr_options) == 0) {
        $error = $this->Lang('error_nooptions');
    }
    if (!$error) {
        $query = 'SELECT id FROM ' . cms_db_prefix() . 'module_news_fielddefs WHERE name = ?';
        $exists = $db->GetOne($query, array($name));
        if ($exists) {
            $error = $this->Lang('nameexists');
コード例 #11
0
    if ($name != '') {
        $query = 'SELECT news_category_id FROM ' . cms_db_prefix() . 'module_news_categories WHERE parent_id = ? AND news_category_name = ?';
        $tmp = $db->GetOne($query, array($parent, $name));
        if ($tmp) {
            echo $this->ShowErrors($this->Lang('error_duplicatename'));
        } else {
            $catid = $db->GenID(cms_db_prefix() . "module_news_categories_seq");
            $time = $db->DBTimeStamp(time());
            $query = 'INSERT INTO ' . cms_db_prefix() . 'module_news_categories (news_category_id, news_category_name, parent_id, create_date, modified_date) VALUES (?,?,?,' . $time . ',' . $time . ')';
            $parms = array($catid, $name, $parent);
            $db->Execute($query, $parms);
            news_admin_ops::UpdateHierarchyPositions();
            @$this->SendEvent('NewsCategoryAdded', array('category_id' => $catid, 'name' => $name));
            $params = array('tab_message' => 'categoryadded', 'active_tab' => 'categories');
            $this->Redirect($id, 'defaultadmin', $returnid, $params);
        }
    } else {
        echo $this->ShowErrors($this->Lang('nonamegiven'));
    }
}
#Display template
$smarty->assign('startform', $this->CreateFormStart($id, 'addcategory', $returnid));
$smarty->assign('endform', $this->CreateFormEnd());
$smarty->assign('nametext', $this->Lang('name'));
$smarty->assign('inputname', $this->CreateInputText($id, 'name', $name, 20, 255));
$smarty->assign('parentdropdown', news_admin_ops::CreateParentDropdown($id, -1, -1));
$smarty->assign('hidden', '');
$smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', lang('submit')));
$smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', lang('cancel')));
$smarty->assign('parenttext', lang('parent'));
echo $this->ProcessTemplate('editcategory.tpl');