@@ -16,55 +16,55 @@ |
||
| 16 | 16 | |
| 17 | 17 | class MigrateToRoles extends ConsoleTaskBase |
| 18 | 18 | { |
| 19 | - public function execute() |
|
| 20 | - { |
|
| 21 | - $communityUser = User::getCommunity(); |
|
| 19 | + public function execute() |
|
| 20 | + { |
|
| 21 | + $communityUser = User::getCommunity(); |
|
| 22 | 22 | |
| 23 | - $database = $this->getDatabase(); |
|
| 24 | - $statement = $database->query('SELECT id, status, checkuser FROM user;'); |
|
| 25 | - $update = $database->prepare("UPDATE user SET status = 'Active' WHERE id = :id;"); |
|
| 23 | + $database = $this->getDatabase(); |
|
| 24 | + $statement = $database->query('SELECT id, status, checkuser FROM user;'); |
|
| 25 | + $update = $database->prepare("UPDATE user SET status = 'Active' WHERE id = :id;"); |
|
| 26 | 26 | |
| 27 | - $users = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 27 | + $users = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 28 | 28 | |
| 29 | - foreach ($users as $user) { |
|
| 30 | - $toAdd = array('user'); |
|
| 29 | + foreach ($users as $user) { |
|
| 30 | + $toAdd = array('user'); |
|
| 31 | 31 | |
| 32 | - if($user['status'] === 'Admin'){ |
|
| 33 | - $toAdd[] = 'admin'; |
|
| 34 | - } |
|
| 32 | + if($user['status'] === 'Admin'){ |
|
| 33 | + $toAdd[] = 'admin'; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - if($user['checkuser'] == 1){ |
|
| 37 | - $toAdd[] = 'checkuser'; |
|
| 38 | - } |
|
| 36 | + if($user['checkuser'] == 1){ |
|
| 37 | + $toAdd[] = 'checkuser'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - foreach ($toAdd as $x) { |
|
| 41 | - $a = new UserRole(); |
|
| 42 | - $a->setUser($user['id']); |
|
| 43 | - $a->setRole($x); |
|
| 44 | - $a->setDatabase($database); |
|
| 45 | - $a->save(); |
|
| 46 | - } |
|
| 40 | + foreach ($toAdd as $x) { |
|
| 41 | + $a = new UserRole(); |
|
| 42 | + $a->setUser($user['id']); |
|
| 43 | + $a->setRole($x); |
|
| 44 | + $a->setDatabase($database); |
|
| 45 | + $a->save(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $logData = serialize(array( |
|
| 49 | - 'added' => $toAdd, |
|
| 50 | - 'removed' => array(), |
|
| 51 | - 'reason' => 'Initial migration' |
|
| 52 | - )); |
|
| 48 | + $logData = serialize(array( |
|
| 49 | + 'added' => $toAdd, |
|
| 50 | + 'removed' => array(), |
|
| 51 | + 'reason' => 'Initial migration' |
|
| 52 | + )); |
|
| 53 | 53 | |
| 54 | - $log = new Log(); |
|
| 55 | - $log->setDatabase($database); |
|
| 56 | - $log->setAction('RoleChange'); |
|
| 57 | - $log->setObjectId($user['id']); |
|
| 58 | - $log->setObjectType('User'); |
|
| 59 | - $log->setUser($communityUser); |
|
| 60 | - $log->setComment($logData); |
|
| 61 | - $log->save(); |
|
| 54 | + $log = new Log(); |
|
| 55 | + $log->setDatabase($database); |
|
| 56 | + $log->setAction('RoleChange'); |
|
| 57 | + $log->setObjectId($user['id']); |
|
| 58 | + $log->setObjectType('User'); |
|
| 59 | + $log->setUser($communityUser); |
|
| 60 | + $log->setComment($logData); |
|
| 61 | + $log->save(); |
|
| 62 | 62 | |
| 63 | - if($user['status'] === 'Admin' || $user['status'] === 'User'){ |
|
| 64 | - $update->execute(array('id' => $user['id'])); |
|
| 65 | - } |
|
| 66 | - } |
|
| 63 | + if($user['status'] === 'Admin' || $user['status'] === 'User'){ |
|
| 64 | + $update->execute(array('id' => $user['id'])); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $database->exec("UPDATE schemaversion SET version = 25;"); |
|
| 69 | - } |
|
| 68 | + $database->exec("UPDATE schemaversion SET version = 25;"); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | |
| 14 | 14 | class UpdateTorExitTask extends ConsoleTaskBase |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @return void |
|
| 18 | - */ |
|
| 19 | - public function execute() |
|
| 20 | - { |
|
| 21 | - TorExitProvider::regenerate( |
|
| 22 | - $this->getDatabase(), |
|
| 23 | - $this->getHttpHelper(), |
|
| 24 | - $this->getSiteConfiguration()->getTorExitPaths()); |
|
| 25 | - } |
|
| 16 | + /** |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 19 | + public function execute() |
|
| 20 | + { |
|
| 21 | + TorExitProvider::regenerate( |
|
| 22 | + $this->getDatabase(), |
|
| 23 | + $this->getHttpHelper(), |
|
| 24 | + $this->getSiteConfiguration()->getTorExitPaths()); |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -10,21 +10,21 @@ |
||
| 10 | 10 | |
| 11 | 11 | abstract class PublicInterfacePageBase extends PageBase |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * PublicInterfaceInternalPageBase constructor. |
|
| 15 | - */ |
|
| 16 | - public function __construct() |
|
| 17 | - { |
|
| 18 | - $this->template = 'publicbase.tpl'; |
|
| 19 | - } |
|
| 13 | + /** |
|
| 14 | + * PublicInterfaceInternalPageBase constructor. |
|
| 15 | + */ |
|
| 16 | + public function __construct() |
|
| 17 | + { |
|
| 18 | + $this->template = 'publicbase.tpl'; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - final public function execute() |
|
| 22 | - { |
|
| 23 | - parent::execute(); |
|
| 24 | - } |
|
| 21 | + final public function execute() |
|
| 22 | + { |
|
| 23 | + parent::execute(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - final public function finalisePage() |
|
| 27 | - { |
|
| 28 | - parent::finalisePage(); |
|
| 29 | - } |
|
| 26 | + final public function finalisePage() |
|
| 27 | + { |
|
| 28 | + parent::finalisePage(); |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -12,21 +12,21 @@ |
||
| 12 | 12 | |
| 13 | 13 | interface IRoutedTask extends ITask |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Sets the route the request will take. Only should be called from the request router. |
|
| 17 | - * |
|
| 18 | - * @param $routeName string |
|
| 19 | - * |
|
| 20 | - * @return void |
|
| 21 | - * |
|
| 22 | - * @throws Exception |
|
| 23 | - * @category Security-Critical |
|
| 24 | - */ |
|
| 25 | - public function setRoute($routeName); |
|
| 15 | + /** |
|
| 16 | + * Sets the route the request will take. Only should be called from the request router. |
|
| 17 | + * |
|
| 18 | + * @param $routeName string |
|
| 19 | + * |
|
| 20 | + * @return void |
|
| 21 | + * |
|
| 22 | + * @throws Exception |
|
| 23 | + * @category Security-Critical |
|
| 24 | + */ |
|
| 25 | + public function setRoute($routeName); |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Gets the name of the route that has been passed from the request router. |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - public function getRouteName(); |
|
| 27 | + /** |
|
| 28 | + * Gets the name of the route that has been passed from the request router. |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + public function getRouteName(); |
|
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -10,8 +10,8 @@ |
||
| 10 | 10 | |
| 11 | 11 | class RegexConstants |
| 12 | 12 | { |
| 13 | - const IPV6_CIDR = '(?:/(?:12[0-8]|1[01][0-9]|[0-9]{1,2}))?'; |
|
| 14 | - const IPV4_CIDR = '(?:/(?:32|3[01]|[0-2]?[0-9]))?'; |
|
| 15 | - const IPV4 = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
|
| 16 | - const IPV6 = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'; |
|
| 13 | + const IPV6_CIDR = '(?:/(?:12[0-8]|1[01][0-9]|[0-9]{1,2}))?'; |
|
| 14 | + const IPV4_CIDR = '(?:/(?:32|3[01]|[0-2]?[0-9]))?'; |
|
| 15 | + const IPV4 = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
|
| 16 | + const IPV6 = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'; |
|
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -21,22 +21,22 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | abstract class ReadableException extends Exception |
| 23 | 23 | { |
| 24 | - use TemplateOutput; |
|
| 24 | + use TemplateOutput; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Returns a readable HTML error message that's displayable to the user using templates. |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - abstract public function getReadableError(); |
|
| 26 | + /** |
|
| 27 | + * Returns a readable HTML error message that's displayable to the user using templates. |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + abstract public function getReadableError(); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return SiteConfiguration |
|
| 34 | - */ |
|
| 35 | - protected function getSiteConfiguration() |
|
| 36 | - { |
|
| 37 | - // Uck. However, we have encountered an exception. |
|
| 38 | - global $siteConfiguration; |
|
| 32 | + /** |
|
| 33 | + * @return SiteConfiguration |
|
| 34 | + */ |
|
| 35 | + protected function getSiteConfiguration() |
|
| 36 | + { |
|
| 37 | + // Uck. However, we have encountered an exception. |
|
| 38 | + global $siteConfiguration; |
|
| 39 | 39 | |
| 40 | - return $siteConfiguration; |
|
| 41 | - } |
|
| 40 | + return $siteConfiguration; |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class EnvironmentException extends Exception |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * EnvironmentException constructor. |
|
| 26 | - * |
|
| 27 | - * @param string $friendlyMessage |
|
| 28 | - */ |
|
| 29 | - public function __construct($friendlyMessage) |
|
| 30 | - { |
|
| 31 | - parent::__construct($friendlyMessage); |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * EnvironmentException constructor. |
|
| 26 | + * |
|
| 27 | + * @param string $friendlyMessage |
|
| 28 | + */ |
|
| 29 | + public function __construct($friendlyMessage) |
|
| 30 | + { |
|
| 31 | + parent::__construct($friendlyMessage); |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -15,95 +15,95 @@ |
||
| 15 | 15 | |
| 16 | 16 | class UserRole extends DataObject |
| 17 | 17 | { |
| 18 | - /** @var int */ |
|
| 19 | - private $user; |
|
| 20 | - /** @var string */ |
|
| 21 | - private $role; |
|
| 18 | + /** @var int */ |
|
| 19 | + private $user; |
|
| 20 | + /** @var string */ |
|
| 21 | + private $role; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @param int $userId |
|
| 25 | - * @param PdoDatabase $database |
|
| 26 | - * |
|
| 27 | - * @return UserRole[] |
|
| 28 | - */ |
|
| 29 | - public static function getForUser($userId, PdoDatabase $database) |
|
| 30 | - { |
|
| 31 | - $sql = 'SELECT * FROM userrole WHERE user = :user'; |
|
| 32 | - $statement = $database->prepare($sql); |
|
| 33 | - $statement->bindValue(':user', $userId); |
|
| 23 | + /** |
|
| 24 | + * @param int $userId |
|
| 25 | + * @param PdoDatabase $database |
|
| 26 | + * |
|
| 27 | + * @return UserRole[] |
|
| 28 | + */ |
|
| 29 | + public static function getForUser($userId, PdoDatabase $database) |
|
| 30 | + { |
|
| 31 | + $sql = 'SELECT * FROM userrole WHERE user = :user'; |
|
| 32 | + $statement = $database->prepare($sql); |
|
| 33 | + $statement->bindValue(':user', $userId); |
|
| 34 | 34 | |
| 35 | - $statement->execute(); |
|
| 35 | + $statement->execute(); |
|
| 36 | 36 | |
| 37 | - $result = array(); |
|
| 37 | + $result = array(); |
|
| 38 | 38 | |
| 39 | - /** @var Ban $v */ |
|
| 40 | - foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) { |
|
| 41 | - $v->setDatabase($database); |
|
| 42 | - $result[] = $v; |
|
| 43 | - } |
|
| 39 | + /** @var Ban $v */ |
|
| 40 | + foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) { |
|
| 41 | + $v->setDatabase($database); |
|
| 42 | + $result[] = $v; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $result; |
|
| 46 | - } |
|
| 45 | + return $result; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Saves a data object to the database, either updating or inserting a record. |
|
| 50 | - * |
|
| 51 | - * @throws Exception |
|
| 52 | - */ |
|
| 53 | - public function save() |
|
| 54 | - { |
|
| 55 | - if ($this->isNew()) { |
|
| 56 | - // insert |
|
| 57 | - $statement = $this->dbObject->prepare('INSERT INTO `userrole` (user, role) VALUES (:user, :role);' |
|
| 58 | - ); |
|
| 59 | - $statement->bindValue(":user", $this->user); |
|
| 60 | - $statement->bindValue(":role", $this->role); |
|
| 48 | + /** |
|
| 49 | + * Saves a data object to the database, either updating or inserting a record. |
|
| 50 | + * |
|
| 51 | + * @throws Exception |
|
| 52 | + */ |
|
| 53 | + public function save() |
|
| 54 | + { |
|
| 55 | + if ($this->isNew()) { |
|
| 56 | + // insert |
|
| 57 | + $statement = $this->dbObject->prepare('INSERT INTO `userrole` (user, role) VALUES (:user, :role);' |
|
| 58 | + ); |
|
| 59 | + $statement->bindValue(":user", $this->user); |
|
| 60 | + $statement->bindValue(":role", $this->role); |
|
| 61 | 61 | |
| 62 | - if ($statement->execute()) { |
|
| 63 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 64 | - } |
|
| 65 | - else { |
|
| 66 | - throw new Exception($statement->errorInfo()); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - else { |
|
| 70 | - // update |
|
| 71 | - throw new Exception('Updating roles is not available'); |
|
| 72 | - } |
|
| 73 | - } |
|
| 62 | + if ($statement->execute()) { |
|
| 63 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 64 | + } |
|
| 65 | + else { |
|
| 66 | + throw new Exception($statement->errorInfo()); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + else { |
|
| 70 | + // update |
|
| 71 | + throw new Exception('Updating roles is not available'); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - #region Properties |
|
| 75 | + #region Properties |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @return int |
|
| 79 | - */ |
|
| 80 | - public function getUser() |
|
| 81 | - { |
|
| 82 | - return $this->user; |
|
| 83 | - } |
|
| 77 | + /** |
|
| 78 | + * @return int |
|
| 79 | + */ |
|
| 80 | + public function getUser() |
|
| 81 | + { |
|
| 82 | + return $this->user; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @param int $user |
|
| 87 | - */ |
|
| 88 | - public function setUser($user) |
|
| 89 | - { |
|
| 90 | - $this->user = $user; |
|
| 91 | - } |
|
| 85 | + /** |
|
| 86 | + * @param int $user |
|
| 87 | + */ |
|
| 88 | + public function setUser($user) |
|
| 89 | + { |
|
| 90 | + $this->user = $user; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - public function getRole() |
|
| 97 | - { |
|
| 98 | - return $this->role; |
|
| 99 | - } |
|
| 93 | + /** |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + public function getRole() |
|
| 97 | + { |
|
| 98 | + return $this->role; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @param string $role |
|
| 103 | - */ |
|
| 104 | - public function setRole($role) |
|
| 105 | - { |
|
| 106 | - $this->role = $role; |
|
| 107 | - } |
|
| 108 | - #endregion |
|
| 101 | + /** |
|
| 102 | + * @param string $role |
|
| 103 | + */ |
|
| 104 | + public function setRole($role) |
|
| 105 | + { |
|
| 106 | + $this->role = $role; |
|
| 107 | + } |
|
| 108 | + #endregion |
|
| 109 | 109 | } |
@@ -22,73 +22,73 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Notification extends DataObject |
| 24 | 24 | { |
| 25 | - private $date; |
|
| 26 | - private $type; |
|
| 27 | - private $text; |
|
| 25 | + private $date; |
|
| 26 | + private $type; |
|
| 27 | + private $text; |
|
| 28 | 28 | |
| 29 | - public function delete() |
|
| 30 | - { |
|
| 31 | - throw new Exception("You shouldn't be doing this..."); |
|
| 32 | - } |
|
| 29 | + public function delete() |
|
| 30 | + { |
|
| 31 | + throw new Exception("You shouldn't be doing this..."); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function save() |
|
| 35 | - { |
|
| 36 | - if ($this->isNew()) { |
|
| 37 | - // insert |
|
| 38 | - $statement = $this->dbObject->prepare("INSERT INTO notification ( type, text ) VALUES ( :type, :text );"); |
|
| 39 | - $statement->bindValue(":type", $this->type); |
|
| 40 | - $statement->bindValue(":text", $this->text); |
|
| 34 | + public function save() |
|
| 35 | + { |
|
| 36 | + if ($this->isNew()) { |
|
| 37 | + // insert |
|
| 38 | + $statement = $this->dbObject->prepare("INSERT INTO notification ( type, text ) VALUES ( :type, :text );"); |
|
| 39 | + $statement->bindValue(":type", $this->type); |
|
| 40 | + $statement->bindValue(":text", $this->text); |
|
| 41 | 41 | |
| 42 | - if ($statement->execute()) { |
|
| 43 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 44 | - } |
|
| 45 | - else { |
|
| 46 | - throw new Exception($statement->errorInfo()); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - else { |
|
| 50 | - throw new Exception("You shouldn't be doing this..."); |
|
| 51 | - } |
|
| 52 | - } |
|
| 42 | + if ($statement->execute()) { |
|
| 43 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 44 | + } |
|
| 45 | + else { |
|
| 46 | + throw new Exception($statement->errorInfo()); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + else { |
|
| 50 | + throw new Exception("You shouldn't be doing this..."); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getDate() |
|
| 55 | - { |
|
| 56 | - return new DateTimeImmutable($this->date); |
|
| 57 | - } |
|
| 54 | + public function getDate() |
|
| 55 | + { |
|
| 56 | + return new DateTimeImmutable($this->date); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return int |
|
| 61 | - */ |
|
| 62 | - public function getType() |
|
| 63 | - { |
|
| 64 | - return $this->type; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * @return int |
|
| 61 | + */ |
|
| 62 | + public function getType() |
|
| 63 | + { |
|
| 64 | + return $this->type; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @return string |
|
| 69 | - */ |
|
| 70 | - public function getText() |
|
| 71 | - { |
|
| 72 | - return $this->text; |
|
| 73 | - } |
|
| 67 | + /** |
|
| 68 | + * @return string |
|
| 69 | + */ |
|
| 70 | + public function getText() |
|
| 71 | + { |
|
| 72 | + return $this->text; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Summary of setType |
|
| 77 | - * |
|
| 78 | - * @param int $type |
|
| 79 | - */ |
|
| 80 | - public function setType($type) |
|
| 81 | - { |
|
| 82 | - $this->type = $type; |
|
| 83 | - } |
|
| 75 | + /** |
|
| 76 | + * Summary of setType |
|
| 77 | + * |
|
| 78 | + * @param int $type |
|
| 79 | + */ |
|
| 80 | + public function setType($type) |
|
| 81 | + { |
|
| 82 | + $this->type = $type; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Summary of setText |
|
| 87 | - * |
|
| 88 | - * @param string $text |
|
| 89 | - */ |
|
| 90 | - public function setText($text) |
|
| 91 | - { |
|
| 92 | - $this->text = $text; |
|
| 93 | - } |
|
| 85 | + /** |
|
| 86 | + * Summary of setText |
|
| 87 | + * |
|
| 88 | + * @param string $text |
|
| 89 | + */ |
|
| 90 | + public function setText($text) |
|
| 91 | + { |
|
| 92 | + $this->text = $text; |
|
| 93 | + } |
|
| 94 | 94 | } |