123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- function materio_admin_permission() {
- return array(
- 'access default users list' => array(
- 'title' => t('Access default users list'),
- 'description' => t('Access default users list.'),
- ),
- 'access default UC roles expiration list' => array(
- 'title' => t('access default UC roles expiration list'),
- 'description' => t('access default UC roles expiration list.'),
- ),
- );
- }
- function materio_admin_menu() {
- if(module_exists('simplenews')){
- $cats = simplenews_category_list();
-
- foreach ($cats as $tid => $name) {
-
-
-
-
-
-
-
-
-
-
-
- $items['node/add/simplenews/'.$tid] = array(
- 'title' => $name,
- 'title callback' => 'check_plain',
- 'page callback' => 'node_add',
- 'page arguments' => array('simplenews'),
- 'access callback' => 'node_access',
- 'access arguments' => array('create', 'simplenews'),
- 'file path' => drupal_get_path('module', 'node'),
- 'file' => 'node.pages.inc',
- );
- }
- }
- return $items;
- }
- function materio_admin_menu_alter(&$items){
-
- if(isset($items['admin/people'])){
- $items['admin/people']['access arguments'] = array('access default users list');
-
- }
- if(isset($items['admin/people/expiration'])){
- $items['admin/people/expiration']['access arguments'] = array('access default UC roles expiration list');
-
- }
-
- $items['node']['access callback'] = FALSE;
-
-
-
-
-
-
-
-
- }
- function materio_admin_menu_local_tasks_alter(&$data, $router_item, $root_path) {
- if ($root_path == 'admin/people/simplenews') {
- $item = menu_get_item('admin/content/simplenews');
- if ($item['access']) {
- $item['title'] = 'Go to '.$item['title'];
- $data['actions']['output'][] = array(
- '#theme' => 'menu_local_task',
- '#link' => $item,
- );
- }
- }
- if ($root_path == 'admin/content/simplenews') {
- $cats = simplenews_category_list();
- foreach ($cats as $tid => $name) {
- $item = menu_get_item('node/add/simplenews/'.$tid);
- $item['title'] = 'Add new '.$name;
- if ($item['access']) {
- $data['actions']['output'][] = array(
- '#theme' => 'menu_local_task',
- '#link' => $item,
- );
- }
- }
- $item = menu_get_item('admin/people/simplenews');
- if ($item['access']) {
- $item['title'] = 'Go to '.$item['title'];
- $data['actions']['output'][] = array(
- '#theme' => 'menu_local_task',
- '#link' => $item,
- );
- }
- }
- }
- function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $form_id) {
-
-
-
-
- if(!$form['nid']['#value']){
- $cats = simplenews_category_list();
- $cats_tids = array_keys($cats);
- $q = parse_url($_GET['q']);
- $cat = array_pop(explode('/', $q['path']));
-
- if(in_array($cat, $cats_tids)){
-
- $form['field_simplenews_term']['und']['#default_value'] = $cat;
- $form['field_simplenews_term']['und']['#disabled'] = true;
-
- $form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($cat);
- }
- }else{
- $form['field_simplenews_term']['und']['#disabled'] = true;
- }
- $form['body']['und'][0]['#rows'] = 50;
- }
- function materio_admin_getSimplenewsNodeBodyTemplate($cat){
- return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$cat.'_node.html');
- }
|