Added LDAP sync for new registrations and updated the form validation rules. Removed Nordea-code.
This commit is contained in:
1 parent
95f8e11663
commit
ceef0e82e7
4 files changed
+32
-186
No files matched your search
+5
-10
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once("migration/inside_functions.php");
|
||||
class ActionParser {
|
||||
var $action;
|
||||
|
||||
@@ -854,16 +855,10 @@ private function logError($username, $error)
|
||||
$user = new User(NULL, $_REQUEST);
|
||||
if ($user->id != -1) {
|
||||
if ($user->store()) {
|
||||
if (isset ($_REQUEST['nordea'])) {
|
||||
$lead = Array (
|
||||
"firstname" => $user->firstname,
|
||||
"lastname" => $user->lastname,
|
||||
"email" => $user->email,
|
||||
"phonenumber" => $user->phonenumber
|
||||
);
|
||||
$nordea = new Nordea(NULL, $lead);
|
||||
$nordea->store();
|
||||
}
|
||||
/* Push the user to LDAP (nikolark) */
|
||||
$migrated = ldap_add_user($user->username, $user->firstname, $user->lastname, $user->email, $user->password, find_groups());
|
||||
_log($migrated);
|
||||
set_migrated();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
*This class requires PEAR::DB and functions library
|
||||
*/
|
||||
class nordea {
|
||||
|
||||
var $id;
|
||||
var $firstname;
|
||||
var $lastname;
|
||||
var $email;
|
||||
var $phonenumber;
|
||||
|
||||
var $conn;
|
||||
|
||||
function Nordea($id = NULL, $data = NULL){
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
if ($id == NULL){//New Nordea-lead
|
||||
if ($data == NULL){
|
||||
error("Nordea-lead: No data supplied.");
|
||||
}
|
||||
}else {//ID set, existing lead
|
||||
if ($data != NULL){//Update existing lead
|
||||
|
||||
}else {//Retrieve data from backend for display or other actions
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
$this->firstname = $data['firstname'];
|
||||
$this->lastname = $data['lastname'];
|
||||
$this->email = $data['email'];
|
||||
$this->phonenumber = $data['phonenumber'];
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$sql = sprintf("INSERT INTO din_nordea
|
||||
(id, firstname, lastname, email, phonenumber)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->firstname),
|
||||
$this->conn->quoteSmart($this->lastname),
|
||||
$this->conn->quoteSmart($this->email),
|
||||
$this->conn->quoteSmart($this->phonenumber)
|
||||
);
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
notify("Ønske om å bli kontakt av Nordea er registrert.");
|
||||
$sendto = "student@nordea.no";
|
||||
$subject = "Nytt lead fra Studentersamfundet";
|
||||
$message = "Dette er en autogenerert epost som blir sendt hver gang et nytt medlem har haket av for ønske om å bli kontaktet av Nordea. Denne personen har nettopp kjøpt medlemskap i Studentersamfundet og registrert seg på nettsidene våre." .
|
||||
"\n" .
|
||||
"\nEt nytt lead er registrert:" .
|
||||
"\n" .
|
||||
"\n$this->firstname $this->lastname" .
|
||||
"\n" .
|
||||
"\nEpost: $this->email".
|
||||
"\nTelefon: $this->phonenumber" .
|
||||
"\n" .
|
||||
"\nmvh" .
|
||||
"\nStudentersamfundet";
|
||||
$headers = 'From: nordea@studentersamfundet.no'."\r\n";
|
||||
$headers .= 'Cc: support@studentersamfundet.no'."\r\n";
|
||||
mail($sendto, $subject, $message, $headers);
|
||||
|
||||
}else {
|
||||
error("New nordea: " . $result->toString());
|
||||
notify("Problemer med å registrere Nordealead.");
|
||||
}
|
||||
|
||||
}else {
|
||||
//Not finished
|
||||
$sql = sprintf("UPDATE din_nordea SET
|
||||
name = %s,
|
||||
text = %s,
|
||||
phone = %s,
|
||||
email = %s,
|
||||
office = %s,
|
||||
user_id_contact = %s,
|
||||
url = %s,
|
||||
nordeacategory_id = %s
|
||||
WHERE
|
||||
id = %s",
|
||||
$this->conn->quoteSmart($this->name),
|
||||
$this->conn->quoteSmart($this->text),
|
||||
$this->conn->quoteSmart($this->phone),
|
||||
$this->conn->quoteSmart($this->email),
|
||||
$this->conn->quoteSmart($this->office),
|
||||
$this->conn->quoteSmart($this->user_id_contact),
|
||||
$this->conn->quoteSmart($this->url),
|
||||
$this->conn->quoteSmart($this->nordeacategory_id),
|
||||
$this->conn->quoteSmart($this->id)
|
||||
);
|
||||
|
||||
// $result = $this->conn->query($sql);
|
||||
// if (DB::isError($result) != true){
|
||||
// notify("Nordea-lead oppdatert.");
|
||||
// }else {
|
||||
// error("Update nordea lead: " . $result->toString());
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_nordea
|
||||
WHERE id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
|
||||
if (DB::isError($result) != true){
|
||||
if ($row =& $result->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$row['text'] = stripslashes($row['text']);
|
||||
return $row;
|
||||
}
|
||||
}else {
|
||||
error("nordea: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_nordea
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($conn->affectedRows() > 0){
|
||||
notify("Nordea-lead slettet.");
|
||||
}else {
|
||||
notify("Ugyldig lead-id, ingen handling utført.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
|
||||
}
|
||||
|
||||
public function displayList(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+26
-18
@@ -56,26 +56,34 @@ class User {
|
||||
$this->id = -1;
|
||||
return false;
|
||||
} else {
|
||||
$this->username = stripcslashes($data['username']);
|
||||
if (strlen($data['password1']) < 4) {
|
||||
notify("Passordet må være minst 4 tegn.");
|
||||
if (strlen(stripcslashes($data['username'])) < 3 || strlen(stripcslashes($data['username'])) > 12 ) {
|
||||
notify("Brukernavnet må være mellom 3 og 12 tegn.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
} else {
|
||||
if ($data['password1'] != $data['password2']) {
|
||||
notify("Passordene var ikke like.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
} else {
|
||||
$this->password = $data['password1'];
|
||||
if (!isAdmin()) {
|
||||
switch (checkForumUsername($data['username'], $this->password)) {
|
||||
case "wrong-password" :
|
||||
notify("Brukernavnet er allerede i bruk på forumet. " . "Om du selv har dette brukernavnet må du oppgi " . "riktig passord.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(preg_match('/^[a-z]*$/', strtolower(stripcslashes($data['username'])))) {
|
||||
notify("Brukernavnet kan kun inneholde små bokstaver.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
}
|
||||
$this->username = strtolower(stripcslashes($data['username']));
|
||||
if (strlen($data['password1']) < 8) {
|
||||
notify("Passordet må være minst 8 tegn.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
}
|
||||
if ($data['password1'] != $data['password2']) {
|
||||
notify("Passordene var ikke like.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
}
|
||||
$this->password = $data['password1'];
|
||||
if (!isAdmin()) {
|
||||
switch (checkForumUsername($data['username'], $this->password)) {
|
||||
case "wrong-password" :
|
||||
notify("Brukernavnet er allerede i bruk på forumet. " . "Om du selv har dette brukernavnet må du oppgi " . "riktig passord.");
|
||||
$this->id = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -66,7 +66,6 @@ require_once "Messages.php";
|
||||
require_once "MemberCard.php";
|
||||
require_once "MembershipActivationCode.php";
|
||||
require_once "Navigation.php";
|
||||
require_once "Nordea.php";
|
||||
require_once "Order.php";
|
||||
//require_once "Orders.php";
|
||||
require_once "OrderStatuses.php";
|
||||
@@ -236,4 +235,4 @@ $sections = Array("display-barshifts" => "barshifts",
|
||||
"week-program" => "concerts"
|
||||
);
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in new issue
Block a user