コード例 #1
0
 /**
  * The getWidgetList action acts as a service and should be triggered through an XML HTTP GET Request in order
  * to get the lists of widgets that are available for the user-agent's owner (the currently logged in user).
  *
  * @param string $format The output format that will be written in the HTTP Response. It must 'json' or 'xml'.
  * @param string $tag If set, will search the widgets to put in the resulting output by tag name.
  * @param integer $cat If set, will search the widgets to put in the resulting output by category id.
  */
 public function getWidgetList($format, $tag = null, $cat = null)
 {
     if (!Auth::isAuth()) {
         throw new ServiceException(MwwException::CONTROLLER, 'getWidgetList', ServiceException::SERV_AUTH);
     }
     if (isset($tag)) {
         // We have to search widgets by tag name.
         $widgets = Widgets::retrieveWidgetListByTag(Auth::getUserId(), $tag, Auth::getUserLevel(), $format);
     } else {
         if (isset($cat)) {
             // We have to search widgets by category id.
             $widgets = Widgets::retrieveWidgetListByCategory(Auth::getUserId(), $cat, Auth::getUserLevel(), $format);
         } else {
             // We have to get all widgets relevant to the authenticated user.
             $widgets = Widgets::retrieveWidgetList(Auth::getUserId(), Auth::getUserLevel(), $format);
         }
     }
     echo $widgets;
 }