/** * Get available widgets for user * @param int|NULL $uid * @return array of IWidget */ public static function GetAvailable($uid = NULL) { global $g_user; if ($uid === NULL) { $uid = $g_user->getId(); } // get all widget extensions $index = new Extension_Index(); foreach (self::ExtPath() as $path) { $index->addDirectory(WWW_DIR . $path); } $extensions = $index->find('IWidget'); // filter not-available (used) $widgets = array(); foreach ($extensions as $extension) { $widget = WidgetManagerDecorator::GetByExtension($extension); if ($widget->isAvailable($uid)) { $widgets[] = $widget; } } return $widgets; }