Exemple #1
0
 /**
  * This load session information and creates session links
  */
 public function loadSession()
 {
     $this->register_link = new Link(BASEURL . '/mod/register', 'Register');
     $this->login_link = new Link(BASEURL . '/mod/auth', 'Login');
     $this->logout_link = new Link(BASEURL . '/mod/auth/logout', 'Logout');
     $this->logged_username = BootWiki::getLoggedAccount() == null ? NULL : BootWiki::getLoggedAccount()->username;
 }
Exemple #2
0
 /**
  * Loads Content based on unique alias
  * @param string $alias
  * @return boolean
  */
 public function visit($content)
 {
     // Add visit
     $content->addVisits();
     $content->save();
     // Load versions
     if (BootWiki::getLoggedAccount() !== null) {
         $this->versions = $content->loadVersions();
     }
     // set content
     $this->content = $content;
     return true;
 }
Exemple #3
0
 /**
  * Loads content to the form based on Content alias unique key
  * @param string $alias
  * @return \ContentForm
  */
 public function load($alias, $create = false)
 {
     // Try to load content
     $content = R::findOne('content', 'alias = ?', array($alias));
     if (empty($content) && $create) {
         $content = R::dispense('content');
         if (BootWiki::getLoggedAccount()) {
             $this->author = BootWiki::getLoggedAccount()->username;
         }
     }
     if (!$content) {
         return false;
     }
     $this->importBean($content);
     return $this;
 }
Exemple #4
0
<div>

    <h1 itemprop="headline" id="content_title"><a href="<?php 
echo BASEURL . '/' . $this->content->alias;
?>
"><?php 
echo $this->content->title;
?>
</a>
        <?php 
if (BootWiki::getLoggedAccount()) {
    ?>
        &nbsp;<a class="label label-danger small" href="<?php 
    echo BASEURL . '/edit/' . $this->content->alias;
    ?>
">edit</a>
        <?php 
}
?>
    </h1>
    
    <p id="content_meta" class="well">
        <span class="label label-warning">
            <em itemprop="lastReviewed" class="label"><?php 
echo date(DATE_FORMAT, strtotime($this->content->date));
?>
</em>
        </span>&nbsp;
        <?php 
if (is_object($this->content->author) && !empty($this->content->author->profile)) {
    ?>
Exemple #5
0
    $layout->loadRecent();
    $layout->loadPopular();
    // Print layout
    $app->response()->body((string) $layout);
});
/*
 * Process change password
 */
$app->post('/mod/myaccount', function () use($app) {
    // redirect if not logged
    if (BootWiki::getLoggedAccount() == null) {
        $app->redirect(BASEURL);
    }
    // Process change account
    if ($app->request()->post('displayname')) {
        $account = BootWiki::getLoggedAccount();
        $account->update($app->request()->post());
    }
    // Process change password
    if ($app->request()->post('password_confirm')) {
        $main = new Account();
        $main->changePassword($app->request()->post());
    }
    // Apply redirects
    $app->redirect(BASEURL . '/mod/myaccount');
});
/*
 * Process logout
 */
$app->get('/mod/auth/logout', function () use($app) {
    // Process logout
Exemple #6
0
 /**
  * Changes account password
  * @param array $post
  * @return boolean
  */
 public function changePassword($post)
 {
     // Validate create before continue
     $result = $this->validatePassword($post);
     if (!$result) {
         return false;
     }
     // Load account
     $username = BootWiki::getLoggedAccount()->username;
     $account = R::findOne('account', 'username = ?', array($username));
     $account->password = $post['password'];
     R::store($account);
     $this->importBean($account);
     // Encrypt password
     $passwd = BootWiki::encrypt($post['password']);
     $account->password = $passwd;
     R::store($account);
     // Send email to user
     $this->template_path = BootWiki::template('register_mail');
     $message = (string) $this;
     BootWiki::sendMail($username, 'BootWiki - New password', $message);
     // Return success
     BootWiki::setMessage('Password has changed!');
     return true;
 }