Example #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');
     }
 }
Example #2
0
 public static function getWidgetsByCategory($categoryId, $offset, $count)
 {
     $userLevel = Auth::getUserLevel();
     $userId = Auth::getUserId();
     $format = 'raw';
     if ($categoryId == 'null') {
         $categoryId = null;
     }
     $jsonWidgets = Widgets::retrieveWidgetListByCategory($userId, $categoryId, $userLevel, $format);
     $chunkedWidgets = array();
     for ($i = $offset; $i < $offset + $count && $i < count($jsonWidgets); $i++) {
         $chunkedWidgets[] = $jsonWidgets[$i];
     }
     echo json_encode($chunkedWidgets);
 }