public function get_all()
 {
     //ARRAY OBJECT HARU PASS GARNA
     $user_list = array();
     //DATABASE CONNECTION
     $this->db->connect();
     //SELECT ALL QUERY
     $sql = "SELECT user_id,user_name,first_name,last_name,contact_number,user_type,user_status,gen_id,age FROM user INNER JOIN generaluser ON user_id = u_id";
     //fetchquery
     $result = $this->db->fetchquery($sql);
     //STORE IN OBJECT AND SEND TO VIEW
     while ($row = $result->fetch_assoc()) {
         $user = new User();
         $user->set_user_id($row['user_id']);
         $user->set_user_name($row['user_name']);
         $user->set_first_name($row['first_name']);
         $user->set_last_name($row['last_name']);
         $user->set_contact_number($row['contact_number']);
         $user->set_user_type($row['user_type']);
         $user->set_user_status($row['user_status']);
         array_push($user_list, $user);
     }
     $this->db->close();
     return $user_list;
 }
Example #2
0
 public function get_by_id($id)
 {
     $user = null;
     //DATABASE CONNECTION
     $this->db->connect();
     //SELECT BY ID
     $sql = "SELECT * FROM user WHERE user_id=?";
     //PREPARE
     $stmt = $this->db->initialize($sql);
     //BIND
     $stmt->bind_param("i", $id);
     //EXECUTE
     $stmt->execute();
     //BIND RESULT
     $stmt->bind_result($user_id, $user_name, $first_name, $last_name, $contact_number, $user_type, $user_status);
     while ($stmt->fetch()) {
         //instantiate object
         $user = new User();
         $user->set_user_id($user_id);
         $user->set_user_name($user_name);
         $user->set_first_name($first_name);
         $user->set_last_name($last_name);
         $user->set_contact_number($contact_number);
         $user->set_user_type($user_type);
         $user->set_user_status($user_status);
     }
     $this->db->close();
     return $user;
 }
 public function get_all()
 {
     //ARRAY OBJECT HARU PASS GARNA
     $user_list = array();
     //DATABASE CONNECTION
     $this->db->connect();
     //SELECT ALL QUERY
     $sql = "SELECT user_id,user_name,first_name,last_name,contact_number,user_type,user_status,name,doe,img,address,service,objective FROM user INNER JOIN welfare ON user_id = u_id";
     //fetchquery
     $result = $this->db->fetchquery($sql);
     //STORE IN OBJECT AND SEND TO VIEW
     while ($row = $result->fetch_assoc()) {
         $user = new User();
         $user->set_user_id($row['user_id']);
         $user->set_user_name($row['user_name']);
         $user->set_first_name($row['first_name']);
         $user->set_last_name($row['last_name']);
         $user->set_contact_number($row['contact_number']);
         $user->set_user_type($row['user_type']);
         $user->set_user_status($row['user_status']);
         $user->set_welf_name($row['name']);
         $user->set_welf_doe($row['doe']);
         $user->set_welf_img($row['img']);
         $user->set_welf_address($row['address']);
         $user->set_welf_objective($row['objective']);
         $user->set_welf_service($row['service']);
         array_push($user_list, $user);
     }
     $this->db->close();
     return $user_list;
 }
Example #4
0
 private function _map_posted_data()
 {
     $user = new User();
     $user->set_user_name($_POST['user_name']);
     $user->set_first_name($_POST['first_name']);
     $user->set_last_name($_POST['last_name']);
     $user->set_contact_number($_POST['contact_number']);
     $user->set_user_type($_POST['user_type']);
     $user->set_user_status($_POST['user_status']);
     return $user;
 }
Example #5
0
 function authenticate_user($user_name, $user_pass)
 {
     // First determine if this is a local or ldap user
     if ($this->is_local_user($user_name, 'local')) {
         return $this->authenticate_local_user($user_name, $user_pass);
     } else {
         if (!($user_info = $this->authenticate_ldap_user($user_name, $user_pass))) {
             // Auth failed
             return false;
         }
         // Userinfo is an array which hold email and full name
         // Ok user is success fully authenticated
         // create user object and update / insert
         if (!($userid = $this->is_local_user($user_name, 'ldap'))) {
             $ldap_user = new User();
             $ldap_user->set_full_name($user_info["fullname"]);
             $ldap_user->set_email($user_info["email"]);
             $ldap_user->set_user_name($user_name);
             $ldap_user->set_user_type('ldap');
             // New user insert in local user
             if (!($userid = $ldap_user->insert())) {
                 // Unable to update local user cache
                 $this->error = $ldap_user->get_error();
                 return false;
             }
             // existing  user update in local user cache
         } else {
             $ldap_user = new User($userid);
             $ldap_user->set_full_name($user_info["fullname"]);
             $ldap_user->set_email($user_info["email"]);
             $ldap_user->set_user_name($user_name);
             $ldap_user->set_user_type('ldap');
             if (!$ldap_user->update()) {
                 // Unable to update local user cache
                 $this->error = $ldap_user->get_error();
                 return false;
             }
         }
         // get groups
         if (!($ldap_groups = $this->get_ldap_groups($user_name, $user_pass))) {
             return false;
         }
         if (!$this->update_ldap_groups($userid, $ldap_groups)) {
             // Unable to update local group cache
             return false;
         }
         return true;
     }
 }
Example #6
0
 private function _map_posted_data()
 {
     $user = new User();
     $user->set_user_name($_POST['user_name']);
     $user->set_first_name($_POST['first_name']);
     $user->set_last_name($_POST['last_name']);
     $user->set_contact_number($_POST['contact_number']);
     if (isset($_POST['user_type'])) {
         $user->set_user_type($_POST['user_type']);
     }
     $user->set_user_status($_POST['user_status']);
     if (isset($_POST['password'])) {
         $user->set_password($_POST['password']);
     }
     if ($_POST['user_type'] == 'organization') {
         $user->set_name($_POST['name']);
         $user->set_doe($_POST['doe']);
         $user->set_address($_POST['address']);
         $user->set_objective($_POST['objective']);
         //store file
         $filename = $_FILES['img']['name'];
         $path = PUBLIC_PATH . "/pictures/orgPictures/";
         move_uploaded_file($_FILES['img']['tmp_name'], $path . $filename);
         $savepath = PUBLIC_PATH2 . "/pictures/orgPictures/";
         $user->set_img($savepath . $filename);
     } elseif ($_POST['user_type'] == 'welfare') {
         $user->set_welf_name($_POST['welf_name']);
         $user->set_welf_doe($_POST['welf_doe']);
         $user->set_welf_service($_POST['welf_service']);
         $user->set_welf_address($_POST['welf_address']);
         $user->set_welf_objective($_POST['welf_objective']);
         //store file
         $filename = $_FILES['img']['name'];
         $path = PUBLIC_PATH . "/pictures/welfPictures/";
         move_uploaded_file($_FILES['img']['tmp_name'], $path . $filename);
         $savepath = PUBLIC_PATH2 . "/pictures/welfPictures/";
         $user->set_welf_img($savepath . $filename);
     }
     return $user;
 }
Example #7
0
function updateUser()
{
    global $tool, $propertyForm;
    $tempInfo = array();
    $infoKey = array("id", "full", "user", "email");
    foreach ($infoKey as $index => $key) {
        $tempInfo[$key] = htmlspecialchars(trim($_POST[$key]), ENT_QUOTES);
    }
    //add slashes to these 2 to make sure it does not display wrongly
    $tempInfo[user] = addslashes($tempInfo[user]);
    $tempInfo[full] = addslashes($tempInfo[full]);
    $newUser = new User($tempInfo[id]);
    //checks if the name is empty, if not set all the names and insert them
    if ($newUser->set_user_name($tempInfo[user])) {
        //set all the values to the query
        $newUser->set_full_name($tempInfo[full]);
        $newUser->set_email($tempInfo[email]);
        //if the insert is sucessful reload the page with the new values
        if ($newUser->update()) {
            $status = "success";
            echo "<script language='javascript'>LoadPage(\"configurations.php?action=userManage&mode=edit&update=" . $status . "\", 'settingsInfo');</script>";
            //echo "<meta http-equiv=\"REFRESH\" content=\"0;url=".$_SERVER['PHP_SELF']."?action=userManage&add=$status\">";
        } else {
            $propertyForm->error("Warning: Failed to update user. Reason: " . $newUser->get_error(), $_GET['ID']);
        }
    } else {
        $propertyForm->error("Warning: Failed to update user. Reason: " . $newUser->get_error(), $_GET['ID']);
    }
}