Example #1
0
function handleGetGallery($token, $path)
{
    $owner = OC_Gallery_Sharing::getTokenOwner($token);
    $apath = OC_Gallery_Sharing::getPath($token);
    if ($path == false) {
        $root = $apath;
    } else {
        $root = rtrim($apath, '/') . $path;
    }
    $r = OC_Gallery_Album::find($owner, null, $root);
    $albums = array();
    $photos = array();
    $albumId = -1;
    if ($row = $r->fetchRow()) {
        $albumId = $row['album_id'];
    }
    if ($albumId != -1) {
        if (OC_Gallery_Sharing::isRecursive($token)) {
            $r = OC_Gallery_Album::find($owner, null, null, $root);
            while ($row = $r->fetchRow()) {
                $albums[] = $row['album_name'];
            }
        }
        $r = OC_Gallery_Photo::find($albumId);
        while ($row = $r->fetchRow()) {
            $photos[] = $row['file_path'];
        }
    }
    OCP\JSON::success(array('albums' => $albums, 'photos' => $photos));
}
Example #2
0
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$catmgr = OCA\Contacts\App::getVCategories();
$categories = $catmgr->categories(OC_VCategories::FORMAT_MAP);
foreach ($categories as &$category) {
    $ids = array();
    $contacts = $catmgr->itemsForCategory($category['name'], array('tablename' => '*PREFIX*contacts_cards', 'fields' => array('id')));
    foreach ($contacts as $contact) {
        $ids[] = $contact['id'];
    }
    $category['contacts'] = $ids;
}
$favorites = $catmgr->getFavorites();
OCP\JSON::success(array('data' => array('categories' => $categories, 'favorites' => $favorites, 'shared' => OCP\Share::getItemsSharedWith('addressbook', OCA\Contacts\Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS), 'lastgroup' => OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'groupsort', ''))));
{
    OCP\Util::writeLog('contacts', 'ajax/categories/delete.php: ' . $msg, OCP\Util::DEBUG);
}
$categories = isset($_POST['categories']) ? $_POST['categories'] : null;
if (is_null($categories)) {
    bailOut(OC_Contacts_App::$l10n->t('No categories selected for deletion.'));
}
debug(print_r($categories, true));
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
if (count($addressbooks) == 0) {
    bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
}
$addressbookids = array();
foreach ($addressbooks as $addressbook) {
    $addressbookids[] = $addressbook['id'];
}
$contacts = OC_Contacts_VCard::all($addressbookids);
if (count($contacts) == 0) {
    bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
}
$cards = array();
foreach ($contacts as $contact) {
    $cards[] = array($contact['id'], $contact['carddata']);
}
debug('Before delete: ' . print_r($categories, true));
$catman = new OC_VCategories('contacts');
$catman->delete($categories, $cards);
debug('After delete: ' . print_r($catman->categories(), true));
OC_Contacts_VCard::updateDataByID($cards);
OCP\JSON::success(array('data' => array('categories' => $catman->categories())));
Example #4
0
// Load the files
$dir = $data['realPath'];
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\JSON::error(array('success' => false));
    exit;
}
$data = array();
// make filelist
$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
$formattedFiles = array();
foreach ($files as $file) {
    $entry = \OCA\Files\Helper::formatFileInfo($file);
    unset($entry['directory']);
    // for now
    $entry['permissions'] = \OCP\PERMISSION_READ;
    $formattedFiles[] = $entry;
}
$data['directory'] = $relativePath;
$data['files'] = $formattedFiles;
$data['dirToken'] = $linkItem['token'];
$permissions = $linkItem['permissions'];
// if globally disabled
if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') {
    // only allow reading
    $permissions = \OCP\PERMISSION_READ;
}
$data['permissions'] = $permissions;
OCP\JSON::success(array('data' => $data));
 *
 * @author Thomas Tanghus
 * @copyright 2012 Thomas Tanghus <*****@*****.**>
 *
 * 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/>.
 *
 */
// Init owncloud
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$tmp_path = $_GET['tmp_path'];
$id = $_GET['id'];
OCP\Util::writeLog('contacts', 'ajax/cropphoto.php: tmp_path: ' . $tmp_path . ', exists: ' . file_exists($tmp_path), OCP\Util::DEBUG);
$tmpl = new OCP\Template("contacts", "part.cropphoto");
$tmpl->assign('tmp_path', $tmp_path);
$tmpl->assign('id', $id);
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array('page' => $page)));
Example #6
0
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$id = isset($_GET['id']) ? $_GET['id'] : null;
if (is_null($id)) {
    OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided'))));
    exit;
}
$vcard = OC_Contacts_App::getContactVCard($id);
foreach ($vcard->children as $property) {
    if ($property->name == 'CATEGORIES') {
        $checksum = md5($property->serialize());
        OCP\JSON::success(array('data' => array('value' => $property->value, 'checksum' => $checksum)));
        exit;
    }
}
OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
<?php

/**
 * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
OCP\JSON::callCheck();
$errarr = OC_Calendar_Object::validateRequest($_POST);
$event_id = -1;
if ($errarr) {
    //show validate errors
    OCP\JSON::error($errarr);
    exit;
} else {
    $cal = $_POST['calendar'];
    $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST);
    try {
        $event_id = OC_Calendar_Object::add($cal, $vcalendar->serialize());
    } catch (Exception $e) {
        OCP\JSON::error(array('message' => $e->getMessage()));
        exit;
    }
    OCP\JSON::success(array('event_id' => $event_id));
}
Example #8
0
        return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage));
    });
}
$rootInfo = \OC\Files\Filesystem::getFileInfo($path);
$rootView = new \OC\Files\View('');
/**
 * @param \OCP\Files\FileInfo $dir
 * @param \OC\Files\View $view
 * @return array
 */
function getChildInfo($dir, $view)
{
    $children = $view->getDirectoryContent($dir->getPath());
    $result = array();
    foreach ($children as $child) {
        $formated = \OCA\Files\Helper::formatFileInfo($child);
        if ($child->getType() === 'dir') {
            $formated['children'] = getChildInfo($child, $view);
        }
        $formated['mtime'] = $formated['mtime'] / 1000;
        $result[] = $formated;
    }
    return $result;
}
$result = \OCA\Files\Helper::formatFileInfo($rootInfo);
$result['mtime'] = $result['mtime'] / 1000;
if ($rootInfo->getType() === 'dir') {
    $result['children'] = getChildInfo($rootInfo, $rootView);
}
OCP\JSON::success(array('data' => $result));
/**
 * Copyright (c) 2012 Georg Ehrke <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
$data = $_POST['data'];
$data = explode(',', $data);
$data = end($data);
$data = base64_decode($data);
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$import = new OC_Calendar_Import($data);
$import->setUserID(OCP\User::getUser());
$import->setTimeZone(OC_Calendar_App::$tz);
$import->disableProgressCache();
if (!$import->isValid()) {
    OCP\JSON::error();
    exit;
}
$newcalendarname = strip_tags($import->createCalendarName());
$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(), $newcalendarname, 'VEVENT,VTODO,VJOURNAL', null, 0, $import->createCalendarColor());
$import->setCalendarID($newid);
$import->import();
$count = $import->getCount();
if ($count == 0) {
    OC_Calendar_Calendar::deleteCalendar($newid);
    OCP\JSON::error(array('message' => OC_Calendar_App::$l10n->t('The file contained either no events or all events are already saved in your calendar.')));
} else {
    OCP\JSON::success(array('message' => $count . ' ' . OC_Calendar_App::$l10n->t('events has been saved in the new calendar') . ' ' . $newcalendarname, 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo(OC_Calendar_Calendar::find($newid))));
}
Example #10
0
            $params = array('scope' => $scope, 'oauth_callback' => $callback);
            $request = OAuthRequest::from_consumer_and_token($consumer, null, 'GET', $url, $params);
            $request->sign_request($sigMethod, $consumer, null);
            $response = send_signed_request('GET', $url, array($request->to_header()), null, false);
            $token = array();
            parse_str($response, $token);
            if (isset($token['oauth_token']) && isset($token['oauth_token_secret'])) {
                $authUrl = 'https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=' . $token['oauth_token'];
                OCP\JSON::success(array('data' => array('url' => $authUrl, 'request_token' => $token['oauth_token'], 'request_token_secret' => $token['oauth_token_secret'])));
            } else {
                OCP\JSON::error(array('data' => array('message' => 'Fetching request tokens failed. Error: ' . $response)));
            }
            break;
        case 2:
            if (isset($_POST['oauth_verifier']) && isset($_POST['request_token']) && isset($_POST['request_token_secret'])) {
                $token = new OAuthToken($_POST['request_token'], $_POST['request_token_secret']);
                $url = 'https://www.google.com/accounts/OAuthGetAccessToken';
                $request = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $url, array('oauth_verifier' => $_POST['oauth_verifier']));
                $request->sign_request($sigMethod, $consumer, $token);
                $response = send_signed_request('GET', $url, array($request->to_header()), null, false);
                $token = array();
                parse_str($response, $token);
                if (isset($token['oauth_token']) && isset($token['oauth_token_secret'])) {
                    OCP\JSON::success(array('access_token' => $token['oauth_token'], 'access_token_secret' => $token['oauth_token_secret']));
                } else {
                    OCP\JSON::error(array('data' => array('message' => 'Fetching access tokens failed. Error: ' . $response)));
                }
            }
            break;
    }
}
Example #11
0
\OC::$server->getSession()->close();
// Get data
$dir = stripslashes($_POST["dir"]);
$allFiles = isset($_POST["allfiles"]) ? $_POST["allfiles"] : false;
// delete all files in dir ?
if ($allFiles === 'true') {
    $files = array();
    $fileList = \OC\Files\Filesystem::getDirectoryContent($dir);
    foreach ($fileList as $fileInfo) {
        $files[] = $fileInfo['name'];
    }
} else {
    $files = isset($_POST["file"]) ? $_POST["file"] : $_POST["files"];
    $files = json_decode($files);
}
$filesWithError = '';
$success = true;
//Now delete
foreach ($files as $file) {
    if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) && !\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
        $filesWithError .= $file . "\n";
        $success = false;
    }
}
// get array with updated storage stats (e.g. max file size) after upload
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
if ($success) {
    OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));
} else {
    OCP\JSON::error(array("data" => array_merge(array("message" => "Could not delete:\n" . $filesWithError), $storageStats)));
}
Example #12
0
/**
 * ownCloud - Addressbook
 *
 * @author Thomas Tanghus
 * @copyright 2012 Jakob Sack <*****@*****.**>
 *
 * 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/>.
 *
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('mail');
$account_id = isset($_GET['account_id']) ? $_GET['account_id'] : null;
$folder_id = isset($_GET['folder_id']) ? $_GET['folder_id'] : null;
$from = isset($_GET['from']) ? $_GET['from'] : null;
$count = isset($_GET['count']) ? $_GET['count'] : null;
$messages = OCA\Mail\App::getMessages(OCP\User::getUser(), $account_id, $folder_id, $from, $count);
OCP\JSON::success(array('data' => $messages));
Example #13
0
<?php

OCP\JSON::checkAppEnabled('files_versions');
OCP\JSON::callCheck();
$userDirectory = "/" . OCP\USER::getUser() . "/files";
$file = $_GET['file'];
$revision = (int) $_GET['revision'];
if (OCA_Versions\Storage::isversioned($file)) {
    if (OCA_Versions\Storage::rollback($file, $revision)) {
        OCP\JSON::success(array("data" => array("revision" => $revision, "file" => $file)));
    } else {
        OCP\JSON::error(array("data" => array("message" => "Could not revert:" . $file)));
    }
}
Example #14
0
<?php

$dir = '/';
if (isset($_GET['dir'])) {
    $dir = $_GET['dir'];
}
OCP\JSON::checkLoggedIn();
\OC::$server->getSession()->close();
// send back json
OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir)));
Example #15
0
 * 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/>.
 *
 */
// Init owncloud
// Check if we are a user
OCP\JSON::checkLoggedIn();
// Set the session key for the file we are about to edit.
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$filename = isset($_GET['file']) ? $_GET['file'] : '';
if (!empty($filename)) {
    $path = $dir . '/' . $filename;
    if (OC_Filesystem::is_writable($path)) {
        $mtime = OC_Filesystem::filemtime($path);
        $filecontents = OC_Filesystem::file_get_contents($path);
        $filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents);
        OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'true', 'mtime' => $mtime)));
    } else {
        $mtime = OC_Filesystem::filemtime($path);
        $filecontents = OC_Filesystem::file_get_contents($path);
        $filecontents = iconv(mb_detect_encoding($filecontents), "UTF-8", $filecontents);
        OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'false', 'mtime' => $mtime)));
    }
} else {
    OCP\JSON::error(array('data' => array('message' => 'Invalid file path supplied.')));
}
Example #16
0
<?php

// only need filesystem apps
$RUNTIME_APPTYPES = array('filesystem');
OCP\JSON::checkLoggedIn();
// send back json
OCP\JSON::success(array('data' => \OCA\files\lib\Helper::buildFileStorageStatistics('/')));
Example #17
0
/**
 * @author Arthur Schiwon <*****@*****.**>
 * @author Christopher Schäpers <*****@*****.**>
 * @author Lukas Reschke <*****@*****.**>
 * @author Morris Jobke <*****@*****.**>
 *
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
// Check user and app status
OCP\JSON::checkAdminUser();
OCP\JSON::checkAppEnabled('user_ldap');
OCP\JSON::callCheck();
$prefix = (string) $_POST['ldap_serverconfig_chooser'];
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
$connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, $prefix);
OCP\JSON::success(array('configuration' => $connection->getConfiguration()));
Example #18
0
<?php

// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
// Get the params
$dir = isset($_POST['dir']) ? stripslashes($_POST['dir']) : '';
$foldername = isset($_POST['foldername']) ? stripslashes($_POST['foldername']) : '';
if (trim($foldername) == '') {
    OCP\JSON::error(array("data" => array("message" => "Empty Foldername")));
    exit;
}
if (strpos($foldername, '/') !== false) {
    OCP\JSON::error(array("data" => array("message" => "Invalid Foldername")));
    exit;
}
if (OC_Files::newFile($dir, stripslashes($foldername), 'dir')) {
    OCP\JSON::success(array("data" => array()));
    exit;
}
OCP\JSON::error(array("data" => array("message" => "Error when creating the folder")));
<?php

OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::callCheck();
if ($_POST['isPersonal'] == 'true') {
    OCP\JSON::checkLoggedIn();
    $isPersonal = true;
} else {
    OCP\JSON::checkAdminUser();
    $isPersonal = false;
}
$mountPoint = (string) $_POST['mountPoint'];
$oldMountPoint = (string) $_POST['oldMountPoint'];
$class = (string) $_POST['class'];
$options = (string) $_POST['classOptions'];
$type = (string) $_POST['mountType'];
$applicable = (string) $_POST['applicable'];
if ($oldMountPoint and $oldMountPoint !== $mountPoint) {
    OC_Mount_Config::removeMountPoint($oldMountPoint, $type, $applicable, $isPersonal);
}
$status = OC_Mount_Config::addMountPoint($mountPoint, $class, $options, $type, $applicable, $isPersonal);
OCP\JSON::success(array('data' => array('message' => $status)));
Example #20
0
<?php

/**
 * @author Björn Schießle <*****@*****.**>
 * @author Lukas Reschke <*****@*****.**>
 * @author Morris Jobke <*****@*****.**>
 *
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
\OC::$server->getSession()->close();
$trashStatus = OCA\Files_Trashbin\Trashbin::isEmpty(OCP\User::getUser());
OCP\JSON::success(array("data" => array("isEmpty" => $trashStatus)));
 * 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/>.
 *
 */
// Check user and app status
OCP\JSON::checkAdminUser();
OCP\JSON::checkAppEnabled('user_ldap');
OCP\JSON::callCheck();
$l = OC_L10N::get('user_ldap');
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
$connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null);
//needs to be true, otherwise it will also fail with an irritating message
$_POST['ldap_configuration_active'] = 1;
if ($connection->setConfiguration($_POST)) {
    //Configuration is okay
    if ($connection->bind()) {
        OCP\JSON::success(array('message' => $l->t('The configuration is valid and the connection could be established!')));
    } else {
        OCP\JSON::error(array('message' => $l->t('The configuration is valid, but the Bind failed. Please check the server settings and credentials.')));
    }
} else {
    OCP\JSON::error(array('message' => $l->t('The configuration is invalid. Please have a look at the logs for further details.')));
}
Example #22
0
 * @author Bart Visscher <*****@*****.**>
 * @author Lukas Reschke <*****@*****.**>
 * @author Robin Appelman <*****@*****.**>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OC_Util::checkAdminUser();
OCP\JSON::callCheck();
$app = (string) $_GET['app'];
$app = OC_App::cleanAppId($app);
$navigation = OC_App::getAppNavigationEntries($app);
$navIds = array();
foreach ($navigation as $nav) {
    $navIds[] = $nav['id'];
}
OCP\JSON::success(array('nav_ids' => array_values($navIds), 'nav_entries' => $navigation));
Example #23
0
    $path = $dir . '/' . $file;
    if ($dir === '/') {
        $file = ltrim($file, '/');
        $delimiter = strrpos($file, '.d');
        $filename = substr($file, 0, $delimiter);
        $timestamp = substr($file, $delimiter + 2);
    } else {
        $path_parts = pathinfo($file);
        $filename = $path_parts['basename'];
        $timestamp = null;
    }
    if (!OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp)) {
        $error[] = $filename;
        \OCP\Util::writeLog('trashbin', 'can\'t restore ' . $filename, \OCP\Util::ERROR);
    } else {
        $success[$i]['filename'] = $file;
        $success[$i]['timestamp'] = $timestamp;
        $i++;
    }
}
if ($error) {
    $filelist = '';
    foreach ($error as $e) {
        $filelist .= $e . ', ';
    }
    $l = OC::$server->getL10N('files_trashbin');
    $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', ')));
    OCP\JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error)));
} else {
    OCP\JSON::success(array("data" => array("success" => $success)));
}
Example #24
0
<?php

// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::success(array('data' => OCP\Config::getUserValue(OCP\User::getUser(), 'tattoo', 'wallpaper', 'none')));
                $parentname = dirname($curdir);
                $dirs[$curdir] = $selectdir;
                $selectdir = $curdir;
            }
            if ($safeguard === 0) {
                //some funny directory loop
                OCP\JSON::error(array('data' => array('message' => 'An error occured while exploring the path: ' . $_POST['path'])));
            } else {
                foreach ($dirs as $dir => $subdir) {
                    if (strpos($dir, $localroot) !== 0) {
                        unset($dirs[$dir]);
                    }
                }
                OCP\JSON::success(array('data' => $dirs));
            }
        } else {
            //normal directory listing, return an array
            //where key is a sibdir name and value is it's full path
            $dirs = array();
            foreach (glob($path . '/*', GLOB_ONLYDIR) as $subdir) {
                $dirs[basename($subdir)] = $subdir;
            }
            OCP\JSON::success(array('data' => $dirs));
        }
    } else {
        OCP\JSON::success(array('message' => 'outside of starting dir'));
    }
} else {
    //no path provided
    OCP\JSON::error(array('data' => array('message' => 'Please provide the path for directory listing')));
}
Example #26
0
                $GA_VALID_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
                $UserTokenSeed = generateRandomString(8, 64, 8, $GA_VALID_CHAR);
                //}
            } else {
                $UserTokenSeed = $_POST["UserTokenSeed"];
            }
            //$UserTokenSeed="234567234567AZAZ";
            //$UserTokenSeed="Hello!";
            //~ if (OCP\Config::getAppValue('user_otp','TokenBase32Encode',true)){
            //~ $UserTokenSeed=bin2hex(base32_decode($UserTokenSeed));
            //~ }//else{
            //$UserTokenSeed=bin2hex($UserTokenSeed);
            $UserTokenSeed = bin2hex(base32_decode($UserTokenSeed));
            //$UserTokenSeed=bin2hex(base32_decode($UserTokenSeed));
            //echo $UserTokenSeed." / ".base32_encode($UserTokenSeed);exit;
            //echo $UserTokenSeed." / ".hex2bin($UserTokenSeed);exit;
            //}
            //echo "toto";
            $result = $mOtp->CreateUser($uid, OCP\Config::getAppValue('user_otp', 'UserPrefixPin', '0') ? 1 : 0, OCP\Config::getAppValue('user_otp', 'UserAlgorithm', 'TOTP'), $UserTokenSeed, $_POST["UserPin"], OCP\Config::getAppValue('user_otp', 'UserTokenNumberOfDigits', '6'), OCP\Config::getAppValue('user_otp', 'UserTokenTimeIntervalOrLastEvent', '30'));
            //var_dump($result);
            //exit;
            if ($result) {
                OCP\JSON::success(array("data" => array("message" => $l->t("OTP Changed"))));
            } else {
                OCP\JSON::error(array("data" => array("message" => $l->t("check apps folder rights"))));
            }
        } else {
            OCP\JSON::error(array("data" => array("message" => $l->t("Invalid request"))));
        }
    }
}
Example #27
0
     $mailNotification = new OC\Share\MailNotifications();
     $result = $mailNotification->sendInternalShareMail($recipientList, $itemSource, $itemType);
     \OCP\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, true);
     if (empty($result)) {
         OCP\JSON::success();
     } else {
         OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't send mail to following users: %s ", implode(', ', $result)))));
     }
     break;
 case 'informRecipientsDisabled':
     $itemSource = (string) $_POST['itemSource'];
     $shareType = (int) $_POST['shareType'];
     $itemType = (string) $_POST['itemType'];
     $recipient = (string) $_POST['recipient'];
     \OCP\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, false);
     OCP\JSON::success();
     break;
 case 'email':
     // read post variables
     $link = (string) $_POST['link'];
     $file = (string) $_POST['file'];
     $to_address = (string) $_POST['toaddress'];
     $mailNotification = new \OC\Share\MailNotifications();
     $expiration = null;
     if (isset($_POST['expiration']) && $_POST['expiration'] !== '') {
         try {
             $date = new DateTime((string) $_POST['expiration']);
             $expiration = $date->getTimestamp();
         } catch (Exception $e) {
             \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
         }
Example #28
0
                }
            }
        } else {
            if ($param === 'removeHeaderNav') {
                OCP\Config::setAppValue('roundcube', 'removeHeaderNav', false);
            }
            if ($param === 'removeControlNav') {
                OCP\Config::setAppValue('roundcube', 'removeControlNav', false);
            }
            if ($param === 'autoLogin') {
                OCP\Config::setAppValue('roundcube', 'autoLogin', false);
            }
            if ($param === 'enableDebug') {
                OCP\Config::setAppValue('roundcube', 'enableDebug', false);
            }
            if ($param === 'rcNoCronRefresh') {
                OCP\Config::setAppValue('roundcube', 'rcNoCronRefresh', false);
            }
        }
    }
    // update login status
    $username = OCP\User::getUser();
    $params = array("uid" => $username);
    $loginHelper = new OC_RoundCube_AuthHelper();
    $loginHelper->login($params);
} else {
    OC_JSON::error(array("data" => array("message" => $l->t("Not submitted for us."))));
    return false;
}
OCP\JSON::success(array('data' => array('message' => $l->t('Application settings successfully stored.'))));
return true;
Example #29
0
OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('files_external');
if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST['redirect'])) {
    $client = new Google_Client();
    $client->setClientId($_POST['client_id']);
    $client->setClientSecret($_POST['client_secret']);
    $client->setRedirectUri($_POST['redirect']);
    $client->setScopes(array('https://www.googleapis.com/auth/drive'));
    if (isset($_POST['step'])) {
        $step = $_POST['step'];
        if ($step == 1) {
            try {
                $authUrl = $client->createAuthUrl();
                OCP\JSON::success(array('data' => array('url' => $authUrl)));
            } catch (Exception $exception) {
                OCP\JSON::error(array('data' => array('message' => $l->t('Step 1 failed. Exception: %s', array($exception->getMessage())))));
            }
        } else {
            if ($step == 2 && isset($_POST['code'])) {
                try {
                    $token = $client->authenticate($_POST['code']);
                    OCP\JSON::success(array('data' => array('token' => $token)));
                } catch (Exception $exception) {
                    OCP\JSON::error(array('data' => array('message' => $l->t('Step 2 failed. Exception: %s', array($exception->getMessage())))));
                }
            }
        }
    }
}
Example #30
0
    $result['data'] = array('message' => (string) $l10n->t('The target folder has been moved or deleted.'), 'code' => 'targetnotfound');
    OCP\JSON::error($result);
    exit;
}
$target = $dir . '/' . $fileName;
if (\OC\Files\Filesystem::file_exists($target)) {
    $result['data'] = array('message' => (string) $l10n->t('The name %s is already used in the folder %s. Please choose a different name.', array($fileName, $dir)));
    OCP\JSON::error($result);
    exit;
}
$success = false;
$templateManager = OC_Helper::getFileTemplateManager();
$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target);
$content = $templateManager->getTemplate($mimeType);
try {
    if ($content) {
        $success = \OC\Files\Filesystem::file_put_contents($target, $content);
    } else {
        $success = \OC\Files\Filesystem::touch($target);
    }
} catch (\Exception $e) {
    $result = ['success' => false, 'data' => ['message' => $e->getMessage()]];
    OCP\JSON::error($result);
    exit;
}
if ($success) {
    $meta = \OC\Files\Filesystem::getFileInfo($target);
    OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta)));
    return;
}
OCP\JSON::error(array('data' => array('message' => $l10n->t('Error when creating the file'))));