Added \RainLoop\Api::ClearUserData() function

This commit is contained in:
RainLoop Team 2014-08-14 00:40:56 +04:00
parent 290cf38b97
commit 9a30680748
11 changed files with 363 additions and 279 deletions

View file

@ -2,7 +2,7 @@
"name": "RainLoop", "name": "RainLoop",
"title": "RainLoop Webmail", "title": "RainLoop Webmail",
"version": "1.6.8", "version": "1.6.8",
"release": "154", "release": "155",
"description": "Simple, modern & fast web-based email client", "description": "Simple, modern & fast web-based email client",
"homepage": "http://rainloop.net", "homepage": "http://rainloop.net",
"main": "gulpfile.js", "main": "gulpfile.js",
@ -36,7 +36,7 @@
"plugins" "plugins"
], ],
"readmeFilename": "README.md", "readmeFilename": "README.md",
"ownCloudPackageVersion": "2.0", "ownCloudPackageVersion": "2.1",
"engines": { "engines": {
"node": ">= 0.10.0" "node": ">= 0.10.0"
}, },

View file

@ -30,7 +30,7 @@ class Api
*/ */
public static function Config() public static function Config()
{ {
return self::Actions()->Config(); return \RainLoop\Api::Actions()->Config();
} }
/** /**
@ -38,7 +38,7 @@ class Api
*/ */
public static function Logger() public static function Logger()
{ {
return self::Actions()->Logger(); return \RainLoop\Api::Actions()->Logger();
} }
/** /**
@ -108,7 +108,7 @@ class Api
{ {
$sSsoHash = \sha1(\rand(10000, 99999).$sEmail.$sPassword.\microtime(true)); $sSsoHash = \sha1(\rand(10000, 99999).$sEmail.$sPassword.\microtime(true));
return self::Actions()->Cacher()->Set(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash), \RainLoop\Utils::EncodeKeyValues(array( return \RainLoop\Api::Actions()->Cacher()->Set(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash), \RainLoop\Utils::EncodeKeyValues(array(
'Email' => $sEmail, 'Email' => $sEmail,
'Password' => $sPassword, 'Password' => $sPassword,
'Time' => $bUseTimeout ? \time() : 0 'Time' => $bUseTimeout ? \time() : 0
@ -122,23 +122,51 @@ class Api
*/ */
public static function ClearUserSsoHash($sSsoHash) public static function ClearUserSsoHash($sSsoHash)
{ {
return self::Actions()->Cacher()->Delete(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash)); return \RainLoop\Api::Actions()->Cacher()->Delete(\RainLoop\KeyPathHelper::SsoCacherKey($sSsoHash));
} }
/** /**
* @todo
* @param string $sEmail * @param string $sEmail
* *
* @return bool * @return bool
*/ */
public static function ClearUserDateStorage($sEmail) public static function ClearUserData($sEmail)
{ {
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail); if (0 < \strlen($sEmail))
{
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
// TwoFactor Auth User Data $oStorageProvider = \RainLoop\Api::Actions()->StorageProvider();
self::Actions()->StorageProvider()->Clear(null,
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, if ($oStorageProvider)
\RainLoop\KeyPathHelper::TwoFactorAuthUserData($sEmail) {
); // TwoFactor Auth User Data
$oStorageProvider->Clear(null,
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
\RainLoop\KeyPathHelper::TwoFactorAuthUserData($sEmail)
);
// Accounts list
$oStorageProvider->Clear(null,
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
\RainLoop\KeyPathHelper::WebmailAccounts($sEmail)
);
// Contact sync data
$oStorageProvider->Clear($sEmail,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'contacts_sync'
);
}
\RainLoop\Api::Actions()->SettingsProvider()->ClearByEmail($sEmail);
\RainLoop\Api::Actions()->AddressBookProvider()->DeleteAllContactsAndTags($sEmail);
return true;
}
return false;
} }
} }

View file

@ -108,6 +108,16 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider
return $this->IsActive() ? $this->oDriver->DeleteContacts($sEmail, $aContactIds) : false; return $this->IsActive() ? $this->oDriver->DeleteContacts($sEmail, $aContactIds) : false;
} }
/**
* @param string $sEmail
*
* @return bool
*/
public function DeleteAllContactsAndTags($sEmail)
{
return $this->IsActive() ? $this->oDriver->DeleteAllContactsAndTags($sEmail) : false;
}
/** /**
* @param string $sEmail * @param string $sEmail
* @param int $iOffset = 0 * @param int $iOffset = 0

View file

@ -671,6 +671,30 @@ class PdoAddressBook
return true; return true;
} }
/**
* @param string $sEmail
* @param bool $bSyncDb = true
*
* @return bool
*/
public function DeleteAllContactsAndTags($sEmail, $bSyncDb = true)
{
if ($bSyncDb)
{
$this->SyncDatabase();
}
$iUserID = $this->getUserId($sEmail);
$aParams = array(':id_user' => array($iUserID, \PDO::PARAM_INT));
$this->prepareAndExecute('DELETE FROM rainloop_ab_properties WHERE id_user = :id_user', $aParams);
$this->prepareAndExecute('DELETE FROM rainloop_ab_contacts WHERE id_user = :id_user', $aParams);
$this->prepareAndExecute('DELETE FROM rainloop_ab_tags WHERE id_user = :id_user', $aParams);
return true;
}
/** /**
* @param string $sEmail * @param string $sEmail
* @param array $aTagsIds * @param array $aTagsIds

View file

@ -42,6 +42,16 @@ class Settings extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Save($oAccount, $oSettings->DataAsArray()); return $this->oDriver->Save($oAccount, $oSettings->DataAsArray());
} }
/**
* @param string $sEmail
*
* @return bool
*/
public function ClearByEmail($sEmail)
{
return $this->oDriver->ClearByEmail($sEmail);
}
/** /**
* @return bool * @return bool
*/ */

View file

@ -56,4 +56,16 @@ class DefaultSettings implements \RainLoop\Providers\Settings\SettingsInterface
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME, \RainLoop\Providers\Settings\DefaultSettings::FILE_NAME,
\json_encode($aSettings)); \json_encode($aSettings));
} }
/**
* @param string $sEmail
*
* @return bool
*/
public function ClearByEmail($sEmail)
{
return $this->oStorageProvider->Clear($sEmail,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME);
}
} }