commit
1ec75330ec
@ -0,0 +1,70 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - bookmarks plugin |
||||
* |
||||
* @author Arthur Schiwon |
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
//no apps or filesystem |
||||
$RUNTIME_NOSETUPFS=true; |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
|
||||
// We send json data |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
|
||||
// Check if we are a user |
||||
if( !OC_User::isLoggedIn()){ |
||||
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); |
||||
exit(); |
||||
} |
||||
|
||||
$query = OC_DB::prepare(" |
||||
INSERT IGNORE INTO *PREFIX*bookmarks |
||||
(url, title, description, user_id, public, added, lastmodified) |
||||
VALUES (?, ?, ?, ?, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()) |
||||
"); |
||||
|
||||
$params=array( |
||||
urldecode($_GET["url"]), |
||||
urldecode($_GET["title"]), |
||||
urldecode($_GET["description"]), |
||||
OC_User::getUser() |
||||
); |
||||
$query->execute($params); |
||||
$b_id = OC_DB::insertid(); |
||||
|
||||
if($b_id !== false) { |
||||
$query = OC_DB::prepare(" |
||||
INSERT INTO *PREFIX*bookmarks_tags |
||||
(bookmark_id, tag) |
||||
VALUES (?, ?) |
||||
"); |
||||
|
||||
$tags = explode(' ', urldecode($_GET["tags"])); |
||||
foreach ($tags as $tag) { |
||||
if(empty($tag)) { |
||||
//avoid saving blankspaces |
||||
continue; |
||||
} |
||||
$params = array($b_id, trim($tag)); |
||||
$query->execute($params); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,52 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - bookmarks plugin |
||||
* |
||||
* @author Arthur Schiwon |
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
//no apps or filesystem |
||||
$RUNTIME_NOSETUPFS=true; |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
|
||||
// We send json data |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
|
||||
// Check if we are a user |
||||
if( !OC_User::isLoggedIn()){ |
||||
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); |
||||
exit(); |
||||
} |
||||
|
||||
$query = OC_DB::prepare(" |
||||
DELETE FROM *PREFIX*bookmarks |
||||
WHERE url LIKE ? |
||||
AND user_id = ? |
||||
"); |
||||
|
||||
$params=array( |
||||
urldecode($_GET["url"]), |
||||
OC_User::getUser() |
||||
); |
||||
$result = $query->execute($params); |
||||
|
||||
// var_dump($params); |
||||
|
||||
echo json_encode( array( "status" => "success", "data" => array())); |
@ -0,0 +1,47 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - bookmarks plugin |
||||
* |
||||
* @author Arthur Schiwon |
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
//no apps or filesystem |
||||
$RUNTIME_NOSETUPFS=true; |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
|
||||
// Check if we are a user |
||||
if( !OC_User::isLoggedIn()){ |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); |
||||
exit(); |
||||
} |
||||
|
||||
$query = OC_DB::prepare(" |
||||
UPDATE *PREFIX*bookmarks |
||||
SET clickcount = clickcount + 1 |
||||
WHERE user_id = ? |
||||
AND url LIKE ? |
||||
"); |
||||
|
||||
$params=array(OC_User::getUser(), urldecode($_GET["url"])); |
||||
$bookmarks = $query->execute($params); |
||||
|
||||
header( "HTTP/1.1 204 No Content" ); |
||||
|
@ -0,0 +1,66 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - bookmarks plugin |
||||
* |
||||
* @author Arthur Schiwon |
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
//no apps or filesystem |
||||
$RUNTIME_NOSETUPFS=true; |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
|
||||
// We send json data |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
|
||||
// Check if we are a user |
||||
if( !OC_User::isLoggedIn()){ |
||||
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); |
||||
exit(); |
||||
} |
||||
|
||||
$params=array(OC_User::getUser()); |
||||
|
||||
//Filter for tag? |
||||
$filterTag = isset($_GET["tag"]) ? urldecode($_GET["tag"]) : false; |
||||
if($filterTag){ |
||||
$sqlFilterTag = "HAVING INSTR (tags, ?) > 0"; |
||||
$params[] = $filterTag; |
||||
} else { |
||||
$sqlFilterTag = ''; |
||||
} |
||||
|
||||
$offset = isset($_GET["page"]) ? intval($_GET["page"]) * 10 : 0; |
||||
$params[] = $offset; |
||||
|
||||
//FIXME: bookmarks without tags are not being retrieved |
||||
$query = OC_DB::prepare(" |
||||
SELECT url, title, description, GROUP_CONCAT( tag SEPARATOR ' ' ) AS tags |
||||
FROM *PREFIX*bookmarks, *PREFIX*bookmarks_tags |
||||
WHERE *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id |
||||
AND *PREFIX*bookmarks.user_id = ? |
||||
GROUP BY url |
||||
$sqlFilterTag |
||||
ORDER BY *PREFIX*bookmarks.id DESC |
||||
LIMIT ?, 10"); |
||||
|
||||
|
||||
$bookmarks = $query->execute($params)->fetchAll(); |
||||
|
||||
echo json_encode( array( "status" => "success", "data" => $bookmarks)); |
@ -0,0 +1,27 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - bookmarks plugin |
||||
* |
||||
* @author Arthur Schiwon |
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' )); |
||||
|
||||
OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OC_Helper::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => 'Bookmarks' )); |
||||
|
@ -0,0 +1,127 @@ |
||||
<?xml version="1.0" encoding="ISO-8859-1" ?> |
||||
<database> |
||||
<name>*dbname*</name> |
||||
<create>true</create> |
||||
<overwrite>false</overwrite> |
||||
<charset>latin1</charset> |
||||
<table> |
||||
<name>*dbprefix*bookmarks</name> |
||||
<declaration> |
||||
<field> |
||||
<name>id</name> |
||||
<type>integer</type> |
||||
<autoincrement>1</autoincrement> |
||||
<default>0</default> |
||||
<notnull>true</notnull> |
||||
<length>64</length> |
||||
</field> |
||||
<field> |
||||
<name>url</name> |
||||
<type>text</type> |
||||
<default></default> |
||||
<notnull>true</notnull> |
||||
<length>4096</length> |
||||
</field> |
||||
<field> |
||||
<name>title</name> |
||||
<type>text</type> |
||||
<default></default> |
||||
<notnull>true</notnull> |
||||
<length>140</length> |
||||
</field> |
||||
<field> |
||||
<name>description</name> |
||||
<type>text</type> |
||||
<default></default> |
||||
<notnull>true</notnull> |
||||
<length>255</length> |
||||
</field> |
||||
<field> |
||||
<name>user_id</name> |
||||
<type>text</type> |
||||
<default></default> |
||||
<notnull>true</notnull> |
||||
<length>64</length> |
||||
</field> |
||||
<field> |
||||
<name>public</name> |
||||
<type>integer</type> |
||||
<default>0</default> |
||||
<length>1</length> |
||||
</field> |
||||
<field> |
||||
<name>added</name> |
||||
<type>integer</type> |
||||
<default></default> |
||||
<notnull>false</notnull> |
||||
<unsigned>true</unsigned> |
||||
<length>4</length> |
||||
</field> |
||||
<field> |
||||
<name>lastmodified</name> |
||||
<type>integer</type> |
||||
<default></default> |
||||
<notnull>false</notnull> |
||||
<unsigned>true</unsigned> |
||||
<length>4</length> |
||||
</field> |
||||
<field> |
||||
<name>clickcount</name> |
||||
<type>integer</type> |
||||
<default>0</default> |
||||
<notnull>true</notnull> |
||||
<unsigned>true</unsigned> |
||||
<length>4</length> |
||||
</field> |
||||
|
||||
<index> |
||||
<name>id</name> |
||||
<unique>true</unique> |
||||
<field> |
||||
<name>id</name> |
||||
<sorting>descending</sorting> |
||||
</field> |
||||
</index> |
||||
<!-- <index> |
||||
<name>url</name> |
||||
<unique>true</unique> |
||||
<field> |
||||
<name>url</name> |
||||
<sorting>ascending</sorting> |
||||
</field> |
||||
</index>--> |
||||
</declaration> |
||||
</table> |
||||
|
||||
<table> |
||||
<name>*dbprefix*bookmarks_tags</name> |
||||
<declaration> |
||||
<field> |
||||
<name>bookmark_id</name> |
||||
<type>integer</type> |
||||
<length>64</length> |
||||
</field> |
||||
|
||||
<field> |
||||
<name>tag</name> |
||||
<type>text</type> |
||||
<default></default> |
||||
<notnull>true</notnull> |
||||
<length>255</length> |
||||
</field> |
||||
<index> |
||||
<name>bookmark_tag</name> |
||||
<unique>true</unique> |
||||
<field> |
||||
<name>bookmark_id</name> |
||||
<sorting>ascending</sorting> |
||||
</field> |
||||
<field> |
||||
<name>tag</name> |
||||
<sorting>ascending</sorting> |
||||
</field> |
||||
</index> |
||||
</declaration> |
||||
</table> |
||||
</database> |
||||
|
@ -0,0 +1,10 @@ |
||||
<?xml version="1.0"?> |
||||
<info> |
||||
<id>bookmarks</id> |
||||
<name>Bookmarks</name> |
||||
<description>Bookmark manager for ownCloud</description> |
||||
<version>0.1</version> |
||||
<licence>AGPL</licence> |
||||
<author>Arthur Schiwon</author> |
||||
<require>2</require> |
||||
</info> |
@ -0,0 +1,63 @@ |
||||
#content { overflow: auto; } |
||||
|
||||
.bookmarks_headline { |
||||
font-size: large; |
||||
font-weight: bold; |
||||
margin-left: 2em; |
||||
padding: 2.5ex 0.5ex; |
||||
} |
||||
|
||||
.bookmarks_menu { |
||||
margin-left: 1.5em; |
||||
padding: 0.5ex; |
||||
} |
||||
|
||||
.bookmark_actions { |
||||
font-size: smaller; |
||||
color: #ff44ff; |
||||
padding-left: 4em; |
||||
} |
||||
|
||||
.bookmark_actions span:hover { |
||||
cursor: pointer; |
||||
text-decoration: underline; |
||||
} |
||||
|
||||
.bookmarks_add { |
||||
display: none; |
||||
} |
||||
|
||||
.bookmarks_label { |
||||
width: 7em; |
||||
display: inline-block; |
||||
text-align: right; |
||||
} |
||||
|
||||
.bookmarks_input { |
||||
width: 20em; |
||||
} |
||||
|
||||
.bookmark_single { |
||||
margin-left: 2em; |
||||
margin-top: 3ex; |
||||
padding: 0.5ex; |
||||
/* border-bottom: 1px solid black; */ |
||||
} |
||||
|
||||
.bookmark_single:hover { |
||||
background-color: #ccccff; |
||||
} |
||||
|
||||
.bookmark_title { |
||||
font-size: larger; |
||||
color: blue; |
||||
text-decoration: underline; |
||||
} |
||||
|
||||
.bookmark_url { |
||||
color: green; |
||||
} |
||||
|
||||
.bookmark_tags { |
||||
color: #ff3333; |
||||
} |
After Width: | Height: | Size: 496 B |
@ -0,0 +1,39 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - bookmarks plugin |
||||
* |
||||
* @author Arthur Schiwon |
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.de |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
require_once('../../lib/base.php'); |
||||
|
||||
// Check if we are a user |
||||
if( !OC_User::isLoggedIn()){ |
||||
header( "Location: ".OC_Helper::linkTo( '', 'index.php' )); |
||||
exit(); |
||||
} |
||||
|
||||
OC_App::setActiveNavigationEntry( 'bookmarks_index' ); |
||||
|
||||
OC_Util::addScript('bookmarks','bookmarks'); |
||||
OC_Util::addStyle('bookmarks', 'bookmarks'); |
||||
|
||||
$tmpl = new OC_Template( 'bookmarks', 'list', 'user' ); |
||||
|
||||
$tmpl->printPage(); |
@ -0,0 +1,94 @@ |
||||
var bookmarks_page = 0; |
||||
var bookmarks_loading = false; |
||||
|
||||
$(document).ready(function() { |
||||
$('.bookmarks_addBtn').click(function(event){ |
||||
$('.bookmarks_add').slideToggle(); |
||||
}); |
||||
|
||||
$('#bookmark_add_submit').click(addBookmark); |
||||
$(window).scroll(updateOnBottom); |
||||
|
||||
$('.bookmarks_list').empty(); |
||||
getBookmarks(); |
||||
}); |
||||
|
||||
function getBookmarks() { |
||||
if(bookmarks_loading) { |
||||
//have patience :)
|
||||
return; |
||||
} |
||||
$.ajax({ |
||||
url: 'ajax/updateList.php', |
||||
data: "tag=" + encodeURI($('#bookmarkFilterTag').val()) + "&page=" + bookmarks_page, |
||||
success: function(bookmarks){ |
||||
bookmarks_page += 1; |
||||
$('.bookmark_link').unbind('click', recordClick); |
||||
$('.bookmark_delete').unbind('click', delBookmark); |
||||
|
||||
for(var i in bookmarks.data) { |
||||
updateBookmarksList(bookmarks.data[i]); |
||||
} |
||||
$('.bookmark_link').click(recordClick); |
||||
$('.bookmark_delete').click(delBookmark); |
||||
bookmarks_loading = false; |
||||
} |
||||
});
|
||||
} |
||||
|
||||
function addBookmark(event) { |
||||
$.ajax({ |
||||
url: 'ajax/addBookmark.php', |
||||
data: "url=" + encodeURI($('#bookmark_add_url').val()) + "&title=" + encodeURI($('#bookmark_add_title').val()) + "&description=" + encodeURI($('#bookmark_add_description').val()) + "&tags=" + encodeURI($('#bookmark_add_tags').val()), |
||||
success: function(data){ $('.bookmarks_add').slideToggle(); $('.bookmarks_add').children('p').children('.bookmarks_input').val(''); } |
||||
}); |
||||
} |
||||
|
||||
function delBookmark(event) { |
||||
$.ajax({ |
||||
url: 'ajax/delBookmark.php', |
||||
data: "url=" + encodeURI($(this).parent().parent().children('.bookmark_url:first').text()), |
||||
success: function(data){ alert('deleted!'); } |
||||
}); |
||||
} |
||||
|
||||
function updateBookmarksList(bookmark) { |
||||
var tags = encodeEntities(bookmark.tags).split(" "); |
||||
var taglist = ""; |
||||
for ( var i=0, len=tags.length; i<len; ++i ){ |
||||
taglist = taglist + "<a class=\"bookmark_tags\" href=\"?tag=" + encodeURI(tags[i]) + "\">" + tags[i] + "</a> "; |
||||
} |
||||
$('.bookmarks_list').append( |
||||
"<div class=\"bookmark_single\">" + |
||||
"<p class=\"bookmark_title\"><a href=\"" + encodeEntities(bookmark.url) + "\" target=\"_new\" class=\"bookmark_link\">" + encodeEntities(bookmark.title) + "</a></p>" + |
||||
"<p class=\"bookmark_url\">" + encodeEntities(bookmark.url) + "</p>" + |
||||
"<p class=\"bookmark_description\">" + encodeEntities(bookmark.description) + "</p>" + |
||||
"<p>" + taglist + "</p>" + |
||||
"<p class=\"bookmark_actions\"><span class=\"bookmark_delete\">Delete</span></p>" + |
||||
"</div>" |
||||
); |
||||
} |
||||
|
||||
function updateOnBottom() { |
||||
//check wether user is on bottom of the page
|
||||
if ($('body').height() <= ($(window).height() + $(window).scrollTop())) { |
||||
getBookmarks(); |
||||
} |
||||
} |
||||
|
||||
function recordClick(event) { |
||||
$.ajax({ |
||||
url: 'ajax/recordClick.php', |
||||
data: "url=" + encodeURI($(this).attr('href')), |
||||
});
|
||||
return false; |
||||
} |
||||
|
||||
function encodeEntities(s){ |
||||
try { |
||||
return $("<div/>").text(s).html(); |
||||
|
||||
} catch (ex) { |
||||
return ""; |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
<input type="hidden" id="bookmarkFilterTag" value="<?php echo htmlentities($_GET['tag']); ?>" />
|
||||
<h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? 'Bookmarks with tag: ' . urldecode($_GET["tag"]) : 'All bookmarks'; ?></h2>
|
||||
<div class="bookmarks_menu"> |
||||
<input type="button" class="bookmarks_addBtn" value="Add Bookmark" /> |
||||
</div> |
||||
<div class="bookmarks_add"> |
||||
<p><label class="bookmarks_label">URL: </label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p> |
||||
<p><label class="bookmarks_label">Title: </label><input type="text" id="bookmark_add_title" class="bookmarks_input" /></p> |
||||
<p><label class="bookmarks_label">Description: </label><input type="text" id="bookmark_add_description" class="bookmarks_input" /></p> |
||||
<p><label class="bookmarks_label">Tags:</label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p> |
||||
<p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p> |
||||
</div> |
||||
<div class="bookmarks_list"> |
||||
<noscript> |
||||
JavaScript is needed to display your Bookmarks |
||||
</noscript> |
||||
You have no bookmarks |
||||
</div> |
@ -1 +1,2 @@ |
||||
.contacts_propertyname {float:left;} |
||||
.contacts_details_left {text-align:right;vertical-align:top;padding:2px;} |
||||
.contacts_details_right {text-align:left;vertical-align:top;padding:2px;} |
||||
|
@ -1,2 +0,0 @@ |
||||
#autogenerated |
||||
config.php |
@ -0,0 +1,45 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - ajax group list |
||||
* |
||||
* @author Hans Bakker |
||||
* @copyright 2011 hansmbakker+kde@gmail.com |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
|
||||
// We send json data |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
|
||||
$RUNTIME_NOAPPS = TRUE; //no apps, yet |
||||
require_once('../../lib/base.php'); |
||||
|
||||
if(isset($_GET["user"]) && isset($_GET["password"])) |
||||
{ |
||||
if(!OC_User::checkPassword($_GET["user"], $_GET["password"])) |
||||
exit(); |
||||
|
||||
$groups = array(); |
||||
|
||||
foreach( OC_Group::getGroups() as $i ){ |
||||
// Do some more work here soon |
||||
$groups[] = array( "groupname" => $i ); |
||||
} |
||||
|
||||
echo json_encode($groups); |
||||
} |
||||
?> |
@ -0,0 +1,47 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - ajax user list |
||||
* |
||||
* @author Hans Bakker |
||||
* @copyright 2011 hansmbakker+kde@gmail.com |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
|
||||
// We send json data |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
|
||||
$RUNTIME_NOAPPS = TRUE; //no apps, yet |
||||
require_once('../../lib/base.php'); |
||||
|
||||
if(isset($_GET["user"]) && isset($_GET["password"])) |
||||
{ |
||||
if(!OC_User::checkPassword($_GET["user"], $_GET["password"])) |
||||
exit(); |
||||
|
||||
$users = array(); |
||||
|
||||
foreach( OC_User::getUsers() as $i ){ |
||||
$users[] = array( "username" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) )); |
||||
} |
||||
|
||||
echo json_encode($users); |
||||
|
||||
|
||||
} |
||||
|
||||
?> |
@ -0,0 +1,111 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud |
||||
* |
||||
* @author Robin Appelman |
||||
* @copyright 2011 Robin Appelman icewind1991@gmail.com |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* Class for manipulating filesystem requests |
||||
* |
||||
* Manipulation happens by using 2 kind of proxy operations, pre and post proxies |
||||
* that manipulate the filesystem call and the result of the call respectively |
||||
* |
||||
* A pre-proxy recieves the filepath as arugments (or 2 filespaths in case of operations like copy or move) and return a boolean |
||||
* If a pre-proxy returnes false the file operation will be canceled |
||||
* All filesystem operations have a pre-proxy |
||||
* |
||||
* A post-proxy recieves 2 arguments, the filepath and the result of the operation. |
||||
* The return calue of the post-proxy will be used as the new result of the operation |
||||
* The operations that have a post-proxy are |
||||
* file_get_contents, is_file, is_dir, file_exists, stat, is_readable, is_writable, fileatime, filemtime, filectime, file_get_contents, getMimeType, hash, free_space and search |
||||
*/ |
||||
|
||||
class OC_FileProxy{ |
||||
private static $proxies=array(); |
||||
|
||||
/** |
||||
* check if this proxy implments a specific proxy operation |
||||
* @param string #proxy name of the proxy operation |
||||
* @return bool |
||||
*/ |
||||
public function provides($operation){ |
||||
return method_exists($this,$operation); |
||||
} |
||||
|
||||
/** |
||||
* fallback function when a proxy operation is not implement |
||||
* @param string $function the name of the proxy operation |
||||
* @param mixed |
||||
* |
||||
* this implements a dummy proxy for all operations |
||||
*/ |
||||
public function __call($function,$arguments){ |
||||
if(substr($function,0,3)=='pre'){ |
||||
return true; |
||||
}else{ |
||||
return $arguments[1]; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* register a proxy to be used |
||||
* @param OC_FileProxy $proxy |
||||
*/ |
||||
public static function register($proxy){ |
||||
self::$proxies[]=$proxy; |
||||
} |
||||
|
||||
public static function getProxies($operation,$post){ |
||||
$operation=(($post)?'post':'pre').$operation; |
||||
$proxies=array(); |
||||
foreach(self::$proxies as $proxy){ |
||||
if($proxy->provides($operation)){ |
||||
$proxies[]=$proxy; |
||||
} |
||||
} |
||||
return $proxies; |
||||
} |
||||
|
||||
public static function runPreProxies($operation,$filepath,$filepath2=null){ |
||||
$proxies=self::getProxies($operation,false); |
||||
$operation='pre'.$operation; |
||||
foreach($proxies as $proxy){ |
||||
if($filepath2){ |
||||
if(!$proxy->$operation($filepath,$filepath2)){ |
||||
return false; |
||||
} |
||||
}else{ |
||||
if(!$proxy->$operation($filepath)){ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public static function runPostProxies($operation,$path,$result){ |
||||
$proxies=self::getProxies($operation,true); |
||||
$operation='post'.$operation; |
||||
foreach($proxies as $proxy){ |
||||
$result=$proxy->$operation($path,$result); |
||||
} |
||||
return $result; |
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud |
||||
* |
||||
* @author Robin Appelman |
||||
* @copyright 2011 Robin Appelman icewind1991@gmail.com |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
/** |
||||
* user quota managment |
||||
*/ |
||||
|
||||
class OC_FileProxy_Quota extends OC_FileProxy{ |
||||
private function getFreeSpace(){ |
||||
$usedSpace=OC_Filesystem::filesize(''); |
||||
$totalSpace=OC_Preferences::getValue(OC_User::getUser(),'files','quota',0); |
||||
if($totalSpace==0){ |
||||
return 0; |
||||
} |
||||
return $totalSpace-$usedSpace; |
||||
} |
||||
|
||||
public function postFree_space($path,$space){ |
||||
$free=$this->getFreeSpace(); |
||||
if($free==0){ |
||||
return $space; |
||||
} |
||||
return min($free,$space); |
||||
} |
||||
|
||||
public function preFile_put_contents($path,$data){ |
||||
return (strlen($data)<$this->getFreeSpace() or $this->getFreeSpace()==0); |
||||
} |
||||
|
||||
public function preCopy($path1,$path2){ |
||||
return (OC_Filesystem::filesize($path1)<$this->getFreeSpace() or $this->getFreeSpace()==0); |
||||
} |
||||
|
||||
public function preFromTmpFile($tmpfile,$path){ |
||||
return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0); |
||||
} |
||||
|
||||
public function preFromUploadedFile($tmpfile,$path){ |
||||
return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0); |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
<?php |
||||
|
||||
// Init owncloud |
||||
require_once('../../lib/base.php'); |
||||
|
||||
// We send json data |
||||
header( "Content-Type: application/jsonrequest" ); |
||||
|
||||
// Check if we are a user |
||||
if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ |
||||
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); |
||||
exit(); |
||||
} |
||||
|
||||
$username = $_POST["username"]; |
||||
$quota= OC_Helper::computerFileSize($_POST["quota"]); |
||||
|
||||
// Return Success story |
||||
OC_Preferences::setValue($username,'files','quota',$quota); |
||||
echo json_encode( array( "status" => "success", "data" => array( "username" => $username ,'quota'=>$quota))); |
||||
|
||||
?> |
Loading…
Reference in new issue