MonographDAO::getUnassignedCategories PHP Method

getUnassignedCategories() public method

Get the categories not associated with a given monograph.
public getUnassignedCategories ( $monographId, $pressId = null ) : DAOResultFactory
$monographId int
return DAOResultFactory
    function getUnassignedCategories($monographId, $pressId = null)
    {
        $params = array((int) $monographId);
        if ($pressId) {
            $params[] = (int) $pressId;
        }
        $categoryDao = DAORegistry::getDAO('CategoryDAO');
        // The strange ORDER BY clause is to return subcategories
        // immediately after their parent category's entry.
        $result = $this->retrieve('SELECT	c.*
			FROM	submissions s
				JOIN categories c ON (c.press_id = s.context_id)
				LEFT JOIN submission_categories sc ON (s.submission_id = sc.submission_id AND sc.category_id = c.category_id)
			WHERE	s.submission_id = ? AND
				' . ($pressId ? ' s.context_id = ? AND' : '') . '
				sc.submission_id IS NULL
			ORDER BY CASE WHEN c.parent_id = 0 THEN c.category_id * 2 ELSE (c.parent_id * 2) + 1 END ASC', $params);
        // Delegate category creation to the category DAO.
        return new DAOResultFactory($result, $categoryDao, '_fromRow');
    }