/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'title' => Phpfox::getPhrase('admincp.provide_a_title_for_your_plugin'), 'call_name' => Phpfox::getPhrase('admincp.select_a_hook'), 'php_code' => Phpfox::getPhrase('admincp.provide_php_code_for_your_plugin')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($iEditId = $this->request()->get('id')) { $aPlugin = Phpfox::getService('admincp.plugin')->getForEdit($iEditId); if (isset($aPlugin['plugin_id'])) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aPlugin)); } } else { } if ($aVals = $this->request()->getArray('val')) { if ($bIsEdit) { if (Phpfox::getService('admincp.plugin.process')->update($aPlugin['plugin_id'], $aVals)) { $this->url()->send('admincp.plugin.add', array('id' => $aPlugin['plugin_id']), Phpfox::getPhrase('admincp.plugin_successfully_updated')); } } else { if (Phpfox::getService('admincp.plugin.process')->add($aVals)) { $this->url()->send('admincp.plugin', null, Phpfox::getPhrase('admincp.plugin_successfully_added')); } } } $this->template()->setTitle(Phpfox::getPhrase('admincp.create_plugin'))->setBreadcrumb(Phpfox::getPhrase('admincp.create_plugin'), $this->url()->current(), true)->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aHooks' => Phpfox::getService('admincp.plugin')->getHooks(), 'bIsEdit' => $bIsEdit)); }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; if (($iId = $this->request()->getInt('id')) && ($aComponent = Phpfox::getService('admincp.component')->getForEdit($iId))) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aComponent)); } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'component' => Phpfox::getPhrase('admincp.specify_component'), 'is_active' => Phpfox::getPhrase('admincp.select_component_active'), 'type' => Phpfox::getPhrase('admincp.select_component_type')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('admincp.component.process')->update($iId, $aVals)) { $this->url()->send('admincp.component.add', array('id' => $iId), Phpfox::getPhrase('admincp.component_successfully_updated')); } } else { if (Phpfox::getService('admincp.component.process')->add($aVals)) { $this->url()->send('admincp.component', null, Phpfox::getPhrase('admincp.component_successfully_added')); } } } } $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('admincp.editing_component') : Phpfox::getPhrase('admincp.add_component'))->setBreadcrumb(Phpfox::getPhrase('admincp.manage_components'), $this->url()->makeUrl('admincp.component'))->setBreadCrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing_component') : Phpfox::getPhrase('admincp.add_component'), null, true)->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit)); }
/** * Controller */ public function process() { // assign the categories $this->template()->assign(array('aCategories' => Phpfox::getService('contact.contact')->getCategories())); // create the captcha check JS // they need to input some text always $aValidation = array('text' => Phpfox::getPhrase('contact.fill_in_some_text_for_your_message'), 'category_id' => Phpfox::getPhrase('contact.you_need_to_choose_a_category'), 'subject' => Phpfox::getPhrase('contact.provide_a_subject'), 'full_name' => Phpfox::getPhrase('contact.provide_your_full_name')); // do they need to complete a captcha challenge? if (Phpfox::isModule('captcha') && Phpfox::getParam('contact.contact_enable_captcha')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } // They always need to input their email address $aValidation['email'] = array('def' => 'email', 'title' => Phpfox::getPhrase('contact.provide_a_valid_email')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_contact_form', 'aParams' => $aValidation)); // check if we're getting a request: if ($aVals = $this->request()->getArray('val')) { // check the fields are valid if ($oValid->isValid($aVals)) { if (Phpfox::getService('contact.contact')->sendContactMessage($aVals)) { if (!empty($aVals['category_id']) && $aVals['category_id'] == 'phpfox_sales_ticket') { $this->url()->send('contact', array('sent' => 'true')); } else { $this->url()->send('contact', null, Phpfox::getPhrase('contact.your_message_was_successfully_sent')); } } else { $this->template()->assign(array('aContactErrors' => Phpfox_Error::set(Phpfox::getPhrase('error.site_email_not_set')))); } } } if (Phpfox::isUser()) { $this->template()->assign(array('sFullName' => Phpfox::getUserBy('full_name'), 'sEmail' => Phpfox::getUserBy('email'))); } $this->template()->setTitle(Phpfox::getPhrase('contact.contact_us'))->setBreadcrumb(Phpfox::getPhrase('contact.contact_us'))->assign(array('sCreateJs' => $oValid->createJs(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsSent' => $this->request()->get('sent')))->setFullSite(); }
/** * Controller */ public function process() { $aValidation = array('name' => Phpfox::getPhrase('forum.provide_a_name_for_your_forum')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $bIsEdit = false; if ($iId = $this->request()->getInt('id')) { $bIsEdit = true; Phpfox::getUserParam('forum.can_edit_forum', true); $aForum = Phpfox::getService('forum')->getForEdit($iId); $this->template()->assign('aForms', $aForum); } else { Phpfox::getUserParam('forum.can_add_new_forum', true); } if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('forum.process')->update($aForum['forum_id'], $aVals)) { $this->url()->send('admincp.forum', null, Phpfox::getPhrase('forum.forum_successfully_updated')); } } else { if (Phpfox::getService('forum.process')->add($aVals)) { $this->url()->send('admincp.forum.add', null, Phpfox::getPhrase('forum.forum_successfully_added')); } } } } $sTitle = $bIsEdit ? Phpfox::getPhrase('forum.editing_forum') . ': ' . $aForum['name'] : Phpfox::getPhrase('forum.create_new_form'); $this->template()->setTitle($sTitle)->setBreadCrumb($sTitle, $this->url()->makeUrl('admincp.forum'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sForumParents' => Phpfox::getService('forum')->active($bIsEdit ? $aForum['parent_id'] : $this->request()->getInt('child'))->edit($bIsEdit ? $aForum['forum_id'] : 0)->getJumpTool(true, $bIsEdit))); }
/** * Controller */ public function process() { Phpfox::getUserParam('language.can_manage_lang_packs', true); $bNoJsValidation = $this->getParam('bNoJsValidation'); $aModules = Phpfox::getService('admincp.module')->getModules(); $aLanguages = Phpfox::getService('language')->get(); if ($sPhrase = $this->getParam('sVar')) { $aParts = explode('.', $sPhrase); $sPhrase = $aParts[1]; } /* $aValidation = array( 'var_name' => array( 'def' => 'required', 'title' => Phpfox::getPhrase('language.select_varname') ) ); */ $aValidation = array(); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_phrase_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if (empty($aVals['var_name']) && isset($aVals['text']['en'])) { $aVals['var_name'] = $aVals['text']['en']; } if (empty($aVals['var_name'])) { Phpfox_Error::set('Provide a var name.'); } // Check that all the fields are valid if ($oValid->isValid($aVals)) { // Check to make sure the phrase has not already been added if ($sIsPhrase = Phpfox::getService('language.phrase')->isPhrase($aVals)) { Phpfox_Error::set(Phpfox::getPhrase('language.phrase_already_created', array('phrase' => $sIsPhrase)) . ' - ' . Phpfox::getPhrase($sIsPhrase)); $sCachePhrase = $sIsPhrase; } else { $sVarName = Phpfox::getService('language.phrase.process')->prepare($aVals['var_name']); if (isset($aVals['module'])) { $aParts = explode('|', $aVals['module']); $sVarName = $aParts[1] . '.' . $sVarName; } $sCached = Phpfox::getPhrase('language.phrase_added', array('phrase' => $sVarName)); // Add the new phrase $sPhrase = Phpfox::getService('language.phrase.process')->add($aVals); // Verify if we have a return URL, if we do send them there instead if ($sReturn = $this->request()->get('return')) { $this->url()->forward($sReturn, $sCached); } else { Phpfox::getLib('session')->set('cache_new_phrase', $sVarName); // Phrase added lets send them back to the same page with a message that the phrase was added $this->url()->send('admincp.language.phrase.add', array('last-module' => $aParts[1]), $sCached); } } } } if (!isset($sCachePhrase) && ($sCachePhrase = Phpfox::getLib('session')->get('cache_new_phrase'))) { Phpfox::getLib('session')->remove('cache_new_phrase'); } // Assign needed vars to the template $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => $aModules, 'aLanguages' => $aLanguages, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $bNoJsValidation ? 'return true;' : $oValid->getJsForm(), 'sReturn' => ($sReturn = $this->request()->get('return')) ? $sReturn : $this->getParam('sReturnUrl'), 'sVar' => $sPhrase, 'sCachePhrase' => isset($sCachePhrase) ? $sCachePhrase : '', 'sLastModuleId' => $this->request()->get('last-module')))->setBreadCrumb(Phpfox::getPhrase('language.add_phrase'), $this->url()->current(), true)->setTitle(Phpfox::getPhrase('language.add_phrase')); ($sPlugin = Phpfox_Plugin::get('language.component_controller_admincp_phrase_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $this->url()->send('music'); Phpfox::isUser(true); if (Phpfox::getParam('music.music_user_group_id') == Phpfox::getUserBy('user_group_id')) { $this->url()->send('music'); } $aUser = array('full_name' => Phpfox::getUserBy('full_name')); $aSettings = Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), Phpfox::getUserId(), Phpfox::getParam('music.music_user_group_id')); $aParams = array('full_name' => Phpfox::getPhrase('music.provide_a_artist_band_name'), 'agree' => Phpfox::getPhrase('music.tick_the_box_to_agree_to_our_terms_and_privacy_policy')); foreach ($aSettings as $sKey => $aSetting) { if ($aSetting['is_required']) { $aParams['custom_field_' . $aSetting['field_id']] = array('title' => Phpfox::getPhrase('music.provide_a_value_for') . ': ' . Phpfox::getPhrase($aSetting['phrase_var_name']), 'def' => 'required', 'php_id' => 'custom[' . $aSetting['field_id'] . ']'); } } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aParams)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if (Music_Service_Process::instance()->convertMember($aVals, $this->request()->getArray('custom'))) { $this->url()->send('music', null, Phpfox::getPhrase('music.you_have_successfully_converted_your_account')); } } } $this->template()->setTitle(Phpfox::getPhrase('music.musician_registration'))->setBreadcrumb(Phpfox::getPhrase('music.music'), $this->url()->makeUrl('music'))->setBreadcrumb(Phpfox::getPhrase('music.registration'), null, true)->setFullSite()->assign(array('aForms' => $aUser, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aSettings' => $aSettings)); }
/** * Controller */ public function process() { $aValidation = array('message' => Phpfox::getPhrase('mail.add_reply')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $aMail = Mail_Service_Mail::instance()->getMail($this->request()->getInt('id')); if (!isset($aMail['mail_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message')); } $bCanView = false; if ($aMail['viewer_user_id'] == Phpfox::getUserId() || $aMail['owner_user_id'] == Phpfox::getUserId()) { $bCanView = true; } if ($bCanView === false) { return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message')); } if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { $aVals['to'] = $aMail['owner_user_id']; if ($iNewId = Mail_Service_Process::instance()->add($aVals)) { $this->url()->send('mail.view', array('id' => $iNewId)); } } } if ($aMail['viewer_user_id'] == Phpfox::getUserId()) { Mail_Service_Process::instance()->toggleView($aMail['mail_id'], false); } $this->template()->assign(array('bMobileInboxIsActive' => true, 'aMail' => $aMail)); }
/** * Controller */ public function process() { $aValidation = array('name' => Phpfox::getPhrase('photo.provide_a_name_for_your_photo_category')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if (($aOrder = $this->request()->getArray('order')) && Phpfox::getUserParam('photo.can_edit_photo_categories', true) && Phpfox::getService('photo.category.process')->updateOrder($aOrder)) { $this->url()->send('admincp.photo', null, Phpfox::getPhrase('photo.photo_category_order_successfully_updated')); } if (!Phpfox::getUserParam('photo.can_add_public_categories') && !Phpfox::getUserParam('photo.can_edit_photo_categories')) { return Phpfox_Error::display(Phpfox::getPhrase('photo.invalid_section')); } if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if (isset($aVals['delete']) && Phpfox::getUserParam('photo.can_edit_photo_categories', true)) { if (Phpfox::getService('photo.category.process')->delete($aVals['edit_id'])) { $this->url()->send('admincp.photo', null, Phpfox::getPhrase('photo.photo_category_successfully_deleted')); } } else { if (isset($aVals['edit_id'])) { Phpfox::getUserParam('photo.can_edit_photo_categories', true); if (Phpfox::getService('photo.category.process')->update($aVals)) { $this->url()->send('admincp.photo', null, Phpfox::getPhrase('photo.photo_category_successfully_updated')); } } else { Phpfox::getUserParam('photo.can_add_public_categories', true); if (Phpfox::getService('photo.category.process')->add($aVals)) { $this->url()->send('admincp.photo', null, Phpfox::getPhrase('photo.photo_category_successfully_added')); } } } } } $this->template()->setTitle(Phpfox::getPhrase('photo.manage_photo_categories'))->setBreadCrumb(Phpfox::getPhrase('photo.manage_photo_categories'), $this->url()->makeUrl('admincp.photo'))->setHeader('cache', array('admin.js' => 'module_photo', 'jquery/ui.js' => 'static_script', 'sort.js' => 'module_photo'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm())); }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; if ($iEditId = $this->request()->get('id')) { $aProduct = Admincp_Service_Product_Product::instance()->getForEdit($iEditId); if (isset($aProduct['product_id'])) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aProduct, 'aDependencies' => Admincp_Service_Product_Product::instance()->getDependencies($aProduct['product_id']), 'aInstalls' => Admincp_Service_Product_Product::instance()->getInstalls($aProduct['product_id']))); } } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.add_a_product_id'), 'title' => Phpfox::getPhrase('admincp.add_a_product_title')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { $oAdmincpProductProcess = Phpfox::getService('admincp.product.process'); if (isset($aVals['dependency'])) { if (isset($aVals['dependency']['delete'])) { foreach ($aVals['dependency']['delete'] as $iDeleteId) { $bDeleted = $oAdmincpProductProcess->deleteDependency($iDeleteId); } } if (isset($aVals['dependency']['update'])) { foreach ($aVals['dependency']['update'] as $iDependencyId => $aDependency) { $oAdmincpProductProcess->updateDependency($iDependencyId, $aDependency); } } $bAdded = $oAdmincpProductProcess->addDependency($aVals['dependency']); $this->url()->send('admincp', array('product', 'add', 'id' => $aVals['dependency']['product_id']), Phpfox::getPhrase('admincp.product_dependency_updated')); } elseif (isset($aVals['install'])) { if (isset($aVals['install']['delete'])) { foreach ($aVals['install']['delete'] as $iDeleteId) { $bDeleted = $oAdmincpProductProcess->deleteInstall($iDeleteId); } } if (isset($aVals['install']['update'])) { foreach ($aVals['install']['update'] as $iInstallId => $aInstallUpdate) { $oAdmincpProductProcess->updateInstall($iInstallId, $aInstallUpdate); } } $bAdded = $oAdmincpProductProcess->addInstall($aVals['install']); $this->url()->send('admincp', array('product', 'add', 'id' => $aVals['install']['product_id']), Phpfox::getPhrase('admincp.product_install_uninstall_updated')); } else { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('admincp.product.process')->update($aProduct['product_id'], $aVals)) { $this->url()->send('admincp', array('product', 'add', 'id' => $aProduct['product_id']), Phpfox::getPhrase('admincp.product_successfully_updated')); } } else { if ($sName = Phpfox::getService('admincp.product.process')->add($aVals)) { $this->url()->send('admincp', array('product'), Phpfox::getPhrase('admincp.product_successfully_created')); } } } } } $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('admincp.editing_product') . ': ' . $aProduct['title'] : Phpfox::getPhrase('admincp.create_new_product'))->setBreadcrumb(Phpfox::getPhrase('admincp.products'), $this->url()->makeUrl('admincp.product'))->setBreadCrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing_product') . ': ' . $aProduct['title'] : Phpfox::getPhrase('admincp.create_new_product'), $this->url()->current(), true)->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit)); }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; if (($iEditId = $this->request()->get('id')) || ($iEditId = $this->request()->get('module_id'))) { Phpfox::getUserParam('admincp.can_manage_modules', true); $aRow = Phpfox::getService('admincp.module')->getForEdit($iEditId); $bIsEdit = true; if ($aRow['is_menu'] && !empty($aRow['menu'])) { $aMenus = unserialize($aRow['menu']); $aSubs = array(); foreach ($aMenus as $sPhrase => $aMenu) { $aParts = explode('.', $sPhrase); $aSubs[] = array('phrase' => Phpfox::getService('language.phrase')->getStaticPhrase($sPhrase), 'link' => implode('.', $aMenu['url']), 'var_name' => $aParts[1]); } $aRow['menu'] = $aSubs; } $this->template()->assign(array('aForms' => $aRow)); } else { Phpfox::getUserParam('admincp.can_add_new_modules', true); } $aValidation = array('module_id' => Phpfox::getPhrase('admincp.select_name_for_your_module')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('admincp.module.process')->update($aRow['module_id'], $aVals)) { $this->url()->send('admincp', array('module', 'add', 'id' => $aRow['module_id']), Phpfox::getPhrase('admincp.module_successfully_updated')); } } else { if (Phpfox_Module::instance()->isModule($aVals['module_id'])) { Phpfox_Error::set(Phpfox::getPhrase('admincp.module_name_already_used')); } else { if ($sName = Phpfox::getService('admincp.module.process')->add($aVals)) { $this->url()->send('admincp', array('module'), Phpfox::getPhrase('admincp.module_successfully_created_redirect')); } } } } } $aVals = $this->request()->getArray('val'); $aMenus = array(); if (isset($aVals['menu']) || isset($aRow['menu'])) { $aSubMenus = $bIsEdit ? $aRow['menu'] : $aVals['menu']; if (is_array($aSubMenus) && count($aSubMenus)) { foreach ($aSubMenus as $iKey => $aMenu) { if (empty($aMenu['phrase'])) { continue; } $aMenus[$iKey] = $aMenu; } } } $this->template()->setBreadCrumb($bIsEdit ? 'Editing Module: ' . $aRow['module_id'] : Phpfox::getPhrase('admincp.create_module'), $this->url()->current(), true)->setTitle($bIsEdit ? 'Editing Module: ' . $aRow['module_id'] : Phpfox::getPhrase('admincp.create_module'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aLanguages' => $bIsEdit ? Phpfox::getService('language')->getWithPhrase($aRow['phrase_var_name']) : Phpfox::getService('language')->get(), 'sDir' => PHPFOX_DIR_MODULE, 'aMenus' => $aMenus, 'iMenus' => $bIsEdit && count($aRow['menu']) ? count($aRow['menu']) - 1 : (isset($aVals['menu']) ? count($aVals['menu']) - 1 : 3), 'sPhpfoxDs' => PHPFOX_DS, 'bIsEdit' => $bIsEdit)); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_module_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { Phpfox::isUser(true); if (!Phpfox::getParam('mail.threaded_mail_conversation')) { $this->url()->send('mail'); } $aVals = $this->request()->get('val'); if ($aVals && ($iNewId = Mail_Service_Process::instance()->add($aVals))) { list($aCon, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iNewId); $aMessages = array_reverse($aMessages); Phpfox_Template::instance()->assign(array('aMail' => $aMessages[0], 'aCon' => $aCon, 'bIsLastMessage' => true))->getTemplate('mail.block.entry'); $content = ob_get_contents(); ob_clean(); return ['append' => ['to' => '#mail_threaded_new_message', 'with' => $content]]; } $iThreadId = $this->request()->getInt('id'); list($aThread, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iThreadId); if ($aThread === false) { return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_find_a_conversation_history_with_this_user')); } $aValidation = array('message' => Phpfox::getPhrase('mail.add_reply')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aThread['user_is_archive']) { $this->request()->set('view', 'trash'); } Mail_Service_Mail::instance()->buildMenu(); Mail_Service_Process::instance()->threadIsRead($aThread['thread_id']); $iUserCnt = 0; $sUsers = ''; $bCanViewThread = false; foreach ($aThread['users'] as $aUser) { if ($aUser['user_id'] == Phpfox::getUserId()) { $bCanViewThread = true; } if ($aUser['user_id'] == Phpfox::getUserId()) { continue; } $iUserCnt++; if ($iUserCnt == count($aThread['users']) - 1 && count($aThread['users']) - 1 > 1) { $sUsers .= ' & '; } else { if ($iUserCnt != '1') { $sUsers .= ', '; } } $sUsers .= $aUser['full_name']; } if (!$bCanViewThread) { return Phpfox_Error::display('Unable to view this thread.'); } else { $this->template()->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setBreadcrumb($sUsers, $this->url()->makeUrl('mail.thread', array('id' => $iThreadId)), true); } $this->template()->setTitle($sUsers)->setTitle(Phpfox::getPhrase('mail.mail'))->setHeader('cache', array('mail.js' => 'module_mail', 'jquery/plugin/jquery.scrollTo.js' => 'static_script'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(false), 'aMessages' => $aMessages, 'aThread' => $aThread, 'sCurrentPageCnt' => $this->request()->getInt('page', 0) + 1)); $this->setParam('attachment_share', array('type' => 'mail', 'id' => 'js_form_mail')); $this->setParam('global_moderation', array('name' => 'mail', 'ajax' => 'mail.mailThreadAction', 'custom_fields' => '<div><input type="hidden" name="forward_thread_id" value="' . $aThread['thread_id'] . '" id="js_forward_thread_id" /></div>', 'menu' => array(array('phrase' => Phpfox::getPhrase('mail.forward'), 'action' => 'forward')))); }
/** * Controller */ public function process() { $oValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_genre_add', 'aParams' => array('name' => Phpfox::getPhrase('music.provide_a_genre_name')))); if ($aVals = $this->request()->getArray('val')) { if ($oValidator->isValid($aVals)) { if (Phpfox::getService('music.genre.process')->add($aVals)) { $this->url()->send('admincp.music.add', null, Phpfox::getPhrase('music.genre_successfully_added')); } } } $this->template()->setTitle(Phpfox::getPhrase('music.add_genre'))->setBreadcrumb(Phpfox::getPhrase('music.add_genre'), $this->url()->makeUrl('admincp.music'))->assign(array('sCreateJs' => $oValidator->createJS(), 'sGetJsForm' => $oValidator->getJsForm())); }
/** * Controller */ public function process() { $bIsEdit = false; $oSession = Phpfox::getLib('session'); $aValidation = array('product_id' => Phpfox::getPhrase('page.select_product'), 'title' => Phpfox::getPhrase('page.missing_title'), 'title_url' => Phpfox::getPhrase('page.missing_url_title'), 'is_active' => Phpfox::getPhrase('page.specify_page_active'), 'text' => Phpfox::getPhrase('page.page_missing_data')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if (($iPageId = $this->request()->getInt('id')) || ($iPageId = $this->request()->getInt('page_id'))) { Phpfox::getUserParam('page.can_manage_custom_pages', true); $aPage = Phpfox::getService('page')->getForEdit($iPageId); if (isset($aPage['page_id'])) { $bIsEdit = true; // $aPage['attachment'] = (Phpfox::isModule('attachment') ? Phpfox::getService('attachment')->getForItemEdit($aPage['page_id'], 'page', Phpfox::getUserId()) : ''); if (Phpfox::isModule('tag')) { $aTags = Tag_Service_Tag::instance()->getTagsById('page', $aPage['page_id']); if (isset($aTags[$aPage['page_id']])) { $aPage['tag_list'] = ''; foreach ($aTags[$aPage['page_id']] as $aTag) { $aPage['tag_list'] .= ' ' . $aTag['tag_text'] . ','; } $aPage['tag_list'] = trim(trim($aPage['tag_list'], ',')); } } $this->template()->assign(array('aForms' => $aPage, 'aAccess' => empty($aPage['disallow_access']) ? null : unserialize($aPage['disallow_access']))); } } if ($aVals = $this->request()->getArray('val')) { Phpfox::getLib('parse.input')->allowTitle(Phpfox::getLib('parse.input')->cleanTitle($aVals['title_url']), Phpfox::getPhrase('page.invalid_title')); if ($oValid->isValid($aVals)) { if ($bIsEdit) { $sMessage = Phpfox::getPhrase('page.page_successfully_updated'); $sReturn = Phpfox::getService('page.process')->update($aPage['page_id'], $aVals, $aPage['user_id']); $aUrl = null; } else { $sMessage = Phpfox::getPhrase('page.successfully_added'); $sReturn = Phpfox::getService('page.process')->add($aVals); $aUrl = null; } if ($sReturn) { return ['redirect' => $this->url()->makeUrl($sReturn, null, $sMessage)]; } } else { $aError = Phpfox_Error::get(); $sError = ''; if (is_array($aError)) { $sError = implode(' ', $aError); } else { $sError = $aError; } return ['error' => $sError]; } } $this->template()->setSectionTitle('<a href="' . $this->url()->makeUrl('admincp.page') . '">Custom Pages</a>')->setTitle(Phpfox::getPhrase('page.add_new_page'))->setBreadCrumb(Phpfox::getPhrase('page.add_new_page'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aModules' => Phpfox_Module::instance()->getModules(), 'bFormIsPosted' => count($aVals) ? true : false))->setEditor()->setHeader(array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_menu.js' => 'static_script', '<script type="text/javascript">var Attachment = {sCategory: "page", iItemId: "' . (isset($aPage['page_id']) ? $aPage['page_id'] : '') . '"};</script>')); }
/** * Controller */ public function process() { $aValidation = array('name' => Phpfox::getPhrase('blog.provide_blog_category')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if (Phpfox::getService('blog.category.process')->add($aVals['name'], '0')) { $this->url()->send('admincp.blog.add', null, Phpfox::getPhrase('blog.category_successfully_added')); } } } $this->template()->setTitle(Phpfox::getPhrase('blog.add_category'))->setBreadCrumb(Phpfox::getPhrase('blog.add_category'), $this->url()->makeUrl('admincp.blog'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm())); }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'hook_type' => Phpfox::getPhrase('admincp.select_what_type_of_a_hook_this_is')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('admincp.plugin.process')->addHook($aVals)) { $this->url()->send('admincp.plugin.hook.add', null, Phpfox::getPhrase('admincp.hook_successfully_added')); } } $this->template()->setTitle(Phpfox::getPhrase('admincp.add_hook'))->setBreadCrumb(Phpfox::getPhrase('admincp.add_hook'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aHookTypes' => array('library', 'service', 'component', 'template'))); }
/** * Controller */ public function process() { Phpfox::getUserParam('admincp.can_add_new_block', true); $bIsEdit = false; if (($iEditId = $this->request()->getInt('id')) || ($iEditId = $this->request()->getInt('block_id'))) { $aRow = Admincp_Service_Block_Block::instance()->getForEdit($iEditId); $bIsEdit = true; $this->template()->assign(array('aForms' => $aRow, 'aAccess' => empty($aRow['disallow_access']) ? null : unserialize($aRow['disallow_access']))); } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'location' => Phpfox::getPhrase('admincp.select_block_placement'), 'is_active' => Phpfox::getPhrase('admincp.specify_block_active')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { $sMessage = Phpfox::getPhrase('admincp.successfully_updated'); $aUrl = array('block', 'add', 'id' => $aRow['block_id']); Phpfox::getService('admincp.block.process')->update($aRow['block_id'], $aVals); } else { $sMessage = Phpfox::getPhrase('admincp.block_successfully_added'); $aUrl = array('block'); Phpfox::getService('admincp.block.process')->add($aVals); } $this->url()->send('admincp', $aUrl, $sMessage); } } if (Phpfox::getParam('core.enabled_edit_area')) { $this->template()->setHeader(array('editarea/edit_area_full.js' => 'static_script', '<script type="text/javascript"> editAreaLoader.init({ id: "source_code" ,start_highlight: true ,allow_resize: "both" ,allow_toggle: false ,word_wrap: false ,language: "en" ,syntax: "php" }); </script>')); } $aStyles = Theme_Service_Style_Style::instance()->getStyles(); if ($bIsEdit) { foreach ($aStyles as $iKey => $aStyle) { if (isset($aRow['style_id']) && isset($aRow['style_id'][$aStyle['style_id']])) { $aStyles[$iKey]['block_is_selected'] = $aRow['style_id'][$aStyle['style_id']]; } } } $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aControllers' => Phpfox::getService('admincp.component')->get(true), 'aComponents' => Phpfox::getService('admincp.component')->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aStyles' => $aStyles))->setTitle(Phpfox::getPhrase('admincp.block_manager'))->setBreadcrumb(Phpfox::getPhrase('admincp.block_manager'), $this->url()->makeUrl('admincp.block'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing') . ': ' . (empty($aRow['m_connection']) ? Phpfox::getPhrase('admincp.site_wide') : $aRow['m_connection']) . (empty($aRow['component']) ? '' : '::' . rtrim(str_replace('|', '::', $aRow['component']), '::')) . (empty($aRow['title']) ? '' : ' (' . Phpfox_Locale::instance()->convert($aRow['title']) . ')') : Phpfox::getPhrase('admincp.add_new_block'), $this->url()->makeUrl('admincp.block.add'), true)->setTitle(Phpfox::getPhrase('admincp.add_new_block')); }
/** * Controller */ public function process() { Phpfox::getUserParam('user.can_add_user_group_setting', true); $aGroups = Phpfox::getService('user.group')->get('user_group.is_special = 1'); $aForms = array(); if (($iSetting = $this->request()->getInt('id')) && ($aForms = Phpfox::getService('user.group.setting')->getSetting($iSetting)) && isset($aForms['setting_id'])) { foreach ($aGroups as $iKey => $aGroup) { if ($aGroup['user_group_id'] == '1') { $aGroups[$iKey]['value'] = $aForms['default_admin']; } elseif ($aGroup['user_group_id'] == '3') { $aGroups[$iKey]['value'] = $aForms['default_guest']; } elseif ($aGroup['user_group_id'] == '4') { $aGroups[$iKey]['value'] = $aForms['default_staff']; } else { $aGroups[$iKey]['value'] = $aForms['default_user']; } } } if (!$this->request()->getInt('id')) { $this->url()->send('admincp'); } $aValidation = array('name' => Phpfox::getPhrase('user.select_varname')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { // Check that all the fields are valid if ($oValid->isValid($aVals)) { if (isset($aForms['setting_id'])) { if (Phpfox::getService('user.group.setting.process')->updateSetting(array_merge($aVals, array('setting_id' => $aForms['setting_id'])))) { $this->url()->send('admincp', array('user', 'group', 'add', 'id' => $this->request()->getInt('gid'), '#setting' . $aForms['setting_id']), Phpfox::getPhrase('user.setting_successfully_updated')); } } else { if (Phpfox::getService('user.group.setting.process')->addSetting($aVals)) { $this->url()->send('admincp', array('user', 'group', 'setting'), Phpfox::getPhrase('user.setting_successfully_added')); } } } } if ($sCacheSetting = Phpfox::getLib('session')->get('cache_new_user_setting')) { Phpfox::getLib('session')->remove('cache_new_user_setting'); } if (isset($aForms['name'])) { Phpfox_Database::instance()->select('language_phrase.text, ')->leftJoin(Phpfox::getT('language_phrase'), 'language_phrase', "language_phrase.language_id = l.language_id AND language_phrase.var_name = 'user_setting_{$aForms['name']}'"); } $aLanguages = Phpfox::getService('language')->get(); $this->template()->setBreadcrumb(Phpfox::getPhrase('user.user_groups'), $this->url()->makeUrl('admincp.user.group'))->setBreadcrumb(Phpfox::getPhrase('user.manage_user_groups'), $this->url()->makeUrl('admincp.user.group'))->setBreadcrumb(Phpfox::getPhrase('user.add_user_group_setting'), null, true)->setTitle(Phpfox::getPhrase('user.add_user_group_setting'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'aLanguages' => $aLanguages, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aTypes' => array('boolean', 'integer', 'string', 'array'), 'aUserGroups' => $aGroups, 'sCacheSetting' => $sCacheSetting, 'aForms' => $aForms, 'iGroupId' => $this->request()->getInt('gid'))); ($sPlugin = Phpfox_Plugin::get('user.component_controller_admincp_group_setting_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $aValidation = array('var_name' => Phpfox::getPhrase('admincp.add_a_title_for_the_group'), 'info' => Phpfox::getPhrase('admincp.add_information_regarding_group')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_setting_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($sVarName = Phpfox::getService('admincp.setting.group.process')->add($aVals)) { $this->url()->send('admincp.setting.group.add', null, Phpfox::getPhrase('admincp.added') . ': ' . $sVarName); } } } $this->template()->setBreadCrumb(Phpfox::getPhrase('admincp.add_setting_group'))->setTitle(Phpfox::getPhrase('admincp.add_setting_group'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aModules' => Phpfox_Module::instance()->getModules())); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_group_add_process')) ? eval($sPlugin) : false; }
/** * Controller * @todo Complete the update routine... */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } Phpfox::getUserParam('core.can_add_new_setting', true); $bEdit = false; if ($iId = $this->request()->getInt('id')) { $aSetting = Phpfox::getService('admincp.setting')->getForEdit($iId); if (is_array($aSetting) && isset($aSetting['setting_id'])) { $bEdit = true; $this->url()->send('admincp.setting'); $this->template()->assign(array('aForms' => $aSetting)); } } $aValidation = array('var_name' => array('def' => 'required', 'title' => Phpfox::getPhrase('admincp.add_variable_name')), 'title' => array('def' => 'required', 'title' => Phpfox::getPhrase('admincp.add_title_for_setting')), 'info' => array('def' => 'required', 'title' => Phpfox::getPhrase('admincp.add_information_regarding_setting'))); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_setting_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bEdit) { exit('Updating...'); } else { if ($sSetting = Phpfox::getService('admincp.setting')->isSetting($aVals['var_name'])) { Phpfox_Error::set(Phpfox::getPhrase('admincp.already_in_use') . ': ' . $sSetting); } else { if ($sSetting = Phpfox::getService('admincp.setting.process')->add($aVals)) { $this->url()->send('admincp', array('setting', 'add'), Phpfox::getPhrase('admincp.added') . ': ' . $sSetting); } } } } } $aGroups = Phpfox::getService('admincp.setting.group')->getGroups(); foreach ($aGroups as $iKey => $aGroup) { if (!isset($aGroup['var_name'])) { unset($aGroups[$iKey]); continue; } } $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aGroups' => $aGroups, 'aModules' => Phpfox_Module::instance()->getModules(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bEdit' => $bEdit))->setBreadCrumb(Phpfox::getPhrase('admincp.add_setting'))->setTitle(Phpfox::getPhrase('admincp.add_setting')); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { Phpfox::isUser(true); $sModule = $this->request()->get('module', false); $iItem = $this->request()->getInt('item', false); // Get the total number of albums this user has $iTotalAlbums = Phpfox::getService('photo.album')->getAlbumCount(Phpfox::getUserId()); // Check if they are allowed to create new albums $bAllowedAlbums = Phpfox::getUserParam('photo.max_number_of_albums') == 'null' ? true : (!Phpfox::getUserParam('photo.max_number_of_albums') ? false : (Phpfox::getUserParam('photo.max_number_of_albums') <= $iTotalAlbums ? false : true)); // Check if we have set a session storage for the form. if ($aSessionVals = Phpfox::getLib('session')->get('photo_album_form')) { // We have stored the form in a session, lets destroy it now. Phpfox::getLib('session')->remove('photo_album_form'); // Lets assign the past form data so we can reuse it. $this->template()->assign(array('aForms' => $aSessionVals)); } $aValidation = array('name' => Phpfox::getPhrase('photo.provide_a_name_for_your_album'), 'privacy' => Phpfox::getPhrase('photo.select_a_privacy_setting_for_your_album')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_create_new_album', 'aParams' => $aValidation)); $this->template()->assign(array('bAllowedAlbums' => $bAllowedAlbums, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(false), 'sModule' => $sModule, 'iItem' => $iItem)); }
/** * 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)); }
/** * Controller */ public function process() { $bFriendIsSelected = false; if ($iUserId = $this->request()->getInt('to')) { $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField()); if (isset($aUser['user_id'])) { //if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'mail.send_message')) if (!Mail_Service_Mail::instance()->canMessageUser($aUser['user_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_send_a_private_message_to_this_user_at_the_moment')); } $bFriendIsSelected = true; $this->template()->assign('aUser', $aUser); } } if (Phpfox::getParam('mail.spam_check_messages') && Phpfox::isSpammer()) { return Phpfox_Error::display(Phpfox::getPhrase('mail.currently_your_account_is_marked_as_a_spammer')); } $aValidation = array('subject' => Phpfox::getPhrase('mail.provide_subject_for_your_message'), 'message' => Phpfox::getPhrase('mail.provide_message')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { // Lets make sure they are actually trying to send someone a message. if ((!isset($aVals['to']) || isset($aVals['to']) && !count($aVals['to'])) && (!isset($aVals['copy_to_self']) || $aVals['copy_to_self'] != 1)) { Phpfox_Error::set(Phpfox::getPhrase('mail.select_a_member_to_send_a_message_to')); } if ($oValid->isValid($aVals)) { if (Phpfox::getParam('mail.mail_hash_check')) { Phpfox::getLib('spam.hash', array('table' => 'mail_hash', 'total' => Phpfox::getParam('mail.total_mail_messages_to_check'), 'time' => Phpfox::getParam('mail.total_minutes_to_wait_for_pm'), 'content' => $aVals['message']))->isSpam(); } if (Phpfox::getParam('mail.spam_check_messages')) { if (Phpfox::getLib('spam')->check(array('action' => 'isSpam', 'params' => array('module' => 'comment', 'content' => Phpfox::getLib('parse.input')->prepare($aVals['message']))))) { Phpfox_Error::set(Phpfox::getPhrase('mail.this_message_feels_like_spam_try_again')); } } if (Phpfox_Error::isPassed()) { $aIds = Mail_Service_Process::instance()->add($aVals); $this->url()->send('mail.view', array('id' => $aIds[0])); } } } $this->template()->assign(array('bMobileInboxIsActive' => true, 'bFriendIsSelected' => $bFriendIsSelected, 'aMobileSubMenus' => array($this->url()->makeUrl('mail') => Phpfox::getPhrase('mail.mobile_messages'), $this->url()->makeUrl('mail', 'sent') => Phpfox::getPhrase('mail.sent'), $this->url()->makeUrl('mail', 'compose') => Phpfox::getPhrase('mail.compose')), 'sActiveMobileSubMenu' => $this->url()->makeUrl('mail', 'compose'))); }
/** * Controller */ public function process() { // When they first submit the newsletter this block adds it to the ongoing or scheduling if ($aVals = $this->request()->getArray('val')) { $aNewsletter = Phpfox::getService('newsletter.process')->add($aVals, Phpfox::getUserId()); if ($aNewsletter['state'] == 1) { $this->url()->send('admincp.newsletter.add', array('job' => $aNewsletter['newsletter_id']), Phpfox::getPhrase('newsletter.processing_job_newsletter_id', array('newsletter_id' => $aNewsletter['newsletter_id']))); } elseif ($aNewsletter === false) { } else { $this->url()->send('admincp.newsletter.manage', null, null); } } elseif ($iJob = $this->request()->getInt('job')) { list($iContinue, $iPerc) = Phpfox::getService('newsletter.process')->processJob($iJob); if (is_int($iContinue) && $iPerc < 100) { $sMessage = Phpfox::getPhrase('newsletter.5_seconds_break_processing_job_continue_total_completed_perc', array('continue' => $iContinue, 'perc' => $iPerc)); $sLink = $this->url()->makeUrl('admincp.newsletter.add', array('job' => $iContinue)); $this->template()->setHeader('<META HTTP-EQUIV="refresh" content="5;URL=' . $sLink . '">')->assign(array('sMessage' => $sMessage)); //$this->url()->send('admincp.newsletter.add', array('job' => $iContinue)); } elseif ($iContinue === true || $iPerc >= 100) { $this->url()->send('admincp.newsletter.manage', null, Phpfox::getPhrase('newsletter.job_completed_successfully')); } elseif ($iContinue === false) { $this->url()->send('admincp.newsletter.manage', null, Phpfox::getPhrase('newsletter.there_was_a_problem_with_this_job_feel_free_to_resume_it_at_any_time')); } } if ($iId = $this->request()->getInt('id') || ($iId = $this->request()->getInt('job'))) { $aNewsletter = Phpfox::getService('newsletter')->get($iId); $this->template()->assign(array('aForms' => $aNewsletter)); } $aValidation = array('type_id' => array('title' => Phpfox::getPhrase('newsletter.select_a_newsletter_type'), 'def' => 'int')); // 2 = html; 1 = plain text; $oValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $aAge = array(); for ($i = 18; $i <= 68; $i++) { $aAge[$i] = $i; } $this->template()->assign(array('aAge' => $aAge, 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValidator->createJS(), 'sGetJsForm' => $oValidator->getJsForm()))->setTitle(Phpfox::getPhrase('newsletter.newsletter'))->setBreadCrumb(Phpfox::getPhrase('newsletter.newsletter'), $this->url()->makeUrl('admincp.newsletter.add'))->setBreadCrumb(Phpfox::getPhrase('newsletter.add_newsletter'), null, true)->setPhrase(array('newsletter.min_age_cannot_be_higher_than_max_age', 'newsletter.max_age_cannot_be_lower_than_the_min_age'))->setEditor()->setHeader(array('add.js' => 'module_newsletter')); }
public function verifyUsername() { if (!Phpfox::getParam('user.suggest_usernames_on_registration')) { return false; } $aUser = array('user_name' => $this->get('user_name')); $aUser['user_name'] = str_replace(' ', '_', $aUser['user_name']); Phpfox_Validator::instance()->verify('username', $aUser['user_name']); if (!Phpfox_Error::isPassed()) { return false; } if ($this->searchUserName($aUser)) { // this username is valid $this->html('#js_verify_username', '<div class="valid_message">' . Phpfox::getPhrase('user.this_username_is_available') . '</div>')->show('#js_verify_username'); } else { // get X suggestions as usernames and check them $iFailedTries = 0; $aValidNames = array(); // filter the username so it only allows a-z, A-Z, numbers, dash (-) and underscore (_) $sValidUsername = ''; if (strlen($aUser['user_name']) > 0) { for ($i = 0; $i < strlen($aUser['user_name']); $i++) { if (preg_match('/[-a-zA-Z0-9_]/i', $aUser['user_name'][$i]) !== false) { $sValidUsername .= $aUser['user_name'][$i]; } } } $aSuggestedNames = Phpfox::getParam('user.usernames_to_suggest'); $aSuggestedNames[] = $sValidUsername; // check user.validate --> eregi("[a-zA-Z] use this to get the valid part of the username and generate the new usernames $iRand = rand(100, 999); while (count($aValidNames) < Phpfox::getParam('user.how_many_usernames_to_suggest')) { $sTry = $aSuggestedNames[array_rand($aSuggestedNames)] . $iRand; if (Phpfox_Validator::instance()->verify('username', $sTry) && Phpfox::getLib('parse.input')->allowTitle($sTry, 'Username is already in use.') && Phpfox::getService('ban')->check('username', $sTry)) { $aValidNames[] = $sTry; $iRand = rand(100, 999); } elseif ($iFailedTries < 2) { // missed once, we increment the random value $iRand = rand(100, 9999); $iFailedTries++; } else { // ok now its too many break; } } Phpfox::getBlock('user.signup-error', array('aNames' => $aValidNames)); $this->html('#js_verify_username', $this->getContent(false))->show('#js_verify_username'); } }
/** * Controller */ public function process() { Phpfox::isUser(true); $bCanEditPersonalData = true; $aCallback = false; if ($this->request()->get('module')) { $this->template()->assign(array('bIsGroup' => '1')); } if (($sModule = $this->request()->get('module')) && Phpfox::isModule($sModule) && ($iItemId = $this->request()->getInt('item')) && Phpfox::hasCallback($sModule, 'addForum')) { $aCallback = Phpfox::callback($sModule . '.addForum', $iItemId); $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.pages'), $this->url()->makeUrl('pages')); $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']); $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.discussions'), $aCallback['url_home'] . 'forum/'); if ($sModule == 'pages' && !Phpfox::getService('pages')->hasPerm($iItemId, 'forum.share_forum')) { return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings')); } } else { $this->template()->setBreadcrumb(Phpfox::getPhrase('forum.forum'), $this->url()->makeUrl('forum')); } $iId = $this->request()->getInt('id'); $aAccess = Forum_Service_Forum::instance()->getUserGroupAccess($iId, Phpfox::getUserBy('user_group_id')); if ($aAccess['can_view_thread_content']['value'] != true) { return Phpfox_Error::display(Phpfox::getPhrase('forum.unable_to_view_this_item_due_to_privacy_settings')); } if (Phpfox::isModule('poll')) { $this->template()->setHeader('cache', array('poll.js' => 'module_poll', '<script type="text/javascript">$Behavior.loadSortableAnswers = function() {$(".sortable").sortable({placeholder: "placeholder", axis: "y"});}</script>')); } $this->template()->setEditor()->setTitle(Phpfox::getPhrase('forum.forum'))->setHeader('cache', array('switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'pager.css' => 'style_css', 'forum.css' => 'style_css')); $bIsEdit = false; if ($this->request()->get('req3') == 'thread') { if ($iEditId = $this->request()->getInt('edit')) { $aThread = Forum_Service_Thread_Thread::instance()->getForEdit($iEditId); if (!isset($aThread['thread_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread')); } if (Phpfox::getUserParam('forum.can_edit_own_post') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'edit_post')) { $bIsEdit = true; if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aThread['user_id']) { $bCanEditPersonalData = false; } $iId = $aThread['forum_id']; if (Phpfox::isModule('tag')) { $aThread['tag_list'] = Tag_Service_Tag::instance()->getForEdit('forum', $aThread['thread_id']); } $this->template()->assign(array('aForms' => $aThread, 'iEditId' => $aThread['thread_id'])); } else { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread')); } } if ($aCallback === false) { $aForum = Phpfox::getService('forum')->id($iId)->getForum(); if (!isset($aForum['forum_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum')); } if ($aForum['is_closed']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed')); } } if (!$bIsEdit) { $bPass = false; if (Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) { $bPass = true; } if ($bPass === false) { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread')); } } if (!Forum_Service_Forum::instance()->hasAccess($iId, 'can_start_thread')) { return Phpfox_Error::display('You are unable to create a new post in this forum.'); } $aValidation = array('title' => Phpfox::getPhrase('forum.provide_a_title_for_your_thread'), 'text' => Phpfox::getPhrase('forum.provide_some_text')); if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $bPosted = false; if ($aVals = $this->request()->getArray('val')) { if (isset($aVals['type_id']) && $aVals['type_id'] == 'announcement') { $bPosted = true; } if ($oValid->isValid($aVals)) { if ($bIsEdit) { $aVals['post_id'] = $aThread['start_id']; $aVals['was_announcement'] = $aThread['is_announcement']; $aVals['forum_id'] = $aThread['forum_id']; if (Phpfox::getService('forum.thread.process')->update($aThread['thread_id'], $aThread['user_id'], $aVals)) { $this->url()->permalink('forum.thread', $aThread['thread_id'], Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true, Phpfox::getPhrase('forum.thread_successfully_updated')); } } else { if (($iFlood = Phpfox::getUserParam('forum.forum_thread_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_thread'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_new_thread_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('forum.thread.process')->add($aVals, $aCallback))) { $this->url()->permalink('forum.thread', $iId, Phpfox::getLib('parse.input')->clean($aVals['title'], 255), true); } } } } if ($aCallback === false) { $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->permalink('forum', $aForum['forum_id'], $aForum['name']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true); } else { $this->template()->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_thread') . ': ' . $aThread['title'] : Phpfox::getPhrase('forum.post_new_thread'), $this->url()->makeUrl('forum.post.thread'), true); } $this->template()->assign(array('iForumId' => $iId, 'iActualForumId' => $iId, 'sFormLink' => $aCallback == false ? $this->url()->makeUrl('forum.post.thread', array('id' => $iId)) : $this->url()->makeUrl('forum.post.thread', array('module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sForumParents' => $aCallback === false ? Phpfox::getUserParam('forum.can_post_announcement') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'post_announcement') ? Phpfox::getService('forum')->active($aForum['forum_id'])->getJumpTool(true) : '' : '', 'bPosted' => $bPosted, 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback)); if (Phpfox::getUserParam('forum.can_add_forum_attachments')) { $this->setParam('attachment_share', array('type' => 'forum', 'id' => 'js_forum_form')); } } else { if ($iEditId = $this->request()->getInt('edit')) { $aPost = Phpfox::getService('forum.post')->getForEdit($iEditId); if (!isset($aPost['post_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_post')); } $bCanEditPost = Phpfox::getUserParam('forum.can_edit_own_post') && $aPost['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_edit_other_posts') || Phpfox::getService('forum.moderate')->hasAccess($aPost['forum_id'], 'edit_post'); if ($bCanEditPost) { $bIsEdit = true; if (Phpfox::getUserParam('forum.can_edit_other_posts') && Phpfox::getUserId() != $aPost['user_id']) { $bCanEditPersonalData = false; } $iId = $aPost['thread_id']; $this->template()->assign(array('aForms' => $aPost, 'iEditId' => $aPost['post_id'])); if (PHPFOX_IS_AJAX) { Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : Phpfox::getLib('parse.output')->shorten($aPost['title'], 80, '...'))); } } else { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_edit_this_thread')); } } $aThread = Forum_Service_Thread_Thread::instance()->getActualThread($iId, $aCallback); if (!isset($aThread['thread_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_thread')); } if ($aThread['is_closed'] && (isset($bCanEditPost) && !$bCanEditPost || !isset($bCanEditPost))) { return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_closed')); } if ($aCallback === false && $aThread['forum_is_closed']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed')); } if (!$iEditId && $aThread['is_announcement']) { return Phpfox_Error::display(Phpfox::getPhrase('forum.thread_is_an_announcement_not_allowed_to_leave_a_reply')); } if (!$bIsEdit) { $bPass = false; if (Phpfox::getUserParam('forum.can_reply_to_own_thread') && $aThread['user_id'] == Phpfox::getUserId() || Phpfox::getUserParam('forum.can_reply_on_other_threads') || Phpfox::getService('forum.moderate')->hasAccess($aThread['forum_id'], 'can_reply')) { $bPass = true; } if ($bPass === false) { return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread')); } } $sExtraText = ''; if ($sSavedText = $this->request()->get('save_text')) { $sExtraText .= Phpfox::getLib('parse.output')->clean($sSavedText); } if (Phpfox::getUserParam('forum.can_multi_quote_forum') && (($iQuote = $this->request()->getInt('quote')) || ($sCookie = Phpfox::getCookie('forum_quote')) && !empty($sCookie))) { $sCookie = Phpfox::getCookie('forum_quote'); if (!empty($sCookie)) { $iQuote = $sCookie . $iQuote; } $sExtraText .= Phpfox::getService('forum.post')->getQuotes($aThread['thread_id'], $iQuote); } if (($iQuoteId = $this->request()->getInt('quote')) && ($aQuotePost = Phpfox::getService('forum.post')->getForEdit($iQuoteId))) { Phpfox_Ajax::instance()->setTitle(Phpfox::getPhrase('forum.replying_to_a_post_by_full_name', array('full_name' => Phpfox::getLib('parse.output')->shorten($aQuotePost['full_name'], 80, '...')))); } $aSubForms = array(); if (isset($aThread['is_subscribed'])) { $aSubForms['is_subscribed'] = $aThread['is_subscribed']; } if (!empty($sExtraText)) { $aSubForms['text'] = $sExtraText; } if (isset($bCanEditPost) && $bCanEditPost) { $aSubForms = array_merge($aSubForms, $aPost); } $this->template()->assign('aForms', $aSubForms); $aValidation = array('text' => Phpfox::getPhrase('forum.provide_some_text')); if (Phpfox::isModule('captcha') && Phpfox::getUserParam('forum.enable_captcha_on_posting')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); $aForum = Phpfox::getService('forum')->id($aThread['forum_id'])->getForum(); if ($aVals = $this->request()->getArray('val')) { $aVals['forum_id'] = $aThread['forum_id']; if ($oValid->isValid($aVals)) { Phpfox::setCookie('forum_quote', '', -1); if ($bIsEdit) { if (Phpfox::getService('forum.post.process')->update($aPost['post_id'], $aPost['user_id'], $aVals)) { $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $aPost['post_id'])); } } else { if (($iFlood = Phpfox::getUserParam('forum.forum_post_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_post'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_reply_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if (Phpfox_Error::isPassed()) { if ($iId = Phpfox::getService('forum.post.process')->add($aVals, $aCallback)) { $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, null, array('post' => $iId)); } else { if (Phpfox::getUserParam('forum.approve_forum_post')) { $this->url()->permalink('forum', $aThread['thread_id'], $aThread['title'], true, Phpfox::getPhrase('forum.your_post_has_successfully_been_added_however_it_is_pending_an_admins_approval_before_it_can_be_displayed_publicly'), array('post' => $iId)); } } } } } } if ($aCallback === false) { $this->template()->setBreadcrumb($aForum['breadcrumb'])->setBreadcrumb($aForum['name'], $this->url()->makeUrl('forum', $aForum['name_url'] . '-' . $aForum['forum_id'])); } else { } $this->template()->setBreadcrumb($aThread['title'], $aCallback === false ? $this->url()->makeUrl('forum', array($aForum['name_url'] . '-' . $aForum['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('forum.editing_post') . ': ' . (empty($aPost['title']) ? '#' . $aPost['post_id'] : $aPost['title']) : Phpfox::getPhrase('forum.post_new_reply'), $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', array($aThread['title_url'], 'post' => $aPost['post_id'])) : null, true)->assign(array('iThreadId' => $iId, 'iActualForumId' => $aForum['forum_id'], 'sFormLink' => $aCallback === false ? $this->url()->makeUrl('forum.post.reply', array('id' => $iId)) : $this->url()->makeUrl('forum.post.reply', array('id' => $iId, 'module' => $sModule, 'item' => $iItemId)), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(PHPFOX_IS_AJAX ? false : true), 'sReturnLink' => $bIsEdit ? $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'], 'post_' . $aPost['post_id'])) : $this->url()->makeUrl($aCallback['url_home'] . '.forum', $aThread['title_url']) : '', 'sThreadReturnLink' => $aCallback === false ? $this->url()->makeUrl('forum', array($aThread['forum_url'] . '-' . $aThread['forum_id'], $aThread['title_url'])) : $this->url()->makeUrl($aCallback['url_home'], array('forum', $aThread['title_url'])), 'aPreviews' => Phpfox::getService('forum.post')->getPreview($aThread['thread_id']), 'iTotalPosts' => $aThread['total_post'], 'bIsEdit' => $bIsEdit, 'aCallback' => $aCallback, 'iTotalPostPreview' => Phpfox::getParam('forum.total_forum_post_preview'))); if (Phpfox::getUserParam('forum.can_add_forum_attachments')) { $this->setParam('attachment_share', array('type' => 'forum', 'inline' => PHPFOX_IS_AJAX ? true : false, 'id' => 'js_forum_form', 'edit_id' => $bIsEdit ? $aPost['post_id'] : '')); } } }
/** * Controller */ public function process() { Phpfox::isUser(true); Phpfox::getUserParam('poll.can_create_poll', true); $bIsCustom = $this->request()->get('item_id') && $this->request()->get('module_id') ? true : false; // minimum answers $iMinAnswers = 2; $iMaxAnswers = (int) Phpfox::getUserParam('poll.maximum_answers_count'); $iTotalDefaultAnswers = 4; $bIsEdit = false; ($sPlugin = Phpfox_Plugin::get('poll.component_controller_add_process_start')) ? eval($sPlugin) : false; // ajax validation // check input fields $aValidation = array('question' => array('def' => 'required', 'title' => Phpfox::getPhrase('poll.provide_a_question_for_your_poll'))); if (Phpfox::getParam('poll.is_image_required')) { // $aValidation['image'] = Phpfox::getPhrase('poll.image_is_required'); } // do they need to complete a captcha challenge? if (Phpfox::isModule('captcha') && Phpfox::getUserParam('poll.poll_require_captcha_challenge')) { $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge'); } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_poll_form', 'aParams' => $aValidation)); $this->template()->assign(array('aForms' => array('randomize' => 0))); if ($iReq = $this->request()->getInt('id')) { $aPoll = Phpfox::getService('poll')->getPollById((int) $iReq); // did we get a result if (!empty($aPoll)) { $bIsOwnPoll = $aPoll['user_id'] == Phpfox::getUserId(); $bCanEditTitle = Phpfox::getUserParam('poll.can_edit_title') && ($bIsOwnPoll && Phpfox::getUserParam('poll.poll_can_edit_own_polls') || !$bIsOwnPoll && Phpfox::getUserParam('poll.poll_can_edit_others_polls')); $bCanEditQuestion = Phpfox::getUserParam('poll.can_edit_question') && ($bIsOwnPoll && Phpfox::getUserParam('poll.poll_can_edit_own_polls') || !$bIsOwnPoll && Phpfox::getUserParam('poll.poll_can_edit_others_polls')); $bCanEditAnything = $bCanEditTitle || $bCanEditQuestion; if ($bCanEditAnything && ($bIsOwnPoll && Phpfox::getUserParam('poll.poll_can_edit_own_polls') || !$bIsOwnPoll && Phpfox::getUserId('poll.poll_can_edit_others_polls'))) { $bIsEdit = true; $aAnswers = Phpfox::getService('poll')->getAnswers($iReq); $this->template()->assign(array('aForms' => $aPoll, 'aAnswers' => $aAnswers, 'bCanEditTitle' => $bCanEditTitle, 'bCanEditQuestion' => $bCanEditQuestion)); } else { $this->url()->send('poll', null, Phpfox::getPhrase('poll.your_user_group_lacks_permissions_to_edit_that_poll')); } } else { $this->url()->send('poll', null, Phpfox::getPhrase('poll.that_poll_does_not_exist')); } } if ($aVals = $this->request()->getArray('val')) { if (!$bIsEdit) { // avoid a flood $iFlood = Phpfox::getUserParam('poll.poll_flood_control'); if ($iFlood != '0') { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('poll'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { // Set an error Phpfox_Error::set(Phpfox::getPhrase('poll.poll_flood_control', array('x' => $iFlood))); } } } $mErrors = Phpfox::getService('poll')->checkStructure($aVals); if (is_array($mErrors)) { foreach ($mErrors as $sError) { Phpfox_Error::set($sError); } $this->template()->assign('aForms', $aVals); } // check theres an image if (Phpfox::getParam('poll.is_image_required') && empty($_FILES['image']['name'])) { Phpfox_Error::set(Phpfox::getPhrase('poll.each_poll_requires_an_image')); } if ($oValid->isValid($aVals)) { // check if question has a question mark if (strpos($aVals['question'], '?') === false) { $aVals['question'] = $aVals['question'] . '?'; } // we do the insert // check if its updating: if ($bIsEdit) { $aVals['poll_id'] = $aPoll['poll_id']; if (Phpfox::getService('poll.process')->add(Phpfox::getUserId(), $aVals, true)) { if ($this->request()->get('submit_poll')) { $this->url()->permalink('poll', $aPoll['poll_id'], $aPoll['question'], true, Phpfox::getPhrase('poll.your_poll_has_been_updated')); } else { $this->url()->send('poll.design', array('id' => $aPoll['poll_id']), Phpfox::getPhrase('poll.your_poll_has_been_updated')); } } else { $this->template()->assign('aForms', $aVals); } } else { if (list($iId, $aPoll) = Phpfox::getService('poll.process')->add(Phpfox::getUserId(), $aVals)) { if ($this->request()->get('submit_poll')) { $this->url()->permalink('poll', $iId, $aPoll['question'], true, Phpfox::getPhrase('poll.your_poll_has_been_added') . (Phpfox::getUserParam('poll.poll_requires_admin_moderation') == true ? ' ' . Phpfox::getPhrase('poll.your_poll_needs_to_be_approved_before_being_shown_on_the_site') : '')); } else { $this->url()->send('poll.design', array('id' => $iId), Phpfox::getPhrase('poll.your_poll_has_been_added_feel_free_to_custom_design_it_the_way_you_want_here') . (Phpfox::getUserParam('poll.poll_requires_admin_moderation') == true ? ' ' . Phpfox::getPhrase('poll.your_poll_needs_to_be_approved_before_being_shown_on_the_site') : '')); } } else { $this->template()->assign('aForms', $aVals); } } } else { $this->template()->assign('aAnswers', $aVals); } } // final assigns $this->template()->setTitle(Phpfox::getPhrase('poll.polls'))->setTitle($bIsEdit ? Phpfox::getPhrase('poll.editing_a_new_poll') : Phpfox::getPhrase('poll.adding_a_new_poll'))->setBreadcrumb(Phpfox::getPhrase('poll.polls'), $this->url()->makeUrl('poll'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('poll.editing_poll') . ': ' . Phpfox::getLib('parse.output')->shorten($aPoll['question'], Phpfox::getService('core')->getEditTitleSize(), '...') : Phpfox::getPhrase('poll.adding_poll'), $this->url()->makeUrl('poll.add', array('id' => $this->request()->getInt('id'))), true)->setFullSite()->setHeader(array('<script type="text/javascript">$Behavior.setSortableAnswers = function() {iMaxAnswers = ' . $iMaxAnswers . '; iMinAnswers = ' . $iMinAnswers . ';}</script>', 'poll.js' => 'module_poll', 'jquery/ui.js' => 'static_script', 'poll.css' => 'module_poll', '<script type="text/javascript">$Behavior.loadSortableAnswers = function() {$(".sortable").sortable({placeholder: "placeholder", axis: "y"});}</script>', 'pager.css' => 'style_css'))->setPhrase(array('poll.you_have_reached_your_limit', 'poll.answer', 'poll.you_must_have_a_minimum_of_total_answers', 'poll.are_you_sure'))->assign(array('iTotalAnswers' => $iTotalDefaultAnswers, 'iMaxAnswers' => $iMaxAnswers, 'iMin' => $iMinAnswers, 'bIsEdit' => $bIsEdit, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm($bIsCustom ? false : true), 'sSuffix' => '_' . Phpfox::getParam('poll.poll_max_image_pic_size'), 'bIsCustom' => $bIsCustom, 'iItemId' => (int) $this->request()->get('item_id'), 'sModuleId' => $this->request()->get('module_id', null))); ($sPlugin = Phpfox_Plugin::get('poll.component_controller_add_process_end')) ? eval($sPlugin) : false; }
/** * 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)); }
/** * Controller */ public function process() { Phpfox::isUser(true); Phpfox::getUserParam('marketplace.can_create_listing', true); $bIsEdit = false; $bIsSetup = $this->request()->get('req4') == 'setup' ? true : false; $sAction = $this->request()->get('req3'); if ($iEditId = $this->request()->get('id')) { if ($aListing = Phpfox::getService('marketplace')->getForEdit($iEditId)) { $bIsEdit = true; $this->setParam('aListing', $aListing); $this->setParam(array('country_child_value' => $aListing['country_iso'], 'country_child_id' => $aListing['country_child_id'])); $this->template()->setHeader(array('<script type="text/javascript">$Behavior.marketplaceEditCategory = function(){ var aCategories = explode(\',\', \'' . $aListing['categories'] . '\'); for (i in aCategories) { $(\'#js_mp_holder_\' + aCategories[i]).show(); $(\'#js_mp_category_item_\' + aCategories[i]).attr(\'selected\', true); } }</script>'))->assign(array('aForms' => $aListing)); } } else { $this->template()->assign('aForms', array('price' => '0.00')); } $aValidation = array('title' => Phpfox::getPhrase('marketplace.provide_a_name_for_this_listing'), 'country_iso' => Phpfox::getPhrase('marketplace.provide_a_location_for_this_listing'), 'price' => array('def' => 'money')); $oValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_marketplace_form', 'aParams' => $aValidation)); // With this we implement support for Input validation here (which at this point only means required fields) if (Phpfox::isModule('input')) { $oValidator->setAction('marketplace.add-listing'); } if ($aVals = $this->request()->get('val')) { if ($oValidator->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('marketplace.process')->update($aListing['listing_id'], $aVals)) { ($sPlugin = Phpfox_Plugin::get('marketplace.component_controller_add_process_update_complete')) ? eval($sPlugin) : false; if ($bIsSetup) { switch ($sAction) { case 'customize': $this->url()->send('marketplace.add.invite.setup', array('id' => $aListing['listing_id']), Phpfox::getPhrase('marketplace.successfully_uploaded_images_for_this_listing')); break; case 'invite': $this->url()->permalink('marketplace', $aListing['listing_id'], $aListing['title'], true, Phpfox::getPhrase('marketplace.successfully_invited_users_for_this_listing')); break; } } else { switch ($this->request()->get('page_section_menu')) { case 'js_mp_block_customize': $this->url()->send('marketplace.add.customize', array('id' => $aListing['listing_id']), Phpfox::getPhrase('marketplace.successfully_uploaded_images')); break; case 'js_mp_block_invite': $this->url()->send('marketplace.add.invite', array('id' => $aListing['listing_id']), Phpfox::getPhrase('marketplace.successfully_invited_users')); break; default: $this->url()->send('marketplace.add', array('id' => $aListing['listing_id']), Phpfox::getPhrase('marketplace.listing_successfully_updated')); break; } } } } else { if (($iFlood = Phpfox::getUserParam('marketplace.flood_control_marketplace')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('marketplace'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('marketplace.you_are_creating_a_listing_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if (Phpfox_Error::isPassed()) { if ($iId = Phpfox::getService('marketplace.process')->add($aVals)) { $this->url()->send('marketplace.add.customize.setup', array('id' => $iId), Phpfox::getPhrase('marketplace.listing_successfully_added')); } } } } } $aCurrencies = Phpfox::getService('core.currency')->get(); foreach ($aCurrencies as $iKey => $aCurrency) { $aCurrencies[$iKey]['is_default'] = '0'; if (Phpfox::getService('core.currency')->getDefault() == $iKey) { $aCurrencies[$iKey]['is_default'] = '1'; } } if ($bIsEdit) { $aMenus = array('detail' => Phpfox::getPhrase('marketplace.listing_details'), 'customize' => Phpfox::getPhrase('marketplace.photos'), 'invite' => Phpfox::getPhrase('marketplace.invite')); if (!$bIsSetup) { $aMenus['manage'] = Phpfox::getPhrase('marketplace.manage_invites'); } $this->template()->buildPageMenu('js_mp_block', $aMenus, array('link' => $this->url()->permalink('marketplace', $aListing['listing_id'], $aListing['title']), 'phrase' => Phpfox::getPhrase('marketplace.view_this_listing'))); } $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('marketplace.editing_listing') . ': ' . $aListing['title'] : Phpfox::getPhrase('marketplace.create_a_marketplace_listing'))->setBreadcrumb(Phpfox::getPhrase('marketplace.marketplace'), $this->url()->makeUrl('marketplace'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('marketplace.editing_listing') . ': ' . $aListing['title'] : Phpfox::getPhrase('marketplace.create_a_listing'), $this->url()->makeUrl('marketplace.add'), true)->setEditor()->setFullSite()->setPhrase(array('core.select_a_file_to_upload'))->setHeader(array('add.js' => 'module_marketplace', 'progress.js' => 'static_script', '<script type="text/javascript">$Behavior.marketplaceProgressBarSettings = function(){ if ($Core.exists(\'#js_marketplace_form_holder\')) { oProgressBar = {holder: \'#js_marketplace_form_holder\', progress_id: \'#js_progress_bar\', uploader: \'#js_progress_uploader\', add_more: true, max_upload: ' . (int) Phpfox::getUserParam('marketplace.total_photo_upload_limit') . ', total: 1, frame_id: \'js_upload_frame\', file_id: \'image[]\'}; $Core.progressBarInit(); } }</script>', 'pager.css' => 'style_css', 'country.js' => 'module_core'))->assign(array('sMyEmail' => Phpfox::getUserBy('email'), 'sCreateJs' => $oValidator->createJS(), 'sGetJsForm' => $oValidator->getJsForm(false), 'bIsEdit' => $bIsEdit, 'sCategories' => Phpfox::getService('marketplace.category')->get(), 'iMaxFileSize' => Phpfox::getUserParam('marketplace.max_upload_size_listing') === 0 ? null : Phpfox::getUserParam('marketplace.max_upload_size_listing') / 1024 * 1048576, 'aCurrencies' => $aCurrencies, 'sUserSettingLink' => $this->url()->makeUrl('user.setting'))); ($sPlugin = Phpfox_Plugin::get('marketplace.component_controller_add_process')) ? eval($sPlugin) : false; }
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); Phpfox::getUserParam('quiz.can_create_quiz', true); ($sPlugin = Phpfox_Plugin::get('quiz.component_controller_add_process_start')) ? eval($sPlugin) : false; $iMaxAnswers = Phpfox::getUserParam('quiz.max_answers'); $iMinAnswers = Phpfox::getUserParam('quiz.min_answers'); $iMaxQuestions = Phpfox::getUserParam('quiz.max_questions'); $iMinQuestions = Phpfox::getUserParam('quiz.min_questions'); $sFormSubmit = $this->url()->makeUrl('quiz.add'); // bErrors is used to tell JS when there has been errors so it knows when to add more // questions or not $bErrors = 'false'; $bIsAdd = 'true'; // determine if we should show the questions and the title sections $bShowQuestions = true; $bShowTitle = true; // is user editing? if ($iQuizId = $this->request()->getInt('id')) { $bIsAdd = 'false'; $sFormSubmit = $this->url()->makeUrl('current'); $aQuiz = Phpfox::getService('quiz')->getQuizToEdit($iQuizId); if (empty($aQuiz)) { $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.that_quiz_does_not_exist_or_its_awaiting_moderation')); } if ($aVals = $this->request()->getArray('val')) { $aQuestions = isset($aVals['q']) ? $aVals['q'] : false; $mValid = true; if ($aQuestions !== false) { list($mValid, $bNull) = Phpfox::getService('quiz')->checkStructure($aQuestions); } if ($mValid === true) { list($mEdit, $sUrl) = Quiz_Service_Process::instance()->update($aVals, Phpfox::getUserId()); if ($mEdit === true) { $this->url()->permalink('quiz', $aQuiz['quiz_id'], Phpfox::getLib('parse.input')->clean($aVals['title']), true, Phpfox::getPhrase('quiz.your_quiz_has_been_edited')); } } else { foreach ($mValid as $sError) { Phpfox_Error::set($sError); } $aQuiz['questions'] = $bNull; } } $this->template()->setTitle(Phpfox::getPhrase('quiz.edit_quiz'))->setBreadcrumb(Phpfox::getPhrase('quiz.quizzes'), $this->url()->makeUrl('quiz'))->assign(array('aQuiz' => $aQuiz, 'aForms' => $aQuiz))->setBreadcrumb('Editing Quiz: ' . Phpfox::getLib('parse.output')->shorten($aQuiz['title'], Phpfox::getService('core')->getEditTitleSize(), '...'), $this->url()->makeUrl('quiz.add', array('id' => $aQuiz['quiz_id'])), true); } else { $this->template()->setTitle(Phpfox::getPhrase('quiz.add_new_quiz'))->setBreadcrumb(Phpfox::getPhrase('quiz.quizzes'), $this->url()->makeUrl('quiz'))->setBreadcrumb(Phpfox::getPhrase('quiz.add_new_quiz'), $this->url()->makeUrl('quiz.add'), true); } // Using it: $aValidation = array('title' => array('def' => 'required', 'title' => Phpfox::getPhrase('quiz.you_need_to_write_a_title')), 'description' => array('def' => 'required', 'title' => Phpfox::getPhrase('quiz.you_need_to_write_a_description'))); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); // are we getting a new quiz if (($aVals = $this->request()->getArray('val')) && empty($iQuizId)) { // check that tere is at least one question and one answer: $aQuestions = $aVals['q']; $iCntQuestions = count($aQuestions); // moved the contents of the whole check to be called as well when editing list($mValid, $aQuestions) = Phpfox::getService('quiz')->checkStructure($aQuestions); if ($mValid !== true && is_array($mValid)) { foreach ($mValid as $sError) { Phpfox_Error::set($sError); } } if (($iFlood = Phpfox::getUserParam('quiz.flood_control_quiz')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('quiz'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('quiz.you_are_creating_a_quiz_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime()); } } if ($oValid->isValid($aVals)) { if ($iId = Quiz_Service_Process::instance()->add($aVals, Phpfox::getUserId())) { $this->url()->permalink('quiz', $iId, Phpfox::getLib('parse.input')->clean($aVals['title']), true, Phpfox::getUserParam('quiz.new_quizzes_need_moderation') ? Phpfox::getPhrase('quiz.your_quiz_has_been_added_it_needs_to_be_approved_by_our_staff_before_it_can_be_shown') : Phpfox::getPhrase('quiz.your_quiz_has_been_added')); } else { Phpfox_Error::set(Phpfox::getPhrase('quiz.there_was_an_error_with_your_quiz_please_try_again')); } } else { $aQQuestions['questions'] = $aVals['q']; $bErrors = true; $this->template()->assign(array('aQuiz' => $aQQuestions, 'bErrors' => $bErrors)); } } if ($this->request()->getInt('id')) { $iQuizOwner = (int) $aQuiz['user_id']; if ($iQuizOwner == Phpfox::getUserId()) { $bShowQuestions = Phpfox::getUserParam('quiz.can_edit_own_questions'); $bShowTitle = Phpfox::getUserParam('quiz.can_edit_own_title'); } else { $bShowQuestions = Phpfox::getUserParam('quiz.can_edit_others_questions'); $bShowTitle = Phpfox::getUserParam('quiz.can_edit_others_title'); } // redirect if ($bShowQuestions == false && $bShowTitle == false) { $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.you_are_not_allowed_to_edit_this_quiz')); } } $this->template()->setFullSite()->setPhrase(array('quiz.you_have_reached_the_maximum_questions_allowed_per_quiz', 'quiz.you_are_required_a_minimum_of_total_questions', 'quiz.you_have_reached_the_maximum_answers_allowed_per_question', 'quiz.you_are_required_a_minimum_of_total_answers_per_question', 'quiz.are_you_sure', 'quiz.answer', 'quiz.delete', 'core.you_cannot_write_more_then_limit_characters', 'core.you_have_limit_character_s_left', 'quiz.question_count', 'quiz.answer_count'))->setHeader(array('jquery/plugin/jquery.limitTextarea.js' => 'static_script', 'add.js' => 'module_quiz', 'add.css' => 'module_quiz', '<script type="text/javascript">$Behavior.quizAddQuestion = function() { $Core.quiz.init({sRequired:"' . Phpfox::getParam('core.required_symbol') . '", isAdd: ' . $bIsAdd . ', bErrors: ' . $bErrors . ', iMaxAnswers: ' . $iMaxAnswers . ', iMinAnswers: ' . $iMinAnswers . ', iMaxQuestions: ' . $iMaxQuestions . ', iMinQuestions: ' . $iMinQuestions . '}); }</script>'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'sFormAction' => $sFormSubmit, 'bIsAdd' => $bIsAdd, 'bShowQuestions' => $bShowQuestions, 'bShowTitle' => $bShowTitle, 'sSuffix' => '_' . Phpfox::getParam('quiz.quiz_max_image_pic_size'))); }