Ejemplo n.º 1
0
 /**
  * This action is the default action of the Admin module. It should be triggered
  * when the user agent request requests to enter the administration panel.
  */
 public function index()
 {
     // Session message handling.
     if (isset($_SESSION['message'])) {
         $message = $_SESSION['message'];
         $isError = $_SESSION['isError'];
         // We consider message and isError session variables as flash variables.
         unset($_SESSION['message']);
         unset($_SESSION['isError']);
     }
     if (!(Auth::isAuth() && (Auth::isAdmin() || Auth::isGod()))) {
         // forward to the login script
         DefaultFC::redirection('users/index?ref=admin');
     } else {
         // Determine if the view must allow the user to manage widgets.
         $widgetManagement = false;
         if (Auth::isAdmin() || Auth::isGod()) {
             $widgetManagement = true;
         }
         // View preparation.
         $categories = $this->buildCategoryList();
         $installedWidgets = Widgets::retrieveWidgetList(Auth::getUserId(), Auth::getUserLevel(), 'raw', true);
         $partial = 'widgets';
         require DefaultFC::getView('admin.tpl');
     }
 }
Ejemplo n.º 2
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;
 }