aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xapp/Controllers/feedController.php20
-rw-r--r--app/Models/CategoryDAO.php3
-rw-r--r--data/users/_/config.default.php1
-rw-r--r--p/api/greader.php47
4 files changed, 55 insertions, 16 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index faf670e6e..ca7a818c6 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -473,17 +473,25 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
return $feedDAO->updateFeed($feed_id, array('name' => $feed_name));
}
- public static function moveFeed($feed_id, $cat_id) {
+ public static function moveFeed($feed_id, $cat_id, $new_cat_name = '') {
if ($feed_id <= 0) {
return false;
}
- if ($cat_id <= 0) {
- // If category was not given get the default one.
- $catDAO = new FreshRSS_CategoryDAO();
+
+ $catDAO = new FreshRSS_CategoryDAO();
+ if ($cat_id > 0) {
+ $cat = $catDAO->searchById($cat_id);
+ $cat_id = $cat == null ? 0 : $cat->id();
+ }
+ if ($cat_id <= 1 && $new_cat_name != '') {
+ $cat_id = $catDAO->addCategory(array('name' => $new_cat_name));
+ }
+ if ($cat_id <= 1) {
$catDAO->checkDefault();
- $def_cat = $catDAO->getDefault();
- $cat_id = $def_cat->id();
+ $cat = $catDAO->getDefault();
+ $cat_id = $cat->id();
}
+
$feedDAO = FreshRSS_Factory::createFeedDao();
return $feedDAO->updateFeed($feed_id, array('category' => $cat_id));
}
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index fc431553e..c103163a1 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -50,6 +50,9 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
}
public function deleteCategory($id) {
+ if ($id <= 1) {
+ return false;
+ }
$sql = 'DELETE FROM `' . $this->prefix . 'category` WHERE id=?';
$stm = $this->bd->prepare($sql);
diff --git a/data/users/_/config.default.php b/data/users/_/config.default.php
index 2c56d5f45..6e1d497bc 100644
--- a/data/users/_/config.default.php
+++ b/data/users/_/config.default.php
@@ -5,6 +5,7 @@ return array (
'old_entries' => 3,
'keep_history_default' => 0,
'ttl_default' => 3600,
+ 'mail_login' => '',
'token' => '',
'passwordHash' => '',
'apiPasswordHash' => '',
diff --git a/p/api/greader.php b/p/api/greader.php
index e2d7dc039..8b1e0ffb1 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -222,6 +222,17 @@ function checkToken($conf, $token) {
unauthorized();
}
+function userInfo() { //https://github.com/theoldreader/api#user-info
+ //logMe("userInfo()");
+ $user = Minz_Session::param('currentUser', '_');
+ exit(json_encode(array(
+ 'userId' => $user,
+ 'userName' => $user,
+ 'userProfileId' => $user,
+ 'userEmail' => FreshRSS_Context::$user_conf->mail_login,
+ )));
+}
+
function tagList() {
//logMe("tagList()");
header('Content-Type: application/json; charset=UTF-8');
@@ -299,14 +310,24 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = '
$categoryDAO = new FreshRSS_CategoryDAO();
}
$c_name = '';
- if ($add != '' && strpos($add, 'user/-/label/') === 0) { //user/-/label/Example
- $c_name = substr($add, 13);
+ if ($add != '' && strpos($add, 'user/') === 0) { //user/-/label/Example ; user/username/label/Example
+ if (strpos($add, 'user/-/label/') === 0) {
+ $c_name = substr($add, 13);
+ } else {
+ $user = Minz_Session::param('currentUser', '_');
+ $prefix = 'user/' . $user . '/label/';
+ if (strpos($add, $prefix) === 0) {
+ $c_name = substr($add, strlen($prefix));
+ } else {
+ $c_name = '';
+ }
+ }
$cat = $categoryDAO->searchByName($c_name);
$addCatId = $cat == null ? -1 : $cat->id();
} else if ($remove != '' && strpos($remove, 'user/-/label/')) {
$addCatId = 1; //Default category
}
- if ($addCatId <= 0 && $c_name = '') {
+ if ($addCatId <= 0 && $c_name == '') {
$addCatId = 1; //Default category
}
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -345,9 +366,7 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = '
break;
case 'edit':
if ($feedId > 0) {
- if ($addCatId > 0) {
- FreshRSS_feed_Controller::moveFeed($feedId, $addCatId);
- }
+ FreshRSS_feed_Controller::moveFeed($feedId, $addCatId, $c_name);
if ($title != '') {
FreshRSS_feed_Controller::renameFeed($feedId, $title);
}
@@ -633,8 +652,8 @@ function renameTag($s, $dest) {
badRequest();
}
-function disableTag($s, $dest) {
- //logMe("renameTag()");
+function disableTag($s) {
+ //logMe("disableTag($s)");
if ($s != '' && strpos($s, 'user/-/label/') === 0) {
$s = substr($s, 13);
$categoryDAO = new FreshRSS_CategoryDAO();
@@ -642,6 +661,9 @@ function disableTag($s, $dest) {
if ($cat != null) {
$feedDAO = FreshRSS_Factory::createFeedDao();
$feedDAO->changeCategory($cat->id(), 0);
+ if ($cat->id() > 1) {
+ $categoryDAO->deleteCategory($cat->id());
+ }
exit('OK');
}
}
@@ -798,8 +820,10 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
case 'disable-tag': //https://github.com/theoldreader/api
$token = isset($_POST['T']) ? trim($_POST['T']) : '';
checkToken(FreshRSS_Context::$user_conf, $token);
- $s = isset($_POST['s']) ? $_POST['s'] : ''; //user/-/label/Folder
- disableTag($s);
+ $s_s = multiplePosts('s');
+ foreach ($s_s as $s) {
+ disableTag($s); //user/-/label/Folder
+ }
break;
case 'mark-all-as-read':
$token = isset($_POST['T']) ? trim($_POST['T']) : '';
@@ -814,6 +838,9 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
case 'token':
token(FreshRSS_Context::$user_conf);
break;
+ case 'user-info':
+ userInfo();
+ break;
}
} elseif ($pathInfos[1] === 'check' && $pathInfos[2] === 'compatibility') {
checkCompatibility();