CMS  Version 3.9
contact_topics.inc
Go to the documentation of this file.
1 <?php
2 /**************************************************************
3 
4  Copyright (c) 2010 Sonjara, Inc
5 
6  Permission is hereby granted, free of charge, to any person
7  obtaining a copy of this software and associated documentation
8  files (the "Software"), to deal in the Software without
9  restriction, including without limitation the rights to use,
10  copy, modify, merge, publish, distribute, sublicense, and/or sell
11  copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following
13  conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  Except as contained in this notice, the name(s) of the above
19  copyright holders shall not be used in advertising or otherwise
20  to promote the sale, use or other dealings in this Software
21  without prior written authorization.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30  OTHER DEALINGS IN THE SOFTWARE.
31 
32 *****************************************************************/
33 
34 /*
35  * Description: table list view of contact us topics
36  *
37  * author: Janice Gallant for Sonjara, Inc.
38  *
39  * date: 11/18/10
40 
41 ***************************************************************/
42 
43 
44 Fakoli::using("email");
45 Fakoli::usingFeature("data_view");
46 
47 $menu_item = "Contact Topics";
48 
49 $title = "Contact Topics";
50 
51 $topics = query(ContactTopic, "ORDER BY sort_order");
52 
53 $table = new DataListView($topics, "contactTopics");
54 $table->column("Code Name", "<a href=\"/admin/contact_topic_form?contact_topic_id={contact_topic_id}\">{topic}</a>")
55  ->column("Topic", "{topic}")
56  ->column("Recipients", "{recipients}");
57 
58 $sites = query(Site);
59 if(count($sites) > 1)
60  $table->column("Sites", formatSiteList);
61 
62 $table->emptyMessage = "There are no contact topics defined.";
63 $table->sortable = false;
64 $table->cssStyle = "width: 100%";
65 $table->enableDragReorder("/action/email/reorder_contact_topics");
66 $table->dragText = "<span style='font-size: 10px'>Click and drag to reorder contact topics</span>";
67 
68 
69 if ($method == "POST")
70 {
72  // refresh
73  redirect("/admin/contact_topics");
74 }
75 
76 $script .= $table->writeScript();
77 
78 ?>
79 <p>Contact Us Topics are displayed to users in a drop down menu when completing the Contact Us form.</p>
80 <form style='display: inline' name="contact_topics_form" method="POST" action="">
81 
82 <?php
83 $table->drawView();
84 ?>
85 <br><br><input class='button' type="submit" name="reorder" value="&nbsp;Update Topic Order&nbsp;"/>&nbsp;&nbsp;
86 <a class='button' href='/admin/contact_topic_form'>Add a Contact Us Topic</a>
87 </form>
88 <?php
90 {
91  return "<input type='text' name='contact_topic_{$contactTopic->contact_topic_id}'
92  value='{$contactTopic->sort_order}' size='4'/>";
93 
94 }
95 
97 {
98  $sites = $contactTopic->Sites();
99  return formatItems($sites, "{site_name}", "<br>");
100 }
101 
103 {
104  global $_POST;
105  // reorder
106  foreach($_POST as $name => $value)
107  {
108  if (!strncmp($name, "contact_topic_", 14))
109  {
110  $id = substr($name, 14);
111  $contactTopic = new ContactTopic();
112  $contactTopic->filter = new InclusionFilter("contact_topic_id", "sort_order");
113  $contactTopic->contact_topic_id = $id;
114  $contactTopic->sort_order = $value;
115  $contactTopic->save();
116  }
117  }
118  // renumber
119  $contactTopics = query(ContactTopic, "ORDER BY sort_order");
120  $value = 1;
121 
122  foreach($contactTopics as $contactTopic)
123  {
124  $contactTopic->filter = new InclusionFilter("sort_order");
125  $contactTopic->sort_order = $value;
126  $contactTopic->save();
127  $value++;
128  } // end reOrder
129 }
130 ?>
& nbsp
Definition: index.inc:49
$_POST["owner_id"]
Definition: blog_form.inc:54
$helpTree style
Definition: tree.inc:46
$form action
Definition: edit.inc:67
$name
Definition: upload.inc:54
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
Definition: site.inc:40
This class maps the topic table.
Definition: topic.inc:38
formatSiteList($contactTopic)
$sites
formatSortOrderInputField($contactTopic)
$topics
$menu_item
reorderContactTopics()
$title
$table
if($method=="POST") $script
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$forumRequest to