コード例 #1
0
ファイル: system.class.php プロジェクト: rasler/CRETPictures
 public function user_create($login, $password, $profile = null)
 {
     global $default_permissions;
     if (!is_string($login) || !is_string($password) || !ctype_alnum($login)) {
         throw new Exception("Invalid user");
     }
     $this->permissions_require("admin.user.create");
     $this->db->beginTransaction();
     $rs = $this->db->prepare('INSERT INTO ' . $this->prfx . 'users (login, pass, creation) VALUES (?,?,NOW())');
     $rs->execute(array($login, $this->crypte_password($password)));
     $id = $this->db->lastInsertId();
     foreach ($default_permissions as $perm) {
         $this->db->exec('INSERT INTO ' . $this->prfx . 'permissions VALUES (' . $id . ', \'' . $perm . '\');');
     }
     // création du profil
     $temp = $this->user;
     $this->user = array('id' => $id);
     if ($profile == null) {
         $profile = array("link" => $id);
     } else {
         $profile["link"] = $id;
     }
     $ph = new ProfilesHandler($this);
     $ph->profiles_create($profile);
     $this->user = $temp;
     $this->db->commit();
     return $id;
 }
コード例 #2
0
ファイル: creerProfil.php プロジェクト: rasler/CRETPictures
$perms[5] = $sys->permissions_test('application.picture.upload');
$smarty->assign('perms', $perms);
if ($usr != null) {
    $smarty->assign('name', $usr['login']);
} else {
    $smarty->assign('name', "");
}
if (isset($_GET['who']) && $_GET['who'] == 'self') {
    $smarty->assign('who', "self");
} else {
    $smarty->assign('who', NULL);
}
if (isset($_GET['do']) && $_GET['do'] == "create") {
    $profile["gender"] = $_POST['gender'];
    $profile["nickName"] = $_POST['nickname'];
    $profile["firstName"] = $_POST['firstname'];
    $profile["lastName"] = $_POST['lastname'];
    $profile["birth"] = $_POST['birth'];
    $profile["email"] = $_POST['email'];
    $profile["phone"] = $_POST['phone'];
    if (isset($_GET['link']) && $_GET['link'] == "user") {
        $profile["link"] = $usr['id'];
    }
    var_dump($profile);
    $prid = $profiles->profiles_create($profile);
    $smarty->assign('profil', $profile);
    $smarty->assign('profilID', $prid);
    $smarty->display('apercuProfil.tpl');
} else {
    $smarty->display('creerProfil.tpl');
}