Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix PHP strict syntax issues.

  • Loading branch information...
commit eae2f4a7a3841f3e48685f09fe4d513c9c613039 1 parent 8354c3f
Tim Hunt timhunt authored
4 classes/command.php
View
@@ -155,9 +155,9 @@ public function role_users($role, $context) {
* @param object $workflow The workflow to be tested
* @return Boolean
*/
- public function is_activity($workflow) {
+ public static function is_activity($workflow) {
// All workflows barring courses are activities.
- return ($workflow->appliesto != 'course');
+ return $workflow->appliesto != 'course';
}
/**
3  classes/step.php
View
@@ -283,9 +283,10 @@ public static function clone_step($srcid, $workflowid = null) {
// Retrieve the source and copy it.
$src = new block_workflow_step($srcid);
+ $dst = new stdClass();
// Copy the source based on the allowed settings.
- foreach (self::expected_settings() as $k) {
+ foreach ($src->expected_settings() as $k) {
$dst->$k = $src->$k;
}
43 classes/workflow.php
View
@@ -303,9 +303,10 @@ public static function clone_workflow($srcid, $data) {
// Retrieve the source and copy it.
$src = new block_workflow_workflow($srcid);
+ $dst = new stdClass();
// Copy the source based on the allowed settings.
- foreach (self::expected_settings() as $k) {
+ foreach ($src->expected_settings() as $k) {
$dst->$k = $src->$k;
}
@@ -580,20 +581,22 @@ public function toggle() {
* ever been used and thus has state information
*
* @param int $id The ID of the workflow (defaults to the id of the current workflow)
- * @return Boolean Whether the workflow may be deleted or not
+ * @return bool whether the workflow may be deleted.
*/
public function is_deletable($id = null) {
- global $DB;
-
- if ($id === null) {
- // Get the current workflow id.
- $id = $this->id;
- }
-
- // Count the uses.
- $count = self::in_use_by($id);
+ return self::is_workflow_deletable($this->id);
+ }
- return (!$count > 0);
+ /**
+ * Determine whether a workflow is in use or not, and thus whether it can be removed.
+ *
+ * Workflows can only be removed if they are not in use.
+ *
+ * @param int $id The ID of the workflow.
+ * @return bool whether the workflow may be deleted.
+ */
+ public static function is_workflow_deletable($id) {
+ return self::in_use_by($id) == 0;
}
/**
@@ -615,21 +618,15 @@ public function require_deletable($id = null) {
}
/**
- * Determine how many locations the currently loaded, or the specified worklow is in use.
+ * Determine how many locations the specified worklow is in use.
*
- * @param int $id The ID of the workflow if the function is
- * called in a static context
- * @param boolean $activeonly Include active states only?
- * @return int How many places the workflow is in use
+ * @param int $id The ID of the workflow to check.
+ * @param bool $activeonly Include active states only?
+ * @return int How many places the workflow is in use.
*/
- public function in_use_by($id = null, $activeonly = false) {
+ public static function in_use_by($id, $activeonly = false) {
global $DB;
- // If no ID was specified, use the ID from the currently loaded object.
- if (!$id) {
- $id = $this->id;
- }
-
// Determine whether the workflow is currently assigned to any
// step_states, regardless of whether those states are are active
// or not.
6 renderer.php
View
@@ -257,7 +257,7 @@ protected function list_workflows($workflows) {
// Check whether each workflow is deletable.
foreach ($workflows as $workflow) {
- $workflow->is_deletable = block_workflow_workflow::is_deletable($workflow->id);
+ $workflow->is_deletable = block_workflow_workflow::is_workflow_deletable($workflow->id);
$table->data[] = $this->workflow_row($workflow);
}
@@ -731,7 +731,7 @@ public function display_workflow($workflow) {
$status = get_string('workflowactive', 'block_workflow', $togglelink->out());
}
// Count the times the workflow is actively in use.
- if ($count = $workflow->in_use_by(null, true)) {
+ if ($count = block_workflow_workflow::in_use_by($workflow->id, true)) {
$status .= get_string('inuseby', 'block_workflow', $count);
} else {
$status .= get_string('notcurrentlyinuse', 'block_workflow');
@@ -763,7 +763,7 @@ public function display_workflow($workflow) {
$url = new moodle_url('/blocks/workflow/export.php', array('sesskey' => sesskey(), 'workflowid' => $workflow->id));
$actions[] = html_writer::link($url, get_string('export', 'block_workflow'));
- if (block_workflow_workflow::is_deletable($workflow->id)) {
+ if (block_workflow_workflow::is_workflow_deletable($workflow->id)) {
// Delete the workflow.
$url = new moodle_url('/blocks/workflow/delete.php', array('workflowid' => $workflow->id));
$actions[] = html_writer::link($url, get_string('delete', 'block_workflow'));
4 simpletest/testlib.php
View
@@ -582,11 +582,11 @@ public function test_course_workflow() {
$this->assertEqual(count($clist), 1);
// And the workflow should be in use once.
- $inusetimes = $workflow->in_use_by();
+ $inusetimes = block_workflow_workflow::in_use_by($workflow->id);
$this->assertEqual($inusetimes, 1);
// And active once too.
- $inusetimes = $workflow->in_use_by(null, true);
+ $inusetimes = block_workflow_workflow::in_use_by($workflow->id, true);
$this->assertEqual($inusetimes, 1);
// We should be able to grab a list of step_states for this context too.
Please sign in to comment.
Something went wrong with that request. Please try again.