Beispiel #1
0
 public function enterNewWorkflow()
 {
     $config = new Configuration();
     //remove any current workflow steps
     $this->removeResourceSteps();
     //make sure this resource is marked in progress in case it was archived
     $status = new Status();
     $this->statusID = $status->getIDFromName('progress');
     $this->save();
     //Determine the workflow this resource belongs to
     $workflowObj = new Workflow();
     $workflowID = $workflowObj->getWorkflowID($this->resourceTypeID, $this->resourceFormatID, $this->acquisitionTypeID);
     if ($workflowID) {
         $workflow = new Workflow(new NamedArguments(array('primaryKey' => $workflowID)));
         //Copy all of the step attributes for this workflow to a new resource step
         foreach ($workflow->getSteps() as $step) {
             $resourceStep = new ResourceStep();
             $resourceStep->resourceStepID = '';
             $resourceStep->resourceID = $this->resourceID;
             $resourceStep->stepID = $step->stepID;
             $resourceStep->priorStepID = $step->priorStepID;
             $resourceStep->stepName = $step->stepName;
             $resourceStep->userGroupID = $step->userGroupID;
             $resourceStep->displayOrderSequence = $step->displayOrderSequence;
             $resourceStep->save();
         }
         //Start the first step
         //this handles updating the db and sending notifications for approval groups
         foreach ($this->getFirstSteps() as $resourceStep) {
             $resourceStep->startStep();
         }
     }
     //send an email notification to the feedback email address and the creator
     $cUser = new User(new NamedArguments(array('primaryKey' => $this->createLoginID)));
     $acquisitionType = new AcquisitionType(new NamedArguments(array('primaryKey' => $this->acquisitionTypeID)));
     if ($cUser->firstName) {
         $creator = $cUser->firstName . " " . $cUser->lastName;
     } else {
         if ($this->createLoginID) {
             //for some reason user isn't set up or their firstname/last name don't exist
             $creator = $this->createLoginID;
         } else {
             $creator = "(unknown user)";
         }
     }
     if ($config->settings->feedbackEmailAddress || $cUser->emailAddress) {
         $email = new Email();
         $util = new Utility();
         $email->message = $util->createMessageFromTemplate('NewResourceMain', $this->resourceID, $this->titleText, '', '', $creator);
         if ($cUser->emailAddress) {
             $emailTo[] = $cUser->emailAddress;
         }
         if ($config->settings->feedbackEmailAddress != '') {
             $emailTo[] = $config->settings->feedbackEmailAddress;
         }
         $email->to = implode(",", $emailTo);
         if ($acquisitionType->shortName) {
             $email->subject = "CORAL Alert: New " . $acquisitionType->shortName . " Resource Added: " . $this->titleText;
         } else {
             $email->subject = "CORAL Alert: New Resource Added: " . $this->titleText;
         }
         $email->send();
     }
 }
<?php

$resourceStepID = $_POST['resourceStepID'];
$userGroupID = $_POST['userGroupID'];
$applyToAll = $_POST['applyToAll'] == "true" ? true : false;
if ($resourceStepID != '') {
    $step = new ResourceStep(new NamedArguments(array('primaryKey' => $resourceStepID)));
    //business logic
    $step->userGroupID = $userGroupID;
    //if apply to all selected, we need to cycle through later steps.
    try {
        $step->restartReassignedStep();
        if ($applyToAll) {
            //get later open steps and restart those.
            $laterSteps = $step->getLaterOpenSteps();
            if (count($laterSteps) > 0) {
                foreach ($laterSteps as $laterStep) {
                    $laterStep->userGroupID = $userGroupID;
                    $laterStep->restartReassignedStep();
                }
            }
        }
    } catch (Exception $e) {
        echo $e->getMessage();
    }
} else {
    //do something for empty result
    echo "There was an error. Invalid or missing step.";
}
<?php

if (!isset($_GET['resourceStepID'])) {
    echo "<div><p>You must supply a valid resource step ID.</p></div>";
} else {
    $resourceStepID = $_GET['resourceStepID'];
    $resourceStep = new ResourceStep(new NamedArguments(array('primaryKey' => $resourceStepID)));
    //get step name & group
    $stepName = $resourceStep->attributes['stepName'];
    $stepGroupID = $resourceStep->attributes['userGroupID'];
    $orderNum = $resourceStep->attributes['displayOrderSequence'];
    $remainingSteps = $resourceStep->getNumberOfOpenSteps();
    //echo "the step name is ".$stepName.", and the group id is ". $stepGroup.".<br>\n";
    //get possible groups
    $userGroupArray = array();
    $userGroupObj = new UserGroup();
    $userGroupArray = $userGroupObj->allAsArray();
    //make form
    ?>
    <div id='div_resourceStepForm'>
        <form id='resourceStepForm'>
            <input type='hidden' name='editRSID' id='editRSID' value='<?php 
    echo $resourceStepID;
    ?>
'>
            <input type='hidden' name='orderNum' id='orderNum' value='<?php 
    echo $orderNum;
    ?>
'>
            <input type='hidden' name='currentGroupID' id='currentGroupID' value='<?php 
    echo $stepGroupID;
Beispiel #4
0
<?php

if ($_GET['resourceStepID']) {
    $resourceStepID = $_GET['resourceStepID'];
    $resourceStep = new ResourceStep(new NamedArguments(array('primaryKey' => $resourceStepID)));
    try {
        $resourceStep->completeStep();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
<?php

$resourceStepID = $_GET['resourceStepID'];
$resourceStep = new ResourceStep(new NamedArguments(array('primaryKey' => $resourceStepID)));
try {
    $resourceStep->delete();
    $resourceStep->startNextStepsOrComplete();
    //TODO fix the display order sequence if there are later steps
} catch (Exception $e) {
    echo $e->getMessage();
}