Customizing SMF > SMF Coding Discussion

Custom Permission Code Help

(1/3) > >>

Iomega0318:
Ok I redid the post and made all the code a LOT shorter, my php file is also uploaded if you need to look at all the coding.
What I need is help adding a custom permission to Subs-Editor.php the permission will basically allow admins to see it but not anyone else, the code I need "blocked" is highlighted in red below:


--- Quote --- if (empty($context['bbc_tags']))
{
// The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!
$context['bbc_tags'] = array();
$context['bbc_tags'][] = array(
array(
'image' => 'bold',
'code' => 'b',
'before' => '[b]',
'after' => '[/b]',
'description' => $txt['bold'],
),
array(
'image' => 'italicize',
'code' => 'i',
'before' => '[i]',
'after' => '[/i]',
'description' => $txt['italic'],
),
array(
'image' => 'underline',
'code' => 'u',
'before' => '[u]',
'after' => '[/u]',
'description' => $txt['underline']
),
array(
'image' => 'strike',
'code' => 's',
'before' => '[s]',
'after' => '[/s]',
'description' => $txt['strike']
),
array(),
array(
'image' => 'pre',
'code' => 'pre',
'before' => '[pre]',
'after' => '[/pre]',
'description' => $txt['preformatted']
),
array(
'image' => 'left',
'code' => 'left',
'before' => '[left]',
'after' => '[/left]',
'description' => $txt['left_align']
),
array(
'image' => 'center',
'code' => 'center',
'before' => '[center]',
'after' => '[/center]',
'description' => $txt['center']
),
array(
'image' => 'right',
'code' => 'right',
'before' => '[right]',
'after' => '[/right]',
'description' => $txt['right_align']
),
);
$context['bbc_tags'][] = array(
array(
'image' => 'flash',
'code' => 'flash',
'before' => '[flash=200,200]http://',
'after' => '[/flash]',
'description' => $txt['flash']
),
array(
'image' => 'img',
'code' => 'img',
'before' => '[img]http://',
'after' => '[/img]',
'description' => $txt['image']
),
array(
'image' => 'url',
'code' => 'url',
'before' => '[url=http://',
'after' => ']',
'after' => '[/url]',
'description' => $txt['hyperlink']
),
array(
'image' => 'email',
'code' => 'email',
'before' => '[email]',
'after' => '[/email]',
'description' => $txt['insert_email']
),
array(
'image' => 'ftp',
'code' => 'ftp',
'before' => '[ftp=ftp://',
'after' => ']',
'after' => '[/ftp]',
'description' => $txt['ftp']
),
         array(),
         array(
         'image' => 'error',
         'code' => 'error',
         'before' => '[error]',
         'after' => '[/error]',
         'description' => $txt['error_bbc']),
         
         array(
         'image' => 'warning',
         'code' => 'warning',
         'before' => '[warning]',
         'after' => '[/warning]',
         'description' => $txt['warning_bbc']),
         
         array(
         'image' => 'okay',
         'code' => 'okay',
         'before' => '[okay]',
         'after' => '[/okay]',
         'description' => $txt['okay_bbc']),
         
         array(
         'image' => 'info',
         'code' => 'info',
         'before' => '[info]',
         'after' => '[/info]',
         'description' => $txt['info_bbc']),
         array(),
array(
'image' => 'glow',
'code' => 'glow',
'before' => '[glow=red,2,300]',
'after' => '[/glow]',
'description' => $txt['glow']
),
array(
'image' => 'shadow',
'code' => 'shadow',
'before' => '[shadow=red,left]',
'after' => '[/shadow]',
'description' => $txt['shadow']
),
array(
'image' => 'move',
'code' => 'move',
'before' => '[move]',
'after' => '[/move]',
'description' => $txt['marquee']
),
array(),
array(
'image' => 'sup',
'code' => 'sup',
'before' => '[sup]',
'after' => '[/sup]',
'description' => $txt['superscript']
),
array(
'image' => 'sub',
'code' => 'sub',
'before' => '[sub]',
'after' => '[/sub]',
'description' => $txt['subscript']
),
array(
'image' => 'tele',
'code' => 'tt',
'before' => '[tt]',
'after' => '[/tt]',
'description' => $txt['teletype']
),
array(),
array(
'image' => 'tabletrtd',
'code' => 'tabletrtd',
'before' => '[table][tr][td]\n[table][tr][td]\n[table][tr][td]',
'after' => '[/td][td][/td][/tr][/table]\n[/td][/tr][/table]\n',
'description' => $txt['table']
),
array(
'image' => 'tr',
'code' => 'tr',
'before' => '[table][tr][td]\n[table][tr][td]',
'after' => '[/td][td][/td][/tr][/table]\n[/td][/tr][/table]',
'description' => $txt['table_tr']
),
array(
'image' => 'td',
'code' => 'td',
'before' => '[table][tr][td]',
'after' => '[/td][/tr][/table]',
'description' => $txt['table_td']
),
array(
'image' => 'code',
'code' => 'code',
'before' => '[/td][/tr][/table][code]',
'after' => '[/code]',
'description' => $txt['bbc_code']
),
array(
'image' => 'quote',
'code' => 'quote',
'before' => '[quote]',
'after' => '[/quote]',
'description' => $txt['bbc_quote']
),
array(),
array(
'image' => 'list',
'code' => 'list',
'before' => '[list]\n[list][li]',
'after' => '[/li][/list]\n[list][li][/li][/list]\n[/list]',
'description' => $txt['list_unordered']
),
array(
'image' => 'orderlist',
'code' => 'orderlist',
'before' => '[list type=decimal]\n[list][li]',
'after' => '[/li][/list]\n[list][li][/li][/list]\n[/list]',
'description' => $txt['list_ordered']
),
array(
'image' => 'hr',
'code' => 'hr',
'before' => '[hr]',
'description' => $txt['horizontal_rule']
),
);
--- End quote ---

The example I used was this:

--- Code: ---if (allowedTo('view_this'))
echo 'Yes, you can see this.';
else
echo 'Nope, say goodbye';

--- End code ---

So I tried this and it didn't work:

--- Code: --- if (allowedTo('view_this'))
echo '
array(),
array(
'image' => 'error',
'code' => 'error',
'before' => '[error]',
'after' => '[/error]',
'description' => $txt['error_bbc']),

array(
'image' => 'warning',
'code' => 'warning',
'before' => '[warning]',
'after' => '[/warning]',
'description' => $txt['warning_bbc']),

array(
'image' => 'okay',
'code' => 'okay',
'before' => '[okay]',
'after' => '[/okay]',
'description' => $txt['okay_bbc']),

array(
'image' => 'info',
'code' => 'info',
'before' => '[info]',
'after' => '[/info]',
'description' => $txt['info_bbc']),
array(),';
else
echo 'array(),';
--- End code ---

So if someone could help me figure out how to add that in that would be awesome!

I was also wanting to put those BBC Boxes for those bits on another line if that makes sense but have no clue where to start with that.. any help or advice would be greatly appreciated, thank you.

AngelinaBelle:
Hello Iomega0318,

I cannot find the section highlighted in red in the quoted section.
I hope you won't mind me moving this to an SMF customization board, where I hope it will attract more attention from others with experience customizing SMF.

Suki:
@Iomega0318 please do use the code tag: [code]code here![/code]  when posting bits of code, makes things easier for everyone.

Which is the specific part you want to modify?

What is the part that you want to be only visible for admins?

Iomega0318:
I will have to redo my post, give me a sec lol.. When it got moved it broke the BBCodes.. and I had only used qoutes because if it's in code tags it won't highlight colors..

**EDIT**
Ok I edited the first post, should be much easier to read now and I deleted most of the code, my file is uploaded as well if you need to see the rest.

AngelinaBelle:
I don't know what broke the BBCodes -- they were already broken before I moved your post.
I'm glad you were able to put back the highlighting.

I had always assumed that you chose quote instead of  [code] because you specifically wanted the bbcode highlighting.

I hope you find someone who can help you figure this out.

----------
edit: put [ nobbc] tags around code tag...

Navigation

[0] Message Index

[#] Next page

Go to full version