function index_action() { $this->enqueue_static_resources(); $settings = C_NextGen_Settings::get_instance(); $retval = $settings->proofing_user_confirmation_not_found; if ($proof = C_NextGen_Pro_Proofing_Mapper::get_instance()->find_by_hash($this->param('proof'), TRUE)) { $image_mapper = C_Image_Mapper::get_instance(); $images = array(); foreach ($proof->proofed_gallery['image_list'] as $image_id) { $images[] = $image_mapper->find($image_id); } $message = $settings->proofing_user_confirmation_template; if (preg_match_all('/%%(\\w+)%%/', $settings->proofing_user_confirmation_template, $matches, PREG_SET_ORDER) > 0) { foreach ($matches as $match) { switch ($match[1]) { case 'user_name': $message = str_replace('%%user_name%%', $proof->customer_name, $message); break; case 'user_email': $message = str_replace('%%user_email%%', $proof->email, $message); break; case 'proof_link': $message = str_replace('%%proof_link%%', $proof->referer, $message); break; case 'proof_details': $imagehtml = $this->object->render_partial('photocrati-nextgen_pro_proofing#confirmation', array('images' => $images, 'storage' => C_Gallery_Storage::get_instance()), TRUE); $message = str_replace('%%proof_details%%', $imagehtml, $message); break; } } $retval = $message; } } return $retval; }
function output_proofing_column($column_name, $post_id) { global $post; $mapper = C_NextGen_Pro_Proofing_Mapper::get_instance(); $entity = $mapper->unserialize($post->post_content); switch ($column_name) { case 'proofing_customer': echo esc_html($entity['customer_name']); break; } }
/** * Submits proofed image list */ function submit_proofed_gallery_action() { $settings = C_NextGen_Settings::get_instance(); $response = array(); $proofed_gallery = $this->object->param('proofed_gallery'); $email = $this->object->param('email'); $customer_name = $this->object->param('customer_name'); $referer = $_SERVER['HTTP_REFERER']; // Do we have fields to work with? if ($this->object->validate_ajax_request()) { $image_list = isset($proofed_gallery['image_list']) ? $proofed_gallery['image_list'] : null; $file_list = ''; if (!empty($image_list)) { $i = 0; foreach ($image_list as $image_id) { $image = C_Image_Mapper::get_instance()->find($image_id); $name = pathinfo($image->filename); $name = $name['filename']; if ($i == 0) { $file_list = $name; } else { $file_list .= ',' . $name; } $i++; } } if ($image_list != null && $email != null) { $post_title = sprintf(__('Proof request by %1$s (%2$d images)', 'nextgen-gallery-pro'), $email, count($image_list)); $proof_mapper = C_NextGen_Pro_Proofing_Mapper::get_instance(); $proof = $proof_mapper->create(array('customer_name' => $customer_name, 'email' => $email, 'proofed_gallery' => $proofed_gallery, 'referer' => $referer, 'title' => $post_title)); $post_id = $proof_mapper->save($proof); if ($post_id) { $response['message'] = __('Done', 'nextgen-gallery-pro'); $confirmation_params = array('proof' => $proof->hash); if (!empty($settings->proofing_page_confirmation)) { $confirmation_url = M_NextGen_Pro_Proofing::get_page_url($settings->proofing_page_confirmation, $confirmation_params); } else { $confirmation_url = M_NextGen_Pro_Proofing::add_to_querystring(site_url('/?ngg_pro_proofing_page=1'), $confirmation_params); } // send e-mail to the site admin (get_option(admin_email)) $mailman = $this->object->get_registry()->get_utility('I_Nextgen_Mail_Manager'); $content = $mailman->create_content(); $content->set_subject($post_title); $content->set_property('admin', get_bloginfo('name')); $content->set_property('site_name', get_bloginfo('name')); $content->set_property('file_list', $file_list); $content->set_property('proof_link', $confirmation_url); $content->set_property('user', array('email' => $email, 'name' => $customer_name)); $content->load_template($settings->proofing_email_template); $mailman->send_mail($content, get_bloginfo('admin_email')); // potentially send email to the submitting user if ($settings->proofing_enable_user_email) { $content = $mailman->create_content(); $content->set_subject($settings->proofing_user_email_subject); $content->set_property('proof_link', $confirmation_url); $content->set_property('user', array('email' => $email, 'name' => $customer_name)); $content->load_template($settings->proofing_user_email_template); $mailman->send_mail($content, $email); } $response['redirect'] = $confirmation_url; } else { $response['error'] = __('Proof post could not be created', 'nextgen-gallery-pro'); } } else { if (empty($email) || empty($customer_name)) { $response['error'] = __('Please provide a name and e-mail address', 'nextgen-gallery-pro'); } else { if ($image_list == null) { // Sanity check, submit button is disabled when 0 images are selected $response['error'] = __('No images selected', 'nextgen-gallery-pro'); } } } } else { $response['error'] = __('Invalid request', 'nextgen-gallery-pro'); } return $response; }