Beispiel #1
0
 public function defaultaction()
 {
     if (!auth::isloggedin()) {
         lib::sendto('/login');
     } else {
         $contacts = new contactscollection(lib::getitem('user'));
         $contacts->getwithdata();
         echo view::show('contacts/browse', array('contacts' => $contacts));
     }
 }
Beispiel #2
0
 public function processadd()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     $admin = $_POST['admin'];
     $user = new user(array('username' => $username));
     if (!is_null($user->id)) {
         lib::seterror($username . ' is already in use');
         lib::sendto('/users/add');
     }
     $user->username = $username;
     $user->password = lib::makehashedpassword($user, $password);
     $user->admin = $admin;
     $user->save();
     lib::sendto('/users');
 }
Beispiel #3
0
 public function process()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     if (empty($username)) {
         lib::seterror('Please enter a username.');
         lib::sendto('/login');
     }
     if (empty($password)) {
         lib::setitem('username', $username);
         lib::seterror('Please enter a password.');
         lib::sendto('/login');
     }
     $user = new user(array('username' => $username));
     if (auth::authenticate($user, $password)) {
         lib::setitem('user', $user);
         lib::sendto();
     } else {
         lib::setitem('username', $username);
         lib::seterror('Invalid username or password.');
         lib::sendto('/login');
     }
 }
Beispiel #4
0
 public function defaultaction()
 {
     lib::setitem('user', NULL);
     lib::sendto();
 }
Beispiel #5
0
 public function processdelete()
 {
     $controller = lib::getitem('controller');
     if (empty($controller->params[0])) {
         lib::sendto();
     } else {
         $connection = db::factory('mysql');
         $contactid = (int) $controller->params[0];
         $sql = "delete c.*, g.*, m.* from contact c\r\n                    left join contactgroup g on g.contactid=c.id\r\n                    left join contactmethod m on g.id=m.contactgroupid\r\n                    where c.id={$contactid}\r\n                    ";
         $results = $connection->execute($sql);
         lib::sendto();
     }
 }