*/ GalleryCoreApi::relativeRequireOnce('modules/nokiaupload/classes/ImageUploadHelper.class'); /** * This controller implements the Nokia Image Uploader API's 'Login' command. * * @package NokiaUpload */ class LoginController extends GalleryController { /** * @see GalleryController::handleRequest() */ function handleRequest($form) { ImageUploadHelper::logRequest('LoginController'); $results['delegate'] = array('view' => 'nokiaupload.Login'); $results['status'] = ImageUploadHelper::doLogin(); $results['error'] = array(); return array(GalleryStatus::success(), $results); } } /** * This view implements the Nokia Image Uploader API's 'Login' command. * * @package NokiaUpload */ class LoginView extends GalleryView { /** * @see GalleryView::renderImmediate() */ function isImmediate() { return true; } /** * API defines the output very specifically so we can't allow any global * templating to be used. * * @see GalleryView::renderImmediate() */ function renderImmediate($status, $error) { global $gallery; $gallery->debug("##### LoginView #####\n\$status = "); $gallery->debug_r($status); $reply = array($status['success'] . "\r\n"); $reply[] = 'Version=' . NOKIAUPLOAD_PROTOCOLVERSION . "\r\n"; if ($status['success'] == NOKIAUPLOAD_ERR_NOERR) { $reply[] = 'SId=' . $status['sessionidparam'] . '=' . $status['sessionid'] . "\r\n"; $reply[] = 'RSURL=' . $status['rsurl'] . "\r\n"; /* Send RS Capabilities as well if we have them. */ if (isset($status['capabilities'])) { foreach ($status['capabilities'] as $capability) { $reply[] = $capability; } } } else { list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'nokiaupload'); if ($ret->isError()) { $reply[] = "Login failed.\r\n"; } else { $reply[] = $module->translate('Login failed.') . "\r\n"; } } $reply = implode('', $reply); $gallery->debug("Sending:\n$reply"); header('Content-Length: ' . strlen($reply)); print $reply; return GalleryStatus::success(); } } ?>