inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php -text
inc/classes/exceptions/crypto/class_EncryptMissingException.php -text
inc/classes/exceptions/database/.htaccess -text
+inc/classes/exceptions/database/class_ -text
inc/classes/exceptions/database/class_DatabaseException.php -text
inc/classes/exceptions/database/general/.htaccess -text
+inc/classes/exceptions/database/general/class_DatabaseUpdateSupportException.php -text
inc/classes/exceptions/database/general/class_SqlException.php -text
inc/classes/exceptions/database/local_file/.htaccess -text
inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php -text
inc/classes/interfaces/crypto/class_Cryptable.php -text
inc/classes/interfaces/database/.htaccess -text
inc/classes/interfaces/database/class_FrameworkDatabaseInterface.php -text
+inc/classes/interfaces/database/class_Updateable.php -text
inc/classes/interfaces/database/frontend/.htaccess -text
inc/classes/interfaces/database/frontend/class_DatabaseFrontendInterface.php -text
inc/classes/interfaces/database/middleware/.htaccess -text
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 <http://www.gnu.org/licenses/>.
+ */
+class ???Exception extends DatabaseException {
+ /**
+ * The constructor
+ *
+ * @param $message Message from the exception
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct ($message, $code) {
+ // Just call the parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when a class tries an unallowed database update
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 <http://www.gnu.org/licenses/>.
+ */
+class DatabaseUpdateSupportException extends DatabaseException {
+ /**
+ * The constructor
+ *
+ * @param $class Class trying the invalid database update
+ * @param $code Code number for the exception
+ * @return void
+ */
+ public function __construct (FrameworkInterface $class, $code) {
+ // Generate message
+ $message = sprintf("[%s:%d] Database updated not allowed for this class.",
+ $class->__toString(),
+ $this->getLine()
+ );
+
+ // Just call the parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An interface for classes which are allowed to update database records
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 <http://www.gnu.org/licenses/>.
+ */
+interface Updateable extends FrameworkInterface {
+}
+
+//
+?>
const EXCEPTION_FILE_NOT_FOUND = 0x036;
const EXCEPTION_ASSERTION_FAILED = 0x037;
const EXCEPTION_FILE_CANNOT_BE_READ = 0x038;
+ const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
/**
* In the super constructor these system classes shall be ignored or else
// Return the stamp
return $readable;
}
+
+ /**
+ * "Getter" for databse entry
+ *
+ * @return $entry An array with database entries
+ * @throws NullPointerException If the database result is not found
+ * @throws InvalidDatabaseResultException If the database result is invalid
+ */
+ protected final function getDatabaseEntry () {
+ // Is there an instance?
+ if (is_null($this->getResultInstance())) {
+ // Throw an exception here
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+
+ // Rewind it
+ $this->getResultInstance()->rewind();
+
+ // Do we have an entry?
+ if (!$this->getResultInstance()->valid()) {
+ throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
+ } // END - if
+
+ // Get next entry
+ $this->getResultInstance()->next();
+
+ // Fetch it
+ $entry = $this->getResultInstance()->current();
+
+ // And return it
+ return $entry;
+ }
+
+ /**
+ * Getter for field name
+ *
+ * @param $fieldName Field name which we shall get
+ * @return $fieldValue Field value from the user
+ * @throws NullPointerException If the result instance is null
+ */
+ public final function getField ($fieldName) {
+ // Default field value
+ $fieldValue = null;
+
+ // Get result instance
+ $resultInstance = $this->getResultInstance();
+
+ // Is this instance null?
+ if (is_null($resultInstance)) {
+ // Then the user instance is no longer valid (expired cookies?)
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+
+ // Get current array
+ $fieldArray = $resultInstance->current();
+
+ // Does the field exist?
+ if (isset($fieldArray[$fieldName])) {
+ // Get it
+ $fieldValue = $fieldArray[$fieldName];
+ } // END - if
+
+ // Return it
+ return $fieldValue;
+ }
+
+ /**
+ * Updates a given field with new value
+ *
+ * @param $fieldName Field to update
+ * @param $fieldValue New value to store
+ * @return void
+ * @throws DatabaseUpdateSupportException If this class does not support database updates
+ */
+ public function updateDatabaseField ($fieldName, $fieldValue) {
+ // Is updating database fields allowed by interface?
+ if (!$this instanceof Updateable) {
+ // Update not supported!
+ throw new DatabaseUpdateSupportException($this, self::EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED);
+ } // END - if
+
+ // Get a critieria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add search criteria
+ $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $searchInstance->setLimit(1);
+
+ // Now get another criteria
+ $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
+
+ // And add our both entries
+ $updateInstance->addCriteria($fieldName, $fieldValue);
+
+ // Add the search criteria for searching for the right entry
+ $updateInstance->setSearchInstance($searchInstance);
+
+ // Remember the update in database result
+ $this->getResultInstance()->add2UpdateQueue($updateInstance);
+ }
}
// [EOF]
$this->removeSystemArray();
}
- /**
- * "Getter" for databse entry
- *
- * @return $entry An array with database entries
- * @throws NullPointerException If the database result is not found
- * @throws InvalidDatabaseResultException If the database result is invalid
- */
- private function getDatabaseEntry () {
- // Is there an instance?
- if (is_null($this->getResultInstance())) {
- // Throw new exception
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
-
- // Rewind it
- $this->getResultInstance()->rewind();
-
- // Do we have an entry?
- if (!$this->getResultInstance()->valid()) {
- throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
- } // END - if
-
- // Get next entry
- $this->getResultInstance()->next();
-
- // Fetch it
- $entry = $this->getResultInstance()->current();
-
- // And return it
- return $entry;
- }
-
/**
* Setter for username
*
if (isset($entry['pass_hash'])) {
// Get it
$passHash = $entry['pass_hash'];
- }
+ } // END - if
// And return the hash
return $passHash;
}
- /**
- * Getter for field name
- *
- * @param $fieldName Field name which we shall get
- * @return $fieldValue Field value from the user
- * @throws NullPointerException If the result instance is null
- */
- public final function getField ($fieldName) {
- // Default field value
- $fieldValue = null;
-
- // Get result instance
- $resultInstance = $this->getResultInstance();
-
- // Is this instance null?
- if (is_null($resultInstance)) {
- // Then the user instance is no longer valid (expired cookies?)
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
-
- // Get current array
- $fieldArray = $resultInstance->current();
-
- // Does the field exist?
- if (isset($fieldArray[$fieldName])) {
- // Get it
- $fieldValue = $fieldArray[$fieldName];
- } // END - if
-
- // Return it
- return $fieldValue;
- }
-
/**
* Getter for primary key value
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class User extends BaseUser implements ManageableUser, Registerable {
+class User extends BaseUser implements ManageableUser, Registerable, Updateable {
// Exceptions
const EXCEPTION_USERNAME_NOT_FOUND = 0x150;
const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
* @param $column Column we want to update
* @param $value New value to store in database
* @return void
- * @todo 0% done
+ * @deprecated
*/
public function addUpdateData ($column, $value) {
- $this->partialStub("Column={$column}, value={$value}");
+ $this->deprecatedMethod("Please use updateDatabaseField() instead!");
+ $this->updateDatabaseField($column, $value);
}
/**
$this->getResultInstance()->add2UpdateQueue($updateInstance);
}
- /**
- * Updates a given field with new value
- *
- * @param $fieldName Field to update
- * @param $fieldValue New value to store
- * @return void
- */
- public function updateDatabaseField ($fieldName, $fieldValue) {
- // Get a critieria instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Add search criteria
- $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
- $searchInstance->setLimit(1);
-
- // Now get another criteria
- $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
-
- // And add our both entries
- $updateInstance->addCriteria($fieldName, $fieldValue);
-
- // Add the search criteria for searching for the right entry
- $updateInstance->setSearchInstance($searchInstance);
-
- // Remember the update in database result
- $this->getResultInstance()->add2UpdateQueue($updateInstance);
- }
-
/**
* Flushs all pending updates to the database layer
*