Exemplo n.º 1
0
 public function actionSelect($app_id, $app_secret)
 {
     $session = Yii::$app->session;
     $model = App::findOne(['app_id' => $app_id, 'app_secret' => $app_secret]);
     if (!Yii::$app->user->can('app_' . $model->app_code)) {
         throw new ForbiddenHttpException('没有该项目权限');
     }
     $session['api_url'] = $model->api_url;
     $session['app_code'] = $model->app_code;
     $session['app_name'] = $model->app_name;
     $this->redirect(['main/add']);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = App::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'cp_id' => $this->cp_id, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'app_name', $this->app_name])->andFilterWhere(['like', 'app_id', $this->app_id])->andFilterWhere(['like', 'app_secret', $this->app_secret])->andFilterWhere(['like', 'app_code', $this->app_code])->andFilterWhere(['like', 'version', $this->version]);
     $query->andWhere(['in', 'app_code', Tools::getPrevApp()]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getApp()
 {
     return $this->hasOne(App::className(), ['id' => 'app_id']);
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getApps()
 {
     return $this->hasMany(App::className(), ['cp_id' => 'id']);
 }
Exemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function controlAttributes()
 {
     return [['id' => 'basic', 'name' => '基本属性', 'attributes' => ['name' => ['type' => 'text'], 'parent_id' => ['type' => 'tree', 'pkAttrName' => 'menu_id', 'showAttrName' => 'name', 'items' => function () {
         return static::find()->asArray()->all();
     }, 'topItem' => [0 => '顶级菜单']], 'app' => ['type' => 'dropDown', 'items' => [App::className(), 'getAppsItems']], 'module' => ['type' => 'text'], 'controller' => ['type' => 'text'], 'action' => ['type' => 'text'], 'params' => ['type' => 'text', 'hint' => '额外附加到生成地址的参数,比如a=1&b=2'], 'sort' => ['type' => 'text'], 'type' => ['type' => 'dropDown', 'items' => [static::className(), 'getTypeItems']], 'auth_rules' => ['type' => 'checkbox', 'items' => [Auth::className(), 'getRuleItems']], 'remark' => ['type' => 'textarea'], 'status' => ['type' => 'radio', 'items' => [static::className(), 'getStatusItems']]]]];
 }
Exemplo n.º 6
0
 /**
  * Finds the App model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return App the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = App::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }