Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

removing some files

  • Loading branch information...
commit b0043160528a3b29ef6dc21faef2872f6de32b0d 1 parent 704ba13
authored
274  blog/TODO.txt
... ...
@@ -1,274 +0,0 @@
1  
- * @uses parseIni() <-- note for phpdoc, you can use @uses function() notation! great for deprecated functions and functions that are wrappers for functions with different args, etc. Also use the @deprecated keyword on some of those.
2  
-
3  
-
4  
-MEETING NOTES:
5  
-
6  
-Need to convert api.php, archive.php and index.php, blogEntry.class and anything else over to use the new uniquehash as the blog entry identifier rather than blogid/postid combination.
7  
-
8  
-EDIT: Did I include the bit about messaging? If a student is moderated and they change their publish state they should be prompted to enter a message as to what they are changing the publish state for (teacher review, show the class because it's done, etc) and then a moodle message is generated to the teacher.
9  
-
10  
-New course formatting - tabbed interface which has "Course", "Blog", "etc". (Done)
11  
-In the blog tab of course use table class to place User picture/name/last blog entry mod date/latest blog entries (see more link) sorted by default by most recent entry. Need "sort by" in this section.
12  
-
13  
-User profile tabs - add a new tab "My Blog" (if you come to the user profile from a course you see course posts, from site you see site posts - though a drop down selection would be nice)
14  
-
15  
-Categories should have the same tinyurl hash as a unique id for backup and restore. (similar to the way that the quiz module currently handles quiz questions. eg?  www.mysite.com.63AB6VD. I'm thinking md5($ownerid.$CFG->wwwroot.$categoryid))
16  
-
17  
-Grading feature will have to be available early on. Maybe add a third table for blog grades/courseid. The teacher viewing the course entries would have the ability to set the grades for those entries. Teacher would set the scales for their course. Note: Grades in most places in moodle are done using an integer, if negative then refers to scale id.
18  
-
19  
-Anonymous comments are not to be allowed at all. remove the ability for guest users to post comments to blog entries entirely. Remove comments on posts entirely. Instead of comments the options should be to "Send a private message" or blog a reference ("blog this!"), or add a forum post referencing the entry.
20  
-no anonymous comments, trackback and pingback optional, little finger with string tied icon to "blog this post", internal trackback style.
21  
-Trackback/pingback from remote sites should not be allowed at all I guess (even on publicly published entries) since they're a form of anonymous comment. 
22  
-Trackbacks should not use blog id/post id - they should use a unique field like quiz does with a "tinyurl" or random number/hash which will better allow backup and restore.
23  
-
24  
-Default blog template 'moodle' (for layout) needs to look exactly like forum posts, including extra space under user picture. Modify 'moodle' template!
25  
-
26  
-In the People block perhaps add a "This user's blog". List all of the class faces with their most recent blog entries, sorted by most recent entries.
27  
-
28  
-"everything I have ever said to this person" would be a useful bit of information.
29  
-
30  
-Post table:
31  
-  - id
32  
-  - author (userid)
33  
-  - reader (userid) 
34  
-  - courseid
35  
-  - moduleid
36  
-  - coursemoduleid
37  
-  - groupid
38  
-  - subject (text)
39  
-  - summary (text)
40  
-  - content (text)
41  
-  - uniquehash  (similar to the way that the quiz module currently handles quiz questions. eg?  www.mysite.com.63AB6VD)
42  
-  check to see if the int id for blog api will accepts an md5(string) value. use marsedit and hack api.php to test. (-UPDATE- Looks good! Blogger api uses string values for blogid and postid)
43  
-
44  
- post->id == blog_entries->id
45  
- post->author == blog_entries->userid
46  
- post->reader == ?
47  
- post->courseid == blog_entries->courseid
48  
- post->moduleid == ?
49  
- post->coursemoduleid == ?
50  
- post->groupid ==== blog_entries->groupid (unused by blog so far)
51  
- post->subject == blog_entries->title
52  
- post->summary == blog_entries->body
53  
- post->content == blog_entries->extendedbody
54  
- post->uniquehash  == md5($post->author.$CFG->wwwroot.$post->id) (fair?)
55  
-(similar to the way that the quiz module currently handles quiz questions. eg?  www.mysite.com.63AB6VD)
56  
-
57  
-
58  
-New course formatting - tabbed interface which has "Course", "Blog", "etc". (Done)
59  
-no comments, remove comments from blog entries. (Done)
60  
-Remove the use of blogid completely. The blogid IS the userid - just refer the the moodle userid. 1 user == 1 blog, period. - DONE (api.php still uses 'blogid' in a few places internally)
61  
-For blog entries change the publish to text of No one (draft) to 'publish to: "just for myself"' - DONE
62  
-Remove class.BlogServer.php file completely. - DONE
63  
-By removing blog_list and blog_acl we now have to store user preferences for their blog title and tagline, useextendedbody as well as potentially theme choice. It appears typeid was never used. - DONE
64  
-The blog_acl table and all references to it can be completly removed. we have wikis for shared documents and other tools. - DONE
65  
-RSS lib has gotten some work recently. Moodle still uses RSS2 only, no selection, so remove rss 0.9 and Atom options entirely. - DONE
66  
-From Daryl: Remove all search references. If forum uses the POST table in the future then searching forum vs. blog entries becomes irrelevent. - DONE
67  
-
68  
-
69  
-NOTE: blog preferences have (finally) been moved to user preferences
70  
-set_user_preference($name, $value, $otheruser=NULL);
71  
-get_user_preferences($name=NULL, $default=NULL, $userid=NULL);
72  
-preference keys for blog:
73  
-blogtitle
74  
-blogtagline
75  
-bloguseextendedbody
76  
-blogtheme
77  
-bloglastmodified
78  
-
79  
-
80  
-__________
81  
-REGULAR TODO:
82  
-
83  
-                        MOODLE BLOG TODO
84  
-=================================================
85  
-NEEDS TESTING
86  
- (NOTE: If you decide to test these items please
87  
-send your detailed observations to dhawes@mac.com
88  
-so they can either be cleared out or added back
89  
-to active bug tracking. Thanks!)
90  
-=================================================
91  
-
92  
------ New blog moderation/permissions model added -----
93  
-
94  
-The default is current permission model
95  
-Current permission model can be defined as
96  
-    1) All users have the same publish abilities - no moderation, no restrictions
97  
-    2) When posting an entry users can publish as a draft, to teachers in a given course, to all users in a given course, to all site members or to the world.
98  
-
99  
-I have now added an admin toggle to enable/disable blog moderation.
100  
-Blog moderation is now defined as
101  
-    1) Admin users have current permission model
102  
-    2) Teachers posting an entry associated with a course that they teach in can publish to any option.
103  
-    3) all other posts must be associated with a course! When moderation is on there are no "personal" blog entries.
104  
-    4) all other posts are sent to draft by default. student users can publish to teacher only (or draft of course). 
105  
-    5) Teachers will see posts "published to teacher" by students in their class (later perhaps also notified by moodle message - right now they will see the entries on the blog index page only)
106  
-    6) Only a teacher can promote an entry from draft/teacher to class view, site view, or world view
107  
-    7) Once promoted/published the student can no longer edit that entry. To edit the teacher will have to first demote the entry back to draft.
108  
-    8 ) Batch publishing now available to all users on index page - Teachers' interface  has a "publish all" option as well as a per message publish option
109  
-
110  
-    
111  
-=================================================
112  
-ACTIVE WORK / TO BE COMPLETED
113  
-   (bug fixes and other things targeted for first release)
114  
-=================================================
115  
-
116  
-�rss_client - during upgrade check for fopen() (or whatever is required) and disable the block if it cannot function on the server? How to properly introspect this functionality?
117  
-
118  
-� Elimiate admin.php file - move one remaining function into category block
119  
-
120  
-� Calendar Block Bug: Cal is showing link to dates with blog entries which are not found in the current blog! It should only show links to dates that have entries which the user can see given their blogFilter constraints. (Odd - in testing on my local site I cannot reproduce this error).
121  
-
122  
-� Martin suggested that the "Enable blog" step should occur on first attempt at new entry - eliminating one step. I'm not thoroughly convinced that this is the best, it needs more discussion. If you enable the blog just because they click "post new entry" then you are adding extra blogs for the curious who may not use it after first investigation. The best compromise is to show the'learning text' on the edit form itself and enable the blog when they submit their first entry, but the edit form doesn't lend itself well to this approach and the edit form would be pretty far down the page.
123  
-(One possible solution is to add a bool column to the blog_list table enabled/disabled. If the user hits the edit page and they have no blog then create one in the db for them and use that blogid for the remainder of the page. If their blog is disabled (default) then add a link to the top of the page suggesting that they read the help file on "About Blogs" before posting.)
124  
-
125  
-� Martin makes a good point about eliminating jargon for the end user experience. Look through blocks and links and comb out overly cryptic wording.
126  
-
127  
-� Continue work on help pages for trackback and pingback. Explain what they are and why you would want to send or not send them from a post. (posted discussion topic requesting assistance with this text on using moodle blog forum)
128  
-
129  
-� phase out the use of BlogEntry->entryCategoryIds since BlogEntry->entryCategories now contains both the id and name in a single associative array.
130  
-
131  
-RSS (server): feeds NOW support args of blogid=# or catid=#. As we integrate further with moodle we may want a courseid=# option. This applies to rss, rss2 and atom.php. Courseid may not be useful except on courses which allow guest access. 
132  
-I do not know for sure that rss feeds can be authenticated. The current rss feeds do not do any form of authentication. How would a news reader client handle authentication of the feed? Page re: authenticated feeds: http://labs.silverorange.com/archives/2003/july/privaterss
133  
-
134  
-� On edit.php indent the send trackback option and make it dependent on pingback being enabled
135  
-for reference on how to do this see  code for "when adding a Resource" (I'm not positive that tb/pb are quite this neatly related with tb dependant on pb being enabled. I believe that tb could be enabled without pb and it will work. This requires more research and better help file explanations of feature functionality. It might seem appropriate to simply allow trackback as it seems to be built on top of pb, but I believe pb is supported because some remote servers do not support tb.)
136  
-
137  
-� SECURITY - ADMIN CONFIG OPTION - I'm thinking lately that it might be nice during install time (and as an admin blog config option) to present the user with a choice - "use blogs" <yes/no> -  that way any "security" concerns are negated since it can be completely disabled.
138  
-
139  
-� Check to see if guest users who have joined the course with an enrollment key can post comments when anon comments disabled/enabled - maybe extra setting in config - "allow guests who enter with enrolment key to post comments"
140  
-
141  
-� Convert archive.php into view.php which will be a permalink page for viewing single entries only.
142  
-
143  
-=================================================
144  
-ONGOING / STYLE
145  
-=================================================
146  
-� Examine database usage and attempt to optimize: (note from Jon: you can say "EXPLAIN (your query here)" and MySQL will tell you what it's doing to execute the query for example, how many rows it will have to consider, what indexes it will be using and stuff)
147  
-
148  
-� if you're worried about memory bloat - just don't keep the objects around any longer than you need to -  e.g. after done with it call "unset($page)"
149  
-
150  
-� Add phpdoc comments to files, classes and functions.
151  
-
152  
-� SQL: Convert more sql calls to moodle functions rather than raw sql.
153  
-
154  
-� LOCALIZATION: Review code occasionally to localize any hard coded text
155  
-
156  
-� MOODLE INTEGRATION/CLEANUP: enforce integer values before using them in db calls:     
157  
-// Make sure that the GET variables are correct
158  
-    $day = intval($_GET['cal_d']);
159  
-
160  
-� MOODLE INTEGRATION/CLEANUP: Use p() when showing vars in html forms
161  
-<input name="block_online_users_timetosee" type="text" size="5" value="<?php if(isset($CFG->block_online_users_timetosee)) {p($CFG->block_online_users_timetosee);} else {p(5);} ?>"
162  
-actually p(0 and s() just pass the argument though strip_chars and htmlspecialchars to remove < > special characters - making sure it's just text.
163  
-
164  
-� from Jon: $motto = "always use empty() UNLESS there is a specific reason not to"
165  
-and the specific reasons may be two:
166  
-1) you care to differentiate between NULL and ''
167  
-2) you want to see if an object exists before starting to pull out its properties
168  
-
169  
-=======================================================================
170  
-FEATURE REQUESTS (not targeted for first release, order means nothing)
171  
-=======================================================================
172  
-� http://wordpress.org/about/shots/1.5/moderation.png - comment moderation for the blog owner themselves
173  
-
174  
-� RSS 2.0's enclosure capabilities would be a nice addition for podcasting.
175  
-
176  
-� From Martin's bug regarding blogging:
177  
-"3) Blog entries appear as usual, and can have a discussion attached to them for feedback and comments. Each entry can also have a "grade", which is the average of a number of ratings. Normally this might just be the teacher, but it could be the whole class rating each other's entries."
178  
-
179  
-� find a way to moderate based on the category and course rather than the site. Would allow one teacher to moderate their own course entries while another chooses not to
180  
-
181  
-� RSS_CLIENT: 
182  
-define('MAGPIE_CACHE_FRESH_ONLY', false); //should be exposed as an admin config option - if true then it will not display stale cache contents when remote feed cannot be refreshed.
183  
-
184  
-� PINGBACK/TRACKBACK: PingBacks and TrackBacks should be logged in moodle logs as they are saved/executed.
185  
-
186  
-� Handle deletion of user
187  
-   BlogServer class has function deleteBlogById($blogid). This is not currently called by any blog code. It might be a good function to be used by moodle. However, moodle's delete user simply marks the user as deleted - allowing the user to be easily reactivated. Should we be checking for ($user->deleted != 1) before displaying blog information?
188  
-   
189  
-� Possibly re-enable weblogs.com RPC option
190  
-//below is a section removed from edit.php.
191  
-<?php
192  
-if($CFG->blog_useweblog_rpc) {
193  
-echo "<input type=checkbox name=weblogrpc value=\"1\" />Send update notice to weblogs.com<br>(may cause longer load time)&nbsp;";
194  
-}?>
195  
-
196  
-� DH - RSS - All rss/atom scripts should use a blogFilter with arguments passed in to be used in loading correct blogEntries. Either the news page or a new function in BlogFilter should build the cache filename. Create a new page that has full drop down menu options to select a specific feed type (filter news feeds by category, user, date to start with)
197  
-
198  
-� RSS: Single page where users can go to access rss links (xml image and link) which are available to them on the moodle server - instead of only being available in blocks. When working with our own published feeds add links for administrator to "Validate" remote feed. Should integrate with new news page that lists all available local feeds. ( http://feeds.archive.org/validator/check?url=<BLOGRSSURL>) (NEWS/RSS: add new index_news.php file. should list all possible feeds for the site. including blogids, catids and moodle links. At the top should be "My RSS Feeds" for logged in users to quickly find their own links. RSS Feeds side block and the user admin section should have links to this new page.)
199  
-
200  
-� API.PHP: Add support for media upload api metaweblog call. Would allow a user to post a blog entry complete with pictures. "Finally, the ability of students to include pictures and other media is very useful." Should target this ASAP. Right now I'm waiting for moodle to have a comprehensive file management system that would allow a student to upload their own files to the server.
201  
-
202  
-� Add entry/comment view counters
203  
-    COUNTERS: Add view counters to simplog tables (or create blog_log table). How many times has the full body of an entry been viewed, how many times have comments on an entry been viewed? (member vs. guest views should be counted) Should be a new template markup option --showguestviews-- --showmemberviews-- --showtotalviews--. 
204  
-
205  
-
206  
-INDEX_MORE.PHP: Column headers should be linked to allow column sorting. Clicking a column header would cause the sort order to be changed to be by that column and paging would be reset back to start=0.
207  
-
208  
-TRACKBACK/PINGBACK: Add ability to blacklist remote URLs so that specific incoming tb/pbs can be rejected on a site level
209  
-
210  
-=================================================
211  
-ADDITIONAL NOTES / UNCATEGORIZED NOTES
212  
-=================================================
213  
-
214  
-CALENDAR: It would be nice if Blog entries that have been marked 'published' appear on the calendar as EVENTS! The first publish it'll appear as 'entry created', changing status and then republishing will make it show on the calendar as 'entry status modified'. When an entry is edited it'll show on the calendar as 'entry modified'. These event entries should not be editable by the user.
215  
-From email with Jon P. :
216  
-    Is it possible to create an event in the calendar programmatically
217  
-that
218  
-    1) is NOT tied to a courseid, an event for the user, not for a course
219  
-they are in
220  
-    2) is not editable by the user
221  
-
222  
-"OK, your question has two parts and a two-sided answer. First of all, you
223  
-could add fields to mdl_event that make the recognition of a fifth type of
224  
-event possible, and change the code to make use of that. But this is a
225  
-solution I would advise against, not to mention that you would have to make
226  
-the changes mentioned for the "other solution" below.
227  
-
228  
-Another thing you could do is fiddle with the calendar_edit_event_allowed()
229  
-function (or something like that). I think it's located at about the end
230  
-of calendar/view.php[...]. That one decides whether you can edit the event or not,
231  
-so your best bet is to add code there to achieve your desired effect. For
232  
-example, add another column to mdl_event and make that function return
233  
-false if it's set to 1.
234  
-
235  
-A third solution just came to mind. You can always change the link 
236  
-for the edit icon. That's what Martin did for activity events; they don't
237  
-allow you to change the event details, but take you to the corresponding
238  
-activity which "controls" the event."
239  
-
240  
-MOODLE INTEGRATION/CALENDAR: Convert existing simplog calendar code to use Moodle calendar. This is terribly involved unfortunately.
241  
-
242  
-BLOG_ENTRIES: blog entries should track their modification date info and note the most recent update in the listing. Would be a nice addition if it also listed all modifications dates in the full single entry view (archive.php). Users who make updates should be able to enter a comment about what the update was. Now that we have publish states perhaps a new table should have a list of all modifications made to non-draft entries. when entries were returned to draft status, republished, edited, etc.
243  
-Additionally, perhaps a modification can only ADD extra text rather than editing the original post (this would be a site wide setting and would make published blog posts more moodle like)
244  
-
245  
-WEBLOGRPC.php: use as a template to create a blog entry publishing system for other blogs? Refer to other open source blog systems to see if others do this already. They might have useful code to use as a reference or starting point.
246  
- 
247  
-LONG TERM:(Tom note)Teachers down the road might want to attach scales and grades to individual blog instances, entries, or categories...
248  
-
249  
-
250  
-
251  
-Posted By: vik 
252  
-Date: 9:56 AM 31-Mar-2004
253  
-
254  
-Having used blogs at my school for a few months, I'd like to add these observations. 
255  
-
256  
-We used blogs in two ways; one for personal reflection, the other for text-responses. In the latter, the students were directed by questions from the teacher, and as I understand, had much the same functionality of the journal module. The personal blogs on the other hand, have completely different requirements:
257  
-
258  
-Firstly, students need ownership of the blog. This means the blog would have to be assigned to the *student*, not any course. This might be 'worked around' by using form groups or year groups or similar as courses, but ownership is one of the concepts we identified that makes blogs so appealing to students. 
259  
-
260  
-Further to this, I think that having the structure and layout of the blog customisable is very beneficial. How possible would this be (to have the students modify html and css for their own instances of such a module)? 
261  
-
262  
-______________________________
263  
-
264  
-
265  
-RSS:
266  
-Notes from: http://www.learningcircuits.org/2004/may2004/0405_trends.htm
267  
-
268  
-And what about other technologies? Could RSS be integrated with other new tools, such as the ones described in �We Learning�, parts I and II? Consider
269  
-� a social networking tool that sends you a feed informing you of the new people who just joined the network
270  
-� an expert management system that uses feeds to tell you when a new expert is added to the system in your area of interest, or when an expert has created a new document you might be interested in
271  
-� collaborative workspaces that use feeds to bring in information people in the group need to complete a project
272  
-� a problem-based RSS feed integrated with a social networking or expert management tool in which you could subscribe to a problem, for example �reluctant learners,� and then receive updates whenever someone writes on that topic.
273  
-
274  
-   � RSS Server: Create RSS feed of member joins for each course.
100  blog/tags.html
... ...
@@ -1,100 +0,0 @@
1  
-<?php
2  
-$otags  = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC');
3  
-$ptags1 = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'personal\' AND userid = '.$USER->id.' ORDER by text ASC');
4  
-$ptags2 = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'personal\' AND userid <> '.$USER->id.' ORDER by text ASC');
5  
-
6  
-print_heading(get_string('tagmanagement'));
7  
-?>
8  
-
9  
-<table>
10  
-    <tr>
11  
-        <td width="50%" align="left"><label for="otags"><?php print_string('otags','blog');?></label></td>
12  
-        <td width="50%" align="left"><label for="ptags"><?php print_string('ptags','blog');?></label></td>
13  
-    </tr>
14  
-
15  
-    <tr>
16  
-        <td>
17  
-            <form action="tags.php" method="post">
18  
-            <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
19  
-            <?php
20  
-            if (has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
21  
-            ?>
22  
-            <select name="tags[]" id="otags" multiple="multiple" size="8">
23  
-            <?php
24  
-            if ($otags) {
25  
-                foreach ($otags as $otag) {
26  
-                    echo '<option value="'.$otag->id.'">'.$otag->text.'</option>';
27  
-                }
28  
-            }
29  
-            ?>
30  
-            </select>
31  
-            <input type="hidden" name="action" value="delete" />
32  
-            <br />
33  
-            <input type="submit" value="<?php print_string('delete');?>" />
34  
-            <?php }
35  
-                else {
36  
-                    if ($otags) {
37  
-                        foreach ($otags as $otag) {
38  
-                            echo '<br />'.$otag->text;
39  
-                        }
40  
-                    }
41  
-                }
42  
-            ?>
43  
-            </form>
44  
-        </td>
45  
-
46  
-        <td>
47  
-            <form action="tags.php" method="post">
48  
-            <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
49  
-            <select name="tags[]" multiple="multiple" id="ptags" size="8">
50  
-            <?php
51  
-
52  
-                $ptags = array();
53  
-                
54  
-                // Not sure if this sowring is needed anymore
55  
-                if (!empty($ptags1)) { // user's own tag exists
56  
-                    if (!empty($ptags2)) { // user's own tags, and other users tags exist, we merge
57  
-                        $ptags = array_merge($ptags1, $ptags2);
58  
-                    } else { // user's own tags exist, no other personal tags, just use that
59  
-                        $ptags = $ptags1;
60  
-                    }
61  
-                } else if (!empty($ptags2)) {
62  
-                    $ptags = $ptags2;
63  
-                }
64  
-
65  
-                if (!empty($ptags)) {
66  
-                    foreach ($ptags as $ptag) {
67  
-                        echo '<option value="'.$ptag->id.'">'.$ptag->text.'</option>';
68  
-                    }
69  
-                }
70  
-            ?>
71  
-            </select>
72  
-            <input type="hidden" name="action" value="delete" />
73  
-            <br />
74  
-            <input type="submit" value="<?php print_string('delete');?>" />
75  
-            </form>
76  
-        </td>
77  
-    </tr>
78  
-
79  
-    <tr>
80  
-        <td>
81  
-            <?php if (has_capability('moodle/blog:manageofficialtags', $sitecontext)) { ?>
82  
-            <form action="tags.php" method="post">
83  
-            <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
84  
-            <label for="newotag"><?php print_string('addotags','blog');?></label>:<br/>
85  
-            <input type="text" name="otag" id="newotag" />
86  
-            <input type="submit" value="<?php print_string('add');?>" />
87  
-            <input type="hidden" name="action" value="addofficial" />
88  
-            </form>
89  
-            <?php }?>
90  
-        </td>
91  
-
92  
-        <td>
93  
-        </td>
94  
-    </tr>
95  
-
96  
-</table>
97  
-
98  
-<p align="center">
99  
-    <a href="#" onclick="window.close()"><?php print_string('closewindow');?></a>
100  
-</p>
141  blog/tags.php
... ...
@@ -1,141 +0,0 @@
1  
-<?php  // $Id$
2  
-require_once('../config.php');
3  
-
4  
-/// main switch for form processing to perform, add/delete etc
5  
-$action = optional_param('action','',PARAM_ALPHA);
6  
-
7  
-require_login();
8  
-
9  
-/// blogs could be disabled altogether
10  
-if (empty($CFG->bloglevel)) {
11  
-    error('Blogging is disabled!');
12  
-}
13  
-
14  
-if (isguest()) {
15  
-    error(get_string('noguestpost', 'blog'));
16  
-}
17  
-
18  
-/// blogs are site level
19  
-$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
20  
-
21  
-$error = '';
22  
-
23  
-$script = '';
24  
-switch ($action) {
25  
-    /// Adding an official tag from submitted value
26  
-    case 'addofficial':
27  
-        // Double check to make sure user has capability
28  
-        if (!has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
29  
-            error('Can not add official tags tags');
30  
-        }
31  
-        if (data_submitted() and confirm_sesskey()) {
32  
-            
33  
-            $otag = trim(required_param('otag', PARAM_NOTAGS));
34  
-            // When adding ofical tag, we see if there's already a personal tag
35  
-            // With the same Name, if there is, we just change the type
36  
-            if ($tag = tag_by_name ($otag)) {
37  
-                if ($tag->type == 'official') {
38  
-                    // official tag already exist
39  
-                    $error = get_string('tagalready');
40  
-                    break;
41  
-                } else { 
42  
-                    $tag->type = 'official';
43  
-                    update_record('tag', $tag);
44  
-                    $tagid = $tag->id;
45  
-                }
46  
-                
47  
-            } else { // Brand new offical tag
48  
-                if (!$tagid = tag_create($otag, 'official')) {
49  
-                    error('Can not create tag!');
50  
-                }
51  
-            }
52  
-
53  
-            /// Write newly added tags back into window opener.
54  
-            $script = '<script type="text/javascript">
55  
-//<![CDATA[
56  
-            var o = opener.document.createElement("option");
57  
-            o.innerHTML = "<option>'.$tag->text.'</option>";
58  
-            o.value = '.$tagid.';
59  
-            opener.document.entry[\'otags[]\'].insertBefore(o, null);
60  
-//]]>
61  
-            </script>';
62  
-        }
63  
-
64  
-    break;
65  
-    
66  
-    /// Deletes a tag.
67  
-    case 'delete':
68  
-        
69  
-        if (data_submitted() and confirm_sesskey()) {
70  
-            $tagids = optional_param('tags', array(), PARAM_INT);
71  
-
72  
-            if (empty($tagids) or !is_array($tagids)) {
73  
-                // TODO add error message here
74  
-                // $error = 'no data selected';
75  
-                break;
76  
-            }
77  
-
78  
-            foreach ($tagids as $tagid) {
79  
-
80  
-                if (!$tag = get_record('tags', 'id', $tagid)) {
81  
-                    continue; // page refreshed?
82  
-                }
83  
-
84  
-                if ($tag->type == 'official' and !has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
85  
-                    //can not delete
86  
-                    continue;
87  
-                }
88  
-
89  
-                if ($tag->type == 'personal' and !has_capability('moodle/blog:managepersonaltags', $sitecontext)) {
90  
-                    //can not delete
91  
-                    continue;
92  
-                }
93  
-                
94  
-                // Delete the tag itself
95  
-                if (!delete_records('tags', 'id', $tagid)) {
96  
-                    error('Can not delete tag');
97  
-                }
98  
-                
99  
-                // Deleteing all references to this tag
100  
-                if (!delete_records('blog_tag_instance', 'tagid', $tagid)) {
101  
-                    error('Can not delete blog tag instances');
102  
-                }
103  
-
104  
-                /// Remove parent window option via javascript.
105  
-                $script = '<script>
106  
-//<![CDATA[
107  
-                var i=0;
108  
-                while (i < window.opener.document.entry[\'otags[]\'].length) {
109  
-                    if (window.opener.document.entry[\'otags[]\'].options[i].value == '.$tagid.') {
110  
-                        window.opener.document.entry[\'otags[]\'].removeChild(opener.document.entry[\'otags[]\'].options[i]);
111  
-                    }
112  
-                    i++;
113  
-                }
114  
-
115  
-                var i=0;
116  
-                while (i < window.opener.document.entry[\'ptags[]\'].length) {
117  
-                    if (window.opener.document.entry[\'ptags[]\'].options[i].value == '.$tagid.') {
118  
-                        window.opener.document.entry[\'ptags[]\'].removeChild(opener.document.entry[\'ptags[]\'].options[i]);
119  
-                    }
120  
-                    i++;
121  
-                }
122  
-//]]>
123  
-                </script>';
124  
-            }
125  
-
126  
-        }
127  
-    break;
128  
-
129  
-    default:
130  
-        /// Just display the tags form.
131  
-    break;
132  
-}
133  
-
134  
-
135  
-/// Print the table.
136  
-print_header (get_string('tagmanagement'), '', '', '', $script);
137  
-include_once('tags.html');
138  
-print_footer();
139  
-
140  
-
141  
-?>

0 notes on commit b004316

Please sign in to comment.
Something went wrong with that request. Please try again.