Beispiel #1
0
 private static function _nominate()
 {
     $out = new stdClass();
     $out->success = false;
     $bracketId = Lib\Url::Post('bracketId', true);
     $nomineeName = Lib\Url::Post('nomineeName');
     $nomineeSource = Lib\Url::Post('nomineeSource');
     $verified = Lib\Url::Post('verified') === 'true';
     $image = Lib\Url::Post('image');
     if ($bracketId && $nomineeName && $image) {
         // Verify the image first
         if (self::_verifyImage($image)) {
             $nominee = new Api\Nominee();
             $nominee->bracketId = $bracketId;
             $nominee->name = $nomineeName;
             $nominee->source = $nomineeSource;
             $nominee->created = time();
             $nominee->image = $image;
             $nominee->processed = $verified ? 1 : null;
             if ($nominee->sync()) {
                 $out->success = true;
             } else {
                 $out->message = 'Unable to save to database';
             }
         } else {
             $out->message = 'Invalid image';
         }
     } else {
         $out->message = 'Missing fields';
         $out->data = $_POST;
     }
     return $out;
 }
Beispiel #2
0
 private static function _nominate(Api\User $user)
 {
     $out = new stdClass();
     $out->success = false;
     $bracketId = Lib\Url::Post('bracketId', true);
     $bracket = Api\Bracket::getById($bracketId);
     $nomineeName = Lib\Url::Post('nomineeName');
     $nomineeSource = Lib\Url::Post('nomineeSource');
     $verified = Lib\Url::Post('verified') === 'true';
     $image = Lib\Url::Post('image');
     if ($bracket && $nomineeName && $image) {
         if (self::_verifyAccountAge($user, $bracket)) {
             // Verify the image first
             if (self::_verifyImage($image)) {
                 $nominee = new Api\Nominee();
                 $nominee->bracketId = $bracket->id;
                 $nominee->name = $nomineeName;
                 $nominee->source = $nomineeSource;
                 $nominee->created = time();
                 $nominee->image = $image;
                 $nominee->processed = $verified ? 1 : null;
                 if ($nominee->sync()) {
                     $out->success = true;
                 } else {
                     $out->message = 'Unable to save to database';
                 }
             } else {
                 $out->message = 'Invalid image';
             }
         } else {
             $out->message = 'Your reddit account is not old enough to nominate in this bracket';
             $out->date = $_POST;
         }
     } else {
         $out->message = 'Missing fields';
         $out->data = $_POST;
     }
     return $out;
 }
 private static function _getSimilarCharacters($bracketId, $query)
 {
     $retVal = [];
     // Search for similar entered characters first
     $characters = Api\Character::searchBracketCharacters($query, $bracketId);
     if ($characters && count($characters)) {
         $retVal = $characters;
     } else {
         // Search nominees so that maybe we can prevent another similar character being nominated
         $nominees = Api\Nominee::searchBracketNominees($query, $bracketId);
         if ($nominees && count($nominees)) {
             $retVal = $nominees;
         }
     }
     return $retVal;
 }
Beispiel #4
0
 private static function _nomineeList(Api\Bracket $bracket)
 {
     Lib\Cache::setDisabled(true);
     Lib\Display::renderAndAddKey('content', 'admin/nominees', ['nominees' => Api\Nominee::queryReturnAll(['bracketId' => $bracket->id, 'processed' => ['null' => true]]), 'bracket' => $bracket]);
     Lib\Cache::setDisabled(false);
 }