Example #1
0
 public function before()
 {
     parent::before();
     $this->template->title = 'Swiftriver';
     $this->template->theme = Theming::get_theme();
     $this->template->header = new View('defaults/header');
     $this->template->content = '';
     $this->template->rightbar = new View('defaults/rightbar');
     $this->template->footer = new View('defaults/footer');
     $loggedinstatus = RiverId::is_logged_in();
     if (!$loggedinstatus["IsLoggedIn"]) {
         $this->template->admin = new View("adminbar/user");
     } else {
         if ($loggedinstatus["Role"] == "sweeper") {
             $this->template->admin = new View("adminbar/sweeper");
         } else {
             if ($loggedinstatus["Role"] == "editor") {
                 $this->template->admin = new View("adminbar/editor");
             } else {
                 if ($loggedinstatus["Role"] == "admin") {
                     $this->template->admin = new View("adminbar/admin");
                 }
             }
         }
     }
 }
Example #2
0
 public function action_render()
 {
     //Very strange to have to encode then decoe but we want objects
     //at the end of the day not arrays and this is the easiest way
     //to get one!
     $content = json_decode(json_encode($_POST["content"]));
     //do some work on organisng the tags
     $tags = array("general" => array(), "who" => array(), "what" => array(), "where" => array());
     if (isset($content->tags)) {
         foreach ($content->tags as $tag) {
             switch ($tag->type) {
                 case "General":
                     $tags["general"][] = $tag->text;
                     break;
                 case "who":
                     $tags["who"][] = $tag->text;
                     break;
                 case "what":
                     $tags["what"][] = $tag->text;
                     break;
                 case "where":
                     $tags["where"][] = $tag->text;
                     break;
             }
         }
     }
     $content->tags = $tags;
     $this->template->content = $content;
     $logincheck = RiverId::is_logged_in();
     $this->template->enableActions = $logincheck["IsLoggedIn"];
 }
 private function set_menu()
 {
     $loggedinstatus = RiverId::is_logged_in();
     if (!$loggedinstatus["IsLoggedIn"]) {
         $this->template->menu = new View("contentmenu/user");
     } else {
         if ($loggedinstatus["Role"] == "sweeper") {
             $this->template->menu = new View("contentmenu/sweeper");
         } else {
             if ($loggedinstatus["Role"] == "editor") {
                 $this->template->menu = new View("contentmenu/editor");
             } else {
                 if ($loggedinstatus["Role"] == "admin") {
                     $this->template->menu = new View("contentmenu/editor");
                 }
             }
         }
     }
     $this->template->menu->state = $this->state;
     $this->template->menu->new_content_class = $this->state == "new_content" ? "selected" : "";
     $this->template->menu->accurate_class = $this->state == "accurate" ? "selected" : "";
     $this->template->menu->inaccurate_class = $this->state == "inaccurate" ? "selected" : "";
     $this->template->menu->irrelevant_class = $this->state == "irrelevant" ? "selected" : "";
     $this->template->menu->chatter_class = $this->state == "chatter" ? "selected" : "";
 }
Example #4
0
 public function action_register()
 {
     $username = $_POST["username"];
     $password = $_POST["password"];
     $role = $_POST["role"];
     $return->result = RiverId::register($username, $password, $role);
     $this->request->response = json_encode($return);
 }
 public function action_getterms($withcontrols)
 {
     $json = API::channel_api()->get_all_channels();
     $widget = View::factory("parts/termstomonitorwidget")->set('json', $json);
     $loggedinstatus = RiverId::is_logged_in();
     $loggedinstatus = $loggedinstatus["IsLoggedIn"];
     if ($withcontrols == "true") {
         $widget->set('withcontrols', true);
     } else {
         $widget->set('withcontrols', false);
     }
     $widget->set('isloggedin', $loggedinstatus);
     // Render the widget
     $this->request->response = $widget;
 }
Example #6
0
 public function RunChecks($postVar)
 {
     $this->firsttime = count($postVar) == 0;
     if ($this->firsttime) {
         return null;
     }
     if (!key_exists("password1", $postVar) || strlen($postVar["password1"]) == 0) {
         $this->errors[] = "You have to enter a password in the first box.";
     }
     if (!key_exists("password2", $postVar) || strlen($postVar["password2"]) == 0) {
         $this->errors[] = "You have to enter a password in the second box.";
     }
     if (count($this->errors) > 0) {
         return false;
     }
     $password1 = $postVar["password1"];
     $password2 = $postVar["password2"];
     if ($password1 != $password2) {
         $this->errors[] = "The passwords you entered did not match.";
     }
     if (count($this->errors) > 0) {
         return false;
     }
     if (strlen($password1) < 6) {
         $this->errors[] = "The password you choose must be at lease 6 characters long.";
     }
     if (count($this->errors) > 0) {
         return false;
     }
     try {
         include_once dirname(__FILE__) . "/../../web/modules/riverid/classes/riverid.php";
         include_once dirname(__FILE__) . "/../../web/modules/riverid/classes/riveridconfig.php";
         RiverId::register("admin", $password1, "admin");
         return true;
     } catch (\Exception $e) {
         $this->errors[] = "There was a problem registering the admin username and password: {$e}";
         return false;
     }
 }
Example #7
0
 public function test()
 {
     include_once dirname(__FILE__) . "/../../../../../web/modules/riverid/classes/RiverId.php";
     include_once dirname(__FILE__) . "/../../../../../web/modules/riverid/classes/RiverIdConfig.php";
     \RiverId::register("test2", "password", "sweeper");
 }