/** * @param array $params * @throws \Exception */ public function __construct($params) { if (isset($params['host'])) { $host = $params['host']; $this->username_as_share = $params['username_as_share'] === 'true'; // dummy credentials, unused, to satisfy constructor $user = '******'; $password = '******'; if (\OC::$server->getSession()->exists('smb-credentials')) { $params_auth = json_decode(\OC::$server->getCrypto()->decrypt(\OC::$server->getSession()->get('smb-credentials')), true); $user = \OC::$server->getSession()->get('loginname'); $password = $params_auth['password']; } else { // assume we are testing from the admin section } $root = isset($params['root']) ? $params['root'] : '/'; $share = ''; if ($this->username_as_share) { $share = '/' . $user; } elseif (isset($params['share'])) { $share = $params['share']; } else { throw new \Exception(); } parent::__construct(array("user" => $user, "password" => $password, "host" => $host, "share" => $share, "root" => $root)); } else { throw new \Exception(); } }
/** * @param array $params * @throws \Exception */ public function __construct($params) { if (isset($params['host']) && \OC::$server->getSession()->exists('smb-credentials')) { $host = $params['host']; $this->username_as_share = $params['username_as_share'] === 'true'; $params_auth = json_decode(\OC::$server->getCrypto()->decrypt(\OC::$server->getSession()->get('smb-credentials')), true); $user = \OC::$server->getSession()->get('loginname'); $password = $params_auth['password']; $root = isset($params['root']) ? $params['root'] : '/'; $share = ''; if ($this->username_as_share) { $share = '/' . $user; } elseif (isset($params['share'])) { $share = $params['share']; } else { throw new \Exception(); } parent::__construct(array("user" => $user, "password" => $password, "host" => $host, "share" => $share, "root" => $root)); } else { throw new \Exception(); } }