Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix alerts with shared minisites
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jul 25, 2014
1 parent 4fe48a4 commit 3474e9b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
12 changes: 12 additions & 0 deletions core/src/plugins/core.notifications/class.AJXP_Notification.php
Expand Up @@ -218,6 +218,18 @@ public function getAuthor()
return $this->author;
}

public function getAuthorLabel(){
if (array_key_exists($this->getAuthor(), self::$usersCaches)) {
$uLabel = self::$usersCaches[$this->getAuthor()];
} if (AuthService::userExists($this->getAuthor())) {
$obj = ConfService::getConfStorageImpl()->createUserObject($this->getAuthor());
$uLabel = $obj->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
self::$usersCaches[$this->getAuthor()] = $uLabel;
}
if(!empty($uLabel)) return $uLabel;
else return $this->getAuthor();
}

public function setDate($date)
{
$this->date = $date;
Expand Down
Expand Up @@ -179,7 +179,7 @@ public function loadUserFeed($actionName, $httpVars, $fileVars)
} catch (Exception $e) {
continue;
}
$node->event_description = ucfirst($notif->getDescriptionBlock()) . " ".$mess["notification.tpl.block.user_link"] ." ". $notif->getAuthor();
$node->event_description = ucfirst($notif->getDescriptionBlock()) . " ".$mess["notification.tpl.block.user_link"] ." ". $notif->getAuthorLabel();
$node->event_description_long = $notif->getDescriptionLong(true);
$node->event_date = AJXP_Utils::relativeDate($notif->getDate(), $mess);
$node->event_time = $notif->getDate();
Expand Down Expand Up @@ -255,6 +255,9 @@ public function loadUserAlerts($actionName, $httpVars, $fileVars)
$res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
if(!count($res)) return;

// Recompute children notifs


$format = $httpVars["format"];
$skipContainingTags = (isSet($httpVars["skip_container_tags"]));
$mess = ConfService::getMessages();
Expand All @@ -266,6 +269,8 @@ public function loadUserAlerts($actionName, $httpVars, $fileVars)
AJXP_XMLWriter::header();
}
}
$parentRepository = ConfService::getRepositoryById($repositoryFilter);
$parentRoot = $parentRepository->getOption("PATH");
$cumulated = array();
foreach ($res as $notification) {
if ($format == "html") {
Expand All @@ -276,6 +281,26 @@ public function loadUserAlerts($actionName, $httpVars, $fileVars)
$node = $notification->getNode();
$path = $node->getPath();

if($node->getRepository()->hasParent() && $node->getRepository()->getParentId() == $repositoryFilter){
$nodeRepo = $node->getRepository();
$currentRoot = $nodeRepo->getOption("PATH");
$contentFilter = $nodeRepo->getContentFilter();
if(isSet($contentFilter)){
$nodePath = $contentFilter->filterExternalPath($node->getPath());
if($nodePath == "/"){
$k = array_keys($contentFilter->filters);
$nodePath = $k[0];
}
}else{
$nodePath = $node->getPath();
}
$relative = rtrim( substr($currentRoot, strlen($parentRoot)), "/"). rtrim($nodePath, "/");
$parentNodeURL = $node->getScheme()."://".$repositoryFilter.$relative;
$this->logDebug("action.share", "Recompute alert to ".$parentNodeURL);
$node = new AJXP_Node($parentNodeURL);
}


if (isSet($cumulated[$path])) {
$cumulated[$path]->event_occurence ++;
continue;
Expand All @@ -289,7 +314,7 @@ public function loadUserAlerts($actionName, $httpVars, $fileVars)
continue;
}
$node->event_is_alert = true;
$node->event_description = ucfirst($notification->getDescriptionBlock()) . " ".$mess["notification.tpl.block.user_link"] ." ". $notification->getAuthor();
$node->event_description = ucfirst($notification->getDescriptionBlock()) . " ".$mess["notification.tpl.block.user_link"] ." ". $notification->getAuthorLabel();
$node->event_description_long = $notification->getDescriptionLong(true);
$node->event_date = AJXP_Utils::relativeDate($notification->getDate(), $mess);
$node->event_type = "alert";
Expand All @@ -309,15 +334,20 @@ public function loadUserAlerts($actionName, $httpVars, $fileVars)
}
$index = 1;
foreach ($cumulated as $nodeToSend) {
if ($nodeToSend->event_occurence > 1) {
$nodeToSend->setLabel(basename($nodeToSend->getPath()) . " (". $nodeToSend->event_occurence .")" );
} else {
$nodeToSend->setLabel(basename($nodeToSend->getPath()));
$nodeOcc = $nodeToSend->event_occurence > 1 ? "(".$nodeToSend->event_occurence.")" : "";
if(isSet($httpVars["merge_description"]) && $httpVars["merge_description"] == "true"){
if(isSet($httpVars["description_as_label"]) && $httpVars["description_as_label"] == "true"){
$nodeToSend->setLabel($nodeToSend->event_description." ". $nodeOcc." ".$nodeToSend->event_date);
}else{
$nodeToSend->setLabel(basename($nodeToSend->getPath())." ". $nodeOcc." "." <small class='notif_desc'>".$nodeToSend->event_description." ".$nodeToSend->event_date."</small>");
}
}else{
$nodeToSend->setLabel(basename($nodeToSend->getPath()) . $nodeOcc);
}
// Replace PATH
$nodeToSend->real_path = $path;
$url = parse_url($nodeToSend->getUrl());
$nodeToSend->setUrl($url["scheme"]."://".$url["host"]."/alert_".$index);
//$nodeToSend->setUrl($url["scheme"]."://".$url["host"]."/alert_".$index);
$index ++;
AJXP_XMLWriter::renderAjxpNode($nodeToSend);

Expand Down
Expand Up @@ -64,7 +64,7 @@ public function persistAlert(AJXP_Notification $notif);
* @abstract
* @param $userId
* @param null $repositoryIdFilter
* @return mixed
* @return AJXP_Notification[]
*/
public function loadAlerts($userId, $repositoryIdFilter = null);

Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/core.notifications/manifest.xml
Expand Up @@ -111,7 +111,7 @@
<additional_content id="navigation_alerts"><![CDATA[
<div id="navigation_alerts" ajxp_position="0">
<h3 class="colorcode-alert" ajxp_message_id="notification_center.3">AJXP_MESSAGE[notification_center.3] <span class="alerts_number_badge" id="alerts_number" ajxpClass="DataModelProperty" ajxpOptions='{"dmID":"notif_pane","property":"metadata","metadata_sum":"event_occurence"}'></span><small id="alerts_toggler" class="simple-toggler-hide" ajxpClass="VisibilityToggler" ajxpOptions='{"widget_id":"notif_pane"}'>AJXP_MESSAGE[514]</small></h3>
<div id="notif_pane" ajxpClass="FetchedResultPane" ajxpOptions='{"forceClearOnRepoSwitch":true, "inlineToolbarOptions":{"toolbarsList":["inline-notifications"]}, "fit":"content", "columnsDef":[{"attributeName":"ajxp_label", "messageId":1, "sortType":"String"},{"attributeName":"event_time", "messageString":"Time", "sortType":"MyDate"},{"attributeName":"event_type", "messageString":"Type", "sortType":"String"}], "reloadOnServerMessage":"tree/reload_user_feed", "silentLoading":true, "fixedSortColumn":"event_time", "fixedSortDirection":"desc","nodeProviderProperties":{"get_action":"get_my_feed", "connexion_discrete":true, "format":"xml", "current_repository":"true", "feed_type":"alert", "merge_description":"true"}, "emptyChildrenMessage":"notification_center.8"}'></div>
<div id="notif_pane" ajxpClass="FetchedResultPane" ajxpOptions='{"forceClearOnRepoSwitch":true, "inlineToolbarOptions":{"toolbarsList":["inline-notifications"]}, "fit":"content", "columnsDef":[{"attributeName":"ajxp_label", "messageId":1, "sortType":"String"},{"attributeName":"event_description", "messageString":"Description", "sortType":"String"}], "reloadOnServerMessage":"tree/reload_user_feed", "silentLoading":true, "fixedSortColumn":"event_time", "fixedSortDirection":"desc","nodeProviderProperties":{"get_action":"get_my_feed", "connexion_discrete":true, "format":"xml", "current_repository":"true", "feed_type":"alert", "merge_description":"true"}, "emptyChildrenMessage":"notification_center.8"}'></div>
</div>
]]></additional_content>
</component_config>
Expand Down
5 changes: 4 additions & 1 deletion core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php
Expand Up @@ -189,7 +189,10 @@ public function loadAlerts($userId, $repositoryIdFilter = null)
require_once(AJXP_BIN_FOLDER."/dibi.compact.php");
dibi::connect($this->sqlDriver);
if ($repositoryIdFilter != null) {
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [repository_id] = %s AND [user_id] = %s ORDER BY [edate] DESC %lmt", "alert", $repositoryIdFilter, $userId, 100);
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s
AND ([repository_id] = %s OR [repository_id] IN (SELECT [uuid] FROM [ajxp_repo] WHERE [parent_uuid]=%s))
AND [user_id] = %s ORDER BY [edate] DESC %lmt", "alert", $repositoryIdFilter, $repositoryIdFilter, $userId, 100);
//$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [repository_id] = %s AND [user_id] = %s ORDER BY [edate] DESC %lmt", "alert", $repositoryIdFilter, $userId, 100);
} else {
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [user_id] = %s ORDER BY [edate] DESC %lmt", "alert", $userId, 100);
}
Expand Down
18 changes: 15 additions & 3 deletions core/src/plugins/gui.ajax/res/themes/orbit/css/ajaxplorer.css
Expand Up @@ -1804,8 +1804,8 @@ div.detailed div.FL-inlineToolbar div.toolbarGroup {

#topPane div.FL-inlineToolbar{
position: absolute;
top: 10px;
right: 40px;
top: 4px;
right: 33px;
margin: 0;
}

Expand Down Expand Up @@ -1877,6 +1877,15 @@ div.class-FetchedResultPane > div.panelHeader
#notif_pane div.thumbLabel small {
font-style: italic;
opacity: 0.7;
display: block;
margin-left: 40px;
width: 217px;
overflow: hidden;
height: auto;
}

#notif_pane div.thumbLabel {
padding: 4px 0 !important;
}

#topPane h3,
Expand Down Expand Up @@ -3502,7 +3511,10 @@ div.class-FetchedResultPane div.thumbnail_selectable_cell.detailed div.thumbLabe

#topPane div.thumbnail_selectable_cell.detailed div.thumbLabel{
color: #ccc;
font-weight: lighter;
}

#topPane div.thumbnail_selectable_cell.detailed.selected.selected-focus div.thumbLabel{
color: #fff;
}

div.class-FetchedResultPane div.thumbnail_selectable_cell.detailed span.text_label,
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/themes/orbit/css/allz.css

Large diffs are not rendered by default.

0 comments on commit 3474e9b

Please sign in to comment.