예제 #1
0
 /**
  * Verifies database connection information
  *
  * @param array $words List of words to censor (from input). Keys: word, exact, replace
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$database, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     if (array_key_exists('newInstall', $database)) {
         return true;
     }
     if (!array_key_exists('adapter', $database) || !array_key_exists('host', $database) || !array_key_exists('port', $database) || !array_key_exists('dbname', $database) || !array_key_exists('username', $database) || !array_key_exists('password', $database)) {
         return false;
     }
     try {
         $db = Zend_Db::factory($database['adapter'], array('host' => $database['host'], 'port' => $database['port'], 'dbname' => $database['dbname'], 'username' => $database['username'], 'password' => $database['password']));
         $db->getConnection();
         $sbTables = array($database['table_prefix'] . '_admins', $database['table_prefix'] . '_admins_servers_groups', $database['table_prefix'] . '_banlog', $database['table_prefix'] . '_bans', $database['table_prefix'] . '_comments', $database['table_prefix'] . '_demos', $database['table_prefix'] . '_groups', $database['table_prefix'] . '_log', $database['table_prefix'] . '_mods', $database['table_prefix'] . '_overrides', $database['table_prefix'] . '_protests', $database['table_prefix'] . '_servers', $database['table_prefix'] . '_servers_groups', $database['table_prefix'] . '_settings', $database['table_prefix'] . '_srvgroups', $database['table_prefix'] . '_srvgroups_overrides', $database['table_prefix'] . '_submissions');
         $query = $db->listTables();
         if (count(array_diff($sbTables, $query)) > 0) {
             $dw->error(new XenForo_Phrase('sourcebans_table_prefix_invalid'));
             return false;
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         if ($dw) {
             $dw->error($e->getMessage(), $fieldName);
         }
         return false;
     }
     return true;
 }
예제 #2
0
파일: Check.php 프로젝트: Sywooch/forums
 public static function watermark(array &$optionValues, XenForo_DataWriter $optionDw, $optionId)
 {
     if ($optionId !== 'sonnbXG_watermark') {
         return true;
     }
     if (!empty($optionValues['enabled'])) {
         switch ($optionValues['overlay']) {
             case 'image':
                 if (!Zend_Uri::check($optionValues['url']) && !is_file($optionValues['url'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_image_not_valid'), $optionId);
                     return false;
                 }
                 break;
             case 'text':
                 if (!self::isTextColorValid($optionValues['textColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_text_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!self::isBgColorValid($optionValues['bgColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_bg_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!empty($optionValues['font']) && !is_file($optionValues['font'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_font_path_not_valid'), $optionId);
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
예제 #3
0
 public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     if (empty($values['enabled'])) {
         return true;
     }
     try {
         $helper = new XenGallery_Helper_Video(null, $values['ffmpegPath'], !empty($values['transcode']));
         $errors = $helper->getFfmpegErrors();
         if ($errors) {
             $dw->error(reset($errors), $fieldName);
             return false;
         }
     } catch (Exception $e) {
         $dw->error($e->getMessage(), $fieldName);
         return false;
     }
     if (!empty($values['transcode'])) {
         try {
             if (!is_file($values['phpPath']) && !is_executable($values['phpPath'])) {
                 $dw->error(new XenForo_Phrase('xengallery_php_binary_path_could_not_be_verified'));
                 return false;
             }
         } catch (Exception $e) {
             $dw->error($e->getMessage(), $fieldName);
             return false;
         }
     }
     return true;
 }
예제 #4
0
 public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
 {
     $positions = trim($positions);
     if (empty($positions)) {
         $dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
     }
     if ('all' == $positions) {
         return true;
     }
     /** @var XenForo_Model_Template $templateModel */
     $templateModel = $dw->getModelFromCache('XenForo_Model_Template');
     $db = XenForo_Application::getDb();
     $positionsArray = explode(',', $positions);
     $positionsGood = array();
     $templateForHooks = array();
     foreach ($positionsArray as $position) {
         $position = trim($position);
         if (empty($position)) {
             continue;
         }
         if (in_array($position, array('wf_widget_page', 'hook:wf_widget_page_contents'), true) and !$dw->get('widget_page_id')) {
             $dw->error(new XenForo_Phrase('wf_position_x_requires_widget_page', array('position' => $position)), $fieldName);
             return false;
         }
         if (in_array($position, array('wf_widget_ajax'), true)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         // sondh@2012-08-25
         // added support for hook:hook_name
         if (substr($position, 0, 5) == 'hook:') {
             // accept all kind of hooks, just need to get parent templates for them
             $templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
             if (count($templates) > 0) {
                 $templateForHooks[$position] = array();
                 foreach ($templates as $template) {
                     $templateForHooks[$position][] = $template['title'];
                 }
                 $templateForHooks[$position] = array_unique($templateForHooks[$position]);
             } else {
                 $dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
                 return false;
             }
         } elseif (!$templateModel->getTemplateInStyleByTitle($position)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         $positionsGood[] = $position;
     }
     $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
     asort($positionsGood);
     $positions = implode(', ', $positionsGood);
     return true;
 }
 /**
  * Verifies the registrationWelcome setting
  *
  * @param array $values
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         // insert - just trust the default value
         return true;
     }
     if (!empty($values['messageEnabled'])) {
         /** @var XenForo_Model_User $userModel */
         $userModel = XenForo_Model::create('XenForo_Model_User');
         $participants = explode(',', $values['messageParticipants']);
         $starter = array_shift($participants);
         $participantUsers = $userModel->getUsersByNames($participants);
         $starterUser = $userModel->getUserByName($starter);
         if (!$starterUser) {
             if ($starter) {
                 $dw->error(new XenForo_Phrase('the_following_recipients_could_not_be_found_x', array('names' => $starter)), $fieldName);
             } else {
                 $dw->error(new XenForo_Phrase('please_enter_at_least_one_valid_recipient'), $fieldName);
             }
             return false;
         }
         /** @var XenForo_DataWriter_ConversationMaster $conversationDw */
         $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
         $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $starterUser);
         $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $values['messageBody']);
         $conversationDw->set('user_id', $starterUser['user_id']);
         $conversationDw->set('username', $starterUser['username']);
         $conversationDw->set('title', $values['messageTitle']);
         $conversationDw->addRecipientUserIds(array_keys($participantUsers));
         // skips permissions
         $messageDw = $conversationDw->getFirstMessageDw();
         $messageDw->set('message', $values['messageBody']);
         $conversationDw->preSave();
         if ($conversationDw->hasErrors()) {
             $errors = $conversationDw->getErrors();
             // Skip recipient errors. We've already verified the recipients are valid.
             if (isset($errors['recipients'])) {
                 unset($errors['recipients']);
             }
             if (count($errors)) {
                 $dw->error(reset($errors), $fieldName);
                 return false;
             }
         }
         $validUsernames = XenForo_Application::arrayColumn($participantUsers, 'username');
         array_unshift($validUsernames, $starter);
         $values['messageParticipants'] = implode(', ', array_unique($validUsernames));
     }
     if (!empty($values['emailEnabled']) && !strlen(trim($values['emailBody']))) {
         $dw->error(new XenForo_Phrase('you_must_enter_email_message_to_enable_welcome_email'), $fieldName);
         return false;
     }
     return true;
 }
예제 #6
0
 public static function validateColour($value, XenForo_DataWriter $dw, $fieldName)
 {
     // #fff and #fff444 are acceptable formats here
     if (strlen($value) != 7 && strlen($value) != 4) {
         $dw->error(new XenForo_Phrase("mc_assoc_errors_hex_colour"), $fieldName);
     }
     $truncatedValue = substr($value, 1);
     // chop off the #
     if (!ctype_xdigit($truncatedValue) || $value[0] != "#") {
         $dw->error(new XenForo_Phrase("mc_assoc_errors_hex_colour"), $fieldName);
     }
     return $dw;
 }
예제 #7
0
 public static function verifyTweetOption(array &$option, XenForo_DataWriter $dw, $fieldName)
 {
     if (!empty($option['enabled'])) {
         if (!empty($option['via']) && !XenForo_Helper_UserField::verifyTwitter(array(), $option['via'], $error)) {
             $dw->error($error, $fieldName);
             return false;
         }
         if (!empty($option['related']) && !XenForo_Helper_UserField::verifyTwitter(array(), $option['related'], $error)) {
             $dw->error($error, $fieldName);
             return false;
         }
     }
     return true;
 }
예제 #8
0
 public static function verifyTweetOption(array &$option, XenForo_DataWriter $dw, $fieldName)
 {
     if (!empty($option['enabled'])) {
         if (!XenForo_Model_IdentityService_Twitter::verifyAccountName($option['via'], $error)) {
             $dw->error($error);
             return false;
         }
         if (!XenForo_Model_IdentityService_Twitter::verifyAccountName($option['related'], $error)) {
             $dw->error($error);
             return false;
         }
     }
     return true;
 }
예제 #9
0
 public static function xenWrapperCallback(array &$configs, XenForo_DataWriter $dw, $fieldName)
 {
     if (isset($configs['Bbm_wrapper_callback']) && $configs['Bbm_wrapper_callback'] == 'callback' && !BBM_Helper_Bbm::callbackChecker($configs['class'], $configs['method'])) {
         $dw->error(new XenForo_Phrase('bbm_xenwrapper_callback_not_valid'));
     }
     return true;
 }
예제 #10
0
 public static function verifyOption(&$optionValue, XenForo_DataWriter $dw, $fieldName)
 {
     if ($optionValue == 'imPecl' && !class_exists('Imagick')) {
         $dw->error(new XenForo_Phrase('must_have_imagick_pecl_extension'), $fieldName);
         return false;
     }
     return true;
 }
예제 #11
0
 /**
  * Verifies the license key.
  *
  * @param string $licenseKey license key to be verified
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(&$licenseKey, XenForo_DataWriter $dw, $fieldName)
 {
     if (XenForo_Application::getOptions()->simpleFormsLicenseKey && !self::VerifyLicense($licenseKey)) {
         $errorMessage = 'The license key you entered is invalid. If you are having trouble with your license, please contact <a href="https://liquidpro.net/clients/clientarea.php" target="_blank">LiquidPro Support</a>.';
         $dw->error($errorMessage, $fieldName);
     }
     return true;
 }
예제 #12
0
파일: Option.php 프로젝트: Sywooch/forums
 /**
  * Verifies that the Google Analytics Web Property ID is valid, if specified.
  * See https://www.google.com/support/googleanalytics/bin/answer.py?answer=113500
  *
  * @param string $wpId
  * @param XenForo_DataWriter $dw
  * @param string $fieldName
  *
  * @return boolean
  */
 public static function verifyGoogleAnalyticsWebPropertyId(&$wpId, XenForo_DataWriter $dw, $fieldName)
 {
     if ($wpId !== '' && !preg_match('/^UA-\\d+-\\d+$/', $wpId)) {
         $dw->error(new XenForo_Phrase('please_enter_your_google_analytics_web_property_id_in_format'), $fieldName);
         return false;
     }
     return true;
 }
예제 #13
0
파일: Uri.php 프로젝트: Sywooch/forums
 /**
  * Verifies that the provided string is a valid URL
  *
  * @param string $url
  *
  * @return boolean
  */
 public static function verifyUri(&$uri, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (Zend_Uri::check($uri)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_enter_valid_url'), $fieldName);
     return false;
 }
예제 #14
0
 public static function VerifyDefaultValue(&$defaultValue, XenForo_DataWriter $dw, $inputName = false)
 {
     if ($defaultValue == '') {
         return true;
     }
     $fieldType = $dw->get('field_type');
     if ($fieldType == 'datetime') {
         if (is_string($defaultValue)) {
             $temp = explode(' ', $defaultValue);
             if (count($temp) != 2) {
                 $dw->error(new XenForo_Phrase('lpsf_please_enter_a_datetime_in_format'), $inputName);
                 return false;
             }
             $defaultValue = array('date' => $temp[0], 'time' => $temp[1]);
         }
         if (is_array($defaultValue) && array_key_exists('date', $defaultValue) && array_key_exists('time', $defaultValue)) {
             // validate
             $dateTimeStr = $defaultValue['date'] . ' ' . $defaultValue['time'];
             $dateTime = DateTime::createFromFormat('Y-m-d g:ia', $dateTimeStr);
             if (!$dateTime) {
                 $dw->error(new XenForo_Phrase('lpsf_please_enter_a_datetime_in_format'), $inputName);
                 return false;
             }
             $defaultValue = $dateTimeStr;
         }
     }
     if ($fieldType == 'time') {
         $dateTime = DateTime::createFromFormat('g:ia', $defaultValue);
         if (!$dateTime) {
             $dw->error(new XenForo_Phrase('lpsf_please_enter_a_time_in_format'), $inputName);
             return false;
         }
     }
     if ($fieldType == 'date') {
         $dateTime = DateTime::createFromFormat('Y-m-d', $defaultValue);
         if (!$dateTime) {
             $dw->error(new XenForo_Phrase('lpsf_please_enter_a_date_in_format'), $inputName);
             return false;
         }
     }
     return true;
 }
예제 #15
0
 public static function verifyOption(array &$groups, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     // override for a new install, no group validation should be done
     if (is_array($groups) && array_key_exists('newInstall', $groups)) {
         return true;
     }
     if (is_array($groups) && array_key_exists(0, $groups)) {
         unset($groups[0]);
     }
     foreach ($groups as $groupId => $selectedGroups) {
         if (!is_array($selectedGroups)) {
             $dw->error(new XenForo_Phrase('sourcebans_group_association_invalid'));
         } else {
             if ($selectedGroups['web_admin_group_id'] == '' || $selectedGroups['server_admin_group_id'] == '' || $selectedGroups['server_group_id'] == '') {
                 $dw->error(new XenForo_Phrase('sourcebans_group_association_invalid'));
             }
         }
     }
     return true;
 }
예제 #16
0
 public static function validateOption(&$choices, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     if (!in_array($choices, self::$navbarPositions)) {
         $dw->error(new XenForo_Phrase('invalid_argument'), $fieldName);
         return false;
     }
     return true;
 }
예제 #17
0
파일: Mood.php 프로젝트: Sywooch/forums
 /**
  * Verifies that the provided integer is a valid mood ID
  *
  * @param integer $moodId
  * @param XenForo_DataWriter The current running data writer
  * @param string Field being affected
  *
  * @return boolean
  */
 public static function verifyMoodId($moodId, XenForo_DataWriter $dw, $fieldName = false)
 {
     if ($moodId === 0) {
         // explicitly set to 0, use system default
         return true;
     }
     if ($dw->getModelFromCache('XenMoods_Model_Mood')->getMoodById($moodId)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_select_valid_mood'), $fieldName);
     return false;
 }
예제 #18
0
 public static function verifyUsernameExists(&$username, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     if ($username != '') {
         $userModel = XenForo_Model::create('XenForo_Model_User');
         $user = $userModel->getUserByName($username);
         if (!$user) {
             $dw->error(new XenForo_Phrase('AWickham_SourceBansSync_InvalidUsername'));
             return false;
         }
     }
     return true;
 }
예제 #19
0
 public static function verifySerialized(&$serial, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (!is_string($serial)) {
         $serial = serialize($serial);
         return true;
     }
     if (@unserialize($serial) === false && $serial != serialize(false)) {
         // debugging message, no need for phrasing
         $dw->error('The data provided as a serialized array does not unserialize.', $fieldName);
         return false;
     }
     return true;
 }
예제 #20
0
 /**
  * Verifies the autoEmbedMedia setting
  *
  * @param array $values
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
 {
     if (empty($values['linkBbCode'])) {
         $values['linkBbCode'] = '[i][size=2][url={$url}]View: {$url}[/url][/size][/i]';
     }
     if ($values['embedType'] != XenForo_Helper_Media::AUTO_EMBED_MEDIA_DISABLED) {
         if (strpos($values['linkBbCode'], '{$url}') === false) {
             $dw->error(new XenForo_Phrase('link_bbcode_must_include_url_token'), $fieldName);
             return false;
         }
     }
     return true;
 }
예제 #21
0
    public static function verifyUserId($user_id, XenForo_DataWriter $dw, $fieldName = false)
    {
        $db = XenForo_Application::get('db');
        $existing_user_id = $db->fetchOne('
				SELECT user_id
				FROM xf_user
				WHERE user_id = ?
			', $user_id);
        if ($existing_user_id == $user_id) {
            return true;
        }
        $dw->error(new XenForo_Phrase('requested_user_not_found'), $fieldName);
        return false;
    }
예제 #22
0
 /**
  * Verifies the list of Facebook admin IDs.
  *
  * @param array $admins Array of of Facebook user IDs
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$admins, XenForo_DataWriter $dw, $fieldName)
 {
     $output = array();
     foreach ($admins as $admin) {
         $admin = trim($admin);
         if ($admin) {
             if (!preg_match('/^[0-9]+$/', $admin)) {
                 $dw->error(new XenForo_Phrase('facebook_user_ids_are_integers'), $fieldName);
                 return false;
             }
             $output[] = $admin;
         }
     }
     $admins = $output;
     return true;
 }
예제 #23
0
 /**
  * Verifies and prepares the censor option to the correct format.
  *
  * @param array $words List of words to censor (from input). Keys: word, exact, replace
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$options, XenForo_DataWriter $dw, $fieldName)
 {
     if ($options['action'] == 'move') {
         if ($options['node_id']) {
             if ($node = self::_getNodeModel()->getNodeById($options['node_id'])) {
                 if ($node['node_type_id'] === 'Forum') {
                     return true;
                 }
             }
         }
         $dw->error(new XenForo_Phrase('please_specify_valid_spam_forum'), $fieldName);
         return false;
     }
     // not selected move, so we don't care about the node value
     return true;
 }
예제 #24
0
 /**
  * Verifies the list of Facebook admin IDs.
  *
  * @param array $admins Array of of Facebook user IDs
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$admins, XenForo_DataWriter $dw, $fieldName)
 {
     $output = array();
     foreach ($admins as $admin) {
         $admin = trim($admin);
         if ($admin) {
             if (!is_numeric($admin)) {
                 $dw->error(new XenForo_Phrase('facebook_user_ids_are_integers'));
                 return false;
             }
             $output[] = intval($admin);
         }
     }
     $admins = $output;
     return true;
 }
예제 #25
0
 public static function verifySerialized(&$serial, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (!is_string($serial)) {
         $serial = serialize($serial);
         $verifyValidSerialization = false;
     } else {
         // already serialized, so we need to check whether this is valid
         $verifyValidSerialization = true;
     }
     if (XenForo_Helper_Php::serializedContainsObject($serial)) {
         throw new XenForo_Exception("Serialized value contains an object and this is not allowed");
     }
     if ($verifyValidSerialization) {
         if (@unserialize($serial) === false && $serial != serialize(false)) {
             $dw->error('The data provided as a serialized array does not unserialize.', $fieldName);
             return false;
         }
     }
     return true;
 }
예제 #26
0
    public function verifyOptionForAddOn(&$optionValue, XenForo_DataWriter $dw, $fieldName)
    {
        if ($optionValue && !$optionValue['log']) {
            $dw->error(new XenForo_Phrase('xengallery_no_import_log_table_specified'), $fieldName);
        }
        $routeFilterWriter = XenForo_DataWriter::create('XenForo_DataWriter_RouteFilter');
        $filterExists = XenForo_Application::getDb()->fetchRow('
			SELECT *
			FROM xf_route_filter
			WHERE find_route = ?
		', 'xengallery-' . $this->route . '/');
        if ($optionValue) {
            if (!$filterExists) {
                $routeFilterWriter->bulkSet(array('route_type' => 'public', 'prefix' => 'xengallery-' . $this->route, 'find_route' => 'xengallery-' . $this->route, 'replace_route' => $this->replaceRoute, 'enabled' => 1, 'url_to_route_only' => 0));
                $routeFilterWriter->save();
            }
        } else {
            if ($filterExists) {
                $routeFilterWriter->setExistingData($filterExists);
                $routeFilterWriter->delete();
            }
        }
        return true;
    }
 public static function verifyOption(&$database, XenForo_DataWriter $dw, $fieldName)
 {
     $dw->error(new XenForo_Phrase('source_database_connection_details_not_correct_x', array('error' => print_r('asdf', true))), $fieldName);
     return false;
 }
예제 #28
0
파일: Widget.php 프로젝트: Sywooch/forums
 public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
 {
     if ($dw->get('widget_page_id') > 0) {
         if ($positions === 'sidebar') {
             // good
         } else {
             $positions = '';
         }
         return true;
     }
     // sondh@2012-08-28
     // it may be better to use strtolower with $positions (making it easier for
     // admins)
     // but some add-on developers decided to use template with mixed case characters
     // so...
     // no strtolower goodness for everyone.
     $positions = trim($positions);
     if (empty($positions)) {
         $dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
     }
     if ('all' == $positions) {
         return true;
     }
     $templateModel = $dw->getModelFromCache('XenForo_Model_Template');
     $db = XenForo_Application::getDb();
     $positionsArray = explode(',', $positions);
     $positionsGood = array();
     $templateForHooks = array();
     foreach ($positionsArray as $position) {
         $position = trim($position);
         if (empty($position)) {
             continue;
         }
         // sondh@2012-08-25
         // added support for hook:hook_name
         if (substr($position, 0, 5) == 'hook:') {
             // accept all kind of hooks, just need to get parent templates for them
             $templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
             if (count($templates) > 0) {
                 $templateForHooks[$position] = array();
                 foreach ($templates as $template) {
                     $templateForHooks[$position][] = $template['title'];
                 }
                 $templateForHooks[$position] = array_unique($templateForHooks[$position]);
             } else {
                 $dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
                 return false;
             }
         } else {
             $found = $templateModel->getTemplateInStyleByTitle($position);
             if (!$found) {
                 $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
                 return false;
             }
         }
         $positionsGood[] = $position;
     }
     $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
     asort($positionsGood);
     $positions = implode(', ', $positionsGood);
     return true;
 }
예제 #29
0
파일: Render.php 프로젝트: Sywooch/forums
 public static function verifyOptionLimit(array &$numbers, XenForo_DataWriter $dw, $fieldName)
 {
     $output = array();
     if (!empty($numbers['value'])) {
         foreach ($numbers['value'] as $number) {
             if (!empty($number) && $number > 0) {
                 $output[] = intval($number);
             }
         }
         asort($output);
         $numbers['value'] = array_values(array_unique($output));
     }
     if (!empty($numbers['default'])) {
         $numbers['default'] = intval($numbers['default']);
     } else {
         $numbers['default'] = 15;
     }
     if (!empty($numbers['enabled']) && empty($numbers['value'])) {
         $dw->error(new XenForo_Phrase('BRMS_must_have_value_for_item_limit'), $fieldName);
     }
     return true;
 }