Пример #1
0
 public function attributeLabels()
 {
     $labels = array('user_id' => Yii::t("UserModule.user", 'User ID'), 'profile_id' => Yii::t("UserModule.user", 'Profile ID'));
     $model = ProfileField::model()->forOwner()->findAll();
     foreach ($model as $field) {
         $labels[$field->varname] = Yii::t("UserModule.user", $field->title);
     }
     return $labels;
 }
Пример #2
0
 /**
  * Shows a particular model.
  */
 public function actionProfile()
 {
     $model = $this->loadUser();
     $attributes = array('username' => array('label' => 'Username', 'value' => $model->username), 'email' => array('label' => 'E-mail', 'value' => $model->email), 'createtime' => array('label' => 'Created at', 'value' => date("d.m.Y H:i:s", $model->createtime)), 'lastvisit' => array('label' => 'Last visited at', 'value' => date("d.m.Y H:i:s", $model->lastvisit)), 'status' => array('label' => 'Status', 'value' => User::itemAlias("UserStatus", $model->status)));
     $profileFields = ProfileField::model()->forOwner()->sort()->findAll();
     if ($profileFields) {
         foreach ($profileFields as $field) {
             $attributes[$field->varname] = array('label' => UserModule::t($field->title), 'value' => $model->profile->getAttribute($field->varname));
         }
     }
     $this->render('profile', array('attributes' => $attributes));
 }
Пример #3
0
 /**
  * Displays a particular model.
  */
 public function actionView()
 {
     $model = $this->loadModel();
     $attributes = array('id', 'username');
     $profileFields = ProfileField::model()->forOwner()->sort()->findAll();
     if ($profileFields) {
         foreach ($profileFields as $field) {
             array_push($attributes, array('label' => UserModule::t($field->title), 'name' => $field->varname, 'type' => 'raw', '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, 'password', 'email', 'activkey', array('name' => 'createtime', 'value' => date("d.m.Y H:i:s", $model->createtime)), array('name' => 'lastvisit', 'value' => $model->lastvisit ? date("d.m.Y H:i:s", $model->lastvisit) : UserModule::t("Not visited")), array('name' => 'superuser', 'value' => User::itemAlias("AdminStatus", $model->superuser)), array('name' => 'status', 'value' => User::itemAlias("UserStatus", $model->status)));
     $this->render('view', array('model' => $model, 'attributes' => $attributes));
 }
 public function run($args)
 {
     $companies = Company::model()->findAll('frozen=:p', array(':p' => '0'));
     foreach ($companies as $company) {
         Company::setActive($company);
         Yii::app()->language = Company::getLanguage();
         User::model()->refreshMetaData();
         AuthAssignment::model()->refreshMetaData();
         ProfileField::model()->refreshMetaData();
         Profile::model()->refreshMetaData();
         Zakaz::model()->refreshMetaData();
         ZakazParts::model()->refreshMetaData();
         Events::model()->refreshMetaData();
         Templates::model()->refreshMetaData();
         Emails::model()->refreshMetaData();
         self::executor();
         self::manager();
         self::send_deffered_emails();
     }
 }
Пример #5
0
 /**
  * Updates or creates user by given ldap node
  * 
  * @param Zend_Ldap_Node $node
  * @return User User Object
  */
 public function handleLdapUser($node)
 {
     $username = $node->getAttribute(HSetting::Get('usernameAttribute', 'authentication_ldap'), 0);
     $email = $node->getAttribute('mail', 0);
     $guid = $this->binToStrGuid($node->getAttribute('objectGUID', 0));
     // Try to load User:
     $userChanged = false;
     $user = null;
     if ($guid != "") {
         $user = User::model()->findByAttributes(array('guid' => $guid, 'auth_mode' => User::AUTH_MODE_LDAP));
     } else {
         // Fallback use e-mail
         $user = User::model()->findByAttributes(array('email' => $email, 'auth_mode' => User::AUTH_MODE_LDAP));
     }
     if ($user === null) {
         $user = new User();
         if ($guid != "") {
             $user->guid = $guid;
         }
         $user->status = User::STATUS_ENABLED;
         $user->auth_mode = User::AUTH_MODE_LDAP;
         $user->group_id = 1;
         Yii::log('Create ldap user ' . $username . '!', CLogger::LEVEL_INFO, 'authentication_ldap');
     }
     // Update Group Mapping
     foreach (Group::model()->findAll('ldap_dn != ""') as $group) {
         if (in_array($group->ldap_dn, $node->getAttribute('memberOf'))) {
             if ($user->group_id != $group->id) {
                 $userChanged = true;
                 $user->group_id = $group->id;
             }
         }
     }
     // Update Users Field
     if ($user->username != $username) {
         $userChanged = true;
         $user->username = $username;
     }
     if ($user->email != $email) {
         $userChanged = true;
         $user->email = $email;
     }
     if ($user->validate()) {
         // Only Save user when something is changed
         if ($userChanged || $user->isNewRecord) {
             $user->save();
         }
         // Update Profile Fields
         foreach (ProfileField::model()->findAll('ldap_attribute != ""') as $profileField) {
             $ldapAttribute = $profileField->ldap_attribute;
             $profileFieldName = $profileField->internal_name;
             $user->profile->{$profileFieldName} = $node->getAttribute($ldapAttribute, 0);
         }
         if ($user->profile->validate()) {
             $user->profile->save();
             // Update Space Mapping
             foreach (Space::model()->findAll('ldap_dn != ""') as $space) {
                 if (in_array($space->ldap_dn, $node->getAttribute('memberOf'))) {
                     $space->addMember($user->id);
                 }
             }
         } else {
             Yii::log('Could not create or update ldap user profile! (' . print_r($user->profile->getErrors(), true) . ")", CLogger::LEVEL_ERROR, 'authentication_ldap');
         }
     } else {
         Yii::log('Could not create or update ldap user! (' . print_r($user->getErrors(), true) . ")", CLogger::LEVEL_ERROR, 'authentication_ldap');
     }
     return $user;
 }
Пример #6
0
 public function actionEditField()
 {
     // XSS Protection
     $_POST = Yii::app()->input->stripClean($_POST);
     $id = (int) Yii::app()->request->getQuery('id');
     // Get Base Field
     $field = ProfileField::model()->findByPk($id);
     if ($field == null) {
         $field = new ProfileField();
     }
     // Get all Available Field Class Instances, also bind current profilefield to the type
     $fieldTypes = ProfileFieldType::getTypeInstances($field);
     // Build Form Definition
     $definition = array();
     #$definition['activeForm'] = array(
     #    'class' => 'CActiveForm',
     #    'enableAjaxValidation' => true,
     #    'id' => 'login-form',
     #);
     $definition['elements'] = array();
     // Add all sub forms
     $definition['elements'] = array_merge($definition['elements'], $field->getFormDefinition());
     foreach ($fieldTypes as $fieldType) {
         $definition['elements'] = array_merge($definition['elements'], $fieldType->getFormDefinition());
     }
     // Add Form Buttons
     $definition['buttons'] = array('save' => array('type' => 'submit', 'label' => Yii::t('AdminModule.controllers_UserprofileController', 'Save'), 'class' => 'btn btn-primary'));
     if (!$field->isNewRecord && !$field->is_system) {
         $definition['buttons']['delete'] = array('type' => 'submit', 'label' => Yii::t('AdminModule.controllers_UserprofileController', 'Delete'), 'class' => 'btn btn-danger pull-right');
     }
     // Create Form Instance
     $form = new HForm($definition);
     // Add used models to the CForm, so we can validate it
     $form['ProfileField']->model = $field;
     foreach ($fieldTypes as $fieldType) {
         $form[get_class($fieldType)]->model = $fieldType;
     }
     // Form Submitted?
     if ($form->submitted('save') && $form->validate()) {
         $this->forcePostRequest();
         // Use ProfileField Instance from Form with new Values
         $field = $form['ProfileField']->model;
         $fieldType = $form[$field->field_type_class]->model;
         $field->save();
         $fieldType->save();
         $this->redirect(Yii::app()->createUrl('//admin/userprofile'));
     }
     if ($form->submitted('delete')) {
         $this->forcePostRequest();
         $field->delete();
         $this->redirect(Yii::app()->createUrl('//admin/userprofile'));
     }
     $this->render('editField', array('form' => $form, 'field' => $field));
 }
Пример #7
0
<?php

//Yii::app()->getClientScript()->registerCssFile(Yii::app()->theme->baseUrl.'/css/manager.css');
?>
<div class="row white-block">
<?php 
/* @var $this CategoriesController */
/* @var $dataProvider CActiveDataProvider */
//$this->breadcrumbs=array(
//	Yii::t('site','Catalog'),
//);
$this->menu = array(array('label' => Yii::t('site', 'Catalog'), 'url' => array('create')), array('label' => Yii::t('site', 'Manage Catalog'), 'url' => array('admin')));
?>

<h1><?echo Yii::t('site','Catalog');?></h1>

<?php 
$criteria = new CDbCriteria();
$criteria->compare('field_type', 'LIST');
$list = CHtml::listData(ProjectField::model()->findAll($criteria), 'varname', 'title');
$list = array_merge($list, CHtml::listData(ProfileField::model()->findAll($criteria), 'varname', 'title'));
echo CHtml::link(CHtml::encode('All'), array('index')) . '   ';
foreach ($list as $key => $value) {
    echo CHtml::link(CHtml::encode($value), array('index', 'field_varname' => $key)) . '   ';
}
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
?>
</div>
Пример #8
0
	<?php 
    echo CHtml::activePasswordField($form, 'verifyPassword');
    ?>
	</div>
	
	<div class="row">
	<?php 
    echo CHtml::activeLabelEx($form, 'email');
    ?>
	<?php 
    echo CHtml::activeTextField($form, 'email');
    ?>
	</div>
	
<?php 
    $profileFields = ProfileField::model()->forRegistration()->sort()->findAll();
    if ($profileFields) {
        foreach ($profileFields as $field) {
            ?>
	<div class="row">
		<?php 
            echo CHtml::activeLabelEx($profile, $field->varname);
            ?>
		<?php 
            if ($field->field_type == "TEXT") {
                echo CHtml::activeTextArea($profile, $field->varname, array('rows' => 6, 'cols' => 50));
            } else {
                echo CHtml::activeTextField($profile, $field->varname, array('size' => 60, 'maxlength' => $field->field_size ? $field->field_size : 255));
            }
            ?>
		<?php 
Пример #9
0
 public function getFields()
 {
     if ($this->regMode) {
         if (!$this->_modelReg) {
             $this->_modelReg = ProfileField::model()->forRegistration()->findAll();
         }
         return $this->_modelReg;
     } else {
         if (!$this->_model) {
             $this->_model = ProfileField::model()->forOwner()->findAll();
         }
         return $this->_model;
     }
 }
Пример #10
0
 /**
  * Validator which checks the fieldtype
  *
  * Also ensures that field_type_class could not be changed on existing records.
  */
 public function checkType()
 {
     if (!$this->isNewRecord) {
         // Dont allow changes of internal_name - Maybe not the best way to check it.
         $currentProfileField = ProfileField::model()->findByPk($this->id);
         if ($this->field_type_class != $currentProfileField->field_type_class) {
             $this->addError('field_type_class', Yii::t('UserModule.models_ProfileField', 'Field Type could not be changed!'));
         }
     } else {
         if (!key_exists($this->field_type_class, ProfileFieldType::getFieldTypes())) {
             $this->addError('field_type_class', Yii::t('UserModule.models_ProfileField', 'Invalid field type!'));
         }
     }
 }
Пример #11
0
 public static function getAllVarnames()
 {
     $criteria = new CDbCriteria();
     $criteria->compare('field_type', 'LIST');
     $list = CHtml::listData(ProjectField::model()->findAll($criteria), 'varname', function ($data) {
         return $data->varname . " ({$data->title})";
     });
     $list = array_merge($list, CHtml::listData(ProfileField::model()->findAll($criteria), 'varname', function ($data) {
         return $data->varname . " ({$data->title})";
     }));
     return $list;
 }
Пример #12
0
 /**
  * Returns all profile fields with user data by given category
  * 
  * @todo Optimize me
  * @param ProfileFieldCategory $category
  * @return Array ProfileFields
  */
 public function getProfileFields(ProfileFieldCategory $category)
 {
     $fields = array();
     foreach (ProfileField::model()->findAllByAttributes(array('profile_field_category_id' => $category->id, 'visible' => 1), array('order' => 'sort_order')) as $field) {
         if ($field->getUserValue($this->user) != "") {
             $fields[] = $field;
         }
     }
     return $fields;
 }
Пример #13
0
        <ul>
            <?php 
foreach (ProfileFieldCategory::model()->findAll(array('order' => 'sort_order')) as $category) {
    ?>
            <li>
                <a href="<?php 
    echo $this->createUrl('editCategory', array('id' => $category->id));
    ?>
">Category: <?php 
    echo $category->title;
    ?>
</a>
                <ul class="admin-userprofiles-fields">
                    <?php 
    foreach (ProfileField::model()->findAllByAttributes(array('profile_field_category_id' => $category->id), array('order' => 'sort_order')) as $field) {
        ?>
                        <li class="admin-userprofiles-field" data-id="<?php 
        echo $field->id;
        ?>
">
                            <a href="<?php 
        echo $this->createUrl('editField', array('id' => $field->id));
        ?>
">Field: <?php 
        echo $field->title;
        ?>
</a>
                        </li>
                    <?php 
    }
Пример #14
0
<?php

$this->breadcrumbs = array(UserModule::t('Users') => array('admin'), $model->username);
$this->menu = array(array('label' => UserModule::t('Create User'), 'url' => array('create')), array('label' => UserModule::t('Update User'), 'url' => array('update', 'id' => $model->id)), array('label' => UserModule::t('Delete User'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => UserModule::t('Are you sure to delete this item?'))), array('label' => UserModule::t('Manage Users'), 'url' => array('admin')), array('label' => UserModule::t('Manage Profile Field'), 'url' => array('profileField/admin')), array('label' => UserModule::t('List User'), 'url' => array('/user')));
?>
<h1><?php 
echo UserModule::t('View User') . ' "' . $model->username . '"';
?>
</h1>

<?php 
echo CHtml::link(UserModule::t('Edit assignments'), $this->createAbsoluteUrl('/rights/assignment/user', array('id' => $model->id))) . '<br /><br />';
$attributes = array('id', 'username', 'full_name', 'phone_number');
$mailing_list = 0;
if ($model->profile) {
    $profile = ProfileField::model()->findAll();
    if ($profile) {
        foreach ($profile as $field) {
            $arr = array('label' => UserModule::t($field->title), 'name' => $field->varname, 'type' => 'raw', '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)));
            if ($field->varname == 'mailing_list') {
                $index = $model->profile->getAttribute($field->varname);
                if ($index > 3) {
                    $index = 0;
                }
                $_temp = array('', 'icq', 'sms', 'email');
                $arr['value'] = $_temp[$index];
            }
            if ($field->field_type == "LIST") {
                $arr['value'] = Catalog::getNamesByIds($model->profile->getAttribute($field->varname), '<br>');
            }
            array_push($attributes, $arr);
Пример #15
0
 public static function getFields()
 {
     if (self::$regMode) {
         if (!self::$_modelReg) {
             self::$_modelReg = ProfileField::model()->forRegistration()->findAll();
         }
         return self::$_modelReg;
     } else {
         if (!self::$_model) {
             self::$_model = ProfileField::model()->forOwner()->findAll();
         }
         return self::$_model;
     }
 }
Пример #16
0
 /**
  * Returns all profile fields with user data by given category
  * 
  * @todo Optimize me
  * @param ProfileFieldCategory $category
  * @return Array ProfileFields
  */
 public function getProfileFields(ProfileFieldCategory $category = null)
 {
     $fields = array();
     $criteria = new CDbCriteria();
     if ($category !== null) {
         $criteria->condition = "profile_field_category_id=:catId AND ";
         $criteria->params = array(':catId' => $category->id);
     }
     $criteria->condition .= "visible = 1";
     $criteria->order = "sort_order";
     foreach (ProfileField::model()->findAll($criteria) as $field) {
         if ($field->getUserValue($this->user) != "") {
             $fields[] = $field;
         }
     }
     return $fields;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  */
 public function actionUpdate()
 {
     $model = $this->loadModel();
     $profile = $model->profile;
     $this->performAjaxValidation(array($model, $profile));
     $manager = !User::model()->isAuthor();
     $admin = User::model()->isAdmin();
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $_POST['Profile']['mailing_list'] = array_search($_POST['Profile']['mailing_list'], array('', 'icq', 'sms', 'email'));
         $profile->setAttributes($_POST['Profile'], false);
         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();
         }
     }
     $fields = ProfileField::model()->findAll();
     $this->render('update', array('model' => $model, 'profile' => $profile, 'manager' => $manager, 'admin' => $admin, 'fields' => $fields));
 }
Пример #18
0
            $specials2 = true;
        }
    }
    if ($specials2) {
        if (isset($data->zakaz->catalog_specials2)) {
            return $data->zakaz->catalog_specials2->cat_name;
        }
    } else {
        return false;
    }
}), array('name' => 'manager', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->manager, array('/user/admin/view', 'id' => $data->profileManager->id));
}), array('name' => 'user', 'type' => 'raw', 'value' => function ($data) {
    return CHtml::link($data->user, array('/user/admin/view', 'id' => $data->profileUser->id));
}), array('name' => 'profileUser.AuthAssignment.AuthItem.description'), array('name' => 'summ', 'footer' => $model->pageTotal($provider)), array('header' => Yii::t('site', 'Payment method'), 'type' => 'raw', 'value' => function ($data) {
    $payFields = ProfileField::model()->findAllByAttributes(array('paymentProps' => '1'));
    $payFieldsUser = $data->profileUser;
    foreach ($payFields as $field) {
        $fields[] = $field->varname;
        $final[$field->varname] = $field->title;
    }
    $fields = implode($fields, ',');
    $userPayFields = Profile::model()->find(array('select' => $fields, 'condition' => 'user_id = :user', 'params' => array(':user' => $data->profileUser->id)));
    $fields = array();
    if (!empty($userPayFields)) {
        foreach ($userPayFields as $key => $field) {
            if ($field != null) {
                $fields[$key] = $final[$key];
            }
        }
    }
Пример #19
0
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = ProfileField::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Пример #20
0
 public function getFields()
 {
     if ($this->regMode) {
         if (!$this->_modelReg) {
             $criteria = new CDbCriteria();
             $criteria->order = 'position';
             if ($this->regType == 'Author') {
                 $criteria->addInCondition('visible', array(2, 3));
                 $this->_modelReg = ProfileField::model()->findAll($criteria);
             } elseif ($this->regType == 'Customer') {
                 $criteria->addInCondition('visible', array(1, 3));
                 $this->_modelReg = ProfileField::model()->findAll($criteria);
             }
         }
         return $this->_modelReg;
     } else {
         if (!$this->_model) {
             $criteria = new CDbCriteria();
             $criteria->order = 'position';
             if (User::model()->isCustomer()) {
                 $criteria->addInCondition('visible', array(1, 3));
                 $this->_model = ProfileField::model()->findAll($criteria);
             } elseif (User::model()->isAuthor()) {
                 $criteria->addInCondition('visible', array(2, 3));
                 $this->_model = ProfileField::model()->findAll($criteria);
             } elseif (User::model()->isManager()) {
                 $this->_model = ProfileField::model()->findAll();
             } else {
                 $this->_model = ProfileField::model()->forAll()->findAll();
             }
         }
         return $this->_model;
     }
 }
Пример #21
0
<?php

$this->breadcrumbs = array(UserModule::t('Users') => array('/user/admin'), $model->username);
?>
<h1><?php 
echo UserModule::t('View User') . ' "' . $model->username . '"';
?>
</h1>

<?php 
echo $this->renderPartial('_menu', array('list' => array(CHtml::link(UserModule::t('Create User'), array('create')), CHtml::link(UserModule::t('Update User'), array('update', 'id' => $model->id)), CHtml::linkButton(UserModule::t('Delete User'), array('submit' => array('delete', 'id' => $model->id), 'confirm' => UserModule::t('Are you sure to delete this item?'))))));
$attributes = array('id', 'username');
$profileFields = ProfileField::model()->forOwner()->sort()->findAll();
if ($profileFields) {
    foreach ($profileFields as $field) {
        array_push($attributes, array('label' => UserModule::t($field->title), 'name' => $field->varname, 'type' => 'raw', '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, 'password', 'email', 'activkey', array('name' => 'createtime', 'value' => date("d.m.Y H:i:s", $model->createtime)), array('name' => 'lastvisit', 'value' => $model->lastvisit ? date("d.m.Y H:i:s", $model->lastvisit) : UserModule::t("Not visited")), array('name' => 'superuser', 'value' => User::itemAlias("AdminStatus", $model->superuser)), array('name' => 'status', 'value' => User::itemAlias("UserStatus", $model->status)));
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attributes));
Пример #22
0
 public function getAllFieldTypes()
 {
     return ProfileField::model()->getAllFieldTypes();
 }