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(); } }