public function testSetId()
 {
     $u = new ae_UserModel();
     $u->setId(4);
     $this->assertTrue($u->getId() === 4);
     $this->setExpectedException('Exception');
     $u->setId(-1);
 }
Exemple #2
0
        }
    }
}
?>
<h1>Edit: <?php 
echo $editArea;
?>
</h1>

<form method="post" action="scripts/create.php" class="form-create">
	<input type="hidden" name="area" value="<?php 
echo $areaId;
?>
" />
	<input type="hidden" name="edit-id" value="<?php 
echo $model->getId();
?>
" />

<?php 
if ($editArea == 'Comment') {
    ?>
	<?php 
    $content = str_replace('<br />', '', $model->getContent());
    $content = htmlspecialchars($content);
    $userList = new ae_UserList();
    ?>

	<aside>
		<div class="input-group">
			<h3>IP</h3>
Exemple #3
0
 /**
  * Get the user ID.
  * @return {int|boolean} The user ID or FALSE on failure.
  */
 public static function getUserId()
 {
     if (!self::isUser()) {
         $msg = sprintf('[%s] Permalink does not represent a user.', get_class());
         throw new Exception($msg);
     }
     $model = new ae_UserModel();
     if (isset($_GET[PERMALINK_GET_USER])) {
         $permalink = $_GET[PERMALINK_GET_USER];
     } else {
         $permalink = mb_substr(self::$url, 1);
         $permalink = preg_replace(';^' . PERMALINK_BASE_USER . ';i', '', $permalink);
     }
     if (!$model->loadFromPermalink($permalink)) {
         return FALSE;
     }
     return $model->getId();
 }
Exemple #4
0
/**
 * Create the user.
 * @return {int} ID of the new user.
 */
function createUser()
{
    if (!isset($_POST['user-name-internal'], $_POST['user-name-external'], $_POST['user-permalink'], $_POST['user-password'])) {
        header('Location: ../admin.php?error=missing_data_for_user');
        exit;
    }
    $permalink = trim($_POST['user-permalink']);
    $status = isset($_POST['user-status-suspended']) ? ae_UserModel::STATUS_SUSPENDED : ae_UserModel::STATUS_ACTIVE;
    $user = new ae_UserModel();
    if (isset($_POST['edit-id'])) {
        if (!$user->load($_POST['edit-id'])) {
            return FALSE;
        }
    }
    $user->setNameInternal($_POST['user-name-internal']);
    $user->setNameExternal($_POST['user-name-external']);
    if ($permalink != '') {
        $user->setPermalink($permalink);
    }
    if ($_POST['user-password'] !== '') {
        $user->setPasswordHash(ae_Security::hash($_POST['user-password']));
    }
    $user->setStatus($status);
    $user->save();
    return $user->getId();
}