/** * Function to create a user in Drupal. * * @param array $params associated array * @param string $mail email id for cms user * * @return uid if user exists, false otherwise * * @access public * */ function createUser(&$params, $mail) { $form_state = array(); $form_state['input'] = array('name' => $params['cms_name'], 'mail' => $params[$mail], 'op' => 'Create new account'); $admin = user_access('administer users'); if (!variable_get('user_email_verification', TRUE) || $admin) { $form_state['input']['pass'] = array('pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']); } $form_state['rebuild'] = FALSE; $form_state['programmed'] = TRUE; $form_state['method'] = 'post'; $form_state['build_info']['args'] = array(); $config = CRM_Core_Config::singleton(); // we also need to redirect b $config->inCiviCRM = TRUE; $form = drupal_retrieve_form('user_register_form', $form_state); $form_state['process_input'] = 1; $form_state['submitted'] = 1; drupal_process_form('user_register_form', $form, $form_state); $config->inCiviCRM = FALSE; if (form_get_errors()) { return FALSE; } else { return $form_state['user']->uid; } }
/** * Retrieves what Twitter accounts the given user can post to. */ function hook_twitter_accounts($drupal_user, $full_access = FALSE) { $accounts = array(); if (user_access('use global twitter account') && ($name = variable_get('twitter_global_name', NULL)) && ($pass = variable_get('twitter_global_password', NULL))) { $accounts[$name] = array( 'screen_name' => $name, 'password' => $pass, ); } $sql = " SELECT ta.*, tu.uid, tu.password, tu.import FROM {twitter_user} tu "; $sql .= "LEFT JOIN {twitter_account} ta ON (tu.screen_name = ta.screen_name) "; $sql .= "WHERE tu.uid = %d"; if ($full_access) { $sql .= " AND tu.password IS NOT NULL"; } $args = array($drupal_user->uid); $results = db_query($sql, $args); while ($account = db_fetch_array($results)) { $accounts[$account['screen_name']] = $account; } return $accounts; }
/** * Alter content in Administration menu bar before it is rendered. * * @param $content * A structured array suitable for drupal_render(), at the very least * containing the keys 'menu' and 'links'. Most implementations likely want * to alter or add to 'links'. * * $content['menu'] contains the HTML representation of the 'admin_menu' menu * tree. * @see admin_menu_menu_alter() * * $content['links'] contains additional top-level links in the Administration * menu, such as the icon menu or the logout link. You can add more items here * or play with the #weight attribute to customize them. * @see theme_admin_menu_links() * @see admin_menu_links_icon() * @see admin_menu_links_user() */ function hook_admin_menu_output_alter(&$content) { // Add new top-level item. $content['menu']['myitem'] = array('#title' => t('My item'), '#attributes' => array('class' => array('mymodule-myitem')), '#href' => 'mymodule/path', '#options' => array('query' => drupal_get_destination()), '#weight' => 50); // Add link to manually run cron. $content['menu']['myitem']['cron'] = array('#title' => t('Run cron'), '#access' => user_access('administer site configuration'), '#href' => 'admin/reports/status/run-cron'); }
/** * Override theme_username() function. * Removes the text '(not verified)' for anonymous users. */ function quickdrupal_username($object) { if ($object->uid && $object->name) { if (drupal_strlen($object->name) > 20) { $name = drupal_substr($object->name, 0, 15) . '...'; } else { $name = $object->name; } if (user_access('access user profiles')) { $output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.')))); } else { $output = check_plain($name); } } else { if ($object->name) { if (!empty($object->homepage)) { $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow'))); } else { $output = check_plain($object->name); } } else { $output = check_plain(variable_get('anonymous', t('Anonymous'))); } } return $output; }
/** * Override or insert variables into the html template. * @param $vars * An array of variables to pass to the theme template. */ function gavias_laikafood_preprocess_html(&$vars) { global $theme, $base_url; global $parent_root; $skin = theme_get_setting('theme_skin'); drupal_add_css(drupal_get_path('theme', 'gavias_laikafood') . '/css/' . ($skin ? 'skins/' . $skin . '/' : '') . 'template.css', array('group' => CSS_DEFAULT, 'type' => 'file')); drupal_add_css(drupal_get_path('theme', 'gavias_laikafood') . '/css/' . ($skin ? 'skins/' . $skin . '/' : '') . 'bootstrap.css', array('group' => CSS_DEFAULT, 'type' => 'file')); if (module_exists('gavias_themer') && theme_get_setting('frontend_panel') == '1' && user_access('gavias_customize_preview')) { gavias_load_fontend(); } if (theme_get_setting('enable_custom_style') == 1 && trim(variable_get('gavias_profile'))) { drupal_add_css(drupal_get_path('theme', 'gavias_laikafood') . '/customize/save/' . variable_get('gavias_profile') . '.css', array('group' => CSS_DEFAULT, 'type' => 'file')); } $viewport = array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1'), '#weight' => 1); drupal_add_html_head($viewport, 'viewport'); // Add boxed class if layout is set that way. if (theme_get_setting('site_layout') == 'boxed') { $vars['classes_array'][] = 'boxed'; } if (theme_get_setting('preloader') == '1') { $vars['classes_array'][] = 'js-preloader'; } else { $vars['classes_array'][] = 'not-preloader'; } }
function phptemplate_username($object) { if ($object->uid && $object->name) { // Shorten the name when it is too long or it will break many tables. if (arg(0) == 'user' or 'groups') { $name = $object->name; } else { if (drupal_strlen($object->name) > 20) { $name = drupal_substr($object->name, 0, 15) . '...'; } else { $name = $object->name; } } if (user_access('access user profiles')) { $output = l($name, 'user/' . $object->uid, array('title' => t('View user profile.'))); } else { $output = check_plain($name); } } else { if ($object->name) { // Sometimes modules display content composed by people who are // not registered members of the site (e.g. mailing list or news // aggregator modules). This clause enables modules to display // the true author of the content. if ($object->homepage) { $output = l($object->name, $object->homepage, array('class' => 'anonymous', 'title' => t('not verified'))); } else { $output = '<span class="anonymous" title="' . t('not verified') . '">' . check_plain($object->name) . '</span>'; } } else { $output = variable_get('anonymous', t('Anonymous')); } } return $output; }
/** * Overrides \RestfulEntityBase::getList(). * * Make sure only privileged users may see a list of users. */ public function getList() { $account = $this->getAccount(); if (!user_access('administer users', $account) && !user_access('access user profiles', $account)) { throw new \RestfulForbiddenException('You do not have access to listing of users.'); } return parent::getList(); }
/** * Default constructor. * * @param null|int $id * Comment id if a comment edit form is to be loaded and null if comment * add form is to be loaded. */ public function __construct($id) { if (!user_access('post comments')) { $this->setErrors("User is not allowed to post comments."); $this->setInitialized(FALSE); return; } $args = func_get_args(); array_shift($args); $nid = array_shift($args); $pid = array_shift($args); $classname = get_called_class(); $class = new \ReflectionClass($classname); $class_shortname = $class->getShortName(); $class_fullname = "RedTest\\entities\\Comment\\" . substr($class_shortname, 0, -4); $commentObject = new $class_fullname($id, $nid, $pid); if (!$commentObject->getInitialized()) { $this->setErrors($commentObject->getErrors()); $this->setInitialized(FALSE); return; } $this->setEntityObject($commentObject); $nid = $commentObject->getNidValues(); $node = node_load($nid); if ($node->comment != COMMENT_NODE_OPEN && is_null($id)) { $this->setErrors("Node {$nid} does not allow posting of comments."); $this->setInitialized(FALSE); return; } $type = Utils::makeSnakeCase(substr($class_shortname, 0, -11)); parent::__construct('comment_node_' . $type . '_form', (object) array('nid' => $nid, 'pid' => $pid)); }
function cubert_preprocess_views_view_table(&$vars) { // Table headers are collapsible by default - override that for specific views here. $no_collapse = array('tickets_feature_requests', 'tickets_bug_reports'); if (!in_array($vars['view']->name, $no_collapse)) { $vars['collapsible_title'] = TRUE; } $extra_classes = ''; // Add "Completed" value for milestones if ($vars['view']->name == 'milestones') { $can_edit = user_access('administer milestones'); $vars['can_edit'] = $can_edit; $key = key($vars['result']); $nid = !empty($vars['result'][$key]->nid) ? $vars['result'][$key]->nid : ''; if (!empty($nid)) { $node = node_load($nid); $completed = !empty($node->field_milestone_completed[LANGUAGE_NONE][0]['value']) ? $node->field_milestone_completed[LANGUAGE_NONE][0]['value'] : FALSE; $vars['milestone_completed'] = $completed; if ($completed) { $vars['completed_class'] = 'completed'; } else { $vars['completed_class'] = 'uncompleted'; } $vars['nid'] = $nid; $extra_classes = ' collapse'; } } $vars['extra_classes'] = $extra_classes; }
function thearchivetheme_process_page(&$vars) { $usernav = ''; if (user_is_logged_in()) { global $user; $node = menu_get_object(); $ar = array(); if ($node) { $nid = $node->nid; if (user_access('update collection')) { $ar[] = '<a href="collection/edit/' . $nid . '">編輯</a>'; } if (user_access('update collection')) { $ar[] = '<a href="collection/update/file/' . $nid . '">更新數位檔</a>'; } if (user_access('update collection') && editcol_is_video_collection($nid)) { $ar[] = '<a href="collection/upload/video_icons/' . $nid . '">自定影片圖示</a>'; } if (user_access('delete collection')) { $ar[] = '<a href="collection/delete/' . $nid . '">刪除</a>'; } } if (user_access('control panel')) { $ar[] = '<a href="/control_panel/1">Control Panel</a>'; } $ar[] = 'Login as ' . $user->name; $ar[] = '<a href="/user/logout">Log out</a>'; $usernav = '<div class="row">' . implode(' | ', $ar) . '</div>'; } $vars['usernav'] = $usernav; }
/** * Loads options to Maximenu admin * */ function _maximenu_menu_options($menu_content = array(), $settings = array()) { $form_new = array(); // Skin $output_options = isset($settings['outputs']) ? $settings['outputs'] : ''; if (!empty($output_options)) { $form_new['stacking'] = array('#type' => 'select', '#title' => t('Stacking'), '#options' => array('row' => 'Row', 'column' => 'Column'), '#default_value' => isset($menu_content['stacking']) ? $menu_content['stacking'] : 'row', '#description' => t(' <ul> <li><strong>Row</strong> - all links in 1 row</li> <li><strong>Column</strong> -all links in 1 column</li> </ul> ')); $form_new['direction'] = array('#type' => 'select', '#title' => t('Block Menu Direction'), '#options' => array('block-down' => 'Dropdown', 'block-up' => 'Dropup', 'block-right' => 'Right', 'block-left' => 'Left'), '#default_value' => isset($menu_content['direction']) ? $menu_content['direction'] : 'block-down', '#description' => t('OM Maximenu will popup on this direction. Applicable only with dropdown style.')); $access = user_access('use PHP for settings'); if (isset($menu_content['visibility']) && $menu_content['visibility'] == 2 && !$access) { $form_new['visibility'] = array('#type' => 'value', '#value' => 2); $form_new['pages'] = array('#type' => 'value', '#value' => $menu_content['pages']); } else { $options = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')); $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcardfor every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')); if (module_exists('php') && $access) { $options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).'); $description .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code canbreak your Drupal site.', array('%php' => '<?php ?>')); } $form_new['visibility'] = array('#type' => 'radios', '#title' => t('Show menu on specific pages'), '#options' => $options, '#default_value' => isset($menu_content['visibility']) ? $menu_content['visibility'] : 0); $form_new['pages'] = array('#type' => 'textarea', '#title' => t('Pages'), '#default_value' => isset($menu_content['pages']) ? $menu_content['pages'] : '', '#description' => $description); } } return $form_new; }
/** * Implements template_preprocess_page. */ function mooc_foundation_access_preprocess_page(&$variables) { // speedreader is enabled if (module_exists('speedreader')) { $variables['speedreader'] = TRUE; } // mespeak is enabled if (module_exists('mespeak')) { $variables['mespeak'] = TRUE; } // support for add child page shortcut $node = menu_get_object(); if ($node && user_access('access printer-friendly version')) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1)); } $child_type = variable_get('book_child_type', 'book'); if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid']))); } if (user_access('access contextual links')) { $variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>'; } // remove the prefix that provides a link to the home page // as MOOC is the thing that currently provides support directly for this // and slightly overrides the behavior $keys = array_keys($variables['page']['header']); $keyname = array_shift($keys); unset($variables['page']['header'][$keyname]['#prefix']); }
/** * Prepares variables for page.tpl.php */ function borg_preprocess_page(&$variables) { // Add the Source Sans Pro font. backdrop_add_css('https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700', array('type' => 'external')); // Add FontAwesome. backdrop_add_js('https://use.fontawesome.com/baf3c35582.js', array('type' => 'external')); // Add Flexslider to the front page only. if (backdrop_is_front_page()) { $path = backdrop_get_path('theme', 'borg'); backdrop_add_css($path . '/css/flexslider.css'); backdrop_add_js($path . '/js/jquery.flexslider.js'); $script = "\n\$(window).load(function() {\n \$('.flexslider').flexslider();\n});"; backdrop_add_js($script, array('type' => 'inline')); } $node = menu_get_object(); if (isset($node) && isset($node->type) && $node->type === 'book') { $variables['classes'][] = 'drawer-open'; $variables['classes'][] = 'layout-both-sidebars'; } else { $variables['classes'][] = 'drawer-closed'; $array_key = array_search('layout-both-sidebars', $variables['classes']); if ($array_key !== FALSE) { $variables['classes'][$array_key] = 'layout-one-sidebar'; } } if (module_exists('admin_bar') && user_access('admin_bar')) { $variables['classes'][] = 'admin-bar'; } }
/** * Create a new session or update an open session. */ public function createOrUpdateWorkSession() { $request = $this->getRequest(); $account = $this->getAccount(); if (!user_access('timewatch punch')) { throw new RestfulForbiddenException('No punch access.'); } if (empty($request['pincode'])) { throw new \RestfulBadRequestException('Pincode is required'); } $uid = timewatch_session_get_uid_by_pincode($request['pincode']); if (!$uid) { throw new \RestfulBadRequestException('Wrong pincode'); } $employee_account = user_load($uid); // Find an existing session with no end date. $query = new EntityFieldQuery(); $result = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'work_session')->propertyCondition('status', NODE_PUBLISHED)->fieldCondition('field_employee', 'target_id', $uid)->fieldCondition('field_session_date', 'value2', NULL)->range(0, 1)->execute(); if (empty($result['node'])) { // When there's no open session, create a new one. $values = array('type' => 'work_session', 'uid' => $account->uid, 'status' => NODE_PUBLISHED, 'title' => format_string('@date - @user', array('@date' => date('d/m/y'), '@user' => $employee_account->name))); $node = entity_create('node', $values); $wrapper = entity_metadata_wrapper('node', $node); $wrapper->field_employee->set($uid); $wrapper->field_session_date->value->set(REQUEST_TIME); } else { // Otherwise set the end date of the open session. $wrapper = entity_metadata_wrapper('node', key($result['node'])); $wrapper->field_session_date->value2->set(REQUEST_TIME); } $wrapper->save(); return $this->viewEntity($wrapper->getIdentifier()); }
/** * Menu access callback for a user's personal contact form. * * @param $account * The user object of the user whose contact form is being requested. */ function _contact_personal_tab_access($account) { global $user; // Anonymous users cannot have contact forms. if (!$account->uid) { return FALSE; } // User administrators should always have access to personal contact forms. if (user_access('administer users')) { return TRUE; } // Users may not contact themselves. if ($user->uid == $account->uid) { return FALSE; } // If the requested user has disabled their contact form, or this preference // has not yet been saved, do not allow users to contact them. if (empty($account->data['contact'])) { return FALSE; } // If requested user has been blocked, do not allow users to contact them. if (empty($account->status)) { return FALSE; } return user_access('access user contact forms'); }
function openfit_base_preprocess_comment(&$variables) { $openfit_node_types = array('activity' => TRUE); if (!isset($variables['node']) || !isset($openfit_node_types[$variables['node']->type])) { return; } $comment = $variables['comment']; // Remove the standard comment links: reply, edit, delete unset($variables['content']['links']['comment']['#links']); // Add a delete menu if the user posted the comment or is admin global $user; if (user_access('administer comments') || $user->uid == $comment->uid) { $url = drupal_get_path_alias('node/' . $variables['node']->nid) . '/comments'; $variables['content']['links']['comment']['#links'] = array('comment-delete' => array('title' => ' ', 'href' => 'comment/' . $comment->cid . '/delete', 'query' => array('destination' => $url), 'html' => TRUE)); } // Display "XX ago" for posts less than 1 day, otherwise use locale to format datetime $ago = time() - $comment->created; if ($ago < 86400) { $variables['created'] = t('!interval ago', array('!interval' => format_interval(time() - $comment->created))); } else { $locale = OpenFitUserSetting::getCurrentUserLocale(); $fmt = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); $created = new DateTime('now'); $created->setTimestamp($comment->created); $variables['created'] = $fmt->format($created); } $variables['submitted'] = $variables['author'] . ' ' . '<time datetime="' . $variables['datetime'] . '" pubdate="pubdate">' . $variables['created'] . '</time>'; }
protected static function getExtraGridModeTabs($retTabs, $readAuth, $args, $attributes) { // TBD add check for loctools global $indicia_templates; $isAdmin = user_access($args['edit_permission']); if (!$isAdmin) { return ''; } if (!$retTabs) { return array('#downloads' => lang::get('Reports'), '#locations' => lang::get('LANG_Locations')); } $LocationTypeID = iform_mnhnl_getTermID(parent::$auth, 'indicia:location_types', $args['LocationTypeTerm']); $retVal = '<div id="downloads" > <p>' . lang::get('LANG_Data_Download') . '</p> <form method="post" action="' . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/mnhnl_butterflies2_sites_report.xml&reportSource=local&auth_token=' . $readAuth['auth_token'] . '&nonce=' . $readAuth['nonce'] . '&mode=csv&filename=downloadsites"> <input type="hidden" name="params" value=\'{"location_type_id":' . $LocationTypeID . '}\' /> <label>' . lang::get('Sites report') . ':</label><input type="submit" class="ui-state-default ui-corner-all" value="' . lang::get('Download') . '"> </form> <form method="post" action="' . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/mnhnl_butterflies2_conditions_report.xml&reportSource=local&auth_token=' . $readAuth['auth_token'] . '&nonce=' . $readAuth['nonce'] . '&mode=csv&filename=downloadconditions"> <input type="hidden" name="params" value=\'{"survey_id":' . $args['survey_id'] . '}\' /> <label>' . lang::get('Conditions report') . ':</label><input type="submit" class="ui-state-default ui-corner-all" value="' . lang::get('Download') . '"> </form> <form method="post" action="' . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/mnhnl_butterflies2_species_report.xml&reportSource=local&auth_token=' . $readAuth['auth_token'] . '&nonce=' . $readAuth['nonce'] . '&mode=csv&filename=downloadoccurrences"> <input type="hidden" name="params" value=\'{"survey_id":' . $args['survey_id'] . '}\' /> <label>' . lang::get('Species report') . ':</label><input type="submit" class="ui-state-default ui-corner-all" value="' . lang::get('Download') . '"> </form> </div>' . iform_mnhnl_locModTool(parent::$auth, $args, parent::$node); return $retVal; }
/** * main function for churchauth * @return string */ function churchauth_main() { if (!user_access("administer persons", "churchcore")) { addInfoMessage(t("no.permission.for", "<i>administer persons</i>")); return " "; } drupal_add_css(ASSETS . '/fileuploader/fileuploader.css'); drupal_add_js(BOOTSTRAP . '/js/bootstrap-multiselect.js'); drupal_add_js(ASSETS . '/fileuploader/fileuploader.js'); drupal_add_js(ASSETS . '/js/jquery.history.js'); drupal_add_css(ASSETS . '/dynatree/ui.dynatree.css'); drupal_add_js(ASSETS . '/dynatree/jquery.dynatree-1.2.4.js'); drupal_add_js(CHURCHCORE . '/churchcore.js'); drupal_add_js(CHURCHCORE . '/churchforms.js'); drupal_add_js(CHURCHCORE . '/cc_abstractview.js'); drupal_add_js(CHURCHCORE . '/cc_standardview.js'); drupal_add_js(CHURCHCORE . '/cc_maintainstandardview.js'); drupal_add_js(CHURCHCORE . '/cc_interface.js'); drupal_add_js(CHURCHCORE . '/cc_authview.js'); drupal_add_js(CHURCHCORE . '/cc_authmain.js'); drupal_add_js(createI18nFile("churchcore")); $content = ' <div class="row-fluid"> <div class="span3"> <div id="cdb_menu"></div> <div id="cdb_filter"></div> </div> <div class="span9"> <div id="cdb_search"></div> <div id="cdb_group"></div> <div id="cdb_content"></div> </div> </div>'; return $content; }
public function getMasterData() { global $user, $base_url; $ret = array(); $ret["modulename"] = "churchcal"; $ret["modulespath"] = CHURCHCAL; $ret["churchservice_name"] = variable_get("churchservice_name"); $ret["churchcal_name"] = variable_get("churchcal_name"); $ret["churchresource_name"] = variable_get("churchresource_name"); $ret["maincal_name"] = variable_get("churchcal_maincalname", "Gemeindekalender"); $ret["base_url"] = $base_url; $ret["user_pid"] = $user->id; if (user_access("view", "churchdb")) { $ret["absent_reason"] = churchcore_getTableData("cs_absent_reason"); } if (user_access("view", "churchresource") || user_access("create bookings", "churchresource")) { $ret["resources"] = churchcore_getTableData("cr_resource"); $ret["resourceTypes"] = churchcore_getTableData("cr_resourcetype"); $ret["bookingStatus"] = churchcore_getTableData("cr_status"); } $ret["category"] = churchcal_getAllowedCategories(true); $ret["settings"] = churchcore_getUserSettings("churchcal", $user->id); $ret["repeat"] = churchcore_getTableData("cc_repeat"); if (count($ret["settings"]) == 0) { $arr["checkboxEvents"] = "true"; $ret["settings"] = $arr; } $ret["auth"] = churchcal_getAuthForAjax(); return $ret; }
/** * Provide the actual editing form. */ function edit_form(&$form, &$form_state) { parent::edit_form($form, $form_state); $item = $form_state['item']; $form['info']['admin_title']['#required'] = TRUE; $form['info']['admin_title']['#maxlength'] = 80; $form['path'] = array('#type' => 'textarea', '#title' => t('Paths'), '#default_value' => $item->path, '#maxlength' => 128, '#size' => 45, '#description' => t('Specify pages by using their paths. Enter one path per line. The \'*\' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.', array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')), '#required' => TRUE); $form['help'] = array('#type' => 'textarea', '#title' => t('Help message'), '#default_value' => $item->help, '#description' => t('Specify a help message.'), '#required' => TRUE); $form['options'] = array('#type' => 'vertical_tabs'); $form['options_roles'] = array('#type' => 'fieldset', '#title' => t('Roles'), '#collapsible' => TRUE, '#group' => 'options', '#weight' => -50); $item->options = unserialize($item->options); $roles = user_roles(FALSE, 'view custom help text'); // Get all Authenticated roles if (isset($roles[DRUPAL_AUTHENTICATED_RID])) { $roles += array_diff(user_roles(TRUE), $roles); } if (user_access('administer permissions')) { $permission_link = l(t('View custom help text'), 'admin/people/permissions', array('fragment' => 'module-custom_help_text')); } else { $permission_link = t('View custom help text'); } $form['options_roles']['roles'] = array('#type' => 'checkboxes', '#options' => $roles, '#title' => t('User roles that can view the custom help text'), '#required' => TRUE, '#description' => t('Check the roles that needs to view the help message and have currently the permission \'!permission_url\'.', array('!permission_url' => $permission_link))); if (!empty($item->options['roles'])) { foreach ($item->options['roles'] as $role_name) { if ($role = user_role_load_by_name($role_name)) { $form['options_roles']['roles']['#default_value'][] = $role->rid; } } } else { $form['options_roles']['roles']['#default_value'] = array(); } }
/** * Implements template_preprocess_page. */ function mooc_foundation_access_preprocess_page(&$variables) { // speedreader is enabled if (module_exists('speedreader')) { $variables['speedreader'] = TRUE; } // mespeak is enabled if (module_exists('mespeak')) { $variables['mespeak'] = TRUE; } // support for add child page shortcut $node = menu_get_object(); if ($node && user_access('access printer-friendly version')) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1)); } $child_type = variable_get('book_child_type', 'book'); if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) { $variables['tabs_extras'][200][] = '<hr>'; $variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid']))); } if (user_access('access contextual links')) { $variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>'; } }
/** * Control access to memberships. * * @param string $op * The membership operation. * @param MembershipEntity $membership * The membership object. NULL if $op is 'join'. * @param object $account * The loaded user account object. Defaults to logged in user. * * @return bool * TRUE if $account as permission for $op. */ function hook_membership_entity_access($op, $membership = NULL, $account = NULL) { $user = isset($account) ? $account : $GLOBALS['user']; // Join page access. if ($op == 'join') { $type = str_replace('-', '_', $membership); // Check if a membership already exists for this user. $exists = (bool) db_query('SELECT mid FROM {membership_entity} WHERE uid = :uid AND uid <> 0 AND type = :type', array(':uid' => $user->uid, ':type' => $type))->rowCount(); if (!$exists && user_access("{$type} join", $user)) { return TRUE; } return FALSE; } if (isset($membership) && ($type_name = $membership->type)) { if (user_access("{$type_name} {$op} any membership", $user)) { return TRUE; } if (user_access("{$type_name} {$op} own membership", $user) && $membership->uid == $user->uid) { return TRUE; } // Secondary member access. $results = db_query('SELECT mid FROM {membership_entity_secondary_member} WHERE uid = :uid', array(':uid' => $user->uid))->fetchAllAssoc('mid'); if (!empty($results) && in_array($membership->mid, array_keys($results))) { // Can secondary members edit the membership? $bundle_settings = membership_entity_get_bundle_settings($type_name); if ($op == 'edit' && $bundle_settings['all_edit'] && user_access("{$type} edit own membership", $user)) { return TRUE; } // Can secondary members view the membership? if ($op == 'view' && user_access("{$type} view own membership", $user)) { return TRUE; } } } }
/** * Preprocessor for theme('page'). */ function rubik_preprocess_page(&$vars) { // Show a warning if base theme is not present. if (!function_exists('tao_theme') && user_access('administer site configuration')) { drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://code.developmentseed.org/tao'))), 'warning'); } // Split page content & content blocks. $vars['content_region'] = theme('blocks_content', TRUE); // Set a page icon class. $vars['page_icon_class'] = ($item = menu_get_item()) ? _rubik_icon_classes($item['href']) : ''; // Add body class for theme. $vars['attr']['class'] .= ' rubik'; // Body class for admin module. $vars['attr']['class'] .= ' admin-static'; // Help pages. They really do need help. if (strpos($_GET['q'], 'admin/help/') === 0) { $vars['content'] = theme('help_page', $vars['content']); } // Display user account links. $vars['user_links'] = _rubik_user_links(); // Help text toggler link. $vars['help_toggler'] = l(t('Help'), $_GET['q'], array('attributes' => array('id' => 'help-toggler', 'class' => 'toggler'), 'fragment' => 'help-text')); // Clear out help text if empty. if (empty($vars['help']) || !strip_tags($vars['help'])) { $vars['help'] = ''; } }
/** * Preprocessor for theme('page'). */ function jake_preprocess_page(&$vars) { // Help link if (!empty($vars['help'])) { $vars['help_link'] = l('?', $_GET['q'], array('fragment' => 'help', 'attributes' => array('class' => 'help-link'))); } // Admin link if (user_access('administer mn')) { $vars['admin_link'] = l(t('Admin'), 'admin/settings/site-information', array('attributes' => array('class' => 'admin-link'))); } // Add body class for layout. $vars['attr']['class'] .= !empty($vars['template_files']) ? ' ' . end($vars['template_files']) : ''; // Site name $vars['site_name'] = theme('site_name'); // Display mission in a block if (!empty($vars['mission']) && drupal_is_front_page()) { $mission_block = new stdClass(); $mission_block->content = $vars['mission']; $vars['mission_block'] = theme('block', $mission_block); } // Truncate the slogan so it doesn't break the header $vars['site_slogan'] = truncate_utf8($vars['site_slogan'], 35); // Determine stack height for fullscreen views. $class = array(); if ($stackclass = context_get('theme', 'stackclass')) { $class[] = $stackclass; } if (!empty($vars['tabs'])) { $class[] = 'tabs'; } if (!empty($class)) { $vars['attr']['class'] .= ' with-' . implode('-', $class); } }
/** * Show the pending update notice on admin pages * */ public static function show_pending_update_notice(&$vars) { if (ShareaholicUtilities::is_admin_page() && ShareaholicUtilities::has_accepted_terms_of_service() && !db_table_exists('shareaholic_content_settings') && user_access('administer modules')) { $message = sprintf(t('Action required: You have pending updates required by Shareaholic. Please go to update.php for more information.')); $vars['page'] = self::header_message_html($message) . $vars['page']; } }
function guifi_domain_access($op, $id) { global $user; guifi_log(GUIFILOG_TRACE, 'function guifi_domain_access()', $id); guifi_log(GUIFILOG_FULL, 'user='******'nid' => $domain['sid'])); if ($op == 'create') { if (user_access('administer guifi dns') || user_access('create guifi dns')) { return TRUE; } else { return FALSE; } } if ($op == 'update' or $op == 'delete') { if (user_access('administer guifi dns') || user_access('edit own guifi dns')) { return TRUE; } else { return FALSE; } } }
/** * Preprocessor for theme('page'). */ function rubik_preprocess_page(&$vars) { // Show a warning if base theme is not present. if (!function_exists('tao_theme') && user_access('administer site configuration')) { drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://code.developmentseed.org/tao'))), 'warning'); } // Set a page icon class. $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ', _rubik_icon_classes($item['href'])) : ''; // Help pages. They really do need help. if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) { $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup'])); } // Clear out help text if empty. if (empty($vars['help']) || !strip_tags($vars['help'])) { $vars['help'] = ''; } // Process local tasks. Only do this processing if the current theme is // indeed Rubik. Subthemes must reimplement this call. global $theme; if ($theme === 'rubik') { _rubik_local_tasks($vars); } // Overlay is enabled. $vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child'; }
function cstark_preprocess_node(&$variables) { if (user_access('administer nodes')) { $variables['edit_link'] = l(t('Edit'), 'node/' . $variables['nid'] . '/edit'); if ($variables['type'] == 'painting') { $title = $variables['promote'] ? t('Remove from front page') : t('Add to front page'); $variables['set_as_main_link'] = l($title, 'set-as-main/' . $variables['nid']); // Facebook share. $url = url('node/' . $variables['nid'], array('absolute' => TRUE)); $variables['share_link'] = l(t('Share'), "http://www.facebook.com/sharer.php?u={$url}", array('attributes' => array('class' => array('facebook')))); } } if ($variables['type'] == 'painting') { $wrapper = entity_metadata_wrapper('node', $variables['nid']); if ($image = $wrapper->field_image->value()) { $element = array('#tag' => 'meta', '#attributes' => array('property' => 'og:image', 'content' => file_create_url($image['uri']))); drupal_add_html_head($element, 'cstark_painting_image'); $element = array('#tag' => 'meta', '#attributes' => array('property' => 'og:title', 'content' => $wrapper->label())); drupal_add_html_head($element, 'cstark_painting_title'); } } if ($variables['type'] == 'painting' && !drupal_is_front_page()) { $variables['pager'] = shapira_get_painting_pager($variables['nid']); } if ($variables['type'] != 'news') { $variables['hide_title'] = true; } if ($variables['type'] == 'painting') { if ($variables['field_image']) { $info = image_get_info(image_style_path('painting', $variables['field_image'][0]['uri'])); $variables['node_width'] = $info['width']; } } }
function add_meta() { ctools_include('display-edit', 'panels'); ctools_include('content'); if (empty($this->display->cache_key)) { $this->cache = panels_edit_cache_get_default($this->display); } // @todo we may need an else to load the cache, but I am not sure we // actually need to load it if we already have our cache key, and doing // so is a waste of resources. ctools_include('cleanstring'); $this->clean_key = ctools_cleanstring($this->display->cache_key); $button = array('#type' => 'link', '#title' => t('Customize this page'), '#href' => $this->get_url('save_form'), '#id' => 'panels-ipe-customize-page', '#attributes' => array('class' => array('panels-ipe-startedit', 'panels-ipe-pseudobutton')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>'); panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button); // @todo this actually should be an IPE setting instead. if (user_access('change layouts in place editing')) { $button = array('#type' => 'link', '#title' => t('Change layout'), '#href' => $this->get_url('change_layout'), '#attributes' => array('class' => array('panels-ipe-change-layout', 'panels-ipe-pseudobutton', 'ctools-modal-layout')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>'); panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', $button); } ctools_include('ajax'); ctools_include('modal'); ctools_modal_add_js(); ctools_add_css('panels_dnd', 'panels'); ctools_add_css('panels_admin', 'panels'); ctools_add_js('panels_ipe', 'panels_ipe'); ctools_add_css('panels_ipe', 'panels_ipe'); drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting'); drupal_add_library('system', 'ui.draggable'); drupal_add_library('system', 'ui.droppable'); drupal_add_library('system', 'ui.sortable'); parent::add_meta(); }
/** * Allow other modules the ability to modify access to the unpublish controls. * * Modules may implement this hook if they want to have a say in whether or not * a given user has access to perform unpublish action on a node. * * @param node $node * A node object being checked * @param user $account * The user wanting to unpublish the node. * * @return bool|NULL * TRUE - if the user should access return TRUE * FALSE - if the user definetley should not access return FALSE * NULL - This module wan't change the outcome. It is typically * better to return NULL than FALSE. If no module returns TRUE * then the user will be denied access. If one module returns * FALSE then the user will denied even if another module returns * TRUE. */ function hook_publishcontent_unpublish_access($node, $account) { $access = $node->status && (user_access('administer nodes') || user_access('unpublish any content') || user_access('unpublish own content') && $user->uid == $node->uid || user_access('unpublish editable content') && node_access('update', $node) || user_access('unpublish own ' . check_plain($node->type) . ' content', $user) && $user->uid == $node->uid || user_access('unpublish any ' . check_plain($node->type) . ' content') || user_access('unpublish editable ' . check_plain($node->type) . ' content') && node_access('update', $node)); if ($access) { return TRUE; } }