public function share() { $aPost = $this->get('val'); if ($aPost['post_type'] == '2') { if (!isset($aPost['friends']) || isset($aPost['friends']) && !count($aPost['friends'])) { Phpfox_Error::set('Select a friend to share this with.'); } else { $iCnt = 0; foreach ($aPost['friends'] as $iFriendId) { $aVals = array('user_status' => $aPost['post_content'], 'parent_user_id' => $iFriendId, 'parent_feed_id' => $aPost['parent_feed_id'], 'parent_module_id' => $aPost['parent_module_id']); if (Phpfox::getService('user.privacy')->hasAccess($iFriendId, 'feed.share_on_wall') && Phpfox::getUserParam('profile.can_post_comment_on_profile')) { $iCnt++; Phpfox::getService('feed.process')->addComment($aVals); } } $sMessage = '<div class="message">' . str_replace("'", "\\'", Phpfox::getPhrase('feed.successfully_shared_this_item_on_your_friends_wall')) . '</div>'; if (!$iCnt) { $sMessage = '<div class="error_message">' . str_replace("'", "\\'", Phpfox::getPhrase('user.unable_to_share_this_post_due_to_privacy_settings')) . '</div>'; } $this->call('$(\'#\' + tb_get_active()).find(\'.js_box_content:first\').html(\'' . $sMessage . '\');'); if ($iCnt) { $this->call('setTimeout(\'tb_remove();\', 2000);'); } } return; } $aVals = array('user_status' => $aPost['post_content'], 'privacy' => '0', 'privacy_comment' => '0', 'parent_feed_id' => $aPost['parent_feed_id'], 'parent_module_id' => $aPost['parent_module_id']); if ($iId = User_Service_Process::instance()->updateStatus($aVals)) { $this->call('$(\'#\' + tb_get_active()).find(\'.js_box_content:first\').html(\'<div class="message">' . str_replace("'", "\\'", Phpfox::getPhrase('feed.successfully_shared_this_item')) . '</div>\'); setTimeout(\'tb_remove();\', 2000);'); } else { $this->call("\$('#btnShareFeed').attr('disabled', false); \$('#imgShareFeedLoading').hide();"); } }
public function post() { $this->requires(['name', 'email', 'password']); \User_Service_Validate::instance()->email($this->request('email')); $userId = \User_Service_Process::instance()->add(['full_name' => $this->request('name'), 'email' => $this->request('email'), 'password' => $this->request('password')]); if (!$userId) { throw new \Exception(implode('', \Phpfox_Error::get())); } return $this->get($userId); }
private function _final() { $aForms = array(); $aValidation = array('full_name' => 'full_name', 'email' => array('def' => 'email', 'title' => 'Provide a valid email.'), 'password' => array('def' => 'password', 'title' => 'Provide a valid password.'), 'user_name' => array('def' => 'username', 'title' => 'Provide a valid user name.')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->_oReq->getArray('val')) { Phpfox::getService('user.validate')->user($aVals['user_name'])->email($aVals['email']); if ($oValid->isValid($aVals)) { if ($iUserId = Phpfox::getService('user.process')->add($aVals, ADMIN_USER_ID)) { list($bLogin, $aUser) = User_Service_Auth::instance()->login($aVals['email'], $aVals['password'], true, 'email'); if ($bLogin || isset($aVals['skip_user_login'])) { define('PHPFOX_FEED_NO_CHECK', true); User_Service_Auth::instance()->setUserId($iUserId); $this->_db()->update(Phpfox::getT('user_field'), array('in_admincp' => PHPFOX_TIME), 'user_id = ' . $iUserId); $this->_db()->update(Phpfox::getT('setting'), array('value_actual' => Phpfox::getVersion()), 'var_name = \'phpfox_version\''); $this->_video(true); User_Service_Process::instance()->updateStatus(['user_status' => 'Hello World!']); // $this->_pass('completed'); return ['next' => 'completed']; } } } } else { $aForms = array_merge($this->_video(), $aForms); } $this->_oTpl->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(false), 'aForms' => $aForms)); }
/** * Controller */ public function process() { Phpfox::isUser(true); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); list($bIsRegistration, $sNextUrl) = $this->url()->isRegistration(3); ($sPlugin = Phpfox_Plugin::get('user.component_controller_photo_1')) ? eval($sPlugin) : false; $bIsProcess = false; if ($this->request()->get('req3') == 'process') { $bIsProcess = true; /* if (($sStep = $this->request()->get('step'))) { $bIsProcess = true; $aCacheImage = unserialize(base64_decode(urldecode($sStep))); } */ } if (isset($_SERVER['HTTP_X_FILE_NAME'])) { define('PHPFOX_HTML5_PHOTO_UPLOAD', true); } ($sPlugin = Phpfox_Plugin::get('user.component_controller_photo_2')) ? eval($sPlugin) : false; if (($aVals = $this->request()->getArray('val')) || isset($_SERVER['HTTP_X_FILE_NAME'])) { $aImage = Phpfox_File::instance()->load('image', array('jpg', 'gif', 'png'), Phpfox::getUserParam('user.max_upload_size_profile_photo') === 0 ? null : Phpfox::getUserParam('user.max_upload_size_profile_photo') / 1024); if (!empty($aImage['name'])) { $iUserId = Phpfox::getUserId(); if (isset($aVals['is_iframe']) && Phpfox::isAdmin()) { $iUserId = (int) $aVals['user_id']; } if (($aImage = User_Service_Process::instance()->uploadImage($iUserId, true)) !== false) { if (isset($aVals['is_iframe'])) { $sImage = Phpfox::getLib('image.helper')->display(array('server_id' => $aImage['server_id'], 'path' => 'core.url_user', 'file' => $aImage['user_image'], 'suffix' => '_75', 'max_width' => 75, 'max_height' => 75, 'thickbox' => true, 'time_stamp' => true)); echo "<script type=\"text/javascript\">window.parent.document.getElementById('js_user_photo_" . $iUserId . "').innerHTML = '{$sImage}'; window.parent.tb_remove();</script>"; exit; } else { if (Phpfox::getUserParam('user.force_cropping_tool_for_photos')) { $this->url()->send('user.photo.process', array('step' => urlencode(base64_encode(serialize($aImage))))); } else { /* if ($bIsRegistration === true) { $this->url()->send($sNextUrl, null, Phpfox::getPhrase('user.profile_photo_successfully_uploaded')); } else { $this->url()->send('user.photo', null, Phpfox::getPhrase('user.profile_photo_successfully_uploaded')); } */ if (isset($_SERVER['HTTP_X_FILE_NAME'])) { return ['redirect' => $this->url()->makeUrl('user.photo.process')]; } $this->url()->send('user.photo.process'); } } } } } if (isset($aVals['is_iframe'])) { exit; } $sImage = Phpfox_Image_Helper::instance()->display(array('server_id' => Phpfox::getUserBy('server_id'), 'title' => Phpfox::getUserBy('full_name'), 'path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '', 'max_width' => 400, 'max_height' => 400, 'no_default' => true, 'time_stamp' => true, 'id' => 'user_profile_photo', 'class' => 'border')); // $sImage = str_replace('<img', '<img ', $sImage); /* $sImageThumb = Phpfox::getLib('image.helper')->display(array( 'server_id' => Phpfox::getUserBy('server_id'), 'title' => Phpfox::getUserBy('full_name'), 'path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_120' . (Phpfox::getParam('core.keep_non_square_images') ? '_square' : ''), 'max_width' => 120, 'max_height' => 120, 'no_default' => true, 'time_stamp' => true, 'class' => 'border' ) ); */ $sImageAvatar = Phpfox::getLib('image.helper')->display(array('server_id' => Phpfox::getUserBy('server_id'), 'title' => Phpfox::getUserBy('full_name'), 'path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_50_square', 'max_width' => 75, 'max_height' => 75, 'no_default' => true, 'time_stamp' => true, 'class' => 'border')); if (Phpfox::getUserBy('user_image') && !empty($sImage)) { preg_match("/src=\"(.*?)\"/", $sImage, $aMatches); list($width, $height) = @getimagesize($aMatches[1]); list($newHeight, $newWidth) = Phpfox_Image_Helper::instance()->getNewSize([$aMatches[1]], 400, 400, $width, $height); $sImage = str_replace('<img', '<img width="' . $newWidth . '" height="' . $newHeight . '" ', $sImage); $this->template()->setHeader('cache', array('jquery/plugin/jquery.crop.js' => 'static_script', 'jquery/plugin/imgnotes/jquery.imgareaselect.js' => 'static_script', 'imgareaselect-default.css' => 'style_css', '<script type="text/javascript">$Behavior.initPhotoCrop = function(){$Core.photo_crop.init({width: 75, height: 75, image_width: ' . $newWidth . ', image_height: ' . $newHeight . '}); };</script>'))->assign(array('iImageHeight' => $newHeight, 'iImageWidth' => $newWidth)); } $sPageTitle = $bIsRegistration ? Phpfox::getPhrase('user.upload_profile_picture') : Phpfox::getPhrase('user.edit_profile_picture'); ($sPlugin = Phpfox_Plugin::get('user.component_controller_photo_3')) ? eval($sPlugin) : false; $this->template()->setTitle($sPageTitle)->setBreadcrumb($sPageTitle)->setFullSite()->setPhrase(array('core.select_a_file_to_upload'))->setHeader(array('progress.js' => 'static_script', '<script type="text/javascript">$Behavior.changeUserPhoto = function(){ if ($Core.exists(\'#js_photo_form_holder\')) { oProgressBar = {holder: \'#js_photo_form_holder\', progress_id: \'#js_progress_bar\', uploader: \'#js_progress_uploader\', add_more: false, max_upload: 1, total: 1, frame_id: \'js_upload_frame\', file_id: \'image\'}; $Core.progressBarInit(); } }</script>'))->assign(array('sProfileImage' => $sImage, 'sImageAvatar' => $sImageAvatar, 'sProfileImage2' => str_replace('id="user_profile_photo"', 'id="js_profile_photo_preview"', $sImage), 'bIsRegistration' => $bIsRegistration, 'sNextUrl' => $this->url()->makeUrl($sNextUrl), 'bIsProcess' => $bIsProcess, 'iMaxFileSize' => Phpfox::getUserParam('user.max_upload_size_profile_photo') === 0 ? null : Phpfox::getUserParam('user.max_upload_size_profile_photo') / 1024 * 1048576)); }
/** * Controller */ public function process() { Phpfox::isUser(true); $aUser = Phpfox::getService('user')->get(Phpfox::getUserId(), true); $aVals = $this->request()->getArray('val'); if (!isset($aUser['user_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('user.unable_to_edit_this_account')); } /*if (!empty($aUser['signature'])) { $aUser['signature'] = preg_replace("/<br\s*\/?>/is", "\n", $aUser['signature']); }*/ /*$aValidation = array( 'country_iso' => Phpfox::getPhrase('user.select_current_location') ); */ if (Phpfox::getUserParam('user.can_change_email')) { $aValidation['email'] = array('def' => 'email', 'title' => Phpfox::getPhrase('user.provide_a_valid_email_address')); } /*if (Phpfox::getUserParam('user.can_edit_gender_setting')) { $aValidation['gender'] = Phpfox::getPhrase('user.select_your_gender'); }*/ /*if (Phpfox::getUserParam('user.can_edit_dob')) { $aValidation['month'] = Phpfox::getPhrase('user.select_month_of_birth'); $aValidation['day'] = Phpfox::getPhrase('user.select_day_of_birth'); $aValidation['year'] = Phpfox::getPhrase('user.select_year_of_birth'); } */ /*if (!empty($aVals['postal_code'])) { $aValidation['postal_code'] = array('def' => 'zip', 'title' => Phpfox::getPhrase('user.zip_postal_code_is_invalid')); }*/ if (Phpfox::getUserParam('user.can_change_own_full_name')) { $aValidation['full_name'] = Phpfox::getPhrase('user.provide_your_full_name'); } if (Phpfox::getUserParam('user.can_change_own_user_name') && !Phpfox::getParam('user.profile_use_id')) { $aValidation['user_name'] = array('def' => 'username', 'title' => Phpfox::getPhrase('user.provide_a_user_name')); } ($sPlugin = Phpfox_Plugin::get('user.component_controller_setting_process_validation')) ? eval($sPlugin) : false; $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if (count($aVals)) { ($sPlugin = Phpfox_Plugin::get('user.component_controller_setting_process_check')) ? eval($sPlugin) : false; if ($oValid->isValid($aVals)) { $bAllowed = true; $sMessage = Phpfox::getPhrase('user.account_settings_updated'); if (Phpfox::getUserParam('user.can_change_email') && $aUser['email'] != $aVals['email']) { $bAllowed = Phpfox::getService('user.verify.process')->changeEmail($aUser, $aVals['email']); if (is_string($bAllowed)) { Phpfox_Error::set($bAllowed); $bAllowed = false; } if (Phpfox::getParam('user.verify_email_at_signup')) { $sMessage = Phpfox::getPhrase('user.account_settings_updated_your_new_mail_address_requires_verification_and_an_email_has_been_sent_until_then_your_email_remains_the_same'); if (Phpfox::getParam('user.logout_after_change_email_if_verify')) { $this->url()->send('user.verify', null, Phpfox::getPhrase('user.email_updated_you_need_to_verify_your_new_email_address_before_logging_in')); } } } if ($bAllowed && ($iId = User_Service_Process::instance()->update(Phpfox::getUserId(), $aVals, array('changes_allowed' => Phpfox::getUserParam('user.total_times_can_change_user_name'), 'total_user_change' => $aUser['total_user_change'], 'full_name_changes_allowed' => Phpfox::getUserParam('user.total_times_can_change_own_full_name'), 'total_full_name_change' => $aUser['total_full_name_change'], 'current_full_name' => $aUser['full_name']), true))) { $this->url()->send('user.setting', null, $sMessage); } } } if (!empty($aUser['birthday'])) { $aUser = array_merge($aUser, Phpfox::getService('user')->getAgeArray($aUser['birthday'])); } $aGateways = Phpfox::getService('api.gateway')->getActive(); if (!empty($aGateways)) { $aGatewayValues = Phpfox::getService('api.gateway')->getUserGateways($aUser['user_id']); foreach ($aGateways as $iKey => $aGateway) { foreach ($aGateway['custom'] as $iCustomKey => $aCustom) { if (isset($aGatewayValues[$aGateway['gateway_id']]['gateway'][$iCustomKey])) { $aGateways[$iKey]['custom'][$iCustomKey]['user_value'] = $aGatewayValues[$aGateway['gateway_id']]['gateway'][$iCustomKey]; } } } } $aTimeZones = Phpfox::getService('core')->getTimeZones(); if (count($aTimeZones) > 100) { $this->template()->setHeader('cache', array('setting.js' => 'module_user')); } $sFullNamePhrase = Phpfox::getUserParam('user.custom_name_field'); ($sPlugin = Phpfox_Plugin::get('user.component_controller_setting_settitle')) ? eval($sPlugin) : false; if (Phpfox::getParam('user.split_full_name') && empty($aUser['first_name']) && empty($aUser['last_name'])) { preg_match('/(.*) (.*)/', $aUser['full_name'], $aNameMatches); if (isset($aNameMatches[1]) && isset($aNameMatches[2])) { $aUser['first_name'] = $aNameMatches[1]; $aUser['last_name'] = $aNameMatches[2]; } else { $aUser['first_name'] = $aUser['full_name']; } } $this->template()->setTitle(Phpfox::getPhrase('user.account_settings'))->setBreadcrumb(Phpfox::getPhrase('user.account_settings'))->setFullSite()->setHeader('cache', array('country.js' => 'module_core', '<script type="text/javascript">sSetTimeZone = "' . Phpfox::getUserBy('time_zone') . '";</script>'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aForms' => $aUser, 'aTimeZones' => $aTimeZones, 'sFullNamePhrase' => empty($sFullNamePhrase) ? Phpfox::getPhrase('user.full_name') : Phpfox::getPhrase($sFullNamePhrase), 'iTotalChangesAllowed' => Phpfox::getUserParam('user.total_times_can_change_user_name'), 'iTotalFullNameChangesAllowed' => Phpfox::getUserParam('user.total_times_can_change_own_full_name'), 'aLanguages' => Phpfox::getService('language')->get(array('l.user_select = 1')), 'sDobStart' => Phpfox::getParam('user.date_of_birth_start'), 'sDobEnd' => Phpfox::getParam('user.date_of_birth_end'), 'aCurrencies' => Phpfox::getService('core.currency')->get(), 'aGateways' => $aGateways)); }