本文整理汇总了PHP中Phpfox::getUserGroupParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Phpfox::getUserGroupParam方法的具体用法?PHP Phpfox::getUserGroupParam怎么用?PHP Phpfox::getUserGroupParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phpfox
的用法示例。
在下文中一共展示了Phpfox::getUserGroupParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add($iBlockedUserId)
{
Phpfox::isUser(true);
Phpfox::getUserParam('user.can_block_other_members', true);
if ($iBlockedUserId == Phpfox::getUserId())
{
return Phpfox_Error::set(Phpfox::getPhrase('user.not_able_to_block_yourself'));
}
if (Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $iBlockedUserId))
{
return Phpfox_Error::set(Phpfox::getPhrase('user.you_have_already_blocked_this_user'));
}
$aUser = Phpfox::getService('user')->getUser($iBlockedUserId, 'u.user_id, u.user_group_id');
if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others'))
{
return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user'));
}
$this->database()->insert($this->_sTable, array(
'user_id' => Phpfox::getUserId(),
'block_user_id' => (int) $iBlockedUserId,
'time_stamp' => PHPFOX_TIME,
'ip_address' => Phpfox::getIp()
)
);
Phpfox::getService('friend.process')->deleteFromConnection(Phpfox::getUserId(), $iBlockedUserId);
Phpfox::getService('friend.process')->deleteFromConnection($iBlockedUserId, Phpfox::getUserId());
return true;
}
示例2: process
/**
* Class process method wnich is used to execute this component.
*/
public function process()
{
$aUser = $this->getParam('aUser');
if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'music.can_upload_music_public'))
{
return false;
}
$aAlbums = Phpfox::getService('music.album')->getForProfile($aUser['user_id']);
if (!count($aAlbums) && !defined('PHPFOX_IN_DESIGN_MODE'))
{
return false;
}
$this->template()->assign(array(
'sHeader' => Phpfox::getPhrase('music.albums'),
'sBlockJsId' => 'profile_music_album',
'aAlbums' => $aAlbums
)
);
if (count($aAlbums) >= 4)
{
$this->template()->assign(array(
'aFooter' => array(
Phpfox::getPhrase('music.view_more') => $this->url()->makeUrl('music.browse.album', array('userid' => $aUser['user_id']))
)
)
);
}
return 'block';
}
示例3: getProfileTitle
public function getProfileTitle($aRow)
{
$sTitleReplace = Phpfox::getParam('profile.profile_seo_for_meta_title');
if (!empty($sTitleReplace) && Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'profile.basic_info')) {
preg_match_all('/\\{(.*?)\\}/i', $sTitleReplace, $aMatches);
if (isset($aMatches[1]) && is_array($aMatches[1])) {
foreach ($aMatches[1] as $sFind) {
if ($sFind == 'gender_name' && !Phpfox::getUserGroupParam($aRow['user_group_id'], 'user.can_edit_gender_setting')) {
unset($aRow[$sFind]);
}
if (!empty($aRow[$sFind])) {
if ($sFind == 'location' && !empty($aRow[$sFind])) {
if (isset($aRow['location_child'])) {
$aRow[$sFind] = $aRow[$sFind] . ' - ' . $aRow['location_child'];
}
}
$sTitleReplace = str_replace('{' . $sFind . '}', $aRow[$sFind], $sTitleReplace);
} else {
$sTitleReplace = str_replace('{' . $sFind . '} -', '', $sTitleReplace);
$sTitleReplace = str_replace('{' . $sFind . '}', '', $sTitleReplace);
}
}
}
$sPageTitle = rtrim(trim($sTitleReplace), '-');
}
if (empty($sPageTitle)) {
$sPageTitle = $aRow['full_name'];
}
return $sPageTitle;
}
示例4: changeEmail
/**
* Changes a user's email addres, checks if user is allowed and if he should be made verify their email address
* afterwards and if it should be logged out immediately after changing it.
* @param <type> $aUser
* @param <type> $sMail
* @return <type>
*/
public function changeEmail($aUser, $sMail)
{
// check if user has enough permissions and the mails dont match if they have to verify the new email upon signup it
if (Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_change_email')) {
Phpfox::getService('user.validate')->email($sMail);
if (!Phpfox_Error::isPassed()) {
return false;
}
// check that the new email is not in use.
$sEmail = Phpfox::getLib('parse.input')->prepare($sMail);
$inUse = $this->database()->select('email')->where('email = \'' . $sEmail . '\'')->from(Phpfox::getT('user'))->execute('getSlaveField');
if ($inUse != '') {
return 'Email address already in use';
}
//die(d(Phpfox::getParam('user.verify_email_at_signup'), true));
// set the status to need to be verified only if they are required at signup
if (Phpfox::getParam('user.verify_email_at_signup')) {
$mUser = array('user_id' => $aUser['user_id'], 'email' => Phpfox::getLib('parse.input')->prepare($sMail), 'password' => $aUser['password']);
$this->database()->update(Phpfox::getT('user'), array('status_id' => 1), 'user_id = ' . (int) $aUser['user_id']);
$this->sendMail($mUser);
} else {
// just change the email
$this->database()->update(Phpfox::getT('user'), array('email' => Phpfox::getLib('parse.input')->prepare($sMail)), 'user_id = ' . (int) $aUser['user_id']);
}
//Phpfox::getParam('user.logout_after_change_email_if_verify') && Phpfox::getParam('user.verify_email_at_signup')
// check if they should be logged out immediately after changing it. Only then should their status_id be changed
if (Phpfox::getParam('user.verify_email_at_signup') && Phpfox::getParam('user.logout_after_change_email_if_verify') == true) {
Phpfox::getService('user.auth')->logout();
}
return true;
}
return false;
}
示例5: process
/**
* Class process method wnich is used to execute this component.
*/
public function process()
{
$aUser = PHPFOX_IS_AJAX ? array('user_group_id' => Phpfox::getUserBy('user_group_id'), 'user_id' => Phpfox::getUserId()) : $this->getParam('aUser');
if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'music.can_upload_music_public')) {
return false;
}
$aUserGenres = Phpfox::getService('music.genre')->getUserGenre($aUser['user_id']);
if (!count($aUserGenres)) {
return false;
}
$this->template()->assign(array('aUserGenres' => $aUserGenres));
}
示例6: getGroups
public function getGroups($sType, $iUserGroup)
{
$iGroup = 0;
$aWhere = array('type_id = \'' . $this->database()->escape($sType) . '\' AND is_active = 1');
if (Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields')) {
$iGroup = $iUserGroup;
$iInherit = $this->database()->select('inherit_id')->from(Phpfox::getT('user_group'))->where('user_group_id = ' . (int) $iUserGroup)->execute('getSlaveField');
$aWhere[] = 'AND (user_group_id = 0 OR user_group_id = ' . $iInherit . ' OR user_group_id = ' . (int) $iGroup . ')';
} else {
$aWhere[] = 'AND (user_group_id = 0 OR user_group_id = ' . (int) $iGroup . ')';
}
return $this->database()->select('*')->from($this->_sTable)->where($aWhere)->order('ordering ASC')->execute('getSlaveRows');
}
示例7: getGroups
public function getGroups($sType, $iUserGroup)
{
$iGroup = 0;
if (Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields'))
{
$iGroup = $iUserGroup;
}
return $this->database()->select('*')
->from($this->_sTable)
->where('user_group_id = ' . (int) $iGroup . ' AND type_id = \'' . $this->database()->escape($sType) . '\' AND is_active = 1')
->order('ordering ASC')
->execute('getSlaveRows');
}
示例8: process
/**
* Controller
*/
public function process()
{
$aUser = $this->getParam('aUser');
if (!Phpfox::getUserGroupParam(isset($aUser['user_group_id']) ? $aUser['user_group_id'] : Phpfox::getUserBy('user_group_id'), 'music.can_upload_music_public')) {
return false;
}
$aUserGenres = array();
$aGetUserGenres = Phpfox::getService('music.genre')->getUserGenre(isset($aUser['user_id']) ? $aUser['user_id'] : Phpfox::getUserId());
if (count($aGetUserGenres)) {
foreach ($aGetUserGenres as $aUserGenre) {
$aUserGenres[$aUserGenre['order_id']] = $aUserGenre;
}
}
$this->template()->assign(array('iCustomGroupId' => Phpfox::getService('custom.group')->getId('music.custom_group_basics'), 'aGenres' => Phpfox::getService('music.genre')->getList(), 'aUserGenres' => $aUserGenres, 'iGenerCount' => 3, 'bIsGlobalEdit' => isset($aUser['user_id']) ? true : false));
}
示例9: process
/**
* Controller
*/
public function process()
{
$aUser = Phpfox::getService('user')->getUser($this->request()->getInt('user_id'));
if (!isset($aUser['user_id'])) {
return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_find_this_member'));
}
$bIsBlocked = Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aUser['user_id']);
if (!$bIsBlocked) {
Phpfox::getUserParam('user.can_block_other_members', true);
if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others')) {
return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user'));
}
}
$this->template()->assign(array('aUser' => $aUser, 'bIsBlocked' => $bIsBlocked));
}
示例10: process
/**
* Controller
*/
public function process()
{
$aUser = $this->getParam('aUser');
$bIsMusician = false;
if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'music.can_upload_music_public')) {
return false;
}
$aSongs = Phpfox::getService('music')->getSongs($aUser['user_id'], null, 10);
if (!count($aSongs) && !defined('PHPFOX_IN_DESIGN_MODE')) {
return false;
}
$this->template()->assign(array('sHeader' => Phpfox::getPhrase('music.latest_tracks'), 'sBlockJsId' => 'profile_music_song', 'aSongs' => $aSongs, 'bIsMusician' => true, 'sCustomPlayId' => 'js_my_block_track_player'));
if (Phpfox::getUserId() == $aUser['user_id']) {
$this->template()->assign('sDeleteBlock', 'profile');
}
return 'block';
}
示例11: process
/**
* Controller
*/
public function process()
{
$bIsEdit = false;
if ($iEditId = $this->request()->getInt('id')) {
Phpfox::getUserParam('custom.can_manage_custom_fields', true);
if (($aGroup = Phpfox::getService('custom.group')->getForEdit($iEditId)) && isset($aGroup['group_id'])) {
$bIsEdit = true;
$this->template()->assign(array('aForms' => $aGroup));
}
} else {
Phpfox::getUserParam('custom.can_add_custom_fields_group', true);
}
$aGroupValidation = array('product_id' => Phpfox::getPhrase('custom.select_a_product_this_custom_field_will_belong_to'), 'module_id' => Phpfox::getPhrase('custom.select_a_module_this_custom_field_will_belong_to'), 'type_id' => Phpfox::getPhrase('custom.select_where_this_custom_field_should_be_located'));
$oGroupValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_group_field', 'aParams' => $aGroupValidation, 'bParent' => true));
$aGroupTypes = array();
foreach (Phpfox::massCallback('getCustomGroups') as $sModule => $aCustomGroups) {
foreach ($aCustomGroups as $sKey => $sPhrase) {
$aGroupTypes[$sKey] = $sPhrase;
}
}
if ($aVals = $this->request()->getArray('val')) {
if ($oGroupValidator->isValid($aVals)) {
if ($bIsEdit === true) {
if (Phpfox::getService('custom.group.process')->update($aGroup['group_id'], $aVals)) {
$this->url()->send('admincp.custom.group.add', array('id' => $aGroup['group_id']), Phpfox::getPhrase('custom.group_successfully_updated'));
}
} else {
if (Phpfox::getService('custom.group.process')->add($aVals)) {
$this->url()->send('admincp.custom.group.add', null, Phpfox::getPhrase('custom.group_successfully_added'));
}
}
}
}
$aUserGroups = Phpfox::getService('user.group')->get();
foreach ($aUserGroups as $iKey => $aUserGroup) {
if (!Phpfox::getUserGroupParam($aUserGroup['user_group_id'], 'custom.has_special_custom_fields')) {
unset($aUserGroups[$iKey]);
}
}
$this->template()->setTitle(Phpfox::getPhrase('custom.add_a_new_custom_group'))->setBreadcrumb(Phpfox::getPhrase('custom.add_a_new_custom_group'))->assign(array('sGroupCreateJs' => $oGroupValidator->createJS(), 'sGroupGetJsForm' => $oGroupValidator->getJsForm(), 'aGroupTypes' => $aGroupTypes, 'bIsEdit' => $bIsEdit, 'aUserGroups' => $aUserGroups));
}
示例12: processJob
//.........这里部分代码省略.........
->group('u.user_id')
->where($sWhere)
->execute('getSlaveRows');
if (count($aUsers) == 0)
{
if ($aNewsletterInfo['archive'] != 1)
{
$this->database()->delete($this->_sTable, 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']);
$this->database()->delete(Phpfox::getT('newsletter_text'), 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']);
}
else
{
$this->database()->update($this->_sTable, array('state' => 2), 'newsletter_id = ' . (int)$aNewsletterInfo['newsletter_id']);
}
$this->database()->update(Phpfox::getT('user_field'), array('newsletter_state' => 0), 'newsletter_state != 0');
return array(true, 100); // newsletter sent to everyone. finished successfully.
}
$sOriginalHtmlText = $aNewsletterInfo['text_html'];
$sOriginalPlainText = $aNewsletterInfo['text_plain'];
// store these users ID into a string to update them
$sUpdate = '1=2 ';
// Step 3: Send the message
if ($aNewsletterInfo['type_id'] == 2) // External -> send email
{
$aValsT = $aNewsletterInfo;
foreach ($aUsers as $aUser)
{
$aNewsletterInfo = $aValsT;
$sUpdate .= ' OR user_id = ' . $aUser['user_id'];
if (isset($aUser['user_group_id']) && Phpfox::getUserGroupParam($aUser['user_group_id'], 'newsletter.can_receive_notification') == false)
{
}
elseif (isset($aUser['notification']) && $aUser['notification'] != '' && $aNewsletterInfo['privacy'] != 1)
{ // user does not want to receive mails and admin set this newsletter to NOT override this
continue;
}
// keyword substitution
$aSearch = array('{FULL_NAME}', '{USER_NAME}', '{SITE_NAME}');
$aReplace = array($aUser['full_name'], $aUser['user_name'], Phpfox::getParam('core.site_title'));
$aNewsletterInfo['text_html'] = str_ireplace($aSearch, $aReplace, $sOriginalHtmlText);
$aNewsletterInfo['subject'] = str_ireplace($aSearch, $aReplace, $aNewsletterInfo['subject']);
if ($aNewsletterInfo['text_plain'] !== null)
{
$aNewsletterInfo['text_plain'] = str_ireplace($aSearch, $aReplace, $sOriginalPlainText);
}
unset($aSearch);
unset($aReplace);
$this->_sendExternal($aNewsletterInfo, $aUser);
}
}
elseif($aNewsletterInfo['type_id'] == 1) // internal message
{
foreach ($aUsers as $aUser)
{
// keyword substitution
$aSearch = array('{FULL_NAME}', '{USER_NAME}', '{SITE_NAME}');
$aReplace = array($aUser['full_name'], $aUser['user_name'], Phpfox::getParam('core.site_title'));
$aNewsletterInfo['text_html'] = str_ireplace($aSearch, $aReplace, $sOriginalHtmlText);
$aNewsletterInfo['subject'] = str_ireplace($aSearch, $aReplace, $aNewsletterInfo['subject']);
示例13: process
/**
* Class process method wnich is used to execute this component.
*/
public function process()
{
// $aUser = (PHPFOX_IS_AJAX ? Phpfox::getService('user')->get(Phpfox::getUserId(), true) : $this->getParam('aUser'));
$aUser = $this->getParam('aUser');
/*
if (PHPFOX_IS_AJAX)
{
$aUser['gender_name'] = Phpfox::getService('user')->gender($aUser['gender']);
$aUser['birthday_time_stamp'] = $aUser['birthday'];
$aUser['birthday'] = Phpfox::getService('user')->age($aUser['birthday']);
$aUser['location'] = Phpfox::getService('core.country')->getCountry($aUser['country_iso']);
$this->template()->assign('aUser', $aUser);
}
*/
if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'profile.basic_info')) {
return false;
}
$aUser['bRelationshipHeader'] = true;
$sRelationship = Phpfox::getService('custom')->getRelationshipPhrase($aUser);
$aUserDetails = array();
if (!empty($aUser['gender'])) {
$aUserDetails[Phpfox::getPhrase('profile.gender')] = '<a href="' . $this->url()->makeUrl('user.browse', array('gender' => $aUser['gender'])) . '">' . $aUser['gender_name'] . '</a>';
}
$aUserDetails = array_merge($aUserDetails, $aUser['birthdate_display']);
$sExtraLocation = '';
if (!empty($aUser['city_location'])) {
$sExtraLocation .= '<div class="p_2"><a href="' . $this->url()->makeUrl('user.browse', array('location' => $aUser['country_iso'], 'state' => $aUser['country_child_id'], 'city-name' => $aUser['city_location'])) . '">' . Phpfox::getLib('parse.output')->clean($aUser['city_location']) . '</a> »</div>';
}
if ($aUser['country_child_id'] > 0) {
$sExtraLocation .= '<div class="p_2"><a href="' . $this->url()->makeUrl('user.browse', array('location' => $aUser['country_iso'], 'state' => $aUser['country_child_id'])) . '">' . Phpfox::getService('core.country')->getChild($aUser['country_child_id']) . '</a> »</div>';
}
if (!empty($aUser['country_iso'])) {
$aUserDetails[Phpfox::getPhrase('profile.location')] = $sExtraLocation . '<a href="' . $this->url()->makeUrl('user.browse', array('location' => $aUser['country_iso'])) . '">' . Phpfox::getPhraseT($aUser['location'], 'country') . '</a>';
}
if ((int) $aUser['last_login'] > 0 && (!$aUser['is_invisible'] || Phpfox::getUserParam('user.can_view_if_a_user_is_invisible') && $aUser['is_invisible'])) {
$aUserDetails[Phpfox::getPhrase('profile.last_login')] = Phpfox::getLib('date')->convertTime($aUser['last_login'], 'core.profile_time_stamps');
}
if ((int) $aUser['joined'] > 0) {
$aUserDetails[Phpfox::getPhrase('profile.member_since')] = Phpfox::getLib('date')->convertTime($aUser['joined'], 'core.profile_time_stamps');
}
if (Phpfox::getUserGroupParam($aUser['user_group_id'], 'profile.display_membership_info')) {
$aUserDetails[Phpfox::getPhrase('profile.membership')] = (empty($aUser['icon_ext']) ? '' : '<img src="' . Phpfox::getParam('core.url_icon') . $aUser['icon_ext'] . '" class="v_middle" alt="' . Phpfox::getLib('locale')->convert($aUser['title']) . '" title="' . Phpfox::getLib('locale')->convert($aUser['title']) . '" /> ') . $aUser['prefix'] . Phpfox::getLib('locale')->convert($aUser['title']) . $aUser['suffix'];
}
$aUserDetails[Phpfox::getPhrase('profile.profile_views')] = $aUser['total_view'];
if (Phpfox::isModule('rss') && Phpfox::getParam('rss.display_rss_count_on_profile') && Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'rss.display_on_profile')) {
$aUserDetails[Phpfox::getPhrase('profile.rss_subscribers')] = $aUser['rss_count'];
}
$sEditLink = '';
if ($aUser['user_id'] == Phpfox::getUserId()) {
$sEditLink = '<div class="js_edit_header_bar">';
$sEditLink .= '<span id="js_user_basic_info" style="display:none;"><img src="' . $this->template()->getStyle('image', 'ajax/small.gif') . '" alt="" class="v_middle" /></span>';
$sEditLink .= '<a href="' . Phpfox::getLib('url')->makeUrl('user.profile') . '" id="js_user_basic_edit_link">';
$sEditLink .= '<img src="' . $this->template()->getStyle('image', 'misc/page_white_edit.png') . '" alt="" class="v_middle" />';
$sEditLink .= '</a>';
$sEditLink .= '</div>';
}
// Get the Smoker and Drinker details
$aUserPanel = Phpfox::getService('custom')->getUserPanelForUser($aUser['user_id']);
foreach ($aUserPanel as $sName => $aField) {
//$aUserDetails[Phpfox::getPhrase($aField['phrase_var_name'])] = Phpfox::getPhrase($aField['phrase_chosen']);
}
$this->template()->assign(array('aUserDetails' => $aUserDetails, 'sBlockJsId' => 'profile_basic_info', 'sRelationship' => $sRelationship));
$this->setParam('aRatingCallback', array('type' => 'user', 'total_rating' => Phpfox::getPhrase('profile.total_rating_ratings', array('total_rating' => $aUser['total_rating'])), 'default_rating' => $aUser['total_score'], 'item_id' => $aUser['user_id'], 'stars' => range(1, 10)));
($sPlugin = Phpfox_Plugin::get('profile.component_block_info')) ? eval($sPlugin) : false;
if (!Phpfox::isMobile()) {
$this->template()->assign(array('sHeader' => $sEditLink . Phpfox::getPhrase('profile.basic_info'), 'sEditLink' => $sEditLink));
return 'block';
}
}
示例14: deleteOption
public function deleteOption($iId)
{
Phpfox::getUserParam('custom.can_manage_custom_fields', true);
$aOption = $this->database()->select('co.*, cf.field_name, cf.user_group_id, cf.var_type, cf.field_id')->from(Phpfox::getT('custom_option'), 'co')->join(Phpfox::getT('custom_field'), 'cf', 'cf.field_id = co.field_id')->where('co.option_id = ' . (int) $iId)->execute('getRow');
if (!isset($aOption['option_id'])) {
return Phpfox_Error::set(Phpfox::getPhrase('custom.unable_to_find_the_custom_option_you_plan_on_deleting'));
}
if ($aOption['var_type'] == 'select' || $aOption['var_type'] == 'multiselect' || $aOption['var_type'] == 'checkbox' || $aOption['var_type'] == 'radio') {
Phpfox::getService('language.phrase.process')->delete($aOption['phrase_var_name']);
$this->database()->delete(Phpfox::getT('custom_option'), 'option_id = ' . $aOption['option_id']);
$this->database()->delete(Phpfox::getT('user_custom_multiple_value'), 'option_id = ' . $aOption['option_id'] . ' AND field_id = ' . $aOption['field_id']);
return true;
}
$sTable = 'user_custom';
$sValueTable = 'user_custom_value';
if ($aOption['user_group_id'] > 0) {
if (Phpfox::getUserGroupParam($aOption['user_group_id'], 'custom.has_special_custom_fields')) {
$sTable = Phpfox::getUserGroupParam($aOption['user_group_id'], 'custom.custom_table_name');
$sValueTable = $sTable . '_value';
}
}
$sFieldName = Phpfox::getService('custom')->getAlias() . $aOption['field_name'];
$this->database()->update(Phpfox::getT($sTable), array($sFieldName => null), $sFieldName . ' = \'' . $this->database()->escape($aOption['phrase_var_name']) . '\'');
$this->database()->update(Phpfox::getT($sValueTable), array($sFieldName => 0), $sFieldName . ' = \'' . $aOption['option_id'] . '\'');
list($sModule, $sPhrase) = explode('.', $aOption['phrase_var_name']);
$this->database()->delete(Phpfox::getT('language_phrase'), 'module_id = \'' . $sModule . '\' AND var_name = \'' . $sPhrase . '\'');
$this->database()->delete(Phpfox::getT('custom_option'), 'option_id = ' . $aOption['option_id']);
return true;
}
示例15: process
/**
* Controller
*/
public function process()
{
$bHideOptions = true;
$iDefaultSelect = 4;
$bIsEdit = false;
if ($iEditId = $this->request()->getInt('id')) {
Phpfox::getUserParam('custom.can_manage_custom_fields', true);
$aField = Phpfox::getService('custom')->getForCustomEdit($iEditId);
if (isset($aField['field_id'])) {
$bIsEdit = true;
$this->template()->assign(array('aForms' => $aField));
if (isset($aField['option']) && $aField['var_type'] == 'select') {
$bHideOptions = false;
}
}
} else {
Phpfox::getUserParam('custom.can_add_custom_fields', true);
$this->template()->assign(array('aForms' => array()));
}
$aFieldValidation = array('product_id' => Phpfox::getPhrase('custom.select_a_product_this_custom_field_will_belong_to'), 'type_id' => Phpfox::getPhrase('custom.select_a_module_this_custom_field_will_belong_to'), 'var_type' => Phpfox::getPhrase('custom.select_what_type_of_custom_field_this_is'));
$oCustomValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_custom_field', 'aParams' => $aFieldValidation, 'bParent' => true));
$this->template()->assign(array('sCustomCreateJs' => $oCustomValidator->createJS(), 'sCustomGetJsForm' => $oCustomValidator->getJsForm()));
if ($aVals = $this->request()->getArray('val')) {
if ($oCustomValidator->isValid($aVals)) {
if ($bIsEdit) {
if (Phpfox::getService('custom.process')->update($aField['field_id'], $aVals)) {
$this->url()->send('admincp.custom.add', array('id' => $aField['field_id']), Phpfox::getPhrase('custom.field_successfully_updated'));
}
} else {
if (Phpfox::getService('custom.process')->add($aVals)) {
$this->url()->send('admincp.custom.add', null, Phpfox::getPhrase('custom.field_successfully_added'));
}
}
}
if (isset($aVals['var_type']) && $aVals['var_type'] == 'select') {
$bHideOptions = false;
$iCnt = 0;
$sOptionPostJs = '';
foreach ($aVals['option'] as $iKey => $aOptions) {
if (!$iKey) {
continue;
}
$aValues = array_values($aOptions);
if (!empty($aValues[0])) {
$iCnt++;
}
foreach ($aOptions as $sLang => $mValue) {
$sOptionPostJs .= 'option_' . $iKey . '_' . $sLang . ': \'' . str_replace("'", "\\'", $mValue) . '\',';
}
}
$sOptionPostJs = rtrim($sOptionPostJs, ',');
$iDefaultSelect = $iCnt;
}
}
$aTypes = array();
foreach (Phpfox::massCallback('getCustomFieldLocations') as $sModule => $aCustomFields) {
foreach ($aCustomFields as $sKey => $sPhrase) {
$aTypes[$sKey] = $sPhrase;
}
}
$aGroupTypes = array();
foreach (Phpfox::massCallback('getCustomGroups') as $sModule => $aCustomGroups) {
foreach ($aCustomGroups as $sKey => $sPhrase) {
$aGroupTypes[$sKey] = $sPhrase;
}
}
$aGroupValidation = array('product_id' => Phpfox::getPhrase('custom.select_a_product_this_custom_field_will_belong_to'), 'module_id' => Phpfox::getPhrase('custom.select_a_module_this_custom_field_will_belong_to'), 'type_id' => Phpfox::getPhrase('custom.select_where_this_custom_field_should_be_located'));
$oGroupValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_group_field', 'aParams' => $aGroupValidation, 'bParent' => true));
$this->template()->assign(array('sGroupCreateJs' => $oGroupValidator->createJS(), 'sGroupGetJsForm' => $oGroupValidator->getJsForm(false)));
$aUserGroups = Phpfox::getService('user.group')->get();
foreach ($aUserGroups as $iKey => $aUserGroup) {
if (!Phpfox::getUserGroupParam($aUserGroup['user_group_id'], 'custom.has_special_custom_fields')) {
unset($aUserGroups[$iKey]);
}
}
// only show the input if there are custom fields
$this->template()->assign(array('bShowUserGroups' => count($aUserGroups) > 0));
$this->template()->setSectionTitle('Custom Fields')->setTitle(Phpfox::getPhrase('custom.add_a_new_custom_field'))->setBreadcrumb($bIsEdit ? 'Edit Custom Field' : Phpfox::getPhrase('custom.add_a_new_custom_field'), $this->url()->current(), true)->setPhrase(array('custom.are_you_sure_you_want_to_delete_this_custom_option'))->setHeader(array('<script type="text/javascript"> var bIsEdit = ' . ($bIsEdit ? 'true' : 'false') . '</script>', 'admin.js' => 'module_custom', '<script type="text/javascript">$Behavior.custom_admin_add_init = function(){$Core.custom.init(' . ($bIsEdit == true ? 1 : $iDefaultSelect) . '' . (isset($sOptionPostJs) ? ', {' . $sOptionPostJs . '}' : '') . ');};</script>'))->assign(array('aTypes' => $aTypes, 'aLanguages' => Phpfox::getService('language')->getAll(), 'aGroupTypes' => $aGroupTypes, 'aGroups' => Phpfox::getService('custom.group')->get(), 'bHideOptions' => $bHideOptions, 'bIsEdit' => $bIsEdit, 'aUserGroups' => $aUserGroups));
}