Esempio n. 1
0
 static function register()
 {
     if (!LoginManager::isRegistered()) {
         $login = sqlite_escape_string(LoginManager::getLogin());
         $email = sqlite_escape_string(LoginManager::getEmail());
         DatabaseManager::setQuery("INSERT INTO users VALUES(\n                '{$login}',\n                '',\n                '{$email}',\n                0\n                );");
     }
 }
Esempio n. 2
0
 function execute()
 {
     $this->content = '
     <h1>' . _('Logout') . '</h1>';
     if (LoginManager::isLogged()) {
         $this->content .= '
             <p>' . sprintf(_('Logout from \'%s\' success.'), LoginManager::getLogin()) . '</p>';
     } else {
         $this->content .= '
             <p>' . _('You are not logged.') . '</p>';
     }
     $this->content .= '
         <p><a href="' . RessourceManager::getInnerUrl('index') . '">' . _('Return to index') . '</a></p>';
     LoginManager::logout();
 }
Esempio n. 3
0
 function displayContent()
 {
     $content = '';
     $content .= '
         <h2>' . _('Current propositions') . '</h2>';
     $user = LoginManager::getLogin();
     $results = DatabaseManager::getQuery("SELECT * FROM proposed_exercises WHERE (state='waiting' OR state='processing')");
     while ($result = $results->fetchArray()) {
         $content .= '<div class="subblock" ><ul>';
         $content .= '<li>' . _('Name: ') . $result['name'] . '</li>';
         $content .= '<li>' . _('Description: ') . $result['description'] . '</li>';
         $content .= '<li>' . _('Links: ') . $result['links'] . '</li>';
         $content .= '<li>' . _('Proposer: ') . $result['user'] . '</li>';
         $state = $result['state'];
         $stateStr = _('Unknown state');
         if ($state == 'waiting') {
             $stateStr = _('Waiting for processing');
         } elseif ($state == 'processing') {
             $stateStr = _('Processing');
         } elseif ($state == 'accepted') {
             $stateStr = _('Accepted');
         }
         $content .= '<li>' . _('State: ') . $stateStr . '</li>';
         $content .= '</ul></div>';
     }
     $content .= '
         <h2>' . _('Old propositions') . '</h2>';
     $results = DatabaseManager::getQuery("SELECT * FROM proposed_exercises WHERE  not (state='waiting' OR state='processing')");
     while ($result = $results->fetchArray()) {
         $content .= '<div class="subblock" ><ul>';
         $content .= '<li>' . _('Name: ') . $result['name'] . '</li>';
         $content .= '<li>' . _('Description: ') . $result['description'] . '</li>';
         $content .= '<li>' . _('Links: ') . $result['links'] . '</li>';
         $content .= '<li>' . _('Proposer: ') . $result['user'] . '</li>';
         $state = $result['state'];
         $stateStr = _('Unknown state');
         if ($state == 'waiting') {
             $stateStr = _('Waiting for processing');
         } elseif ($state == 'processing') {
             $stateStr = _('Processing');
         } elseif ($state == 'accepted') {
             $stateStr = _('Accepted');
         }
         $content .= '<li>' . _('State: ') . $stateStr . '</li>';
         $content .= '</ul></div>';
     }
     return $content;
 }
Esempio n. 4
0
 function execute()
 {
     if (isset($_POST['propose_name']) && $_SESSION['form_enabled']) {
         LoginManager::register();
         $name = sqlite_escape_string($_POST['propose_name']);
         $description = sqlite_escape_string($_POST['propose_description']);
         $links = sqlite_escape_string($_POST['propose_links']);
         $user = sqlite_escape_string(LoginManager::getLogin());
         $state = 'waiting';
         DatabaseManager::setQuery("INSERT INTO proposed_exercises VALUES(\n                NULL,\n                '{$name}',\n                '{$description}',\n                '{$links}',\n                '{$user}',\n                '{$state}',\n                '',\n                '',\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL,\n                NULL\n                );");
         $this->message = "Exercise proposed.";
         $_SESSION['form_enabled'] = false;
     } else {
         $_SESSION['form_enabled'] = true;
     }
 }