Exemple #1
0
 public static function getUsersModules()
 {
     $modules = Modules::find();
     $modules->join('inner join', 'users_modules', 'modules.id = users_modules.module_id');
     $modules->where(['users_modules.user_id' => Yii::$app->user->id]);
     return $modules->all();
 }
 public function actionUninstall()
 {
     //TODO 增加返回值及错误返回
     $moduleId = \Yii::$app->request->get('moduleId', null);
     if (Modules::findOne((int) $moduleId)->delete()) {
         return true;
     }
 }
 public function actionSwitch($module, $disabled = 1)
 {
     //TODO 增加返回值及错误返回
     $moduleModel = Modules::findOne($module);
     if ($moduleModel && (int) $moduleModel->disabled !== $disabled) {
         $moduleModel->disabled = (int) $disabled;
         $moduleModel->update(false, ['disabled']);
     }
 }
Exemple #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getModules()
 {
     return $this->hasMany(Modules::className(), ['id' => 'module_id'])->viaTable('phpci_modules_projects', ['project_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getModule()
 {
     return $this->hasOne(Modules::className(), ['id' => 'module_id']);
 }
 /**
  * Get All Modules From DB
  *
  * @return array|\yii\db\ActiveRecord[]
  */
 public function installedModules()
 {
     return Modules::find()->asArray()->indexBy('module')->all();
 }