예제 #1
0
 public function deleteAction()
 {
     $id = $this->request->getPost("id");
     $widget = Widget::findfirst('id =' . $id);
     if (!$widget->delete()) {
         foreach ($widget->getMessages() as $message) {
             $this->flash->error($message);
         }
     } else {
         $this->flash->success("widget was deleted successfully");
     }
     $portlet = Portlet::findFirstById($widget->portlet_id);
     $dashboard = Dashboard::findFirstById($portlet->dashboard_id);
     return $this->response->redirect("/dashboards/" . $dashboard->type . "/edit/" . $dashboard->id);
 }
예제 #2
0
 public function createAction()
 {
     $dashboard = new Dashboard();
     $dashboard->type = $this->dashboard_type;
     $dashboard->title = $this->request->getPost("title");
     $dashboard->icon = $this->request->getPost("icon");
     $dashboard->weight = $this->request->getPost("weight");
     $dashboard->organisation_id = $this->request->getPost("organisation_id");
     $dashboard->parameters = json_encode($this->request->getPost("parameters"));
     if (!$dashboard->save()) {
         foreach ($dashboard->getMessages() as $message) {
             $this->flash->error($message);
         }
     } else {
         $this->flash->success("Dashboard was created successfully");
         // Check if the user has uploaded files
         if ($this->request->hasFiles() == true) {
             $baseLocation = '/files/';
             // Print the real file names and sizes
             foreach ($this->request->getUploadedFiles() as $file) {
                 $ext = end(explode(".", $file->getName()));
                 $file->moveTo($baseLocation . "dashboard_" . $dashboard->id . "." . $ext);
             }
         }
         return $this->dispatcher->forward(array("namespace" => "PRIME\\Themes\\" . $this->theme . "\\dashboards", "controller" => $dashboard->type, "action" => "edit", "params" => array('id' => $dashboard->id)));
     }
 }
 public function GetWidgetsListAction($id)
 {
     $this->view->Disable();
     $dashboard = Dashboard::findFirstByid($id);
     $json = array();
     $portlets = $dashboard->Portlet;
     foreach ($portlets as $portlet) {
         $widgets = $portlet->Widget;
         foreach ($widgets as $widget) {
             $json[] = array('id' => $widget->id, 'text' => $widget->id);
         }
     }
     echo json_encode($json);
 }