/**
  * Deletes a Profile Field Category
  */
 public function actionDeleteCategory()
 {
     $id = (int) Yii::$app->request->get('id');
     $category = ProfileFieldCategory::findOne(['id' => $id]);
     if ($category == null) {
         throw new HttpException(500, Yii::t('AdminModule.controllers_UserprofileController', 'Could not load category.'));
     }
     if (count($category->fields) != 0) {
         throw new HttpException(500, Yii::t('AdminModule.controllers_UserprofileController', 'You can only delete empty categories!'));
     }
     $category->delete();
     return $this->redirect(Url::to(['/admin/user-profile']));
 }
Esempio n. 2
0
 /**
  * Returns The Form Definition to edit the ProfileField Model.
  *
  * @return Array CForm Definition
  */
 public function getFormDefinition()
 {
     $categories = ProfileFieldCategory::find()->orderBy('sort_order')->all();
     $profileFieldTypes = new fieldtype\BaseType();
     $definition = array('ProfileField' => array('type' => 'form', 'elements' => array('internal_name' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control'), 'title' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control'), 'description' => array('type' => 'textarea', 'class' => 'form-control'), 'sort_order' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control'), 'translation_category' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control', 'value' => $this->getTranslationCategory()), 'ldap_attribute' => array('type' => 'text', 'maxlength' => 255, 'class' => 'form-control'), 'required' => array('type' => 'checkbox'), 'visible' => array('type' => 'checkbox'), 'show_at_registration' => array('type' => 'checkbox'), 'editable' => array('type' => 'checkbox'), 'profile_field_category_id' => array('type' => 'dropdownlist', 'items' => \yii\helpers\ArrayHelper::map($categories, 'id', 'title'), 'class' => 'form-control'), 'field_type_class' => array('type' => 'dropdownlist', 'items' => $profileFieldTypes->getFieldTypes(), 'class' => 'form-control'))));
     // Field Type and Internal Name cannot be changed for existing records
     // So disable these fields.
     if (!$this->isNewRecord) {
         $definition['ProfileField']['elements']['field_type_class']['disabled'] = true;
         $definition['ProfileField']['elements']['internal_name']['readonly'] = true;
     }
     return $definition;
 }
Esempio n. 3
0
 /**
  * Returns all profile field categories with some user data
  *
  * @todo Optimize me
  * @return Array ProfileFieldCategory
  */
 public function getProfileFieldCategories()
 {
     $categories = array();
     foreach (ProfileFieldCategory::find()->orderBy('sort_order')->all() as $category) {
         if (count($this->getProfileFields($category)) != 0) {
             $categories[] = $category;
         }
     }
     return $categories;
 }
Esempio n. 4
0
 public static function bootstrap()
 {
     // Seems database is already initialized
     if (Setting::Get('paginationSize') == 10) {
         return;
     }
     //Yii::$app->search->rebuild();
     Setting::Set('baseUrl', \yii\helpers\BaseUrl::base(true));
     Setting::Set('paginationSize', 10);
     Setting::Set('displayNameFormat', '{profile.firstname} {profile.lastname}');
     // Authentication
     Setting::Set('authInternal', '1', 'authentication');
     Setting::Set('authLdap', '0', 'authentication');
     Setting::Set('refreshUsers', '1', 'authentication_ldap');
     Setting::Set('needApproval', '0', 'authentication_internal');
     Setting::Set('anonymousRegistration', '1', 'authentication_internal');
     Setting::Set('internalUsersCanInvite', '1', 'authentication_internal');
     // Mailing
     Setting::Set('transportType', 'php', 'mailing');
     Setting::Set('systemEmailAddress', '*****@*****.**', 'mailing');
     Setting::Set('systemEmailName', 'My Social Network', 'mailing');
     Setting::Set('receive_email_activities', User::RECEIVE_EMAIL_DAILY_SUMMARY, 'mailing');
     Setting::Set('receive_email_notifications', User::RECEIVE_EMAIL_WHEN_OFFLINE, 'mailing');
     // File
     Setting::Set('maxFileSize', '1048576', 'file');
     Setting::Set('maxPreviewImageWidth', '200', 'file');
     Setting::Set('maxPreviewImageHeight', '200', 'file');
     Setting::Set('hideImageFileInfo', '0', 'file');
     // Caching
     Setting::Set('type', 'CFileCache', 'cache');
     Setting::Set('expireTime', '3600', 'cache');
     Setting::Set('installationId', md5(uniqid("", true)), 'admin');
     // Design
     Setting::Set('theme', "HumHub");
     Setting::Set('spaceOrder', 0, 'space');
     // Basic
     Setting::Set('enable', 1, 'tour');
     Setting::Set('defaultLanguage', Yii::$app->language);
     // Notification
     Setting::Set('enable_html5_desktop_notifications', 0, 'notification');
     // Add Categories
     $cGeneral = new ProfileFieldCategory();
     $cGeneral->title = "General";
     $cGeneral->sort_order = 100;
     $cGeneral->visibility = 1;
     $cGeneral->is_system = 1;
     $cGeneral->description = '';
     if (!$cGeneral->save()) {
         throw new Exception(print_r($cGeneral->getErrors(), true));
     }
     $cCommunication = new ProfileFieldCategory();
     $cCommunication->title = "Communication";
     $cCommunication->sort_order = 200;
     $cCommunication->visibility = 1;
     $cCommunication->is_system = 1;
     $cCommunication->description = '';
     $cCommunication->save();
     $cSocial = new ProfileFieldCategory();
     $cSocial->title = "Social bookmarks";
     $cSocial->sort_order = 300;
     $cSocial->visibility = 1;
     $cSocial->is_system = 1;
     $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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->ldap_attribute = 'givenName';
     $field->is_system = 1;
     $field->required = 1;
     $field->show_at_registration = 1;
     if ($field->save()) {
         $field->fieldType->maxLength = 20;
         $field->fieldType->save();
     } else {
         throw new Exception(print_r($field->getErrors(), true));
     }
     $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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->ldap_attribute = 'sn';
     $field->show_at_registration = 1;
     $field->required = 1;
     $field->is_system = 1;
     if ($field->save()) {
         $field->fieldType->maxLength = 30;
         $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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     if ($field->save()) {
         $field->fieldType->maxLength = 50;
         $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 = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = 1;
     $field->field_type_class = \humhub\modules\user\models\fieldtype\Text::className();
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Birthday::className();
     $field->is_system = 1;
     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 = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     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 = \humhub\modules\user\models\fieldtype\Text::className();
     $field->is_system = 1;
     if ($field->save()) {
         $field->fieldType->validator = 'url';
         $field->fieldType->save();
     }
     $group = new Group();
     $group->name = "Users";
     $group->description = "Example Group by Installer";
     $group->save();
 }
Esempio n. 5
0
?>
</div>
    <div class="panel-body">

        <?php 
echo Html::a(Yii::t('AdminModule.views_userprofile_index', 'Add new category'), Url::to(['edit-category']), array('class' => 'btn btn-primary'));
?>

        <?php 
echo Html::a(Yii::t('AdminModule.views_userprofile_index', 'Add new field'), Url::to(['edit-field']), array('class' => 'btn btn-primary'));
?>

        <hr>
        <ul>
            <?php 
foreach (ProfileFieldCategory::find()->orderBy('sort_order')->all() as $category) {
    ?>
                <li>
                    <a href="<?php 
    echo Url::to(['edit-category', 'id' => $category->id]);
    ?>
">Category: <?php 
    echo Html::encode($category->title);
    ?>
</a>
                    <ul class="admin-userprofiles-fields">
                        <?php 
    foreach ($category->fields as $field) {
        ?>
                            <li class="admin-userprofiles-field" data-id="<?php 
        echo $field->id;