Beispiel #1
0
 public function action_edit($id = null)
 {
     $client = Model_Client::find($id);
     $form = $this->setup_form();
     if (Input::method() == 'POST') {
         if ($form->validation()->run() === true) {
             $fields = $form->validated();
             $client->code = $fields['code'];
             $client->name = $fields['name'];
             $client->name_en = $fields['name_en'];
             $client->status = $fields['status'];
             $client->updated_at = Date::forge()->get_timestamp();
             if ($client->save()) {
                 Session::set_flash('success', 'Updated client #' . $id);
                 Response::redirect('clients');
             } else {
                 Session::set_flash('error', 'Could not update client #' . $id);
             }
         } else {
             $this->template->set_global('errors', $form->error(), false);
         }
     }
     $this->template->page_title = "Edit Client";
     $this->template->set('content', $form->build($client), false);
 }
Beispiel #2
0
 public function action_delete($id = null)
 {
     if ($client = Model_Client::find($id)) {
         $client->delete();
         Session::set_flash('success', e('Deleted client #' . $id));
     } else {
         Session::set_flash('error', e('Could not delete client #' . $id));
     }
     Response::redirect('admin/clients');
 }
Beispiel #3
0
 /**
  * OpenID Connectを利用する承認後処理
  */
 public function action_callback()
 {
     $_opauth = new Opauth($this->_config, false);
     switch ($_opauth->env['callback_transport']) {
         case 'session':
             session_start();
             $response = $_SESSION['opauth'];
             unset($_SESSION['opauth']);
             break;
     }
     if (array_key_exists('error', $response)) {
         Response::redirect('/login');
     } else {
         $uid = $response['auth']['uid'];
         $client_no = Model_ClientApiToken::findClientNo($uid)->current();
         $user = Model_Client::find($client_no)->current();
         if (empty($user)) {
             $user = $this->addClient($response['auth']['raw']);
         }
         $this->setSession($user);
         Response::redirect('/');
     }
 }
Beispiel #4
0
 public function set_template_globals()
 {
     $this->template->set_global(array('clients' => Model_Client::find('all', array('order_by' => array(array('name', 'asc')))), 'project_statuses' => Model_Project::get_statuses(), 'project_types' => Model_Project_Type::find('all', array('order_by' => array(array('name', 'asc'))))), false);
 }
Beispiel #5
0
<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Address</th>
            <th>Added</th>
            <th>Last action</th>
        </tr>
    </thead>
    <tbody>
<?php 
foreach (Model_Client::find('all') as $client) {
    ?>
        <tr>
            <td><?php 
    echo $client->id;
    ?>
</td>
            <td><?php 
    echo $client->address;
    ?>
.onion</td>
            <td><?php 
    echo date('d.m.Y H:i:s', $client->created_at);
    ?>
</td>
            <td><?php 
    //date('d.m.Y H:i:s', $client->updated_at)
    ?>
</td>
        </tr>
Beispiel #6
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('client');
     if ($client = Model_Client::find($id)) {
         $client->delete();
         Session::set_flash('success', 'Deleted client #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete client #' . $id);
     }
     Response::redirect('client');
 }