Ejemplo n.º 1
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function insert(Record $record)
 {
     $sql = "INSERT INTO log (user_id, group_name, group_id, action, item_name, item_id, nonce, created)\n            VALUES (:user_id, :group_name, :group_id, :action, :item_name, :item_id, :nonce, NOW())";
     $values = $record->toArray();
     $result = $this->db->run($sql, $values);
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $values = $record->getUpdateValueString();
     $sql = "UPDATE areas SET {$values} WHERE id=:id";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * /
  * @param Record $record [description]
  */
 public function setUserData(Record $record)
 {
     $this->session->set('user.authenticated', true);
     $this->session->set('user.id', $record->get('id'));
     $this->session->set('user.username', $record->get('username'));
     $this->session->set('user.name', $record->get('name'));
     $this->session->set('user.email', $record->get('email'));
 }
Ejemplo n.º 4
0
 /**
  * /
  * @param  [type] $app [description]
  * @return [type]      [description]
  */
 public function route($app)
 {
     $app->view->setLayout('frontend');
     $app->get('/login', function () use($app) {
         $app->render('login');
     })->name('user_login_form');
     $app->post('/login', function () use($app) {
         $credentials = $app->handler->handlePostRequest();
         $app->doorman->login($credentials);
         if ($app->doorman->isUserAuthenticated()) {
             $app->redirect('admin_panel');
         } else {
             $app->redirect('user_login_form');
         }
     })->name('user_login');
     $app->get('/signup', function () use($app) {
         $app->render('signup');
     })->name('user_signup_form');
     $app->post('/signup', function () use($app) {
         $record = new Record($app->request->post());
         $token = User::query($app->db, 'signUp', $record);
         $sent = $app->handler->sendSignUpConfirmation($record, $token);
         $app->redirect('user_login_form');
     })->name('user_signup');
     $app->get('/signup/confirm/:token', function ($user_id, $token) use($app) {
         $result = User::query($app->db, 'validate', $token, 'activation');
         if ((int) $result->isSuccessful()) {
             $app->redirect('user_login');
         }
         $app->errorForbidden();
     })->name('confirm_signup')->conditions(array('token' => '\\w+'));
     $app->get('/password/forgot', function () use($app) {
         $app->render('password.forgot');
     })->name('forgot_password_form');
     $app->post('/password/forgot', function () use($app) {
         $record = new Record($app->request->post());
         $token = User::query($app->db, 'forgot', $record->get('user_id'));
         $sent = $app->handler->sendPasswordReset($record, $token);
         $app->redirect('user_login_form');
     })->name('forgot_password');
     $app->get('/password/new/:token', function ($token) use($app) {
         $result = User::query($app->db, 'validate', $token, 'forgot');
         if ($result->isSuccessful()) {
             $app->render('password.new');
             $app->stop();
         } else {
             $app->handler->errorForbidden();
         }
     })->name('new_password_form')->conditions(array('token' => '\\w+'));
     $app->post('/password/new', function () use($app) {
         $record = new Record($app->request->post());
         $result = User::query($app->db, 'resetPassword', $record->get('new_password'));
         $app->redirect($app->urlFor('user_login_form'));
     })->name('new_password');
     return $app;
 }
Ejemplo n.º 5
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $id = $record->get('id');
     if (!$id) {
         throw new \Exception("Id must be set", 1);
     }
     $values = $record->getUpdateValueString();
     $sql = "UPDATE blocks SET {$values} WHERE id=:id";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 6
0
 /**
  * /
  * @param  Record $credentials [description]
  * @return [type]              [description]
  */
 public function login(Record $credentials)
 {
     $login = $this->user->findByUsernameOrEmail($credentials->get('username'));
     $record = $login->getFirstRecord();
     if ($record->get('password') === sha1($credentials->get('password'))) {
         $this->sessionDataStore->setUserData($data);
         if ($credentials->get('remember')) {
             $this->remember($record->get('id'));
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 7
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $id = $record->get('id');
     $record->remove('id');
     $language = $record->get('language');
     $record->remove('language');
     $sql = "UPDATE collections SET parent_id=:parent_id, modified=NOW() WHERE id=:id";
     $result = $this->db->run($sql, array('id' => $id, 'parent_id' => $record->get('parent_id')));
     $record->remove('parent_id');
     $record->remove('type_id');
     $values = $record->getUpdateValueString();
     $sql = "UPDATE translations SET {$values}\n            WHERE item_id=:id \n                AND language=:language\n                AND item_name=:item_name";
     $record->set('language', $language);
     $record->set('item_name', 'collection');
     $record->set('id', $id);
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 8
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $id = $record->get('id');
     $record->remove('id');
     $language = $record->get('language');
     $record->remove('language');
     $sql = "UPDATE resources SET modified=NOW() WHERE id=:id";
     $result = $this->db->run($sql, array('id' => $id));
     $record->remove('type_id');
     $record->remove('url');
     $record->remove('filepath');
     $record->remove('filename');
     $record->remove('extension');
     $record->remove('embed');
     $record->remove('mimetype');
     $values = $record->getUpdateValueString();
     $sql = "UPDATE translations \n            SET {$values} \n            WHERE item_id=:id \n                AND language=:language\n                AND item_name=:item_name";
     $record->set('language', $language);
     $record->set('item_name', 'term');
     $record->set('id', $id);
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 9
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function processRecord(Record $record)
 {
     $total = (int) $record->get('totalhours') * (int) $record->get('rate');
     $record->set('total', $total);
     return $record;
 }
Ejemplo n.º 10
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $sql = "UPDATE roles SET name=:name, activity=:activity \n            WHERE id=:id";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 11
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $sql = "UPDATE types SET name=:name, item_name=:item_name WHERE id=:id";
     $result = $this->db->run($sql, array('item_name' => $record->get('item_name'), 'name' => $record->get('name'), 'id' => $record->get('id')));
     $record->remove('name');
     $sql = "UPDATE translations SET user_id=:user_id, language=:language, slug=:slug, title=:title\n            WHERE item_id=:id AND item_name=:item_name";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 12
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function insert(Record $record)
 {
     $sql = "INSERT INTO tickets (dev_id, user_id, hash, priority, description, activity, created, modified) \n            VALUES (:dev_id, :user_id, UUID(), :priority, :description, :activity, NOW(), NOW())";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 13
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $sql = "UPDATE projects SET title=:title, description=:description, activity=:activity";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 14
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $sql = "UPDATE config SET activity=:activity, value=:value, modified=NOW() \n            WHERE key=:key";
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 15
0
 /**
  * /
  * @param  Record $record [description]
  * @return [type]         [description]
  */
 public function update(Record $record)
 {
     $id = $record->get('id');
     $record->remove('id');
     $values = $record->getUpdateValueString();
     $sql = "UPDATE users \n            SET {$values}, modified=NOW() WHERE id=:id";
     $record->set('id', $id);
     $result = $this->db->run($sql, $record->toArray());
     return $result;
 }
Ejemplo n.º 16
0
 /**
  * /
  * @return [type] [description]
  */
 public function handlePostRequest()
 {
     // try to get $_POST
     $body = $this->app->request->post();
     // if $_POST is empty, try to get json request body instead
     if (empty($body)) {
         $json = $app->request->getBody();
         $body = json_decode($json, true);
     }
     $record = new Record($body);
     if (!$record->has('nonce') || !$this->app->nonce->verify($record->get('nonce'))) {
         $this->errorForbidden();
     }
     $record->remove('nonce');
     return $record;
 }