first commit
This commit is contained in:
19
plugins/rse_workflow/hooks/admin_group_permissions.php
Executable file
19
plugins/rse_workflow/hooks/admin_group_permissions.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
function HookRse_workflowAdmin_group_permissionsAdditionalperms()
|
||||
{
|
||||
include_once __DIR__ . "/../include/rse_workflow_functions.php";
|
||||
global $lang;
|
||||
# ------------ Edit access to workflow actions
|
||||
$workflowactions = rse_workflow_get_actions();
|
||||
?>
|
||||
<tr class="ListviewTitleStyle">
|
||||
<th colspan=3 class="permheader"><?php echo escape($lang["rse_workflow_actions_heading"]); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($workflowactions as $workflowaction) {
|
||||
DrawOption(
|
||||
"wf" . $workflowaction["ref"],
|
||||
$lang["rse_workflow_access"] . " " . $workflowaction["name"]
|
||||
);
|
||||
}
|
||||
}
|
21
plugins/rse_workflow/hooks/admin_home.php
Executable file
21
plugins/rse_workflow/hooks/admin_home.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
function HookRse_workflowAdmin_homeCustomadminsetup()
|
||||
{
|
||||
global $baseurl;
|
||||
global $lang;
|
||||
|
||||
if (checkperm("a"))
|
||||
{
|
||||
|
||||
?>
|
||||
<li title="<?php echo escape($lang["rse_workflow_manage_workflow-tooltip"]); ?>"><a href="<?php echo $baseurl ?>/plugins/rse_workflow/pages/edit_workflow.php" onclick="return CentralSpaceLoad(this,true);"><i class="fa fa-fw fa-check-square-o"></i><br /><?php echo escape($lang["rse_workflow_manage_workflow"]); ?></a></li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
226
plugins/rse_workflow/hooks/all.php
Executable file
226
plugins/rse_workflow/hooks/all.php
Executable file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
function HookRse_workflowAllInitialise()
|
||||
{
|
||||
include_once __DIR__."/../include/rse_workflow_functions.php";
|
||||
include_once __DIR__."/../../../include/language_functions.php";
|
||||
# Deny access to specific pages if RSE_KEY is not enabled and a valid key is not found.
|
||||
global $lang, $additional_archive_states, $fixed_archive_states, $wfstates, $searchstates, $workflowicons;
|
||||
|
||||
# Update $archive_states and associated $lang variables with entries from database
|
||||
$searchstates = array();
|
||||
$wfstates=rse_workflow_get_archive_states();
|
||||
|
||||
foreach($wfstates as $wfstateref=>$wfstate)
|
||||
{
|
||||
if (!$wfstate['fixed'])
|
||||
{
|
||||
$additional_archive_states[]=$wfstateref;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save for later so we know which are editable
|
||||
$fixed_archive_states[] = $wfstateref;
|
||||
}
|
||||
if((isset($wfstate['simple_search_flag']) && $wfstate['simple_search_flag'] != 0) || $wfstateref == 0) // Always include active state
|
||||
{
|
||||
$searchstates[] = $wfstateref;
|
||||
}
|
||||
$lang["status" . $wfstateref] = i18n_get_translated($wfstate["name"]);
|
||||
if(isset($wfstate['icon']) && trim($wfstate['icon']) != "")
|
||||
{
|
||||
$workflowicons[$wfstateref] = trim($wfstate['icon']);
|
||||
}
|
||||
}
|
||||
natsort($additional_archive_states);
|
||||
}
|
||||
|
||||
function HookRse_workflowAllAfter_update_archive_status($resource, $archive, $existingstates)
|
||||
{
|
||||
global $baseurl, $lang, $userref, $wfstates, $applicationname, $use_phpmailer;
|
||||
|
||||
$workflowaction = getval('workflowaction','');
|
||||
|
||||
// Set message text and URL to link to resources
|
||||
// The field 'more_workflow_action' is a hidden field which carries input text on the action specific form
|
||||
// A textarea named 'more_for_workflow_action' is effectively bound to and copies any keyboard input to 'more_workflow_action'
|
||||
$message = $lang["rse_workflow_state_notify_message"] . $lang["status" . $archive];
|
||||
|
||||
if(getval('more_workflow_action_' . $workflowaction,'') != '')
|
||||
{
|
||||
$message .= "\n\n" . $lang["rse_workflow_more_notes_title"];
|
||||
$message .= "\n\n" . getval('more_workflow_action_' . $workflowaction, '');
|
||||
}
|
||||
|
||||
if(count($resource) > 200)
|
||||
{
|
||||
// Too many resources to link to directly
|
||||
$linkurl = $baseurl . "/pages/search.php?search=archive" . $archive;
|
||||
}
|
||||
else
|
||||
{
|
||||
$linkurl = $baseurl . "/pages/search.php?search=!list" . implode(":",$resource);
|
||||
}
|
||||
|
||||
/***** NOTIFY GROUP SUPPORT IS NOW HANDLED BY ACTIONS *****/
|
||||
|
||||
/*****NOTIFY CONTRIBUTOR*****/
|
||||
if(isset($wfstates[$archive]['notify_user_flag']) && $wfstates[$archive]['notify_user_flag'] == 1)
|
||||
{
|
||||
$cntrb_arr = array();
|
||||
foreach($resource as $resourceref)
|
||||
{
|
||||
$resdata = get_resource_data($resourceref);
|
||||
if(isset($resdata['created_by']) && is_numeric($resdata['created_by']))
|
||||
{
|
||||
$contuser = get_user($resdata['created_by']);
|
||||
if(!$contuser)
|
||||
{
|
||||
// No contributor listed
|
||||
debug("No valid contributor listed for resource " . $resourceref);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!isset($cntrb_arr[$contuser["ref"]]))
|
||||
{
|
||||
// This contributor needs to be added to the array of users to notify
|
||||
$cntrb_arr[$contuser["ref"]] = array();
|
||||
$cntrb_arr[$contuser["ref"]]["resources"] = array();
|
||||
$cntrb_arr[$contuser["ref"]]["email"] = $contuser["email"];
|
||||
$cntrb_arr[$contuser["ref"]]["username"] = $contuser["username"];
|
||||
}
|
||||
$cntrb_arr[$contuser["ref"]]["resources"][] = $resourceref;
|
||||
}
|
||||
}
|
||||
// Construct messages for each user
|
||||
foreach($cntrb_arr as $cntrb_user => $cntrb_detail)
|
||||
{
|
||||
debug("processing notification for contributing user " . $cntrb_user);
|
||||
$message = new ResourceSpaceUserNotification;
|
||||
$message->set_subject($applicationname . ": ");
|
||||
$message->append_subject("lang_status" . $archive);
|
||||
$message->set_text("lang_userresources_status_change");
|
||||
$message->append_text("lang_status" . $archive);
|
||||
if(getval('more_workflow_action_' . $workflowaction,'') != '')
|
||||
{
|
||||
$message->append_text("<br/><br/>");
|
||||
$message->append_text("lang_rse_workflow_more_notes_title");
|
||||
$message->append_text("<br/>" . getval('more_workflow_action_' . $workflowaction, ''));
|
||||
}
|
||||
if(count($cntrb_detail["resources"]) > 200)
|
||||
{
|
||||
// Too many resources to link to directly
|
||||
$linkurl = $baseurl . "/pages/search.php?search=archive" . $archive;
|
||||
}
|
||||
else
|
||||
{
|
||||
$linkurl = $baseurl . "/pages/search.php?search=!list" . implode(":",$cntrb_detail["resources"]);
|
||||
}
|
||||
$message->url = $linkurl;
|
||||
send_user_notification([$cntrb_user],$message);
|
||||
|
||||
if($wfstates[$archive]["rse_workflow_bcc_admin"]==1)
|
||||
{
|
||||
debug("processing bcc notifications");
|
||||
$bccmessage = clone $message;
|
||||
$bccmessage->set_text("lang_user");
|
||||
$bccmessage->append_text(": " . $cntrb_detail["username"] . " (#" . $cntrb_user . ")<br/>");
|
||||
$bccmessage->append_text_multi($message->get_text(true));
|
||||
$bccadmin_users = get_notification_users("SYSTEM_ADMIN");
|
||||
send_user_notification($bccadmin_users,$bccmessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*****END OF NOTIFY CONTRIBUTOR*****/
|
||||
}
|
||||
|
||||
|
||||
function HookRse_workflowAllRender_actions_add_collection_option($top_actions, array $options, $collection_data, $urlparams)
|
||||
{
|
||||
global $baseurl_short, $lang, $pagename, $count_result;
|
||||
|
||||
// Make sure this check takes place before $GLOBALS["hook_return_value"] can be unset by subsequent calls to hook()
|
||||
if(isset($GLOBALS["hook_return_value"]) && is_array($GLOBALS["hook_return_value"]))
|
||||
{
|
||||
// @see hook() for an explanation about the hook_return_value global
|
||||
$options = $GLOBALS["hook_return_value"];
|
||||
}
|
||||
|
||||
// On special search !collection the actions will be added from HookRse_workflowSearchRender_search_actions_add_option
|
||||
if($pagename != "collections" || $count_result == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$wf_actions_options = rse_workflow_compile_actions($urlparams);
|
||||
|
||||
return array_merge($options, $wf_actions_options);
|
||||
}
|
||||
|
||||
function HookRse_workflowAllRender_search_actions_add_option(array $options, array $urlparams)
|
||||
{
|
||||
global $internal_share_access;
|
||||
|
||||
// Make sure this check takes place before $GLOBALS["hook_return_value"] can be unset by subsequent calls to hook()
|
||||
if(isset($GLOBALS["hook_return_value"]) && is_array($GLOBALS["hook_return_value"]))
|
||||
{
|
||||
// @see hook() for an explanation about the hook_return_value global
|
||||
$options = $GLOBALS["hook_return_value"];
|
||||
}
|
||||
|
||||
$k = trim((isset($urlparams["k"]) ? $urlparams["k"] : ""));
|
||||
|
||||
if($k != "" && $internal_share_access === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$wf_actions_options = rse_workflow_compile_actions($urlparams);
|
||||
|
||||
// Append to the current allow list of render_actions_filter (for the selection collection)
|
||||
$current_render_actions_filter = $GLOBALS['render_actions_filter'] ?? fn($action) => true;
|
||||
$GLOBALS['render_actions_filter'] = function($action) use ($current_render_actions_filter, $wf_actions_options)
|
||||
{
|
||||
return $current_render_actions_filter($action)
|
||||
|| in_array($action['value'], array_column($wf_actions_options, 'value'));
|
||||
};
|
||||
|
||||
return array_merge($options, $wf_actions_options);
|
||||
}
|
||||
|
||||
function HookRse_workflowAllRender_actions_add_option_js_case($action_selection_id)
|
||||
{
|
||||
?>
|
||||
case 'rse_workflow_move_to_workflow':
|
||||
var option_url = jQuery('#<?php echo $action_selection_id; ?> option:selected').data('url');
|
||||
ModalLoad(option_url, true, true);
|
||||
break;
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function HookRse_workflowAllAfter_setup_user()
|
||||
{
|
||||
// Replaces notify group messaging - now replaced by actions
|
||||
global $userref, $usergroup;
|
||||
|
||||
get_config_option(['user' => $userref, 'usergroup' => $usergroup],'user_pref_resource_notifications', $addwfactions);
|
||||
if (!$addwfactions)
|
||||
{
|
||||
// No notifications were sent so actions shouldn't appear either
|
||||
return false;
|
||||
}
|
||||
|
||||
$extra_notify_states = [];
|
||||
$wfstates=rse_workflow_get_archive_states();
|
||||
foreach($wfstates as $wfstateref=>$wfstate)
|
||||
{
|
||||
if(isset($wfstate['notify_group']) && (int)$wfstate['notify_group'] == $usergroup && !checkperm("z" . $wfstateref))
|
||||
{
|
||||
$extra_notify_states[] = $wfstateref;
|
||||
}
|
||||
}
|
||||
if(count($extra_notify_states) > 0)
|
||||
{
|
||||
$GLOBALS['actions_notify_states'] .= "," . implode(",",$extra_notify_states);
|
||||
}
|
||||
}
|
223
plugins/rse_workflow/hooks/view.php
Executable file
223
plugins/rse_workflow/hooks/view.php
Executable file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
function HookRse_workflowViewPageevaluation()
|
||||
{
|
||||
include_once __DIR__ . "/../include/rse_workflow_functions.php";
|
||||
global $lang;
|
||||
global $ref;
|
||||
global $resource;
|
||||
global $baseurl;
|
||||
global $search;
|
||||
global $offset;
|
||||
global $order_by;
|
||||
global $archive;
|
||||
global $sort;
|
||||
global $k;
|
||||
global $userref;
|
||||
# Retrieve list of existing defined actions
|
||||
$workflowactions = rse_workflow_get_actions();
|
||||
|
||||
foreach ($workflowactions as $workflowaction)
|
||||
{
|
||||
if(getval("rse_workflow_action_" . $workflowaction["ref"],"")!="" && enforcePostRequest(false))
|
||||
{
|
||||
// Check if resource status has already been changed between form being loaded and submitted
|
||||
$resource_status_check_name = "resource_status_check_" . $workflowaction["ref"];
|
||||
$resource_status_check = getval($resource_status_check_name,"");
|
||||
if($resource_status_check != "" && $resource_status_check != $resource["archive"])
|
||||
{
|
||||
$errors["status"] = $lang["status"] . ': ' . $lang["save-conflict-error"];
|
||||
echo "<div class=\"PageInformal\">" . $lang["error"] . ": " . $lang["status"] . " - " . $lang["save-conflict-error"] . "</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$validstates = explode(',', $workflowaction['statusfrom']);
|
||||
$edit_access = get_edit_access($ref,$resource['archive'], $resource);
|
||||
|
||||
if('' != $k || ($resource["lock_user"] > 0 && $resource["lock_user"] != $userref))
|
||||
{
|
||||
$edit_access = 0;
|
||||
}
|
||||
|
||||
if(
|
||||
in_array($resource['archive'], $validstates)
|
||||
&& (
|
||||
(
|
||||
$edit_access
|
||||
&& checkperm("e{$workflowaction['statusto']}")
|
||||
)
|
||||
|| checkperm("wf{$workflowaction['ref']}")
|
||||
)
|
||||
)
|
||||
{
|
||||
// Check whether More notes are present
|
||||
$more_notes_text = getval("more_workflow_action_" . $workflowaction["ref"],"");
|
||||
update_archive_status($ref, $workflowaction["statusto"], $resource["archive"], 0, $more_notes_text);
|
||||
hook("rse_wf_archivechange","",array($ref,$resource["archive"],$workflowaction["statusto"]));
|
||||
|
||||
if (checkperm("z" . $workflowaction["statusto"]))
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
styledalert('<?php echo escape($lang["success"]); ?>','<?php echo escape($lang["rse_workflow_saved"]) . " " . escape($lang["status" . $workflowaction["statusto"]]);?>');
|
||||
if(jQuery("#modal").is(":visible"))
|
||||
{
|
||||
ModalClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.setTimeout(function(){CentralSpaceLoad(baseurl_short);},1000);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<div class=\"PageInformal\">" . $lang["rse_workflow_saved"] . " " . $lang["status" . $workflowaction["statusto"]] . "</div>";
|
||||
$resource["archive"]=$workflowaction["statusto"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function HookRse_workflowViewAdditionaldownloadtabs()
|
||||
{
|
||||
include_once __DIR__ . "/../include/rse_workflow_functions.php";
|
||||
|
||||
global $lang, $ref, $resource, $baseurl_short, $search, $offset, $order_by, $archive, $sort, $edit_access, $curpos,
|
||||
$userref, $k, $internal_share_access,$modal;
|
||||
|
||||
if(!empty($resource["lock_user"]) && $resource["lock_user"] != 0 && $resource["lock_user"] != $userref)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($k != "" && $internal_share_access === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$validactions = rse_workflow_get_valid_actions(rse_workflow_get_actions(), false);
|
||||
|
||||
if(count($validactions)>0)
|
||||
{?>
|
||||
<div class="RecordDownloadSpace" id="ResourceWorkflowActions" style="display:none;">
|
||||
<p><?php echo escape($lang['rse_workflow_user_info']); ?></p>
|
||||
<script type="text/javascript">
|
||||
function open_notes(action_ref) {
|
||||
var workflow_action = jQuery('#rse_workflow_action_' + action_ref);
|
||||
var more_link = jQuery('#more_link_' + action_ref);
|
||||
|
||||
// Populate textarea with any text there may already be present
|
||||
var more_text_hidden = jQuery('#more_workflow_action_' + action_ref).val();
|
||||
|
||||
more_link.after('<textarea id="more_for_workflow_action_' + action_ref
|
||||
+ '" name="more_for_workflow_action_' + action_ref
|
||||
+ '" style="width: 100%; resize: none;" rows="6">' + more_text_hidden + '</textarea>');
|
||||
more_link.after('<p id="notes_for_workflow_action_' + action_ref + '"><?php echo escape($lang["rse_workflow_more_notes_title"]); ?></p>');
|
||||
|
||||
more_link.text('<?php echo escape($lang["rse_workflow_link_close"]); ?>');
|
||||
more_link.attr('onClick', 'close_notes(' + action_ref + ');');
|
||||
|
||||
// Bind the input textarea 'more_for_workflow_action' value to the hidden 'more_workflow_action' field
|
||||
jQuery('#more_for_workflow_action_' + action_ref).keyup(function (event) {
|
||||
var notes = this.value;
|
||||
jQuery('#more_workflow_action_' + action_ref).val(notes);
|
||||
});
|
||||
}
|
||||
|
||||
function close_notes(action_ref) {
|
||||
|
||||
var more_link = jQuery('#more_link_' + action_ref);
|
||||
var notes_title = jQuery('#notes_for_workflow_action_' + action_ref);
|
||||
var notes_textarea = jQuery('#more_for_workflow_action_' + action_ref);
|
||||
|
||||
// Remove Notes title and textarea from DOM:
|
||||
notes_title.remove();
|
||||
notes_textarea.remove();
|
||||
|
||||
more_link.text('<?php echo escape($lang["rse_workflow_link_open"]); ?>');
|
||||
more_link.attr('onClick', 'open_notes(' + action_ref + ');');
|
||||
|
||||
}
|
||||
</script>
|
||||
<table cellpadding="0" cellspacing="0" id="ResourceWorkflowTable">
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
foreach($validactions as $validaction)
|
||||
{
|
||||
$show_more_link = false;
|
||||
if(!empty($validaction['more_notes_flag']) && $validaction['more_notes_flag'] == 1) {
|
||||
$show_more_link = true;
|
||||
}
|
||||
?>
|
||||
<tr class="DownloadDBlend">
|
||||
<td><?php echo escape(i18n_get_translated($validaction["text"],"workflow-actions")); if($show_more_link) { ?><a href="#" id="more_link_<?php echo $validaction["ref"]; ?>" onClick="open_notes(<?php echo $validaction["ref"]; ?>);" style="float: right;"><?php echo escape($lang['rse_workflow_link_open']); ?></a><?php } ?></td>
|
||||
<td>
|
||||
<form action="<?php echo $baseurl_short?>pages/view.php?ref=<?php echo urlencode($ref)?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset)?>&order_by=<?php echo urlencode($order_by)?>&sort=<?php echo urlencode($sort)?>&archive=<?php echo urlencode($archive)?>&curpos=<?php echo urlencode($curpos)?>&workflowaction=<?php echo urlencode($validaction["ref"])?>"
|
||||
id="resource_<?php echo $ref; ?>_workflowaction<?php echo $validaction['ref']; ?>">
|
||||
<input id='resource_status_checksum_<?php echo $validaction["ref"]; ?>' name='resource_status_check_<?php echo $validaction["ref"]; ?>' type='hidden' value='<?php echo $resource["archive"]; ?>'>
|
||||
<?php
|
||||
if(isset($modal) && $modal=="true")
|
||||
{
|
||||
?>
|
||||
<input type="hidden" name="modal" id="rse_workflow_modal_<?php echo $validaction["ref"]; ?>" value="true" >
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="hidden" name="rse_workflow_action_<?php echo $validaction["ref"]; ?>" id="rse_workflow_action_<?php echo $validaction["ref"]; ?>" value="true" >
|
||||
<input type="hidden" name="more_workflow_action_<?php echo $validaction["ref"]; ?>" id="more_workflow_action_<?php echo $validaction["ref"]; ?>" value="" >
|
||||
<input type="submit" name="rse_workflow_action_submit_<?php echo $validaction["ref"]; ?>" id="rse_workflow_action_submit_<?php echo $validaction["ref"]; ?>" value=" <?php echo escape(i18n_get_translated($validaction["buttontext"],"workflow-actions")); ?> " onClick="return <?php echo $modal ? "Modal" : "CentralSpace"; ?>Post(document.getElementById('resource_<?php echo $ref; ?>_workflowaction<?php echo $validaction['ref']; ?>'), true);" >
|
||||
<?php
|
||||
generateFormToken("resource_{$ref}_workflowaction{$validaction['ref']}");
|
||||
hook("rse_wf_formend","",array($resource["archive"],$validaction["statusto"]));
|
||||
?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
}?>
|
||||
</tbody></table>
|
||||
</div><!-- End of RecordDownloadSpace-->
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
function HookRse_workflowViewAdditionaldownloadtabbuttons()
|
||||
{
|
||||
global $lang, $modal;
|
||||
|
||||
$validactions = rse_workflow_get_valid_actions(rse_workflow_get_actions(), false);
|
||||
|
||||
if (count($validactions) > 0)
|
||||
{
|
||||
?>
|
||||
<div class="Tab" id="ResourceWorkflowActionsButton">
|
||||
<a href="#" onclick="selectDownloadTab('ResourceWorkflowActions',<?php echo $modal ? 'true' : 'false'; ?>);">
|
||||
<?php echo escape($lang["rse_workflow_actions_heading"]) ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
function HookRse_workflowViewReplacetitleprefix($state)
|
||||
{
|
||||
global $lang,$additional_archive_states;
|
||||
|
||||
if ($state<=3) {return false;} # For custom states only.
|
||||
|
||||
$name=ps_value("SELECT name value FROM archive_states WHERE code = ?",["i",$state],"");
|
||||
|
||||
?><span class="ResourceTitleWorkflow<?php echo $state ?>"><?php echo i18n_get_translated($name) ?>:</span> <?php
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user