--- /home/fsouto/Downloads/moodle/course/externallib.php	2011-12-06 09:21:32.000000000 +0000
+++ moodle/course/externallib.php	2011-12-26 13:45:34.138133271 +0000
@@ -253,6 +253,110 @@
         );
     }
 
+
+/**
+ * Get categories
+ * @param array $options
+ * @return array
+ */
+public static function get_categories($options) {
+	global $CFG, $DB;
+	require_once($CFG->dirroot . "/course/lib.php");
+	//validate parameter
+	//still not sure what parameters will this get here... if any
+	$params = self::validate_parameters(self::get_categories_parameters(),
+			array());
+			
+
+	$categories = $DB->get_records('course_categories');
+	$categoriesinfo = array();
+	
+	foreach ($categories as $category) {
+	
+		//security checks
+		$context = context_coursecat::instance($category->id);
+		try {
+			self::validate_context($context);
+		} catch (Exception $e) {
+			$exceptionparam = new stdClass();
+			$exceptionparam->message = $e->getMessage();
+			$exceptionparam->catid = $category->id;
+				throw new moodle_exception(
+			get_string('errorcatcontextnotvalid', 'webservice', $exceptionparam));
+		}
+		
+		$categoryinfo = array();
+		$categoryinfo['id'] = $category->id;
+		$categoryinfo['name'] = $category->name;
+		$categoryinfo['idnumber'] = $category->idnumber;
+		$categoryinfo['description'] = $category->description;
+		$categoryinfo['descriptionformat'] = $category->descriptionformat;
+		$categoryinfo['parent'] = $category->parent;
+		$categoryinfo['sortorder'] = $category->sortorder;
+		$categoryinfo['coursecount'] = $category->coursecount;
+		$categoryinfo['visible'] = $category->visible;
+		$categoryinfo['visibleold'] = $category->visibleold;
+		$categoryinfo['timemodified'] = $category->timemodified;
+		$categoryinfo['depth'] = $category->depth;
+		$categoryinfo['path'] = $category->path;
+		$categoryinfo['theme'] = $category->theme;
+		
+		if ($category->visible or 
+				has_capability('moodle/category:viewhiddencategories')) {
+			$categoriesinfo[] = $categoryinfo;
+		}
+	}
+	
+	return $categoriesinfo;
+}
+
+	/**
+	* Returns description of method result value
+	* @return external_description
+	*/
+	public static function get_categories_returns() {
+		return new external_multiple_structure(
+		new external_single_structure(
+		array(
+		                            'id' => new external_value(PARAM_INT, 'category id'),
+		                            'name' => new external_value(PARAM_TEXT, 'category name'),
+		                            'idnumber' => new external_value(PARAM_RAW, 'id number', VALUE_OPTIONAL),
+		                            'description' => new external_value(PARAM_TEXT,
+		                                    'the category description'),
+		                            'descriptionformat' => new external_value(PARAM_INT, 'description format'),
+		                            'parent' => new external_value(PARAM_INT, 'parent category id'),
+		                            'sortorder' => new external_value(PARAM_INT, 'category sorting order'),
+		                            'coursecount' => new external_value(PARAM_INT,
+		                                    'number of courses in this category'),
+		                            'visible' => new external_value(PARAM_INT,
+		                                    '1: available, 0:not available', VALUE_OPTIONAL),
+		                            'visibleold' => new external_value(PARAM_INT,
+		                                    '1: available, 0:not available', VALUE_OPTIONAL),
+		                            'timemodified' => new external_value(PARAM_INT,
+		                                    'timestamp when the course have been modified', VALUE_OPTIONAL),
+		                            'depth' => new external_value(PARAM_INT,
+		                                    'category depth'),
+		                            'path' => new external_value(PARAM_TEXT, 'category path'),
+		                            'theme' => new external_value(PARAM_THEME, 'the category theme', VALUE_OPTIONAL),
+		                          
+		), 'categories'
+		)
+		);
+	}
+
+	
+	/**
+	 * Returns description of method parameters
+	 * @return external_function_parameters
+	 */
+	function get_categories_parameters() {
+	        return new external_function_parameters(
+        	    array()
+        	);
+	}
+
+
+
     /**
      * Get courses
      * @param array $options
