public function actionSendChallenge() { if (isset($_POST['idUser'], $_POST['private'], $_POST['comment']) && (isset($_POST['idTruth']) || isset($_POST['idDare'])) && Friend::areFriendsOrFriendRequest($_POST['idUser'], Yii::app()->user->getId(), 1) == 1) { $type = isset($_POST['idTruth']) ? "idTruth" : "idDare"; $id = isset($_POST['idTruth']) ? $_POST['idTruth'] : $_POST['idDare']; //If the challenge is public and it already exists if ($_POST['private'] == 'false' && Challenge::model()->exists("idUserTo = :idUserTo AND {$type} = :id", array(':idUserTo' => $_POST['idUser'], ':id' => $id))) { echo 'ALREADY_EXISTS'; return; } $challenge = new Challenge(); $challenge->idUserFrom = Yii::app()->user->getId(); $challenge->idUserTo = $_POST['idUser']; $challenge->{$type} = $id; $challenge->createDate = date('Y-m-d, H:i:s'); $challenge->private = $_POST['private'] == 'true' ? 1 : 0; $challenge->comment = $_POST['comment']; if ($challenge->save()) { echo "SUCCESS"; } } }
Idea: <?php echo $score['scoreDareVoteIdeas']['week']; ?> pts<br /> Challenge: <?php echo $score['scoreDareChallenges']['week'] + $score['scoreDareVoteChallenges']['week']; ?> pts </div> </div> <div style="float:right; width:120px; height:71px; font-size:4.5em; vertical-align:middle; text-align:center; font-weight:bold;">D</div> </div> </div> </div> <!--******--> <!-- Wall --> <!--******--> <div style="background-color:#FEE;"> <?php $this->widget('UserWallWidget', array('idCurrentUser' => Yii::app()->user->isGuest ? null : Yii::app()->user->getId(), 'idWallOwner' => $user->idUser, 'filterLevel' => Yii::app()->user->isGuest ? 1 : Yii::app()->user->getLevel(), 'withVotes' => 1, 'withFavourites' => 1, 'withComments' => 1, 'withSendChallenge' => 1, 'withFormMessage' => Friend::areFriendsOrFriendRequest($user->idUser, Yii::app()->user->getId(), 1), 'withWallMessages' => Friend::areFriendsOrFriendRequest($user->idUser, Yii::app()->user->getId(), 1))); ?> </div> </div> <p>(See yiinfinite-scroll)</p> <!--***************************--> <!-- Dialog for Friend Request --> <!--***************************--> <div id="dialog-friendRequest" title="Friend Request"></div>