Remove cutenews/yui, use twitter bootstrap css
[contractdashboard.git] / editnews.mdu
1 <?PHP
2
3 if($member_db[1] > 3){ msg("error", "Access Denied", "You don't have permission to edit news"); }
4
5
6
7
8 $orig_cat_lines = file("./data/category.db.php");
9 //only show allowed categories
10 $allowed_cats = array();
11 $cat_lines = array();
12 foreach($orig_cat_lines as $single_line){
13 $ocat_arr = explode("|", $single_line);
14 $cat[$ocat_arr[0]] = $ocat_arr[1];
15 if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){
16 $cat_lines[] = $single_line;
17 $allowed_cats[] = $ocat_arr[0];
18 }
19
20 }
21
22
23
24
25 // ********************************************************************************
26 // List all news available for editing
27 // ********************************************************************************
28 if($action == "list")
29 {
30 echoheader("editnews","Edit News");
31
32
33
34
35
36
37
38 // How Many News to show on one page
39 if($news_per_page == ""){ $news_per_page = 21; }
40
41 $all_db = array();
42 if($source == ""){ $all_db = file("./data/news.txt"); }
43 elseif($source == "postponed"){ $all_db = file("./data/postponed_news.txt"); ResynchronizePostponed(); }
44 elseif($source == "unapproved"){ $all_db = file("./data/unapproved_news.txt");}
45 else{ $all_db = file("./data/archives/${source}.news.arch"); }
46
47
48
49 // choose only needed news items
50 if ($category != '' or $author != "" or $member_db[1] == 3){
51 foreach($all_db as $raw_line){
52 $raw_arr = explode("|", $raw_line);
53
54 ;
55
56 if (
57 ($category == '' or in_array($category, explode(',',$raw_arr[6])))
58 and ($author == "" or $raw_arr[1] == $author)
59 and ($member_db[1] != 3 or $raw_arr[1] == $member_db[2] )
60
61 ){
62 $all_db_tmp[] = $raw_line;
63 }
64 }
65 $all_db = $all_db_tmp;
66 }
67
68
69 // Prelist Entries
70 $flag = 1;
71 if($start_from == "0"){ $start_from = ""; }
72 $i = $start_from;
73 $entries_showed = 0;
74
75 if(!empty($all_db)){
76
77 foreach ($all_db as $line){
78 if($j < $start_from){ $j++; continue; }
79 $i++;
80
81 $item_db = explode("|",$line);
82 $itemdate = date("d/m/y",$item_db[0]);
83
84 if($flag == 1){ $bg="#F7F6F4"; $flag = 0; }
85 else {$bg = "#FFFFFF"; $flag = 1;}
86
87 if(strlen($item_db[2]) > 74){ $title = substr($item_db[2],0,70)." ..."; }
88 $title = stripslashes( preg_replace(array("'\|'", "'\"'", "'\''"), array("I", "&quot;", "&#039;"), $item_db[2]) );
89 $title = ereg_replace("<[^>]*>","",$title);
90 $entries .= "<tr>
91
92 <td height=18 bgcolor=$bg>
93 <!-- ID: $item_db[0]--><a title='EDIT: $item_db[2]' href=\"$PHP_SELF?mod=editnews&action=editnews&id=$item_db[0]&source=$source\">$title</a>
94 <td height=18 bgcolor=$bg align=right>";
95 $count_comments = countComments($item_db[0], $source);
96 if($count_comments == 0){$entries .= "<font color=gray>$count_comments</font>";}
97 else{$entries .= "$count_comments";}
98
99 $entries .= "&nbsp;&nbsp;&nbsp;&nbsp;<td height=18 bgcolor=$bg nowrap>&nbsp;&nbsp;&nbsp;";
100
101
102 if($item_db[6] == ""){ $my_cat = "<font color=gray>---</font>"; }
103
104 // elseif($cat[$item_db[6]] == ""){ $my_cat = "<font color=red title='The news article is posted in category which does not exist anymore'>(ID: <b>$item_db[6]</b>)</font>"; }
105
106 elseif(strstr($item_db[6],',')){
107 $all_this_cats_arr = explode(',',$item_db[6]);
108 $my_multy_cat_labels = '';
109 foreach($all_this_cats_arr as $this_single_cat){
110 $my_multy_cat_labels .= "$cat[$this_single_cat], ";
111 }
112 $my_cat = "<span onmouseover=\" window.status='categories: $my_multy_cat_labels'; return true\" onmouseout=\"window.status=''; return true\"><font color=#7979FF title='$my_multy_cat_labels'>(multiple)</font></span>";
113 }
114
115 else{ $my_cat = $cat[$item_db[6]]; }
116
117 $entries .= "$my_cat&nbsp;<td height=18 bgcolor=$bg>
118 $itemdate
119 <td height=18 bgcolor=$bg>
120 $item_db[1]
121
122 <td align=center bgcolor=$bg><input name=\"selected_news[]\" value=\"{$item_db[0]}\" style=\"border:0; background-color:$bg\" type='checkbox'>
123
124 </tr>
125 ";
126 $entries_showed ++;
127
128 if($i >= $news_per_page + $start_from){ break; }
129 }//foreach news line
130 }
131 // End prelisting
132
133
134
135 $all_count_news = count($all_db);
136 if($category != ""){ $cat_msg = "Category: <b>$cat[$category]</b>;"; }
137
138 if($source == "postponed"){ $source_msg = "<span style='background-color:yellow;'>Postponed News, <a title='Refresh the postponed news file' href=\"$PHP_SELF?mod=editnews&action=list&source=postponed\">[Resynchronize]</a></span>"; $postponed_selected = " selected ";}
139 elseif($source == "unapproved"){ $source_msg = "<span style='background-color:yellow;'>Unapproved News</span>"; $unapproved_selected = " selected ";}
140 elseif($source != "" ){
141
142 $news_lines = file("./data/archives/$source.news.arch");
143 $count = count($news_lines);
144 $last = $count-1;
145 $first_news_arr = explode("|", $news_lines[$last]);
146 $last_news_arr = explode("|", $news_lines[0]);
147 $first_timestamp = $first_news_arr[0];
148 $last_timestamp = $last_news_arr[0];
149 $source_msg = "Archive: <b>". date("d M Y",$first_timestamp) ." - ". date("d M Y",$last_timestamp) ."</b>;";
150 }
151
152
153
154 ///////////////////////////////////////////
155 // Options Bar
156 echo"
157 <table class=panel border=0 cellpading=0 cellspacing=0 width=99% >
158 <tr>
159 <td title='Show More Options' style=\"cursor:pointer;\" onClick=\"getElementById('options').style.display='';\">
160 Showing <b>$entries_showed</b> articles from total <b>$all_count_news</b>; $cat_msg $source_msg
161 </td>
162
163 <td >
164 <p align=\"right\"><a href=\"javascript:ShowOrHide('options','')\">show options&nbsp;</a>
165 </td>
166 </tr>
167 <tr>
168 <td colspan=\"2\" >
169
170
171 <div id='options' style='display:none;z-index:1;' >
172 <form action=\"$PHP_SELF?mod=editnews&action=list\" method=POST name=options_bar>
173 <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
174 <tr>
175 <td height=\"1\" style=\"border-top: 1px dashed silver\" width=\"100%\" align=\"right\" colspan=\"3\">
176 <p align=\"center\">&nbsp;
177 </td>
178 </tr>
179 <tr >
180 <td height=\"1\" width=\"286\" align=\"right\">
181 Source&nbsp;
182 </td>
183 <td height=\"1\" width=\"180\">
184 <select name=\"source\" size=\"1\"><option value=\"\">- Active News -</option> \n <option $postponed_selected value=\"postponed\">- Postponed News -</option> \n <option $unapproved_selected value=\"unapproved\">- Unapproved News -</option>";
185
186 if(!$handle = opendir("./data/archives")){ die("<center>Can not open directory ./data/archives "); }
187 while (false !== ($file = readdir($handle)))
188 {
189 if($file != "." and $file != ".." and !is_dir("./data/archives/$file") and eregi("news.arch", $file))
190 {
191 $file_arr = explode(".", $file);
192 $id = $file_arr[0];
193
194 $news_lines = file("./data/archives/$file");
195 $count = count($news_lines);
196 $last = $count-1;
197 $first_news_arr = explode("|", $news_lines[$last]);
198 $last_news_arr = explode("|", $news_lines[0]);
199
200 $first_timestamp = $first_news_arr[0];
201 $last_timestamp = $last_news_arr[0];
202
203 $arch_date = date("d M Y",$first_timestamp) ." - ". date("d M Y",$last_timestamp);
204 $ifselected = "";
205 if($source == $file_arr[0]){ $ifselected = "selected"; }
206 echo "<option $ifselected value=\"$file_arr[0]\">Archive: $arch_date ($count)</option>";
207 }
208 }
209 closedir($handle);
210
211 echo"</select>
212
213 </td>
214 <td height=\"1\" width=\"182\">
215 </td>
216 </tr>
217 <tr>
218 <td height=\"1\" width=\"284\" align=\"right\" >
219 Category&nbsp;
220 </td>