예제 #1
0
/**
 * Load all books from bd rcommon_books
 * @param int $levelid -> ID of the level
 * @param string $from -> to response in a format or other
 * @return array -> (id=>name)
 */
function rcontent_isbn_list($levelid = '', $from = 'ajax')
{
    global $DB;
    $return = array();
    if ($from == 'ajax') {
        $return[] = array('id' => 0, 'name' => '- ' . get_string('isbn', 'rcontent') . ' -');
    }
    if (!empty($levelid)) {
        if ($records = rcommon_book::get_by_level($levelid, 'webcontent')) {
            foreach ($records as $r) {
                if ($from == 'ajax') {
                    $return[] = array('id' => $r->id, 'name' => $r->name, 'group' => $r->publisher);
                } else {
                    if (!isset($return[$r->publisher])) {
                        $return[$r->publisher] = array();
                    }
                    $return[$r->publisher][$r->id] = $r->name;
                }
            }
        }
    }
    return $return;
}