implement CRUD for seminaries and correct typos for users

This commit is contained in:
coderkun 2014-01-25 20:55:10 +01:00
commit 297c56e29d
15 changed files with 247 additions and 27 deletions

View file

@ -99,6 +99,63 @@
return $seminary[0];
}
/**
* Create a new seminary.
*
* @param string $title Title of seminary to create
* @param int $userId ID of creating user
* @return int ID of the newly created seminary
*/
public function createSeminary($title, $userId)
{
$this->db->query(
'INSERT INTO seminaries '.
'(created_user_id, title, url) '.
'VALUES '.
'(?, ?, ?)',
'iss',
$userId,
$title,
\nre\core\Linker::createLinkParam($title)
);
return $this->db->getInsertId();
}
/**
* Edit a seminary.
*
* @throws DatamodelException
* @param int $seminaryId ID of the seminary to delete
* @param string $title New title of seminary
*/
public function editSeminary($seminaryId, $title)
{
$this->db->query(
'UPDATE seminaries '.
'SET title = ?, url = ? '.
'WHERE id = ?',
'ssi',
$title,
\nre\core\Linker::createLinkParam($title),
$seminaryId
);
}
/**
* Delete a seminary.
*
* @param int $seminaryId ID of the seminary to delete
*/
public function deleteSeminary($seminaryId)
{
$this->db->query('DELETE FROM seminaries WHERE id = ?', 'i', $seminaryId);
}
}
?>

View file

@ -155,6 +155,7 @@
* Edit a user.
*
* @throws DatamodelException
* @param int $userId ID of the user to delete
* @param string $username New name of user
* @param string $email Changed email-address of user
* @param string $password Changed plaintext password of user
@ -165,10 +166,12 @@
// Update user data
$this->db->query(
'UPDATE users '.
'SET username = ?, email = ? '.
'SET username = ?, url = ?, email = ? '.
'WHERE id = ?',
'ssi',
$sername, $email,
'sssi',
$username,
\nre\core\Linker::createLinkParam($username),
$email,
$userId
);
@ -214,7 +217,7 @@
* @param string $password Plaintext password
* @return string Hashed password
*/
private function hash($password)
public function hash($password)
{
return password_hash($password, PASSWORD_DEFAULT);
}