本文整理汇总了PHP中isadmin函数的典型用法代码示例。如果您正苦于以下问题:PHP isadmin函数的具体用法?PHP isadmin怎么用?PHP isadmin使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isadmin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templates_page_setup
function templates_page_setup()
{
global $PAGE;
global $CFG;
if (!empty($PAGE->setupdone)) {
return false;
// don't run twice
}
$PAGE->setupdone = true;
// leave your mark
//
// Populate $PAGE with links for non-module core code
//
if (isadmin()) {
$PAGE->menu_top[] = array('name' => 'admin', 'html' => "<li><a href=\"" . $CFG->wwwroot . "mod/admin/\">" . __gettext("Administration") . "</a></li>");
}
if (logged_on) {
$PAGE->menu_top[] = array('name' => 'userdetails', 'html' => "<li><a href=\"" . $CFG->wwwroot . "_userdetails/\">" . __gettext("Account settings") . "</a></li>");
$PAGE->menu_top[] = array('name' => 'logoff', 'html' => "<li><a href=\"" . $CFG->wwwroot . "login/logout.php\">" . __gettext("Log off") . "</a></li>");
}
//
// Give a chance to all registered modules
//
if ($allmods = get_list_of_plugins('mod')) {
foreach ($allmods as $mod) {
$mod_pagesetup = $mod . '_pagesetup';
if (function_exists($mod_pagesetup)) {
$mod_pagesetup();
}
}
}
}
示例2: get_content
function get_content()
{
global $USER;
$isteacher = get_record('role_assignments', 'userid', $USER->id, 'roleid', '3');
// Is the $USER assigned as Teacher, anywhere in the system?
$iscoursecreator = get_record('role_assignments', 'userid', $USER->id, 'roleid', '2');
// Is the $USER assigned as Course Creator, anywhere in the system?
if ($this->content !== NULL) {
return $this->content;
}
//echo "debug teacher=";print_r($isteacher);
if (!isadmin($USER->id)) {
if (empty($isteacher) and empty($iscoursecreator)) {
return;
}
}
if (!empty($this->instance->pinned) or $this->instance->pagetype === 'course-view') {
// fancy html allowed only on course page and in pinned blocks for security reasons
$filteropt = new stdClass();
$filteropt->noclean = true;
} else {
$filteropt = null;
}
$this->content = new stdClass();
$this->content->text = isset($this->config->text) ? format_text($this->config->text, FORMAT_HTML, $filteropt) : '';
$this->content->footer = '';
unset($filteropt);
// memory footprint
return $this->content;
}
示例3: get_text_for_indexing_pdf
/**
* @param object $resource
* @uses CFG, USER
*/
function get_text_for_indexing_pdf(&$resource)
{
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
// adds moodle root switch if none was defined
if (!isset($CFG->block_search_usemoodleroot)) {
set_config('block_search_usemoodleroot', 1);
}
$moodleroot = $CFG->block_search_usemoodleroot ? "{$CFG->dirroot}/" : '';
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_pdf_to_text_cmd)) {
preg_match("/^\\S+/", $CFG->block_search_pdf_to_text_cmd, $matches);
if (!file_exists("{$moodleroot}{$matches[0]}")) {
mtrace('Error with pdf to text converter command : executable not found at ' . $moodleroot . $matches[0]);
} else {
$file = escapeshellarg($CFG->dataroot . '/' . $resource->course . '/' . $resource->reference);
$command = trim($CFG->block_search_pdf_to_text_cmd);
$text_converter_cmd = "{$moodleroot}{$command} {$file} -";
$result = shell_exec($text_converter_cmd);
if ($result) {
return $result;
} else {
mtrace('Error with pdf to text converter command : execution failed for ' . $text_converter_cmd . '. Check for execution permission on pdf converter executable.');
return '';
}
}
} else {
mtrace('Error with pdf to text converter command : command not set up. Execute once search block configuration.');
return '';
}
}
示例4: get_text_for_indexing_doc
/**
* MS Word extractor
* @param object $resource
* @uses CFG, USER
*/
function get_text_for_indexing_doc(&$resource)
{
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
$moodleroot = @$CFG->block_search_usemoodleroot ? "{$CFG->dirroot}/" : '';
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_word_to_text_cmd)) {
if (!file_exists("{$moodleroot}{$CFG->block_search_word_to_text_cmd}")) {
mtrace('Error with MSWord to text converter command : exectuable not found.');
} else {
$file = escapeshellarg($CFG->dataroot . '/' . $resource->course . '/' . $resource->reference);
$command = trim($CFG->block_search_word_to_text_cmd);
$text_converter_cmd = "{$moodleroot}{$command} {$file}";
if ($CFG->block_search_word_to_text_env) {
putenv($CFG->block_search_word_to_text_env);
}
mtrace("Executing : {$text_converter_cmd}");
$result = shell_exec($text_converter_cmd);
if ($result) {
return mb_convert_encoding($result, 'UTF8', 'auto');
} else {
mtrace('Error with MSWord to text converter command : execution failed. ');
return '';
}
}
} else {
mtrace('Error with MSWord to text converter command : command not set up. Execute once search block configuration.');
return '';
}
}
示例5: get_text_for_indexing_pdf
/**
* Global Search Engine for Moodle
* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
* 2007/08/02
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
function get_text_for_indexing_pdf(&$resource)
{
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_pdf_to_text_cmd)) {
preg_match("/^\\S+/", $CFG->block_search_pdf_to_text_cmd, $matches);
if (!file_exists("{$CFG->dirroot}/{$matches[0]}")) {
mtrace('Error with pdf to text converter command : exectuable not found.');
} else {
$file = $CFG->dataroot . '/' . $resource->course . '/' . $resource->reference;
$text_converter_cmd = "{$CFG->dirroot}/{$CFG->block_search_pdf_to_text_cmd} {$file} -";
$result = shell_exec($text_converter_cmd);
if ($result) {
return $result;
} else {
mtrace('Error with pdf to text converter command : execution failed.');
return '';
}
}
} else {
mtrace('Error with pdf to text converter command : command not set up. Execute once search block configuration.');
return '';
}
}
示例6: _initialize
public function _initialize()
{
$this->base();
if (isset($_GET['gid']) && intval($_GET['gid']) > 0) {
$this->gid = intval($_GET['gid']);
} elseif (isset($_POST['gid']) && intval($_POST['gid']) > 0) {
$this->gid = intval($_POST['gid']);
} else {
$this->error('gid 错误');
}
$groupinfo = D('Group')->where('id=' . $this->gid . " AND is_del=0")->find();
if (!$groupinfo) {
$this->error('该群组不存在,或者被删除');
}
//判读权限 成员权限
if ($groupinfo['brower_level'] == 1 && !isJoinGroup($this->uid, $this->gid)) {
$this->error('只有成员可见');
} elseif ($groupinfo['brower_level'] == 0 && !$this->mid) {
$this->error('登陆会员可见');
}
$this->groupinfo = $groupinfo;
$this->assign('groupinfo', $groupinfo);
$this->assign('gid', $this->gid);
//记录访问时间
D('Member')->where('gid=' . $this->gid . " AND uid={$this->mid}")->setField('mtime', time());
//判读是否是管理员
$this->isadmin = isadmin($this->mid, $this->gid);
$this->assign('isadmin', $this->isadmin);
$this->setTitle($this->groupinfo['name'] . '群-');
}
示例7: liveclassroom_process_options
/**
* Validate the data in passed in the configuration page
*
* @param $config - the information from the form mod.html
* @return nothing , but returns an error if the configuration is wrong
*/
function liveclassroom_process_options(&$config)
{
global $CFG, $USER;
/*******
we do the following verfication before submitting the configuration
-The parameters sent can not be empty
-The url of the server can not finish with a /
-The url must start with http://
-The api account has to valid
********/
$config->servername = trim($config->servername);
$config->adminusername = trim($config->adminusername);
$config->adminpassword = trim($config->adminpassword);
if (!isadmin($USER->id)) {
wimba_add_log(WIMBA_ERROR, WC, get_string('wrongconfigurationURLunavailable', 'liveclassroom'));
error(get_string('errormustbeadmin', 'liveclassroom'));
}
if (empty($config->servername)) {
wimba_add_log(WIMBA_ERROR, WC, get_string('wrongconfigurationURLunavailable', 'liveclassroom'));
error(get_string('wrongconfigurationURLunavailable', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
} else {
if (empty($config->adminusername)) {
wimba_add_log(WIMBA_ERROR, WC, get_string('emptyAdminUsername', 'liveclassroom'));
error(get_string('emptyAdminUsername', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
} else {
if (empty($config->adminpassword)) {
wimba_add_log(WIMBA_ERROR, WC, get_string('emptyAdminPassword', 'liveclassroom'));
error(get_string('emptyAdminPassword', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
}
}
}
$length = strlen($config->servername);
if ($config->servername[$length - 1] == '/') {
wimba_add_log(WIMBA_ERROR, WC, get_String('trailingSlash', 'liveclassroom'));
error(get_String('trailingSlash', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
}
if (!preg_match('/^http:\\/\\//', $config->servername)) {
wimba_add_log(WIMBA_ERROR, WC, get_String('trailingHttp', 'liveclassroom'));
error(get_String('trailingHttp', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
}
$prefixUtil = new PrefixUtil();
$prefix = $prefixUtil->getPrefix($config->adminusername);
$api = new LCApi($config->servername, $config->adminusername, $config->adminpassword, $prefix);
if (!$api->lcapi_authenticate()) {
wimba_add_log(WIMBA_ERROR, WC, get_string('wrongadminpass', 'liveclassroom'));
error(get_string('wrongadminpass', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
}
$domxml = false;
$php_extension = get_loaded_extensions();
for ($i = 0; $i < count($php_extension); $i++) {
if ($php_extension[$i] == "libxml" || $php_extension[$i] == "domxml") {
$domxml = true;
}
}
if ($domxml === false) {
wimba_add_log(WIMBA_ERROR, WC, get_string('domxml', 'liveclassroom'));
error(get_string('domxml', 'liveclassroom'), $_SERVER["HTTP_REFERER"]);
}
return;
}
示例8: makeAutoreplyList
function makeAutoreplyList($selfurl)
{
global $uid, $special_codes_notice, $br, $guiPlus, $guiMinus, $editText, $addText, $delText;
$content .= "\n <h2>List/Manage/Delete SMS autoreplies</h2>\n <p>\n <a href=\"{$selfurl}&op=add\">[ Add ]</a>\n <a href=\"{$selfurl}&op=export\">[ Export ]</a>\n <a href=\"{$selfurl}&op=import\">[ Import ]</a>\n <a href=\"{$selfurl}&op=test\">[ Test ]</a>\n <a href=\"{$selfurl}&op=help\">[ Help ]</a>\n <hr><p>\n ";
$content .= genDelForm("delAutoreply", "{$selfurl}&op=delAutoreply");
$content .= genDelForm("delScenario", "{$selfurl}&op=delScenario");
$autoreplies = DB_DataObject::factory('playsms_featAutoreply');
if (!isadmin()) {
$autoreplies->uid = $uid;
}
$autoreplies->orderBy("autoreply_code");
$autoreplies->find();
while ($autoreplies->fetch()) {
$owner = uid2username($autoreplies->uid);
$autoreplyInfo = generateScenarios($selfurl, $autoreplies->autoreply_id, false);
$showhideLink = "<a href=\"javascript:;\" onClick=\"javascript: toggleShow('{$autoreplies->autoreply_code}', this, '{$guiPlus}', '{$guiMinus}');\" title=\"Show/Hide\">{$guiPlus}</a>";
$editLink = "<a href=\"{$selfurl}&op=edit&id={$autoreplies->autoreply_id}\" title=\"Edit\">{$editText}</a>";
$deleteMsg = "Are you sure you want to delete SMS autoreply `{$autoreplies->autoreply_code}`? Note that this will delete all autoreply scenarios under this autoreply.";
$deleteLink = "<a href=\"javascript: delAutoreply({$autoreplies->autoreply_id}, '{$deleteMsg}');\" title=\"Delete\">{$delText}</a>";
$content .= "{$showhideLink} \n {$editLink} \n {$deleteLink} \n <b>{$autoreplies->autoreply_code} </b>" . "<span id='{$autoreplies->autoreply_code}' style='display: none;'>" . "<span><b>User:</b> {$owner}<br><hr/></span>" . "<span style='position:relative; left:30px;'>{$autoreplyInfo}</span>" . "<span><hr/></span>" . "</span> \n<br/>";
$content .= "<br/>\n\n";
}
echo $content;
echo "<hr><p/><b>Special codes:</b> {$br}{$special_codes_notice}";
}
示例9: _initialize
public function _initialize()
{
$this->group = D('Group');
parent::_initialize();
//$this->assign('current','member');
if (!isadmin($this->mid, $this->gid)) {
$this->error('你没有权限进行管理');
}
}
示例10: get_text_for_indexing_ppt
/**
* @param object $resource
* @uses CFG, USER
*/
function get_text_for_indexing_ppt(&$resource)
{
global $CFG, $USER;
$indextext = null;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
$text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
$remains = $text;
$fragments = array();
while (preg_match('/\\x00\\x9F\\x0F\\x04.{9}(......)(.*)/s', $remains, $matches)) {
$unpacked = unpack("ncode/Llength", $matches[1]);
$sequencecode = $unpacked['code'];
$length = $unpacked['length'];
// print "length : ".$length." ; segment type : ".sprintf("%x", $sequencecode)."<br/>";
$followup = $matches[2];
// local system encoding sequence
if ($sequencecode == 0xa80f) {
$aFragment = substr($followup, 0, $length);
$remains = substr($followup, $length);
$fragments[] = $aFragment;
} elseif ($sequencecode == 0xa00f) {
$aFragment = substr($followup, 0, $length);
// $aFragment = mb_convert_encoding($aFragment, 'UTF-16', 'UTF-8');
$aFragment = preg_replace('/\\xA0\\x00\\x19\\x20/s', "'", $aFragment);
// some quotes
$aFragment = preg_replace('/\\x00/s', "", $aFragment);
$remains = substr($followup, $length);
$fragments[] = $aFragment;
} else {
$remains = $followup;
}
}
$indextext = implode(' ', $fragments);
$indextext = preg_replace('/\\x19\\x20/', "'", $indextext);
// some quotes
$indextext = preg_replace('/\\x09/', '', $indextext);
// some extra chars
$indextext = preg_replace('/\\x0D/', "\n", $indextext);
// some quotes
$indextext = preg_replace('/\\x0A/', "\n", $indextext);
// some quotes
$indextextprint = implode('<hr/>', $fragments);
// debug code
// $logppt = fopen("C:/php5/logs/pptlog", "w");
// fwrite($logppt, $indextext);
// fclose($logppt);
if (!empty($CFG->block_search_limit_index_body)) {
$indextext = shorten($text, $CFG->block_search_limit_index_body);
}
$indextext = mb_convert_encoding($indextext, 'UTF8', 'auto');
return $indextext;
}
示例11: __construct
function __construct()
{
if (!islogged()) {
redirect('login');
}
if (!isadmin()) {
redirect('/');
}
$this->adminmodel = new adminmodel();
$this->mailerdecorator = new mailerdecorator();
}
示例12: getperm
function getperm()
{
if (!islogged()) {
echo "¬logged";
} else {
if (isadmin()) {
echo "&admin";
} else {
echo "&logged";
}
}
}
示例13: can_get_list
function can_get_list($user)
{
if (isadmin()) {
return TRUE;
}
foreach ($user as $u) {
if (can_get_listrule($u)) {
continue;
} else {
return FALSE;
}
}
return TRUE;
}
示例14: get_text_for_indexing_txt
/**
* Global Search Engine for Moodle
* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
* 2007/08/02
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
function get_text_for_indexing_txt(&$resource)
{
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
// just try to get text empirically from ppt binary flow
$text = implode('', file("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"));
if (!empty($CFG->block_search_limit_index_body)) {
$text = shorten($text, $CFG->block_search_limit_index_body);
}
return $text;
}
示例15: makeList
function makeList($uid, $selfurl, $offset = 0, $numShow = 75)
{
$db = DB_DataObject::factory('playsms_tblUserInbox');
if (!$offset) {
$offset = 0;
}
$db->limit($offset, $numShow);
$db->orderBy("in_id DESC");
$pagetitle = "Inbox";
if (isadmin() && !$uid) {
$pagetitle .= " (All)";
} else {
$db->in_uid = $uid;
}
$db->in_hidden = '0';
if ($offset) {
$newOffset = $offset - $numShow;
$prevUrl = "{$selfurl}&offset={$newOffset}";
} else {
$prevUrl = "#";
}
$note = "<p>Note: This inbox shows messages not processed by any of the features (e.g., AutoReply, Poll, etc)</p>";
$newOffset = $offset + $numShow;
$nextUrl = "{$selfurl}&offset={$newOffset}";
$exportUrl = "{$selfurl}&op=export";
$linksPrevNext = "<a href='{$prevUrl}'>[ Prev] </a>\n \t\t \t\t <a href='{$nextUrl}'>[ Next ]</a>\n <a href='{$exportUrl}'>[ Export ]</a>";
// create hidden form with the
// id to delete, this way it will
// get POSTed
//
$delForm = generateActionSubmitter("del", "{$selfurl}&op=del", "id");
$content = "{$delForm}\n\t\t <h2>{$pagetitle}</h2>\n\t\t <p/>\n\t\t\t{$linksPrevNext}\n\t\t <p/>{$note}\n\t\t <table width=100% cellpadding=1 cellspacing=1 border=1>\n\t\t <tr>\n\t\t <td align=center class=box_title width=4>*</td>\n\t\t <td align=center class=box_title width=20%>Time</td>\n\t\t <td align=center class=box_title width=20%>Sender</td>\n\t\t <td align=center class=box_title width=60%>Message</td>\n\t\t <td align=center class=box_title>Action</td>\n\t\t </tr>\n\t\t";
$db->find();
while ($db->fetch()) {
$in_id = $db->in_id;
$in_sender = $db->in_sender;
$p_desc = pnum2pdesc($in_sender);
$current_sender = $in_sender;
if ($p_desc) {
$current_sender = "{$in_sender}<br>({$p_desc})";
}
$in_msg = nl2br($db->in_msg);
$in_datetime = $db->in_datetime;
$deleteCode = "javascript: del({$db->in_id}, " . "'Are you sure you want to delete this SMS ?');";
$actionCode = "<a href=\"{$deleteCode}\">[Delete]</a>";
$content .= "\n\t\t\t<tr>\n\t\t\t\t<td valign=top class=box_text align=left width=4>{$db->in_id}</td>\n\t\t\t\t<td valign=top class=box_text align=center width=20%>{$in_datetime}</td>\n\t\t\t\t<td valign=top class=box_text align=center width=20%>{$current_sender}</td>\n\t\t\t\t<td valign=top class=box_text align=left width=60%>{$in_msg}</td>\n\t\t\t\t<td valign=top class=box_text align=left nowrap>{$actionCode}</td>\n\t\t\t</tr>\n\t\t ";
}
$content .= "</table>";
return $content;
}