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 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); }
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 actionDetails() { $can_vote = false; $q_id = Yii::app()->Ini->v('id'); $question = Questions::model()->findByPk($q_id); if (!Yii::app()->user->isGuest) { $viewed_by = Yii::app()->user->getId(); $viewed_user_type = Yii::app()->user->role; $vote = QuestionVotes::model()->countByAttributes(array('question_id' => $q_id, 'voted_by' => $viewed_by, 'voted_user_type' => $viewed_user_type)); if ($vote == 0 && ($question->owner_id != $viewed_by && $question->owner_user_type != $viewed_user_type)) { $can_vote = true; } } else { $viewed_by = 0; $viewed_user_type = 'guest'; } $view = new QuestionViews(); $view->question_id = $q_id; $view->viewed_by = $viewed_by; $view->viewed_user_type = $viewed_user_type; $view->save(); $pie = new SimplePie(); $pie->set_feed_url('http://media.handyman.com/feed/'); $pie->init(); $pie->handle_content_type(); $param['feed'] = $pie; $this->pageTitle = 'Handyman.com Answers - ' . $question->title; $param['question'] = $question; $param['sidecats'] = Projecttypes::model()->findAll(array('order' => 'Name ASC')); $param['can_vote'] = $can_vote; $this->render('details', $param); }