Пример #1
0
 /**
  * Deletes a Profile Field Category
  */
 public function actionDeleteCategory()
 {
     $this->forcePostRequest();
     $id = (int) Yii::app()->request->getQuery('id');
     $category = ProfileFieldCategory::model()->findByPk($id);
     if ($category == null) {
         throw new CHttpException(500, Yii::t('AdminModule.controllers_UserprofileController', 'Could not load category.'));
     }
     if (count($category->fields) != 0) {
         throw new CHttpException(500, Yii::t('AdminModule.controllers_UserprofileController', 'You can only delete empty categories!'));
     }
     $category->delete();
     $this->redirect(Yii::app()->createUrl('//admin/userprofile'));
 }
Пример #2
0
// 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;
Пример #3
0
 /**
  * Returns all profile field categories with some user data
  * 
  * @todo Optimize me
  * @return Array ProfileFieldCategory
  */
 public function getProfileFieldCategories()
 {
     $categories = array();
     foreach (ProfileFieldCategory::model()->findAll(array('order' => 'sort_order')) as $category) {
         if (count($this->getProfileFields($category)) != 0) {
             $categories[] = $category;
         }
     }
     return $categories;
 }
Пример #4
0
 /**
  * Returns The Form Definition to edit the ProfileField Model.
  *
  * @return Array CForm Definition
  */
 public function getFormDefinition()
 {
     $categories = ProfileFieldCategory::model()->findAll(array('order' => 'sort_order'));
     $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' => CHtml::listData($categories, 'id', 'title'), 'class' => 'form-control'), 'field_type_class' => array('type' => 'dropdownlist', 'items' => ProfileFieldType::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;
 }
Пример #5
0
 /**
  * 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();
 }
Пример #6
0
</div>
    <div class="panel-body">

        <?php 
echo HHtml::link('Add new category', $this->createUrl('//admin/userprofile/editCategory'), array('class' => 'btn btn-primary'));
?>

        <?php 
echo HHtml::link('Add new field', $this->createUrl('//admin/userprofile/editField'), array('class' => 'btn btn-primary'));
?>

        <hr>

        <ul>
            <?php 
foreach (ProfileFieldCategory::model()->findAll(array('order' => 'sort_order')) as $category) {
    ?>
            <li>
                <a href="<?php 
    echo $this->createUrl('editCategory', array('id' => $category->id));
    ?>
">Category: <?php 
    echo $category->title;
    ?>
</a>
                <ul class="admin-userprofiles-fields">
                    <?php 
    foreach (ProfileField::model()->findAllByAttributes(array('profile_field_category_id' => $category->id), array('order' => 'sort_order')) as $field) {
        ?>
                        <li class="admin-userprofiles-field" data-id="<?php 
        echo $field->id;