public function public_context() { if (function_exists('declare_shortcut') && get_instance()->users_global->isConnected()) { if (current_user_can('publish_posts@blogster')) { declare_shortcut(__('Write a new post'), $this->url->site_url(array('admin', 'open', 'modules', $this->module['namespace'], 'publish'))); } if (current_user_can('category_manage@blogster')) { declare_shortcut(__('Categories'), $this->url->site_url(array('admin', 'open', 'modules', $this->module['namespace'], 'category'))); } } }
/** * declare_shortcut **/ function declare_shortcut($text, $link, $mod_namespace = '', $mod_name = '') { if (is_array($text)) { if (array_key_exists('text', $text) && array_key_exists('link', $text) && array_key_exists('mod_namespace', $text) && array_key_exists('mod_name', $text)) { return declare_shortcut($text['text'], $text['link'], $text['mod_namespace'], $text['mod_name']); } return false; } else { $declared = get_core_vars('declared_shortcuts') ? get_core_vars('declared_shortcuts') : array(); $shortcut = array('link' => $link, 'text' => $text, 'mod_namespace' => $mod_namespace, 'mod_name' => $mod_name); array_push($declared, $shortcut); return set_core_vars('declared_shortcuts', $declared); } }