本文整理汇总了PHP中ProfileField::model方法的典型用法代码示例。如果您正苦于以下问题:PHP ProfileField::model方法的具体用法?PHP ProfileField::model怎么用?PHP ProfileField::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProfileField
的用法示例。
在下文中一共展示了ProfileField::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attributeLabels
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: actionProfile
/**
* 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: actionView
/**
* 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));
}
示例4: run
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: handleLdapUser
/**
* 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: actionEditField
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: array
<?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: foreach
<?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: getFields
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: checkType
/**
* 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: getAllVarnames
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: getProfileFields
/**
* 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: foreach
<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: array
<?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: getFields
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;
}
}