Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.php |
— | — | @@ -43,16 +43,10 @@ |
44 | 44 | SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $querystring ), $querystring, $params, $printouts ); |
45 | 45 | $relatedArticles = array(); |
46 | 46 | foreach ( $printouts as $po ) { |
47 | | - if ( $po == $params['sort'] ) $sorted = true; |
48 | 47 | $printoutArticles[] = array( |
49 | 48 | 'namespace' => SMW_NS_PROPERTY, |
50 | | - 'title' => Title::makeTitle( SMW_NS_PROPERTY, $po->getText() )->getDBkey() ); |
| 49 | + 'title' => Title::makeTitle( SMW_NS_PROPERTY, $po->getText( SMW_OUTPUT_WIKI ) )->getDBkey() ); |
51 | 50 | } |
52 | | - if ( !$sorted && isset( $params['sort'] ) ) { |
53 | | - $printoutArticles[] = array( |
54 | | - 'namespace' => SMW_NS_PROPERTY, |
55 | | - 'title' => Title::makeTitle( SMW_NS_PROPERTY, $params['sort'] )->getDBkey() ); |
56 | | - } |
57 | 51 | |
58 | 52 | $qp = new SMWNotifyParser( $notify_id, $printoutArticles ); |
59 | 53 | $qp->setDefaultNamespaces( $smwgQDefaultNamespaces ); |
— | — | @@ -1129,16 +1123,16 @@ |
1130 | 1124 | |
1131 | 1125 | class SMWNotifyUpdate { |
1132 | 1126 | protected $m_info; |
1133 | | - protected $m_title; |
1134 | | - protected $m_userMsgs; |
1135 | | - protected $m_userHtmlPropMsgs; |
1136 | | - protected $m_userHtmlNMMsgs; |
1137 | | - protected $m_userNMs; |
1138 | | - protected $m_notifyHtmlPropMsgs; |
1139 | | - protected $m_notifyHtmlMsgs; |
1140 | | - protected $m_newMonitor; |
1141 | | - protected $m_removeMonitored; |
1142 | | - protected $m_subQueryNotify; |
| 1127 | + protected $m_title; // current title of the update |
| 1128 | + protected $m_userMsgs; // user_id => plain text message |
| 1129 | + protected $m_userHtmlPropMsgs; // user_id => html message, prop change detail |
| 1130 | + protected $m_userHtmlNMMsgs; // user_id => html message, all notify hint |
| 1131 | + protected $m_userNMs; // user_id => notify_id |
| 1132 | + protected $m_notifyHtmlPropMsgs; // notify_id => html message, prop change detail |
| 1133 | + protected $m_notifyHtmlMsgs; // notify_id => html message, all notify hint |
| 1134 | + protected $m_newMonitor; // notify newly matches the page, array( notify id, page id ) |
| 1135 | + protected $m_removeMonitored; // notify no longer matches the page, array( notify id, page id ) |
| 1136 | + protected $m_subQueryNotify; // subquery, will go through all pages, attention!!! |
1143 | 1137 | |
1144 | 1138 | protected $m_linker; |
1145 | 1139 | |
— | — | @@ -1202,6 +1196,7 @@ |
1203 | 1197 | $sStore = NMStorage::getDatabase(); |
1204 | 1198 | $notifications = $sStore->getMonitoredNotifications( $page_id ); |
1205 | 1199 | |
| 1200 | + $notifyMsgAdded = array(); |
1206 | 1201 | foreach ( $notifications as $user_id => $notifies ) { |
1207 | 1202 | $this->m_userMsgs[$user_id] .= $msg . '\r\n( NM: '; |
1208 | 1203 | $hint = wfMsg( 'smw_nm_hint_delete_html', $page_html_name, htmlspecialchars( $reason ) ); |
— | — | @@ -1215,7 +1210,10 @@ |
1216 | 1211 | } else { |
1217 | 1212 | $first = false; |
1218 | 1213 | } |
1219 | | - $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
| 1214 | + if ( !isset( $notifyMsgAdded[$notify_id] ) ) { |
| 1215 | + $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
| 1216 | + $notifyMsgAdded[$notify_id] = true; |
| 1217 | + } |
1220 | 1218 | |
1221 | 1219 | $this->m_userMsgs[$user_id] .= $notify_detail['name']; |
1222 | 1220 | $htmlMsg .= '<b>' . htmlspecialchars( $notify_detail['name'] ) . '</b>'; |
— | — | @@ -1273,13 +1271,13 @@ |
1274 | 1272 | $i = SMWNotifyProcessor::getInfoFromId( $key ); |
1275 | 1273 | if ( $i[type] == 0 ) { |
1276 | 1274 | return "<td>Category</td> |
1277 | | - <td>" . $info[name]->getShortHTMLText( $this->m_linker ) . "</td> |
| 1275 | + <td>" . $this->getFullLink( $info[name] ) . "</td> |
1278 | 1276 | <td>" . ( $info[sem_act] == 0 ? "<font color='green'>remove</font>":"<font color='red'>cite</font>" ) . "</td> |
1279 | 1277 | <td colspan='2'>N/A</td>"; |
1280 | 1278 | } else { |
1281 | 1279 | $rows = max( count( $info[del_vals] ), count( $info[new_vals] ) ); |
1282 | 1280 | $tmp = "<tr><td rowspan='$rows'>Property</td> |
1283 | | - <td rowspan='$rows'>" . $info[name]->getShortHTMLText( $this->m_linker ) . "</td> |
| 1281 | + <td rowspan='$rows'>" . $this->getFullLink( $info[name] ) . "</td> |
1284 | 1282 | <td rowspan='$rows'>" . ( $info[sem_act] == 0 ? "<font color='green'>remove</font>":( $info[sem_act] == 1 ? "<font color='blue'>modify</font>":"<font color='red'>cite</font>" ) ) . "</td>"; |
1285 | 1283 | for ( $idx = 0; $idx < $rows; ++$idx ) { |
1286 | 1284 | if ( $idx > 0 ) { |
— | — | @@ -1311,7 +1309,7 @@ |
1312 | 1310 | } else { |
1313 | 1311 | $tmp_info[$key] = array( 'sem_act' => 0, 'name' => $value[0][name], 'del_vals' => array(), 'new_vals' => array() ); |
1314 | 1312 | foreach ( $value as $v ) { |
1315 | | - $tmp_info[$key][del_vals][] = array( 'plain' => $v[value]->getWikiValue(), 'html' => $v[value]->getShortHTMLText( $this->m_linker ) ); |
| 1313 | + $tmp_info[$key][del_vals][] = array( 'plain' => $v[value]->getWikiValue(), 'html' => $this->getFullLink( $v[value] ) ); |
1316 | 1314 | } |
1317 | 1315 | } |
1318 | 1316 | } else if ( $i[type] == 2 ) { |
— | — | @@ -1329,7 +1327,7 @@ |
1330 | 1328 | $updated = true; |
1331 | 1329 | $tmp_info[$key] = array( 'sem_act' => 1, 'name' => $value[0][name], 'del_vals' => array(), 'new_vals' => array() ); |
1332 | 1330 | } |
1333 | | - $tmp_info[$key][del_vals][] = array( 'plain' => $v1[value]->getWikiValue(), 'html' => $v1[value]->getShortHTMLText( $this->m_linker ) ); |
| 1331 | + $tmp_info[$key][del_vals][] = array( 'plain' => $v1[value]->getWikiValue(), 'html' => $this->getFullLink( $v1[value] ) ); |
1334 | 1332 | } |
1335 | 1333 | } |
1336 | 1334 | foreach ( $mvalue as $v1 ) { |
— | — | @@ -1345,7 +1343,7 @@ |
1346 | 1344 | $updated = true; |
1347 | 1345 | $tmp_info[$key] = array( 'sem_act' => 1, 'name' => $value[0][name], 'del_vals' => array(), 'new_vals' => array() ); |
1348 | 1346 | } |
1349 | | - $tmp_info[$key][new_vals][] = array( 'plain' => $v1[value]->getWikiValue(), 'html' => $v1[value]->getShortHTMLText( $this->m_linker ) ); |
| 1347 | + $tmp_info[$key][new_vals][] = array( 'plain' => $v1[value]->getWikiValue(), 'html' => $this->getFullLink( $v1[value] ) ); |
1350 | 1348 | } |
1351 | 1349 | } |
1352 | 1350 | } |
— | — | @@ -1358,7 +1356,7 @@ |
1359 | 1357 | } else { |
1360 | 1358 | $tmp_info[$key] = array( 'sem_act' => 2, 'name' => $value[0][name], 'del_vals' => array(), 'new_vals' => array() ); |
1361 | 1359 | foreach ( $value as $v ) { |
1362 | | - $tmp_info[$key][new_vals][] = array( 'plain' => $v[value]->getWikiValue(), 'html' => $v[value]->getShortHTMLText( $this->m_linker ) ); |
| 1360 | + $tmp_info[$key][new_vals][] = array( 'plain' => $v[value]->getWikiValue(), 'html' => $this->getFullLink( $v[value] ) ); |
1363 | 1361 | } |
1364 | 1362 | } |
1365 | 1363 | } |
— | — | @@ -1375,7 +1373,9 @@ |
1376 | 1374 | } |
1377 | 1375 | $page_name = $this->m_title->getText() . ' (' . $this->m_title->getFullUrl() . ')'; |
1378 | 1376 | |
| 1377 | + $notifyMsgAdded = array(); |
1379 | 1378 | foreach ( $notifications as $user_id => $notifies ) { |
| 1379 | + if ( !isset( $notifies['semantic'] ) ) continue; |
1380 | 1380 | foreach ( $notifies['semantic'] as $key => $notify ) { |
1381 | 1381 | if ( isset( $tmp_info[$key] ) ) { |
1382 | 1382 | $hint = ""; |
— | — | @@ -1388,18 +1388,25 @@ |
1389 | 1389 | $this->m_userMsgs[$user_id] .= $this->getNotifyPlain( $tmp_info[$key], $key ) . ' ( NM: '; |
1390 | 1390 | $propHint = $this->getNotifyHtml( $tmp_info[$key], $key ); |
1391 | 1391 | $this->m_userHtmlPropMsgs[$user_id] .= $propHint . "<tr><td colspan='5'>" . wfMsg( 'smw_notifyme' ) . ": "; |
1392 | | - $idx = 0; |
| 1392 | + $first = true; |
1393 | 1393 | foreach ( $notify as $notify_id => $notify_name ) { |
1394 | | - if ( $idx > 0 ) { |
| 1394 | + if ( !$first ) { |
1395 | 1395 | $this->m_userMsgs[$user_id] .= ', '; |
1396 | 1396 | $this->m_userHtmlPropMsgs[$user_id] .= ', '; |
| 1397 | + } else { |
| 1398 | + $first = false; |
1397 | 1399 | } |
1398 | 1400 | $this->m_userMsgs[$user_id] .= $notify_name; |
1399 | 1401 | $this->m_userHtmlPropMsgs[$user_id] .= '<b>' . htmlspecialchars( $notify_name ) . '</b>'; |
1400 | | - $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
1401 | | - $this->m_notifyHtmlPropMsgs[$notify_id] .= $propHint; |
1402 | | - $idx++; |
1403 | 1402 | |
| 1403 | + if ( !isset( $notifyMsgAdded[$notify_id] ) ) { |
| 1404 | + $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
| 1405 | + } |
| 1406 | + if ( !isset( $notifyMsgAdded[$notify_id][$key] ) ) { |
| 1407 | + $this->m_notifyHtmlPropMsgs[$notify_id] .= $propHint; |
| 1408 | + $notifyMsgAdded[$notify_id][$key] = true; |
| 1409 | + } |
| 1410 | + |
1404 | 1411 | $this->m_userNMs[$user_id][] = $notify_id; |
1405 | 1412 | } |
1406 | 1413 | $this->m_userMsgs[$user_id] .= ' ).'; |
— | — | @@ -1443,19 +1450,25 @@ |
1444 | 1451 | foreach ( $main_queries as $notify_id => $notify ) { |
1445 | 1452 | $sStore->getNotifyInMainQuery( $page_id, $notify_id, $notify['sql'], $notify['hierarchy'], $match, $monitoring ); |
1446 | 1453 | if ( ( !$monitoring ) && $match ) { |
1447 | | - $this->m_userMsgs[$notify['user_id']] .= wfMsg( 'smw_nm_hint_match', $page_name, $notify[name] ); |
1448 | 1454 | $hint = wfMsg( 'smw_nm_hint_match_html', $page_html_name, htmlspecialchars( $notify[name] ) ); |
1449 | | - $this->m_userHtmlNMMsgs[$notify['user_id']] .= $hint; |
| 1455 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1456 | + $this->m_userMsgs[$uid] .= wfMsg( 'smw_nm_hint_match', $page_name, $notify[name] ); |
| 1457 | + $this->m_userHtmlNMMsgs[$uid] .= $hint; |
| 1458 | + } |
1450 | 1459 | $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
1451 | 1460 | $this->m_newMonitor[] = array( 'notify_id' => $notify_id, 'page_id' => $page_id ); |
1452 | 1461 | } else if ( ( !$match ) && $monitoring ) { |
1453 | | - $this->m_userMsgs[$notify['user_id']] .= wfMsg( 'smw_nm_hint_nomatch', $page_name, $notify[name] ); |
1454 | 1462 | $hint = wfMsg( 'smw_nm_hint_nomatch_html', $page_html_name, htmlspecialchars( $notify[name] ) ); |
1455 | | - $this->m_userHtmlNMMsgs[$notify['user_id']] .= $hint; |
| 1463 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1464 | + $this->m_userMsgs[$uid] .= wfMsg( 'smw_nm_hint_nomatch', $page_name, $notify[name] ); |
| 1465 | + $this->m_userHtmlNMMsgs[$uid] .= $hint; |
| 1466 | + } |
1456 | 1467 | $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
1457 | 1468 | $this->m_removeMonitored[] = array( 'notify_id' => $notify_id, 'page_id' => $page_id ); |
1458 | 1469 | } |
1459 | | - $this->m_userNMs[$notify['user_id']][] = $notify_id; |
| 1470 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1471 | + $this->m_userNMs[$uid][] = $notify_id; |
| 1472 | + } |
1460 | 1473 | } |
1461 | 1474 | // begin notify query on sub query, should go through all pages |
1462 | 1475 | foreach ( $queries[1] as $notify_id => $notify ) { |
— | — | @@ -1475,13 +1488,17 @@ |
1476 | 1489 | $p_name = $t->getText() . ' (' . $t->getFullUrl() . ')'; |
1477 | 1490 | $p_html_name = '<a href="' . $t->getFullUrl() . '">' . htmlspecialchars( $t->getText() ) . '</a>'; |
1478 | 1491 | |
1479 | | - $this->m_userMsgs[$notify['user_id']] .= wfMsg( 'smw_nm_hint_submatch', $page_name, $p_name, $notify[name] ); |
1480 | 1492 | $hint = wfMsg( 'smw_nm_hint_submatch_html', $page_html_name, $p_html_name, htmlspecialchars( $notify[name] ) ); |
1481 | | - $this->m_userHtmlNMMsgs[$notify['user_id']] .= $hint; |
| 1493 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1494 | + $this->m_userMsgs[$uid] .= wfMsg( 'smw_nm_hint_submatch', $page_name, $p_name, $notify[name] ); |
| 1495 | + $this->m_userHtmlNMMsgs[$uid] .= $hint; |
| 1496 | + } |
1482 | 1497 | $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
1483 | 1498 | $this->m_newMonitor[] = array( 'notify_id' => $notify_id, 'page_id' => $pid ); |
1484 | 1499 | |
1485 | | - $this->m_userNMs[$notify['user_id']][] = $notify_id; |
| 1500 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1501 | + $this->m_userNMs[$uid][] = $notify_id; |
| 1502 | + } |
1486 | 1503 | } |
1487 | 1504 | foreach ( $no_matches as $pid ) { |
1488 | 1505 | $pt = $sStore->getPageTitle( $pid ); |
— | — | @@ -1492,19 +1509,33 @@ |
1493 | 1510 | $p_name = $t->getText() . ' (' . $t->getFullUrl() . ')'; |
1494 | 1511 | $p_html_name = '<a href="' . $t->getFullUrl() . '">' . htmlspecialchars( $t->getText() ) . '</a>'; |
1495 | 1512 | |
1496 | | - $this->m_userMsgs[$notify['user_id']] .= wfMsg( 'smw_nm_hint_subnomatch', $page_name, $p_name, $notify[name] ); |
1497 | 1513 | $hint = wfMsg( 'smw_nm_hint_subnomatch_html', $page_html_name, $p_html_name, htmlspecialchars( $notify[name] ) ); |
1498 | | - $this->m_userHtmlNMMsgs[$notify['user_id']] .= $hint; |
| 1514 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1515 | + $this->m_userMsgs[$uid] .= wfMsg( 'smw_nm_hint_subnomatch', $page_name, $p_name, $notify[name] ); |
| 1516 | + $this->m_userHtmlNMMsgs[$uid] .= $hint; |
| 1517 | + } |
1499 | 1518 | $this->m_notifyHtmlMsgs[$notify_id] .= $hint; |
1500 | 1519 | $this->m_removeMonitored[] = array( 'notify_id' => $notify_id, 'page_id' => $pid ); |
1501 | 1520 | |
1502 | | - $this->m_userNMs[$notify['user_id']][] = $notify_id; |
| 1521 | + foreach ( $notify['user_ids'] as $uid ) { |
| 1522 | + $this->m_userNMs[$uid][] = $notify_id; |
| 1523 | + } |
1503 | 1524 | } |
1504 | 1525 | } |
1505 | 1526 | |
1506 | 1527 | $sStore->removeNotifyMonitor( $this->m_removeMonitored ); |
1507 | 1528 | $sStore->addNotifyMonitor( $this->m_newMonitor ); |
1508 | 1529 | } |
| 1530 | + private function getFullLink( $val ) { |
| 1531 | + if ( $val instanceof SMWWikiPageValue ) { |
| 1532 | + return '<a href="' . $val->getTitle()->getFullUrl() . '">' . htmlspecialchars( $val->getTitle()->getText() ) . '</a>'; |
| 1533 | + } else if ( $val instanceof SMWPropertyValue ) { |
| 1534 | + $val = $val->getWikiPageValue(); |
| 1535 | + return '<a href="' . $val->getTitle()->getFullUrl() . '">' . htmlspecialchars( $val->getTitle()->getText() ) . '</a>'; |
| 1536 | + } else { |
| 1537 | + return $val->getShortHTMLText( $this->m_linker ); |
| 1538 | + } |
| 1539 | + } |
1509 | 1540 | private function applyStyle( $html ) { |
1510 | 1541 | $html = str_replace( "class=\"smwtable\"", "style=\"background-color: #EEEEFF;\"", $html ); |
1511 | 1542 | $html = str_replace( "<th", "<th style=\"background-color: #EEEEFF;text-align: left;\"", $html ); |
— | — | @@ -1533,7 +1564,7 @@ |
1534 | 1565 | $html_msg = $html_style; |
1535 | 1566 | $showing_all = false; |
1536 | 1567 | if ( isset( $notifications[$notify_id] ) && $notifications[$notify_id]['show_all'] ) { |
1537 | | - SMWQueryProcessor::processFunctionParams( explode( "\n", $notifications[$notify_id]['query'] ), $querystring, $params, $printouts ); |
| 1568 | + SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $notifications[$notify_id]['query'] ), $querystring, $params, $printouts ); |
1538 | 1569 | |
1539 | 1570 | $format = 'auto'; |
1540 | 1571 | if ( array_key_exists( 'format', $params ) ) { |
Index: trunk/extensions/SemanticNotifyMe/includes/storage/SMW_NMStorageSQL.php |
— | — | @@ -390,19 +390,19 @@ |
391 | 391 | if ( $db->numRows( $res ) > 0 ) { |
392 | 392 | while ( $row = $db->fetchObject( $res ) ) { |
393 | 393 | $ds = explode( ',', $row->delegate ); |
394 | | - $delegated = false; |
| 394 | + $uids = array(); |
395 | 395 | foreach ( $ds as $delegate ) { |
396 | 396 | $u = User::newFromName( trim( $delegate ) ); |
397 | 397 | if ( $u == null ) continue; |
398 | 398 | $id = $u->getId(); |
399 | 399 | if ( $id > 0 ) { |
400 | | - $result[$row->subquery > 0 ? 1:0][$row->notify_id] = array( 'user_id' => $id, 'name' => $row->name, 'sql' => $row->nm_sql, 'hierarchy' => $row->nm_hierarchy ); |
401 | | - $delegated = true; |
| 400 | + $uids[] = $id; |
402 | 401 | } |
403 | 402 | } |
404 | | - if ( !$delegated ) { |
405 | | - $result[$row->subquery > 0 ? 1:0][$row->notify_id] = array( 'user_id' => $row->user_id, 'name' => $row->name, 'sql' => $row->nm_sql, 'hierarchy' => $row->nm_hierarchy ); |
| 403 | + if ( count( $uids ) == 0 ) { |
| 404 | + $uids[] = $row->user_id; |
406 | 405 | } |
| 406 | + $result[$row->subquery > 0 ? 1:0][$row->notify_id] = array( 'user_ids' => $uids, 'name' => $row->name, 'sql' => $row->nm_sql, 'hierarchy' => $row->nm_hierarchy ); |
407 | 407 | } |
408 | 408 | } |
409 | 409 | $db->freeResult( $res ); |
— | — | @@ -421,19 +421,19 @@ |
422 | 422 | if ( $db->numRows( $res ) > 0 ) { |
423 | 423 | while ( $row = $db->fetchObject( $res ) ) { |
424 | 424 | $ds = explode( ',', $row->delegate ); |
425 | | - $delegated = false; |
| 425 | + $uids = array(); |
426 | 426 | foreach ( $ds as $delegate ) { |
427 | 427 | $u = User::newFromName( trim( $delegate ) ); |
428 | 428 | if ( $u == null ) continue; |
429 | 429 | $id = $u->getId(); |
430 | 430 | if ( $id > 0 ) { |
431 | | - $result[$row->notify_id] = array( 'user_id' => $id, 'name' => $row->name, 'sql' => $row->nm_sql, 'hierarchy' => $row->nm_hierarchy ); |
432 | | - $delegated = true; |
| 431 | + $uids[] = $id; |
433 | 432 | } |
434 | 433 | } |
435 | | - if ( !$delegated ) { |
436 | | - $result[$row->notify_id] = array( 'user_id' => $row->user_id, 'name' => $row->name, 'sql' => $row->nm_sql, 'hierarchy' => $row->nm_hierarchy ); |
| 434 | + if ( count( $uids ) == 0 ) { |
| 435 | + $uids[] = $row->user_id; |
437 | 436 | } |
| 437 | + $result[$row->notify_id] = array( 'user_ids' => $uids, 'name' => $row->name, 'sql' => $row->nm_sql, 'hierarchy' => $row->nm_hierarchy ); |
438 | 438 | } |
439 | 439 | } |
440 | 440 | $db->freeResult( $res ); |