mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
add listAllPads API function
This commit is contained in:
parent
2466e65212
commit
5f5a909420
5 changed files with 45 additions and 1 deletions
|
@ -464,6 +464,46 @@ exports.isPasswordProtected = function(padID, callback)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
listAllPads() returns a array with all pads
|
||||||
|
|
||||||
|
Example returns:
|
||||||
|
|
||||||
|
{code: 0, message:"ok", data: ["pad1", "pad2"]}
|
||||||
|
*/
|
||||||
|
exports.listAllPads = function(callback)
|
||||||
|
{
|
||||||
|
allPads = [];
|
||||||
|
|
||||||
|
var defaultGroup = "g.defaultGroupName";
|
||||||
|
|
||||||
|
//get all groups
|
||||||
|
groupManager.listGroups(function (err, groups)
|
||||||
|
{
|
||||||
|
groups=groups["groups"];
|
||||||
|
// if defaultGroup exists add this too, becaus ists not listed in groupManager.listGroups
|
||||||
|
groupManager.doesGroupExist(defaultGroup, function(err, exists)
|
||||||
|
{
|
||||||
|
if(exists)
|
||||||
|
{
|
||||||
|
groups.push(defaultGroup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for(var group in groups)
|
||||||
|
{
|
||||||
|
groupManager.listPads(groups[group], function(err, pads)
|
||||||
|
{
|
||||||
|
for(var pad in pads)
|
||||||
|
{
|
||||||
|
allPads.push(pads[pad]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(null, {padIDs: allPads});
|
||||||
|
}
|
||||||
|
|
||||||
/******************************/
|
/******************************/
|
||||||
/** INTERNAL HELPER FUNCTIONS */
|
/** INTERNAL HELPER FUNCTIONS */
|
||||||
/******************************/
|
/******************************/
|
||||||
|
|
|
@ -142,6 +142,7 @@ exports.listGroups = function(callback)
|
||||||
//try to get the groups entry
|
//try to get the groups entry
|
||||||
db.get("groups", function (err, groups)
|
db.get("groups", function (err, groups)
|
||||||
{
|
{
|
||||||
|
if(groups == null) groups = [];
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
callback(null, groups);
|
callback(null, groups);
|
||||||
});
|
});
|
||||||
|
|
|
@ -354,6 +354,7 @@ Pad.prototype.init = function init(text, callback) {
|
||||||
if(_this.id.indexOf("$")==-1)
|
if(_this.id.indexOf("$")==-1)
|
||||||
{
|
{
|
||||||
groupID = "g.defaultGroupName";
|
groupID = "g.defaultGroupName";
|
||||||
|
console.log(groupManager);
|
||||||
groupManager.doesGroupExist(groupID, function(err, exists)
|
groupManager.doesGroupExist(groupID, function(err, exists)
|
||||||
{
|
{
|
||||||
if(!exists)
|
if(!exists)
|
||||||
|
|
|
@ -42,7 +42,8 @@ var functions = {
|
||||||
"createGroup" : [],
|
"createGroup" : [],
|
||||||
"createGroupIfNotExistsFor" : ["groupMapper"],
|
"createGroupIfNotExistsFor" : ["groupMapper"],
|
||||||
"deleteGroup" : ["groupID"],
|
"deleteGroup" : ["groupID"],
|
||||||
"listPads" : ["groupID"],
|
"listPads" : ["groupID"],
|
||||||
|
"listAllPads" : [],
|
||||||
"createPad" : ["padID", "text"],
|
"createPad" : ["padID", "text"],
|
||||||
"createGroupPad" : ["groupID", "padName", "text"],
|
"createGroupPad" : ["groupID", "padName", "text"],
|
||||||
"createAuthor" : ["name"],
|
"createAuthor" : ["name"],
|
||||||
|
|
|
@ -144,6 +144,7 @@
|
||||||
<div class="define">deleteGroup(groupID)</div>
|
<div class="define">deleteGroup(groupID)</div>
|
||||||
<div class="define">createGroupIfNotExistsFor(groupMapper)</div>
|
<div class="define">createGroupIfNotExistsFor(groupMapper)</div>
|
||||||
<div class="define">listPads(groupID)</div>
|
<div class="define">listPads(groupID)</div>
|
||||||
|
<div class="define">listAllPads()</div>
|
||||||
<div class="define">createPad(padID,text)</div>
|
<div class="define">createPad(padID,text)</div>
|
||||||
<div class="define">createGroupPad(groupID,padName,text)</div>
|
<div class="define">createGroupPad(groupID,padName,text)</div>
|
||||||
<div class="define">createAuthor(name)</div>
|
<div class="define">createAuthor(name)</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue