Exemplo n.º 1
0
 /**
  * User Login
  * @return Response
  */
 public function post_login()
 {
     $this->filter('before', 'csrf');
     if (Input::get('login')) {
         $rules = array('username' => 'required|max:30', 'password' => 'required');
         $input = Input::all();
         $validation = Validator::make($input, $rules);
         if ($validation->fails()) {
             Vsession::cadd('r', $validation->errors->first())->cflash('status');
         } else {
             foreach ($input as $field => $value) {
                 $input[$field] = trim(filter_var($value, FILTER_SANITIZE_STRING));
             }
             $credentials = array('username' => $input['username'], 'password' => $input['password']);
             try {
                 if (Auth::attempt($credentials)) {
                     return Redirect::to_action('item@list');
                 }
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         }
     }
     return $this->get_login();
 }
Exemplo n.º 2
0
 /**
  * Site Setting post
  * @return redirect Redirecting to user list
  */
 public function post_site()
 {
     if (!Auth::can('edit_settings')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('site@status');
     }
     if (Input::get('submit')) {
         // Registering language validator
         Validator::register('language_exists', function ($attribute, $value, $parameters) {
             if (array_key_exists($value, Config::get('site.languages'))) {
                 return true;
             }
         });
         // So these are the rules
         $rules = array('language' => 'required|language_exists');
         $input = Input::all();
         $validation = Validator::make($input, $rules);
         if ($validation->fails()) {
             Vsession::cadd('r', $validation->errors->first())->cflash('status');
         } else {
             foreach ($input as $field => $value) {
                 if (!empty($value)) {
                     $value = trim(filter_var($value, FILTER_SANITIZE_STRING));
                     DB::table('settings')->where_field($field)->take(1)->update(array('value' => $value));
                 }
             }
             Vsession::cadd('g', __('site.st_settings_up'))->cflash('status');
             return Redirect::to_action('setting@site');
         }
     }
     return $this->get_site();
 }
Exemplo n.º 3
0
 /**
  * Add messages to que
  *
  * Add messages to flash session que,
  * the input color determines the color of the
  * output status messages on page
  * 
  * @param  string $color   Color to be displayed (r,g,b,y)
  * @param  string $message The message to be displayed
  * @return self            Instance of self for method chaining
  */
 public static function cadd($color = 'y', $message)
 {
     self::$cmessage[$color][] = $message;
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * Delete transaction
  * 
  * @param  int $id Transaction ID
  * @return Response
  */
 public function get_delete($tid = null)
 {
     if (!Auth::can('delete_transactions')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('transaction@list');
     }
     if (!is_null($this->filter_transaction($tid))) {
         $iid = $this->item_by_transaction($tid);
         DB::table('transactions')->delete($tid);
         $this->recalculate($iid);
     } else {
         return Redirect::to_action('transaction@list');
     }
     Vsession::cadd('g', __('site.st_trans_deleted'))->cflash('status');
     return Redirect::to_action('transaction@list');
 }
                } );
            } );
            </script>
            <div class="transactions_list_advanced add">
                <?php 
if (isset($id)) {
    ?>
                <?php 
    echo View::make('layout.blocks.nav_sections')->with('id', $id);
    ?>
                <?php 
}
?>
                <div class="message">
                    <?php 
Vsession::cprint('status');
?>
                </div>
                <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
                    <thead>
                        <tr>
                            <th class="tid">Id</th>
                            <th><?php 
echo __('site.code');
?>
</th>
                            <th><?php 
echo __('site.item');
?>
</th>
                            <th><?php 
Exemplo n.º 6
0
 /**
  * Deleting item image
  * @param  int $id Item ID
  * @return response
  */
 public function get_deleteimg($id = null)
 {
     if (!Auth::can('delete_item_images')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('item@list');
     }
     if ($id != null) {
         $id = trim(filter_var($id, FILTER_SANITIZE_NUMBER_INT));
     } else {
         return Redirect::to_action('item@list');
     }
     $image = glob('uploads/images/items/' . $id . '.*');
     if (!empty($image)) {
         if (file_exists($image[0])) {
             File::delete($image[0]);
         }
     }
     Vsession::cadd('g', __('site.st_image_deleted'))->cflash('status');
     return Redirect::to_action('item@edit/' . $id);
 }
Exemplo n.º 7
0
 public function get_delete($id = null)
 {
     if (!Auth::can('delete_contacts')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('contacts@list');
     }
     // ID
     if ($id !== null) {
         $id = trim(filter_var($id, FILTER_SANITIZE_NUMBER_INT));
     } else {
         Redirect::to_action('contact@list');
     }
     if ($delete = DB::table('contacts')->delete($id)) {
         Vsession::cadd('g', __('site.st_contact_deleted'))->cflash('status');
     } else {
         Vsession::cadd('g', __('site.st_contact_not_deleted'))->cflash('status');
     }
     return Redirect::to_action('contact@list');
 }
 /**
  * Display page content
  *
  * @access	public
  */
 public function display_content()
 {
     if (!empty($this->_content)) {
         Html::header_links();
         if (!VSession::html5()) {
             echo '<ul id="links">';
         }
         foreach ($this->_content as $link) {
             Html::related_link($link->_name, $link->_link, $link->_rss_link, $link->_notes, $link->_priority);
         }
         if (!Vsession::html5()) {
             echo '</ul>';
         }
     } else {
         Html::header_links();
         if (!VSession::html5()) {
             echo '<ul id="links">';
         }
         Html::no_content('There\'s no link registered yet.');
         if (!Vsession::html5()) {
             echo '</ul>';
         }
     }
 }
 /**
  * Method to display navigation bar
  *
  * @static
  * @access	public
  * @param	integer [$p] Actual page
  * @param	integer [$max] Maximum of available pages
  * @param	string [$link] Complement in the url
  */
 public static function navigation($p, $max, $link)
 {
     if (Vsession::html5()) {
         if ($p < $max) {
             echo '<div id="prev">' . '<a href="' . PATH . '?' . $link . 'p=' . ($p + 1) . '">Previous Page</a>' . '</div>';
         }
         if ($p > 1) {
             echo '<div id="next">' . '<a href="' . PATH . '?' . $link . 'p=' . ($p - 1) . '">Next Page</a>' . '</div>';
         }
     } else {
         echo '<ul id="nav">';
         if ($p < $max) {
             echo '<li>' . '<div id="prev">' . '<a href="' . PATH . '?' . $link . 'p=' . ($p + 1) . '">Previous Page</a>' . '</div>' . '</li>';
         }
         if ($p > 1) {
             echo '<li>' . '<div id="next">' . '<a href="' . PATH . '?' . $link . 'p=' . ($p - 1) . '">Next Page</a>' . '</div>' . '</li>';
         }
         echo '</ul>';
     }
 }
 /**
  * Method to build easily html5 or not tag
  *
  * @static
  * @access	public
  * @param	string [$tag] $tag can only contain "o" or "c"
  * @param	string [$chevron]
  */
 public static function html5($tag, $chevron = '>')
 {
     if ($tag == 'o') {
         if (Vsession::html5()) {
             echo '<section ';
         } else {
             echo '<div ';
         }
         echo $chevron;
     } elseif ($tag == 'c') {
         if (Vsession::html5()) {
             echo '</section>';
         } else {
             echo '</div>';
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Delete user
  * @param  int $id User ID
  * @return Response
  */
 public function get_delete($id = null)
 {
     if (!Auth::can('delete_users')) {
         Vsession::cadd('y', __('site.not_allowed'))->cflash('status');
         return Redirect::to_action('user@list');
     }
     if ($id != null) {
         $id = trim(filter_var($id, FILTER_SANITIZE_NUMBER_INT));
     } else {
         return Redirect::to_action('user@list');
     }
     if ($id == Auth::user()->id) {
         Vsession::cadd('r', __('site.st_user_urself'))->cflash('status');
         return Redirect::to_action('user@list');
     }
     if (!$this->user_exists($id, 'users')) {
         return Redirect::to_action('user@list');
     }
     DB::table('role_user')->where('user_id', '=', $id)->delete();
     DB::table('users')->where('id', '=', $id)->delete();
     Vsession::cadd('g', __('site.st_user_deleted'))->cflash('status');
     return Redirect::to_action('user@list');
 }