Example #1
0
 public function registerApprove($params)
 {
     $objMdlRegister = app::get('syspromotion')->model('activity_register');
     $objMdlItem = app::get('syspromotion')->model('activity_item');
     $objMdlactivity = app::get('syspromotion')->model('activity');
     $filter = array('activity_id' => $params['activity_id'], 'shop_id' => $params['shop_id']);
     $registerInfo = $objMdlRegister->getRow('*', $filter);
     $activityInfo = $objMdlactivity->getRow('release_time', array('activity_id' => $params['activity_id']));
     $nowTime = time();
     // 审批通过
     if ($params['status'] == 'agree') {
         if ($registerInfo['verify_status'] == 'agree') {
             return true;
         }
         $filter = array('activity_id' => $params['activity_id'], 'shop_id' => $params['shop_id']);
         $db = app::get('syspromotion')->database();
         $db->beginTransaction();
         try {
             if ($nowTime > $activityInfo['release_time']) {
                 throw \LogicException('发布时间已过,不可以对其活动进行操作!');
             }
             if (!$objMdlRegister->update(array('verify_status' => 'agree'), $filter)) {
                 throw \LogicException('活动保存失败');
             }
             if (!$objMdlItem->update(array('verify_status' => 'agree'), $filter)) {
                 throw \LogicException('活动保存失败');
             }
             $db->commit();
         } catch (Exception $e) {
             $db->rollback();
             throw $e;
         }
     }
     // 审批驳回
     if ($params['status'] == 'refuse') {
         if ($registerInfo['verify_status'] == 'refuse') {
             return true;
         }
         $filter = array('activity_id' => $params['activity_id'], 'shop_id' => $params['shop_id']);
         $db = app::get('syspromotion')->database();
         $db->beginTransaction();
         try {
             if ($nowTime > $activityInfo['release_time']) {
                 throw \LogicException('发布时间已过,不可以对其活动进行操作!');
             }
             if (!$objMdlRegister->update(array('verify_status' => 'refuse', 'refuse_reason' => $params['reason']), $filter)) {
                 throw \LogicException('活动保存失败');
             }
             if (!$objMdlItem->update(array('verify_status' => 'refuse'), $filter)) {
                 throw \LogicException('活动保存失败');
             }
             $db->commit();
             return true;
         } catch (Exception $e) {
             $db->rollback();
             throw $e;
         }
     }
     return true;
 }
 /**
  * @return void
  */
 public function render()
 {
     $viewHelperName = str_replace('_JoinItemViewHelper', '_JoinViewHelper', get_class($this));
     $key = 'items';
     if (!$this->viewHelperVariableContainer->exists($viewHelperName, $key)) {
         throw LogicException(sprintf('%s must be used as child of %s.', get_class($this), $viewHelperName));
     }
     $values = $this->viewHelperVariableContainer->get($viewHelperName, $key);
     $values[] = $this->renderChildren();
     $this->viewHelperVariableContainer->addOrUpdate($viewHelperName, $key, $values);
 }
Example #3
0
 /**
  * 保存优惠券
  * @param  array $data 优惠券传入数据
  * @return bool       是否保存成功
  */
 public function saveCoupon($data)
 {
     $couponData = $this->__preareData($data);
     $objMdlCoupon = app::get('syspromotion')->model('coupon');
     $db = app::get('syspromotion')->database();
     $db->beginTransaction();
     try {
         if (!$objMdlCoupon->save($couponData)) {
             throw \LogicException('优惠券保存失败');
         }
         if (!$this->__saveCouponItem($couponData)) {
             throw new \LogicException('优惠券促销关联商品保存失败!');
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollback();
         throw $e;
     }
     return true;
 }
 /**
  * Locates the user based on the given username string.
  * The username string must uniquely identify the user (its format can differ
  * depending on the authentication mechanism e.g. could be a DN string for x509).
  *
  * @param string $username the user string identifying the user whose data is required.
  * @return \IUserDetails implementation (never <code>null</code>)
  * @throws UsernameNotFoundException if the user could not be found or the user has no GrantedAuthority
  */
 public function loadUserByUsername($username)
 {
     throw \LogicException('not implemted yet');
     if ($username == null) {
         throw new UsernameNotFoundException(null, 'null username');
         //throw new \RuntimeException('null username');
     }
     $roles = array();
     // We have a choice here depending on our implementation:
     // At this point we know the user has a valid IGTF certificate and therefore
     // we could add a role such as 'ROLE_CERTOWNER.' In doing this, user would
     // have a granted authority (even if they have not registered) and we
     // would not throw a UsernameNotFoundException below. We would thus
     // regard them as authenticated - this is our implementation choice.
     $roles[] = "ROLE_CERTOWNER";
     // Add extra logic to lookup user and assign roles accordingly
     //$Results = get_xml('Get_User_By_DN', array($username));
     $user = \Factory::getUserService()->getUserByPrinciple($username);
     if ($user != null) {
         $roles[] = 'ROLE_REGISTERED_USER';
         //foreach($user->getRoles() as $role){
         //   if($role->getRoleType()->getName() == 'GocdbAdmin'){
         //        $roles[] = 'ROLE_GOCDB_ADMIN';
         //   }
         //}
         // we can add extra roles here....
     }
     // If the user is not found or has no granted authorities then
     // we need to honour the contract of the public API and throw ex.
     if (count($roles) == 0) {
         throw new UsernameNotFoundException(null, 'username [' . $username . '] not found');
     }
     // return our custom IUserDetails implementation
     $userDetails = new GOCDBUserDetails($username, true, $roles, $user, '');
     return $userDetails;
     //$userDetails = new GOCDBUserDetails($username, true, $roles, null, '');
     //return $userDetails;
 }
Example #5
0
 public function setMainpush($params)
 {
     $objMdlActivity = app::get('syspromotion')->model('activity');
     $result = $objMdlActivity->update(array('mainpush' => 0));
     if (!$result) {
         throw \LogicException("取消原有主推活动失败");
     }
     $params['mainpush'] = 1;
     $result = $objMdlActivity->save($params);
     if (!$result) {
         throw \LogicException("设置主推活动失败");
     }
     return true;
 }
Example #6
0
File: Http.php Project: eix/core
 public function retrieveAll(array $filter = null, array $fields = null)
 {
     throw \LogicException('retrieveAll not implemented!');
 }
Example #7
0
 /**
  * ログアウトする
  */
 public function logout()
 {
     if (!isset($_SESSION)) {
         throw LogicException('no session');
     }
     $this->call_module('before_logout', $this);
     $this->rm_sessions($this->login_id . 'USER');
     $this->rm_sessions($this->login_id);
 }
Example #8
0
 private function addWhereClause($offset)
 {
     if (is_numeric($offset)) {
         // first case: a numeric offset specifies
         if ($this->offsetClause !== null && $offset != $this->offsetClause) {
             throw \LogicException('Cannot specify two offsets at the same time');
         }
         $newThis = clone $this;
         $newThis->offsetClause = $offset;
         if ($newThis->currentResultSet && isset($newThis->currentResultSet[$offset])) {
             $newThis->currentResultSet = [$offset => $newThis->currentResultSet[$offset]];
         }
         return $newThis;
     } else {
         if (is_string($offset)) {
             // second case: a string offset, a where clause
             $newThis = clone $this;
             $newThis->currentResultSet = null;
             if ($newThis->whereClause != '') {
                 $newThis->whereClause .= ' AND ';
             }
             $newThis->whereClause .= $offset;
             return $newThis;
         } else {
             if (is_array($offset)) {
                 // third case: an array, a where clause
                 $newThis = clone $this;
                 $newThis->currentResultSet = null;
                 foreach ($offset as $key => $value) {
                     if (is_numeric($key)) {
                         continue;
                     }
                     if ($newThis->whereClause != '') {
                         $newThis->whereClause .= ' AND ';
                     }
                     $newThis->whereClause .= $this->colNameDelimiter . $key . $this->colNameDelimiter . ' = ?';
                     $newThis->whereParams[] = $value;
                 }
                 return $newThis;
             } else {
                 throw new \LogicException('Can only pass numbers, strings or arrays inside brackets');
             }
         }
     }
 }
Example #9
0
 /**
  * Generates URI using provided params.
  *
  * @throws InvalidArgumentException
  * @param string $controller
  * @param string $action
  * @param array $params
  * @return string
  */
 public function generateUri($controller, $action = null, array $params = array())
 {
     throw LogicException("Cant generate URI in API context");
 }
Example #10
0
 /**
  * Output the data stored in the large object resource to stdout.
  * @param void
  * @return void
  */
 public function stream()
 {
     // filesystem
     if (isset($this->filePath)) {
         return readfile($this->filePath);
     } elseif ($this->oid) {
         $pg = $this->oid->pg;
         $pg->query(new Query('BEGIN'));
         $handle = pg_lo_open($pg->resource->get(), $this->oid->oid, 'r');
         pg_lo_read_all($handle);
         pg_lo_close($handle);
         $pg->query(new Query('COMMIT'));
         return null;
     }
     throw \LogicException("Shouldn't ever get tripped");
 }