public function deleteAccount($userInfo, $userInfoSerializedHashed) { $registry = Zend_Registry::getInstance(); $people = Ml_Model_People::getInstance(); $share = Ml_Model_Share::getInstance(); $removeFiles = Ml_Model_RemoveFiles::getInstance(); $picture = Ml_Model_Picture::getInstance(); if (!is_array($userInfo) || !isset($userInfo['alias'])) { throw new Exception("Invalid userInfo data."); } //flag set to true when authorized to do so, least security resource if (!$registry->isRegistered("canDeleteAccount")) { throw new Exception("Not authorized to delete account."); } if (sha1(serialize($userInfo)) != $userInfoSerializedHashed) { throw new Exception("userInfo and serialized data doesn't match."); } $this->_dbAdapter->beginTransaction(); try { $picture->deleteFiles($userInfo); $removeFiles->addFilesGc($userInfo['id'], $userInfo['alias']); $this->_dbAdapter->query("INSERT INTO " . $this->_dbAdapter->quoteTableAs($this->_dbTable->getTableName()) . " SELECT id, alias, email, membershipdate, name, private_email, CURRENT_TIMESTAMP as delete_timestamp from people where " . $this->_dbAdapter->quoteInto("id = ?", $userInfo['id'])); $people->delete($userInfo['id']); $this->_dbAdapter->commit(); } catch (Exception $e) { $this->_dbAdapter->rollBack(); throw $e; } return true; }
public function cleanfilesAction() { // Clean files left by deleted shares // It is assumed that their metadata is stored in a removefiles table // in the DB $removeFiles = Ml_Model_RemoveFiles::getInstance(); $removedNum = $removeFiles->gc(); echo "Cleaned " . $removedNum . " files from storage.\n"; }
public function deleteShare($shareInfo, $userInfo) { $removeFiles = Ml_Model_RemoveFiles::getInstance(); if (!isset($shareInfo['secret']) || !isset($userInfo['alias'])) { throw new Exception("Not shareInfo or userInfo data."); } $this->_dbAdapter->beginTransaction(); try { $removeFiles->addFileGc(array("id" => $shareInfo['id'], "byUid" => $shareInfo['byUid'], "alias" => $userInfo['alias'], "download_secret" => $shareInfo['download_secret'], "filename" => $shareInfo['filename'])); $this->_dbTable->delete($this->_dbAdapter->quoteInto("id = ?", $shareInfo['id'])); $this->_dbAdapter->commit(); } catch (Exception $e) { $this->_dbAdapter->rollBack(); throw $e; } return true; }