public function postRequestPublishAction($pageId)
 {
     $request_id = Request::input('request');
     $request = PagePublishRequests::with('page_version')->find($request_id);
     if (!empty($request)) {
         $request_action = Request::input('request_action');
         return $request->process($request_action);
     } else {
         return 0;
     }
 }
Exemple #2
0
 public function tabRequests()
 {
     $header = '';
     $contents = '';
     $allRequests = PagePublishRequests::all_requests($this->id);
     if (!$allRequests->isEmpty()) {
         $awaitingRequests = PagePublishRequests::all_requests($this->id, ['status' => 'awaiting']);
         $header = 'Publish Requests';
         if ($count = $awaitingRequests->count()) {
             $header .= ' &nbsp; <span class="badge">' . $count . '</span>';
         }
         if ($awaitingRequests->isEmpty()) {
             $awaitingRequests = 'No awaiting requests';
         }
         $requests_table = View::make('coaster::partials.tabs.publish_requests.table', ['show' => ['page' => false, 'status' => true, 'requested_by' => true], 'requests' => $awaitingRequests])->render();
         $contents = View::make('coaster::partials.tabs.publish_requests.main', ['requests_table' => $requests_table]);
     }
     return [$header, $contents];
 }
 public function getYourRequests()
 {
     $user_requests = PagePublishRequests::all_requests(0, ['user_id' => Auth::user()->id], 25);
     if ($user_requests->isEmpty()) {
         $user_requests = 'You have made no requests';
     }
     $user_requests_table = View::make('coaster::partials.tabs.publish_requests.table', array('show' => ['page' => true, 'status' => true, 'requested_by' => false], 'requests' => $user_requests))->render();
     $this->layoutData['title'] = 'Your Publish Requests';
     $this->layoutData['content'] = View::make('coaster::pages.home.requests', array('title' => $this->layoutData['title'], 'requests' => $user_requests_table, 'pagination' => !is_string($user_requests) ? PaginatorRender::run($user_requests, 2) : ''));
 }
 public static function add($page_id, $version_id, $note = null)
 {
     $page_version = PageVersion::where('page_id', '=', $page_id)->where('version_id', '=', $version_id)->first();
     if ($page_version) {
         $page_requests = PagePublishRequests::where('status', '=', 'awaiting')->where('user_id', '=', Auth::user()->id)->get();
         if (!$page_requests->isEmpty()) {
             $page_version_ids = array();
             foreach ($page_requests as $page_request) {
                 $page_version_ids[] = $page_request->page_version_id;
             }
             $previous_requested_page_version = PageVersion::where('page_id', '=', $page_id)->whereIn('id', $page_version_ids)->first();
         }
         if (!empty($previous_requested_page_version)) {
             $page_request = PagePublishRequests::where('page_version_id', '=', $previous_requested_page_version->id)->where('user_id', '=', Auth::user()->id)->where('status', '=', 'awaiting')->first();
             if ($previous_requested_page_version->id == $page_version->id) {
                 $page_request->note = $note;
                 $page_request->save();
                 return 1;
             } else {
                 $page_request->status = 'cancelled';
                 $page_request->save();
             }
         }
         $new_request = new self();
         $new_request->page_version_id = $page_version->id;
         $new_request->status = 'awaiting';
         $new_request->user_id = Auth::user()->id;
         $new_request->mod_id = 0;
         $new_request->note = $note;
         $new_request->save();
         return 1;
     }
     return 0;
 }