// here the new challlenge that created by the user is being saved IzapBase::gatekeeper(); if (IzapBase::hasFormError()) { if (sizeof(IzapBase::getFormErrors())) { foreach (IzapBase::getFormErrors() as $error) { register_error(elgg_echo($error)); } } forward(REFERRER); } //get all form attributes $challenge_form = IzapBase::getPostedAttributes(); $_SESSION['zcontest']['challenge'] = $challenge_form; $challenge_entity = new IzapChallenge((int) $challenge_form['guid']); IzapBase::updatePostedAttribute('tags', string_to_tag_array($challenge_form['tags'])); $challenge_entity->setAttributes(); if ($challenge_entity->max_quizzes < 2) { $challenge_entity->max_quizzes = 2; } //save the media for the quiz $challenge_entity->izap_upload_generate_thumbs($_FILES, $thumb); if (!$challenge_entity->save()) { register_error(elgg_echo("Error in challenge creation")); forward(REFERER); } // checks the format of the uploaded files, if it is authorised if (!empty($_FILES['related_media']['name'])) { $supproted_media = array('audio/mp3', 'image/jpeg', 'image/gif', 'image/png', 'image/jpg', 'image/jpe', 'image/pjpeg', 'image/x-png'); if (!in_array($_FILES['related_media']['type'], $supproted_media)) { register_error(elgg_echo('izap-contest:no file support')); forward(REFERER);