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

Commit

Permalink
Better API for get_my_feed
Browse files Browse the repository at this point in the history
Ability to force recycle_bin creation in workspace share
  • Loading branch information
cdujeu committed Nov 13, 2013
1 parent 13dc2f2 commit a00c8ef
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/access.fs/class.fsAccessDriver.php
Expand Up @@ -1963,7 +1963,7 @@ public function makeSharedRepositoryOptions($httpVars, $repository)
$newOptions = array(
"PATH" => $repository->getOption("PATH").AJXP_Utils::decodeSecureMagic($httpVars["file"]),
"CREATE" => false,
"RECYCLE_BIN" => "",
"RECYCLE_BIN" => isSet($httpVars["inherit_recycle"])? $repository->getOption("RECYCLE_BIN") : "",
"DEFAULT_RIGHTS" => "");
if ($repository->getOption("USE_SESSION_CREDENTIALS")===true) {
$newOptions["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString();
Expand Down
Expand Up @@ -122,7 +122,9 @@ public function loadUserFeed($actionName, $httpVars, $fileVars)
if($rightString == "r" | $rightString == "rw") $authRepos[] = $repoId;
}
}
$res = $this->eventStore->loadEvents($authRepos, $userId, $userGroup, 0, 10);
$offset = isSet($httpVars["offset"]) ? intval($httpVars["offset"]): 0;
$limit = isSet($httpVars["limit"]) ? intval($httpVars["limit"]): 15;
$res = $this->eventStore->loadEvents($authRepos, $userId, $userGroup, $offset, $limit, (isSet($httpVars["repository_id"])?false:true));
$mess = ConfService::getMessages();
$format = "html";
if (isSet($httpVars["format"])) {
Expand Down
Expand Up @@ -47,9 +47,10 @@ public function persistEvent($hookName, $data, $repositoryId, $repositoryScope,
* @param string $userGroup
* @param integer $offset
* @param integer $limit
* @param boolean $enlargeToOwned
* @return AJXP_Notification[]
*/
public function loadEvents($filterByRepositories, $userId, $userGroup, $offset = 0, $limit = 10);
public function loadEvents($filterByRepositories, $userId, $userGroup, $offset = 0, $limit = 10, $enlargeToOwned = true);

/**
* @abstract
Expand Down
15 changes: 13 additions & 2 deletions core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php
Expand Up @@ -90,19 +90,30 @@ public function persistEvent($hookName, $data, $repositoryId, $repositoryScope,
* @param integer $limit
* @return An array of stdClass objects with keys hookname, arguments, author, date, repository
*/
public function loadEvents($filterByRepositories, $userId, $userGroup, $offset = 0, $limit = 10)
public function loadEvents($filterByRepositories, $userId, $userGroup, $offset = 0, $limit = 10, $enlargeToOwned = true)
{
if($this->sqlDriver["password"] == "XXXX") return array();
require_once(AJXP_BIN_FOLDER."/dibi.compact.php");
dibi::connect($this->sqlDriver);
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND
if ($enlargeToOwned) {
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND
( [repository_id] IN (%s) OR [repository_owner] = %s )
AND (
[repository_scope] = 'ALL'
OR ([repository_scope] = 'USER' AND [user_id] = %s )
OR ([repository_scope] = 'GROUP' AND [user_group] = %s )
)
ORDER BY [edate] DESC %lmt %ofs", "event", $filterByRepositories, $userId, $userId, $userGroup, $limit, $offset);
} else {
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND
( [repository_id] IN (%s))
AND (
[repository_scope] = 'ALL'
OR ([repository_scope] = 'USER' AND [user_id] = %s )
OR ([repository_scope] = 'GROUP' AND [user_group] = %s )
)
ORDER BY [edate] DESC %lmt %ofs", "event", $filterByRepositories, $userId, $userGroup, $limit, $offset);
}
$data = array();
foreach ($res as $n => $row) {
$object = new stdClass();
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/meta.comments/class.CommentsMetaManager.php
Expand Up @@ -135,7 +135,7 @@ public function switchActions($actionName, $httpVars, $fileVars)

HTMLWriter::charsetHeader("application/json");
if ($feedStore !== false) {
$data = $feedStore->findMetaObjectsByIndexPath(ConfService::getRepository()->getId(), $uniqNode->getPath(), AuthService::getLoggedUser()->getId(), AuthService::getLoggedUser()->getGroupPath(), 0, 20, "date", "asc");
$data = $feedStore->findMetaObjectsByIndexPath(ConfService::getRepository()->getId(), $uniqNode->getPath(), AuthService::getLoggedUser()->getId(), AuthService::getLoggedUser()->getGroupPath(), 0, 100, "date", "asc");
$theFeed = array();
foreach ($data as $stdObject) {
$rPath = substr($stdObject->path, strlen($uniqNode->getPath()));
Expand All @@ -150,7 +150,7 @@ public function switchActions($actionName, $httpVars, $fileVars)
"rpath" => $rPath
);
if (isSet($previous) && $previous["author"] == $newItem["author"] && $previous["path"] == $newItem["path"] && $previous["hdate"] == $newItem["hdate"] ) {
$theFeed[count($theFeed) - 1]["content"].= $newItem["content"];
$theFeed[count($theFeed) - 1]["content"].= '<br>--<br>'.$newItem["content"];

} else {
$theFeed[] = $newItem;
Expand Down
38 changes: 38 additions & 0 deletions core/src/plugins/meta.comments/class.CommentsPanel.js
Expand Up @@ -17,6 +17,43 @@
*
* The latest code can be found at <http://pyd.io/>.
*/


(function() {
var autoLink,
__slice = [].slice;

autoLink = function() {
var k, linkAttributes, option, options, pattern, v;
options = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
pattern = /(^|\s)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
if (!(options.length > 0)) {
return this.replace(pattern, "$1<a href='$2'>$2</a>");
}
option = options[0];
linkAttributes = ((function() {
var _results;
_results = [];
for (k in option) {
v = option[k];
if (k !== 'callback') {
_results.push(" " + k + "='" + v + "'");
}
}
return _results;
})()).join('');
return this.replace(pattern, function(match, space, url) {
var link;
link = (typeof option.callback === "function" ? option.callback(url) : void 0) || ("<a href='" + url + "'" + linkAttributes + ">" + url + "</a>");
return "" + space + link;
});
};

String.prototype['autoLink'] = autoLink;

}).call(this);


Class.create("CommentsPanel", {

// Warning, method is called statically, there is no "this"
Expand Down Expand Up @@ -108,6 +145,7 @@ Class.create("CommentsPanel", {
commentObjectToDOM: function(hash, container, node, skipAnim){

var pFactory = new PreviewFactory();
hash.set('content', hash.get('content').autoLink({target:'_blank'}));
var tpl = new Template('<div class="comment_legend"><span class="icon-remove comment_delete"></span>#{author}, #{hdate}</div><div class="comment_text"><span class="comment_text_content">#{content}</span></div>');
var el = new Element("div", {className:'comment_content'}).update(tpl.evaluate(hash._object));
if(hash.get('rpath')){
Expand Down
10 changes: 10 additions & 0 deletions core/src/plugins/meta.comments/comments_feed.css
Expand Up @@ -82,6 +82,16 @@ div.double #comments_form textarea, div.triple #comments_form textarea{
padding: 5px;
}

.comment_text_content a{
display: inline !important;
background-color: transparent !important;
font-size: inherit !important;
cursor: pointer !important;
margin: 0 !important;
border: 0 !important;
padding: 0 !important;
}

.foldedPanel_tooltip .comment_legend{
display: none;
}
Expand Down

0 comments on commit a00c8ef

Please sign in to comment.