Skip to content

Commit

Permalink
Hosted on Drodata.com
Browse files Browse the repository at this point in the history
  • Loading branch information
drodata committed Jul 1, 2015
1 parent 4baec90 commit d76d48a
Show file tree
Hide file tree
Showing 20 changed files with 437 additions and 10 deletions.
7 changes: 7 additions & 0 deletions protected/config/pswd-sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
// fill database name
$connectString = 'mysql:host=localhost;dbname=';
$username = 'root';
$password = ''; // fill your pswd
?>

23 changes: 23 additions & 0 deletions protected/controllers/BackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ class BackController extends Controller
* @var CActiveRecord the currently loaded data model instance.
*/
private $_model;
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}

/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow authenticated users to access all actions
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}

public function actionAjaxGetLabels()
{
Expand Down
106 changes: 106 additions & 0 deletions protected/controllers/UserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

class UserController extends Controller
{
private $_model;
public function loadModel()
{
if($this->_model===null)
{
if(isset($_GET['id']))
{
$this->_model=User::model()->findByPk($_GET['id']);
}
if($this->_model===null)
throw new CHttpException(404,'The requested page does not exist.');
}
return $this->_model;
}
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}

/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow authenticated users to access all actions
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
public function actionChangePwd()
{
$model=new FormUserChangePassword;

if(isset($_POST['ajax']) && $_POST['ajax']==='change-pwd-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}

if(isset($_POST['FormUserChangePassword']) )
{
$model->attributes=$_POST['FormUserChangePassword'];
$user = User::model()->findByPk(Yii::app()->user->id);
$user->password = $user->hashPassword($model->newPassword, $user->salt);

if ( $model->validate() && $user->update(array('password')) ) {
Yii::app()->user->setFlash('success', "&radic; 修改已保存");
$this->redirect(array('user/view', 'id' => $user->id));
}
}

$this->render('changePwd', array( 'model'=>$model,));
}

public function actionIndex()
{
$this->render('index',array(
));
}
public function actionView()
{
$model= $this->loadModel();
$this->render('view',array(
'model'=>$model,
));
}

// Uncomment the following methods and override them if needed
/*
public function filters()
{
// return the filter configuration for this controller, e.g.:
return array(
'inlineFilterName',
array(
'class'=>'path.to.FilterClass',
'propertyName'=>'propertyValue',
),
);
}
public function actions()
{
// return external action classes, e.g.:
return array(
'action1'=>'path.to.ActionClass',
'action2'=>array(
'class'=>'path.to.AnotherActionClass',
'propertyName'=>'propertyValue',
),
);
}
*/
}
40 changes: 40 additions & 0 deletions protected/models/FormUserChangePassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
class FormUserChangePassword extends CFormModel
{
public $oldPassword;
public $newPassword;
public $newPasswordReinput;


public function rules()
{
return array(
array('oldPassword, newPassword, newPasswordReinput', 'required'),
array( 'oldPassword', 'authOldPassword'),
array( 'newPasswordReinput', 'authNewPasswordReinput'),
);
}

public function attributeLabels()
{
return array(
'oldPassword' => '原密码',
'newPassword' => '新密码',
'newPasswordReinput' => '再次输入新密码',
);
}

public function authOldPassword($attribute,$params)
{
$user = User::model()->findByPk(Yii::app()->user->id);
if (!$user->validatePassword($this->oldPassword))
$this->addError('oldPassword','密码输入错误');
}

public function authNewPasswordReinput($attribute,$params)
{
$user = User::model()->findByPk(Yii::app()->user->id);
if ($this->newPassword != $this->newPasswordReinput)
$this->addError('newPasswordReinput','两次密码输入不一致');
}
}
17 changes: 10 additions & 7 deletions protected/modules/pk/assets/css/pk.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.quick-add-taxonomy {
background:#ffffee;
border:0px solid red;
}
.quick-add-taxonomy:focus {
border:0px solid red;
}
.quick-add-taxonomy {
background:#ffffee;
border:0px solid red;
}
.quick-add-taxonomy:focus {
border:0px solid red;
}
/* better display in section/view page */
.clip-item {
padding:10px;
Expand All @@ -17,3 +17,6 @@
span.label{
font-family: Arial;
}
.clip-item img {
width:75%;
}
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/ClipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ class ClipController extends Controller
public $layout = 'column1';
private $_model;
private $_redirectUrl;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadRedirectUrl()
{
if($this->_redirectUrl===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/ExplanationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ class ExplanationController extends Controller
{
public $layout = 'column1';
private $_model;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadModel()
{
if($this->_model===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/QuotationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ class QuotationController extends Controller
public $layout = 'column1';
private $_model;
private $_redirectUrl;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadRedirectUrl()
{
if($this->_redirectUrl===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/ScrapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ class ScrapController extends Controller
{
private $_model;
private $_redirectUrl;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadRedirectUrl()
{
if($this->_redirectUrl===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/SectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ class SectionController extends Controller
{
//public $layout = 'evernote';
private $_model;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadModel()
{
if($this->_model===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/SourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ class SourceController extends Controller
{
public $layout = 'column1';
private $_model;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadModel()
{
if($this->_model===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/TaxonomyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ class TaxonomyController extends Controller
{
public $layout = 'column1';
private $_model;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadModel()
{
if($this->_model===null)
Expand Down
15 changes: 15 additions & 0 deletions protected/modules/pk/controllers/VocabularyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ class VocabularyController extends Controller
{
public $layout = 'column1';
private $_model;
public function filters()
{
return array( 'accessControl',);
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny',
'users'=>array('*'),
),
);
}
public function loadModel()
{
if($this->_model===null)
Expand Down
Loading

0 comments on commit d76d48a

Please sign in to comment.