/** * Commits the request if all the files have * been dealt with */ private function commitRequest($request_id) { if (!Yii::$app->user->can("admin")) { throw new HttpException(403, 'You are not allowed to perform this action.'); } $requests = RequestFile::find()->where(['request_id' => $request_id])->andWhere(['granted' => NULL])->all(); if (sizeof($requests) == 0) { $request = Request::find()->where(['id' => $request_id])->one(); $request->committed = 1; $request->save(); } }
/** * @return \yii\db\ActiveQuery */ public function getRequestFiles() { return $this->hasMany(RequestFile::className(), ['request_id' => 'id']); }
</script> <?php foreach ($files as $f) { ?> <div id="filegroup_<?php echo $f->id; ?> " class="filegroup"> <?php $showform = 1; $status = ""; $rqf = RequestFile::find()->where(['file_id' => $f->id, 'request_id' => $request->id])->one(); if ($rqf !== NULL) { switch ($rqf->granted) { case "1": $showform = 0; $status = "allowed"; break; case "0": $status = "denied"; $showform = 0; break; } } //print "<pre>" . $showform . " " . $rqf->granted ."</pre>"; ?> <div>File: <?php