コード例 #1
0
 public function showMyCategoryAnalytics()
 {
     $categories = $this->categories_repo->getCategories();
     $analytics = $this->analytics_repo->getCategoryAnalytics();
     $admin_analytics = [];
     if (!empty($analytics['_users'][\AuthMgr::getLoggedUserId()])) {
         $admin_analytics = $analytics['_users'][\AuthMgr::getLoggedUserId()];
     }
     return View::make('category-analytics', ['header_title' => 'My Category Analytics', 'categories' => $categories, 'analytics' => $admin_analytics]);
 }
 /**
  * When a product has been added to cart
  */
 public function onCartAdded($product_id, $product_user_id)
 {
     if (empty($product_id)) {
         throw new \InvalidArgumentException();
     }
     if ($product_user_id == \AuthMgr::getLoggedUserId()) {
         return;
     }
     $this->recordInteraction($this->cart_add_add_type_id, $product_id);
 }
コード例 #3
0
        return null;
    }
    $first_name = ucwords($user['first_name']);
    $last_name = ucwords($user['last_name']);
    return $first_name . ' ' . $last_name;
});
HTML::macro('loggedUserFullName', function () {
    $logged_user = AuthMgr::getLoggedUser();
    return HTML::userFullName($logged_user);
});
HTML::macro('loggedUserEmail', function () {
    $user = AuthMgr::getLoggedUser();
    return $user['email'];
});
HTML::macro('loggedUserGravatarImage', function ($alt = null, $attributes = []) {
    $logged_user = AuthMgr::getLoggedUser();
    if (empty($logged_user)) {
        return null;
    }
    return Gravatar::image($logged_user->email, $alt, $attributes);
});
/*
|--------------------------------------------------------------------------
| Helper Functions
|--------------------------------------------------------------------------
|
| Include helper functions file
|
*/
require_once 'helper_functions.php';
/*
コード例 #4
0
 public function testProcessPermDeleteProductReturnsWithErrorsnWhenDeleteOpFails()
 {
     \Artisan::call('migrate');
     \Artisan::call('db:seed');
     \AuthMgr::loginById(1);
     \AuthMgr::shouldReceive('getLoggedUserId')->once()->andReturn(1);
     \AuthMgr::shouldReceive('hasPermission')->once()->with(['_superadmin', '_delete-product'])->andReturn(true);
     \AuthMgr::shouldReceive('hasPermission')->once()->with(['_superadmin', '_blacklist-product'])->andReturn(true);
     $prod_delete_req_repo_mock = Mockery::mock('Giftertipster\\Repository\\ProductDeleteRequest\\ProductDeleteRequestRepositoryInterface');
     $prod_delete_req_repo_mock->shouldReceive('create')->with(['product_id' => 1, 'delete_type' => 'deletePerm', 'is_fulfilled' => 0, 'user_id' => 1])->once()->andReturn(false);
     $prod_delete_req_repo_mock->shouldReceive('errors')->once()->andReturn(['error']);
     $this->app->instance('Giftertipster\\Repository\\ProductDeleteRequest\\ProductDeleteRequestRepositoryInterface', $prod_delete_req_repo_mock);
     $this->call('POST', 'service-tools/perm-delete-product', ['product_id' => 1], [], ['HTTP_REFERER' => 'back']);
     $this->assertSessionHasErrors();
     $this->assertRedirectedToUrl('back');
 }
コード例 #5
0
 public function showMyRecommendations($page = 1)
 {
     $items_per_page = 15;
     $filters = [['filter' => 'TermFilter', 'params' => ['field' => 'user_id', 'value' => \AuthMgr::getLoggedUserId()]]];
     $fetcher_response = $this->prod_suite_fetcher->filterProducts(($page - 1) * $items_per_page, $items_per_page, $filters);
     $pagination_html = '';
     //if there are results, generate pagination
     if (!empty($fetcher_response['results'])) {
         $this->paginator->setUrl(\Request::url(), '/(:num)')->setItems($fetcher_response['meta']['total_hits'], $items_per_page)->setPage($page);
         //make pagination html
         $pagination_html = \HTML::paginatorHTML($this->paginator->toArray());
     }
     return \View::make('my-recommendations')->with('products', $fetcher_response['results'])->with('pagination_html', $pagination_html);
 }