/** * prepare frontend group edit render * * @param int $id * @param UserTable $user */ private function showGroupEdit( $id, $user ) { global $_CB_framework; $row = CBGroupJive::getGroup( $id ); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $categoryId = $this->input( 'category', null, GetterInterface::INT ); if ( $categoryId === null ) { $category = $row->category(); } else { $category = CBGroupJive::getCategory( $categoryId ); } if ( $row->get( 'id' ) ) { $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ); } else { $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $category->get( 'id' ) ) ); } if ( ! $isModerator ) { if ( ( $categoryId !== null ) && ( ! $category->get( 'id' ) ) && ( ! $this->params->get( 'groups_uncategorized', 1 ) ) ) { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'Category does not exist.' ), 'error' ); } elseif ( $category->get( 'id' ) && ( ( ! $category->get( 'published' ) ) || ( ! CBGroupJive::canAccess( (int) $category->get( 'access' ), (int) $user->get( 'id' ) ) ) ) ) { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have access to this category.' ), 'error' ); } elseif ( $row->get( 'id' ) ) { if ( $user->get( 'id' ) != $row->get( 'user_id' ) ) { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this group.' ), 'error' ); } } elseif ( ! CBGroupJive::canCreateGroup( $user, ( $categoryId === null ? null : $category ) ) ) { if ( $category->get( 'id' ) ) { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create a group in this category.' ), 'error' ); } else { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create a group.' ), 'error' ); } } } CBGroupJive::getTemplate( 'group_edit' ); $input = array(); $publishedTooltip = cbTooltip( null, CBTxt::T( 'Select publish state of this group. Unpublished groups will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . $publishedTooltip, (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) ); $categories = CBGroupJive::getCategoryOptions(); if ( $row->get( 'id' ) && $category->get( 'id' ) ) { $available = array(); foreach ( $categories as $option ) { $available[] = (int) $option->value; } if ( ! in_array( (int) $category->get( 'id' ), $available ) ) { array_unshift( $categories, moscomprofilerHTML::makeOption( (int) $category->get( 'id' ), CBTxt::T( $category->get( 'name' ) ) ) ); } } if ( $categories ) { if ( $this->params->get( 'groups_uncategorized', 1 ) || $isModerator ) { array_unshift( $categories, moscomprofilerHTML::makeOption( 0, CBTxt::T( 'Uncategorized' ) ) ); } $categoryTooltip = cbTooltip( null, CBTxt::T( 'Select the group category. This is the category a group will belong to and decide its navigation path.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['category'] = moscomprofilerHTML::selectList( $categories, 'category', 'class="form-control"' . $categoryTooltip, 'value', 'text', (int) $category->get( 'id' ), 1, false, false ); } else { $input['category'] = null; if ( ! $this->params->get( 'groups_uncategorized', 1 ) ) { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create a group in any categories.' ), 'error' ); } } $types = explode( '|*|', $category->get( 'types' ) ); $listType = array(); if ( in_array( 1, $types ) || $isModerator || ( ! $category->get( 'id' ) ) || ( ! $types ) ) { $listType[] = moscomprofilerHTML::makeOption( '1', CBTxt::T( 'Open' ) ); } if ( in_array( 2, $types ) || $isModerator || ( ! $category->get( 'id' ) ) || ( ! $types ) ) { $listType[] = moscomprofilerHTML::makeOption( '2', CBTxt::T( 'Approval' ) ); } if ( in_array( 3, $types ) || $isModerator || ( ! $category->get( 'id' ) ) || ( ! $types ) ) { $listType[] = moscomprofilerHTML::makeOption( '3', CBTxt::T( 'Invite' ) ); } $typeTooltip = cbTooltip( null, CBTxt::T( 'Select the group type. Type determines the way your group is joined (e.g. Invite requires new users to be invited to join your group).' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['type'] = moscomprofilerHTML::selectList( $listType, 'type', 'class="form-control"' . $typeTooltip, 'value', 'text', (int) $this->input( 'post/type', $row->get( 'type', 1 ), GetterInterface::INT ), 1, false, false ); $nameTooltup = cbTooltip( null, CBTxt::T( 'Input the group name. This is the name that will distinguish this group from others. Suggested to input something unique and intuitive.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['name'] = '<input type="text" id="name" name="name" value="' . htmlspecialchars( $this->input( 'post/name', $row->get( 'name' ), GetterInterface::STRING ) ) . '" class="form-control" size="25"' . $nameTooltup . ' />'; $descriptionTooltip = cbTooltip( null, CBTxt::T( 'Optionally input the group description. The group description should be short and to the point; describing what your group is all about.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['description'] = '<textarea id="description" name="description" class="form-control" cols="40" rows="5"' . $descriptionTooltip . '>' . htmlspecialchars( $this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING ) ) . '</textarea>'; $listMethods = array(); $listMethods[] = moscomprofilerHTML::makeOption( 0, CBTxt::T( 'No Change' ) ); $listMethods[] = moscomprofilerHTML::makeOption( 1, CBTxt::T( 'Upload' ) ); $listMethods[] = moscomprofilerHTML::makeOption( 2, CBTxt::T( 'Delete' ) ); $input['canvas_method'] = moscomprofilerHTML::selectList( $listMethods, 'canvas_method', 'class="form-control"', 'value', 'text', $this->input( 'post/canvas_method', 0, GetterInterface::INT ), 1, false, false ); $canvasMinFileSize = (int) $this->params->get( 'canvas_min_size', 0 ); $canvasMaxFileSize = (int) $this->params->get( 'canvas_max_size', 1024 ); $canvasValidation = array(); if ( $canvasMinFileSize || $canvasMaxFileSize ) { $canvasValidation[] = cbValidator::getRuleHtmlAttributes( 'filesize', array( $canvasMinFileSize, $canvasMaxFileSize, 'KB' ) ); } $canvasValidation[] = cbValidator::getRuleHtmlAttributes( 'extension', 'jpg,jpeg,gif,png' ); $canvasTooltip = cbTooltip( null, CBTxt::T( 'Optionally select the group canvas. A canvas should represent the topic of your group; please be respectful and tasteful when selecting a canvas.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['canvas'] = '<input type="file" id="canvas" name="canvas" value="" class="form-control"' . $canvasTooltip . implode( ' ', $canvasValidation ) . ' />'; $input['canvas_limits'] = array( CBTxt::T( 'CANVAS_UPLOAD_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => 'jpg, jpeg, gif, png' ) ) ); if ( $canvasMinFileSize ) { $input['canvas_limits'][] = CBTxt::T( 'CANVAS_UPLOAD_LIMITS_MIN', 'Your file should exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $canvasMinFileSize * 1024 ) ) ); } if ( $canvasMaxFileSize ) { $input['canvas_limits'][] = CBTxt::T( 'CANVAS_UPLOAD_LIMITS_MAX', 'Your file should not exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $canvasMaxFileSize * 1024 ) ) ); } $input['logo_method'] = moscomprofilerHTML::selectList( $listMethods, 'logo_method', 'class="form-control"', 'value', 'text', $this->input( 'post/logo_method', 0, GetterInterface::INT ), 1, false, false ); $logoMinFileSize = (int) $this->params->get( 'logo_min_size', 0 ); $logoMaxFileSize = (int) $this->params->get( 'logo_max_size', 1024 ); $logoValidation = array(); if ( $logoMinFileSize || $logoMaxFileSize ) { $logoValidation[] = cbValidator::getRuleHtmlAttributes( 'filesize', array( $logoMinFileSize, $logoMaxFileSize, 'KB' ) ); } $logoValidation[] = cbValidator::getRuleHtmlAttributes( 'extension', 'jpg,jpeg,gif,png' ); $logoTooltip = cbTooltip( null, CBTxt::T( 'Optionally select the group logo. A logo should represent the topic of your group; please be respectful and tasteful when selecting a logo.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['logo'] = '<input type="file" id="logo" name="logo" value="" class="form-control"' . $logoTooltip . implode( ' ', $logoValidation ) . ' />'; $input['logo_limits'] = array( CBTxt::T( 'LOGO_UPLOAD_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => 'jpg, jpeg, gif, png' ) ) ); if ( $logoMinFileSize ) { $input['logo_limits'][] = CBTxt::T( 'LOGO_UPLOAD_LIMITS_MIN', 'Your file should exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $logoMinFileSize * 1024 ) ) ); } if ( $logoMaxFileSize ) { $input['logo_limits'][] = CBTxt::T( 'LOGO_UPLOAD_LIMITS_MAX', 'Your file should not exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $logoMaxFileSize * 1024 ) ) ); } $invitesTooltip = cbTooltip( null, CBTxt::T( 'Optionally enable or disable usage of invites. Invites allow group users to invite other users to join the group. Group owner and group administrators are exempt from this configuration and can always invite users. Note existing invites will still be accessible.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['invites'] = moscomprofilerHTML::yesnoSelectList( 'params[invites]', 'class="form-control"' . $invitesTooltip, (int) $this->input( 'post/params.invites', $row->params()->get( 'invites', 1 ), GetterInterface::INT ), CBTxt::T( 'Enable' ), CBTxt::T( 'Disable' ), false ); $ownerTooltip = cbTooltip( null, CBTxt::T( 'Input the group owner id. Group owner determines the creator of the group specified as User ID.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['user_id'] = '<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $this->input( 'user', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . $ownerTooltip . ' />'; HTML_groupjiveGroupEdit::showGroupEdit( $row, $input, $category, $user, $this ); }
/** * formats variable array into data attribute string * * @param FieldTable $field * @param UserTable $user * @param string $output * @param string $reason * @param array $attributeArray * @return null|string */ protected function getDataAttributes($field, $user, $output, $reason, $attributeArray = array()) { if (!is_array($attributeArray)) { $attributeArray = array(); } $fieldMinLength = $this->getMinLength($field); if ($fieldMinLength > 0) { $attributeArray[] = cbValidator::getRuleHtmlAttributes('minlength', (int) $fieldMinLength); } $fieldMaxLength = $this->getMaxLength($field); if ($fieldMaxLength > 0) { $attributeArray[] = cbValidator::getRuleHtmlAttributes('maxlength', (int) $fieldMaxLength); } if (isset($field->_identicalTo)) { $attributeArray[] = cbValidator::getRuleHtmlAttributes('equalto', '#' . $field->_identicalTo); } if (count($attributeArray) > 0) { $attributes = ' ' . implode(' ', $attributeArray); } else { $attributes = null; } return $attributes; }
/** * * * @param FieldTable $field * @param UserTable $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists * @param boolean $displayFieldIcons * @return string HTML: <tag type="$type" value="$value" xxxx="xxx" yy="y" /> */ function _htmlEditForm(&$field, &$user, $output, $reason, $displayFieldIcons = true) { global $_CB_framework; $fieldName = $field->get('name'); $value = $user->get($fieldName); $required = $this->_isRequired($field, $user, $reason); $uploadSizeLimitMax = $field->params->get('fieldValidateAudio_sizeMax', 1024); $uploadSizeLimitMin = $field->params->get('fieldValidateAudio_sizeMin', 0); $uploadExtensionLimit = $this->allowedExtensions(); $restrictions = array(); if ($uploadExtensionLimit) { $restrictions[] = CBTxt::Th('AUDIO_FILE_UPLOAD_LIMITS_EXT', 'Your audio file must be of [ext] type.', array('[ext]' => implode(', ', $uploadExtensionLimit))); } if ($uploadSizeLimitMin) { $restrictions[] = CBTxt::Th('AUDIO_FILE_UPLOAD_LIMITS_MIN', 'Your audio file should exceed [size].', array('[size]' => $this->formattedFileSize($uploadSizeLimitMin * 1024))); } if ($uploadSizeLimitMax) { $restrictions[] = CBTxt::Th('AUDIO_FILE_UPLOAD_LIMITS_MAX', 'Your audio file should not exceed [size].', array('[size]' => $this->formattedFileSize($uploadSizeLimitMax * 1024))); } $existingFile = $user->get('id') ? $value != null ? true : false : false; $choices = array(); if ($reason == 'register' || $reason == 'edit' && $user->id == 0) { if ($required == 0) { $choices[] = moscomprofilerHTML::makeOption('', CBTxt::T('No audio file')); } } else { if ($existingFile || $required == 0) { $choices[] = moscomprofilerHTML::makeOption('', CBTxt::T('No change of audio file')); } } $selected = null; if ($required == 1 && !$existingFile) { $selected = 'upload'; } if ($field->params->get('audio_allow_links', 1)) { $choices[] = moscomprofilerHTML::makeOption('link', $existingFile ? CBTxt::T('Link to new audio file') : CBTxt::T('Link to audio file')); } $choices[] = moscomprofilerHTML::makeOption('upload', $existingFile ? CBTxt::T('Upload new audio file') : CBTxt::T('Upload audio file')); if ($existingFile && $required == 0) { $choices[] = moscomprofilerHTML::makeOption('delete', CBTxt::T('Remove audio file')); } $return = null; if ($reason != 'register' && $user->id != 0 && $existingFile) { $return .= '<div class="form-group cb_form_line clearfix">' . $this->getEmbed($field, $user, $value, $reason) . '</div>'; } if (count($choices) > 1) { static $functOut = false; $additional = ' class="form-control"'; if ($_CB_framework->getUi() == 1 && $reason == 'edit' && $field->get('readonly')) { $additional .= ' disabled="disabled"'; } $translatedTitle = $this->getFieldTitle($field, $user, 'html', $reason); $htmlDescription = $this->getFieldDescription($field, $user, 'htmledit', $reason); $trimmedDescription = trim(strip_tags($htmlDescription)); $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, $additional) : $additional; $return .= '<div class="form-group cb_form_line clearfix">' . moscomprofilerHTML::selectList($choices, $fieldName . '__choice', $tooltip, 'value', 'text', $selected, $required, true, null, false) . $this->_fieldIconsHtml($field, $user, 'htmledit', $reason, 'select', '', null, '', array(), $displayFieldIcons, $required) . '</div>'; if (!$functOut) { $js = "function cbslideAudioFile( choice, name ) {" . "if ( ( choice == '' ) || ( choice == 'delete' ) ) {" . "\$( '#cbaudiofile_upload_' + name + ',#cbaudiofile_link_' + name ).slideUp( 'slow' );" . "\$( '#cbaudiofile_upload_' + name + ' input,#cbaudiofile_link_' + name + ' input' ).prop( 'readonly', true );" . "} else if ( choice == 'upload' ) {" . "\$( '#cbaudiofile_link_' + name ).slideUp( 'slow' );" . "\$( '#cbaudiofile_upload_' + name ).slideDown( 'slow' );" . "\$( '#cbaudiofile_link_' + name + ' input' ).prop( 'readonly', true );" . "\$( '#cbaudiofile_upload_' + name + ' input' ).prop( 'readonly', false );" . "} else if ( choice == 'link' ) {" . "\$( '#cbaudiofile_upload_' + name ).slideUp( 'slow' );" . "\$( '#cbaudiofile_link_' + name ).slideDown( 'slow' );" . "\$( '#cbaudiofile_upload_' + name + ' input' ).prop( 'readonly', true );" . "\$( '#cbaudiofile_link_' + name + ' input' ).prop( 'readonly', false );" . "}" . "}"; $_CB_framework->outputCbJQuery($js); $functOut = true; } $js = "\$( '#cbaudiofile_upload_" . addslashes($fieldName) . ",#cbaudiofile_link_" . addslashes($fieldName) . "' ).hide();" . "\$( '#cbaudiofile_upload_" . addslashes($fieldName) . " input,#cbaudiofile_link_" . addslashes($fieldName) . " input' ).prop( 'readonly', true );" . "\$( '#" . addslashes($fieldName) . "__choice' ).on( 'click change', function() {" . "cbslideAudioFile( \$( this ).val(), '" . addslashes($fieldName) . "' );" . "}).change();"; $_CB_framework->outputCbJQuery($js); } else { $return .= '<input type="hidden" name="' . htmlspecialchars($fieldName) . '__choice" value="' . htmlspecialchars($choices[0]->value) . '" />'; } $validationAttributes = array(); $validationAttributes[] = cbValidator::getRuleHtmlAttributes('extension', implode(',', $uploadExtensionLimit)); if ($uploadSizeLimitMin || $uploadSizeLimitMax) { $validationAttributes[] = cbValidator::getRuleHtmlAttributes('filesize', array($uploadSizeLimitMin, $uploadSizeLimitMax, 'KB')); } $return .= '<div id="cbaudiofile_upload_' . htmlspecialchars($fieldName) . '" class="form-group cb_form_line clearfix">' . ($restrictions ? '<div class="help-block">' . implode(' ', $restrictions) . '</div>' : null) . '<div>' . CBTxt::T('Select audio file') . ' <input type="file" name="' . htmlspecialchars($fieldName) . '__file" value="" class="form-control' . ($required == 1 ? ' required' : null) . '"' . implode(' ', $validationAttributes) . ' />' . (count($choices) <= 0 ? $this->_fieldIconsHtml($field, $user, 'htmledit', $reason, 'select', '', null, '', array(), $displayFieldIcons, $required) : null) . '</div>' . '<div class="help-block">'; if ($field->params->get('audio_terms', 0)) { $termsOutput = $field->params->get('terms_output', 'url'); $termsType = CBTxt::T($field->params->get('terms_type', null)); $termsDisplay = $field->params->get('terms_display', 'modal'); $termsURL = $field->params->get('terms_url', null); $termsText = $field->params->get('terms_text', null); $termsWidth = (int) $field->params->get('terms_width', 400); $termsHeight = (int) $field->params->get('terms_height', 200); if (!$termsType) { $termsType = CBTxt::T('TERMS_AND_CONDITIONS', 'Terms and Conditions'); } if (!$termsWidth) { $termsWidth = 400; } if (!$termsHeight) { $termsHeight = 200; } if ($termsOutput == 'url' && $termsURL || $termsOutput == 'text' && $termsText) { if ($termsDisplay == 'iframe') { if (is_numeric($termsHeight)) { $termsHeight .= 'px'; } if (is_numeric($termsWidth)) { $termsWidth .= 'px'; } if ($termsOutput == 'url') { $return .= '<div class="embed-responsive cbTermsFrameContainer" style="padding-bottom: ' . htmlspecialchars($termsHeight) . ';">' . '<iframe class="embed-responsive-item cbTermsFrameURL" style="width: ' . htmlspecialchars($termsWidth) . ';" src="' . htmlspecialchars($termsURL) . '"></iframe>' . '</div>'; } else { $return .= '<div class="cbTermsFrameText" style="height:' . htmlspecialchars($termsHeight) . ';width:' . htmlspecialchars($termsWidth) . ';overflow:auto;">' . $termsText . '</div>'; } $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE_TERMS', 'By uploading, you certify that you have the right to distribute this audio file and that it does not violate the above [type].', array('[type]' => $termsType)); } else { $attributes = ' class="cbTermsLink"'; if ($termsOutput == 'text' && $termsDisplay == 'window') { $termsDisplay = 'modal'; } if ($termsDisplay == 'modal') { // Tooltip height percentage would be based off window height (including scrolling); lets change it to be based off the viewport height: $termsHeight = substr($termsHeight, -1) == '%' ? (int) substr($termsHeight, 0, -1) . 'vh' : $termsHeight; if ($termsOutput == 'url') { $tooltip = '<iframe class="cbTermsModalURL" height="100%" width="100%" src="' . htmlspecialchars($termsURL) . '"></iframe>'; } else { $tooltip = '<div class="cbTermsModalText" style="height:100%;width:100%;overflow:auto;">' . $termsText . '</div>'; } $url = 'javascript:void(0);'; $attributes .= ' ' . cbTooltip($_CB_framework->getUi(), $tooltip, $termsType, array($termsWidth, $termsHeight), null, null, null, 'data-hascbtooltip="true" data-cbtooltip-modal="true"'); } else { $url = htmlspecialchars($termsURL); $attributes .= ' target="_blank"'; } $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE_URL_TERMS', 'By uploading, you certify that you have the right to distribute this audio file and that it does not violate the <a href="[url]"[attributes]>[type]</a>', array('[url]' => $url, '[attributes]' => $attributes, '[type]' => $termsType)); } } else { $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE', 'By uploading, you certify that you have the right to distribute this audio file.'); } } else { $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE', 'By uploading, you certify that you have the right to distribute this audio file.'); } $return .= '</div>' . '</div>' . '<div id="cbaudiofile_link_' . htmlspecialchars($fieldName) . '" class="form-group cb_form_line clearfix">' . '<p>'; if ($field->params->get('audio_allow_links', 1)) { $linkField = new FieldTable($field->getDbo()); foreach (array_keys(get_object_vars($linkField)) as $k) { $linkField->set($k, $field->get($k)); } $linkField->set('type', 'text'); $linkField->set('description', null); $user->set($fieldName, strpos($value, '/') !== false || strpos($value, '\\') !== false ? $value : null); $return .= parent::getField($linkField, $user, $output, $reason, 0); $user->set($fieldName, $value); unset($linkField); } $return .= '</p>' . '</div>'; return $return; }
/** * prepare frontend file edit render * * @param int $id * @param UserTable $user */ private function showFileEdit( $id, $user ) { global $_CB_framework; $row = CBGroupJiveFile::getFile( (int) $id ); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $groupId = $this->input( 'group', null, GetterInterface::INT ); if ( $groupId === null ) { $group = $row->group(); } else { $group = CBGroupJive::getGroup( $groupId ); } $returnUrl = $_CB_framework->pluginClassUrl( $this->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ); if ( ! CBGroupJive::canAccessGroup( $group, $user ) ) { cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' ); } elseif ( ! $isModerator ) { if ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'file' ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to upload a file in this group.' ), 'error' ); } elseif ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) && ( CBGroupJive::getGroupStatus( $user, $group ) < 2 ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this file.' ), 'error' ); } } CBGroupJive::getTemplate( 'file_edit', true, true, $this->element ); $minFileSize = $this->params->get( 'groups_file_min_size', 0 ); $maxFileSize = $this->params->get( 'groups_file_max_size', 1024 ); $extensions = explode( ',', $this->params->get( 'groups_file_extensions', 'zip,rar,doc,pdf,txt,xls' ) ); $fileValidation = array(); if ( $minFileSize || $maxFileSize ) { $fileValidation[] = cbValidator::getRuleHtmlAttributes( 'filesize', array( $minFileSize, $maxFileSize, 'KB' ) ); } if ( $extensions ) { $fileValidation[] = cbValidator::getRuleHtmlAttributes( 'extension', implode( ',', $extensions ) ); } $input = array(); $publishedTooltip = cbTooltip( null, CBTxt::T( 'Select publish state of this file. Unpublished files will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . $publishedTooltip, (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) ); $titleTooltup = cbTooltip( null, CBTxt::T( 'Optionally input a file title to display instead of filename.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['title'] = '<input type="text" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="form-control" size="35"' . $titleTooltup . ' />'; $fileTooltip = cbTooltip( null, CBTxt::T( 'Select the file to upload.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['file'] = '<input type="file" id="file" name="file" value="" class="form-control' . ( ! $row->get( 'id' ) ? ' required' : null ) . '"' . ( $fileTooltip ? ' ' . $fileTooltip : null ) . ( $fileValidation ? implode( ' ', $fileValidation ) : null ) . ' />'; $input['file_limits'] = array(); if ( $extensions ) { $input['file_limits'][] = CBTxt::T( 'GROUP_FILE_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => implode( ', ', $extensions ) ) ); } if ( $minFileSize ) { $input['file_limits'][] = CBTxt::T( 'GROUP_FILE_LIMITS_MIN', 'Your file should exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $minFileSize * 1024 ) ) ); } if ( $maxFileSize ) { $input['file_limits'][] = CBTxt::T( 'GROUP_FILE_LIMITS_MAX', 'Your file should not exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $maxFileSize * 1024 ) ) ); } $descriptionTooltip = cbTooltip( null, CBTxt::T( 'Optionally input a file description.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['description'] = '<textarea id="description" name="description" class="form-control" cols="40" rows="5"' . ( $descriptionTooltip ? ' ' . $descriptionTooltip : null ) . '>' . htmlspecialchars( $this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING ) ) . '</textarea>'; $ownerTooltip = cbTooltip( null, CBTxt::T( 'Input the file owner id. File owner determines the creator of the file specified as User ID.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['user_id'] = '<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $this->input( 'user', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . $ownerTooltip . ' />'; HTML_groupjiveFileEdit::showFileEdit( $row, $input, $group, $user, $this ); }
static function lostPassForm($option) { global $_CB_framework, $ueConfig, $_PLUGINS; $results = $_PLUGINS->trigger('onLostPassForm', array(1)); if ($_PLUGINS->is_errors()) { echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n"; exit; } $regAntiSpamValues = cbGetRegAntiSpams(); $usernameExists = isset($ueConfig['login_type']) && $ueConfig['login_type'] != 2; $pageTitle = $usernameExists ? CBTxt::Th('UE_LOST_USERNAME_OR_PASSWORD', 'Lost your Username or your Password ?') : CBTxt::T('UE_LOST_YOUR_PASSWORD', 'Lost your Password ?'); outputCbTemplate(1); cbValidator::loadValidation(); initToolTip(1); $js = "\$( '#checkusername,#checkemail' ).keyup( function() {" . "\$( this ).next( '.cb_result_container' ).remove();" . "if ( \$.trim( \$( '#checkusername' ).val() ) != '' ) {" . "if ( \$.trim( \$( '#checkemail' ).val() ) == '' ) {" . "\$( '.cbLostPassSend' ).prop( 'disabled', true );" . "} else {" . "\$( '.cbLostPassSend' ).prop( 'disabled', false );" . "}" . "} else {" . "if ( \$.trim( \$( '#checkemail' ).val() ) == '' ) {" . "\$( '.cbLostPassSend' ).prop( 'disabled', true );" . "} else {" . "\$( '.cbLostPassSend' ).prop( 'disabled', false );" . "}" . "}" . "});"; if ($usernameExists) { $js .= "\$( '#reminderUsername,#reminderPassword' ).click( function() {" . "\$( '#checkusername,#checkemail' ).next( '.cb_result_container' ).remove();" . "\$( '#checkusername,#checkemail' ).val( '' );" . "\$( '.cbLostPassSend' ).prop( 'disabled', true );" . "\$( '.cb_forgot_line,.cb_forgot_button' ).show();" . "if ( \$( '#reminderUsername' ).prop( 'checked' ) ) {" . "if ( \$( '#reminderPassword' ).prop( 'checked' ) ) {" . "\$( '.cbLostPassSend' ).val( '" . addslashes(CBTxt::Th('UE_BUTTON_SEND_USERNAME_PASS', 'Send Username/Password')) . "' );" . "\$( '#lostusernamedesc,#lostpassdesc' ).hide();" . "\$( '#lostusernamepassdesc' ).show();" . "} else {" . "\$( '.cbLostPassSend' ).val( '" . addslashes(CBTxt::Th('UE_BUTTON_SEND_USERNAME', 'Send Username')) . "' );" . "\$( '#lostusernamepassdesc,#lostpassdesc' ).hide();" . "\$( '#lostusernamedesc' ).show();" . "}" . "\$( '#lostpassusername' ).hide();" . "\$( '#lostpassemail' ).show();" . "} else {" . "if ( \$( '#reminderPassword' ).prop( 'checked' ) ) {" . "\$( '.cbLostPassSend' ).val( '" . addslashes(CBTxt::Th('UE_BUTTON_SEND_PASS', 'Send Password')) . "' );" . "\$( '#lostusernamepassdesc,#lostusernamedesc' ).hide();" . "\$( '#lostpassusername,#lostpassemail,#lostpassdesc' ).show();" . "} else {" . "\$( '.cb_forgot_line,.cb_forgot_button,#lostusernamepassdesc,#lostusernamedesc,#lostpassdesc' ).hide();" . "}" . "}" . "});" . "\$( '.cb_forgot_line,.cb_forgot_button,#lostusernamepassdesc,#lostusernamedesc,#lostpassdesc' ).hide();"; } $_CB_framework->outputCbJQuery($js); $pageClass = $_CB_framework->getMenuPageClass(); $return = '<div class="cbLostPassForm cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">' . ($pageTitle ? '<div class="page-header"><h3>' . $pageTitle . '</h3></div>' : null) . '<form action="' . $_CB_framework->viewUrl('sendNewPass', true, null, 'html', checkCBPostIsHTTPS(true) ? 1 : 0) . '" method="post" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">'; if ($usernameExists) { $return .= '<div class="form-group cb_form_line clearfix" id="lostpassreminder">' . '<label class="col-sm-3 control-label">' . CBTxt::Th('UE_REMINDER_NEEDED_FOR', 'Reminder needed for') . '</label>' . '<div class="cb_field col-sm-9">' . '<span class="cbSingleCntrl">' . '<label for="reminderUsername" class="checkbox-inline">' . '<input type="checkbox" id="reminderUsername" name="typeofloose[]" value="username" /> ' . CBTxt::Th('UE_LOST__USERNAME', 'Lost Username') . '</label>' . '</span>' . '<span class="cbSingleCntrl">' . '<label for="reminderPassword" class="checkbox-inline">' . '<input type="checkbox" id="reminderPassword" name="typeofloose[]" value="password" /> ' . CBTxt::Th('UE_LOST__PASSWORD', 'Lost Password') . '</label>' . '</span>' . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix" id="lostusernamedesc">' . '<div class="cb_field col-sm-offset-3 col-sm-9">' . CBTxt::Th('UE_LOST_USERNAME_ONLY_DESC', 'If you <strong>lost your username</strong>, please enter your E-mail Address, then click the Send Username button, and your username will be sent to your email address.') . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix" id="lostusernamepassdesc">' . '<div class="cb_field col-sm-offset-3 col-sm-9">' . CBTxt::Th('UE_LOST_USERNAME_PASSWORD_DESC', 'If you <strong>forgot both your username and your password</strong>, please recover the username first, then the password. To recover your username, please enter your E-mail Address, leaving Username field empty, then click the Send Username button, and your username will be sent to your email address. From there you can use this same form to recover your password.') . '</div>' . '</div>'; } $return .= '<div class="form-group cb_form_line clearfix" id="lostpassdesc">' . '<div class="cb_field col-sm-offset-3 col-sm-9">'; if ($usernameExists) { $return .= CBTxt::Th('UE_LOST_PASSWORD_DESC', 'If you <strong>lost your password</strong> but know your username, please enter your Username and your E-mail Address, press the Send Password button, and you will receive a new password shortly. Use this new password to access the site.'); } else { $return .= CBTxt::Th('UE_LOST_PASSWORD_EMAIL_ONLY_DESC', 'If you <strong>lost your password</strong>, please enter your E-mail Address, then click the Send Password button, and you will receive a new password shortly. Use this new password to access the site.'); } $return .= '</div>' . '</div>'; if ($usernameExists) { $usernameValidation = cbValidator::getRuleHtmlAttributes('cbfield', array('user' => 0, 'field' => 'username', 'reason' => 'register', 'function' => 'testexists')); $return .= '<div class="cb_forgot_line form-group cb_form_line clearfix" id="lostpassusername">' . '<label for="checkusername" class="col-sm-3 control-label">' . CBTxt::Th('PROMPT_UNAME', 'Username:'******'</label>' . '<div class="cb_field col-sm-9">' . '<input type="text" name="checkusername" id="checkusername" class="form-control" size="30" maxlength="255"' . $usernameValidation . ' />' . '</div>' . '</div>'; } $emailValidation = cbValidator::getRuleHtmlAttributes('cbfield', array('user' => 0, 'field' => 'email', 'reason' => 'register', 'function' => 'testexists')); $return .= '<div class="cb_forgot_line form-group cb_form_line clearfix" id="lostpassemail">' . '<label for="checkemail" class="col-sm-3 control-label">' . CBTxt::Th('PROMPT_EMAIL', 'E-mail Address:') . '</label>' . '<div class="cb_field col-sm-9">' . '<input type="text" name="checkemail" id="checkemail" class="form-control" size="30" maxlength="255"' . $emailValidation . ' />' . '</div>' . '</div>'; if (is_array($results)) { foreach ($results as $result) { if ($result) { $return .= '<div class="cb_forgot_line form-group cb_form_line clearfix">' . '<label' . (isset($result[2]) ? ' for="' . htmlspecialchars($result[2]) . '"' : null) . ' class="col-sm-3 control-label">' . (isset($result[0]) ? $result[0] : null) . '</label>' . '<div class="cb_field col-sm-9">' . (isset($result[1]) ? $result[1] : null) . '</div>' . '</div>'; } } } $return .= '<div class="cb_forgot_button form-group cb_form_line clearfix">' . '<div class="col-sm-offset-3 col-sm-9">' . '<input type="submit" class="btn btn-primary cbLostPassSend" value="' . htmlspecialchars($usernameExists ? CBTxt::Th('UE_BUTTON_SEND_USERNAME_PASS', 'Send Username/Password') : CBTxt::Th('UE_BUTTON_SEND_PASS', 'Send Password')) . '" disabled="disabled"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />' . '</div>' . '</div>'; if (!$usernameExists) { $return .= '<input type="hidden" name="typeofloose[]" value="password" />'; } $return .= cbGetSpoofInputTag('lostPassForm') . cbGetRegAntiSpamInputTag($regAntiSpamValues) . '</form>' . '</div>' . cbPoweredBy(); echo $return; $_CB_framework->setMenuMeta(); }
/** * Displays item create/edit page * * @param int $id * @param string $type * @param TabTable $tab * @param UserTable $user * @param UserTable $viewer * @param null|string $message * @param null|string $messageType */ public function showItemEdit( $id, $type, $tab, $user, $viewer, $message = null, $messageType = 'error' ) { global $_CB_framework, $_CB_database; /** @var Registry $params */ $params = $tab->params; $row = new cbgalleryItemTable(); $row->load( (int) $id ); if ( ! $row->get( 'id' ) ) { $row->set( 'folder', $this->input( 'folder', 0, GetterInterface::INT ) ); } $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); $canAccess = false; if ( ! $row->get( 'id' ) ) { if ( ( $user->get( 'id' ) != $viewer->get( 'id' ) ) && ( ! $cbModerator ) ) { $user = $viewer; } $canAccess = cbgalleryClass::canUserCreate( $viewer, $type, false ); } elseif ( ( $row->get( 'type' ) == $type ) && ( $cbModerator || ( $viewer->get( 'id' ) == $row->get( 'user_id' ) ) ) ) { $canAccess = true; } if ( $row->get( 'folder' ) ) { $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'folders', 'func' => 'show', 'type' => $type, 'id' => (int) $row->get( 'folder' ), 'user' => (int) $user->get( 'id' ), 'tab' => (int) $tab->get( 'tabid' ) ) ); } else { $returnUrl = $_CB_framework->userProfileUrl( (int) $row->get( 'user_id', $user->get( 'id' ) ), false, $tab->get( 'tabid' ) ); } if ( ! $canAccess ) { cbRedirect( $returnUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } $minFileSize = $this->params->get( $type . '_item_min_size', 0 ); $maxFileSize = $this->params->get( $type . '_item_max_size', 1024 ); switch( $type ) { case 'photos': $typeTranslated = CBTxt::T( 'Photo' ); break; case 'files': $typeTranslated = CBTxt::T( 'File' ); break; case 'videos': $typeTranslated = CBTxt::T( 'Video' ); break; case 'music': $typeTranslated = CBTxt::T( 'Music' ); break; default: $typeTranslated = CBTxt::T( 'Item' ); break; } $extLimit = cbgalleryClass::getExtensions( $type ); switch( $type ) { case 'photos': case 'videos': case 'music': $folderType = CBTxt::T( 'Album' ); break; default: $folderType = CBTxt::T( 'Folder' ); break; } cbgalleryClass::getTemplate( 'item_edit' ); $input = array(); $publishedTooltip = cbTooltip( null, CBTxt::T( 'ITEM_PUBLISHED_DESCRIPTION', 'Select publish status of the [type]. If unpublished the [type] will not be visible to the public.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . ( $publishedTooltip ? ' ' . $publishedTooltip : null ), (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) ); $titleTooltip = cbTooltip( null, CBTxt::T( 'ITEM_TITLE_DESCRIPTION', 'Optionally input a title. If no title is provided the filename will be displayed as the title.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['title'] = '<input type="title" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="form-control" size="25"' . ( $titleTooltip ? ' ' . $titleTooltip : null ) . ' />'; $listFolders = array(); if ( cbgalleryClass::canUserCreate( $viewer, $type, true ) ) { $listFolders[] = moscomprofilerHTML::makeOption( -1, CBTxt::T( 'ITEM_NEW_FOLDER', 'New [type]', array( '[type]' => $folderType ) ) ); } if ( $params->get( 'tab_' . $type . '_uncategorized', 1 ) ) { $listFolders[] = moscomprofilerHTML::makeOption( 0, CBTxt::T( 'Uncategorized' ) ); } $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_folders' ) . "\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type ) . "\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $row->get( 'user_id', $user->get( 'id' ) ) . "\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " DESC"; $_CB_database->setQuery( $query ); $folders = $_CB_database->loadObjectList( null, 'cbgalleryFolderTable', array( $_CB_database ) ); /** @var cbgalleryFolderTable[] $folders */ foreach ( $folders as $folder ) { $listFolders[] = moscomprofilerHTML::makeOption( (int) $folder->get( 'id' ), ( $folder->get( 'title' ) ? $folder->get( 'title' ) : cbFormatDate( $folder->get( 'date' ), true, false ) ) ); } $folderTooltip = cbTooltip( null, CBTxt::T( 'ITEM_FOLDER_DESCRIPTION', 'Select the [folder_type] for this [type].', array( '[folder_type]' => $folderType, '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['folder'] = moscomprofilerHTML::selectList( $listFolders, 'folder', 'class="form-control"' . ( $folderTooltip ? ' ' . $folderTooltip : null ), 'value', 'text', $this->input( 'post/folder', $row->get( 'folder', 0 ), GetterInterface::INT ), 1, false, false ); $allowUpload = $this->params->get( $type . '_item_upload', 1 ); $allowLink = $this->params->get( $type . '_item_link', 0 ); if ( $allowUpload && $allowLink ) { $uploadButton = CBTxt::T( 'UPLOAD_ITEM_TYPE', 'Upload [type]', array( '[type]' => $typeTranslated ) ); $linkButton = CBTxt::T( 'LINK_ITEM_TYPE', 'Link [type]', array( '[type]' => $typeTranslated ) ); $js = "$( '#method' ).on( 'change', function() {" . "var value = $( this ).val();" . "if ( value == 1 ) {" . "$( '#itemUpload' ).removeClass( 'hidden' ).find( 'input' ).removeClass( 'cbValidationDisabled' );" . "$( '#itemLink' ).addClass( 'hidden' ).find( 'input' ).addClass( 'cbValidationDisabled' );"; if ( ! $row->get( 'id' ) ) { $js .= "$( '.galleryButtonSubmit' ).val( '" . addslashes( $uploadButton ) . "' );"; } $js .= "} else if ( value == 2 ) {" . "$( '#itemUpload' ).addClass( 'hidden' ).find( 'input' ).addClass( 'cbValidationDisabled' ).val( '' );" . "$( '#itemLink' ).removeClass( 'hidden' ).find( 'input' ).removeClass( 'cbValidationDisabled' );"; if ( ! $row->get( 'id' ) ) { $js .= "$( '.galleryButtonSubmit' ).val( '" . addslashes( $linkButton ) . "' );"; } $js .= "} else {" . "$( '#itemUpload' ).addClass( 'hidden' ).find( 'input' ).addClass( 'cbValidationDisabled' ).val( '' );" . "$( '#itemLink' ).addClass( 'hidden' ).find( 'input' ).addClass( 'cbValidationDisabled' );" . "}" . "}).change();"; $_CB_framework->outputCbJQuery( $js ); $listMethods = array(); if ( $row->get( 'id' ) ) { $listMethods[] = moscomprofilerHTML::makeOption( 0, CBTxt::T( 'No Change' ) ); } if ( $allowUpload ) { $listMethods[] = moscomprofilerHTML::makeOption( 1, CBTxt::T( 'Upload' ) ); } if ( $allowLink ) { $listMethods[] = moscomprofilerHTML::makeOption( 2, CBTxt::T( 'Link' ) ); } $input['method'] = moscomprofilerHTML::selectList( $listMethods, 'method', 'class="form-control"', 'value', 'text', $this->input( 'post/method', 0, GetterInterface::INT ), 1, false, false ); } else { $input['method'] = null; } $fileValidation = array(); if ( $minFileSize || $maxFileSize ) { $fileValidation[] = cbValidator::getRuleHtmlAttributes( 'filesize', array( $minFileSize, $maxFileSize, 'KB' ) ); } if ( $extLimit ) { $fileValidation[] = cbValidator::getRuleHtmlAttributes( 'extension', implode( ',', $extLimit ) ); } if ( $allowUpload ) { $fileTooltip = cbTooltip( null, CBTxt::T( 'ITEM_UPLOAD_DESCRIPTION', 'Select the file to upload.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['upload'] = '<input type="file" id="file" name="file" value="" class="form-control' . ( ! $row->get( 'id' ) ? ' required' : null ) . '"' . ( $fileTooltip ? ' ' . $fileTooltip : null ) . ( $fileValidation ? implode( ' ', $fileValidation ) : null ) . ' />'; $input['upload_limits'] = array(); if ( $extLimit ) { $input['upload_limits'][] = CBTxt::T( 'ITEM_UPLOAD_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => implode( ', ', $extLimit ) ) ); } if ( $minFileSize ) { $input['upload_limits'][] = CBTxt::T( 'ITEM_UPLOAD_LIMITS_MIN', 'Your file should exceed [size].', array( '[size]' => cbgalleryClass::getFormattedFileSize( $minFileSize * 1024 ) ) ); } if ( $maxFileSize ) { $input['upload_limits'][] = CBTxt::T( 'ITEM_UPLOAD_LIMITS_MAX', 'Your file should not exceed [size].', array( '[size]' => cbgalleryClass::getFormattedFileSize( $maxFileSize * 1024 ) ) ); } } else { $input['upload'] = null; $input['upload_limits'] = null; } if ( $allowLink ) { $linkTooltip = cbTooltip( null, CBTxt::T( 'ITEM_LINK_DESCRIPTION', 'Input the URL to the file to link.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['link'] = '<input type="text" id="value" name="value" value="' . htmlspecialchars( $this->input( 'post/value', ( $row->getLinkDomain() ? $row->get( 'value' ) : null ), GetterInterface::STRING ) ) . '" size="40" class="form-control' . ( ! $row->get( 'id' ) ? ' required' : null ) . '"' . ( $linkTooltip ? ' ' . $linkTooltip : null ) . ' />'; $input['link_limits'] = array(); if ( $extLimit ) { if ( $type == 'videos' ) { $extLimit[] = 'youtube'; } $input['link_limits'][] = CBTxt::T( 'ITEM_LINK_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => implode( ', ', $extLimit ) ) ); } } else { $input['link'] = null; $input['link_limits'] = null; } $descriptionTooltip = cbTooltip( null, CBTxt::T( 'ITEM_DESCRIPTION_DESCRIPTION', 'Optionally input a description.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['description'] = '<textarea id="description" name="description" class="form-control" cols="40" rows="5"' . ( $descriptionTooltip ? ' ' . $descriptionTooltip : null ) . '>' . htmlspecialchars( $this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING ) ) . '</textarea>'; $ownerTooltip = cbTooltip( null, CBTxt::T( 'ITEM_OWNER_DESCRIPTION', 'Input owner as single integer user_id.', array( '[type]' => $typeTranslated ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['user_id'] = '<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . ( $ownerTooltip ? ' ' . $ownerTooltip : null ) . ' />'; if ( $message ) { $_CB_framework->enqueueMessage( $message, $messageType ); } HTML_cbgalleryItemEdit::showItemEdit( $row, $input, $type, $tab, $user, $viewer, $this ); }
/** * formats variable array into data attribute string * * @param FieldTable $field * @param UserTable $user * @param string $output * @param string $reason * @param array $attributeArray * @return null|string */ protected function getDataAttributes( $field, $user, $output, $reason, $attributeArray = array() ) { if ( $field->params->get( 'cbantispam_captcha_ajax_valid', 0 ) ) { $attributeArray[] = cbValidator::getRuleHtmlAttributes( 'cbfield', array( 'user' => (int) $user->id, 'field' => htmlspecialchars( $field->name ), 'reason' => htmlspecialchars( $reason ) ) ); } return parent::getDataAttributes( $field, $user, $output, $reason, $attributeArray ); }