当前位置: 首页>>代码示例>>PHP>>正文


PHP get_config_plugin函数代码示例

本文整理汇总了PHP中get_config_plugin函数的典型用法代码示例。如果您正苦于以下问题:PHP get_config_plugin函数的具体用法?PHP get_config_plugin怎么用?PHP get_config_plugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_config_plugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor.
  */
 public function __construct()
 {
     global $CFG;
     $default = array('opname' => get_string('pluginname', 'auth.oidc'));
     $storedconfig = array('clientid' => '', 'clientsecret' => '', 'redirecturi' => trim($CFG->wwwroot, '/') . '/auth/oidc/redirect.php', 'resource' => '', 'authendpoint' => '', 'tokenendpoint' => '');
     foreach ($storedconfig as $key => $value) {
         $saved = get_config_plugin('auth', 'oidc', $key);
         if ($saved !== null) {
             $storedconfig[$key] = $saved;
         }
     }
     $this->config = (object) array_merge($default, $storedconfig);
 }
开发者ID:remotelearner,项目名称:mahara-auth_oidc,代码行数:16,代码来源:base.php

示例2: groupquotasform_submit

function groupquotasform_submit(Pieform $form, $values)
{
    global $SESSION;
    $oldquota = get_field('group', 'quota', 'id', $values['groupid']);
    $group = new StdClass();
    $group->id = $values['groupid'];
    $group->quota = $values['quota'];
    update_record('group', $group);
    if (!empty($values['quota']) && $values['quota'] != $oldquota) {
        // We need to alert group admins that the group may now be over the threshold
        $quotanotifylimit = get_config_plugin('artefact', 'file', 'quotanotifylimit');
        $sqlwhere = " ((g.quotaused / g.quota) * 100) ";
        if (is_postgres()) {
            $sqlwhere = " ((CAST(g.quotaused AS float) / CAST(g.quota AS float)) * 100) ";
        }
        if ($groups = get_records_sql_assoc("SELECT g.id, g.name, g.quota, " . $sqlwhere . " AS quotausedpercent FROM {group} g WHERE " . $sqlwhere . " >= ? AND id = ?", array($quotanotifylimit, $values['groupid']))) {
            require_once get_config('docroot') . 'artefact/file/lib.php';
            ArtefactTypeFile::notify_groups_threshold_exceeded($groups);
        }
    }
    $SESSION->add_ok_msg(get_string('groupquotaupdated', 'admin'));
    redirect(get_config('wwwroot') . 'admin/groups/groups.php');
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:23,代码来源:manage.php

示例3: get_allowed_filetypes

 private static function get_allowed_filetypes()
 {
     if ($data = get_config_plugin('blocktype', 'internalmedia', 'enabledtypes')) {
         return unserialize($data);
     }
     return array();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:7,代码来源:lib.php

示例4: pieform_element_filebrowser_upload

function pieform_element_filebrowser_upload(Pieform $form, $element, $data)
{
    global $USER;
    $parentfolder = $data['uploadfolder'] ? (int) $data['uploadfolder'] : null;
    $institution = !empty($element['institution']) ? $element['institution'] : $form->get_property('institution');
    $group = !empty($element['group']) ? $element['group'] : $form->get_property('group');
    if (get_config('licensemetadata')) {
        $license = $data['license'];
        $licensor = $data['licensor'];
        $licensorurl = $data['licensorurl'];
    }
    $uploadnumber = (int) $data['uploadnumber'];
    $editable = (int) $element['config']['edit'];
    $selectable = (int) $element['config']['select'];
    $querybase = $element['page'] . (strpos($element['page'], '?') === false ? '?' : '&');
    $prefix = $form->get_name() . '_' . $element['name'];
    $userfileindex = isset($data['userfileindex']) ? $data['userfileindex'] : null;
    $resizeonuploadenable = get_config_plugin('artefact', 'file', 'resizeonuploadenable');
    $resizeonuploaduseroption = get_config_plugin('artefact', 'file', 'resizeonuploaduseroption');
    $resizeonuploaduserenable = (int) $data['resizeonuploaduserenable'];
    $result = array('error' => false, 'uploadnumber' => $uploadnumber);
    if ($parentfolder == 0) {
        $parentfolder = null;
    }
    $data = new StdClass();
    $data->parent = $parentfolder;
    $data->owner = $data->group = $data->institution = null;
    if (get_config('licensemetadata')) {
        $data->license = $license;
        $data->licensor = $licensor;
        $data->licensorurl = $licensorurl;
    }
    if ($parentfolder) {
        $parentartefact = artefact_instance_from_id($parentfolder);
        if (!$USER->can_edit_artefact($parentartefact)) {
            $result['error'] = true;
            $result['message'] = get_string('cannoteditfolder', 'artefact.file');
            return $result;
        } else {
            if ($parentartefact->get('locked')) {
                $result['error'] = true;
                $result['message'] = get_string('cannoteditfoldersubmitted', 'artefact.file');
                return $result;
            }
        }
        $parentfoldername = $parentartefact->get('title');
    } else {
        $parentfoldername = null;
    }
    if ($institution) {
        if (!$USER->can_edit_institution($institution)) {
            $result['error'] = true;
            $result['message'] = get_string('notadminforinstitution', 'admin');
            return $result;
        }
        $data->institution = $institution;
    } else {
        if ($group) {
            if (!group_within_edit_window($group)) {
                return array('error' => true, 'message' => get_string('cannoteditfolder', 'artefact.file'));
            }
            if (!$parentfolder) {
                if (!pieform_element_filebrowser_edit_group_folder($group, 0)) {
                    return array('error' => true, 'message' => get_string('cannoteditfolder', 'artefact.file'));
                }
            }
            $data->group = $group;
        } else {
            $data->owner = $USER->get('id');
        }
    }
    $data->container = 0;
    if (isset($userfileindex)) {
        $originalname = $_FILES['userfile']['name'][$userfileindex];
    } else {
        $originalname = $_FILES['userfile']['name'];
    }
    $originalname = $originalname ? basename($originalname) : get_string('file', 'artefact.file');
    $data->title = ArtefactTypeFileBase::get_new_file_title($originalname, $parentfolder, $data->owner, $group, $institution);
    // Overwrite image file with resized version if required
    $resized = false;
    $resizeattempted = false;
    // resize specified if (resizing is enabled AND user has enabled resizing) OR (resizing is enabled AND user is not given an option to enable/disable)
    if ($resizeonuploadenable && $resizeonuploaduserenable || $resizeonuploadenable && !$resizeonuploaduseroption) {
        require_once 'file.php';
        require_once 'imageresizer.php';
        $file = $_FILES['userfile'];
        if (isset($userfileindex)) {
            $tmpname = $file['tmp_name'][$userfileindex];
        } else {
            $tmpname = $file['tmp_name'];
        }
        if (is_image_file($tmpname)) {
            $imageinfo = getimagesize($tmpname);
            $mimetype = $imageinfo['mime'];
            $width = $imageinfo[0];
            $height = $imageinfo[1];
            $bmptypes = array('image/bmp', 'image/x-bmp', 'image/ms-bmp', 'image/x-ms-bmp');
            // resize image if necessary
            $resizeonuploadmaxwidth = get_config_plugin('artefact', 'file', 'resizeonuploadmaxwidth');
//.........这里部分代码省略.........
开发者ID:rboyatt,项目名称:mahara,代码行数:101,代码来源:filebrowser.php

示例5: param_integer

if ($blogobj->get('institution')) {
    $institution = true;
    $institutionname = $blogobj->get('institution');
} else {
    if ($blogobj->get('group')) {
        $groupid = $blogobj->get('group');
    }
}
PluginArtefactBlog::set_blog_nav($institution, $institutionname, $groupid);
$folder = param_integer('folder', 0);
$browse = (int) param_variable('browse', 0);
$highlight = null;
if ($file = param_integer('file', 0)) {
    $highlight = array($file);
}
$form = pieform(array('name' => 'editpost', 'method' => 'post', 'autofocus' => $focuselement, 'jsform' => true, 'newiframeonsubmit' => true, 'jssuccesscallback' => 'editpost_callback', 'jserrorcallback' => 'editpost_callback', 'plugintype' => 'artefact', 'pluginname' => 'blog', 'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'), 'elements' => array('blog' => array('type' => 'hidden', 'value' => $blog), 'blogpost' => array('type' => 'hidden', 'value' => $blogpost), 'title' => array('type' => 'text', 'title' => get_string('posttitle', 'artefact.blog'), 'rules' => array('required' => true), 'defaultvalue' => $title), 'description' => array('type' => 'wysiwyg', 'rows' => 20, 'cols' => 70, 'title' => get_string('postbody', 'artefact.blog'), 'description' => get_string('postbodydesc', 'artefact.blog'), 'rules' => array('maxlength' => 65536, 'required' => true), 'defaultvalue' => $description), 'tags' => array('defaultvalue' => $tags, 'type' => 'tags', 'title' => get_string('tags'), 'description' => get_string('tagsdesc'), 'help' => true), 'license' => license_form_el_basic(isset($blogpostobj) ? $blogpostobj : null), 'licensing_advanced' => license_form_el_advanced(isset($blogpostobj) ? $blogpostobj : null), 'filebrowser' => array('type' => 'filebrowser', 'title' => get_string('attachments', 'artefact.blog'), 'folder' => $folder, 'highlight' => $highlight, 'institution' => $institutionname, 'group' => $groupid, 'browse' => $browse, 'page' => get_config('wwwroot') . 'artefact/blog/post.php?' . ($blogpost ? 'id=' . $blogpost : 'blog=' . $blog) . '&browse=1', 'browsehelp' => 'browsemyfiles', 'config' => array('upload' => true, 'uploadagreement' => get_config_plugin('artefact', 'file', 'uploadagreement'), 'resizeonuploaduseroption' => get_config_plugin('artefact', 'file', 'resizeonuploaduseroption'), 'resizeonuploaduserdefault' => $USER->get_account_preference('resizeonuploaduserdefault'), 'createfolder' => false, 'edit' => false, 'select' => true), 'defaultvalue' => $attachments, 'selectlistcallback' => 'artefact_get_records_by_id', 'selectcallback' => 'add_attachment', 'unselectcallback' => 'delete_attachment'), 'draft' => array('type' => 'switchbox', 'title' => get_string('draft', 'artefact.blog'), 'description' => get_string('thisisdraftdesc', 'artefact.blog'), 'defaultvalue' => $checked, 'help' => true), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'description' => get_string('allowcommentsonpost', 'artefact.blog'), 'defaultvalue' => $blogpost ? $blogpostobj->get('allowcomments') : 1), 'submitpost' => array('type' => 'submitcancel', 'class' => 'btn-primary', 'value' => array(get_string('savepost', 'artefact.blog'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog))));
/*
 * Javascript specific to this page.  Creates the list of files
 * attached to the blog post.
 */
$wwwroot = get_config('wwwroot');
$noimagesmessage = json_encode(get_string('noimageshavebeenattachedtothispost', 'artefact.blog'));
$javascript = <<<EOF
function editpost_callback(form, data) {
    editpost_filebrowser.callback(form, data);
};
EOF;
$smarty = smarty(array(), array(), array(), array('tinymceconfig' => '
        image_filebrowser: "editpost_filebrowser",
    ', 'sideblocks' => array(array('name' => 'quota', 'weight' => -10, 'data' => array()))));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
开发者ID:sarahjcotton,项目名称:mahara,代码行数:31,代码来源:post.php

示例6: adduser_submit

function adduser_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $TRANSPORTER;
    db_begin();
    raise_time_limit(180);
    // Create user
    $user = (object) array('authinstance' => $values['authinstance'], 'username' => $values['username'], 'firstname' => $values['firstname'] ? $values['firstname'] : 'Imported', 'lastname' => $values['lastname'] ? $values['lastname'] : 'User', 'email' => $values['email'], 'password' => $values['password'], 'passwordchange' => 1);
    if ($USER->get('admin')) {
        // Not editable by institutional admins
        $user->staff = (int) ($values['staff'] == 'on');
        $user->admin = (int) ($values['admin'] == 'on');
    }
    if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
        $user->quota = $values['quota'];
    }
    $authinstance = get_record('auth_instance', 'id', $values['authinstance']);
    $remoteauth = false;
    if ($authinstance->authname != 'internal') {
        $remoteauth = true;
    }
    if (!isset($values['remoteusername'])) {
        $values['remoteusername'] = null;
    }
    $user->id = create_user($user, array(), $authinstance->institution, $remoteauth, $values['remoteusername'], $values);
    if (isset($user->admin) && $user->admin) {
        require_once 'activity.php';
        activity_add_admin_defaults(array($user->id));
    }
    if ($values['institutionadmin']) {
        set_field('usr_institution', 'admin', 1, 'usr', $user->id, 'institution', $authinstance->institution);
    }
    if (isset($values['leap2afile'])) {
        // And we're good to go
        $importdata = (object) array('token' => '', 'usr' => $user->id, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_FILE, 'profile' => true);
        $importer = PluginImport::create_importer(null, $TRANSPORTER, $importdata);
        try {
            $importer->process();
            log_info("Imported user account {$user->id} from Leap2A file, see " . $importer->get('logfile') . ' for a full log');
        } catch (ImportException $e) {
            log_info("Leap2A import failed: " . $e->getMessage());
            die_info(get_string('leap2aimportfailed', 'admin'));
        }
        // Reload the user details, as various fields are changed by the
        // importer when importing (e.g. firstname/lastname)
        $user = get_record('usr', 'id', $user->id);
    }
    db_commit();
    if (!empty($user->email)) {
        try {
            email_user($user, $USER, get_string('accountcreated', 'mahara', get_config('sitename')), get_string('accountcreatedchangepasswordtext', 'mahara', $user->firstname, get_config('sitename'), $user->username, $values['password'], get_config('wwwroot'), get_config('sitename')), get_string('accountcreatedchangepasswordhtml', 'mahara', $user->firstname, get_config('wwwroot'), get_config('sitename'), $user->username, $values['password'], get_config('wwwroot'), get_config('wwwroot'), get_config('sitename')));
        } catch (EmailException $e) {
            $SESSION->add_error_msg(get_string('newuseremailnotsent', 'admin'));
        }
    }
    $SESSION->add_ok_msg(get_string('newusercreated', 'admin'));
    redirect('/admin/users/edit.php?id=' . $user->id);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:57,代码来源:add.php

示例7: define

 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
define('INSTITUTIONALADMIN', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once 'pieforms/pieform/elements/bytes.php';
$instid = param_integer('instid');
$disabled = param_boolean('disabled', false);
$definst = get_field('auth_instance', 'id', 'institution', 'mahara');
$record = get_record_sql('SELECT i.name, i.defaultquota FROM {institution} i JOIN {auth_instance} ai ON (i.name = ai.institution) WHERE ai.id = ?', array($instid));
if (!$USER->get('admin') && !$USER->is_institutional_admin($record->name)) {
    json_reply(true, 'You are not an administrator for institution ' . $record->name);
    return;
}
if ($definst && $instid == $definst) {
    $quota = get_config_plugin('artefact', 'file', 'defaultquota');
} else {
    $quota = $record->defaultquota;
    if (!$quota) {
        $quota = get_config_plugin('artefact', 'file', 'defaultquota');
    }
}
$data = array('data' => $disabled ? display_size($quota) : pieform_element_bytes_get_bytes_from_bytes($quota), 'error' => false, 'message' => null);
json_reply(false, $data);
开发者ID:rboyatt,项目名称:mahara,代码行数:31,代码来源:quota.json.php

示例8: edituser_site_submit

function edituser_site_submit(Pieform $form, $values)
{
    global $USER, $authobj, $SESSION;
    if (!($user = get_record('usr', 'id', $values['id']))) {
        return false;
    }
    if (is_using_probation()) {
        // Value should be between 0 and 10 inclusive
        $user->probation = ensure_valid_probation_points($values['probationpoints']);
    }
    if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
        $user->quota = $values['quota'];
        // check if the user has gone over the quota notify limit
        $quotanotifylimit = get_config_plugin('artefact', 'file', 'quotanotifylimit');
        if ($quotanotifylimit <= 0 || $quotanotifylimit >= 100) {
            $quotanotifylimit = 100;
        }
        $user->quotausedpercent = $user->quotaused / $user->quota * 100;
        $overlimit = false;
        if ($quotanotifylimit <= $user->quotausedpercent) {
            $overlimit = true;
        }
        $notified = get_field('usr_account_preference', 'value', 'field', 'quota_exceeded_notified', 'usr', $user->id);
        if ($overlimit && '1' !== $notified) {
            require_once get_config('docroot') . 'artefact/file/lib.php';
            ArtefactTypeFile::notify_users_threshold_exceeded(array($user), false);
            // no need to email admin as we can alert them right now
            $SESSION->add_error_msg(get_string('useroverquotathreshold', 'artefact.file', display_name($user)));
        } else {
            if ($notified && !$overlimit) {
                set_account_preference($user->id, 'quota_exceeded_notified', false);
            }
        }
    }
    $unexpire = $user->expiry && strtotime($user->expiry) < time() && (empty($values['expiry']) || $values['expiry'] > time());
    $newexpiry = db_format_timestamp($values['expiry']);
    if ($user->expiry != $newexpiry) {
        $user->expiry = $newexpiry;
        if ($unexpire) {
            $user->expirymailsent = 0;
            $user->lastaccess = db_format_timestamp(time());
        }
    }
    // Try to kick the user from any active login sessions, before saving data.
    require_once get_config('docroot') . 'auth/session.php';
    remove_user_sessions($user->id);
    if ($USER->get('admin')) {
        // Not editable by institutional admins
        $user->staff = (int) ($values['staff'] == 'on');
        $user->admin = (int) ($values['admin'] == 'on');
        if ($user->admin) {
            activity_add_admin_defaults(array($user->id));
        }
    }
    if ($values['maildisabled'] == 0 && get_account_preference($user->id, 'maildisabled') == 1) {
        // Reset the sent and bounce counts otherwise mail will be disabled
        // on the next send attempt
        $u = new StdClass();
        $u->email = $user->email;
        $u->id = $user->id;
        update_bounce_count($u, true);
        update_send_count($u, true);
    }
    set_account_preference($user->id, 'maildisabled', $values['maildisabled']);
    // process the change of the authinstance and or the remoteuser
    if (isset($values['authinstance']) && isset($values['remoteusername'])) {
        // Authinstance can be changed by institutional admins if both the
        // old and new authinstances belong to the admin's institutions
        $authinst = get_records_select_assoc('auth_instance', 'id = ? OR id = ?', array($values['authinstance'], $user->authinstance));
        // But don't bother if the auth instance doesn't take a remote username
        $authobj = AuthFactory::create($values['authinstance']);
        if ($USER->get('admin') || $USER->is_institutional_admin($authinst[$values['authinstance']]->institution) && ($USER->is_institutional_admin($authinst[$user->authinstance]->institution) || $user->authinstance == 1)) {
            if ($authobj->needs_remote_username()) {
                // determine the current remoteuser
                $current_remotename = get_field('auth_remote_user', 'remoteusername', 'authinstance', $user->authinstance, 'localusr', $user->id);
                if (!$current_remotename) {
                    $current_remotename = $user->username;
                }
                // if the remoteuser is empty
                if (strlen(trim($values['remoteusername'])) == 0) {
                    delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'localusr', $user->id);
                }
                // what should the new remoteuser be
                $new_remoteuser = get_field('auth_remote_user', 'remoteusername', 'authinstance', $values['authinstance'], 'localusr', $user->id);
                // save the remotename for the target existence check
                $target_remotename = $new_remoteuser;
                if (!$new_remoteuser) {
                    $new_remoteuser = $user->username;
                }
                if (strlen(trim($values['remoteusername'])) > 0) {
                    // value changed on page - use it
                    if ($values['remoteusername'] != $current_remotename) {
                        $new_remoteuser = $values['remoteusername'];
                    }
                }
                // only update remote name if the input actually changed on the page  or it doesn't yet exist
                if ($current_remotename != $new_remoteuser || !$target_remotename) {
                    // only remove the ones related to this traget authinstance as we now allow multiple
                    // for dual login mechanisms
                    delete_records('auth_remote_user', 'authinstance', $values['authinstance'], 'localusr', $user->id);
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:edit.php

示例9: build_html

 public static function build_html(&$data, $onview)
 {
     global $USER, $THEME;
     $candelete = $data->canedit || $USER->get('admin');
     $deletedmessage = array();
     foreach (ArtefactTypeAnnotationfeedback::deleted_by_types_description() as $k => $v) {
         $deletedmessage[$k] = get_string($v, 'artefact.annotation');
     }
     $authors = array();
     $lastcomment = self::last_public_annotation_feedback($data->annotation, $data->view, $data->artefact);
     $editableafter = time() - 60 * get_config_plugin('artefact', 'annotation', 'commenteditabletime');
     foreach ($data->data as &$item) {
         $isadminfeedback = $item->admin == 1 || $item->staff == 1 || $item->feedbackinstitutionadmin == 1 || $item->feedbackinstitutionstaff == 1;
         $item->ts = strtotime($item->ctime);
         $item->date = format_date($item->ts, 'strftimedatetime');
         if ($item->ts < strtotime($item->lastcontentupdate)) {
             $item->updated = format_date(strtotime($item->lastcontentupdate), 'strftimedatetime');
         }
         $item->isauthor = $item->author && $item->author == $USER->get('id');
         if ($item->private) {
             $item->pubmessage = get_string('annotationfeedbackisprivate', 'artefact.annotation');
         }
         if (isset($data->showcomment) && $data->showcomment == $item->id) {
             $item->highlight = 1;
         }
         $is_export_preview = param_integer('export', 0);
         if ($item->deletedby) {
             $item->deletedmessage = $deletedmessage[$item->deletedby];
         } else {
             if (($candelete || $item->isauthor) && !$is_export_preview && !$isadminfeedback) {
                 // If the auther was admin/staff and not the owner of the annotation,
                 // the feedback can't be deleted.
                 $item->deleteform = pieform(self::delete_annotation_feedback_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id));
             }
         }
         // Comment authors can edit recent comments if they're private or if no one has replied yet.
         if (!$item->deletedby && $item->isauthor && !$is_export_preview && ($item->private || $item->id == $lastcomment->id) && $item->ts > $editableafter) {
             $item->canedit = 1;
         }
         // Form to make private comment public, or request that a
         // private comment be made public.
         if (!$item->deletedby && $item->private && $item->author && $data->owner && ($item->isauthor || $data->isowner)) {
             if (empty($item->requestpublic) && $data->isowner || $item->isauthor && $item->requestpublic == 'owner' || $data->isowner && $item->requestpublic == 'author') {
                 if (!$is_export_preview) {
                     $item->makepublicform = pieform(self::make_annotation_feedback_public_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id));
                 }
             } else {
                 if ($item->isauthor && $item->requestpublic == 'author' || $data->isowner && $item->requestpublic == 'owner') {
                     $item->makepublicrequested = 1;
                 }
             }
         } else {
             if (!$item->deletedby && $item->private && !$item->author && $data->owner && $data->isowner && $item->requestpublic == 'author' && !$is_export_preview) {
                 $item->makepublicform = pieform(self::make_annotation_feedback_public_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id));
             } else {
                 if (!$item->deletedby && $item->private && !$data->owner && $item->group && $item->requestpublic == 'author') {
                     // no owner as comment is on a group view / artefact
                     if ($item->isauthor) {
                         $item->makepublicrequested = 1;
                     } else {
                         if ($data->artefact && $data->canedit || $data->view && $data->canedit && !$is_export_preview) {
                             $item->makepublicform = pieform(self::make_annotation_feedback_public_form($data->annotation, $data->view, $data->artefact, $data->block, $item->id));
                         } else {
                             $item->makepublicrequested = 1;
                         }
                     }
                 }
             }
         }
         if ($item->author) {
             if (isset($authors[$item->author])) {
                 $item->author = $authors[$item->author];
             } else {
                 $item->author = $authors[$item->author] = (object) array('id' => $item->author, 'username' => $item->username, 'firstname' => $item->firstname, 'lastname' => $item->lastname, 'preferredname' => $item->preferredname, 'email' => $item->email, 'staff' => $item->staff, 'admin' => $item->admin, 'deleted' => $item->deleted, 'profileicon' => $item->profileicon, 'profileurl' => profile_url($item->author));
             }
         }
     }
     $extradata = array('annotation' => $data->annotation, 'view' => $data->view, 'artefact' => !empty($data->artefact) ? $data->artefact : '', 'blockid' => $data->block);
     $data->jsonscript = 'artefact/annotation/annotations.json.php';
     $data->baseurl = get_config('wwwroot') . 'artefact/artefact.php?' . 'artefact=' . $data->annotation . '&view=' . $data->view . (isset($data->block) ? '&block=' . $data->block : '');
     $smarty = smarty_core();
     $smarty->assign_by_ref('data', $data->data);
     $smarty->assign('canedit', $data->canedit);
     $smarty->assign('viewid', $data->view);
     $smarty->assign('position', $data->position);
     $smarty->assign('baseurl', $data->baseurl);
     $data->tablerows = $smarty->fetch('artefact:annotation:annotationlist.tpl');
     $pagination = build_pagination(array('id' => 'annotationfeedback_pagination_' . $data->block, 'class' => 'center', 'url' => $data->baseurl, 'jsonscript' => $data->jsonscript, 'datatable' => 'annotationfeedbacktable_' . $data->block, 'count' => $data->count, 'limit' => $data->limit, 'offset' => $data->offset, 'forceoffset' => isset($data->forceoffset) ? $data->forceoffset : null, 'resultcounttextsingular' => get_string('annotation', 'artefact.annotation'), 'resultcounttextplural' => get_string('annotations', 'artefact.annotation'), 'extradata' => $extradata));
     $data->pagination = $pagination['html'];
     $data->pagination_js = $pagination['javascript'];
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:91,代码来源:lib.php

示例10: dirname

require dirname(dirname(dirname(__FILE__))) . '/init.php';
define('TITLE', get_string('editannotationfeedback', 'artefact.annotation'));
safe_require('artefact', 'annotation');
$annotationfeedbackid = param_integer('id');
$viewid = param_integer('viewid');
$annotationfeedback = new ArtefactTypeAnnotationFeedback((int) $annotationfeedbackid);
if ($USER->get('id') != $annotationfeedback->get('author')) {
    throw new AccessDeniedException(get_string('canteditnotauthor', 'artefact.annotation'));
}
$annotationid = $annotationfeedback->get('onannotation');
$annotation = new ArtefactTypeAnnotation($annotationid);
$onview = $annotation->get('view');
if ($onview && $onview != $viewid) {
    throw new NotFoundException(get_string('annotationfeedbacknotinview', 'artefact.annotation', $annotationfeedbackid, $viewid));
}
$maxage = (int) get_config_plugin('artefact', 'annotation', 'commenteditabletime');
$editableafter = time() - 60 * $maxage;
$goto = $annotation->get_view_url($viewid, false);
if ($annotationfeedback->get('ctime') < $editableafter) {
    $SESSION->add_error_msg(get_string('cantedittooold', 'artefact.annotation', $maxage));
    redirect($goto);
}
$lastcomment = ArtefactTypeAnnotationfeedback::last_public_annotation_feedback($annotationid, $viewid, $annotation->get('artefact'));
if (!$annotationfeedback->get('private') && $annotationfeedbackid != $lastcomment->id) {
    $SESSION->add_error_msg(get_string('cantedithasreplies', 'artefact.annotation'));
    redirect($goto);
}
$elements = array();
$elements['message'] = array('type' => 'wysiwyg', 'title' => get_string('Annotationfeedback', 'artefact.annotation'), 'rows' => 5, 'cols' => 80, 'defaultvalue' => $annotationfeedback->get('description'), 'rules' => array('maxlength' => 8192));
$elements['ispublic'] = array('type' => 'checkbox', 'title' => get_string('makepublic', 'artefact.annotation'), 'defaultvalue' => !$annotationfeedback->get('private'));
// What is this annotation feedback linked to? Store it in hidden fields.
开发者ID:vohung96,项目名称:mahara,代码行数:31,代码来源:edit.php

示例11: group_create

/**
 * Creates a group.
 *
 * All group creation should be done through this function, as the
 * implementation of group creation may change over time.
 *
 * @param array $data Data required to create the group. The following
 * key/value pairs can be specified:
 *
 * - name: The group name [required, must be unique]
 * - description: The group description [optional, defaults to empty string]
 * - grouptype: The grouptype for the new group. Must be an installed grouptype.
 * - open (jointype): anyone can join the group
 * - controlled (jointype): admin adds members; members cannot leave the group
 * - request: allows membership requests
 * - ctime: The unix timestamp of the time the group will be recorded as having
 *          been created. Defaults to the current time.
 * - members: Array of users who should be in the group, structured like this:
 *            array(
 *                userid => role,
 *                userid => role,
 *                ...
 *            )
 * @return int The ID of the created group
 */
function group_create($data)
{
    if (!is_array($data)) {
        throw new InvalidArgumentException("group_create: data must be an array, see the doc comment for this " . "function for details on its format");
    }
    if (!isset($data['name'])) {
        throw new InvalidArgumentException("group_create: must specify a name for the group");
    }
    if (get_records_sql_array('SELECT id FROM {group} WHERE LOWER(TRIM(name)) = ?', array(strtolower(trim($data['name']))))) {
        throw new UserException(get_string('groupalreadyexists', 'group') . ': ' . $data['name']);
    }
    if (!isset($data['grouptype']) || !in_array($data['grouptype'], group_get_grouptypes())) {
        throw new InvalidArgumentException("group_create: grouptype specified must be an installed grouptype");
    }
    safe_require('grouptype', $data['grouptype']);
    if (!empty($data['open'])) {
        if (!empty($data['controlled'])) {
            throw new InvalidArgumentException("group_create: a group cannot have both open and controlled membership");
        }
        if (!empty($data['request'])) {
            throw new InvalidArgumentException("group_create: open-membership groups don't accept membership requests");
        }
        $jointype = 'open';
    } else {
        if (!empty($data['controlled'])) {
            $jointype = 'controlled';
        } else {
            $jointype = 'approve';
        }
    }
    if (isset($data['jointype'])) {
        log_warn("group_create: ignoring supplied jointype");
    }
    if (!isset($data['ctime'])) {
        $data['ctime'] = time();
    }
    $data['ctime'] = db_format_timestamp($data['ctime']);
    $data['public'] = isset($data['public']) ? intval($data['public']) : 0;
    $data['hidden'] = isset($data['hidden']) ? intval($data['hidden']) : 0;
    $data['hidemembers'] = isset($data['hidemembers']) ? intval($data['hidemembers']) : 0;
    $data['hidemembersfrommembers'] = isset($data['hidemembersfrommembers']) ? intval($data['hidemembersfrommembers']) : 0;
    $data['groupparticipationreports'] = isset($data['groupparticipationreports']) ? intval($data['groupparticipationreports']) : 0;
    $data['usersautoadded'] = isset($data['usersautoadded']) ? intval($data['usersautoadded']) : 0;
    $data['quota'] = get_config_plugin('artefact', 'file', 'defaultgroupquota');
    if (!empty($data['invitefriends']) && !empty($data['suggestfriends'])) {
        throw new InvalidArgumentException("group_create: a group cannot enable both invitefriends and suggestfriends");
    }
    $data['invitefriends'] = isset($data['invitefriends']) ? intval($data['invitefriends']) : 0;
    $data['suggestfriends'] = isset($data['suggestfriends']) ? intval($data['suggestfriends']) : 0;
    if (isset($data['shortname']) && strlen($data['shortname'])) {
        // This is a group whose details and membership can be updated automatically, using a
        // webservice api or possibly csv upload.
        // On updates to this group, it will be identified using the institution and shortname
        // which must be unique.
        // The $USER object will be set to someone with at least institutional admin permission.
        global $USER;
        if (empty($data['institution'])) {
            throw new SystemException("group_create: a group with a shortname must have an institution; shortname: " . $data['shortname']);
        }
        if (!$USER->can_edit_institution($data['institution'])) {
            throw new AccessDeniedException("group_create: cannot create a group in this institution");
        }
        if (!preg_match('/^[a-zA-Z0-9_.-]{2,255}$/', $data['shortname'])) {
            $message = get_string('invalidshortname', 'group') . ': ' . $data['shortname'];
            $message .= "\n" . get_string('shortnameformat', 'group');
            throw new UserException($message);
        }
        if (record_exists('group', 'shortname', $data['shortname'], 'institution', $data['institution'])) {
            throw new UserException('group_create: group with shortname ' . $data['shortname'] . ' and institution ' . $data['institution'] . ' already exists');
        }
        if (empty($data['members'])) {
            $data['members'] = array($USER->get('id') => 'admin');
        }
    } else {
        if (!empty($data['institution'])) {
//.........这里部分代码省略.........
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:group.php

示例12: create_user

/**
 * Create user
 *
 * @param object $user stdclass or User object for the usr table
 * @param array  $profile profile field/values to set
 * @param string|object $institution Institution the user should joined to (name or Institution object)
 * @param bool $remoteauth authinstance record for a remote authinstance
 * @param string $remotename username on the remote site
 * @param array $accountprefs user account preferences to set
 * @return integer id of the new user
 */
function create_user($user, $profile = array(), $institution = null, $remoteauth = null, $remotename = null, $accountprefs = array(), $quickhash = false)
{
    db_begin();
    if ($user instanceof User) {
        $user->create();
        $user->quota_init();
        $user->commit();
        $user = $user->to_stdclass();
    } else {
        $user->ctime = db_format_timestamp(time());
        // Ensure this user has a profile urlid
        if (get_config('cleanurls') && (!isset($user->urlid) || is_null($user->urlid))) {
            $user->urlid = generate_urlid($user->username, get_config('cleanurluserdefault'), 3, 30);
            $user->urlid = get_new_profile_urlid($user->urlid);
        }
        if (empty($user->quota)) {
            $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
        }
        if (get_config('defaultaccountlifetime')) {
            // we need to set the user expiry to the site default one
            $user->expiry = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')) + (int) get_config('defaultaccountlifetime'));
        }
        $user->id = insert_record('usr', $user, 'id', true);
    }
    if (isset($user->email) && $user->email != '') {
        set_profile_field($user->id, 'email', $user->email, TRUE);
    }
    if (isset($user->firstname) && $user->firstname != '') {
        set_profile_field($user->id, 'firstname', $user->firstname, TRUE);
    }
    if (isset($user->lastname) && $user->lastname != '') {
        set_profile_field($user->id, 'lastname', $user->lastname, TRUE);
    }
    foreach ($profile as $k => $v) {
        if (in_array($k, array('firstname', 'lastname', 'email'))) {
            continue;
        }
        set_profile_field($user->id, $k, $v, TRUE);
    }
    if (!empty($institution)) {
        if (is_string($institution)) {
            $institution = new Institution($institution);
        }
        if ($institution->name != 'mahara') {
            $institution->addUserAsMember($user);
            // uses $user->newuser
            if (empty($accountprefs['licensedefault'])) {
                $accountprefs['licensedefault'] = LICENSE_INSTITUTION_DEFAULT;
            }
        }
    }
    $authobj = get_record('auth_instance', 'id', $user->authinstance);
    $authinstance = AuthFactory::create($authobj->id);
    // For legacy compatibility purposes, we'll also put the remote auth on there if it has been
    // specifically requested.
    if ($authinstance->needs_remote_username() || !empty($remoteauth)) {
        if (isset($remotename) && strlen($remotename) > 0) {
            $un = $remotename;
        } else {
            $un = $user->username;
        }
        // remote username must not already exist
        if (record_exists('auth_remote_user', 'remoteusername', $un, 'authinstance', $user->authinstance)) {
            throw new InvalidArgumentException("user_create: remoteusername already exists: ({$un}, {$user->authinstance})");
        }
        insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $un, 'localusr' => $user->id));
    }
    // Set account preferences
    if (!empty($accountprefs)) {
        $expectedprefs = expected_account_preferences();
        foreach ($expectedprefs as $eprefkey => $epref) {
            if (isset($accountprefs[$eprefkey]) && $accountprefs[$eprefkey] != $epref) {
                set_account_preference($user->id, $eprefkey, $accountprefs[$eprefkey]);
            }
        }
    }
    // Copy site views and collections to the new user's profile
    $userobj = new User();
    $userobj->find_by_id($user->id);
    $userobj->copy_site_views_collections_to_new_user();
    reset_password($user, false, $quickhash);
    handle_event('createuser', $user);
    db_commit();
    return $user->id;
}
开发者ID:patkira,项目名称:mahara,代码行数:96,代码来源:user.php

示例13: addpost_submit

function addpost_submit(Pieform $form, $values)
{
    global $USER, $SESSION;
    $parentid = param_integer('parent');
    $postid = insert_record('interaction_forum_post', (object) array('topic' => $values['topic'], 'poster' => $USER->get('id'), 'parent' => $parentid, 'subject' => $values['subject'], 'body' => $values['body'], 'ctime' => db_format_timestamp(time())), 'id', true);
    $delay = get_config_plugin('interaction', 'forum', 'postdelay');
    if (!is_null($delay) && $delay == 0) {
        PluginInteractionForum::interaction_forum_new_post(array($postid));
    }
    $SESSION->add_ok_msg(get_string('addpostsuccess', 'interaction.forum'));
    redirect('/interaction/forum/topic.php?id=' . $values['topic'] . '#post' . $postid);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:12,代码来源:editpost.php

示例14: wallpost_form

 public function wallpost_form(BlockInstance $instance, $replyto = '', $replyuser = '')
 {
     if ($replyuser) {
         $walltoreplyto = self::get_wall_id_for_user($replyuser);
     } else {
         $walltoreplyto = $instance->get('id');
     }
     require_once 'pieforms/pieform.php';
     return pieform(array('name' => 'wallpost_' . $instance->get('id'), 'renderer' => 'maharatable', 'autofocus' => false, 'jsform' => true, 'template' => 'wallpost.php', 'templatedir' => pieform_template_dir('wallpost.php', 'blocktype/wall'), 'successcallback' => array('PluginBlocktypeWall', 'wallpost_submit'), 'jssuccesscallback' => 'wallpost_success', 'elements' => array('text' => array('type' => 'textarea', 'description' => bbcode_format_post_message(), 'rows' => 3, 'cols' => 50, 'defaultvalue' => '', 'width' => '100%', 'rules' => array('required' => true, 'maxlength' => get_config_plugin('blocktype', 'wall', 'defaultpostsizelimit'))), 'postsizelimit' => array('type' => 'html', 'value' => get_string('maxcharacters', 'blocktype.wall', get_config_plugin('blocktype', 'wall', 'defaultpostsizelimit'))), 'private' => array('type' => 'checkbox', 'title' => get_string('makeyourpostprivate', 'blocktype.wall')), 'instance' => array('type' => 'hidden', 'value' => $walltoreplyto), 'replyto' => array('type' => 'hidden', 'value' => $replyto), 'submit' => array('type' => 'submit', 'value' => get_string('Post', 'blocktype.wall')))));
     // TODO if replying here, add select element for replyto other wall or own wall
     // depending on if the user we're replying to has a wall
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:12,代码来源:lib.php

示例15: dirname

global $CFG, $USER, $SESSION;
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once get_config('docroot') . 'auth/saml/lib.php';
require_once get_config('libroot') . 'institution.php';
// check that the plugin is active
if (get_field('auth_installed', 'active', 'name', 'saml') != 1) {
    redirect();
}
// get the config pointing to the SAML library - and load it
$samllib = get_config_plugin('auth', 'saml', 'simplesamlphplib');
if (!file_exists($samllib . '/lib/_autoload.php')) {
    throw new AuthInstanceException(get_string('errorbadssphplib', 'auth.saml'));
}
require_once $samllib . '/lib/_autoload.php';
// point at the configured config directory
$samlconfig = get_config_plugin('auth', 'saml', 'simplesamlphpconfig');
// get all the things that we will need from the SAML authentication
// and then shutdown the session control
SimpleSAML_Configuration::init($samlconfig);
$saml_session = SimpleSAML_Session::getInstance();
// do we have a logout request?
if (param_variable("logout", false)) {
    // logout the saml session
    $sp = $saml_session->getAuthority();
    if (!$sp) {
        $sp = 'default-sp';
    }
    $as = new SimpleSAML_Auth_Simple($sp);
    $as->logout($CFG->wwwroot);
}
$sp = param_alphanumext('as', 'default-sp');
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:index.php


注:本文中的get_config_plugin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。