X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fdatabase%2Ffrontend%2Fclass_UserDatabaseWrapper.php;h=f729abebdaf19274430f4b348194b165d116b68e;hp=59e2c376b0247a7a9479b79521270b32033b863f;hb=HEAD;hpb=cad1ab5ecb2935a6ebf678555860c3bd96b525b0 diff --git a/framework/main/classes/database/frontend/class_UserDatabaseWrapper.php b/framework/main/classes/database/frontend/class_UserDatabaseWrapper.php deleted file mode 100644 index 59e2c376..00000000 --- a/framework/main/classes/database/frontend/class_UserDatabaseWrapper.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @version 0.0.0 -<<<<<<< HEAD:framework/main/classes/database/frontend/class_UserDatabaseWrapper.php - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team -======= - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team ->>>>>>> Some updates::inc/main/classes/database/frontend/class_UserDatabaseWrapper.php - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccountWrapper, Registerable { - // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; - - // Constants for database columns - const DB_COLUMN_USERID = 'userid'; - const DB_COLUMN_USERNAME = 'username'; - const DB_COLUMN_EMAIL = 'email'; - const DB_COLUMN_CONFIRM_HASH = 'confirm_hash'; - const DB_COLUMN_USER_STATUS = 'user_status'; - - // Constants for database table names - const DB_TABLE_USER = 'user'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createUserDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new UserDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_USER); - - // Return the instance - return $wrapperInstance; - } - - /** - * Handles inserting the registration data from a registration instance into the database - * - * @param $registrationInstance An instance of a registration class - * @return void - */ - public function insertRegistrationObject (UserRegister $registrationInstance) { - // Generate a data set for the request - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); - - // Add registration elements to the dataset - $registrationInstance->addElementsToDataSet($dataSetInstance); - - // "Insert" this request instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - } - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a Updateable database result - * @return void - * @throws NullPointerException If $updateInstance or $searchInstance is null - */ - public function doUpdateByResult (UpdateableResult $resultInstance) { - // Get the search instance from result - $searchInstance = $resultInstance->getSearchInstance(); - - // Is this null? - if (is_null($searchInstance)) { - // Get the update instance - $updateInstance = $resultInstance->getUpdateInstance(); - - // Is this null? - if (is_null($updateInstance)) { - // Throw an exception here - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get search instance from update instance - $searchInstance = $updateInstance->getSearchInstance(); - - // Is it still null? - if (is_null($searchInstance)) { - // Throw an exception here - throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - } // END - if - - // Generate a data set object - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); - - // Add seach criteria - $dataSetInstance->setSearchInstance($searchInstance); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); - - // Add all update criteria to the database set - $resultInstance->addElementsToDataSet($dataSetInstance); - - // "Update" this request with the database - $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } - -}