Exemplo n.º 1
0
 public function testUserOtherExport()
 {
     $user = $this->generateUser();
     $user2 = $this->generateUser();
     \OC_User::setUserId($user2);
     $export = \OC_Migrate::export($user);
     // Check it succeeded and exists
     $this->assertTrue(json_decode($export)->success);
     // Validate the export
     $this->validateUserExport($user2, $user, json_decode($export)->data);
 }
Exemplo n.º 2
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/>.
 *
 */
OCP\User::checkAdminUser();
OCP\App::checkAppEnabled('admin_migrate');
// Export?
if (isset($_POST['admin_export'])) {
    // Create the export zip
    $response = json_decode(OC_Migrate::export(null, $_POST['export_type']));
    if (!$response->success) {
        // Error
        die('error');
    } else {
        $path = $response->data;
        // Download it
        header("Content-Type: application/zip");
        header("Content-Disposition: attachment; filename=" . basename($path));
        header("Content-Length: " . filesize($path));
        @ob_end_clean();
        readfile($path);
        unlink($path);
    }
    // Import?
} else {
Exemplo n.º 3
0
 *
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\App::checkAppEnabled('user_migrate');
// Which operation
if ($_GET['operation'] == 'create') {
    $uid = !empty($_POST['uid']) ? $_POST['uid'] : OCP\USER::getUser();
    if ($uid != OCP\USER::getUser()) {
        // Needs to be admin to export someone elses account
        OCP\JSON::error();
        die;
    }
    // Create the export zip
    $response = json_decode(OC_Migrate::export($uid));
    if (!$response->success) {
        // Error
        OCP\JSON::error();
        die;
    } else {
        // Save path in session
        $_SESSION['ocuserexportpath'] = $response->data;
    }
    OCP\JSON::success();
    die;
} else {
    if ($_GET['operation'] == 'download') {
        // Download the export
        $path = isset($_SESSION['ocuserexportpath']) ? $_SESSION['ocuserexportpath'] : false;
        if (!$path) {