Example #1
0
<?php

//----------------
$action = isset($_GET['action']) && sanitize_text_field($_GET["action"]) ? sanitize_text_field($_GET["action"]) : "all";
$pagenum = isset($_GET['paged']) && sanitize_text_field($_GET["paged"]) ? intval(sanitize_text_field($_GET["paged"])) : 1;
$workflow_service = new OW_Workflow_Service();
if ($action == 'hideNotice') {
    update_site_option("oasiswf_show_upgrade_notice", "no");
    $workflows = $workflow_service->get_workflow_list("all");
    $wf_class["all"] = 'class="current"';
} else {
    $workflows = $workflow_service->get_workflow_list($action);
    $wf_class[$action] = 'class="current"';
}
$wf_count_by_status = $workflow_service->get_workflow_count_by_status();
$workflow_count = count($workflows);
$per_page = OASIS_PER_PAGE;
OW_Utility::instance()->owf_pro_features();
?>
<div class="wrap">
   <div id="icon-edit" class="icon32 icon32-posts-post"><br></div>
   <h2><?php 
echo __("Edit Workflows", "oasisworkflow");
?>
</h2>
   <div id="view-workflow">
      <div class="tablenav">
         <ul class="subsubsub">
            <?php 
$active_val = isset($wf_class["active"]) ? $wf_class["active"] : "";
$inactive_val = isset($wf_class["inactive"]) ? $wf_class["inactive"] : "";
 private function validate_steps($wf_info)
 {
     $error_messages = "";
     $wf_info = json_decode($wf_info);
     $step_count = 0;
     // loop through all the steps
     if ($wf_info->steps) {
         foreach ($wf_info->steps as $step) {
             if ($step->fc_dbid == "nodefine") {
                 // if fc_dbid is not defined, which means we have a missing step information
                 $error_messages .= __("Missing \"", "oasisworkflow");
                 $error_messages .= $step->fc_label;
                 $error_messages .= __("\" step information. Right click on the step to edit step information.", "oasisworkflow");
                 $error_messages .= "<br>";
                 // add new line for new messages to append on new line
             }
             // end if
             $step_count++;
         }
         // end for
     }
     // end if
     if ($step_count == 0) {
         $error_messages .= __("No steps found.", "oasisworkflow");
         $error_messages .= "<br>";
         // add new line for new messages to append on new line
     }
     $workflow_service = new OW_Workflow_Service();
     $steps = $workflow_service->get_first_and_last_steps($wf_info);
     if ($steps != "nodefine" && count($steps["first"]) == 0 && count($steps["last"]) == 0) {
         $error_messages .= __("The workflow doesn't have a valid exit path.\tItems in this workflow will never exit the workflow. Please provide a valid exit path.", "oasisworkflow");
         $error_messages .= "<br>";
         // add new line for new messages to append on new line
     }
     if (count($wf_info->first_step) > 1) {
         $error_messages .= __('Multiple steps marked as first step. Workflow can have only one starting point.', "oasisworkflow");
         $error_messages .= "<br>";
         // add new line for new messages to append on new line
     }
     if (count($wf_info->first_step) == 0) {
         $error_messages .= __('Starting step not found. Workflow should have a starting point.', "oasisworkflow");
         $error_messages .= "<br>";
         // add new line for new messages to append on new line
     }
     return $error_messages;
 }
Example #3
0
<?php

global $wpdb, $chkResult;
$ow_workflow_service = new OW_Workflow_Service();
if (is_admin() && preg_match_all('/page=oasiswf(.*)|post-new\\.(.*)|post\\.(.*)/', $_SERVER['REQUEST_URI'], $matches)) {
    wp_enqueue_script('owf-workflow-history', OASISWF_URL . 'js/pages/subpages/history-graphic.js', '', OASISWF_VERSION, true);
}
$workflow = null;
$post_id = intval(sanitize_text_field($_GET['post']));
if (is_numeric($chkResult)) {
    $sql = "SELECT C.ID, C.wf_info\n   \t\t\tFROM (\n   \t\t\t\t(SELECT * FROM " . OW_Utility::instance()->get_action_history_table_name() . " WHERE ID = {$chkResult}) AS A\n   \t\t\t\tLEFT JOIN " . OW_Utility::instance()->get_workflow_steps_table_name() . " AS B\n   \t\t\t\tON A.step_id = B.ID\n   \t\t\t\tLEFT JOIN " . OW_Utility::instance()->get_workflows_table_name() . " AS C\n   \t\t\t\tON B.workflow_id = C.ID\n   \t\t\t)";
    $workflow = $wpdb->get_row($sql);
}
if ($workflow) {
    $sql = "SELECT * FROM " . OW_Utility::instance()->get_action_history_table_name() . " WHERE ID <= {$chkResult} AND (action_status = 'processed' OR action_status = 'assignment') AND post_id = %d ORDER BY ID";
    $processes = $wpdb->get_results($wpdb->prepare($sql, $post_id));
    if ($processes) {
        $startid = "";
        foreach ($processes as $process) {
            if ($startid) {
                $newconns[] = $ow_workflow_service->get_connection($workflow, $startid, $process->step_id);
            }
            $startid = $process->step_id;
        }
        $current_step_id = $ow_workflow_service->get_gpid_dbid($workflow->wf_info, $startid);
        $wf_info = $workflow->wf_info;
    }
    echo "<script type='text/javascript'>\n\t\t\tvar wfPluginUrl  = '" . OASISWF_URL . "' ;\n\t\t\tvar stepinfo='{$wf_info}' ;\n\t\t\tvar currentStepGpId='{$current_step_id}' ;\n\t\t</script>";
}
?>
<div id="workflow-area" style="position:relative;width:100%;"></div>
Example #4
0
<?php

$wf_id = "";
$workflow = "";
$wf_editable = true;
if (isset($_GET['wf_id']) && sanitize_text_field($_GET["wf_id"])) {
    $wf_id = intval(sanitize_text_field($_GET["wf_id"]));
    $workflow_service = new OW_Workflow_Service();
    $workflow = $workflow_service->get_workflow_by_id($wf_id);
    $wf_editable = $workflow_service->is_workflow_editable($wf_id);
    // check if editable.
}
$workflow_info = "";
if (is_object($workflow)) {
    $workflow_info = addslashes($workflow->wf_info);
}
$title = "";
$workflow_description = "";
$start_date = "";
$end_date = "";
if ($workflow) {
    $title = $workflow->name;
    $workflow_description = $workflow->description;
    $start_date = OW_Utility::instance()->format_date_for_display_and_edit($workflow->start_date);
    $end_date = OW_Utility::instance()->format_date_for_display_and_edit($workflow->end_date);
}
echo "<script type='text/javascript'>\n\t\t   wf_structure_data = '{$workflow_info}';\n\t\t   wfeditable = '{$wf_editable}' ;\n\t   </script>";
?>
<div class="wrap">
   <div id="workflow-edit-icon" class="icon32"><br></div>
   <?php 
Example #5
0
<?php

global $ow_custom_statuses;
$selected_term = FALSE;
if (isset($_GET['category']) && !empty($_GET['category']) && isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'category_filter')) {
    $selected_term = trim($_GET['category']);
}
// sanitize the data
$selected_user = isset($_GET['user']) && sanitize_text_field($_GET["user"]) ? intval(sanitize_text_field($_GET["user"])) : get_current_user_id();
$page_number = isset($_GET['paged']) && sanitize_text_field($_GET["paged"]) ? intval(sanitize_text_field($_GET["paged"])) : 1;
$ow_inbox_service = new OW_Inbox_Service();
$ow_process_flow = new OW_Process_Flow();
$ow_workflow_service = new OW_Workflow_Service();
// get assigned posts for selected user
$inbox_items = $ow_process_flow->get_assigned_post(null, $selected_user);
$count_posts = count($inbox_items);
$per_page = OASIS_PER_PAGE;
// TODO: see how to better look into the capabilities of current user
$is_post_editable = current_user_can('edit_others_posts');
$current_user_role = OW_Utility::instance()->get_current_user_role();
$current_user_id = get_current_user_id();
// get custom terminology
$workflow_terminology_options = get_option('oasiswf_custom_workflow_terminology');
$sign_off_label = !empty($workflow_terminology_options['signOffText']) ? $workflow_terminology_options['signOffText'] : __('Sign Off', 'oasisworkflow');
$abort_workflow_label = !empty($workflow_terminology_options['abortWorkflowText']) ? $workflow_terminology_options['abortWorkflowText'] : __('Abort Workflow', 'oasisworkflow');
?>
<div class="wrap">
	<div id="icon-edit" class="icon32 icon32-posts-post"><br></div>
	<h2><?php 
echo __("Inbox", "oasisworkflow");
?>
<?php

$selected_user = isset($_REQUEST['user']) && sanitize_text_field($_REQUEST["user"]) ? intval(sanitize_text_field($_REQUEST["user"])) : null;
$page_number = isset($_GET['paged']) && sanitize_text_field($_GET["paged"]) ? intval(sanitize_text_field($_GET["paged"])) : 1;
$ow_process_flow = new OW_Process_Flow();
$assigned_tasks = $ow_process_flow->get_assigned_post(null, $selected_user);
$count_posts = count($assigned_tasks);
$workflow_service = new OW_Workflow_Service();
$per_page = OASIS_PER_PAGE;
$option = get_option('oasiswf_custom_workflow_terminology');
$due_date_title = !empty($option['dueDateText']) ? $option['dueDateText'] : __('Due Date', 'oasisworkflow');
?>
<div class="wrap">
	<form id="assignment_report_form" method="post" action="<?php 
echo admin_url('admin.php?page=oasiswf-reports&tab=userAssignments');
?>
">
      <div class="tablenav">
      	<ul class="subsubsub"></ul>
      	<div class="tablenav-pages">
      		<?php 
OW_Utility::instance()->get_page_link($count_posts, $page_number, $per_page);
?>
      	</div>
      </div>
   </form>
   <table class="wp-list-table widefat fixed posts" cellspacing="0" border=0>
   	<thead>
   		<?php 
echo "<tr>";
echo "<th class='column-role'>" . __("User", "oasisworkflow") . "</th>";
Example #7
0
<?php

$ow_workflow_service = new OW_Workflow_Service();
$workflows = $ow_workflow_service->get_workflow_by_validity(1);
$default_due_days = get_option('oasiswf_default_due_days');
$default_date = '';
if (!empty($default_due_days)) {
    $default_date = date(OASISWF_EDIT_DATE_FORMAT, current_time('timestamp') + DAY_IN_SECONDS * $default_due_days);
}
$publish_date = current_time(OASISWF_EDIT_DATE_FORMAT);
$publish_time_array = explode("-", current_time("H-i"));
$reminder_days = get_option('oasiswf_reminder_days');
$reminder_days_after = get_option('oasiswf_reminder_days_after');
$workflow_terminology_options = get_option('oasiswf_custom_workflow_terminology');
$assign_actors_label = !empty($workflow_terminology_options['assignActorsText']) ? $workflow_terminology_options['assignActorsText'] : __('Assign Actor(s)', 'oasisworkflow');
$due_date_label = !empty($workflow_terminology_options['dueDateText']) ? $workflow_terminology_options['dueDateText'] : __('Due Date', 'oasisworkflow');
$publish_date_label = !empty($workflow_terminology_options['publishDateText']) ? $workflow_terminology_options['publishDateText'] : __('Publish Date', 'oasisworkflow');
?>
<div class="info-setting" id="new-workflow-submit-div">
   <div class="dialog-title"><strong><?php 
echo __("Submit", "oasisworkflow");
?>
</strong></div>
   <div id="ow-step-messages" class="owf-hidden"></div>
   <div>
      <div class="select-part">
         <label><?php 
echo __("Workflow : ", "oasisworkflow");
?>
         </label>
         <select id="workflow-select" style="width:200px;">
 /**
  * saves workflow step - ajax function
  *
  * @since 2.0
  */
 public function save_workflow_step()
 {
     global $wpdb;
     // validate nonce
     check_ajax_referer('owf_workflow_create_nonce', 'security');
     if (!current_user_can('ow_edit_workflow')) {
         wp_die(__('You are not allowed to create/edit workflows.'));
     }
     // sanitize data
     $wf_id = isset($_POST["wf_id"]) ? intval(sanitize_text_field($_POST["wf_id"])) : "";
     $step_id = isset($_POST["step_id"]) ? sanitize_text_field($_POST["step_id"]) : "";
     $step_info = isset($_POST["step_info"]) ? sanitize_text_field($_POST["step_info"]) : "";
     // FIXED: Do not use sanitize_text_field or stripcslashes to keep user formated message
     $process_info = isset($_POST["process_info"]) ? $_POST["process_info"] : "";
     $workflow_step = new OW_Workflow_Step();
     $workflow_step->ID = $step_id;
     $workflow_step->workflow_id = $wf_id;
     $workflow_step->step_info = trim($step_info);
     $workflow_step->process_info = trim($process_info);
     $workflow_service = new OW_Workflow_Service();
     $step_id = $workflow_service->upsert_workflow_step($workflow_step);
     echo trim($step_id);
     die;
 }
Example #9
0
 public function get_step_mail_content($action_id, $step_id, $to_user_id, $post_id)
 {
     $action_id = intval($action_id);
     $step_id = intval($step_id);
     $to_user_id = intval($to_user_id);
     $post_id = intval($post_id);
     // get step information
     $workflow_service = new OW_Workflow_Service();
     $step = $workflow_service->get_step_by_id($step_id);
     /*
      * Replace the placeholders with actual value
      */
     $ow_placeholders = new OW_Place_Holders();
     // get post details
     $post = get_post($post_id);
     $blog_name = '[' . addslashes(get_bloginfo('name')) . '] ';
     if ($step && $post) {
         $messages = json_decode(trim($step->process_info));
         if (!$messages) {
             return false;
         }
         $post_link = '';
         $message_content = trim($messages->assign_content);
         // replace all the non visible characters with space
         $subject_line = str_replace(array("\\r\\n", "\\r", "\\n", "\\t", "<br />", ' '), '', trim($messages->assign_subject));
         $content_line = str_replace(array("\\r\\n", "\\r", "\\n", "\\t", "<br />", ' '), '', trim($message_content));
         // if the user didn't provide any comments, use default comments
         if (empty($content_line)) {
             $post_link = $ow_placeholders->get_post_title($post_id, $action_id, true);
         }
         $messages->assign_subject = !empty($subject_line) ? $blog_name . $messages->assign_subject : $blog_name . __("You have an assignment", "oasisworkflow");
         $messages->assign_content = !empty($content_line) ? $messages->assign_content : __("Ви маєте нове завдання по процесу модеріції, пов'язане з матеріалом - " . $post_link, "oasisworkflow");
         // replace the placeholders
         //TODO: to implement custom placeholders
         $callback_custom_placeholders = apply_filters('oasiswf_custom_placeholders_handler', $post);
         foreach ($messages as $k => $v) {
             $v = str_replace(OW_Place_Holders::FIRST_NAME, $ow_placeholders->get_first_name($to_user_id), $v);
             $v = str_replace(OW_Place_Holders::LAST_NAME, $ow_placeholders->get_last_name($to_user_id), $v);
             $v = str_replace(OW_Place_Holders::POST_CATEGORY, $ow_placeholders->get_post_categories($post_id), $v);
             $v = str_replace(OW_Place_Holders::POST_LAST_MODIFIED_DATE, $ow_placeholders->get_post_last_modified_date($post_id), $v);
             $v = str_replace(OW_Place_Holders::POST_PUBLISH_DATE, $ow_placeholders->get_post_publish_date($post_id), $v);
             if ($k === "assign_content" || $k === "reminder_content") {
                 //replace %post_title% with a link to the post
                 $v = str_replace(OW_Place_Holders::POST_TITLE, $ow_placeholders->get_post_title($post_id, $action_id, true), $v);
             }
             if ($k === "assign_subject" || $k === "reminder_subject") {
                 // since its a email subject, we don't need to have a link to the post
                 $v = str_replace(OW_Place_Holders::POST_TITLE, $ow_placeholders->get_post_title($post_id, $action_id, false), $v);
             }
             foreach ($callback_custom_placeholders as $ki => $vi) {
                 if (strpos($v, $ki) !== false) {
                     $v = str_replace($ki, $vi, $v);
                 }
             }
             $messages->{$k} = $v;
         }
         return $messages;
     }
     // looks like we either didn't find the post or the step
     return false;
 }
Example #10
0
<?php

if (isset($_GET['post']) && sanitize_text_field($_GET["post"]) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'owf_view_history_nonce')) {
    $selected_post = intval(sanitize_text_field($_GET["post"]));
} else {
    $selected_post = NULL;
}
$pagenum = isset($_GET['paged']) && sanitize_text_field($_GET["paged"]) ? intval(sanitize_text_field($_GET["paged"])) : 1;
$trashed = isset($_GET['trashed']) && sanitize_text_field($_GET["trashed"]) ? sanitize_text_field($_GET["trashed"]) : "";
if ($selected_post && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'owf_view_history_nonce')) {
    $selected_post = $selected_post;
} else {
    $selected_post = NULL;
}
$ow_history_service = new OW_History_Service();
$workflow_service = new OW_Workflow_Service();
$ow_process_flow = new OW_Process_Flow();
$histories = $ow_history_service->get_workflow_history_all($selected_post);
$count_posts = $ow_history_service->get_workflow_history_count($selected_post);
$per_page = OASIS_PER_PAGE;
$current_user_role = OW_Utility::instance()->get_current_user_role();
$option = get_option('oasiswf_custom_workflow_terminology');
$workflow_history = !empty($option['workflowHistoryText']) ? $option['workflowHistoryText'] : __('Workflow History', 'oasisworkflow');
?>
<div class="wrap">
   <div id="icon-edit" class="icon32 icon32-posts-post"><br></div>
   <h2><?php 
echo $workflow_history;
?>
</h2>
   <?php 
Example #11
0
$parent_page = isset($_GET["parent_page"]) && $_GET["parent_page"] ? sanitize_text_field($_GET["parent_page"]) : "post_edit";
//check to be called from which page
if (isset($_GET["task_user"]) && sanitize_text_field($_GET["task_user"])) {
    $task_user = intval(sanitize_text_field($_GET["task_user"]));
} else {
    if (isset($_GET["user"]) && sanitize_text_field($_GET["user"])) {
        $task_user = intval(sanitize_text_field($_GET["user"]));
    } else {
        $task_user = "";
    }
}
$editable = current_user_can('edit_posts');
$post_id = null;
$ow_process_flow = new OW_Process_Flow();
$ow_history_service = new OW_History_Service();
$ow_workflow_service = new OW_Workflow_Service();
if ($action_history_id) {
    $current_action = $ow_history_service->get_action_history_by_id($action_history_id);
    $current_step = $ow_workflow_service->get_step_by_id($current_action->step_id);
    $process = $ow_workflow_service->get_gpid_dbid($current_step->workflow_id, $current_action->step_id, "process");
    $success_status = json_decode($current_step->step_info);
    $success_status = $success_status->status;
    $post_id = $current_action->post_id;
}
$default_due_days = get_option('oasiswf_default_due_days');
$default_date = '';
if (!empty($default_due_days)) {
    $default_date = date(OASISWF_EDIT_DATE_FORMAT, current_time('timestamp') + DAY_IN_SECONDS * $default_due_days);
}
$reminder_days = get_option('oasiswf_reminder_days');
$reminder_days_after = get_option('oasiswf_reminder_days_after');
 public function get_step_status_by_step_id()
 {
     check_ajax_referer('owf_signoff_ajax_nonce', 'security');
     $step_id = intval($_POST["step_id"]);
     $ow_workflow_service = new OW_Workflow_Service();
     $step = $ow_workflow_service->get_step_by_id($step_id);
     $step_result = sanitize_text_field($_POST["review_result"]);
     if ($step) {
         $step_info = json_decode($step->step_info);
         $step_status = "draft";
         if ($step_result == "complete") {
             $step_status = $step_info->status;
         } else {
             $step_status = $step_info->failure_status;
         }
         if ($step_status) {
             echo trim($step_status);
             die;
         }
     }
 }