/** * @desc Checks if the user can edit a document entry * @param mixed object or numeric $doc * @access public * @return bool */ function canEdit($doc = null, $checkCreator = true) { global $_DOCMAN; $database = JFactory::getDBO(); //Make sure we have a document object $this->isDocument($doc); // preform checks if ($this->isSpecial) { // admin return true; } //check if user has access to the document's category if (!$this->canAccessCategory($doc->catid)) { return false; } $maintainer = $doc->dmmantainedby; if ($this->userid) { if ($maintainer == $this->userid || $maintainer == _DM_PERMIT_REGISTERED) { // maintainer return true; } // Check Creator if ($checkCreator && $doc->dmsubmitedby == $this->userid) { if (is_a($doc, 'mosDMDocument')) { $authorCan = $doc->authorCan(); } else { // Naughty! No object. Create a temp one $tempDoc = new mosDMDocument($database); $tempDoc->attribs = $doc->attribs; $authorCan = $tempDoc->authorCan(); } if ($authorCan & _DM_AUTHOR_CAN_EDIT) { return true; } } if ($this->isInGroup($maintainer)) { return true; } } return false; // DEFAULT: can't edit }