public static function add_message($message_code, $podname, $record_id, $allow_message_duplication = FALSE) { if (!$allow_message_duplication) { dms_messages::delete_message($message_code, $podname, $record_id); } $data_messages_pods = pods("jomiz_dms_data_pods_messages"); $data = array("name" => $message_code, "pod_name" => $podname, "record_id" => $record_id); $data_messages_pods->add($data); $message_pod = pods("jomiz_dms_available_messages", array("where" => "message_code = '{$message_code}'")); while ($message_pod->fetch()) { $message_type = $message_pod->field("message_type"); if ($message_type == 'status' || $message_type == "sealed") { $link = pods_related::get_pod_url($podname, "edit", $record_id); $text = "New status added to document: " . $message_pod->field("name"); $record_pod = pods($podname, $record_id); $record_owner = $record_pod->field("author.ID"); dms_messages::add_notification($record_owner, $link, $text); } } }
<?php /* Template Name: Delete Pods */ $podname = isset($_GET['type']) ? $_GET['type'] : ""; $id = isset($_GET['id']) ? $_GET['id'] : -1; if ($podname == '') { echo core_utilities::get_error_message("No Type Avaliable"); return; } if ($id < 0 || !is_numeric($id)) { echo core_utilities::get_error_message("Record Id Type Avaliable"); return; } $return_url = isset($_GET['return-to']) ? urldecode($_GET['return-to']) : pods_related::get_pod_url($podname, "list"); if ($_GET['confirm-delete'] == 1) { $pod_to_delete = pods($podname, $id); $pod_to_delete->delete(); wp_redirect($return_url); return; } settype($id, "integer"); $PodsAPI = pods_api(); $pods_info = $PodsAPI->load_pod(array('name' => $podname)); $record_sealed = dms_data::is_record_sealed($podname, $id); $notification_message = ""; $notification_css_class = ""; if ($record_sealed) { if (dms_security::is_allowed($podname, "delete_sealed")) { $notification_message = '<span class="glyphicon glyphicon-lock"></span> This document is locked. Are you sure you want to delete it?';
public static function get_edit_page_toolbar($podname, $return_url, $record_id, $record_sealed = null, $params = array()) { // Basic Toolbar (Save | Save & Close | Cancel) if ($record_sealed == null) { $record_sealed = dms_data::is_record_sealed($podname, $record_id); } if ($params['overwrite_seal'] || !$record_sealed && !isset($_GET['lock-screen'])) { $basic_toolbar = "<a disabled='disabled' id='toolbar-button-waiting' class='btn btn-info' href='#' title='Please wait while saving.'><span class='glyphicon glyphicon-time'></span></a>"; $basic_toolbar .= "<a class='btn btn-primary' href='#' title='Save' onclick='save_jomizdms_form()'><span class='glyphicon glyphicon-floppy-disk'></span></a>"; } $basic_toolbar .= "<a class='btn btn-default' href='{$return_url}' title='Cancel'><span class='glyphicon glyphicon-floppy-remove'></span></a>"; $basic_toolbar = "<div class='btn-group' role='group' aria-label='Save'>{$basic_toolbar}</div>"; // Default Operations (Delete | Print) // Print if ($record_id > 0) { // Get Print Operations $print_params = array(); $print_params['where'] = "pod_name = '{$podname}'"; $print_params['orderby'] = "display_order"; $print_params['limit'] = -1; $print_pods = pods("jomiz_dms_prints", $print_params); $default_operations = ""; while ($print_pods->fetch()) { $print_url = pods_related::get_print_url($print_pods, $podname, $record_id); $button_type = $print_pods->field("button_type"); $capability = $print_pods->field("capability"); $print_title = $print_pods->field("name"); $message_code_to_disallow = $print_pods->field("message_code_to_disallow"); if ($capability != "" && !dms_security::is_allowed_cap($capability)) { continue; } if ($message_code_to_disallow != "" && dms_messages::has_message_code($podname, $record_id, $message_code_to_disallow)) { continue; } if ($button_type == "") { $button_type = "btn-default"; } $default_operations .= "<a target='_blank' class='btn {$button_type}' href='{$print_url}' title='{$print_title}'><span class='glyphicon glyphicon-print'></span></a>"; } } if (dms_security::is_allowed($podname, "delete") && !$record_sealed && $record_id > 0 && !isset($_GET['lock-screen'])) { $default_operations .= "<a class='btn btn-danger' href='" . pods_related::get_pod_url($podname, "delete", $record_id, TRUE, $return_url) . "' title='Delete'><span class='glyphicon glyphicon-trash'></span></a>"; } if ($default_operations != "") { $default_operations = "<div class='btn-group' role='group' aria-label='Basic Operations'>{$default_operations}</div>"; } // Custom Operations (From Setup Pods) $custom_operations = ""; if ($record_id > 0) { $has_errors = dms_messages::does_pod_record_has_error_messages($podname, $record_id); $actions_on_pod = pods("jomiz_dms_actions", array("where" => "t.pod_name = '{$podname}' AND t.status = 'active' AND t.action_type = 'toolbar'")); if ($actions_on_pod->total() > 0) { while ($actions_on_pod->fetch()) { $arguments = array("record_id" => $record_id); $arguments["podname"] = $podname; $arguments["message_code_to_allow_toolbar"] = $actions_on_pod->field("message_code_to_allow_toolbar"); $arguments["message_code_to_disallow_toolbar"] = $actions_on_pod->field("message_code_to_disallow_toolbar"); $arguments["custom_php"] = $actions_on_pod->field("custom_php"); $arguments["stop_on_error_messages"] = $actions_on_pod->field("stop_on_error_messages"); $arguments["capability"] = $actions_on_pod->field("capability"); if ($arguments["capability"] != "") { if (!dms_security::is_allowed_cap($arguments["capability"])) { continue; } } if ($actions_on_pod->field("stop_on_error_messages") == 1 && $has_errors) { continue; } if ($arguments["message_code_to_allow_toolbar"] != "") { if (!dms_messages::has_message_code($podname, $record_id, $arguments["message_code_to_allow_toolbar"])) { continue; } } if ($arguments["message_code_to_disallow_toolbar"] != "") { if (dms_messages::has_message_code($podname, $record_id, $arguments["message_code_to_disallow_toolbar"])) { continue; } } $action_text = $actions_on_pod->field("name"); $action_url = dms_action::get_action_url($actions_on_pod->field("id"), $record_id); $action_icon = $actions_on_pod->field("toolbar_icon"); $action_url = urlencode($action_url); $onclick = "redirect_to_page(\"{$action_url}\")"; $custom_operations .= "<a onclick='{$onclick}' class='btn btn-info' title='{$action_text}'><span class='glyphicon glyphicon-{$action_icon}'></span></a>"; } } } if ($custom_operations != "") { $custom_operations = "<div class='btn-group' role='group' aria-label='...'>{$custom_operations}</div>"; } // The Complete Toolbar $toolbar = "<div class='btn-toolbar pull-right' role='toolbar' aria-label='...'>\n\t\t\t\t\t {$basic_toolbar}\n\t\t\t\t\t {$default_operations}\n\t\t\t\t\t {$custom_operations}\n\t\t\t\t\t</div>"; return $toolbar; }
$operation_settings_pod = pods("jomiz_dms_gui_settings", array("where" => "t.pod_name = '{$podname}' AND (operation='add' OR operation='edit')")); $operation_settings = null; $extra_js = ""; if ($operation_settings_pod->total() > 0) { $operation_settings = json_decode($operation_settings_pod->field("settings")); $extra_js = $operation_settings_pod->field("extra_javascript"); } if ($use_dialog) { $use_tabs = FALSE; $after_save_url = $return_url; } elseif ($id == -1 && $related_pods->total() == 0) { $use_tabs = FALSE; $after_save_url = $return_url; } elseif ($id == -1) { // ADD - After Save Stay On The Same Page $same_page_url = pods_related::get_pod_url($podname, "edit", "X_ID_X", $use_dialog, $return_url); $use_tabs = TRUE; $after_save_url = $same_page_url; } elseif ($related_pods->total() == 0) { // EDIT - No Other Pods -> Back To Listing $use_tabs = FALSE; $after_save_url = $return_url; } else { // EDIT - Other Pods Exists -> Stay On The Same Page $use_tabs = TRUE; $after_save_url = $same_page_url; } if (isset($operation_settings->{"use_attachments"}) && $operation_settings->{"use_attachments"} == 1) { $use_tabs = TRUE; } // Workflow Settings