public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
tedkulp (author)
Sun Apr 27 07:29:54 -0700 2008
commit  1d4e393fe0cae8142711a915f87157611a76f101
tree    5ae931db88ca7b522756bf319e6cfc6ccda35924
parent  5c1eb285cfb340bd5332b019ff18afc44a4d5881
cmsmadesimple-2-0 / admin / addhtmlblob.php
100644 106 lines (87 sloc) 2.923 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
#CMS - CMS Made Simple
#(c)2004-2008 by Ted Kulp (ted@cmsmadesimple.org)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
 
$CMS_ADMIN_PAGE=1;
 
require_once("../include.php");
$error = "";
 
$htmlblob = "";
if (isset($_POST['htmlblob'])) $htmlblob = $_POST['htmlblob'];
 
$content = "";
if (isset($_POST['content'])) $content = $_POST['content'];
 
if (isset($_POST["cancel"]))
{
  redirect("listhtmlblobs.php");
}
 
$gCms = cmsms();
$smarty = cms_smarty();
$smarty->assign('action', 'addhtmlblob.php');
 
$contentops = $gCms->GetContentOperations();
$gcbops = $gCms->GetGlobalContentOperations();
 
#Make sure we're logged in and get that user id
check_login();
$userid = get_userid();
$access = check_permission($userid, 'Add Global Content Blocks');
 
require_once("header.php");
// Create an array of additional editors
$db = cms_db();
$addt_users = "";
$query = "SELECT id, username FROM ".cms_db_prefix()."users WHERE id <> ? ORDER BY username";
$result = $db->Execute($query, array($userid));
if ($result && $result->RecordCount() > 0) {
  while($row = $result->FetchRow()) {
    $addt_users .= "<option value=\"".$row["id"]."\">".$row["username"]."</option>";
  }
}else{
  $addt_users = "<option>&nbsp;</option>";
}
 
 
$submit = array_key_exists('submitbutton', $_POST);
 
function &get_gcb_object()
{
  $gcb_object = new CmsGlobalContent();
  if (isset($_REQUEST['gcb']))
    $gcb_object->update_parameters($_REQUEST['gcb']);
  return $gcb_object;
}
 
//Get a working page object
$gcb_object = get_gcb_object($userid);
$gcb_wysiwyg = get_preference($userid, 'gcb_wysiwyg', 1);
 
if ($access)
{
  if ($submit)
  {
    if ($gcb_object->save())
    {
      if (isset($_POST["additional_editors"])) {
        foreach ($_POST["additional_editors"] as $addt_user_id) {
          $gcb_object->AddAuthor($addt_user_id);
        }
      }
      audit($gcb_object->id, $gcb_object->name, 'Added Global Content Block');
      redirect("listhtmlblobs.php");
    }
  }
}
 
//Add the header
$smarty->assign('header_name', $themeObject->ShowHeader('addhtmlblob'));
 
//Assign additional editors
$smarty->assign('addt_users', $addt_users);
 
//Setup the gcb object
$smarty->assign_by_ref('gcb_object', $gcb_object);
 
$smarty->display('addhtmlblob.tpl');
 
include_once("footer.php");
?>