本文整理汇总了PHP中coursecat::can_create_subcategory方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::can_create_subcategory方法的具体用法?PHP coursecat::can_create_subcategory怎么用?PHP coursecat::can_create_subcategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coursecat
的用法示例。
在下文中一共展示了coursecat::can_create_subcategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: category_listing_actions
/**
* Renderers the actions that are possible for the course category listing.
*
* These are not the actions associated with an individual category listing.
* That happens through category_listitem_actions.
*
* @param coursecat $category
* @return string
*/
public function category_listing_actions(coursecat $category = null)
{
$actions = array();
$cancreatecategory = $category && $category->can_create_subcategory();
$cancreatecategory = $cancreatecategory || coursecat::can_create_top_level_category();
if ($category === null) {
$category = coursecat::get(0);
}
if ($cancreatecategory) {
$url = new moodle_url('/course/editcategory.php', array('parent' => $category->id));
$actions[] = html_writer::link($url, get_string('createnewcategory'));
}
if (coursecat::can_approve_course_requests()) {
$actions[] = html_writer::link(new moodle_url('/course/pending.php'), get_string('coursespending'));
}
if (count($actions) === 0) {
return '';
}
return html_writer::div(join(' | ', $actions), 'listing-actions category-listing-actions');
}
示例2: get_category_listitem_actions
/**
* Returns an array of actions that can be performed upon a category being shown in a list.
*
* @param \coursecat $category
* @return array
*/
public static function get_category_listitem_actions(\coursecat $category)
{
global $PAGE;
$baseurl = new \moodle_url('/course/management.php', array('categoryid' => $category->id, 'sesskey' => \sesskey()));
$actions = array();
// Edit.
if ($category->can_edit()) {
$actions['edit'] = array('url' => new \moodle_url('/course/editcategory.php', array('id' => $category->id)), 'icon' => new \pix_icon('t/edit', new \lang_string('edit')), 'string' => new \lang_string('edit'));
}
// Show/Hide.
if ($category->can_change_visibility()) {
// We always show both icons and then just toggle the display of the invalid option with CSS.
$actions['hide'] = array('url' => new \moodle_url($baseurl, array('action' => 'hidecategory')), 'icon' => new \pix_icon('t/hide', new \lang_string('hide')), 'string' => new \lang_string('hide'));
$actions['show'] = array('url' => new \moodle_url($baseurl, array('action' => 'showcategory')), 'icon' => new \pix_icon('t/show', new \lang_string('show')), 'string' => new \lang_string('show'));
}
// Move up/down.
if ($category->can_change_sortorder()) {
$actions['moveup'] = array('url' => new \moodle_url($baseurl, array('action' => 'movecategoryup')), 'icon' => new \pix_icon('t/up', new \lang_string('up')), 'string' => new \lang_string('up'));
$actions['movedown'] = array('url' => new \moodle_url($baseurl, array('action' => 'movecategorydown')), 'icon' => new \pix_icon('t/down', new \lang_string('down')), 'string' => new \lang_string('down'));
}
if ($category->can_create_subcategory()) {
$actions['createnewsubcategory'] = array('url' => new \moodle_url('/course/editcategory.php', array('parent' => $category->id)), 'icon' => new \pix_icon('i/withsubcat', new \lang_string('createnewsubcategory')), 'string' => new \lang_string('createnewsubcategory'));
}
// Resort.
if ($category->can_resort_subcategories() && $category->has_children()) {
$actions['resortbyname'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'name')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesby', 'moodle', get_string('categoryname')));
$actions['resortbynamedesc'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'namedesc')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesbyreverse', 'moodle', get_string('categoryname')));
$actions['resortbyidnumber'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'idnumber')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesby', 'moodle', get_string('idnumbercoursecategory')));
$actions['resortbyidnumberdesc'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'idnumberdesc')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesbyreverse', 'moodle', get_string('idnumbercoursecategory')));
}
// Delete.
if ($category->can_delete_full()) {
$actions['delete'] = array('url' => new \moodle_url($baseurl, array('action' => 'deletecategory')), 'icon' => new \pix_icon('t/delete', new \lang_string('delete')), 'string' => new \lang_string('delete'));
}
// Assign roles.
if ($category->can_review_roles()) {
$actions['assignroles'] = array('url' => new \moodle_url('/admin/roles/assign.php', array('contextid' => $category->get_context()->id, 'returnurl' => $PAGE->url->out_as_local_url(false))), 'icon' => new \pix_icon('t/assignroles', new \lang_string('assignroles', 'role')), 'string' => new \lang_string('assignroles', 'role'));
}
// Permissions.
if ($category->can_review_permissions()) {
$actions['permissions'] = array('url' => new \moodle_url('/admin/roles/permissions.php', array('contextid' => $category->get_context()->id, 'returnurl' => $PAGE->url->out_as_local_url(false))), 'icon' => new \pix_icon('i/permissions', new \lang_string('permissions', 'role')), 'string' => new \lang_string('permissions', 'role'));
}
// Check permissions.
if ($category->can_review_permissions()) {
$actions['checkroles'] = array('url' => new \moodle_url('/admin/roles/check.php', array('contextid' => $category->get_context()->id, 'returnurl' => $PAGE->url->out_as_local_url(false))), 'icon' => new \pix_icon('i/checkpermissions', new \lang_string('checkpermissions', 'role')), 'string' => new \lang_string('checkpermissions', 'role'));
}
// Cohorts.
if ($category->can_review_cohorts()) {
$actions['cohorts'] = array('url' => new \moodle_url('/cohort/index.php', array('contextid' => $category->get_context()->id)), 'icon' => new \pix_icon('t/cohort', new \lang_string('cohorts', 'cohort')), 'string' => new \lang_string('cohorts', 'cohort'));
}
// Filters.
if ($category->can_review_filters()) {
$actions['filters'] = array('url' => new \moodle_url('/filter/manage.php', array('contextid' => $category->get_context()->id, 'return' => 'management')), 'icon' => new \pix_icon('i/filter', new \lang_string('filters', 'admin')), 'string' => new \lang_string('filters', 'admin'));
}
if ($category->can_restore_courses_into()) {
$actions['restore'] = array('url' => new \moodle_url('/backup/restorefile.php', array('contextid' => $category->get_context()->id)), 'icon' => new \pix_icon('i/restore', new \lang_string('restorecourse', 'admin')), 'string' => new \lang_string('restorecourse', 'admin'));
}
return $actions;
}