/** * Finds the UserListType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserListType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserListType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserListType::find()->where('status!=0'); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'userType' => $this->userType, 'userId' => $this->userId, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'status' => $this->status]); $query->andFilterWhere(['like', 'reason', $this->reason])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
public static function EventActionDelete($event) { //echo get_class($event->sender) . ' is inserted'; //$modelClass=get_class($event->sender); //$data=array(); //$data=$datamodel::findOne($id)->getAttributes(); $data = array(); $modelClass = get_class($event->sender); //$data= $event->sender->getAttributes(); $data_attribute = $event->sender->getAttributes(); $data_toarray = $event->sender->toArray(); $data = self::ToArrayAttributeDataMerger($data_toarray, $data_attribute); //echo "<pre>"; //var_dump($data_attribute); //var_dump($data_toarray); //var_dump($data); $id = $data['Id']; if (!self::checkPublishStatus($modelClass)) { try { switch ($modelClass) { case 'common\\models\\UserListType': $dataUser = array(); // \Yii::trace(print_r($data,true),__METHOD__); $modelClass = get_class($event->sender); $dataUser = UserListType::find()->where(['userType' => 1])->all(); $userDataString = ''; for ($i = 0; $i < count($dataUser); $i++) { $userDataString .= $dataUser[$i]['userId'] . ','; } $userDataString = substr($userDataString, 0, -1); // \Yii::trace(print_r($dataUser,true),__METHOD__); //\yii::trace('event dfsdfsdf dfdsf: '.$userDataString.' '.__METHOD__,' event'); $userData = array(); $userFlag = ''; $userFlag = 'blacklisted_review_users'; $userData['variable_name'] = $userFlag; $userData['data'] = $userDataString; $where = "variable_name='" . $userFlag . "'"; $masterWrite = new MasterWrite(); $result = $masterWrite->saveUserType($userData, 'UPDATE', $where); ##################################################### $dataUser = array(); // \Yii::trace(print_r($data,true),__METHOD__); $modelClass = get_class($event->sender); $dataUser = UserListType::find()->where(['userType' => 2])->all(); $userDataString = ''; for ($i = 0; $i < count($dataUser); $i++) { $userDataString .= $dataUser[$i]['userId'] . ','; } $userDataString = substr($userDataString, 0, -1); // \Yii::trace(print_r($dataUser,true),__METHOD__); //\yii::trace('event dfsdfsdf dfdsf: '.$userDataString.' '.__METHOD__,' event'); $userData = array(); $userFlag = ''; $userFlag = 'whitelisted_review_users'; $userData['variable_name'] = $userFlag; $userData['data'] = $userDataString; $where = "variable_name='" . $userFlag . "'"; $masterWrite = new MasterWrite(); $result = $masterWrite->saveUserType($userData, 'UPDATE', $where); default: } } catch (\Exception $e) { $message = 'Error in Update ' . $modelClass . ' ' . $id . ' ' . $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine(); $lockText = date('Y-m-d H:i:s') . ' - ' . $message . "\n"; Yii::error($lockText, 'writemodel'); //self::WriteModelErrorLogging($message); } } }