本文整理汇总了PHP中ProfileField::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ProfileField::save方法的具体用法?PHP ProfileField::save怎么用?PHP ProfileField::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProfileField
的用法示例。
在下文中一共展示了ProfileField::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate()
{
$model = new ProfileField();
if (isset($_POST['ProfileField'])) {
$model->attributes = $_POST['ProfileField'];
if ($model->validate()) {
$sql = 'ALTER TABLE ' . Profile::tableName() . ' ADD `' . $model->varname . '` ';
$sql .= $model->field_type;
if ($model->field_type != 'TEXT' && $model->field_type != 'DATE') {
$sql .= '(' . $model->field_size . ')';
}
$sql .= ' NOT NULL ';
if ($model->default) {
$sql .= " DEFAULT '" . $model->default . "'";
} else {
$sql .= $model->field_type == 'TEXT' || $model->field_type == 'VARCHAR' ? " DEFAULT ''" : " DEFAULT 0";
}
$model->dbConnection->createCommand($sql)->execute();
$model->save();
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例2: ProfileField
$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();
}
示例3: setupInitialData
/**
* 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', 'social@example.com', '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;
//.........这里部分代码省略.........
示例4: actionCreate
}
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 = "\r\r\tvar name = \$('#name'),\r\tvalue = \$('#value'),\r\tallFields = \$([]).add(name).add(value),\r\ttips = \$('.validateTips');\r\t\r\tvar listWidgets = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($widgets[0])) . "');\r\tvar widgets = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($widgets[1])) . "');\r\tvar wgByType = jQuery.parseJSON('" . str_replace("'", "\\'", CJavaScript::jsonEncode($wgByTypes)) . "');\r\t\r\tvar fieldType = {\r\t\t\t'INTEGER':{\r\t\t\t\t'hide':['match','other_validator','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':10,\r\t\t\t\t\t'default':'0',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'VARCHAR':{\r\t\t\t\t'hide':['widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':255,\r\t\t\t\t\t'default':'',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'TEXT':{\r\t\t\t\t'hide':['field_size','range','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':0,\r\t\t\t\t\t'default':'',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'DATE':{\r\t\t\t\t'hide':['field_size','field_size_min','match','range','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':0,\r\t\t\t\t\t'default':'0000-00-00',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'FLOAT':{\r\t\t\t\t'hide':['match','other_validator','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':'10,2',\r\t\t\t\t\t'default':'0.00',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'BOOL':{\r\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':0,\r\t\t\t\t\t'default':0,\r\t\t\t\t\t'range':'1==" . UserModule::t('Yes') . ";0==" . UserModule::t('No') . "',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'BLOB':{\r\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':0,\r\t\t\t\t\t'default':'',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t},\r\t\t\t'BINARY':{\r\t\t\t\t'hide':['field_size','field_size_min','match','widgetparams'],\r\t\t\t\t'val':{\r\t\t\t\t\t'field_size':0,\r\t\t\t\t\t'default':'',\r\t\t\t\t\t'range':'',\r\t\t\t\t\t'widgetparams':''\r\t\t\t\t}\r\t\t\t}\r\t\t};\r\t\t\t\r\tfunction showWidgetList(type) {\r\t\t\$('div.widget select').empty();\r\t\t\$('div.widget select').append('<option value=\"\">" . UserModule::t('No') . "</option>');\r\t\tif (wgByType[type]) {\r\t\t\tfor (var k in wgByType[type]) {\r\t\t\t\t\$('div.widget select').append('<option value=\"'+wgByType[type][k]+'\">'+widgets[wgByType[type][k]]['label']+'</option>');\r\t\t\t}\r\t\t}\r\t}\r\t\t\r\tfunction setFields(type) {\r\t\tif (fieldType[type]) {\r\t\t\tif (" . (isset($_GET['id']) ? 0 : 1) . ") {\r\t\t\t\tshowWidgetList(type);\r\t\t\t\t\$('#widgetlist option:first').attr('selected', 'selected');\r\t\t\t}\r\t\t\t\r\t\t\t\$('div.row').addClass('toshow').removeClass('tohide');\r\t\t\tif (fieldType[type].hide.length) \$('div.'+fieldType[type].hide.join(', div.')).addClass('tohide').removeClass('toshow');\r\t\t\tif (\$('div.widget select').val()) {\r\t\t\t\t\$('div.widgetparams').removeClass('tohide');\r\t\t\t}\r\t\t\t\$('div.toshow').show(500);\r\t\t\t\$('div.tohide').hide(500);\r\t\t\t" . (!isset($_GET['id']) ? "\r\t\t\tfor (var k in fieldType[type].val) { \r\t\t\t\t\$('div.'+k+' input').val(fieldType[type].val[k]);\r\t\t\t}" : '') . "\r\t\t}\r\t}\r\t\r\tfunction isArray(obj) {\r\t\tif (obj.constructor.toString().indexOf('Array') == -1)\r\t\t\treturn false;\r\t\telse\r\t\t\treturn true;\r\t}\r\t\t\r\t\$('#dialog-form').dialog({\r\t\tautoOpen: false,\r\t\theight: 400,\r\t\twidth: 400,\r\t\tmodal: true,\r\t\tbuttons: {\r\t\t\t'" . UserModule::t('Save') . "': function() {\r\t\t\t\tvar wparam = {};\r\t\t\t\tvar fparam = {};\r\t\t\t\t\$('#dialog-form fieldset .wparam').each(function(){\r\t\t\t\t\tif (\$(this).val()) wparam[\$(this).attr('name')] = \$(this).val();\r\t\t\t\t});\r\t\t\t\t\r\t\t\t\tvar tab = \$('#tabs ul li.ui-tabs-selected').text();\r\t\t\t\tfparam[tab] = {};\r\t\t\t\t\$('#dialog-form fieldset .tab-'+tab).each(function(){\r\t\t\t\t\tif (\$(this).val()) fparam[tab][\$(this).attr('name')] = \$(this).val();\r\t\t\t\t});\r\t\t\t\t\r\t\t\t\tif (\$.JSON.encode(wparam)!='{}') \$('div.widgetparams input').val(\$.JSON.encode(wparam));\r\t\t\t\tif (\$.JSON.encode(fparam[tab])!='{}') \$('div.other_validator input').val(\$.JSON.encode(fparam)); \r\t\t\t\t\r\t\t\t\t\$(this).dialog('close');\r\t\t\t},\r\t\t\t'" . UserModule::t('Cancel') . "': function() {\r\t\t\t\t\$(this).dialog('close');\r\t\t\t}\r\t\t},\r\t\tclose: function() {\r\t\t}\r\t});\r\r\r\t\$('#widgetparams').focus(function() {\r\t\tvar widget = widgets[\$('#widgetlist').val()];\r\t\tvar html = '';\r\t\tvar wparam = (\$('div.widgetparams input').val())?\$.JSON.decode(\$('div.widgetparams input').val()):{};\r\t\tvar fparam = (\$('div.other_validator input').val())?\$.JSON.decode(\$('div.other_validator input').val()):{};\r\t\t\r\t\t// Class params\r\t\tfor (var k in widget.params) {\r\t\t\thtml += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';\r\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])+'\" />';\r\t\t}\r\t\t// Validator params\t\t\r\t\tif (widget.other_validator) {\r\t\t\tvar tabs = '';\r\t\t\tvar li = '';\r\t\t\tfor (var t in widget.other_validator) {\r\t\t\t\ttabs += '<div id=\"tab-'+t+'\" class=\"tab\">';\r\t\t\t\tli += '<li'+((fparam[t])?' class=\"ui-tabs-selected\"':'')+'><a href=\"#tab-'+t+'\">'+t+'</a></li>';\r\t\t\t\t\r\t\t\t\tfor (var k in widget.other_validator[t]) {\r\t\t\t\t\ttabs += '<label for=\"name\">'+((widget.paramsLabels[k])?widget.paramsLabels[k]:k)+'</label>';\r\t\t\t\t\tif (isArray(widget.other_validator[t][k])) {\r\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+'\">';\r\t\t\t\t\t\tfor (var i in widget.other_validator[t][k]) {\r\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>';\r\t\t\t\t\t\t}\r\t\t\t\t\t\ttabs += '</select>';\r\t\t\t\t\t} else {\r\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])+'\" />';\r\t\t\t\t\t}\r\t\t\t\t}\r\t\t\t\ttabs += '</div>';\r\t\t\t}\r\t\t\thtml += '<div id=\"tabs\"><ul>'+li+'</ul>'+tabs+'</div>';\r\t\t}\r\t\t\r\t\t\$('#dialog-form fieldset').html(html);\r\t\t\r\t\t\$('#tabs').tabs();\r\t\t\r\t\t// Show form\r\t\t\$('#dialog-form').dialog('open');\r\t});\r\t\r\t\$('#field_type').change(function() {\r\t\tsetFields(\$(this).val());\r\t});\r\t\r\t\$('#widgetlist').change(function() {\r\t\tif (\$(this).val()) {\r\t\t\t\$('div.widgetparams').show(500);\r\t\t} else {\r\t\t\t\$('div.widgetparams').hide(500);\r\t\t}\r\t\t\r\t});\r\t\r\t// show all function \r\t\$('div.form p.note').append('<br/><a href=\"#\" id=\"showAll\">" . UserModule::t('Show all') . "</a>');\r \t\$('#showAll').click(function(){\r\t\t\$('div.row').show(500);\r\t\treturn false;\r\t});\r\t\r\t// init\r\tsetFields(\$('#field_type').val());\r\t\r\t";
$cs->registerScript(__CLASS__ . '#dialog', $js);
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$this->layout = '//layouts/column2';
$model = new ProfileField();
$scheme = get_class(Yii::app()->db->schema);
if (isset($_POST['ProfileField'])) {
$model->attributes = $_POST['ProfileField'];
if ($model->validate()) {
$sql = 'ALTER TABLE ' . Profile::model()->tableName() . ' ADD `' . $model->varname . '` ';
$sql .= $this->fieldType($model->field_type);
if ($model->field_type != 'TEXT' && $model->field_type != 'DATE' && $model->field_type != 'BOOL' && $model->field_type != 'BLOB' && $model->field_type != 'BINARY') {
$sql .= '(' . $model->field_size . ')';
}
$sql .= ' NOT NULL ';