diff options
author | Camil Staps | 2016-08-01 09:15:36 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-01 09:15:36 +0200 |
commit | 923aac957cc28723c622570d46d2a915c75df06f (patch) | |
tree | e4c6a3683f0f0781ed9545feb922e41a2e8d1e8b /classes/BusinessAdmin.php | |
parent | Internationalisation: email subjects (diff) |
Removed duplicate code
Diffstat (limited to 'classes/BusinessAdmin.php')
-rw-r--r-- | classes/BusinessAdmin.php | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/classes/BusinessAdmin.php b/classes/BusinessAdmin.php index 1ea02ae..f6abe14 100644 --- a/classes/BusinessAdmin.php +++ b/classes/BusinessAdmin.php @@ -332,103 +332,6 @@ class BusinessAdmin { //------------------------------------------------------------------------------ /** - * Create a new client - * - * @param PDO $pdo The database connection - * @param string $name The name for the new client - * - * @throws PDOException If something went wrong with the database - * - * @return client|bool A new instance of the client object, or false on failure - */ - public static function createClient($pdo, $name) { - $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."client` (`name`) VALUES (?)"); - $stmt->execute(array($name)); - if ($stmt->rowCount() == 1) { - return new Client($pdo, $pdo->lastInsertId()); - } else { - return false; - } - } - - /** - * Create a new file - * - * @param PDO $pdo The database connection - * @param string $filename The desired filename - * - * @throws PDOException If something went wrong with the database - * @throws Exception If the file could not be created (due to permissions, file existed already, etc.), or the database record couldn't be added - * - * @return file A new instance of the file object - */ - public static function createFile($pdo, $filename) { - // Check for file existence - if (file_exists(Constants::files_folder . $filename)) { - throw new Exception("$filename already exists."); - } - - // Try to create the file - if (file_put_contents(Constants::files_folder . $filename, '') === false) { - throw new Exception("$filename could not be created. Check the permissions."); - } - - $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."file` (`filename`) VALUES (?)"); - $stmt->execute(array($filename)); - if ($stmt->rowCount() == 1) { - $file = new File($pdo, $pdo->lastInsertId()); - $file->secret_key = File::getRandomSecretKey(); - return $file; - } else { - unlink(Constants::files_folder . $filename); - throw new Exception("$filename could not be added to the database"); - } - } - - /** - * Create a new user - * - * @param PDO $pdo The database connection - * @param string $username The username for the new user - * @param string $password The password for the new user - * - * @throws PDOException If something went wrong with the database - * - * @return user|bool A new instance of the user object, or false on failure - */ - public static function createUser($pdo, $username, $password) { - $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."user` (`username`, `password`) VALUES (?,?)"); - $stmt->execute([$username, user::hash($password)]); - if ($stmt->rowCount() == 1) { - return new User($pdo, $pdo->lastInsertId()); - } else { - return false; - } - } - - /** - * Create a new mail - * - * @param PDO $pdo The database connection - * @param int $contactId The contactId for the new mail - * @param int $offerId The offerId for the new mail - * @param string $subject - * - * @throws PDOException If something went wrong with the database - * - * @return Mail|bool A new instance of the Mail class, or false on failure - */ - public static function createMail($pdo, $contactId, $offerId, $subject) { - $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."mail` (`contactId`, `offerId`, `subject`) VALUES (?,?,?)"); - $stmt->execute([$contactId, $offerId, $subject]); - if ($stmt->rowCount() == 1) { - return new Mail($pdo, $pdo->lastInsertId()); - } else { - return false; - } - } - - /** * Format a date nicely * * @param int $timestamp The UNIX timestamp to format |