public function delete() { $post = $this->input->post(); if ($post) { $ids = array_filter(explode(",", $post['id'])); foreach ($ids as $id) { $cladArr = $imgArr = $this->common_model->selectData(CLASSIFIEDAD, '*', array("clad_id" => $id)); //pr($imgArr,9); if (!empty($imgArr)) { $imglist = $imgArr[0]->clad_image; if ($imglist != '') { $imgArr = array_filter(explode(',', $imglist)); foreach ($imgArr as $k => $v) { removeAdImgs($v); /*if(file_exists(DOC_ROOT_CLASSIFIED_AD.$v)) unlink(DOC_ROOT_CLASSIFIED_AD.$v);*/ } } } $uData = $this->common_model->selectData(USER, '*', array("u_id" => $cladArr[0]->clad_uid)); //pr($uData,9); //$ret = $this->common_model->deleteData(CLASSIFIEDAD, array('clad_id' => $id )); $curDate = date('Y-m-d H:i:s'); $where = 'clad_id = ' . $id; $param = array('clad_active' => 0, 'is_deleted' => 1, 'clad_image' => '', 'clad_modified_date' => $curDate); $ret = $this->common_model->updateData(CLASSIFIEDAD, $param, $where); if ($ret > 0) { ## send mail n sms to owner $uName = $uData[0]->u_fname ? $uData[0]->u_fname : ''; $uEmail = $uData[0]->u_email ? $uData[0]->u_email : ''; if ($uEmail != '') { $emailTpl = $this->load->view('email_templates/addeletenotification', array('name' => $uName, 'adtitle' => $cladArr[0]->clad_title, 'adid' => $post['id']), true); $retemail = sendEmail($uEmail, SUBJECT_ADDELETE_INFO, $emailTpl, FROM_EMAIL, FROM_NAME); } ## Send sms to seller $phonemsg = AD_DELETE_NOTIFICATION; ## take msg content from constant $phonemsg = str_replace('{name}', $cnt, $phonemsg); $phonemsg = str_replace('{clad_id}', "#" . $post['id'], $phonemsg); $phonemsg = str_replace('{clad_title}', $cladArr[0]->clad_title, $phonemsg); $response = connectMobile($phonemsg, $uData[0]->u_mobile); $res = json_decode($response->raw_body, true); } } if ($ret > 0) { echo "success"; } else { echo "error"; } } }
public function delete() { $post = $this->input->post(); if ($post) { $ids = array_filter(explode(",", $post['id'])); foreach ($ids as $id) { /*Remove ad images*/ $adImgList = $this->common_model->selectData(CLASSIFIEDAD, 'clad_id,clad_image', array("clad_uid" => $id)); $adId = array(); foreach ($adImgList as $obj) { $adId[] = $obj->clad_id; $imgs = array_filter(explode(",", $obj->clad_image)); foreach ($imgs as $img) { removeAdImgs($img); } } /*Remove report abuse entry*/ if (count($adId) > 0) { $this->common_model->deleteData(REPORTAD, "report_clad_id in (" . implode(",", $adId) . ")"); } /*Remove ad from database*/ $this->common_model->deleteData(CLASSIFIEDAD, array("clad_uid" => $id)); /*Remove fav ad from database*/ $this->common_model->deleteData(FAVOURITE, array("fav_uid" => $id)); /*Update uid to 0 in message table*/ $this->common_model->deleteData(MESSAGE, array("ad_msg_from" => $id)); $this->common_model->deleteData(MESSAGE, array("ad_msg_to" => $id)); /*Remove device entry from database*/ $this->common_model->deleteData(DEVICE, array("userid" => $id)); /*Remove login history from database*/ $this->common_model->deleteData(LOGINHISTORY, array("uid" => $id)); /*Remove user from database*/ $ret = $this->common_model->deleteData(USER, array('u_id' => $id)); } if ($ret > 0) { echo "success"; } else { echo "error"; } } }