public function beforeAction($action) { if (parent::beforeAction($action)) { if (Yii::app()->user->isGuest) { $this->redirect(array('site/login')); } else { $userInfo = MemberModel::model()->find('username=:username', array(':username' => Yii::app()->user->name)); foreach (GroupModel::model()->findAll() as $g) { $group[$g->id] = $g; } Yii::app()->session['group'] = $group; Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'lv' => $userInfo->lv, 'groupId' => $userInfo->groupId); } } return true; }
public static function GetUserMenu() { $userInfo = Yii::app()->session['userInfo']; $groupInfo = GroupModel::model()->find(array('condition' => 'group_id=:group_id', 'params' => array('group_id' => $userInfo['group_id']))); $actionArray = explode(',', $groupInfo->action); $menuList = self::$menuList; foreach ($menuList as $k => $m) { if (!in_array($m['act'], $actionArray)) { unset($menuList[$k]); foreach ($m['action'] as $sk => $subMenu) { if (!in_array($subMenu['act'], $actionArray)) { unset($menuList[$k]['action'][$sk]); } } } } return $menuList; }
</tr> <tr> <td> <fieldset> <input id="quicksearch" type="text" style="display:none;margin:4px 0" name="search" value="" id="id_search" placeholder="Tìm nhóm Spam" autofocus /> </fieldset> </td> </tr> </table> <br> <div id="group" style="display:none;height: 200px; overflow-y: scroll; width: 100%; padding-top: 10px; border-top: 2px solid rgb(51, 51, 51);"> <?php $cri = new CDbCriteria(); $cri->condition = " id != {$group_id}"; $group = GroupModel::model()->findAll($cri); foreach ($group as $gr) { echo "<div class='igroup'><input type='checkbox' name='group_list[]' value={$gr->id} ><span>" . $gr->name . "</span></div>"; } ?> </div> <br> <table style="float:left;width:100%;"> <tr> <td style="vertical-align: middle;" ><b><?php echo CHtml::label(Yii::t('admin', 'Thời gian'), ""); ?> </b></td> <td style="vertical-align: middle;"> <div class="row created_time" style="position: relative;float:left">
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new PhoneModel(); $message = ""; $errorList = array(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['source_name'], $_POST['group_id'])) { $fileName = _APP_PATH_ . DS . "data" . DS . "tmp" . DS . $_POST['source_name']; $group_id = $_POST['group_id']; //$fileName = "D:\\chacha_cloud\\src\\trunk\chacha\data\\tmp\\20120713170547_phone_list.xls"; try { require_once 'excel_reader2.php'; $data = new Spreadsheet_Excel_Reader($fileName, true, "UTF-8"); // khoi tao doi tuong doc file excel $rowsnum = $data->rowcount($sheet_index = 0); // lay so hang cua sheet $colsnum = $data->colcount($sheet_index = 0); // lay so cot cua sheet for ($i = 2; $i <= $rowsnum; $i++) { // doc tu hang so 2 vi hang 1 la tieu de roi! $phoneNum = $data->val($i, 1); // xuat cot so 1 va cot so 2 tren cung 1 hang // check so dien thoai xem co dung cua Vinaphone ko try { $phoneNum = Formatter::formatPhone($phoneNum); if (Formatter::isVinaphoneNumber($phoneNum)) { $model->phone = "{$phoneNum}"; $model->group_id = $group_id; $model->status = 0; $model->created_time = date("Y-m-d H:i:s"); var_dump($model->phone); try { if ($model->save()) { $message = yii::t('SpamModule', 'Upload thành công'); } else { print_r($model->getErrors()); exit; } } catch (Exception $exc) { echo $exc->getTrace(); } } else { //echo so dien thoai ko dung $errorList[] = $phoneNum; } } catch (Exception $exc) { echo $exc->getMessage(); } } } catch (Exception $exc) { echo $exc->getMessage(); } } $uploadModel = new XUploadForm(); $tmpArr = GroupModel::model()->findAll(); $smsGroup = array(); foreach ($tmpArr as $smsG) { $smsGroup[$smsG->id] = $smsG->name; } $this->render('create', array('model' => $model, 'uploadModel' => $uploadModel, 'message' => $message, 'smsGroup' => $smsGroup, 'errorList' => $errorList)); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = GroupModel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionUserUpdate($id) { $model = UserModel::model()->findByPk($id); $group = GroupModel::model()->findall(); foreach ($group as $v) { $groupList[$v->group_id] = $v->name; } if (isset($_POST['UserModel'])) { $model->attributes = $_POST['UserModel']; $model->scenario = 'update'; if ($model->validate()) { if ($_POST['UserModel']['newPswd']) { $model->pswd = md5($_POST['UserModel']['newPswd']); } $model->save(); $this->redirect(array('group/user')); } } $this->render('userUpdate', array('model' => $model, 'group' => $groupList)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['CldModel'])) { $model->attributes = $_POST['CldModel']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $tmpArr = GroupModel::model()->findAll(); $smsGroup = array(); foreach ($tmpArr as $smsG) { $smsGroup[$smsG->id] = $smsG->name; } $this->render('update', array('model' => $model, 'smsGroup' => $smsGroup, 'group_id' => $model->group_id)); }