public function __construct()
 {
     gateKeeper();
     $message = NULL;
     $user = getLoggedInUser();
     $user->profile_complete = true;
     $profile_type = $user->profile_type;
     $fields = ProfileField::get($profile_type);
     foreach ($fields as $key => $field) {
         if ($field['required'] == "true" && !getInput($key)) {
             $message .= "{$field['label']} cannot be empty.";
         }
     }
     if ($message) {
         new SystemMessage($message);
         forward("editProfile");
     }
     foreach ($fields as $key => $field) {
         $user->{$key} = getInput($key);
     }
     $user->save();
     new Activity($user->guid, "activity:profile:updated", array($user->getURL(), $user->full_name));
     new SystemMessage("Your profile has been updated.");
     forward("profile/{$user->guid}");
 }
 /**
  * @return $this
  */
 public function findbyPk($condition)
 {
     $primaryKey = ProfileField::primaryKey();
     if (isset($primaryKey[0])) {
         $condition = [$primaryKey[0] => $condition];
     }
     return $this->andWhere($condition);
 }
Exemple #3
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;
 }
Exemple #4
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));
 }
Exemple #5
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();
     }
 }
 /**
  * Register Script
  */
 public function registerManegeScript()
 {
     $basePath = Yii::getPathOfAlias(Yii::app()->getModule('cart')->assetPath);
     $baseUrl = Yii::app()->getAssetManager()->publish($basePath);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerCssFile($baseUrl . '/css/redmond/jquery-ui.css');
     $cs->registerCssFile($baseUrl . '/css/style.css');
     $cs->registerScriptFile($baseUrl . '/js/jquery-ui.min.js');
     $cs->registerScriptFile($baseUrl . '/js/form.js');
     $cs->registerScriptFile($baseUrl . '/js/jquery.json.js');
     $widgets = self::getWidgets();
     $wgByTypes = ProfileField::itemAlias('field_type');
     foreach ($wgByTypes as $k => $v) {
         $wgByTypes[$k] = array();
     }
     foreach ($widgets[1] as $widget) {
         if (isset($widget['fieldType']) && count($widget['fieldType'])) {
             foreach ($widget['fieldType'] as $type) {
                 array_push($wgByTypes[$type], $widget['name']);
             }
         }
     }
     //echo '<pre>'; print_r($widgets[1]); die();
     $js = "\n\n\tvar name = \$('#name'),\n\tvalue = \$('#value'),\n\tallFields = \$([]).add(name).add(value),\n\ttips = \$('.validateTips');\n\t\n\tvar listWidgets = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($widgets[0])) . "');\n\tvar widgets = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($widgets[1])) . "');\n\tvar wgByType = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($wgByTypes)) . "');\n\t\n\tvar fieldType = {\n\t\t\t'INTEGER':{\n\t\t\t\t'hide':['match','other_validator','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':10,\n\t\t\t\t\t'default':'0',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'VARCHAR':{\n\t\t\t\t'hide':['widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':255,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'TEXT':{\n\t\t\t\t'hide':['field_size','range','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'DATE':{\n\t\t\t\t'hide':['field_size','field_size_min','match','range','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'0000-00-00',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'FLOAT':{\n\t\t\t\t'hide':['match','other_validator','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':'10,2',\n\t\t\t\t\t'default':'0.00',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'BOOL':{\n\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':0,\n\t\t\t\t\t'range':'1==" . CartModule::t('Yes') . ";0==" . CartModule::t('No') . "',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'BLOB':{\n\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t},\n\t\t\t'BINARY':{\n\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\n\t\t\t\t'val':{\n\t\t\t\t\t'field_size':0,\n\t\t\t\t\t'default':'',\n\t\t\t\t\t'range':'',\n\t\t\t\t\t'widgetparams':''\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\t\n\tfunction showWidgetList(type) {\n\t\t\$('div.widget select').empty();\n\t\t\$('div.widget select').append('<option value=\"\">" . CartModule::t('No') . "</option>');\n\t\tif (wgByType[type]) {\n\t\t\tfor (var k in wgByType[type]) {\n\t\t\t\t\$('div.widget select').append('<option value=\"'+wgByType[type][k]+'\">'+widgets[wgByType[type][k]]['label']+'</option>');\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\tfunction setFields(type) {\n\t\tif (fieldType[type]) {\n\t\t\tif (" . (isset($_GET['id']) ? 0 : 1) . ") {\n\t\t\t\tshowWidgetList(type);\n\t\t\t\t\$('#widgetlist option:first').attr('selected', 'selected');\n\t\t\t}\n\t\t\t\n\t\t\t\$('div.row').addClass('toshow').removeClass('tohide');\n\t\t\tif (fieldType[type].hide.length) \$('div.'+fieldType[type].hide.join(', div.')).addClass('tohide').removeClass('toshow');\n\t\t\tif (\$('div.widget select').val()) {\n\t\t\t\t\$('div.widgetparams').removeClass('tohide');\n\t\t\t}\n\t\t\t\$('div.toshow').show(500);\n\t\t\t\$('div.tohide').hide(500);\n\t\t\t" . (!isset($_GET['id']) ? "\n\t\t\tfor (var k in fieldType[type].val) { \n\t\t\t\t\$('div.'+k+' input').val(fieldType[type].val[k]);\n\t\t\t}" : '') . "\n\t\t}\n\t}\n\t\n\tfunction isArray(obj) {\n\t\tif (obj.constructor.toString().indexOf('Array') == -1)\n\t\t\treturn false;\n\t\telse\n\t\t\treturn true;\n\t}\n\t\t\n\t\$('#dialog-form').dialog({\n\t\tautoOpen: false,\n\t\theight: 400,\n\t\twidth: 400,\n\t\tmodal: true,\n\t\tbuttons: {\n\t\t\t'" . CartModule::t('Save') . "': function() {\n\t\t\t\tvar wparam = {};\n\t\t\t\tvar fparam = {};\n\t\t\t\t\$('#dialog-form fieldset .wparam').each(function(){\n\t\t\t\t\tif (\$(this).val()) wparam[\$(this).attr('name')] = \$(this).val();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tvar tab = \$('#tabs ul li.ui-tabs-selected').text();\n\t\t\t\tfparam[tab] = {};\n\t\t\t\t\$('#dialog-form fieldset .tab-'+tab).each(function(){\n\t\t\t\t\tif (\$(this).val()) fparam[tab][\$(this).attr('name')] = \$(this).val();\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tif (\$.JSON.encode(wparam)!='{}') \$('div.widgetparams input').val(\$.JSON.encode(wparam));\n\t\t\t\tif (\$.JSON.encode(fparam[tab])!='{}') \$('div.other_validator input').val(\$.JSON.encode(fparam)); \n\t\t\t\t\n\t\t\t\t\$(this).dialog('close');\n\t\t\t},\n\t\t\t'" . CartModule::t('Cancel') . "': function() {\n\t\t\t\t\$(this).dialog('close');\n\t\t\t}\n\t\t},\n\t\tclose: function() {\n\t\t}\n\t});\n\n\n\t\$('#widgetparams').focus(function() {\n\t\tvar widget = widgets[\$('#widgetlist').val()];\n\t\tvar html = '';\n\t\tvar wparam = (\$('div.widgetparams input').val())?\$.JSON.decode(\$('div.widgetparams input').val()):{};\n\t\tvar fparam = (\$('div.other_validator input').val())?\$.JSON.decode(\$('div.other_validator input').val()):{};\n\t\t\n\t\t// Class params\n\t\tfor (var k in widget.params) {\n\t\t\thtml += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';\n\t\t\thtml += '<input type=\"text\" name=\"'+k+'\" id=\"widget_'+k+'\" class=\"text wparam ui-widget-content ui-corner-all\" value=\"'+((wparam[k])?wparam[k]:widget.params[k])+'\" />';\n\t\t}\n\t\t// Validator params\t\t\n\t\tif (widget.other_validator) {\n\t\t\tvar tabs = '';\n\t\t\tvar li = '';\n\t\t\tfor (var t in widget.other_validator) {\n\t\t\t\ttabs += '<div id=\"tab-'+t+'\" class=\"tab\">';\n\t\t\t\tli += '<li'+((fparam[t])?' class=\"ui-tabs-selected\"':'')+'><a href=\"#tab-'+t+'\">'+t+'</a></li>';\n\t\t\t\t\n\t\t\t\tfor (var k in widget.other_validator[t]) {\n\t\t\t\t\ttabs += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';\n\t\t\t\t\tif (isArray(widget.other_validator[t][k])) {\n\t\t\t\t\t\ttabs += '<select type=\"text\" name=\"'+k+'\" id=\"filter_'+k+'\" class=\"text fparam ui-widget-content ui-corner-all tab-'+t+'\">';\n\t\t\t\t\t\tfor (var i in widget.other_validator[t][k]) {\n\t\t\t\t\t\t\ttabs += '<option value=\"'+widget.other_validator[t][k][i]+'\"'+((fparam[t]&&fparam[t][k])?' selected=\"selected\"':'')+'>'+widget.other_validator[t][k][i]+'</option>';\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttabs += '</select>';\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttabs += '<input type=\"text\" name=\"'+k+'\" id=\"filter_'+k+'\" class=\"text fparam ui-widget-content ui-corner-all tab-'+t+'\" value=\"'+((fparam[t]&&fparam[t][k])?fparam[t][k]:widget.other_validator[t][k])+'\" />';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttabs += '</div>';\n\t\t\t}\n\t\t\thtml += '<div id=\"tabs\"><ul>'+li+'</ul>'+tabs+'</div>';\n\t\t}\n\t\t\n\t\t\$('#dialog-form fieldset').html(html);\n\t\t\n\t\t\$('#tabs').tabs();\n\t\t\n\t\t// Show form\n\t\t\$('#dialog-form').dialog('open');\n\t});\n\t\n\t\$('#field_type').change(function() {\n\t\tsetFields(\$(this).val());\n\t});\n\t\n\t\$('#widgetlist').change(function() {\n\t\tif (\$(this).val()) {\n\t\t\t\$('div.widgetparams').show(500);\n\t\t} else {\n\t\t\t\$('div.widgetparams').hide(500);\n\t\t}\n\t\t\n\t});\n\t\n\t// show all function \n\t\$('div.form p.note').append('<br/><a href=\"#\" id=\"showAll\">" . CartModule::t('Show all') . "</a>');\n \t\$('#showAll').click(function(){\n\t\t\$('div.row').show(500);\n\t\treturn false;\n\t});\n\t\n\t// init\n\tsetFields(\$('#field_type').val());\n\t\n\t";
     $cs->registerScript(__CLASS__ . '#dialog', $js);
 }
Exemple #8
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;
     }
 }
 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;
 }
Exemple #10
0
?>
		<?php 
echo CHtml::error($model, 'position');
?>
		<p class="hint"><?php 
echo UserModule::t('Display order of fields.');
?>
</p>
	</div>

	<div class="row visible">
		<?php 
echo CHtml::activeLabelEx($model, 'visible');
?>
		<?php 
echo CHtml::activeDropDownList($model, 'visible', ProfileField::itemAlias('visible'));
?>
		<?php 
echo CHtml::error($model, 'visible');
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save'));
?>
	</div>

<?php 
echo CHtml::endForm();
?>
Exemple #11
0
<?php

$this->breadcrumbs = array(UserModule::t('Profile Fields') => array('admin'), UserModule::t('Manage'));
$this->menu = array(array('label' => UserModule::t('Create Profile Field'), 'url' => array('create')), array('label' => UserModule::t('Manage Profile Field'), 'url' => array('admin')), array('label' => UserModule::t('Manage Users'), 'url' => array('/user/admin')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n    \$('.search-form').toggle();\n    return false;\n});\n\$('.search-form form').submit(function(){\n    \$.fn.yiiGridView.update('profile-field-grid', {\n        data: \$(this).serialize()\n    });\n    return false;\n});\n");
?>
<h1><?php 
echo UserModule::t('Manage Profile Fields');
?>
</h1>

<p><?php 
echo UserModule::t("You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.");
?>
</p>

<?php 
echo CHtml::link(UserModule::t('Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('bootstrap.widgets.TbGridView', array('dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'varname', 'type' => 'raw', 'value' => 'UHtml::markSearch($data,"varname")'), array('name' => 'title', 'value' => 'UserModule::t($data->title)'), array('name' => 'field_type', 'value' => '$data->field_type', 'filter' => ProfileField::itemAlias("field_type")), 'field_size', array('name' => 'required', 'value' => 'ProfileField::itemAlias("required",$data->required)', 'filter' => ProfileField::itemAlias("required")), 'position', array('name' => 'visible', 'value' => 'ProfileField::itemAlias("visible",$data->visible)', 'filter' => ProfileField::itemAlias("visible")), array('class' => 'bootstrap.widgets.TbButtonColumn'))));
Exemple #12
0
<?php

$this->breadcrumbs = array(UserModule::t('Profile Fields') => array('admin'), UserModule::t('Manage'));
$this->menu = array(array('label' => UserModule::t('Create Profile Field'), 'url' => array('create')), array('label' => UserModule::t('Manage Profile Field'), 'url' => array('admin')), array('label' => UserModule::t('Manage Users'), 'url' => array('/user/admin')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n    \$('.search-form').toggle();\n    return false;\n});\n\$('.search-form form').submit(function(){\n    \$.fn.yiiGridView.update('profile-field-grid', {\n        data: \$(this).serialize()\n    });\n    return false;\n});\n");
?>
<h1><?php 
echo UserModule::t('Manage Profile Fields');
?>
</h1>

<p class="helper"><?php 
echo UserModule::t("You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.");
?>
</p>

<?php 
echo CHtml::link(UserModule::t('Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
//$this->widget('zii.widgets.grid.CGridView', array(
$this->widget('JGridView', array('dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('class' => 'id-column')), array('name' => 'varname', 'type' => 'raw', 'value' => 'UHtml::markSearch($data,"varname")'), array('name' => 'title', 'value' => 'UserModule::t($data->title)'), array('name' => 'field_type', 'value' => '$data->field_type', 'filter' => ProfileField::itemAlias("field_type")), 'field_size', array('name' => 'required', 'value' => 'ProfileField::itemAlias("required",$data->required)', 'filter' => ProfileField::itemAlias("required")), 'position', array('name' => 'visible', 'value' => 'ProfileField::itemAlias("visible",$data->visible)', 'filter' => ProfileField::itemAlias("visible")), array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'updateButtonImageUrl' => Yii::app()->theme->baseUrl . '/images/update16x16.png', 'deleteButtonImageUrl' => Yii::app()->theme->baseUrl . '/images/delete16x16.png'))));
Exemple #13
0
?>
        <?php 
echo $form->textFieldRow($model, 'error_message', array('size' => 60, 'maxlength' => 255));
?>
        <?php 
echo $form->textFieldRow($model, 'other_validator', array('size' => 60, 'maxlength' => 5000));
?>
        <?php 
echo $form->textFieldRow($model, 'default', array('size' => 60, 'maxlength' => 255));
?>
        <?php 
echo $form->textFieldRow($model, 'widget', array('size' => 60, 'maxlength' => 255));
?>
        <?php 
echo $form->textFieldRow($model, 'widgetparams', array('size' => 60, 'maxlength' => 5000));
?>
        <?php 
echo $form->textFieldRow($model, 'position');
?>
        <?php 
echo $form->dropDownListRow($model, 'visible', ProfileField::itemAlias('visible'));
?>

    <div class="form-actions">
        <?php 
$this->widget('bootstrap.widgets.TbButton', array('type' => 'primary', 'buttonType' => 'submit', 'label' => UserModule::t('Search')));
?>
    </div>

<?php 
$this->endWidget();
 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;
     }
 }
            $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];
            }
        }
    }
Exemple #16
0
echo $form->dropDownListRow($model, 'widget', $widgetsList, array('class' => 'widget', 'id' => 'widgetlist', 'hint' => UserModule::t('Widget name.')));
?>
    </div>
    <div class="formrow widgetparams">
        <?php 
echo $form->textFieldRow($model, 'widgetparams', array('class' => 'widgetparams', 'size' => 60, 'maxlength' => 5000, 'id' => 'widgetparams', 'hint' => UserModule::t('JSON string (example: {example}).', array('{example}' => CJavaScript::jsonEncode(array('param1' => array('val1', 'val2'), 'param2' => array('k1' => 'v1', 'k2' => 'v2')))))));
?>
	</div>
	<div class="formrow position">
	   <?php 
echo $form->textFieldRow($model, 'position', array('class' => 'position', 'hint' => UserModule::t('Display order of fields.')));
?>
	</div>
	<div class="formrow visible">
	   <?php 
echo $form->dropDownListRow($model, 'visible', ProfileField::itemAlias('visible'), array('class' => 'visible'));
?>
	</div>
	<div class="form-actions">
        <?php 
$this->widget('bootstrap.widgets.TbButton', array('type' => 'primary', 'buttonType' => 'submit', 'label' => $model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save')));
?>
    </div>
	
	<?php 
/*
	<div class="row varname">
		<?php echo CHtml::activeLabelEx($model,'varname'); ?>
		<?php echo (($model->id)?CHtml::activeTextField($model,'varname',array('size'=>60,'maxlength'=>50,'readonly'=>true)):CHtml::activeTextField($model,'varname',array('size'=>60,'maxlength'=>50))); ?>
		<?php echo CHtml::error($model,'varname'); ?>
		<p class="hint"><?php echo UserModule::t("Allowed lowercase letters and digits."); ?></p>
Exemple #17
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;
 }
Exemple #18
0
<p><?php 
echo UserModule::t("You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.");
?>
</p>

<?php 
echo CHtml::link(UserModule::t('Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
    <?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $model->search(), 'columns' => array(array('name' => 'id', 'value' => '$data->id', 'htmlOptions' => array('style' => 'display:none;'), 'headerHtmlOptions' => array('style' => 'display:none;')), array('header' => '# ', 'value' => '$data->position'), array('name' => 'title', 'value' => 'UserModule::t($data->title)'), array('name' => 'field_type', 'value' => '$data->field_type', 'filter' => ProfileField::itemAlias("field_type")), 'group', 'subgroup', array('name' => 'visible', 'value' => 'ProfileField::itemAlias("visible",$data->visible)', 'filter' => ProfileField::itemAlias("visible")), 'visible_for_role', array('class' => 'CButtonColumn'))));
?>

<?php 
Yii::app()->clientScript->registerCoreScript('jquery.ui');
?>
<script type="text/javascript">
    $(function() {
        $( "table.items tbody" ).sortable({ 
            items: 'tr',
            update : function () { 
                var order = [];
                $('table.items tbody tr').each(function(i,item) {
                    order.push($(item).find('td:eq(0)').text() * 1);
                    $(item).find('td:eq(1)').text(i + 1);
                });
Exemple #19
0
$field->title = 'MySpace URL';
$field->sort_order = 800;
$field->profile_field_category_id = $cSocial->id;
$field->field_type_class = 'ProfileFieldTypeText';
$field->is_system = true;
if ($field->save()) {
    $field->fieldType->validator = 'url';
    $field->fieldType->save();
}
$field = new ProfileField();
$field->internal_name = "url_googleplus";
$field->title = 'Google+ URL';
$field->sort_order = 900;
$field->profile_field_category_id = $cSocial->id;
$field->field_type_class = 'ProfileFieldTypeText';
$field->is_system = true;
if ($field->save()) {
    $field->fieldType->validator = 'url';
    $field->fieldType->save();
}
$field = new ProfileField();
$field->internal_name = "url_twitter";
$field->title = 'Twitter URL';
$field->sort_order = 1000;
$field->profile_field_category_id = $cSocial->id;
$field->field_type_class = 'ProfileFieldTypeText';
$field->is_system = true;
if ($field->save()) {
    $field->fieldType->validator = 'url';
    $field->fieldType->save();
}
<?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>
 /**
  * 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));
 }
 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));
 }
 /**
  * Setup some inital database settings.
  *
  * This will be done at the first step.
  */
 private function setupInitialData()
 {
     // Seems database is already initialized
     if (HSetting::Get('paginationSize') == 10) {
         return;
     }
     // Rebuild Search
     HSearch::getInstance()->rebuild();
     HSetting::Set('baseUrl', Yii::app()->getBaseUrl(true));
     HSetting::Set('paginationSize', 10);
     HSetting::Set('displayNameFormat', '{profile.firstname} {profile.lastname}');
     // Authentication
     HSetting::Set('authInternal', '1', 'authentication');
     HSetting::Set('authLdap', '0', 'authentication');
     HSetting::Set('needApproval', '0', 'authentication_internal');
     HSetting::Set('anonymousRegistration', '1', 'authentication_internal');
     HSetting::Set('internalUsersCanInvite', '1', 'authentication_internal');
     // Mailing
     HSetting::Set('transportType', 'php', 'mailing');
     HSetting::Set('systemEmailAddress', '*****@*****.**', 'mailing');
     HSetting::Set('systemEmailName', 'My Social Network', 'mailing');
     HSetting::Set('receive_email_activities', User::RECEIVE_EMAIL_DAILY_SUMMARY, 'mailing');
     HSetting::Set('receive_email_notifications', User::RECEIVE_EMAIL_WHEN_OFFLINE, 'mailing');
     // File
     HSetting::Set('maxFileSize', '1048576', 'file');
     HSetting::Set('forbiddenExtensions', 'exe', 'file');
     // Caching
     HSetting::Set('type', 'CFileCache', 'cache');
     HSetting::Set('expireTime', '3600', 'cache');
     HSetting::Set('installationId', md5(uniqid("", true)), 'admin');
     // Design
     HSetting::Set('theme', "HumHub");
     // Basic
     HSetting::Set('enable', 1, 'tour');
     // Add Categories
     $cGeneral = new ProfileFieldCategory();
     $cGeneral->title = "General";
     $cGeneral->sort_order = 100;
     $cGeneral->visibility = 1;
     $cGeneral->is_system = true;
     $cGeneral->description = '';
     $cGeneral->save();
     $cCommunication = new ProfileFieldCategory();
     $cCommunication->title = "Communication";
     $cCommunication->sort_order = 200;
     $cCommunication->visibility = 1;
     $cCommunication->is_system = true;
     $cCommunication->description = '';
     $cCommunication->save();
     $cSocial = new ProfileFieldCategory();
     $cSocial->title = "Social bookmarks";
     $cSocial->sort_order = 300;
     $cSocial->visibility = 1;
     $cSocial->is_system = true;
     $cSocial->description = '';
     $cSocial->save();
     // Add Fields
     $field = new ProfileField();
     $field->internal_name = "firstname";
     $field->title = 'Firstname';
     $field->sort_order = 100;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->ldap_attribute = 'givenName';
     $field->is_system = true;
     $field->required = true;
     $field->show_at_registration = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "lastname";
     $field->title = 'Lastname';
     $field->sort_order = 200;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->ldap_attribute = 'sn';
     $field->show_at_registration = true;
     $field->required = true;
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "title";
     $field->title = 'Title';
     $field->sort_order = 300;
     $field->ldap_attribute = 'title';
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "gender";
     $field->title = 'Gender';
     $field->sort_order = 300;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeSelect';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->options = "male=>Male\nfemale=>Female\ncustom=>Custom";
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "street";
     $field->title = 'Street';
     $field->sort_order = 400;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 150;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "zip";
     $field->title = 'Zip';
     $field->sort_order = 500;
     $field->profile_field_category_id = $cGeneral->id;
     $field->is_system = true;
     $field->field_type_class = 'ProfileFieldTypeText';
     if ($field->save()) {
         $field->fieldType->maxLength = 10;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "city";
     $field->title = 'City';
     $field->sort_order = 600;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "country";
     $field->title = 'Country';
     $field->sort_order = 700;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "state";
     $field->title = 'State';
     $field->sort_order = 800;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "birthday";
     $field->title = 'Birthday';
     $field->sort_order = 900;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeBirthday';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "about";
     $field->title = 'About';
     $field->sort_order = 900;
     $field->profile_field_category_id = $cGeneral->id;
     $field->field_type_class = 'ProfileFieldTypeTextArea';
     $field->is_system = true;
     if ($field->save()) {
         #$field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "phone_private";
     $field->title = 'Phone Private';
     $field->sort_order = 100;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "phone_work";
     $field->title = 'Phone Work';
     $field->sort_order = 200;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "mobile";
     $field->title = 'Mobile';
     $field->sort_order = 300;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "fax";
     $field->title = 'Fax';
     $field->sort_order = 400;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "im_skype";
     $field->title = 'Skype Nickname';
     $field->sort_order = 500;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "im_msn";
     $field->title = 'MSN';
     $field->sort_order = 600;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->maxLength = 100;
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "im_icq";
     $field->title = 'ICQ Number';
     $field->sort_order = 700;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeNumber';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "im_xmpp";
     $field->title = 'XMPP Jabber Address';
     $field->sort_order = 800;
     $field->profile_field_category_id = $cCommunication->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'email';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url";
     $field->title = 'Url';
     $field->sort_order = 100;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_facebook";
     $field->title = 'Facebook URL';
     $field->sort_order = 200;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_linkedin";
     $field->title = 'LinkedIn URL';
     $field->sort_order = 300;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_xing";
     $field->title = 'Xing URL';
     $field->sort_order = 400;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_youtube";
     $field->title = 'Youtube URL';
     $field->sort_order = 500;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_vimeo";
     $field->title = 'Vimeo URL';
     $field->sort_order = 600;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_flickr";
     $field->title = 'Flickr URL';
     $field->sort_order = 700;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_myspace";
     $field->title = 'MySpace URL';
     $field->sort_order = 800;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_googleplus";
     $field->title = 'Google+ URL';
     $field->sort_order = 900;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $field = new ProfileField();
     $field->internal_name = "url_twitter";
     $field->title = 'Twitter URL';
     $field->sort_order = 1000;
     $field->profile_field_category_id = $cSocial->id;
     $field->field_type_class = 'ProfileFieldTypeText';
     $field->is_system = true;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $group = new Group();
     $group->name = "Users";
     $group->description = "Example Group by Installer";
     $group->save();
 }
Exemple #24
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!'));
         }
     }
 }
 /**
  * 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;
 }
Exemple #26
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;
 }
Exemple #27
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;
     }
 }
Exemple #28
0
 /**
  * Gets all field types.
  * @return array
  */
 public function getAllFieldTypes()
 {
     /*
      * List of field types:
      *  - checkBox
      *  - checkBoxList
      *  - dropDownList
      *  - fileField
      *  - passwordField
      *  - radioButton
      *  - radioButtonList
      *  - textArea
      *  - textField
      */
     if (empty(self::$_types) || self::$_refreshTypes === true) {
         self::$_refreshTypes = false;
         $fieldMetadata = $this->getAllFieldsMetadata();
         self::$_types = array();
         foreach ($fieldMetadata as $fieldName => $metadata) {
             if ($metadata['not_validator']['field_type'] !== 'dropDownList' && $metadata['not_validator']['field_type'] !== 'checkBoxList' && $metadata['not_validator']['field_type'] !== 'radioButtonList' && $metadata['not_validator']['field_type'] !== 'listBox') {
                 self::$_types[$fieldName] = $metadata['not_validator']['field_type'];
             } else {
                 self::$_types[$fieldName] = array('type' => $metadata['not_validator']['field_type'], 'data' => json_decode($metadata['not_validator']['items'], true));
             }
         }
     }
     return self::$_types;
 }
Exemple #29
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));
Exemple #30
0
 /**
  * @param ProfileField|XoopsObject $obj
  */
 public function __construct(ProfileField $obj)
 {
     $xoops = Xoops::getInstance();
     $title = $obj->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD);
     parent::__construct($title, 'form', '', 'post', true);
     $this->addElement(new Xoops\Form\Text(_PROFILE_AM_TITLE, 'field_title', 5, 255, $obj->getVar('field_title', 'e')), true);
     $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $obj->getVar('field_description', 'e'), 5, 5));
     if (!$obj->isNew()) {
         $fieldcat_id = $obj->getVar('cat_id');
     } else {
         $fieldcat_id = 0;
     }
     $category_handler = $xoops->getModuleHandler('category');
     $cat_select = new Xoops\Form\Select(_PROFILE_AM_CATEGORY, 'field_category', $fieldcat_id);
     $cat_select->addOption(0, _PROFILE_AM_DEFAULT);
     $cat_select->addOptionArray($category_handler->getList());
     $this->addElement($cat_select);
     $weight = new Xoops\Form\Text(_PROFILE_AM_WEIGHT, 'field_weight', 1, 10, $obj->getVar('field_weight', 'e'), '');
     $weight->setPattern('^\\d+$', _PROFILE_AM_ERROR_WEIGHT);
     $this->addElement($weight, true);
     if ($obj->getVar('field_config') || $obj->isNew()) {
         if (!$obj->isNew()) {
             $this->addElement(new Xoops\Form\Label(_PROFILE_AM_NAME, $obj->getVar('field_name')));
             $this->addElement(new Xoops\Form\Hidden('id', $obj->getVar('field_id')));
         } else {
             $this->addElement(new Xoops\Form\Text(_PROFILE_AM_NAME, 'field_name', 5, 255, $obj->getVar('field_name', 'e')), true);
         }
         //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
         $fieldtypes = array('checkbox' => _PROFILE_AM_CHECKBOX, 'date' => _PROFILE_AM_DATE, 'datetime' => _PROFILE_AM_DATETIME, 'longdate' => _PROFILE_AM_LONGDATE, 'group' => _PROFILE_AM_GROUP, 'group_multi' => _PROFILE_AM_GROUPMULTI, 'language' => _PROFILE_AM_LANGUAGE, 'radio' => _PROFILE_AM_RADIO, 'select' => _PROFILE_AM_SELECT, 'select_multi' => _PROFILE_AM_SELECTMULTI, 'textarea' => _PROFILE_AM_TEXTAREA, 'dhtml' => _PROFILE_AM_DHTMLTEXTAREA, 'textbox' => _PROFILE_AM_TEXTBOX, 'timezone' => _PROFILE_AM_TIMEZONE, 'yesno' => _PROFILE_AM_YESNO);
         $element_select = new Xoops\Form\Select(_PROFILE_AM_TYPE, 'field_type', $obj->getVar('field_type', 'e'));
         $element_select->addOptionArray($fieldtypes);
         $this->addElement($element_select);
         switch ($obj->getVar('field_type')) {
             case "textbox":
                 $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                 $type_select = new Xoops\Form\Select(_PROFILE_AM_VALUETYPE, 'field_valuetype', $obj->getVar('field_valuetype', 'e'), 5, 5);
                 $type_select->addOptionArray($valuetypes);
                 $this->addElement($type_select);
                 break;
             case "select":
             case "radio":
                 $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                 $type_select = new Xoops\Form\Select(_PROFILE_AM_VALUETYPE, 'field_valuetype', $obj->getVar('field_valuetype', 'e'));
                 $type_select->addOptionArray($valuetypes);
                 $this->addElement($type_select);
                 break;
         }
         //$this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_NOTNULL, 'field_notnull', $obj->getVar('field_notnull', 'e') ));
         if ($obj->getVar('field_type') == "select" || $obj->getVar('field_type') == "select_multi" || $obj->getVar('field_type') == "radio" || $obj->getVar('field_type') == "checkbox") {
             $options = $obj->getVar('field_options');
             if (count($options) > 0) {
                 $remove_options = new Xoops\Form\Checkbox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions');
                 //$remove_options->columns = 3;
                 asort($options);
                 foreach (array_keys($options) as $key) {
                     $options[$key] .= "[{$key}]";
                 }
                 $remove_options->addOptionArray($options);
                 $this->addElement($remove_options);
             }
             $option_text = "<table  cellspacing='1'><tr><td class='width20'>" . _PROFILE_AM_KEY . "</td><td>" . _PROFILE_AM_VALUE . "</td></tr>";
             for ($i = 0; $i < 3; ++$i) {
                 $option_text .= "<tr><td><input type='text' name='addOption[{$i}][key]' id='addOption[{$i}][key]' size='15' /></td><td><input type='text' name='addOption[{$i}][value]' id='addOption[{$i}][value]' size='35' /></td></tr>";
                 $option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
             }
             $option_text .= "</table>";
             $this->addElement(new Xoops\Form\Label(_PROFILE_AM_ADDOPTION, $option_text));
         }
     }
     if ($obj->getVar('field_edit')) {
         switch ($obj->getVar('field_type')) {
             case "textbox":
             case "textarea":
             case "dhtml":
                 $this->addElement(new Xoops\Form\Text(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 5, 5, $obj->getVar('field_maxlength', 'e')));
                 $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "checkbox":
             case "select_multi":
                 $def_value = $obj->getVar('field_default', 'e') != null ? unserialize($obj->getVar('field_default', 'n')) : null;
                 $element = new Xoops\Form\Select(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true);
                 $options = $obj->getVar('field_options');
                 asort($options);
                 // If options do not include an empty element, then add a blank option to prevent any default selection
                 if (!in_array('', array_keys($options))) {
                     $element->addOption('', XoopsLocale::NONE);
                 }
                 $element->addOptionArray($options);
                 $this->addElement($element);
                 break;
             case "select":
             case "radio":
                 $def_value = $obj->getVar('field_default', 'e') != null ? $obj->getVar('field_default') : null;
                 $element = new Xoops\Form\Select(_PROFILE_AM_DEFAULT, 'field_default', $def_value);
                 $options = $obj->getVar('field_options');
                 asort($options);
                 // If options do not include an empty element, then add a blank option to prevent any default selection
                 if (!in_array('', array_keys($options))) {
                     $element->addOption('', XoopsLocale::NONE);
                 }
                 $element->addOptionArray($options);
                 $this->addElement($element);
                 break;
             case "date":
                 $this->addElement(new Xoops\Form\DateSelect(_PROFILE_AM_DEFAULT, 'field_default', 2, $obj->getVar('field_default', 'e')));
                 break;
             case "longdate":
                 $this->addElement(new Xoops\Form\DateSelect(_PROFILE_AM_DEFAULT, 'field_default', 2, strtotime($obj->getVar('field_default', 'e'))));
                 break;
             case "datetime":
                 $this->addElement(new Xoops\Form\DateTime(_PROFILE_AM_DEFAULT, 'field_default', 2, $obj->getVar('field_default', 'e')));
                 break;
             case "yesno":
                 $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "timezone":
                 $this->addElement(new Xoops\Form\SelectTimeZone(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "language":
                 $this->addElement(new Xoops\Form\SelectLanguage(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "group":
                 $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $obj->getVar('field_default', 'e')));
                 break;
             case "group_multi":
                 $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, unserialize($obj->getVar('field_default', 'n')), 5, true));
                 break;
             case "theme":
                 $this->addElement(new Xoops\Form\SelectTheme(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
             case "autotext":
                 $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e')));
                 break;
         }
     }
     $groupperm_handler = $xoops->getHandlerGroupperm();
     $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language');
     if (in_array($obj->getVar('field_type'), $searchable_types)) {
         $search_groups = $groupperm_handler->getGroupIds('profile_search', $obj->getVar('field_id'), $xoops->module->getVar('mid'));
         $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_PROF_SEARCH, 'profile_search', true, $search_groups, 5, true));
     }
     if ($obj->getVar('field_edit') || $obj->isNew()) {
         if (!$obj->isNew()) {
             //Load groups
             $editable_groups = $groupperm_handler->getGroupIds('profile_edit', $obj->getVar('field_id'), $xoops->module->getVar('mid'));
         } else {
             $editable_groups = array();
         }
         $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_PROF_EDITABLE, 'profile_edit', false, $editable_groups, 5, true));
         $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_REQUIRED, 'field_required', $obj->getVar('field_required', 'e')));
         $regstep_select = new Xoops\Form\Select(_PROFILE_AM_PROF_REGISTER, 'step_id', $obj->getVar('step_id', 'e'));
         $regstep_select->addOption(0, XoopsLocale::NO);
         $regstep_handler = $xoops->getModuleHandler('regstep');
         $regstep_select->addOptionArray($regstep_handler->getList());
         $this->addElement($regstep_select);
     }
     $this->addElement(new Xoops\Form\Hidden('op', 'save'));
     $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
 }