コード例 #1
0
 /**
  * @param $formData
  */
 public function editUserDetails($formData)
 {
     if ($this->checkUserProfile()) {
         $type = $this->encrypt->decode($formData['type']);
         $this->db->where('user_id', $this->session->userdata('authorId'));
         switch ($type) {
             case 'about':
                 $this->db->update('user_profiles', ['about' => $formData['about']]);
                 break;
             case 'summary':
                 $this->db->update('user_profiles', ['summary' => $formData['summary']]);
                 break;
             case 'email':
                 $this->db->update('user_profiles', ['email' => $formData['email']]);
                 break;
             case 'mobile':
                 $this->db->update('user_profiles', ['mobile' => $formData['mobile']]);
                 break;
             case 'featured_image':
                 $folderPath = FCPATH . 'img/users/' . $this->session->userdata('authorUsername');
                 # get the file name from the database and delete the file from the location
                 $fileName = $this->_getData('user_profiles', ['user_id' => $this->session->userdata('authorId')], 'featured_image');
                 # Check if file exists on server
                 if (file_exists(FCPATH . $fileName[0]['featured_image'])) {
                     unlink(FCPATH . $fileName[0]['featured_image']);
                 }
                 $fileName = "";
                 # Check if the folder path exists otherwise create it
                 if (!is_dir($folderPath)) {
                     mkdir($folderPath, 0777, true);
                 }
                 # Set the file configuration
                 $config['upload_path'] = FCPATH . 'img/users/' . $this->session->userdata('authorUsername');
                 $config['allowed_types'] = 'gif|jpg|png';
                 $config['encrypt_name'] = TRUE;
                 $this->load->library('upload', $config);
                 if (!$this->upload->do_upload('featured_image')) {
                     $error = array('error' => $this->upload->display_errors());
                     var_dump($error);
                     die;
                 } else {
                     $data = array('upload_data' => $this->upload->data());
                     $fileUrl = 'img/users/' . $this->session->userdata('authorUsername') . '/' . $data['upload_data']['file_name'];
                     $this->db->update('user_profiles', ['featured_image' => $fileUrl]);
                 }
                 break;
             default:
                 return false;
                 break;
         }
         $affectedRowsCount = $this->db->affected_rows();
         if ($affectedRowsCount == 1) {
             return true;
         }
     }
     $this->db->insert('user_profiles', ['user_id' => $this->session->authorId]);
     editUserDetails($formData);
 }
コード例 #2
0
    $adminId = 'e-002';
    // need to be send in request..for time being using hardcoded values.
    $fullName = $userFname . ' ' . $userLname;
    //$Mobile = $_REQUEST['Phone'];
    $rm = new Response_Methods();
    if ($userFname == "" || $userLname == "" || $age == "" || $sex == "" || $emailId == "" || $address == "" || $userType == "" || $userID == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getRegisterFieldValue['user_fname'] = $userFname;
        $getRegisterFieldValue['user_lname'] = $userLname;
        $getRegisterFieldValue['user_age'] = $age;
        $getRegisterFieldValue['user_sex'] = $sex;
        $getRegisterFieldValue['user_email_id'] = $emailId;
        $getRegisterFieldValue['user_address'] = $address;
        $getRegisterFieldValue['last_modified_date'] = $createdDate;
        //$lastInserted_user_id=$rm->insert_record($getRegisterFieldValue,'user_details_t');
        $affectedRows = $rm->update_record($getRegisterFieldValue, 'user_details_t', 'user_id', $userID);
        if ($affectedRows >= 0) {
            $result = $rm->userModifiedSuccess();
            return $result;
        } else {
            $result = $rm->userModifiedFail();
            return $result;
        }
    }
}
echo editUserDetails();