Esempio n. 1
0
 /**
  * 修改个人信息
  */
 function actionChangeInfo()
 {
     $this->_pathway->addStep('个人信息');
     $currentUser = $this->_app->currentUser();
     $user = Users::find()->getById($currentUser['id']);
     $form = new Form_User(url('admin::usercenter/changeInfo'));
     $form->element('username')->set('readonly', 'true');
     $form->remove('password');
     $form->element('group_id')->items = Groups::find('id=?', $user->group_id)->order('weight desc')->getAll()->toHashMap('id', 'name');
     $form->element('level_id')->items = Levels::find('weight=?', $user->level_id)->order('weight desc')->getAll()->toHashMap('weight', 'name');
     $form->remove('enabled');
     $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $currentUser['id']));
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             $user->changeProps($form->values());
             $user->save();
             return "{msg:'编辑成功'}";
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     } else {
         $form->import($user);
     }
     $form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true'));
     $form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true'));
     $this->_view['form'] = $form;
 }
Esempio n. 2
0
 /**
  * 详情 等级
  */
 function actionLevelView()
 {
     $this->_pathway->addStep('浏览等级详情');
     $id = $this->_context->id;
     $level = Levels::find()->getById($id);
     $this->_view['level'] = $level;
 }
Esempio n. 3
0
 function actionPutout()
 {
     $this->_pathway->addStep('媒资编目');
     $id = $this->_context->id;
     $file = Files::find()->getById($id);
     if ($file->isNewRecord()) {
         return '记录不存在或已删除';
     }
     if (!file_exists($file->path . $file->name . '.' . $file->ext)) {
         return '文件不存在或已删除';
     }
     //保存编目信息
     if ($this->_context->isPOST()) {
         $file->level = $this->_context->level;
         if (!isset($this->_context->groups) || in_array('all', $this->_context->groups)) {
             $file->groups = 'all';
         } else {
             $file->groups = ',';
             foreach ($this->_context->groups as $v) {
                 $file->groups .= $v . ',';
             }
         }
         $file->is_download = $this->_context->is_download;
         $file->status = $this->_context->status;
         $file->putout_username = $this->_view['currentUser']['username'];
         $file->putout_at = time();
         try {
             $file->save();
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             return '提交失败!';
         }
         //更新索引
         $filesCounter = FilesCounter::find()->getById(1);
         if ($filesCounter->isNewRecord()) {
             $filesCounter = new FilesCounter();
             $filesCounter->id = 1;
         }
         $filesCounter->file_id = $file->id();
         try {
             $filesCounter->save();
             @exec(Q::ini('appini/search/sphinxDelta'));
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             return '更新索引失败!';
         }
         return '提交成功!';
     }
     $this->_view['file'] = $file;
     $this->_view['levels'] = Levels::find('enabled=1')->getAll();
     $this->_view['groups'] = Groups::find('enabled=1')->getAll();
 }