/**
  * Create new project group.
  *
  * @param string      $name     Name project
  * @param string      $alias    Folder alias
  * @param string      $project  Project ID
  */
 public function actionCreate($name, $alias, $project)
 {
     if (($project = Project::findOne($project)) !== 0) {
         $mod = \Yii::createObject(['class' => ProjectMod::className(), 'name' => $name, 'alias' => $alias]);
         $mod->link('project', $project);
         if ($mod->save()) {
             $this->stdout('Project modification has been created' . "!\n", Console::FG_GREEN);
         } else {
             $this->stdout('Please fix following errors:' . "\n", Console::FG_RED);
             foreach ($mod->errors as $errors) {
                 foreach ($errors as $error) {
                     $this->stdout(" - " . $error . "\n", Console::FG_RED);
                 }
             }
         }
     } else {
         $this->stdout('Invalid project' . "\n", Console::FG_RED);
     }
 }
Exemplo n.º 2
0
 public function actionDeletefile()
 {
     if (!Yii::$app->request->isPost || !isset($_POST['Release']) || !isset($_POST['Release']['file_name']) || !isset($_POST['Release']['mod_id'])) {
         throw new yii\web\BadRequestHttpException();
     }
     if (!Yii::$app->user->can('deleteReleaseFile')) {
         throw new yii\web\ForbiddenHttpException();
     }
     if (($model = ProjectMod::findOne($_POST['Release']['mod_id'])) === null) {
         throw new NotFoundHttpException('Not found project modification.');
     }
     $release = Release::findOne(['mod_id' => $model->id, 'file_name' => $_POST['Release']['file_name']]);
     if ($release === null) {
         $a = $model->getModule()->basePathReleases;
         $b = $model->getFullAlias();
         $file = Yii::getAlias($model->getModule()->basePathReleases) . '/' . $model->getFullAlias() . '/' . $_POST['Release']['file_name'];
         unlink($file);
         Yii::$app->session->setFlash('release-status', ['success', 'Success', 'File has been deleted.']);
     } else {
         Yii::$app->session->setFlash('release-status', ['warning', 'Error', 'Deleting failed.']);
     }
     return $this->actionView($model->project->group->alias, $model->project->alias, $model->alias);
 }