예제 #1
0
 /**
  * @param OrderBids $orderBids
  * @return bool
  */
 public function canWithdrawOrderBid(OrderBids $orderBids)
 {
     if ($this->getUser()->isAdmin()) {
         return true;
     }
     if ($this->getUser()->isSupervisor()) {
         return true;
     }
     if ($this->getUser()->isManager()) {
         // Manager can withdraw only best offer
         $bestOrderBids = OrderBids::model()->findBestOfferByOrder($orderBids->order);
         if ($bestOrderBids->id === $orderBids->id) {
             return true;
         }
     }
     return false;
 }
예제 #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param $id
  * @return OrderBids
  * @throws CHttpException
  * @internal param the $integer ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = OrderBids::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }