getProfil($id); $data['info']['Fakultas'] = cvFakultas($data['info']['Fakultas']); //all status $data['post'] = $u->getStatus($id); //count friend $data['cFriend'] = $u->getcountfriend($id); //list friend $data['Friend'] = $u->getFriend($id); //status friend $a = $u->statusFriend($id); if ($a<3){ if ($a==0)$data['sFriend']='Request Sent'; elseif ($a==1)$data['sFriend']='Friend'; else $data['sFriend']='Add Friend'; } //community joined $data['comm'] = $u->getCommunity($id); //buat cek database error unset($_SESSION['notif-warning']); //$_SESSION['notif-warning'] = $u->getSqlerr(); return $data; } function addFriend($id){ $u = new User(); if ($u->addFriend($id))header('Location: profile.php?id='.$id); else echo 'gagal'; } function update(){ $u = new User(); $data = array( 'status' => $_POST['status'], 'user' => $_SESSION['username'] ); if (isset($_POST['idu']))$data['to'] = $_POST['idu']; if(empty($data['to'])){ if ($u->insertPost($data))header('Location: profile.php?id='.$_SESSION['username']); else echo 'gagal'; }else{ if ($u->writetowall($data))header('Location: profile.php?id='.$data['to']); else echo 'gagal'; } } function editProfile($id){ $u = new User(); return $u->getProfil($id); } function cedit(){ $u = new User(); $data = array( 'nama' => $_POST['name'], 'dob' => date("Y-m-d",strtotime($_POST['dob'])), 'telp' => $_POST['telp'], 'address' => $_POST['address'], 'hometown' => $_POST['hometown'], 'fakultas' => $_POST['fakultas'], 'jurusan' => $_POST['jurusan'], 'angkatan' => $_POST['angkatan'], 'kelas' => $_POST['kelas'], 'relationship' => $_POST['relati'], 'user' => $_SESSION['username'], 'id' => $_POST['idprof'] ); if ($u->updateProfil($data)){ //echo ' insert bisa '; unset($_SESSION['notif-alert']); if (!empty($_FILES['file']['name'])){ $foto = new Foto($_FILES); if ($foto->update($_SESSION['username'])){ $hasil = $foto->getHasil(); $photo = $hasil['lokasi']; //echo $photo; if($u->inputAvatar($photo,$_POST['idprof']))header('Location: profile.php?id='.$_SESSION['username']); }else { $_SESSION['notif-alert'] = 'Foto yang anda Masukkan Salah'; header('Location: profile.php?action=edit&id='.$_SESSION['username']); } } else header('Location: profile.php?id='.$_SESSION['username']); } else{ $_SESSION['notif-alert'] = 'Periksa kembali inputan'; header('Location: profile.php?action=edit&id='.$_SESSION['username']); } } function isFriend($id1,$id2){ $u = new User(); return $u->isFriend($id1,$id2); } function ajaxedit(){ $data = array( 'nama' => $_POST['name'], 'dob' => date("Y-m-d",strtotime($_POST['dob'])), 'address' => $_POST['address'], 'hometown' => $_POST['hometown'], 'fakultas' => $_POST['fakultas'], 'jurusan' => $_POST['jurusan'], 'angkatan' => $_POST['angkatan'], 'user' => $_SESSION['username'] ); $u = new User(); if ($u->updtae($data))echo 'sukses'; } function singleupdate($row){ } ?>