/** * Function to check whether we can reserve the resource we are trying to * * @return boolean indicating state * @todo cache results */ function verify_can_reserve() { if (empty($this->resource)) { debug_add("Resource is set to empty value returning true"); return true; } try { $resource = new org_openpsa_calendar_resource_dba($this->resource); } catch (midcom_error $e) { debug_add("Cannot fetch resource #{$this->resource} returning false", MIDCOM_LOG_INFO); return false; } $stat = $resource->can_do('org.openpsa.calendar:reserve'); if (!$stat) { debug_add("\$resource->can_do('org.openpsa.calendar:reserve'), returned false, so will we", MIDCOM_LOG_INFO); } return $stat; }
private function _check_duplicates($name) { if ($name == '') { return false; } // Check for duplicates $qb = org_openpsa_calendar_resource_dba::new_query_builder(); $qb->add_constraint('name', '=', $name); if ($this->id) { $qb->add_constraint('id', '<>', $this->id); } $result = $qb->execute(); if (count($result) > 0) { return true; } return false; }