Exemple #1
0
 * 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');
$op = filter_input(INPUT_POST, 'op', FILTER_SANITIZE_STRING);
$rawFileID = filter_input(INPUT_POST, 'fileID', FILTER_SANITIZE_URL);
$tagID = filter_input(INPUT_POST, 'tagID', FILTER_SANITIZE_NUMBER_INT);
$fileIDs = json_decode($rawFileID);
switch ($op) {
    case 'add':
        if (is_array($fileIDs)) {
            $result = \OCA\OCLife\hTags::addTagForFiles($fileIDs, $tagID);
        } else {
            $result = \OCA\OCLife\hTags::addTagForFile($fileIDs, $tagID);
        }
        break;
    case 'remove':
        if (is_array($fileIDs)) {
            $result = \OCA\OCLife\hTags::removeTagForFiles($fileIDs, $tagID);
        } else {
            $result = \OCA\OCLife\hTags::removeTagForFile($fileIDs, $tagID);
        }
        break;
}
die($result);