PageRenderTime 54ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/gravityforms/entry_list.php

https://github.com/ttimsmith/Anythin-Goes
PHP | 1331 lines | 1068 code | 236 blank | 27 comment | 133 complexity | 09dd244692c61896c83e65d7de80af95 MD5 | raw file
Possible License(s): GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. class GFEntryList{
  3. public static function all_leads_page(){
  4. if(!GFCommon::ensure_wp_version())
  5. return;
  6. $forms = RGFormsModel::get_forms(null, "title");
  7. $id = RGForms::get("id");
  8. if(sizeof($forms) == 0)
  9. {
  10. ?>
  11. <div style="margin:50px 0 0 10px;">
  12. <?php echo sprintf(__("You don't have any active forms. Let's go %screate one%s", "gravityforms"), '<a href="?page=gf_new_form">', '</a>'); ?>
  13. </div>
  14. <?php
  15. }
  16. else{
  17. if(empty($id))
  18. $id = $forms[0]->id;
  19. self::leads_page($id);
  20. }
  21. }
  22. public static function leads_page($form_id){
  23. global $wpdb;
  24. //quit if version of wp is not supported
  25. if(!GFCommon::ensure_wp_version())
  26. return;
  27. echo GFCommon::get_remote_message();
  28. $action = RGForms::post("action");
  29. $update_message = "";
  30. switch($action){
  31. case "delete" :
  32. check_admin_referer('gforms_entry_list', 'gforms_entry_list');
  33. $lead_id = $_POST["action_argument"];
  34. RGFormsModel::delete_lead($lead_id);
  35. $update_message = __("Entry deleted.", "gravityforms");
  36. break;
  37. case "bulk":
  38. check_admin_referer('gforms_entry_list', 'gforms_entry_list');
  39. $bulk_action = !empty($_POST["bulk_action"]) ? $_POST["bulk_action"] : $_POST["bulk_action2"];
  40. $leads = $_POST["lead"];
  41. $entry_count = count($leads) > 1 ? sprintf(__("%d entries", "gravityforms"), count($leads)) : __("1 entry", "gravityforms");
  42. switch($bulk_action) {
  43. case "delete":
  44. RGFormsModel::delete_leads($leads);
  45. $update_message = sprintf(__("%s deleted.", "gravityforms"), $entry_count);
  46. break;
  47. case "trash":
  48. RGFormsModel::update_leads_property($leads, "status", "trash");
  49. $update_message = sprintf(__("%s moved to Trash.", "gravityforms"), $entry_count);
  50. break;
  51. case "restore":
  52. RGFormsModel::update_leads_property($leads, "status", "active");
  53. $update_message = sprintf(__("%s restored from the Trash.", "gravityforms"), $entry_count);
  54. break;
  55. case "unspam":
  56. RGFormsModel::update_leads_property($leads, "status", "active");
  57. $update_message = sprintf(__("%s restored from the spam.", "gravityforms"), $entry_count);
  58. break;
  59. case "spam":
  60. RGFormsModel::update_leads_property($leads, "status", "spam");
  61. $update_message = sprintf(__("%s marked as spam.", "gravityforms"), $entry_count);
  62. break;
  63. case "mark_read":
  64. RGFormsModel::update_leads_property($leads, "is_read", 1);
  65. $update_message = sprintf(__("%s marked as read.", "gravityforms"), $entry_count);
  66. break;
  67. case "mark_unread":
  68. RGFormsModel::update_leads_property($leads, "is_read", 0);
  69. $update_message = sprintf(__("%s marked as unread.", "gravityforms"), $entry_count);
  70. break;
  71. case "add_star":
  72. RGFormsModel::update_leads_property($leads, "is_starred", 1);
  73. $update_message = sprintf(__("%s starred.", "gravityforms"), $entry_count);
  74. break;
  75. case "remove_star":
  76. RGFormsModel::update_leads_property($leads, "is_starred", 0);
  77. $update_message = sprintf(__("%s unstarred.", "gravityforms"), $entry_count);
  78. break;
  79. }
  80. break;
  81. case "change_columns":
  82. check_admin_referer('gforms_entry_list', 'gforms_entry_list');
  83. $columns = GFCommon::json_decode(stripslashes($_POST["grid_columns"]), true);
  84. RGFormsModel::update_grid_column_meta($form_id, $columns);
  85. break;
  86. }
  87. $filter = rgget("filter");
  88. if(rgpost("button_delete_permanently")){
  89. RGFormsModel::delete_leads_by_form($form_id, $filter);
  90. }
  91. $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
  92. $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"];
  93. $search = RGForms::get("s");
  94. $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1;
  95. $star = $filter == "star" ? 1 : null; // is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null;
  96. $read = $filter == "unread" ? 0 : null; //is_numeric(RGForms::get("read")) ? intval(RGForms::get("read")) : null;
  97. $page_size = apply_filters("gform_entry_page_size", apply_filters("gform_entry_page_size_{$form_id}", 20, $form_id), $form_id);
  98. $first_item_index = $page_index * $page_size;
  99. $form = RGFormsModel::get_form_meta($form_id);
  100. $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
  101. $is_numeric = $sort_field_meta["type"] == "number";
  102. $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
  103. $leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric, null, null, $status);
  104. $lead_count = RGFormsModel::get_lead_count($form_id, $search, $star, $read);
  105. $summary = RGFormsModel::get_form_counts($form_id);
  106. $active_lead_count = $summary["total"];
  107. $unread_count = $summary["unread"];
  108. $starred_count = $summary["starred"];
  109. $spam_count = $summary["spam"];
  110. $trash_count = $summary["trash"];
  111. $columns = RGFormsModel::get_grid_columns($form_id, true);
  112. $search_qs = empty($search) ? "" : "&s=" . urlencode($search);
  113. $sort_qs = empty($sort_field) ? "" : "&sort=$sort_field";
  114. $dir_qs = empty($sort_field) ? "" : "&dir=$sort_direction";
  115. $star_qs = $star !== null ? "&star=$star" : "";
  116. $read_qs = $read !== null ? "&read=$read" : "";
  117. $filter_qs = "&filter=" . $filter;
  118. // determine which counter to use for paging and set total count
  119. switch ($filter)
  120. {
  121. case "trash" :
  122. $display_total = ceil($trash_count / $page_size);
  123. $total_lead_count = $trash_count;
  124. break;
  125. case "spam" :
  126. $display_total = ceil($spam_count / $page_size);
  127. $total_lead_count = $spam_count;
  128. break;
  129. case "star" :
  130. $display_total = ceil($starred_count / $page_size);
  131. $total_lead_count = $starred_count;
  132. break;
  133. case "unread" :
  134. $display_total = ceil($unread_count / $page_size);
  135. $total_lead_count = $unread_count;
  136. break;
  137. default :
  138. $display_total = ceil($active_lead_count / $page_size);
  139. $total_lead_count = $active_lead_count;
  140. break;
  141. }
  142. $page_links = paginate_links( array(
  143. 'base' => admin_url("admin.php") . "?page=gf_entries&view=entries&id=$form_id&%_%" . $search_qs . $sort_qs . $dir_qs. $star_qs . $read_qs . $filter_qs,
  144. 'format' => 'paged=%#%',
  145. 'prev_text' => __('&laquo;', 'gravityforms'),
  146. 'next_text' => __('&raquo;', 'gravityforms'),
  147. 'total' => $display_total,
  148. 'current' => $page_index + 1,
  149. 'show_all' => false
  150. ));
  151. wp_print_styles(array("thickbox"));
  152. ?>
  153. <script type="text/javascript">
  154. var messageTimeout = false;
  155. function ChangeColumns(columns){
  156. jQuery("#action").val("change_columns");
  157. jQuery("#grid_columns").val(jQuery.toJSON(columns));
  158. tb_remove();
  159. jQuery("#lead_form")[0].submit();
  160. }
  161. function Search(sort_field_id, sort_direction, form_id, search, star, read, filter){
  162. var search_qs = search == "" ? "" : "&s=" + search;
  163. var star_qs = star == "" ? "" : "&star=" + star;
  164. var read_qs = read == "" ? "" : "&read=" + read;
  165. var filter_qs = filter == "" ? "" : "&filter=" + filter;
  166. var location = "?page=gf_entries&view=entries&id=" + form_id + "&sort=" + sort_field_id + "&dir=" + sort_direction + search_qs + star_qs + read_qs + filter_qs;
  167. document.location = location;
  168. }
  169. function ToggleStar(img, lead_id, filter){
  170. var is_starred = img.src.indexOf("star1.png") >=0
  171. if(is_starred)
  172. img.src = img.src.replace("star1.png", "star0.png");
  173. else
  174. img.src = img.src.replace("star0.png", "star1.png");
  175. jQuery("#lead_row_" + lead_id).toggleClass("lead_starred");
  176. //if viewing the starred entries, hide the row and adjust the paging counts
  177. if (filter == "star")
  178. {
  179. var title = jQuery("#lead_row_" + lead_id);
  180. title.css("display", "none");
  181. UpdatePagingCounts(1);
  182. }
  183. UpdateCount("star_count", is_starred ? -1 : 1);
  184. UpdateLeadProperty(lead_id, "is_starred", is_starred ? 0 : 1);
  185. }
  186. function ToggleRead(lead_id, filter){
  187. var title = jQuery("#lead_row_" + lead_id);
  188. marking_read = title.hasClass("lead_unread");
  189. jQuery("#mark_read_" + lead_id).css("display", marking_read ? "none" : "inline");
  190. jQuery("#mark_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
  191. jQuery("#is_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
  192. title.toggleClass("lead_unread");
  193. //if viewing the unread entries, hide the row and adjust the paging counts
  194. if (filter == "unread")
  195. {
  196. title.css("display", "none");
  197. UpdatePagingCounts(1);
  198. }
  199. UpdateCount("unread_count", marking_read ? -1 : 1);
  200. UpdateLeadProperty(lead_id, "is_read", marking_read ? 1 : 0);
  201. }
  202. function UpdateLeadProperty(lead_id, name, value){
  203. var mysack = new sack("<?php echo admin_url("admin-ajax.php")?>" );
  204. mysack.execute = 1;
  205. mysack.method = 'POST';
  206. mysack.setVar( "action", "rg_update_lead_property" );
  207. mysack.setVar( "rg_update_lead_property", "<?php echo wp_create_nonce("rg_update_lead_property") ?>" );
  208. mysack.setVar( "lead_id", lead_id);
  209. mysack.setVar( "name", name);
  210. mysack.setVar( "value", value);
  211. mysack.onError = function() { alert('<?php echo esc_js(__("Ajax error while setting lead property", "gravityforms")) ?>' )};
  212. mysack.runAJAX();
  213. return true;
  214. }
  215. function UpdateCount(element_id, change){
  216. var element = jQuery("#" + element_id);
  217. var count = parseInt(element.html()) + change
  218. element.html(count + "");
  219. }
  220. function UpdatePagingCounts(change){
  221. //update paging header/footer Displaying # - # of #, use counts from header, no need to use footer since they are the same, just update footer paging with header info
  222. var paging_range_max_header = jQuery("#paging_range_max_header");
  223. var paging_range_max_footer = jQuery("#paging_range_max_footer");
  224. var range_change_max = parseInt(paging_range_max_header.html()) - change;
  225. var paging_total_header = jQuery("#paging_total_header");
  226. var paging_total_footer = jQuery("#paging_total_footer");
  227. var total_change = parseInt(paging_total_header.html()) - change;
  228. var paging_range_min_header = jQuery("#paging_range_min_header");
  229. var paging_range_min_footer = jQuery("#paging_range_min_footer");
  230. //if min and max are the same, this is the last entry item on the page, clear out the displaying # - # of # text
  231. if (parseInt(paging_range_min_header.html()) == parseInt(paging_range_max_header.html()))
  232. {
  233. var paging_header = jQuery("#paging_header");
  234. paging_header.html("");
  235. var paging_footer = jQuery("#paging_footer");
  236. paging_footer.html("");
  237. }
  238. else
  239. {
  240. paging_range_max_header.html(range_change_max + "");
  241. paging_range_max_footer.html(range_change_max + "");
  242. paging_total_header.html(total_change + "");
  243. paging_total_footer.html(total_change + "");
  244. }
  245. }
  246. function DeleteLead(lead_id){
  247. jQuery("#action").val("delete");
  248. jQuery("#action_argument").val(lead_id);
  249. jQuery("#lead_form")[0].submit();
  250. return true;
  251. }
  252. function handleBulkApply(actionElement){
  253. var action = jQuery("#" + actionElement).val();
  254. var defaultModalOptions = '';
  255. var leadIds = getLeadIds();
  256. if(leadIds.length == 0){
  257. alert('<?php _e('Please select at least one entry.', 'gravityforms'); ?>');
  258. return false;
  259. }
  260. switch(action){
  261. case 'resend_notifications':
  262. resetResendNotificationsUI();
  263. tb_show('<?php _e("Resend Notifications", "gravityforms"); ?>', '#TB_inline?width=350&amp;inlineId=notifications_modal_container', '');
  264. return false;
  265. break;
  266. case 'print':
  267. resetPrintUI();
  268. tb_show('<?php _e("Print Entries", "gravityforms"); ?>', '#TB_inline?width=350&amp;height=250&amp;inlineId=print_modal_container', '');
  269. return false;
  270. break;
  271. default:
  272. jQuery('#action').val('bulk');
  273. }
  274. }
  275. function getLeadIds(){
  276. var leads = jQuery(".check-column input[name='lead[]']:checked");
  277. var leadIds = new Array();
  278. jQuery(leads).each(function(i){
  279. leadIds[i] = jQuery(leads[i]).val();
  280. });
  281. return leadIds;
  282. }
  283. function BulkResendNotifications(){
  284. var selectedNotifications = new Array();
  285. jQuery(".gform_notifications:checked").each(function(){
  286. selectedNotifications.push(jQuery(this).val());
  287. });
  288. var leadIds = getLeadIds();
  289. var sendTo = jQuery('#notification_override_email').val();
  290. if(selectedNotifications.length <=0) {
  291. displayMessage("<?php _e("You must select at least one type of notification to resend.", "gravityforms"); ?>", "error", "#notifications_container");
  292. return;
  293. }
  294. jQuery('#please_wait_container').fadeIn();
  295. jQuery.post(ajaxurl, {
  296. action : "gf_resend_notifications",
  297. gf_resend_notifications : '<?php echo wp_create_nonce('gf_resend_notifications'); ?>',
  298. notifications: jQuery.toJSON(selectedNotifications),
  299. sendTo : sendTo,
  300. leadIds : leadIds,
  301. formId : '<?php echo $form['id']; ?>'
  302. },
  303. function(response){
  304. jQuery('#please_wait_container').hide();
  305. if(response) {
  306. displayMessage(response, "error", "#notifications_container");
  307. } else {
  308. var message = '<?php _e("Notifications for %s were resent successfully.", "gravityforms"); ?>';
  309. displayMessage(message.replace('%s', leadIds.length + ' ' + getPlural(leadIds.length, '<?php _e('entry', 'gravityforms'); ?>', '<?php _e('entries', 'gravityforms'); ?>')), "updated", "#lead_form");
  310. closeModal(true);
  311. }
  312. }
  313. );
  314. }
  315. function resetResendNotificationsUI(){
  316. jQuery('#notification_admin, #notification_user').attr('checked', false);
  317. jQuery('#notifications_container .message, #notifications_override_settings').hide();
  318. }
  319. function BulkPrint(){
  320. var leadIds = getLeadIds();
  321. var leadsQS = '&lid=' + leadIds.join(',');
  322. var notesQS = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : '';
  323. var pageBreakQS = jQuery('#gform_print_page_break').is(':checked') ? '&page_break=1' : '';
  324. var url = '<?php echo trailingslashit(site_url()) ?>?gf_page=print-entry&fid=<?php echo $form['id'] ?>' + leadsQS + notesQS + pageBreakQS;
  325. window.open (url,'printwindow');
  326. closeModal(true);
  327. hideMessage('#lead_form', false);
  328. }
  329. function resetPrintUI(){
  330. jQuery('#print_options input[type="checkbox"]').attr('checked', false);
  331. }
  332. function displayMessage(message, messageClass, container){
  333. hideMessage(container, true);
  334. var messageBox = jQuery('<div class="message ' + messageClass + '" style="display:none;"><p>' + message + '</p></div>');
  335. jQuery(messageBox).prependTo(container).slideDown();
  336. if(messageClass == 'updated')
  337. messageTimeout = setTimeout(function(){ hideMessage(container, false); }, 10000);
  338. }
  339. function hideMessage(container, messageQueued){
  340. if(messageTimeout)
  341. clearTimeout(messageTimeout);
  342. var messageBox = jQuery(container).find('.message');
  343. if(messageQueued)
  344. jQuery(messageBox).remove();
  345. else
  346. jQuery(messageBox).slideUp(function(){ jQuery(this).remove(); });
  347. }
  348. function closeModal(isSuccess) {
  349. if(isSuccess)
  350. jQuery('.check-column input[type="checkbox"]').attr('checked', false);
  351. tb_remove();
  352. }
  353. function getPlural(count, singular, plural) {
  354. return count > 1 ? plural : singular;
  355. }
  356. function toggleNotificationOverride(isInit) {
  357. if(isInit)
  358. jQuery('#notification_override_email').val('');
  359. if(jQuery(".gform_notifications:checked").length > 0 ) {
  360. jQuery('#notifications_override_settings').slideDown();
  361. } else {
  362. jQuery('#notifications_override_settings').slideUp(function(){
  363. jQuery('#notification_override_email').val('');
  364. });
  365. }
  366. }
  367. jQuery(document).ready(function(){
  368. jQuery("#lead_search").keypress(function(event){
  369. if(event.keyCode == 13){
  370. Search('<?php echo $sort_field ?>', '<?php echo $sort_direction ?>', <?php echo $form_id ?>, this.value, '<?php echo $star ?>', '<?php echo $read ?>', '<?php echo $filter ?>');
  371. event.preventDefault();
  372. }
  373. });
  374. var action = '<?php echo $action; ?>';
  375. var message = '<?php echo $update_message; ?>';
  376. if(action && message)
  377. displayMessage(message, 'updated', '#lead_form');
  378. var list = jQuery("#gf_entry_list").wpList( { alt: '<?php echo esc_js(__('Entry List', 'gravityforms')) ?>'} );
  379. list.bind('wpListDelEnd', function(e, s, list){
  380. var currentStatus = "<?php echo $filter == "trash" || $filter == "spam" ? $filter : "active" ?>";
  381. var filter = "<?php echo $filter ?>";
  382. var movingTo = "active";
  383. if(s.data.status == "trash")
  384. movingTo = "trash";
  385. else if(s.data.status == "spam")
  386. movingTo = "spam";
  387. else if(s.data.status == "delete")
  388. movingTo = "delete";
  389. var id = s.data.entry;
  390. var title = jQuery("#lead_row_" + id);
  391. var isUnread = title.hasClass("lead_unread");
  392. var isStarred = title.hasClass("lead_starred");
  393. if(movingTo != "delete"){
  394. //Updating All count
  395. var allCount = currentStatus == "active" ? -1 : 1;
  396. UpdateCount("all_count", allCount);
  397. //Updating Unread count
  398. if(isUnread){
  399. var unreadCount = currentStatus == "active" ? -1 : 1;
  400. UpdateCount("unread_count", unreadCount);
  401. }
  402. //Updating Starred count
  403. if(isStarred){
  404. var starCount = currentStatus == "active" ? -1 : 1;
  405. UpdateCount("star_count", starCount);
  406. }
  407. }
  408. //Updating Spam count
  409. if(currentStatus == "spam" || movingTo == "spam"){
  410. var spamCount = movingTo == "spam" ? 1 : -1;
  411. UpdateCount("spam_count", spamCount);
  412. //adjust paging counts
  413. if (filter == "spam")
  414. {
  415. UpdatePagingCounts(1);
  416. }
  417. else
  418. {
  419. UpdatePagingCounts(spamCount);
  420. }
  421. }
  422. //Updating trash count
  423. if(currentStatus == "trash" || movingTo == "trash"){
  424. var trashCount = movingTo == "trash" ? 1 : -1;
  425. UpdateCount("trash_count", trashCount);
  426. //adjust paging counts
  427. if (filter == "trash")
  428. {
  429. UpdatePagingCounts(1);
  430. }
  431. else
  432. {
  433. UpdatePagingCounts(trashCount);
  434. }
  435. }
  436. });;
  437. });
  438. </script>
  439. <link rel="stylesheet" href="<?php echo GFCommon::get_base_url() ?>/css/admin.css" type="text/css" />
  440. <style>
  441. /*#TB_window { height: 400px !important; }
  442. #TB_ajaxContent[style] { height: 370px !important; }*/
  443. .lead_unread a, .lead_unread td{font-weight: bold;}
  444. .lead_spam_trash a, .lead_spam_trash td{font-weight:normal;}
  445. .row-actions a { font-weight:normal;}
  446. .entry_nowrap{ overflow:hidden; white-space:nowrap; }
  447. .message { margin: 15px 0 0 !important; }
  448. </style>
  449. <div class="wrap">
  450. <div class="icon32" id="gravity-entry-icon"><br></div>
  451. <h2 class="gf_admin_page_title"><span><?php _e("Entries", "gravityforms") ?></span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php echo $form['id']; ?></span><?php echo $form['title']; ?></span></h2>
  452. <?php RGForms::top_toolbar() ?>
  453. <form id="lead_form" method="post">
  454. <?php wp_nonce_field('gforms_entry_list', 'gforms_entry_list') ?>
  455. <input type="hidden" value="" name="grid_columns" id="grid_columns" />
  456. <input type="hidden" value="" name="action" id="action" />
  457. <input type="hidden" value="" name="action_argument" id="action_argument" />
  458. <ul class="subsubsub">
  459. <li><a class="<?php echo empty($filter) ? "current" : "" ?>" href="?page=gf_entries&view=entries&id=<?php echo $form_id ?>"><?php _e("All", "gravityforms"); ?> <span class="count">(<span id="all_count"><?php echo $active_lead_count ?></span>)</span></a> | </li>
  460. <li><a class="<?php echo $read !== null ? "current" : ""?>" href="?page=gf_entries&view=entries&id=<?php echo $form_id ?>&filter=unread"><?php _e("Unread", "gravityforms"); ?> <span class="count">(<span id="unread_count"><?php echo $unread_count ?></span>)</span></a> | </li>
  461. <li><a class="<?php echo $star !== null ? "current" : ""?>" href="?page=gf_entries&view=entries&id=<?php echo $form_id ?>&filter=star"><?php _e("Starred", "gravityforms"); ?> <span class="count">(<span id="star_count"><?php echo $starred_count ?></span>)</span></a> | </li>
  462. <?php
  463. if(GFCommon::akismet_enabled($form_id)){
  464. ?>
  465. <li><a class="<?php echo $filter == "spam" ? "current" : ""?>" href="?page=gf_entries&view=entries&id=<?php echo $form_id ?>&filter=spam"><?php _e("Spam", "gravityforms"); ?> <span class="count">(<span id="spam_count"><?php echo $spam_count ?></span>)</span></a> | </li>
  466. <?php
  467. }
  468. ?>
  469. <li><a class="<?php echo $filter == "trash" ? "current" : ""?>" href="?page=gf_entries&view=entries&id=<?php echo $form_id ?>&filter=trash"><?php _e("Trash", "gravityforms"); ?> <span class="count">(<span id="trash_count"><?php echo $trash_count ?></span>)</span></a></li>
  470. </ul>
  471. <p class="search-box">
  472. <label class="hidden" for="lead_search"><?php _e("Search Entries:", "gravityforms"); ?></label>
  473. <input type="text" id="lead_search" value="<?php echo $search ?>"><a class="button" id="lead_search_button" href="javascript:Search('<?php echo $sort_field ?>', '<?php echo $sort_direction ?>', <?php echo $form_id ?>, jQuery('#lead_search').val(), '<?php echo $star ?>', '<?php echo $read ?>', '<?php echo $filter ?>');"><?php _e("Search", "gravityforms") ?></a>
  474. </p>
  475. <div class="tablenav">
  476. <div class="alignleft actions" style="padding:8px 0 7px 0;">
  477. <label class="hidden" for="bulk_action"> <?php _e("Bulk action", "gravityforms") ?></label>
  478. <select name="bulk_action" id="bulk_action">
  479. <option value=''><?php _e(" Bulk action ", "gravityforms") ?></option>
  480. <?php
  481. switch($filter){
  482. case "trash" :
  483. ?>
  484. <option value='restore'><?php _e("Restore", "gravityforms") ?></option>
  485. <?php
  486. if(GFCommon::current_user_can_any("gravityforms_delete_entries")){
  487. ?>
  488. <option value='delete'><?php _e("Delete Permanently", "gravityforms") ?></option>
  489. <?php
  490. }
  491. break;
  492. case "spam" :
  493. ?>
  494. <option value='unspam'><?php _e("Not Spam", "gravityforms") ?></option>
  495. <?php
  496. if(GFCommon::current_user_can_any("gravityforms_delete_entries")){
  497. ?>
  498. <option value='delete'><?php _e("Delete Permanently", "gravityforms") ?></option>
  499. <?php
  500. }
  501. break;
  502. default:
  503. ?>
  504. <option value='mark_read'><?php _e("Mark as Read", "gravityforms") ?></option>
  505. <option value='mark_unread'><?php _e("Mark as Unread", "gravityforms") ?></option>
  506. <option value='add_star'><?php _e("Add Star", "gravityforms") ?></option>
  507. <option value='remove_star'><?php _e("Remove Star", "gravityforms") ?></option>
  508. <option value='resend_notifications'><?php _e("Resend Notifications", "gravityforms") ?></option>
  509. <option value='print'><?php _e("Print", "gravityforms") ?></option>
  510. <?php
  511. if(GFCommon::akismet_enabled($form_id)){
  512. ?>
  513. <option value='spam'><?php _e("Spam", "gravityforms") ?></option>
  514. <?php
  515. }
  516. if(GFCommon::current_user_can_any("gravityforms_delete_entries")){
  517. ?>
  518. <option value='trash'><?php _e("Trash", "gravityforms") ?></option>
  519. <?php
  520. }
  521. }?>
  522. </select>
  523. <?php
  524. $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return handleBulkApply(\'bulk_action\');" />';
  525. echo apply_filters("gform_entry_apply_button", $apply_button);
  526. if(in_array($filter, array("trash", "spam"))){
  527. $message = $filter == "trash" ? __("WARNING! This operation cannot be undone. Empty trash? \'Ok\' to empty trash. \'Cancel\' to abort.", "gravityforms") : __("WARNING! This operation cannot be undone. Permanently delete all spam? \'Ok\' to delete. \'Cancel\' to abort.", "gravityforms");
  528. $button_label = $filter == "trash" ? __("Empty Trash", "gravityforms") : __("Delete All Spam", "gravityforms");
  529. ?>
  530. <input type="submit" class="button" name="button_delete_permanently" value="<?php echo $button_label ?>" onclick="return confirm('<?php echo esc_attr($message) ?>');" />
  531. <?php
  532. }
  533. ?>
  534. <div id="notifications_modal_container" style="display:none;">
  535. <div id="notifications_container">
  536. <div id="post_tag" class="tagsdiv">
  537. <div id="resend_notifications_options">
  538. <p class="description"><?php _e("Specify which notifications you would like to resend for the selected entries.", "gravityforms"); ?></p>
  539. <?php
  540. if(!is_array($form["notifications"]) || count($form["notifications"]) <=0){
  541. ?>
  542. <div class="error" style="padding: 20px;"><?php _e("This form does not have any notifications configured", "gravityforms") ?></div>
  543. <?php
  544. }
  545. else{
  546. foreach($form["notifications"] as $notification){
  547. ?>
  548. <input type="checkbox" class="gform_notifications" value="<?php echo $notification["id"] ?>" id="notification_<?php echo $notification["id"]?>" onclick="toggleNotificationOverride();" />
  549. <label for="notification_<?php echo $notification["id"]?>"><?php echo $notification["name"] ?></label> <br /><br />
  550. <?php
  551. }
  552. }
  553. ?>
  554. <div id="notifications_override_settings" style="display:none;">
  555. <p class="description" style="padding-top:0; margin-top:0;">You may override the default notification settings
  556. by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
  557. <label for="notification_override_email"><?php _e("Send To", "gravityforms"); ?> <?php gform_tooltip("notification_override_email") ?></label><br />
  558. <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" /><br /><br />
  559. </div>
  560. <input type="button" name="notification_resend" id="notification_resend" value="<?php _e("Resend Notifications", "gravityforms") ?>" class="button" style="" onclick="BulkResendNotifications();"/>
  561. <span id="please_wait_container" style="display:none; margin-left: 5px;">
  562. <img src="<?php echo GFCommon::get_base_url()?>/images/loading.gif"> <?php _e("Resending...", "gravityforms"); ?>
  563. </span>
  564. </div>
  565. <div id="resend_notifications_close" style="display:none;margin:10px 0 0;">
  566. <input type="button" name="resend_notifications_close_button" value="<?php _e("Close Window", "gravityforms") ?>" class="button" style="" onclick="closeModal(true);"/>
  567. </div>
  568. </div>
  569. </div>
  570. </div> <!-- / Resend Notifications -->
  571. <div id="print_modal_container" style="display:none;">
  572. <div id="print_container">
  573. <div class="tagsdiv">
  574. <div id="print_options">
  575. <p class="description"><?php _e("Print all of the selected entries at once.", "gravityforms"); ?></p>
  576. <?php if(GFCommon::current_user_can_any("gravityforms_view_entry_notes")) { ?>
  577. <input type="checkbox" name="gform_print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
  578. <label for="gform_print_notes"><?php _e("Include notes", "gravityforms"); ?></label>
  579. <br /><br />
  580. <?php } ?>
  581. <input type="checkbox" name="gform_print_page_break" value="print_notes" checked="checked" id="gform_print_page_break" />
  582. <label for="gform_print_page_break"><?php _e("Add page break between entries", "gravityforms"); ?></label>
  583. <br /><br />
  584. <input type="button" value="<?php _e("Print", "gravityforms"); ?>" class="button" onclick="BulkPrint();" />
  585. </div>
  586. </div>
  587. </div>
  588. </div> <!-- / Print -->
  589. </div>
  590. <?php echo self::display_paging_links("header", $page_links, $first_item_index, $page_size, $total_lead_count);?>
  591. <div class="clear"></div>
  592. </div>
  593. <table class="widefat fixed" cellspacing="0">
  594. <thead>
  595. <tr>
  596. <th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" class="headercb" /></th>
  597. <?php
  598. if(!in_array($filter, array("spam", "trash"))){
  599. ?>
  600. <th scope="col" id="cb" class="manage-column column-cb check-column" >&nbsp;</th>
  601. <?php
  602. }
  603. foreach($columns as $field_id => $field_info){
  604. $dir = $field_id == 0 ? "DESC" : "ASC"; //default every field so ascending sorting except date_created (id=0)
  605. if($field_id == $sort_field) //reverting direction if clicking on the currently sorted field
  606. $dir = $sort_direction == "ASC" ? "DESC" : "ASC";
  607. ?>
  608. <th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php echo $field_id ?>', '<?php echo $dir ?>', <?php echo $form_id ?>, '<?php echo $search ?>', '<?php echo $star ?>', '<?php echo $read ?>', '<?php echo $filter ?>');" style="cursor:pointer;"><?php echo esc_html($field_info["label"]) ?></th>
  609. <?php
  610. }
  611. ?>
  612. <th scope="col" align="right" width="50">
  613. <a title="<?php _e("Select Columns" , "gravityforms") ?>" href="<?php echo trailingslashit(site_url()) ?>?gf_page=select_columns&id=<?php echo $form_id ?>&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><?php _e("Edit", "gravityforms") ?></a>
  614. </th>
  615. </tr>
  616. </thead>
  617. <tfoot>
  618. <tr>
  619. <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
  620. <?php
  621. if(!in_array($filter, array("spam", "trash"))){
  622. ?>
  623. <th scope="col" id="cb" class="manage-column column-cb check-column" >&nbsp;</th>
  624. <?php
  625. }
  626. foreach($columns as $field_id => $field_info){
  627. $dir = $field_id == 0 ? "DESC" : "ASC"; //default every field so ascending sorting except date_created (id=0)
  628. if($field_id == $sort_field) //reverting direction if clicking on the currently sorted field
  629. $dir = $sort_direction == "ASC" ? "DESC" : "ASC";
  630. ?>
  631. <th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php echo $field_id ?>', '<?php echo $dir ?>', <?php echo $form_id ?>, '<?php echo $search ?>', '<?php echo $star ?>', '<?php echo $read ?>', '<?php echo $filter ?>');" style="cursor:pointer;"><?php echo esc_html($field_info["label"]) ?></th>
  632. <?php
  633. }
  634. ?>
  635. <th scope="col" style="width:15px;">
  636. <a href="<?php echo trailingslashit(site_url()) ?>?gf_page=select_columns&id=<?php echo $form_id ?>&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><?php _e("Edit", "gravityforms") ?></a>
  637. </th>
  638. </tr>
  639. </tfoot>
  640. <tbody data-wp-lists="list:gf_entry" class="user-list" id="gf_entry_list">
  641. <?php
  642. if(sizeof($leads) > 0){
  643. $field_ids = array_keys($columns);
  644. foreach($leads as $position => $lead){
  645. $position = ($page_size * $page_index) + $position;
  646. ?>
  647. <tr id="lead_row_<?php echo $lead["id"] ?>" class='author-self status-inherit <?php echo $lead["is_read"] ? "" : "lead_unread" ?> <?php echo $lead["is_starred"] ? "lead_starred" : "" ?> <?php echo in_array($filter, array("trash", "spam")) ? "lead_spam_trash" : "" ?>' valign="top">
  648. <th scope="row" class="check-column">
  649. <input type="checkbox" name="lead[]" value="<?php echo $lead["id"] ?>" />
  650. </th>
  651. <?php
  652. if(!in_array($filter, array("spam", "trash"))){
  653. ?>
  654. <td >
  655. <img id="star_image_<?php echo $lead["id"]?>" src="<?php echo GFCommon::get_base_url() ?>/images/star<?php echo intval($lead["is_starred"]) ?>.png" onclick="ToggleStar(this, <?php echo $lead["id"] . ",'" . $filter . "'" ?>);" />
  656. </td>
  657. <?php
  658. }
  659. $is_first_column = true;
  660. $nowrap_class="entry_nowrap";
  661. foreach($field_ids as $field_id){
  662. /* maybe move to function */
  663. $field = RGFormsModel::get_field($form, $field_id);
  664. $value = rgar($lead, $field_id);
  665. if($field['type'] == 'post_category')
  666. $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
  667. //filtering lead value
  668. $value = apply_filters("gform_get_field_value", $value, $lead, $field);
  669. $input_type = !empty($columns[$field_id]["inputType"]) ? $columns[$field_id]["inputType"] : $columns[$field_id]["type"];
  670. switch($input_type){
  671. case "checkbox" :
  672. $value = "";
  673. //if this is the main checkbox field (not an input), display a comma separated list of all inputs
  674. if(absint($field_id) == $field_id){
  675. $lead_field_keys = array_keys($lead);
  676. $items = array();
  677. foreach($lead_field_keys as $input_id){
  678. if(is_numeric($input_id) && absint($input_id) == $field_id){
  679. $items[] = GFCommon::selection_display(rgar($lead, $input_id), null, $lead["currency"], false);
  680. }
  681. }
  682. $value = GFCommon::implode_non_blank(", ", $items);
  683. // special case for post category checkbox fields
  684. if($field['type'] == 'post_category')
  685. $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
  686. }
  687. else{
  688. $value = "";
  689. //looping through lead detail values trying to find an item identical to the column label. Mark with a tick if found.
  690. $lead_field_keys = array_keys($lead);
  691. foreach($lead_field_keys as $input_id){
  692. //mark as a tick if input label (from form meta) is equal to submitted value (from lead)
  693. if(is_numeric($input_id) && absint($input_id) == absint($field_id)){
  694. if($lead[$input_id] == $columns[$field_id]["label"]){
  695. $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
  696. }
  697. else{
  698. $field = RGFormsModel::get_field($form, $field_id);
  699. if(rgar($field, "enableChoiceValue") || rgar($field, "enablePrice")){
  700. foreach($field["choices"] as $choice){
  701. if($choice["value"] == $lead[$field_id]){
  702. $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
  703. break;
  704. }
  705. else if($field["enablePrice"]){
  706. $ary = explode("|", $lead[$field_id]);
  707. $val = count($ary) > 0 ? $ary[0] : "";
  708. $price = count($ary) > 1 ? $ary[1] : "";
  709. if($val == $choice["value"]){
  710. $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
  711. break;
  712. }
  713. }
  714. }
  715. }
  716. }
  717. }
  718. }
  719. }
  720. break;
  721. case "post_image" :
  722. list($url, $title, $caption, $description) = rgexplode("|:|", $value, 4);
  723. if(!empty($url)){
  724. //displaying thumbnail (if file is an image) or an icon based on the extension
  725. $thumb = self::get_icon_url($url);
  726. $value = "<a href='" . esc_attr($url) . "' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='$thumb'/></a>";
  727. }
  728. break;
  729. case "fileupload" :
  730. $file_path = $value;
  731. if(!empty($file_path)){
  732. //displaying thumbnail (if file is an image) or an icon based on the extension
  733. $thumb = self::get_icon_url($file_path);
  734. $file_path = esc_attr($file_path);
  735. $value = "<a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='$thumb'/></a>";
  736. }
  737. break;
  738. case "source_url" :
  739. $value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) ."' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
  740. break;
  741. case "textarea…

Large files files are truncated, but you can click here to view the full file