/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model=new Register; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Register'])) { $model->attributes=$_POST['Register']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('create',array( 'model'=>$model, )); }
function send() { //保存数据 session_start(); $this->doNotRenderHeader = 1; $email = get_post_value('email'); $_SESSION["email"] = $email; $psword = get_post_value('psword'); //$mobile = get_post_value('mobile'); $intro = get_post_value('intro'); $m = new Register(); $data = $m->save($email, $psword, $intro); if ($data != '') { //正式表不存在且成功保存在注册过渡表中 $this->sendEmail($data); $this->assign('email', $this->emailHide($email)); $this->assign('mail', $this->getMail($email)); } else { //未完善 $this->assign('error', "注册失败"); } }
public function actionRegister() { $registerModel = new Register(); if (isset($_POST['Register'])) { $post = $_POST['Register']; $registerModel->attributes = $post; if ($registerModel->validate()) { //验证新用户是否已注册 $registerInfo = $registerModel->findBySql("select username from {{user}} where username = '******'username'] . "' "); if ($registerInfo['username'] != NULL) { $data = array('backup' => 'index/register', 'params' => array(), 'message' => '(⊙v⊙),运气很背的说,你注册的号比人先注册了。TRY and Make a Change...'); $this->renderPartial('error', $data); die; } $registerModel->password = md5($post['password']); if ($registerModel->save() == true) { //初始化个人网站配置 $configModel = new Config(); $configModel->userid = $registerModel->attributes['id']; $configModel->iaccess = 0; $configModel->save(false); //初始化个人菜单 for ($s = 1; $s < 3; $s++) { for ($i = 1; $i < 7; $i++) { $name = "自定义" . $i; $pid = 0; $sort = $i; $link = "#"; $position = 1; $uid = $registerModel->attributes['id']; //顶部菜单 if ($s == 1) { if ($i == 1) { //首页 $link = $this->createUrl("/index/m/who/" . $uid); $name = "主页"; } if ($i == 3) { //下拉菜单 $sql = "insert into {{menu}} (name,pid,sort,link,position,userid) values('{$name}',{$pid},{$sort},'{$link}',{$position},{$uid})"; if (Yii::app()->db->createCommand($sql)->execute()) { $pid = Yii::app()->db->getLastInsertID(); for ($j = 1; $j < 4; $j++) { $name = "下拉菜单" . $j; $sort = $j; $sql = "insert into {{menu}} (name,pid,sort,link,position,userid) values('{$name}',{$pid},{$sort},'{$link}',{$position},{$uid})"; Yii::app()->db->createCommand($sql)->execute(); } } continue; } if ($i == 4) { $name = "@我吧"; $link = $this->createUrl("/index/contact/uid/" . $uid); } if ($i == 5) { $name = "视频播客" . $i; } if ($i == 6) { $name = "我的音乐" . $i; } } //顶部菜单 if ($s == 2) { $position = 2; if ($i == 1) { $name = "版权所有 walksun Copyright 2014 - 2015"; } if ($i == 6) { $name = "管理助手"; $link = $this->createUrl("/admin/admin/index"); } } $sql = "insert into {{menu}} (name,pid,sort,link,position,userid) values('{$name}',{$pid},{$sort},'{$link}',{$position},{$uid})"; Yii::app()->db->createCommand($sql)->execute(); } } Yii::app()->session['uid'] = $registerModel->attributes['id']; $this->redirect(array("/index/m/who/" . $registerModel->attributes['id'])); } else { $data = array('backup' => 'index/index/register', 'message' => '(⊙v⊙),运气很背的说,你注册的号比你先注册了。'); $this->renderPartial('error', $data); } } } $data = array('registerModel' => $registerModel, "backup" => "index/index", 'login' => 'admin/login/index'); $this->layout = '//layouts/register'; $this->render('iregister', $data); }
public function setRegister($record) { if(strtolower($record->role->role) === strtolower(Helper::CONST_Sales)) { $loginid = $record->login->id; $roleid = $record->role->id; $criteria=new CDbCriteria; $criteria->addCondition('login_id = :loginid AND role_id=:roleid AND DATE(salesdate) = DATE(NOW()) AND open_time IS NOT NULL AND close_time IS NULL'); $criteria->params = array(':loginid' => $loginid, ':roleid' => $roleid, ); $result = Register::model()->findAll($criteria); if(empty($result)) { $result = null; $register = new Register; $register->login_id = $loginid; $register->role_id = $roleid; $register->salesdate = date(Yii::app()->controller->datetimemysqlformatYMD); $register->op_balance = null; $rtn = $register->save(); if($rtn) { $result = $register; } } else { $result = $result[0]; } $this->setState('register',$result); } else { $this->setState('register',null); } }