Skip to content

Commit

Permalink
#3660 - Add "Last Name" fileld for Persons
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlesnikov committed Jan 21, 2022
1 parent b54b9ca commit 1d0f57a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 45 deletions.
39 changes: 22 additions & 17 deletions modules/base/profile/classes/BxBaseModProfileModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public function serviceProfileName ($iContentId)
if (!$aContentInfo)
return false;

$sDisplayName = bx_process_output($aContentInfo[$this->_oConfig->CNF['FIELD_NAME']]);
$sDisplayName = $this->getProfileName($aContentInfo);
bx_alert($this->getName(), 'profile_name', $aContentInfo['profile_id'], 0, array('info' => $aContentInfo, 'display_name' => &$sDisplayName));

return $sDisplayName;
Expand Down Expand Up @@ -1443,6 +1443,22 @@ public function serviceSetViewProfileCover($oPage, $aProfileInfo)
{
$this->_oTemplate->setCover($oPage,$aProfileInfo);
}

/**
* Returns list of members by mode with limited number of records for React Jot
* @param string $sMode
* @param int $iStart
* @param int $iPerPage
* @return mixed
*/
public function serviceGetMembers($sMode = 'active', $iStart = 0, $iPerPage = 10){
bx_import('SearchResult', $this->_aModule);
$sClass = $this->_aModule['class_prefix'] . 'SearchResult';
$o = new $sClass($sMode);

$o -> aCurrent['paginate'] = array('perPage' => $iPerPage, 'forceStart' => $iStart);
return $o -> getSearchData();
}

/**
* @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
Expand Down Expand Up @@ -1807,6 +1823,11 @@ public function getEntryImageData($aContentInfo, $sField = 'FIELD_PICTURE', $aTr
{
return parent::getEntryImageData($aContentInfo, $sField, $aTranscoders);
}

public function getProfileName ($aContentInfo)
{
return bx_process_output($aContentInfo[$this->_oConfig->CNF['FIELD_NAME']]);
}


// ====== PROTECTED METHODS
Expand Down Expand Up @@ -1968,22 +1989,6 @@ protected function _getContent($iContentId = 0, $sFuncGetContent = 'getContentIn

return parent::_getContent($iContentId, $sFuncGetContent);
}

/**
* Returns list of members by mode with limited number of records for React Jot
* @param string $sMode
* @param int $iStart
* @param int $iPerPage
* @return mixed
*/
public function serviceGetMembers($sMode = 'active', $iStart = 0, $iPerPage = 10){
bx_import('SearchResult', $this->_aModule);
$sClass = $this->_aModule['class_prefix'] . 'SearchResult';
$o = new $sClass($sMode);

$o -> aCurrent['paginate'] = array('perPage' => $iPerPage, 'forceStart' => $iStart);
return $o -> getSearchData();
}
}

/** @} */
2 changes: 1 addition & 1 deletion modules/base/profile/classes/BxBaseModProfileTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function unitVars ($aData, $isCheckPrivateContent = true, $mixedTemplate = false
$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);

// get profile's title
$sTitle = bx_process_output($aData[$CNF['FIELD_NAME']]);
$sTitle = $oModule->getProfileName($aData);

$sText = $sSummary = '';
if(!empty($CNF['FIELD_TEXT']) && !empty($aData[$CNF['FIELD_TEXT']])) {
Expand Down
3 changes: 2 additions & 1 deletion modules/boonex/persons/classes/BxPersonsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function __construct($aModule)
'FIELD_ADDED' => 'added',
'FIELD_CHANGED' => 'changed',
'FIELD_NAME' => 'fullname',
'FIELD_LAST_NAME' => 'last_name',
'FIELD_TITLE' => 'fullname',
'FIELD_TEXT' => 'description',
'FIELD_PICTURE' => 'picture',
Expand All @@ -52,7 +53,7 @@ function __construct($aModule)
'FIELD_VIEWS' => 'views',
'FIELD_VOTES' => 'votes',
'FIELD_COMMENTS' => 'comments',
'FIELDS_QUICK_SEARCH' => array('fullname'),
'FIELDS_QUICK_SEARCH' => array('fullname', 'last_name'),
'FIELD_LOCATION' => 'location',
'FIELD_LOCATION_PREFIX' => 'location',
'FIELD_LABELS' => 'labels',
Expand Down
4 changes: 4 additions & 0 deletions modules/boonex/persons/classes/BxPersonsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public function serviceGetSearchOptions ($sField, $sFieldType, $sSearchType)
return false;
}

public function getProfileName ($aContentInfo)
{
return bx_process_output($aContentInfo[$this->_oConfig->CNF['FIELD_NAME']] . ($aContentInfo[$this->_oConfig->CNF['FIELD_LAST_NAME']] != '' ? ' ' . $aContentInfo[$this->_oConfig->CNF['FIELD_LAST_NAME']] : ''));
}

}

Expand Down
6 changes: 4 additions & 2 deletions modules/boonex/persons/install/langs/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
<string name="_bx_persons_form_profile_input_allow_post_to"><![CDATA[Who can post to my profile]]></string>
<string name="_bx_persons_form_profile_input_sys_allow_contact_to"><![CDATA[Who can contact me]]></string>
<string name="_bx_persons_form_profile_input_allow_contact_to"><![CDATA[Who can contact me]]></string>
<string name="_bx_persons_form_profile_input_sys_fullname"><![CDATA[Full Name]]></string>
<string name="_bx_persons_form_profile_input_fullname"><![CDATA[Full Name]]></string>
<string name="_bx_persons_form_profile_input_sys_fullname"><![CDATA[Name]]></string>
<string name="_bx_persons_form_profile_input_fullname"><![CDATA[Name]]></string>
<string name="_bx_persons_form_profile_input_sys_last_name"><![CDATA[Last Name]]></string>
<string name="_bx_persons_form_profile_input_last_name"><![CDATA[Last Name]]></string>
<string name="_bx_persons_form_profile_input_fullname_err"><![CDATA[Profile name is mandatory and and cannot start with @]]></string>
<string name="_bx_persons_form_profile_input_sys_desc"><![CDATA[Description]]></string>
<string name="_bx_persons_form_profile_input_desc"><![CDATA[Description]]></string>
Expand Down
50 changes: 28 additions & 22 deletions modules/boonex/persons/install/sql/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS `bx_persons_data` (
`picture` int(11) NOT NULL,
`cover` int(11) NOT NULL,
`fullname` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`description` text NOT NULL,
`gender` varchar(255) DEFAULT NULL,
`birthday` date DEFAULT NULL,
Expand Down Expand Up @@ -266,6 +267,7 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
('bx_person', 'bx_persons', 'do_submit', '_bx_persons_form_profile_input_submit', '', 0, 'submit', '_bx_persons_form_profile_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
('bx_person', 'bx_persons', 'description', '', '', 0, 'textarea', '_bx_persons_form_profile_input_sys_desc', '_bx_persons_form_profile_input_desc', '', 0, 0, 1, '', '', '', '', '', '', 'XssHtml', '', 1, 1, ''),
('bx_person', 'bx_persons', 'fullname', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_fullname', '_bx_persons_form_profile_input_fullname', '', 1, 0, 0, '', '', '', 'ProfileName', '', '_bx_persons_form_profile_input_fullname_err', 'Xss', '', 1, 0, ''),
('bx_person', 'bx_persons', 'last_name', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_last_name', '_bx_persons_form_profile_input_last_name', '', 1, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0, ''),
('bx_person', 'bx_persons', 'cover', 'a:1:{i:0;s:21:"bx_persons_cover_crop";}', 'a:1:{s:21:"bx_persons_cover_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_cover', '_bx_persons_form_profile_input_cover', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
('bx_person', 'bx_persons', 'picture', 'a:1:{i:0;s:23:"bx_persons_picture_crop";}', 'a:1:{s:23:"bx_persons_picture_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_picture', '_bx_persons_form_profile_input_picture', '', 0, 0, 0, '', '', '', '', '', '_bx_persons_form_profile_input_picture_err', '', '', 1, 0, ''),
('bx_person', 'bx_persons', 'location', '', '', 0, 'location', '_sys_form_input_sys_location', '_sys_form_input_location', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
Expand All @@ -287,12 +289,13 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
('bx_person_add', 'gender', 2147483647, 1, 2),
('bx_person_add', 'birthday', 2147483647, 1, 3),
('bx_person_add', 'fullname', 2147483647, 1, 4),
('bx_person_add', 'description', 2147483647, 1, 5),
('bx_person_add', 'location', 2147483647, 1, 6),
('bx_person_add', 'allow_view_to', 2147483647, 1, 7),
('bx_person_add', 'allow_post_to', 2147483647, 1, 8),
('bx_person_add', 'allow_contact_to', 2147483647, 1, 9),
('bx_person_add', 'do_submit', 2147483647, 1, 10),
('bx_person_add', 'last_name', 2147483647, 0, 5),
('bx_person_add', 'description', 2147483647, 1, 6),
('bx_person_add', 'location', 2147483647, 1, 7),
('bx_person_add', 'allow_view_to', 2147483647, 1, 8),
('bx_person_add', 'allow_post_to', 2147483647, 1, 9),
('bx_person_add', 'allow_contact_to', 2147483647, 1, 10),
('bx_person_add', 'do_submit', 2147483647, 1, 11),

('bx_person_delete', 'cover', 2147483647, 0, 0),
('bx_person_delete', 'picture', 2147483647, 0, 0),
Expand All @@ -304,12 +307,13 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
('bx_person_edit', 'gender', 2147483647, 1, 2),
('bx_person_edit', 'birthday', 2147483647, 1, 3),
('bx_person_edit', 'fullname', 2147483647, 1, 4),
('bx_person_edit', 'description', 2147483647, 1, 5),
('bx_person_edit', 'location', 2147483647, 1, 6),
('bx_person_edit', 'allow_view_to', 2147483647, 1, 7),
('bx_person_edit', 'allow_post_to', 2147483647, 1, 8),
('bx_person_edit', 'allow_contact_to', 2147483647, 1, 9),
('bx_person_edit', 'do_submit', 2147483647, 1, 10),
('bx_person_edit', 'last_name', 2147483647, 0, 5),
('bx_person_edit', 'description', 2147483647, 1, 6),
('bx_person_edit', 'location', 2147483647, 1, 7),
('bx_person_edit', 'allow_view_to', 2147483647, 1, 8),
('bx_person_edit', 'allow_post_to', 2147483647, 1, 9),
('bx_person_edit', 'allow_contact_to', 2147483647, 1, 10),
('bx_person_edit', 'do_submit', 2147483647, 1, 11),

('bx_person_edit_cover', 'delete_confirm', 2147483647, 0, 1),
('bx_person_edit_cover', 'fullname', 2147483647, 0, 2),
Expand All @@ -320,20 +324,22 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
('bx_person_view', 'gender', 2147483647, 1, 1),
('bx_person_view', 'birthday', 2147483647, 1, 2),
('bx_person_view', 'fullname', 2147483647, 1, 3),
('bx_person_view', 'profile_email', 192, 1, 4),
('bx_person_view', 'profile_status', 192, 1, 5),
('bx_person_view', 'profile_ip', 192, 1, 6),
('bx_person_view', 'added', 192, 1, 7),
('bx_person_view', 'changed', 192, 1, 8),
('bx_person_view', 'friends_count', 2147483647, 1, 9),
('bx_person_view', 'followers_count', 2147483647, 1, 10),
('bx_person_view', 'last_name', 2147483647, 0, 4),
('bx_person_view', 'profile_email', 192, 1, 5),
('bx_person_view', 'profile_status', 192, 1, 6),
('bx_person_view', 'profile_ip', 192, 1, 7),
('bx_person_view', 'added', 192, 1, 8),
('bx_person_view', 'changed', 192, 1, 9),
('bx_person_view', 'friends_count', 2147483647, 1, 10),
('bx_person_view', 'followers_count', 2147483647, 1, 11),

('bx_person_view_full', 'gender', 2147483647, 1, 1),
('bx_person_view_full', 'birthday', 2147483647, 1, 2),
('bx_person_view_full', 'fullname', 2147483647, 1, 3),
('bx_person_view_full', 'description', 2147483647, 0, 4),
('bx_person_view_full', 'profile_email', 192, 1, 5),
('bx_person_view_full', 'profile_status', 192, 1, 6),
('bx_person_view_full', 'last_name', 2147483647, 0, 4),
('bx_person_view_full', 'description', 2147483647, 0, 5),
('bx_person_view_full', 'profile_email', 192, 1, 6),
('bx_person_view_full', 'profile_status', 192, 1, 7),

('bx_person_skills', 'skill_name', 2147483647, 1, 1),
('bx_person_skills_view', 'skill_name', 2147483647, 1, 1);
Expand Down
6 changes: 4 additions & 2 deletions modules/boonex/russian/data/langs/bx_persons/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
<string name="_bx_persons_form_profile_input_allow_post_to"><![CDATA[Оставлять сообщения в профиле могут]]></string>
<string name="_bx_persons_form_profile_input_sys_allow_contact_to"><![CDATA[Писать мне могут]]></string>
<string name="_bx_persons_form_profile_input_allow_contact_to"><![CDATA[Писать мне могут]]></string>
<string name="_bx_persons_form_profile_input_sys_fullname"><![CDATA[Полное имя]]></string>
<string name="_bx_persons_form_profile_input_fullname"><![CDATA[Полное имя]]></string>
<string name="_bx_persons_form_profile_input_sys_fullname"><![CDATA[Имя]]></string>
<string name="_bx_persons_form_profile_input_fullname"><![CDATA[Имя]]></string>
<string name="_bx_persons_form_profile_input_sys_last_name"><![CDATA[Фамилия]]></string>
<string name="_bx_persons_form_profile_input_last_name"><![CDATA[Фамилия]]></string>
<string name="_bx_persons_form_profile_input_fullname_err"><![CDATA[Имя профиля обязательно для заполнения и не должно начинаться с @.]]></string>
<string name="_bx_persons_form_profile_input_sys_desc"><![CDATA[Описание]]></string>
<string name="_bx_persons_form_profile_input_desc"><![CDATA[Описание]]></string>
Expand Down

0 comments on commit 1d0f57a

Please sign in to comment.