Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public function preUp()
 {
     $q = Doctrine_Query::create()->select('a.userid, a.plan, a.edit_text, a.username')->from('Accounts a');
     $plans = $q->execute();
     foreach ($plans as $plan) {
         $p = new Plans();
         $p->user_id = $plan->userid;
         try {
             $p->edit_text = stripslashes($plan->edit_text);
             $p->save();
         } catch (Doctrine_Validator_Exception $e) {
             echo "[{$plan->username}]'s Plan did not update because the generated HTML was too long\n";
             $p->plan = stripslashes($plan->plan);
             $p->save();
         }
     }
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 /**
  * 验证用户具体发帖权限,并不影响其他权限
  * @param type $uid 验证的用户
  * @param type $type 验证的类型
  * @param type $field 是否检查总数
  * @return type
  */
 public static function check($type, $field = false, $uid = '')
 {
     if (!$uid) {
         $uid = Yii::app()->user->id;
     }
     if (!$uid) {
         if (zmf::config('officalUid')) {
             return array('status' => 1, 'msg' => '');
         }
         return array('status' => 0, 'msg' => '用户不存在');
     }
     $uinfo = Users::getUserInfo($uid);
     if (!$uinfo) {
         return array('status' => 0, 'msg' => '用户不存在');
     }
     if (!$uinfo['groupid']) {
         return array('status' => 0, 'msg' => '无组织用户');
     }
     $groupInfo = UserPower::model()->find('groupid=:gid', array(':gid' => $uinfo['groupid']));
     if (!$groupInfo) {
         return array('status' => 0, 'msg' => '无组织用户');
     }
     $num = $groupInfo->getAttribute($type);
     if ($num === null) {
         return array('status' => 0, 'msg' => '无法完成验证的type:' . $type);
     } elseif ($num === 0) {
         return array('status' => 0, 'msg' => '不允许');
     } elseif ($field) {
         switch ($field) {
             case 'addPost':
                 $totalNum = $groupInfo['postNum'];
                 $hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addQuestion':
                 $totalNum = $groupInfo['questionNum'];
                 $hasNum = Question::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addAnswer':
                 $totalNum = $groupInfo['answerNum'];
                 $hasNum = Answer::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addPoiPost':
                 $totalNum = $groupInfo['poiPostNum'];
                 $hasNum = PoiPost::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addPoiTips':
                 $totalNum = $groupInfo['poiTipsNum'];
                 $hasNum = PoiTips::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addImage':
                 $totalNum = $groupInfo['imageNum'];
                 $hasNum = Attachments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addComment':
                 $totalNum = $groupInfo['commentNum'];
                 $hasNum = Comments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'addPlan':
                 $totalNum = $groupInfo['planNum'];
                 $hasNum = Plans::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
             case 'yueban':
                 $totalNum = $groupInfo['yuebanNum'];
                 $hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
                 break;
         }
         if (!$totalNum) {
             return array('status' => 1, 'msg' => '无限制');
         } else {
             if ($hasNum >= $totalNum) {
                 return array('status' => 0, 'msg' => '已超出限制:' . $totalNum);
             } else {
                 return array('status' => 1, 'msg' => '');
             }
         }
     } else {
         return array('status' => 1, 'msg' => '');
     }
 }
Exemplo n.º 5
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 integer $id the ID of the model to be loaded
  * @return Plans the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Plans::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 6
0
 public function actionSend()
 {
     $plan_id = "880dcb73-7bc2-11e5-bc4d-3c07717072c4";
     $plan_model = Plans::model()->find(array('condition' => 'id = "' . $plan_id . '" '));
     $data['plan_name'] = $plan_model->name;
     $body = $this->renderPartial("quotation_mail_template", $data, true);
     mailsend("*****@*****.**", "*****@*****.**", "hi", $body);
 }
Exemplo n.º 7
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