Example #1
0
 case 'settings_password':
     $success = Session::Get('current_user')->ChangePassword($_POST);
     $message = $success ? array(Config::Get('success.saved')) : Error::GetAll();
     break;
 case 'admin_add':
     $_POST['social_type'] = 'normal';
     $success = User::AddUser($_POST);
     if (isset($_POST['emailpassword']) && $success) {
         Email::SendEmail($_POST['email'], 'New account', 'Admin created an account with your email; Your password is : ' . $_POST['password']);
     }
     $message = $success ? array(Config::Get('success.created')) : Error::GetAll();
     break;
 case 'admin_edit':
     $user = new User();
     $user->Load(array('id' => $_POST['user_id']));
     $user->ChangeSettings($_POST);
     $success = Error::HasErrors() ? false : true;
     if (!empty($_POST['password']) || !empty($_POST['cpassword'])) {
         $success = $success && $user->ChangePassword($_POST);
     }
     $message = $success ? array(Config::Get('success.saved')) : Error::GetAll();
     $data = array('email' => $user->Get('email'), 'username' => $user->Get('username'));
     break;
 case 'admin_delete':
     $user = new User();
     if ($user->Load(array('id' => $_POST['user_id']))) {
         $success = $user->Delete();
     } else {
         Error::Set('user', 'usernotfound');
     }
     $message = $success ? array(Config::Get('success.saved')) : Error::GetAll();