Пример #1
0
 function actionModify()
 {
     $id = (int) $this->_context->get('id');
     $rs = Plans::find('plan_id = ?', $id)->getOne();
     $form = Form_Common::createForm('', 'manage/plans');
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         $post = $this->_context->post();
         $dsp = array_combine($post['config']['val'], $post['config']['dsp']);
         $tmp = array();
         foreach ($dsp as $val => $dsp) {
             $tmp[] = array('price' => $val, 'print' => $dsp);
         }
         $sku = array_combine($post['config']['key'], $tmp);
         $rs->name = $post['name'];
         $rs->desc = $post['desc'];
         $rs->groupname = $post['groupname'];
         $rs->sku = phpversion() >= '5.4' ? json_encode($sku, JSON_UNESCAPED_UNICODE) : json_encode($sku);
         $rs->save();
         return $this->msg($tip = '修改成功', url('manage::plans/modify', array('id' => $id)));
     }
     $groupname_list = Radgroupcheck::find()->group('groupname')->getAll()->toHashMap('groupname', 'groupname');
     $form->element('groupname')->items = $groupname_list;
     $form->import($rs->toArray());
     $this->_view['_UDI'] = 'manage::plans/index';
     $this->_view['form'] = $form;
     $this->_view['rs'] = $rs;
 }
Пример #2
0
 /**
  * Update user account information
  *
  * @param $request
  * @return bool
  */
 public function updateUser($request)
 {
     $redirect = false;
     $errorMsg = '';
     // Start transaction
     DB::beginTransaction();
     // Create new user
     try {
         $userId = $request->get('user_id');
         // Update user info
         $user = $this->model->find($userId);
         $update = $user->update(['first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'email' => $request->get('email'), 'active' => $request->get('active'), 'password' => bcrypt($request->get('password'))]);
         // Remove all existing roles for user
         if (isset($user->id)) {
             $user->roles()->delete();
         }
         // Update user roles
         $newRoles = explode(',', $request->get('role'));
         if (count($newRoles) > 0) {
             foreach ($newRoles as $key => $value) {
                 $this->userRoleModel->create(['user_id' => $userId, 'role_id' => $value]);
             }
         }
     } catch (\Exception $e) {
         $errorMsg = $e->getMessage();
         $redirect = true;
     } catch (QueryException $e) {
         $errorMsg = $e->getErrors();
         $redirect = true;
     } catch (ModelNotFoundException $e) {
         $errorMsg = $e->getErrors();
         $redirect = true;
     }
     // Redirect if errors
     if ($redirect) {
         // Rollback
         DB::rollback();
         // Log specific technical message
         Tools::log($errorMsg, array_except($request->all(), ['_token', 'created_from', 'created_to', 'password', 'password_confirmation']));
         return false;
     }
     // Commit all changes
     DB::commit();
     return true;
 }
Пример #3
0
    if (Q::ini('isDemo')) {
        ?>
    <tr>
        <td width="40"><label for="subject">购买:</label></td>
        <td><select name="billingcycle" class="slt">
            <option value="monthly" selected="selected">月付(0.01元--仅供演示)</option>
            <option value="quarterly">季付(0.01元--仅供演示)</option>
            <option value="semi-annually">半年付(0.01元--仅供演示)</option>
        </select>
        </td>
    </tr>
    <?php 
    } else {
        ?>
    <?php 
        $rs = Plans::find()->order('plan_id DESC')->getAll();
        ?>
    <tr>
        <td width="40"><label for="subject">计划:</label></td>
        <td><select id="plan_id" name="plan_id" class="slt">
            <?php 
        foreach ($rs as $plan) {
            ?>
            <option value="<?php 
            echo $plan->id();
            ?>
"><?php 
            echo $plan->name();
            ?>
</option>
            <?php