public function deactivate($contractor_id) { $criteria = new CDbCriteria(); $criteria->condition = "user_type='contractor' AND userid=" . $contractor_id; Affiliates::model()->deleteAll($criteria); Referral::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "owner_user_type='contractor' AND owner_id=" . $contractor_id; Answers::model()->deleteAll($criteria); Questions::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "user_type='contractor' AND deleted_by=" . $contractor_id; Messagedeleted::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "from_user_type='contractor' AND from_id=" . $contractor_id; Messages::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "to_user_type='contractor' AND to_id=" . $contractor_id; Messages::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "viewed_user_type='contractor' AND viewed_by=" . $contractor_id; QuestionViews::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "referred_by_type='contractor' AND referred_by=" . $contractor_id; Referral::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "invited_id=" . $contractor_id; ContractorTeam::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "contractor_id=" . $contractor_id; ContractorBond::model()->deleteAll($criteria); ContractorLicense::model()->deleteAll($criteria); ContractorPoints::model()->deleteAll($criteria); ContractorSocials::model()->deleteAll($criteria); ContractorTeam::model()->deleteAll($criteria); ContractorViews::model()->deleteAll($criteria); Contractorphotos::model()->deleteAll($criteria); Feedback::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "ContractorId=" . $contractor_id; self::model()->deleteAll($criteria); return true; }
public function deactivate($homeowner_id) { $criteria = new CDbCriteria(); $criteria->condition = "user_type='homeowner' AND userid=" . $homeowner_id; Affiliates::model()->deleteAll($criteria); Referral::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "owner_user_type='homeowner' AND owner_id=" . $homeowner_id; Answers::model()->deleteAll($criteria); Questions::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "user_type='homeowner' AND deleted_by=" . $homeowner_id; Messagedeleted::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "from_user_type='homeowner' AND from_id=" . $homeowner_id; Messages::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "to_user_type='homeowner' AND to_id=" . $homeowner_id; Messages::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "project_id NOT IN (Select project_id from projects where homeowner_id = {$homeowner_id} )"; Projectphotos::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "viewed_user_type='homeowner' AND viewed_by=" . $homeowner_id; QuestionViews::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "referred_by_type='homeowner' AND referred_by=" . $homeowner_id; Referral::model()->deleteAll($criteria); $criteria = new CDbCriteria(); $criteria->condition = "homeowner_id=" . $homeowner_id; HomeownerPoints::model()->deleteAll($criteria); Feedback::model()->deleteAll($criteria); HomeownerViews::model()->deleteAll($criteria); Projects::model()->deleteAll($criteria); self::model()->deleteAll($criteria); return true; }
public function deletequestion($post) { $id = $post['id']; $question = Questions::model()->findByPk($id); $question->delete(); $criteria = new CDbCriteria(); $criteria->condition = 'question_id = ' . $id; Answers::model()->deleteAll($criteria); QuestionViews::model()->deleteAll($criteria); QuestionVotes::model()->deleteAll($criteria); $return['status'] = true; $this->renderJSON($return, true); }