Add room lock
Took 5 minutes
This commit is contained in:
parent
5424a99a0a
commit
c957eae3bb
26
.idea/workspace.xml
generated
26
.idea/workspace.xml
generated
@ -21,8 +21,9 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="fc13552d-b118-4828-b78f-fc8714e0cfdc" name="Default Changelist" comment="Final COMMIT!!!">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/templates/faq.tmpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/faq.tmpl.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/vendor/js/faq.js" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/js/faq.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/controller/FaqController.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/controller/FaqController.class.inc.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/model/FaqModel.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/model/FaqModel.class.inc.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/views/Apitemplate.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/views/Apitemplate.class.inc.php" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -33,7 +34,7 @@
|
||||
<execution />
|
||||
</component>
|
||||
<component name="DarkyenusTimeTracker">
|
||||
<option name="totalTimeSeconds" value="92688" />
|
||||
<option name="totalTimeSeconds" value="93042" />
|
||||
<option name="gitIntegration" value="true" />
|
||||
<option name="naggedAbout" value="1" />
|
||||
</component>
|
||||
@ -79,7 +80,7 @@
|
||||
<updated>1601618466935</updated>
|
||||
<workItem from="1601618467981" duration="36776000" />
|
||||
<workItem from="1601809534320" duration="1558000" />
|
||||
<workItem from="1601811106543" duration="27303000" />
|
||||
<workItem from="1601811106543" duration="27722000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Initial commit">
|
||||
<created>1601618764031</created>
|
||||
@ -326,7 +327,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1601915871071</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="36" />
|
||||
<task id="LOCAL-00036" summary="Correct spelling">
|
||||
<created>1601919457161</created>
|
||||
<option name="number" value="00036" />
|
||||
<option name="presentableId" value="LOCAL-00036" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1601919457161</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="37" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -345,7 +353,6 @@
|
||||
<option name="oldMeFiltersMigrated" value="true" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Should be the final commit" />
|
||||
<MESSAGE value=" Updating database-conf" />
|
||||
<MESSAGE value="Final COMMIT!!!" />
|
||||
<MESSAGE value="Fix issue #1" />
|
||||
@ -370,7 +377,8 @@
|
||||
<MESSAGE value="Performance update, add setup for refresh rate" />
|
||||
<MESSAGE value="Update optionsModal" />
|
||||
<MESSAGE value="increase answer size" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="increase answer size" />
|
||||
<MESSAGE value="Correct spelling" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Correct spelling" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="728" y="326" width="800" height="683" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1601632929047">
|
||||
@ -409,10 +417,10 @@
|
||||
<screen x="0" y="34" width="1920" height="1046" />
|
||||
</state>
|
||||
<state x="441" y="192" width="1037" height="736" key="SettingsEditor/0.34.1920.1046@0.34.1920.1046" timestamp="1601632853044" />
|
||||
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2" timestamp="1601915872297">
|
||||
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2" timestamp="1601919458785">
|
||||
<screen x="0" y="34" width="1920" height="1046" />
|
||||
</state>
|
||||
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601915872297" />
|
||||
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601919458785" />
|
||||
<state x="809" y="122" width="639" height="876" key="com.intellij.database.view.ui.AbstractDbRefactoringDialog" timestamp="1601632983240">
|
||||
<screen x="0" y="34" width="1920" height="1046" />
|
||||
</state>
|
||||
|
@ -26,6 +26,7 @@ class FaqController extends DefaultController
|
||||
$questions = $FAQModel->getQuestions( $room['id'] );
|
||||
|
||||
$view->setResponse( array( 'questions' => $questions ) );
|
||||
$view->setSuccess( true );
|
||||
|
||||
return $view->getResponse();
|
||||
}
|
||||
@ -71,6 +72,13 @@ class FaqController extends DefaultController
|
||||
return $view->getResponse();
|
||||
}
|
||||
|
||||
if( $FAQModel->checkRoomLock( $room ) )
|
||||
{
|
||||
$view->setSuccess( false );
|
||||
$view->setHeaderCode( 910 );
|
||||
return $view->getResponse();
|
||||
}
|
||||
|
||||
try {
|
||||
$FAQModel->addQuestion( $room['id'], $question, $nickname );
|
||||
} catch( Exception $e )
|
||||
@ -101,6 +109,13 @@ class FaqController extends DefaultController
|
||||
return $view->getResponse();
|
||||
}
|
||||
|
||||
if( $FAQModel->checkRoomLock( $room ) )
|
||||
{
|
||||
$view->setSuccess( false );
|
||||
$view->setHeaderCode( 910 );
|
||||
return $view->getResponse();
|
||||
}
|
||||
|
||||
try {
|
||||
$FAQModel->addAnswer( $question_id, $answer );
|
||||
} catch( Exception $e )
|
||||
|
@ -94,6 +94,25 @@ class FaqModel
|
||||
|
||||
}
|
||||
|
||||
public function checkRoomLock( array $a_room )
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'SELECT locked FROM rooms WHERE id = :id' );
|
||||
$stmnt->execute( array( 'id' => $a_room['id'] ) );
|
||||
$result = $stmnt->fetch( PDO::FETCH_ASSOC );
|
||||
|
||||
if( $result === false || empty( $result ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( (bool)$result['locked'] === true ) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkUserIsRoomOwner( array $a_room )
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'SELECT id, owner_sid FROM rooms WHERE id = :id' );
|
||||
|
@ -37,6 +37,7 @@ class Apitemplate
|
||||
903 => 'wrong-parameters-given',
|
||||
905 => 'User-is-not-owner',
|
||||
906 => 'Question-does-not-exist',
|
||||
910 => 'room-is-locked'
|
||||
);
|
||||
$text = isset( $codes[$a_code] ) ? $codes[$a_code] : "Error";
|
||||
header("HTTP/1.1 $a_code $text" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user