PageRenderTime 56ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/gravityforms/entry_list.php

https://github.com/petergibbons/OpenCounterWP
PHP | 1322 lines | 1062 code | 236 blank | 24 comment | 135 complexity | b73545f64f04766fb0d1c1b8ff603756 MD5 | raw file

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

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