public function testProposeToSelf() { $stat = org_openpsa_projects_workflow::propose(self::$_task, self::$_user->id, 'test comment'); $this->assertTrue($stat); self::$_task->refresh(); $this->assertEquals(org_openpsa_projects_task_status_dba::ACCEPTED, self::$_task->status); $this->assertEquals('not_started', self::$_task->status_type); $this->assertEquals('test comment', self::$_task->status_comment); $qb = org_openpsa_projects_task_status_dba::new_query_builder(); $qb->add_constraint('task', '=', self::$_task->id); $qb->add_order('type'); $result = $qb->execute(); $this->assertEquals(sizeof($result), 2); $this->assertEquals(self::$_user->id, $result[0]->targetPerson); $this->assertEquals(0, $result[1]->targetPerson); self::$_project->refresh(); $this->assertEquals(org_openpsa_projects_task_status_dba::ACCEPTED, self::$_project->status); }
public function _on_created() { // Add resources to the parent task/project $task = new org_openpsa_projects_task_dba($this->task); $this->add_resource_to_parent($task); if ($this->person) { if ($this->orgOpenpsaObtype == ORG_OPENPSA_OBTYPE_PROJECTRESOURCE) { org_openpsa_projects_workflow::propose($task, $this->person); } $this->_personobject = self::pid_to_obj($this->person); if (!$this->_personobject || !is_object($this->_personobject)) { debug_add('Person ' . $this->person . ' could not be resolved to user, skipping privilege assignment'); } else { $this->set_privilege('midgard:read', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); $this->set_privilege('midgard:delete', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); $this->set_privilege('midgard:update', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); $this->set_privilege('midgard:read', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); if ($task->orgOpenpsaObtype == ORG_OPENPSA_OBTYPE_TASK) { $task->set_privilege('midgard:read', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); // Resources must be permitted to create hour/expense reports into tasks $task->set_privilege('midgard:create', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); //For declines etc they also need update... $task->set_privilege('midgard:update', $this->_personobject->id, MIDCOM_PRIVILEGE_ALLOW); } } } }