Beispiel #1
0
<?php

/*
 * Copyright 2014 by Francesco PIRANEO G. (fpiraneo@gmail.com)
 * 
 * This file is part of oclife.
 * 
 * oclife is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * oclife 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with oclife.  If not, see <http://www.gnu.org/licenses/>.
 */
\OCP\JSON::callCheck();
\OCP\JSON::checkAppEnabled('oclife');
\OCP\JSON::checkLoggedIn();
$tagID = filter_input(INPUT_POST, 'movedTag', FILTER_SANITIZE_NUMBER_INT);
$parentID = filter_input(INPUT_POST, 'droppedTo', FILTER_SANITIZE_NUMBER_INT);
if ($tagID === FALSE || $parentID === FALSE) {
    die('KO');
}
$ctags = new \OCA\OCLife\hTags();
$ctags->setTagParentByID($tagID, $parentID);
echo 'OK';
Beispiel #2
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * oclife 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with oclife.  If not, see <http://www.gnu.org/licenses/>.
 */
\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('oclife');
$ctags = new \OCA\OCLife\hTags();
$tagData = $ctags->getAllTags('xx');
$searchKey = filter_input(INPUT_GET, 'term', FILTER_SANITIZE_STRING);
$result = array();
foreach ($tagData as $tag) {
    if ($tag['tagid'] !== '-1') {
        if (is_null($searchKey) || $searchKey === FALSE || $searchKey === '') {
            $result[] = new \OCA\OCLife\tag($tag['tagid'], $tag['descr']);
        } else {
            if (strpos($tag['descr'], $searchKey) !== FALSE) {
                $result[] = new \OCA\OCLife\tag($tag['tagid'], $tag['descr']);
            }
        }
    }
}
$jsonTagData = json_encode((array) $result);
$priviledge = filter_input(INPUT_POST, 'setPriviledge', FILTER_SANITIZE_STRING);
$tagOwnerToSet = filter_input(INPUT_POST, 'tagOwner', FILTER_SANITIZE_STRING);
// At least tagID and the priviledge or the owner has to be set to perform a valid operation
if (!isset($tagID) || !isset($priviledge) && !isset($tagOwnerToSet)) {
    $result = json_encode(array('result' => 'KO'));
    die($result);
}
// If we have to perform an owner change and we're not admin then forfait
// NOTE: Disabling the owner menu from javascript is fine but we need a function
// to check if logged user is an admin
if (isset($tagOwnerToSet) && !OC_User::isAdminUser(OC_User::getUser())) {
    $result = json_encode(array('result' => 'NOTALLOWED', 'newpriviledges' => '', 'newowner' => ''));
    die($result);
}
// Perform the requested operation
$ctags = new \OCA\OCLife\hTags();
$user = \OCP\User::getUser();
$tagOwner = $ctags->getTagOwner($tagID);
if ($ctags->writeAllowed($tagID, $user) || $user === $tagOwner) {
    if (isset($priviledge)) {
        // Set priviledges
        $newPriviledges = $ctags->setTagPermission($tagID, $priviledge);
        $newOwner = '';
    } else {
        // Set owner
        $newOwner = $ctags->setTagOwner($tagID, $tagOwnerToSet);
        $newPriviledges = '';
    }
    $result = json_encode(array('result' => 'OK', 'newpriviledges' => $newPriviledges, 'newowner' => $newOwner));
} else {
    $result = json_encode(array('result' => 'NOTALLOWED', 'newpriviledges' => '', 'newowner' => ''));
Beispiel #4
0
$tagID = filter_input(INPUT_POST, 'tagID', FILTER_SANITIZE_NUMBER_INT);
$tagName = filter_input(INPUT_POST, 'tagName', FILTER_SANITIZE_STRING);
$tagLang = filter_input(INPUT_POST, 'tagLang', FILTER_SANITIZE_STRING);
if ($parentID === FALSE || $tagName === FALSE || strlen($tagLang) === 0 || strlen($tagLang) > 2) {
    $result = array('result' => 'KO', 'title' => '', 'key' => '');
    die(json_encode($result));
}
// For write operations check if tag can be written
if ($tagOp == 'rename' || $tagOp == 'delete') {
    if (!\OCA\OCLife\hTags::writeAllowed($tagID)) {
        $result = array('result' => 'NOTALLOWED', 'title' => '', 'key' => $tagID);
        die(json_encode($result));
    }
}
// Tag handler instance
$ctags = new \OCA\OCLife\hTags();
// Switch between possible operations
switch ($tagOp) {
    case 'new':
        $tagID = $ctags->newTag($tagLang, $tagName, $parentID);
        $permission = $ctags->getTagPermission($tagID);
        $result = TRUE;
        break;
    case 'rename':
        $tagData = array($tagLang => $tagName);
        $result = $ctags->alterTag($tagID, $tagData);
        $permission = $ctags->getTagPermission($tagID);
        break;
    case 'delete':
        $result = $ctags->deleteTagAndChilds(intval($tagID));
        $permission = '';
Beispiel #5
0
 * oclife is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * oclife 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with oclife.  If not, see <http://www.gnu.org/licenses/>.
 */
\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('oclife');
$rawFilesData = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_URL);
$filesData = json_decode($rawFilesData);
if (is_array($filesData)) {
    $tagCodes = \OCA\OCLife\hTags::getCommonTagsForFiles($filesData);
} else {
    $tagCodes = \OCA\OCLife\hTags::getAllTagsForFile($filesData);
}
$tags = new \OCA\OCLife\hTags();
$result = array();
foreach ($tagCodes as $tagID) {
    $tagData = $tags->searchTagFromID($tagID);
    $result[] = new \OCA\OCLife\tag($tagID, $tagData['xx']);
}
$jsonTagData = json_encode((array) $result);
echo $jsonTagData;
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * oclife 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with oclife.  If not, see <http://www.gnu.org/licenses/>.
 */
\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('oclife');
$ctags = new \OCA\OCLife\hTags();
$JSONtags = filter_input(INPUT_POST, 'tags', FILTER_SANITIZE_URL);
// Look for selected tag and child
$tags = json_decode($JSONtags);
$tagsToSearch = array();
foreach ($tags as $tag) {
    $tagID = intval($tag->key);
    $partTags = $ctags->getAllChildID($tagID);
    foreach ($partTags as $tag) {
        $tagsToSearch[] = intval($tag);
    }
}
// Look for files with that tag
$filesIDs = \OCA\OCLife\hTags::getFileWithTagArray($tagsToSearch);
$fileData = \OCA\OCLife\utilities::getFileInfoFromID(OCP\User::getUser(), $filesIDs);
$result = '';
Beispiel #7
0
<?php

/*
 * Copyright 2014 by Francesco PIRANEO G. (fpiraneo@gmail.com)
 * 
 * This file is part of oclife.
 * 
 * oclife is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * oclife 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with oclife.  If not, see <http://www.gnu.org/licenses/>.
 */
\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('oclife');
$ctags = new \OCA\OCLife\hTags();
$tagData = $ctags->getTagTree('xx');
$jsonTagData = json_encode($tagData);
echo $jsonTagData;