Beispiel #1
0
 /**
  *  Create a new redirect from request.
  *
  * @param $request input form data
  * @return User
  */
 public function pushRedirect($request)
 {
     $input = $request->all();
     $input['code'] = substr(uniqid(rand(), true), 0, 12);
     $redirect = new Redirect();
     $redirect->fill($input);
     $redirect->save();
     return $redirect;
 }
 public static function store($files, $material)
 {
     // Making counting of uploaded images
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     if (!empty($files)) {
         foreach ($files as $file_path) {
             if (!empty($file_path)) {
                 $type = File::type($file_path);
                 $mime = File::mimeType($file_path);
                 $extension = File::extension($file_path);
                 $filename = $material->slug . '_' . str_replace(' ', '_', File::name($file_path)) . '.' . $extension;
                 File::move($file_path, storage_path() . '/app/' . $filename);
                 //add file path and thumb path to material_files database
                 $material_file = MaterialFile::firstOrCreate(['original_filename' => File::name($file_path), 'filename' => $filename, 'mime' => $mime]);
                 //add to material file table
                 $material->files()->save($material_file);
                 $uploadcount++;
                 //create thumb
                 MaterialFile::makeThumb($extension, $filename);
             }
         }
         if ($uploadcount == $file_count) {
             Session::flash('success', 'Upload(s) successfully');
         } else {
             return Redirect::to('material.edit')->withInput();
         }
     }
 }
 public function actionAdd()
 {
     $model = new Article();
     if (Request::isPost()) {
         if ($model->add(['title' => Request::post('title'), 'content' => Request::post('content')])) {
             Redirect::home();
         }
     }
     echo $this->view->render('add');
 }
 public function deleteEntry($fid, $pid)
 {
     $rules = ['id' => 'required|integer'];
     $inputs = ['id' => $pid];
     $deleted = $this->doDelete($pid, $inputs, $rules);
     if ($deleted['status'] == 1) {
         return Redirect::to('/crm/feature/' . $fid)->withMessage(Generate::message('SUCCESS', $deleted['message']));
     }
     return Redirect::to('/crm/feature/' . $fid)->withMessage(Generate::message('FAILED', $deleted['message']));
 }
Beispiel #5
0
 public static function add_field()
 {
     if (isset($_POST["mytext"]) != '') {
         foreach ($_POST["mytext"] as $labelField) {
             if ($labelField != '') {
                 $field = Field::firstOrNew(array('student_label' => $labelField));
                 $field->save();
             }
         }
     }
     return Redirect::back()->with('msg', 'Field was successfuly updated');
 }
Beispiel #6
0
 public function assignRolePermission($rid)
 {
     $inputs = Input::all();
     //get all the permission that this role has.
     $current_permissions_id = Role::getPermissionsAssignedToCurrentRole($rid);
     foreach ($inputs as $key => $value) {
         $is_permission_added_in_current_role = false;
         if ($key == '_token') {
             continue;
         }
         $permission_id = explode("_", $key)[1];
         $is_permission_added_in_current_role = in_array($permission_id, $current_permissions_id);
         if (!$is_permission_added_in_current_role && $value == 'on') {
             echo 'ON';
             print_r($current_permissions_id);
             echo $permission_id . '->';
             echo $is_permission_added_in_current_role;
             echo '<br>';
             //if the permission is not exist, create new permission role record.
             $new_permission = new PermissionRole();
             $new_permission->role_id = $rid;
             $new_permission->permission_id = $permission_id;
             $new_permission->order = '1';
             $new_permission->save();
             //else since it is already exist, and it is on, no need to do anything.
         } else {
             if ($is_permission_added_in_current_role) {
                 if ($value == 'off') {
                     echo 'OFF';
                     print_r($current_permissions_id);
                     echo $permission_id . '->';
                     echo $is_permission_added_in_current_role;
                     echo '<br>';
                     //if permission record is exist (true), find and do a delete.
                     $perm = PermissionRole::where('role_id', $rid)->where('permission_id', $permission_id)->first();
                     if (isset($perm)) {
                         $perm->delete();
                     }
                     //else it is not exist, do nothing.
                 } else {
                     if ($value == 'on') {
                         //echo 'ON'; print_r ($current_permissions_id); echo $permission_id.'->'; echo $is_permission_added_in_current_role; echo '<br>';
                         //do nothing ....
                     }
                 }
             }
         }
     }
     //return '';
     return Redirect::to('/crm/role/' . $rid)->withMessage(Generate::message('Success', 'New Permissions Applied, please relogin to see the changes.'));
 }
Beispiel #7
0
 public function createPayment()
 {
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $item_1 = new Item();
     $item_1->setName('Item 1')->setCurrency('USD')->setQuantity(2)->setPrice('15');
     // unit price
     $item_2 = new Item();
     $item_2->setName('Item 2')->setCurrency('USD')->setQuantity(4)->setPrice('7');
     $item_3 = new Item();
     $item_3->setName('Item 3')->setCurrency('USD')->setQuantity(1)->setPrice('20');
     // add item to list
     $item_list = new ItemList();
     $item_list->setItems(array($item_1, $item_2, $item_3));
     $amount = new Amount();
     $amount->setCurrency('USD')->setTotal(78);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description');
     $redirect_urls = new RedirectUrls();
     $redirect_urls->setReturnUrl(route('payment.status'))->setCancelUrl(route('payment.status'));
     $payment = new Payment();
     $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction));
     try {
         $payment->create($this->_api_context);
     } catch (\PayPal\Exception\PPConnectionException $ex) {
         if (\Config::get('app.debug')) {
             echo "Exception: " . $ex->getMessage() . PHP_EOL;
             $err_data = json_decode($ex->getData(), true);
             exit;
         } else {
             die('Some error occur, sorry for inconvenient');
         }
     }
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirect_url = $link->getHref();
             break;
         }
     }
     // add payment ID to session
     Session::put('paypal_payment_id', $payment->getId());
     if (isset($redirect_url)) {
         // redirect to paypal
         return Redirect::away($redirect_url);
     }
     return Redirect::route('original.route')->with('error', 'Unknown error occurred');
 }
Beispiel #8
0
 public function makeCreatePermissionForm($fid)
 {
     $feature = Feature::find($fid);
     if (!isset($feature)) {
         return Redirect::to('/crm/feature')->withMessage(Generate::message('Invalid', 'Invalid Feature or Feature has been deleted'));
     }
     $all_positions = Permission::getAllCurrentPosition();
     $icons = SysConfig::getSystemConfig('Icons');
     $icon_bgs = SysConfig::getSystemConfig('IconBG');
     $all_pages = Permission::getAllCurrentPages();
     $all_prompt_types = Permission::getAllCurrentPromptTypes();
     return View::make('backend.feature.create_permission')->with('feature', $feature)->with('icons', $icons)->with('icon_bgs', $icon_bgs)->with('all_prompt_types', $all_prompt_types)->with('all_pages', $all_pages)->with('all_positions', $all_positions)->with('module', $this->module);
 }
Beispiel #9
0
 public static function refreshUserSession()
 {
     $user_id = Session::get('user')['id'];
     $user = User::find($user_id);
     if (Auth::login($user)) {
         Session::flush();
         // if()
         Session::put('user', $user->toArray());
         Session::put('navtop', User::getNavTop($user_id)['data']);
         Session::put('sidebar', User::getSidebar($user_id)['data']);
         Session::put('permissions', User::getUserPermission($user_id)['data']);
         Session::put('features', User::getUserFeatures($user_id)['data']);
         return Redirect::to(Session::get('navtop')['home_url']);
     }
 }