Index: trunk/extensions/SemanticTasks/Teamspace ST reminder |
— | — | @@ -1,18 +0,0 @@ |
2 | | -Here are things to add to the current teamspace structure : |
3 | | - |
4 | | -* Create Property:Reminder at" |
5 | | - [[Has type::Type:Integer]] |
6 | | - |
7 | | - |
8 | | -*In the Template:Task |
9 | | - = Reminders = |
10 | | - '''Reminder at:''' {{ #if: {{{reminder|}}} | {{#arraymap:{{{reminder}}}|,|x|[[Reminder at::x]]}} | 0 }} |
11 | | - |
12 | | - |
13 | | -*In the Form:Task |
14 | | - __NOTOC__ |
15 | | - |
16 | | -and |
17 | | - |
18 | | - = Reminders = |
19 | | - <p><strong>Remind me </strong> {{{field|reminder|default=20,15,7,3}}} days before Target date</p> |
Index: trunk/extensions/SemanticTasks/ST_Notify_Assignment.php |
— | — | @@ -1,222 +0,0 @@ |
2 | | -<?php |
3 | | -# (C) 2008 Steren Giannini |
4 | | -# Licensed under the GNU GPLv2 (or later). |
5 | | -function fnMailAssignees_updated_task( $article, $current_user, $text, $summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision ) { |
6 | | - if ( !$minoredit ) { |
7 | | - // i18n |
8 | | - wfLoadExtensionMessages( 'SemanticTasks' ); |
9 | | - |
10 | | - // Grab the wiki name |
11 | | - global $wgSitename; |
12 | | - |
13 | | - // Get the revision count to determine if new article |
14 | | - $rev = $article->estimateRevisionCount(); |
15 | | - |
16 | | - if ( $rev == 1 ) { |
17 | | - fnMailAssignees( $article, $current_user, '[' . $wgSitename . '] ' . wfMsg( 'semantictasks-newtask' ), 'semantictasks-assignedtoyou-msg', /*diff?*/ false, /*Page text*/ true ); |
18 | | - } else { |
19 | | - fnMailAssignees( $article, $current_user, '[' . $wgSitename . '] ' . wfMsg( 'semantictasks-taskupdated' ), 'semantictasks-updatedtoyou-msg', /*diff?*/ true, /*Page text*/ false ); |
20 | | - } |
21 | | - } |
22 | | - return TRUE; |
23 | | -} |
24 | | - |
25 | | -function fnMailAssignees( $article, $user, $pre_title, $message, $display_diff, $display_text ) { |
26 | | - $title = $article->getTitle(); |
27 | | - |
28 | | - // Send notifications to assignees and ccs |
29 | | - fnMailNotification( 'Assigned to', $article, $user, $pre_title, $message, $display_diff, $display_text ); |
30 | | - fnMailNotification( 'Carbon copy', $article, $user, $pre_title, $message, $display_diff, $display_text ); |
31 | | - return TRUE; |
32 | | -} |
33 | | - |
34 | | -/** |
35 | | -* Sends mail notifications |
36 | | -* @param $query_word String: the property that designate the users to notify. |
37 | | -*/ |
38 | | -function fnMailNotification( $query_word, $article, $user, $pre_title, $message, $display_diff, $display_text ) { |
39 | | - $title = $article->getTitle(); |
40 | | - |
41 | | - // get the result of the query "[[$title]][[$query_word::+]]" |
42 | | - $properties_to_display = array(); |
43 | | - $properties_to_display[0] = $query_word; |
44 | | - $results = st_get_query_results( "[[$title]][[$query_word::+]]", $properties_to_display, false ); |
45 | | - |
46 | | - // In theory, there is only one row |
47 | | - while ( $row = $results->getNext() ) { |
48 | | - $task_assignees = $row[0]; |
49 | | - } |
50 | | - |
51 | | - // If not any row, do nothing |
52 | | - if ( empty( $task_assignees ) ) { |
53 | | - return FALSE; |
54 | | - } |
55 | | - |
56 | | - $subject = "$pre_title $title"; |
57 | | - $from = new MailAddress( $user->getEmail(), $user->getName() ); |
58 | | - $link = $title->escapeFullURL(); |
59 | | - |
60 | | - $user_mailer = new UserMailer(); |
61 | | - |
62 | | - while ( $task_assignee = $task_assignees->getNextObject() ) { |
63 | | - $assignee_username = $task_assignee->getTitle(); |
64 | | - $assignee_user_name = explode( ":", $assignee_username ); |
65 | | - $assignee_name = $assignee_user_name[1]; |
66 | | - $body = wfMsg( $message , $assignee_name , $title ) . $link; |
67 | | - if ( $display_text ) { |
68 | | - $body .= "\n \n" . wfMsg( 'semantictasks-text-message' ) . "\n" . $article->getContent() ; |
69 | | - } |
70 | | - if ( $display_diff ) { |
71 | | - $body .= "\n \n" . wfMsg( 'semantictasks-diff-message' ) . "\n" . st_generateDiffBody_txt( $title ); |
72 | | - } |
73 | | - |
74 | | - // TEST: uncomment this for test mode (Writes body in testFile) |
75 | | - // st_WriteTestFile( $body ); |
76 | | - |
77 | | - $assignee = User::newFromName( $assignee_name ); |
78 | | - // if assignee is the current user, do nothing |
79 | | - if ( $assignee->getID() != $user->getID() ) { |
80 | | - $assignee_mail = new MailAddress( $assignee->getEmail(), $assignee_name ); |
81 | | - $user_mailer->send( $assignee_mail, $from, $subject, $body ); |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - return TRUE; |
86 | | -} |
87 | | - |
88 | | -/** |
89 | | -* Generates a diff txt |
90 | | -* @param Title $title |
91 | | -* @return string |
92 | | -*/ |
93 | | -function st_generateDiffBody_txt( $title ) { |
94 | | - $revision = Revision::newFromTitle( $title, 0 ); |
95 | | - $diff = new DifferenceEngine( $title, $revision->getId(), 'prev' ); |
96 | | - // The getDiffBody() method generates html, so let's generate the txt diff manualy: |
97 | | - global $wgContLang; |
98 | | - $diff->loadText(); |
99 | | - $otext = str_replace( "\r\n", "\n", $diff->mOldtext ); |
100 | | - $ntext = str_replace( "\r\n", "\n", $diff->mNewtext ); |
101 | | - $ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) ); |
102 | | - $nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) ); |
103 | | - // We use here the php diff engine included in MediaWiki |
104 | | - $diffs = new Diff( $ota, $nta ); |
105 | | - // And we ask for a txt formatted diff |
106 | | - $formatter = new UnifiedDiffFormatter(); |
107 | | - $diff_text = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ); |
108 | | - return $diff_text; |
109 | | -} |
110 | | - |
111 | | -/** |
112 | | -* This function returns to results of a certain query |
113 | | -* Thank you Yaron Koren for advices concerning this code |
114 | | -* @param $query_string String : the query |
115 | | -* @param $properties_to_display array(String): array of property names to display |
116 | | -* @param $display_title Boolean : add the page title in the result |
117 | | -* @return TODO |
118 | | -*/ |
119 | | -function st_get_query_results( $query_string, $properties_to_display, $display_title ) { |
120 | | - // i18n |
121 | | - wfLoadExtensionMessages( 'SemanticTasks' ); |
122 | | - |
123 | | - // We use the Semantic Media Wiki Processor |
124 | | - global $smwgIP; |
125 | | - include_once( $smwgIP . "/includes/SMW_QueryProcessor.php" ); |
126 | | - |
127 | | - $params = array(); |
128 | | - $inline = true; |
129 | | - $format = 'auto'; |
130 | | - $printlabel = ""; |
131 | | - $printouts = array(); |
132 | | - |
133 | | - // add the page name to the printouts |
134 | | - if ( $display_title ) { |
135 | | - $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $printlabel ); |
136 | | - array_push( $printouts, $to_push ); |
137 | | - } |
138 | | - |
139 | | - // Push the properties to display in the printout array. |
140 | | - foreach ( $properties_to_display as $property ) { |
141 | | - if ( class_exists( 'SMWPropertyValue' ) ) { // SMW 1.4 |
142 | | - $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printlabel, SMWPropertyValue::makeProperty( $property ) ); |
143 | | - } else { |
144 | | - $to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printlabel, Title::newFromText( $property, SMW_NS_PROPERTY ) ); |
145 | | - } |
146 | | - array_push( $printouts, $to_push ); |
147 | | - } |
148 | | - |
149 | | - $query = SMWQueryProcessor::createQuery( $query_string, $params, $inline, $format, $printouts ); |
150 | | - $results = smwfGetStore()->getQueryResult( $query ); |
151 | | - |
152 | | - return $results; |
153 | | -} |
154 | | - |
155 | | -function fnRemindAssignees( $wiki_url ) { |
156 | | - global $wgSitename, $wgServer; |
157 | | - |
158 | | - $user_mailer = new UserMailer(); |
159 | | - |
160 | | - $t = getdate(); |
161 | | - $today = date( 'F d Y', $t[0] ); |
162 | | - |
163 | | - $query_string = "[[Reminder at::+]][[Status::New||In Progress]][[Target date::> $today]]"; |
164 | | - $properties_to_display = array( 'Reminder at', 'Assigned to', 'Target date' ); |
165 | | - |
166 | | - $results = st_get_query_results( $query_string, $properties_to_display, true ); |
167 | | - if ( empty( $results ) ) { |
168 | | - return FALSE; |
169 | | - } |
170 | | - |
171 | | - $sender = new MailAddress( "no-reply@$wgServerName", "$wgSitename" ); |
172 | | - |
173 | | - while ( $row = $results->getNext() ) { |
174 | | - $task_name = $row[0]->getNextObject()->getTitle(); |
175 | | - $subject = '[' . $wgSitename . '] ' . wfMsg( 'semantictasks-reminder' ) . $task_name; |
176 | | - // The following doesn't work, maybe because we use a cron job. |
177 | | - // $link = $task_name->escapeFullURL(); |
178 | | - // So let's do it manually |
179 | | - $link = $wiki_url . $task_name->getPartialURL(); |
180 | | - |
181 | | - $target_date = $row[3]->getNextObject(); |
182 | | - $tg_date = new DateTime( $target_date->getShortHTMLText() ); |
183 | | - |
184 | | - while ( $reminder = $row[1]->getNextObject() ) { |
185 | | - $remind_me_in = $reminder->getShortHTMLText(); |
186 | | - $date = new DateTime( $today ); |
187 | | - $date->modify( "+$remind_me_in day" ); |
188 | | - |
189 | | - if ( $tg_date-> format( 'F d Y' ) == $date-> format( 'F d Y' ) ) { |
190 | | - global $wgLang; |
191 | | - while ( $task_assignee = $row[2]->getNextObject() ) { |
192 | | - $assignee_username = $task_assignee->getTitle(); |
193 | | - $assignee_user_name = explode( ":", $assignee_username ); |
194 | | - $assignee_name = $assignee_user_name[1]; |
195 | | - |
196 | | - $assignee = User::newFromName( $assignee_name ); |
197 | | - $assignee_mail = new MailAddress( $assignee->getEmail(), $assignee_name ); |
198 | | - $body = wfMsgExt( 'semantictasks-reminder-message', 'parsemag', $assignee_name, $task_name, $wgLang->formatNum( $remind_me_in ), $link ); |
199 | | - $user_mailer->send( $assignee_mail, $sender, $subject, $body ); |
200 | | - } |
201 | | - } |
202 | | - } |
203 | | - } |
204 | | - return TRUE; |
205 | | -} |
206 | | - |
207 | | -function st_SetupExtension() { |
208 | | - global $wgHooks; |
209 | | - $wgHooks['ArticleSaveComplete'][] = 'fnMailAssignees_updated_task'; |
210 | | - return true; |
211 | | -} |
212 | | - |
213 | | -/** |
214 | | -* This function is for test mode only, it write its argument in a specific file. |
215 | | -* This file must be writable for the system and be at the roor of your wiki installation |
216 | | -* @param $stringData String : to write |
217 | | -*/ |
218 | | -function st_WriteTestFile( $stringData ) { |
219 | | - $testFile = "testFile.txt"; |
220 | | - $fh = fopen( $testFile, 'w' ) or die( "can't open file" ); |
221 | | - fwrite( $fh, $stringData ); |
222 | | - fclose( $fh ); |
223 | | -} |
Index: trunk/extensions/SemanticTasks/INSTALL |
— | — | @@ -1,4 +1,4 @@ |
2 | | -[[Semantic Tasks 1.0]] |
| 2 | +[[Semantic Tasks 1.2]] |
3 | 3 | |
4 | 4 | == Installation == |
5 | 5 | |