public function actionCreate() { $city = Yii::app()->request->getPost('city'); $type = Yii::app()->request->getPost('type'); $aim = Yii::app()->request->getPost('aim'); $prepay = Yii::app()->request->getPost('prepay'); $name = Yii::app()->request->getPost('name'); $phone = Yii::app()->request->getPost('phone'); $model = new Evaluate(); $phone_pattern = '/^\\d{3,4}[-]?\\d{7,8}$/'; if (empty($name) || trim($name) == '您的称谓') { echo CJSON::encode(array('success' => false, 'msg' => '请填写您的称谓后提交')); exit; } else { $model->name = $name; } if (empty($phone) || trim($phone) == '联系方式') { echo CJSON::encode(array('success' => false, 'msg' => '请填写联系方式后提交')); exit; } elseif (!preg_match($phone_pattern, $phone)) { echo CJSON::encode(array('success' => false, 'msg' => '不是有效的联系方式')); exit; } else { $model->phone = $phone; } if (!empty($city) && trim($city) != '意向城市') { $model->city = $city; } if (!empty($type) && trim($type) != '投资类型') { $model->type = $type; } if (!empty($aim) && trim($aim) != '投资目的') { $model->aim = $aim; } if (!empty($prepay) && trim($prepay) != '首付预算') { $model->prepay = $prepay; } if ($model->save()) { $url = Yii::app()->createUrl('evaluate/success'); echo CJSON::encode(array('success' => true, 'msg' => $url)); } else { echo CJSON::encode(array('success' => false, 'msg' => '提交失败,请稍后重试')); } }
public static function init() { global $wpdb; self::$metric_table = $wpdb->prefix . self::$metric_table; self::$voting_table = $wpdb->prefix . self::$voting_table; self::$scores_table = $wpdb->prefix . self::$scores_table; self::$directory_path = plugin_dir_path(__FILE__); self::$directory_url = plugin_dir_url(__FILE__); register_activation_hook(__FILE__, array(__CLASS__, 'activate')); add_action('plugins_loaded', array(__CLASS__, 'load'), 11); }
public function actionEvaluateHandle() { if (parent::_ajax_acl('evaluate_update')) { $id = Yii::app()->request->getPost('id'); $evaluate = Evaluate::model()->findByPk($id); if (!empty($evaluate)) { $evaluate->status = 1; if ($evaluate->save()) { AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新评估处理状态,ID:' . $evaluate->id)); echo CJSON::encode(array('success' => true, 'msg' => '需求处理成功')); } else { echo CJSON::encode(array('success' => false, 'msg' => '操作失败,请联系管理员')); } } else { echo CJSON::encode(array('success' => false, 'msg' => '此评估不存在')); } } else { echo CJSON::encode(array('success' => false, 'msg' => '当前角色组无权限进行此操作,请联系管理员授权')); } }
<?php /** * Created by PhpStorm. * User: lipeng_wei * Date: 15-12-22 * Time: 上午6:04 * * 回测评估页 * */ require_once dirname(__FILE__) . '/Require.php'; require_once MODULE_PATH . 'Purpose.class.php'; class Evaluate extends Purpose { //展示页面 public static function show() { parent::setAim('evaluate'); parent::show(); } } Evaluate::show();
/** * Returns a PHP standard object from a JSON string. * * @return stdClass */ public static function jsonDecodeString($string) { return Evaluate::isJson($string) ? (array) json_decode($string, true) : []; }