/** * sink function for the 'add_management_page' hook. * displays the page content for the 'Manage PhotoQ' submenu */ function manage_page() { PhotoQHelper::debug('enter manage_page()'); //do some inital setup $this->createDirIfNotExists($this->_oc->getCacheDir(), true); if (isset($_POST['add_entry']) || isset($_POST['ftp_upload'])) { //a photo will be added $this->createDirIfNotExists($this->_oc->getQDir()); require_once PHOTOQ_PATH . 'panels/upload.php'; } elseif (isset($_POST['edit_batch'])) { PhotoQHelper::debug('manage_page: load edit-batch panel'); if (isset($_POST['ftpFiles'])) { foreach ($_POST['ftpFiles'] as $ftpFile) { $this->uploadPhoto(basename($ftpFile), '', $this->_oc->getValue('qPostDefaultTags'), '', $ftpFile); } //refresh the queue $this->_queue->load(); } require_once PHOTOQ_PATH . 'panels/edit-batch.php'; PhotoQHelper::debug('manage_page: edit-batch panel loaded'); } elseif (isset($_POST['batch_upload'])) { if ($_POST['batch_upload']) { //check for correct nonce first check_admin_referer('photoq-uploadBatch'); } $this->uploadPhoto($_FILES['Filedata']['name'], '', $this->_oc->getValue('qPostDefaultTags'), ''); if (!$_POST['batch_upload']) { //show errors if any PhotoQErrorHandler::showAllErrors($this->_errStack); //refresh the queue as a photo was added $this->_queue->load(); require_once PHOTOQ_PATH . 'panels/edit-batch.php'; } } else { if (isset($_POST['save_batch'])) { PhotoQHelper::debug('manage_page: start saving batch'); //check for correct nonce first check_admin_referer('photoq-saveBatch', 'saveBatchNonce'); //uploaded file info is stored in arrays $no_upl = count(PhotoQHelper::arrayAttributeEscape($_POST['img_title'])); $qLength = $this->_queue->getLength(); for ($i = 0; $i < $no_upl; $i++) { $this->update_queue(esc_attr($_POST['img_id'][$i]), esc_attr($_POST['img_title'][$i]), $_POST['img_descr'][$i], esc_attr($_POST['tags_input'][$i]), esc_attr($_POST['img_slug'][$i]), esc_attr($_POST['img_author'][$i]), esc_attr($_POST['img_position'][$i]), esc_attr($_POST['img_position'][$i]), esc_attr($_POST['img_parent'][$i]), $qLength, $i); } PhotoQHelper::debug('manage_page: batch saved'); } if (isset($_POST['update_queue'])) { //check for correct nonce first check_admin_referer('photoq-updateQueue'); $this->update_queue(esc_attr($_POST['img_id']), esc_attr($_POST['img_title']), $_POST['img_descr'], esc_attr($_POST['tags_input']), esc_attr($_POST['img_slug']), esc_attr($_POST['img_author']), esc_attr($_POST['img_position']), esc_attr($_POST['img_old_position']), esc_attr($_POST['img_parent'][0]), esc_attr($_POST['q_length'])); } if (isset($_GET['action']) && $_GET['action'] == 'delete') { //check for correct nonce first check_admin_referer('photoq-deleteQueueEntry' . esc_attr($_GET['entry'])); $status = $this->_queue->deletePhotoById(esc_attr($_GET['entry'])); } if (isset($_GET['action']) && $_GET['action'] == 'rebuild') { //check for correct nonce first $postID = esc_attr($_GET['id']); check_admin_referer('photoq-rebuildPost' . $postID); $photo =& $this->_db->getPublishedPhoto($postID); if ($photo) { $photo->rebuild($this->_oc->getImageSizeNames()); } $status =& new PhotoQStatusMessage(__("Photo post with id {$postID} rebuilt.")); } //the donation dialog appeared and the user either clicked on the "No, Thanks" or "Already Donated" link if (isset($_GET['action']) && $_GET['action'] == 'nothanks' || $_GET['action'] == 'alreadydid') { update_option('wimpq_posted_since_reminded', 0); $reminderThreshold = get_option('wimpq_reminder_threshold'); $then = get_option('wimpq_last_reminder_reset'); if ($_GET['action'] == 'alreadydid' && time() - $then > 86400) { $reminderThreshold *= 2; } //don't bother guys who donated too often, exponential increase update_option('wimpq_reminder_threshold', $reminderThreshold); update_option('wimpq_last_reminder_reset', time()); } //the first photo of the queue is being published if (isset($_POST['post_first'])) { //check for correct nonce first check_admin_referer('photoq-manageQueue', 'manageQueueNonce'); $status = $this->_queue->publishTop(); } if (isset($_POST['post_multi'])) { //check for correct nonce first check_admin_referer('photoq-manageQueue', 'manageQueueNonce'); $status = $this->_queue->publishMulti($this->_oc->getValue('postMulti')); } if (isset($_POST['clear_queue'])) { //check for correct nonce first check_admin_referer('photoq-manageQueue', 'manageQueueNonce'); $this->_queue->deleteAll(); } //refresh the queue as it might have changed because of above operations $this->_queue->load(); //show donation reminder $this->_showReminder(); //show status message if any if (isset($status)) { $status->show(); } //show errors if any PhotoQErrorHandler::showAllErrors($this->_errStack); /*show the manage panel*/ require_once PHOTOQ_PATH . 'panels/manage.php'; } PhotoQHelper::debug('leave manage_page()'); }