Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
AdminController Class Reference
Inheritance diagram for AdminController:
Controller Controller BaseController BaseController

Public Member Functions

 actionReports ($form_id=null, $csv=false)
 exportCSV ($form)
 actionGetMyForms ($email)
 actionUpdateCreator ($form_id=null, $mail= '')
 filters ()
 accessRules ()
 actionAdmin ()
 actionView ()
 actionCreate ()
 actionUpdate ()
 actionDelete ()
 actionManagePersonalisation ()
 loadModel ()

Public Attributes

 $defaultAction = 'reports'
- Public Attributes inherited from Controller
 $menu = array()
 $breadcrumbs = array()
- Public Attributes inherited from BaseController
 $layout = '//layouts/gportal'
 $mailLayout = '//layouts/mail'

Additional Inherited Members

- Protected Member Functions inherited from BaseController
 beforeAction ($action)

Detailed Description

Definition at line 3 of file AdminController.php.

Member Function Documentation

AdminController::accessRules ( )

Specifies the access control rules. This method is used by the 'accessControl' filter.

Returns
array access control rules

Definition at line 30 of file AdminController.php.

{
return array(
array('allow', // allow authenticated users to access all actions
'roles'=>array('Admin'),
),
array('deny', // deny all users
'users' => array('*'),
),
);
}
AdminController::actionAdmin ( )

Manages all models.

Returns
void

Definition at line 47 of file AdminController.php.

{
$model = new User('search');
$model->status = null;
$model->is_bulk = null;
if (isset($_GET['User'])) {
$model->attributes = $_GET['User'];
}
$this->render('index', array('model' => $model,));
}
AdminController::actionCreate ( )

Creates a new model. If creation is successful, the browser will be redirected to the 'view' page.

Returns
void

Definition at line 134 of file AdminController.php.

{
$model = new User;
$profile = new Profile;
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$model->createtime = date('Y-m-d H:i:s');
$model->lastvisit = date('Y-m-d H:i:s');
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
}
$this->redirect(array('view', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render(
'create', array(
'model' => $model,
'profile' => $profile,
)
);
}
AdminController::actionDelete ( )

Deletes a particular model. If deletion is successful, the browser will be redirected to the 'index' page.

Exceptions
CHttpException
Returns
void

Definition at line 209 of file AdminController.php.

References loadModel(), Account\model(), and Profile\model().

{
if (Yii::app()->request->isPostRequest) {
// we only allow deletion via POST request
$model = $this->loadModel();
$profile = Profile::model()->findByPk($model->id);
if ($account = Account::model()->findByAttributes(array('user_id'=>$model->id))) {
$account->delete();
}
$profile->delete();
$model->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if (!isset($_POST['ajax'])) {
$this->redirect(array('/user/admin'));
}
} else {
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
}
AdminController::actionManagePersonalisation ( )

Renders ManagePersonalisation view

Returns
void

Definition at line 236 of file AdminController.php.

{
$this->render('managePersonalisation');
}
AdminController::actionUpdate ( )

Updates a particular model. If update is successful, the browser will be redirected to the 'view' page.

Returns
void

Definition at line 171 of file AdminController.php.

References loadModel(), and User\model().

{
$model = $this->loadModel();
$profile = $model->profile;
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$profile->attributes = $_POST['Profile'];
if ($model->validate() && $profile->validate()) {
$old_password = User::model()->notsafe()->findByPk($model->id);
if ($old_password->password != $model->password) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
}
$model->save();
$profile->save();
$this->redirect(array('view', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render(
'update', array(
'model' => $model,
'profile' => $profile,
)
);
}
AdminController::actionView ( )

Displays a particular model.

Returns
void

Definition at line 64 of file AdminController.php.

References loadModel(), ProfileField\model(), and UserModule\t().

{
$model = $this->loadModel();
$attributes = array(
'id',
'username',
);
array_push($attributes,
'password',
'email',
'activkey',
array(
'name' => 'createtime',
'value' => $model->createtime,
),
array(
'name' => 'lastvisit',
'value' => (($model->lastvisit) ? $model->lastvisit : UserModule::t("Not visited")),
),
array(
'name' => 'status',
'value' => User::itemAlias("UserStatus", $model->status),
)
);
$profileFields = ProfileField::model()->forAdmin()->sort()->findAll();
if ($profileFields) {
foreach ($profileFields as $field) {
$value = null;
$varname = $field->varname;
if(in_array($varname, array("send_me_notifications", "find_me_in_phone_book")) ){
$value = ($model->profile->$varname == 1)? true : false;
}else{
$value = ($field->widgetView($model->profile)) ? $field->widgetView($model->profile) : (($field->range) ? Profile::range($field->range, $model->profile->getAttribute($field->varname)) : $model->profile->getAttribute($field->varname));
}
array_push($attributes, array(
'label' => UserModule::t($field->title),
'name' => $field->varname,
'value' => $value,
));
unset($value);
}
}
foreach ($attributes as $i => &$attribute) {
if(!is_null($attribute)&&(in_array($attribute, array("password","activkey")))){
unset($attributes[$i]);
}
elseif (is_null($attribute['value'])) {
$attribute['value'] = '';
}
}
$this->render(
'view', array(
'model' => $model,
'attributes' => $attributes,
)
);
}
AdminController::filters ( )

Allows to set some filters

Returns
array action filters

Definition at line 14 of file AdminController.php.

{
return CMap::mergeArray(
parent::filters(),
array(
'accessControl', // perform access control for CRUD operations
)
);
}
AdminController::loadModel ( )

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.

Exceptions
CHttpException
Returns
void

Definition at line 249 of file AdminController.php.

References User\model().

Referenced by actionDelete(), actionUpdate(), and actionView().

{
if ($this->_model === null) {
if (isset($_GET['id'])) {
$this->_model = RegistrationForm::model()->notsafe()->findbyPk($_GET['id']);
}
if ($this->_model===null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
}
return $this->_model;
}

The documentation for this class was generated from the following files: