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


PHP handle_event函数代码示例

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


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

示例1: requestfriendship_submit

function requestfriendship_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id, $goto;
    $loggedinid = $USER->get('id');
    $user = get_record('usr', 'id', $id);
    // friend db record
    $f = new StdClass();
    $f->ctime = db_format_timestamp(time());
    // notification info
    $n = new StdClass();
    $n->url = profile_url($USER, false);
    $n->users = array($user->id);
    $n->fromuser = $loggedinid;
    $lang = get_user_language($user->id);
    $displayname = display_name($USER, $user);
    $n->strings = new stdClass();
    $n->strings->urltext = (object) array('key' => 'Requests');
    $f->owner = $id;
    $f->requester = $loggedinid;
    $f->message = $values['message'];
    insert_record('usr_friend_request', $f);
    $n->subject = get_string_from_language($lang, 'requestedfriendlistsubject', 'group');
    if (isset($values['message']) && !empty($values['message'])) {
        $n->message = get_string_from_language($lang, 'requestedfriendlistmessageexplanation', 'group', $displayname) . $values['message'];
    } else {
        $n->message = get_string_from_language($lang, 'requestedfriendlistinboxmessage', 'group', $displayname);
    }
    require_once 'activity.php';
    activity_occurred('maharamessage', $n);
    handle_event('addfriendrequest', array('requester' => $loggedinid, 'owner' => $id));
    $SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id)));
    redirect($goto);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:33,代码来源:requestfriendship.php

示例2: cancelrequest_submit

function cancelrequest_submit(Pieform $form, $values)
{
    global $USER;
    foreach ($values as $k => $v) {
        if (preg_match('/^\\_cancelrequest\\_([a-z0-9]+)$/', $k, $m)) {
            $institution = $m[1];
            break;
        }
    }
    if (!empty($institution)) {
        delete_records('usr_institution_request', 'usr', $USER->id, 'institution', $institution);
        handle_event('updateuser', $USER->id);
    }
    redirect(get_config('wwwroot') . 'account/institutions.php');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:institutions.php

示例3: do_masquerade

/**
 * Notify user (if configured), do the masquerading and emit event. Called when
 * no (further) interaction with the admin is needed before the loginas.
 *
 * @param string $why The masquerading reason (if given) or null.
 */
function do_masquerade($why = null)
{
    global $USER, $SESSION;
    $id = param_integer('id');
    $who = display_name($USER, $id);
    $when = format_date(time());
    if (get_config('masqueradingnotified')) {
        $msg = (object) array('subject' => get_string('masqueradenotificationsubject', 'admin'), 'message' => $why === null ? get_string('masqueradenotificationnoreason', 'admin', $who, $when) : get_string('masqueradenotificationreason', 'admin', $who, $when, $why), 'users' => array($id), 'url' => profile_url($USER, false), 'urltext' => $who);
        activity_occurred('maharamessage', $msg);
        $SESSION->add_info_msg(get_string('masqueradenotificationdone', 'admin'));
    }
    $USER->change_identity_to($id);
    // Permissions checking is done in here
    handle_event('loginas', array('who' => $who, 'when' => $when, 'reason' => $why));
    redirect(get_config('wwwroot'));
}
开发者ID:patkira,项目名称:mahara,代码行数:22,代码来源:changeuser.php

示例4: denyrequest_submit

function denyrequest_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id;
    $loggedinid = $USER->get('id');
    $user = get_record('usr', 'id', $id);
    // friend db record
    $f = new StdClass();
    $f->ctime = db_format_timestamp(time());
    // notification info
    $n = new StdClass();
    $n->url = profile_url($USER, false);
    $n->users = array($user->id);
    $n->fromuser = $USER->get('id');
    $lang = get_user_language($user->id);
    $displayname = display_name($USER, $user);
    $n->urltext = $displayname;
    delete_records('usr_friend_request', 'owner', $loggedinid, 'requester', $id);
    $n->subject = get_string_from_language($lang, 'friendrequestrejectedsubject', 'group');
    if (isset($values['reason']) && !empty($values['reason'])) {
        $n->message = get_string_from_language($lang, 'friendrequestrejectedmessagereason', 'group', $displayname) . $values['reason'];
    } else {
        $n->message = get_string_from_language($lang, 'friendrequestrejectedmessage', 'group', $displayname);
    }
    require_once 'activity.php';
    activity_occurred('maharamessage', $n);
    handle_event('removefriendrequest', array('owner' => $loggedinid, 'requester' => $id));
    $SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
    $offset = param_integer('offset', 0);
    switch (param_alpha('returnto', 'myfriends')) {
        case 'find':
            $goto = 'user/find.php';
            break;
        case 'view':
            $goto = profile_url($user, false);
            break;
        default:
            $goto = 'user/myfriends.php';
            break;
    }
    $goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset;
    $goto = get_config('wwwroot') . $goto;
    redirect($goto);
}
开发者ID:vohung96,项目名称:mahara,代码行数:43,代码来源:denyrequest.php

示例5: removefriend_submit

function removefriend_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id;
    $loggedinid = $USER->get('id');
    $user = get_record('usr', 'id', $id);
    // friend db record
    $f = new StdClass();
    $f->ctime = db_format_timestamp(time());
    // notification info
    $n = new StdClass();
    $n->url = get_config('wwwroot') . 'user/view.php?id=' . $loggedinid;
    $n->users = array($user->id);
    $lang = get_user_language($user->id);
    $displayname = display_name($USER, $user);
    $n->urltext = $displayname;
    delete_records_select('usr_friend', '(usr1 = ? AND usr2 = ?) OR (usr2 = ? AND usr1 = ?)', array($id, $loggedinid, $id, $loggedinid));
    $n->subject = get_string_from_language($lang, 'removedfromfriendslistsubject', 'group');
    if (isset($values['reason']) && !empty($values['reason'])) {
        $n->message = get_string_from_language($lang, 'removedfromfriendslistmessage', 'group', $displayname) . $values['reason'];
    } else {
        $n->message = get_string_from_language($lang, 'removedfromfriendslistmessage', 'group', $displayname);
    }
    require_once 'activity.php';
    activity_occurred('maharamessage', $n);
    handle_event('removefriend', array('user' => $loggedinid, 'friend' => $id));
    $SESSION->add_ok_msg(get_string('friendformremovesuccess', 'group', display_name($id)));
    switch (param_alpha('returnto', 'myfriends')) {
        case 'find':
            redirect('/user/find.php');
            break;
        case 'view':
            redirect('/user/view.php?id=' . $id);
            break;
        default:
            redirect('/user/myfriends.php');
            break;
    }
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:38,代码来源:removefriend.php

示例6: viewskin_submit

function viewskin_submit(Pieform $form, $values)
{
    global $SESSION;
    $view = new View($values['view']);
    $new = $values['new'];
    $view->set('skin', $values['skin']);
    $view->commit();
    handle_event('saveview', $view->get('id'));
    $SESSION->add_ok_msg(get_string('viewskinchanged', 'skin'));
    redirect('/view/view.php?id=' . $view->get('id') . ($new ? '&new=1' : ''));
}
开发者ID:rboyatt,项目名称:mahara,代码行数:11,代码来源:skin.php

示例7: 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

示例8: commit

 public function commit()
 {
     if (empty($this->dirty)) {
         return;
     }
     $fordb = new StdClass();
     foreach (get_object_vars($this) as $k => $v) {
         // The configdata is initially fetched from the database in string
         // form. Calls to get() will convert it to an array on the fly. We
         // ensure that it is a string again here
         if ($k == 'configdata' && is_array($v)) {
             $fordb->{$k} = serialize($v);
         } else {
             $fordb->{$k} = $v;
         }
     }
     if (empty($this->id)) {
         $this->id = insert_record('block_instance', $fordb, 'id', true);
     } else {
         update_record('block_instance', $fordb, 'id');
     }
     $this->rebuild_artefact_list();
     // Tell stuff about this
     handle_event('blockinstancecommit', $this);
     $this->dirty = false;
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:26,代码来源:lib.php

示例9: core_install_lastcoredata_defaults

function core_install_lastcoredata_defaults()
{
    db_begin();
    $institution = new StdClass();
    $institution->name = 'mahara';
    $institution->displayname = 'No Institution';
    $institution->authplugin = 'internal';
    $institution->theme = 'default';
    insert_record('institution', $institution);
    $auth_instance = new StdClass();
    $auth_instance->instancename = 'Internal';
    $auth_instance->priority = '1';
    $auth_instance->institution = 'mahara';
    $auth_instance->authname = 'internal';
    $auth_instance->id = insert_record('auth_instance', $auth_instance, 'id', true);
    // Insert the root user
    $user = new StdClass();
    $user->id = 0;
    $user->username = 'root';
    $user->password = '*';
    $user->salt = '*';
    $user->firstname = 'System';
    $user->lastname = 'User';
    $user->email = 'root@example.org';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->authinstance = $auth_instance->id;
    if (is_mysql()) {
        // gratuitous mysql workaround
        $newid = insert_record('usr', $user, 'id', true);
        set_field('usr', 'id', 0, 'id', $newid);
        execute_sql('ALTER TABLE {usr} AUTO_INCREMENT=1');
    } else {
        insert_record('usr', $user);
    }
    install_system_profile_view();
    // Insert the admin user
    $user = new StdClass();
    $user->username = 'admin';
    $user->password = 'mahara';
    $user->authinstance = $auth_instance->id;
    $user->passwordchange = 1;
    $user->admin = 1;
    $user->firstname = 'Admin';
    $user->lastname = 'User';
    $user->email = 'admin@example.org';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->id = insert_record('usr', $user, 'id', true);
    set_profile_field($user->id, 'email', $user->email);
    set_profile_field($user->id, 'firstname', $user->firstname);
    set_profile_field($user->id, 'lastname', $user->lastname);
    set_config('installed', true);
    handle_event('createuser', $user->id);
    activity_add_admin_defaults(array($user->id));
    db_commit();
    // if we're installing, set up the block categories here and then poll the plugins.
    // if we're upgrading this happens somewhere else.  This is because of dependency issues around
    // the order of installation stuff.
    install_blocktype_extras();
}
开发者ID:Br3nda,项目名称:mahara,代码行数:59,代码来源:upgrade.php

示例10: tlschema

<?php

// addnews ready.
// translator ready
// mail ready
require_once "common.php";
require_once "lib/http.php";
require_once "lib/buffs.php";
require_once "lib/events.php";
tlschema("graveyard");
page_header("The Graveyard");
$skipgraveyardtext = handle_event("graveyard");
$deathoverlord = getsetting('deathoverlord', '`$Ramius');
if (!$skipgraveyardtext) {
    if ($session['user']['alive']) {
        redirect("village.php", "Redirecting from Shades because the player isn't dead!");
    }
    checkday();
}
$battle = false;
strip_all_buffs();
$op = httpget('op');
switch ($op) {
    case "search":
        require_once "lib/graveyard/case_battle_search.php";
        break;
    case "run":
        if (e_rand(0, 2) == 1) {
            output("`\$%s`) curses you for your cowardice.`n`n", $deathoverlord);
            $favor = 5 + e_rand(0, $session['user']['level']);
            if ($favor > $session['user']['deathpower']) {
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:31,代码来源:graveyard.php

示例11: set_access

 public function set_access($accessdata)
 {
     global $USER;
     require_once 'activity.php';
     $beforeusers = activity_get_viewaccess_users($this->get('id'), $USER->get('id'), 'viewaccess');
     db_begin();
     delete_records('view_access', 'view', $this->get('id'), 'visible', 1);
     // View access
     if ($accessdata) {
         /*
          * There should be a cleaner way to do this
          * $accessdata_added ensures that the same access is not granted twice because the profile page
          * gets very grumpy if there are duplicate access rules
          *
          * Additional rules:
          * - Don't insert records with stopdate in the past
          * - Remove startdates that are in the past
          * - If view allows comments, access record comment permissions, don't apply, so reset them.
          * @todo: merge overlapping date ranges.
          */
         $accessdata_added = array();
         $time = time();
         foreach ($accessdata as $item) {
             if (!empty($item['stopdate']) && $item['stopdate'] < $time) {
                 continue;
             }
             if (!empty($item['startdate']) && $item['startdate'] < $time) {
                 unset($item['startdate']);
             }
             if ($this->get('allowcomments')) {
                 unset($item['allowcomments']);
                 unset($item['approvecomments']);
             }
             $accessrecord = new StdClass();
             switch ($item['type']) {
                 case 'user':
                     $accessrecord->usr = $item['id'];
                     break;
                 case 'group':
                     $accessrecord->group = $item['id'];
                     if (isset($item['role']) && strlen($item['role'])) {
                         // Don't insert a record for a role the group doesn't have
                         $roleinfo = group_get_role_info($item['id']);
                         if (!isset($roleinfo[$item['role']])) {
                             break;
                         }
                         $accessrecord->role = $item['role'];
                     }
                     break;
                 case 'token':
                     $accessrecord->token = $item['id'];
                     break;
                 case 'friends':
                     if (!$this->owner) {
                         continue;
                         // Don't add friend access to group, institution or system views
                     }
                 case 'public':
                 case 'loggedin':
                     $accessrecord->accesstype = $item['type'];
             }
             $accessrecord->view = $this->get('id');
             if (isset($item['allowcomments'])) {
                 $accessrecord->allowcomments = (int) (!empty($item['allowcomments']));
                 if ($accessrecord->allowcomments) {
                     $accessrecord->approvecomments = (int) (!empty($item['approvecomments']));
                 }
             }
             if (isset($item['startdate'])) {
                 $accessrecord->startdate = db_format_timestamp($item['startdate']);
             }
             if (isset($item['stopdate'])) {
                 $accessrecord->stopdate = db_format_timestamp($item['stopdate']);
             }
             if (array_search($accessrecord, $accessdata_added) === false) {
                 insert_record('view_access', $accessrecord);
                 $accessdata_added[] = $accessrecord;
             }
         }
     }
     $data = new StdClass();
     $data->view = $this->get('id');
     $data->owner = $USER->get('id');
     $data->oldusers = $beforeusers;
     activity_occurred('viewaccess', $data);
     handle_event('saveview', $this->get('id'));
     db_commit();
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:88,代码来源:view.php

示例12: array

$schemas = array("text" => "village", "clock" => "village", "title" => "village", "talk" => "village", "sayline" => "village", "newest" => "village", "newestplayer" => "village", "newestid" => "village", "gatenav" => "village", "fightnav" => "village", "marketnav" => "village", "tavernnav" => "village", "infonav" => "village", "othernav" => "village", "section" => "village", "innname" => "village", "stablename" => "village", "mercenarycamp" => "village", "armorshop" => "village", "weaponshop" => "village");
// Now store the schemas
$origtexts['schemas'] = $schemas;
// don't hook on to this text for your standard modules please, use "village"
// instead.
// This hook is specifically to allow modules that do other villages to create
// ambience.
$texts = modulehook("villagetext", $origtexts);
//and now a special hook for the village
//$texts = modulehook("villagetext-{$session['user']['location']}",$texts);
$schemas = $texts['schemas'];
tlschema($schemas['title']);
page_header($texts['title']);
tlschema();
addcommentary();
$skipvillagedesc = handle_event("village");
checkday();
if ($session['user']['slaydragon'] == 1) {
    $session['user']['slaydragon'] = 0;
}
if ($session['user']['alive']) {
} else {
    redirect("shades.php", "Player in village but not alive");
}
if (getsetting("automaster", 1) && $session['user']['seenmaster'] != 1) {
    //masters hunt down truant students
    $level = $session['user']['level'] + 1;
    $dks = $session['user']['dragonkills'];
    $expreqd = exp_for_next_level($level, $dks);
    if ($session['user']['experience'] > $expreqd && $session['user']['level'] < 15) {
        redirect("train.php?op=autochallenge", "Master auto-challenge");
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:31,代码来源:village.php

示例13: core_install_lastcoredata_defaults

function core_install_lastcoredata_defaults()
{
    global $USER;
    db_begin();
    $institution = new StdClass();
    $institution->name = 'mahara';
    $institution->displayname = 'No Institution';
    $institution->authplugin = 'internal';
    $institution->theme = 'default';
    $institution->priority = 0;
    insert_record('institution', $institution);
    $pages = site_content_pages();
    $now = db_format_timestamp(time());
    foreach ($pages as $name) {
        $page = new stdClass();
        $page->name = $name;
        $page->ctime = $now;
        $page->mtime = $now;
        $page->content = get_string($page->name . 'defaultcontent', 'install', get_string('staticpageconfigdefault', 'install'));
        $page->institution = 'mahara';
        insert_record('site_content', $page);
    }
    $auth_instance = new StdClass();
    $auth_instance->instancename = 'Internal';
    $auth_instance->priority = '1';
    $auth_instance->institution = 'mahara';
    $auth_instance->authname = 'internal';
    $auth_instance->id = insert_record('auth_instance', $auth_instance, 'id', true);
    // Insert the root user
    $user = new StdClass();
    $user->id = 0;
    $user->username = 'root';
    $user->password = '*';
    $user->salt = '*';
    $user->firstname = 'System';
    $user->lastname = 'User';
    $user->email = 'root@example.org';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->authinstance = $auth_instance->id;
    if (is_mysql()) {
        // gratuitous mysql workaround
        $newid = insert_record('usr', $user, 'id', true);
        set_field('usr', 'id', 0, 'id', $newid);
        execute_sql('ALTER TABLE {usr} AUTO_INCREMENT=1');
    } else {
        insert_record('usr', $user);
    }
    // install the default layout options
    install_view_layout_defaults();
    require_once 'group.php';
    install_system_profile_view();
    install_system_dashboard_view();
    install_system_grouphomepage_view();
    require_once 'license.php';
    install_licenses_default();
    require_once 'skin.php';
    install_skins_default();
    // Insert the admin user
    $user = new StdClass();
    $user->username = 'admin';
    $user->salt = auth_get_random_salt();
    $user->password = crypt('mahara', '$2a$' . get_config('bcrypt_cost') . '$' . substr(md5(get_config('passwordsaltmain') . $user->salt), 0, 22));
    $user->password = substr($user->password, 0, 7) . substr($user->password, 7 + 22);
    $user->authinstance = $auth_instance->id;
    $user->passwordchange = 1;
    $user->admin = 1;
    $user->firstname = 'Admin';
    $user->lastname = 'User';
    $user->email = 'admin@example.org';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->id = insert_record('usr', $user, 'id', true);
    set_profile_field($user->id, 'email', $user->email);
    set_profile_field($user->id, 'firstname', $user->firstname);
    set_profile_field($user->id, 'lastname', $user->lastname);
    handle_event('createuser', $user);
    activity_add_admin_defaults(array($user->id));
    db_commit();
    // if we're installing, set up the block categories here and then poll the plugins.
    // if we're upgrading this happens somewhere else.  This is because of dependency issues around
    // the order of installation stuff.
    install_blocktype_extras();
}
开发者ID:agwells,项目名称:Mahara-1,代码行数:82,代码来源:upgrade.php

示例14: set_access


//.........这里部分代码省略.........
     // need to have the view and any attached artefacts removed from their
     // watchlist.
     $oldusers = array();
     foreach ($this->get_access() as $item) {
         if ($item['type'] == 'user') {
             $oldusers[] = $item;
         }
     }
     $newusers = array();
     if ($accessdata) {
         foreach ($accessdata as $item) {
             if ($item['type'] == 'user') {
                 $newusers[] = $item;
             }
         }
     }
     $userstodelete = array();
     foreach ($oldusers as $olduser) {
         foreach ($newusers as $newuser) {
             if ($olduser['id'] == $newuser['id']) {
                 continue 2;
             }
         }
         $userstodelete[] = $olduser;
     }
     if ($userstodelete) {
         $userids = array();
         foreach ($userstodelete as $user) {
             $userids[] = intval($user['id']);
         }
         $userids = implode(',', $userids);
         execute_sql('DELETE FROM {usr_watchlist_view}
             WHERE view = ' . $this->get('id') . '
             AND usr IN (' . $userids . ')');
     }
     $beforeusers = activity_get_viewaccess_users($this->get('id'), $USER->get('id'), 'viewaccess');
     // Procedure:
     // get list of current friends - this is available in global $data
     // compare with list of new friends
     // work out which friends are being removed
     // foreach friend
     //     // remove record from usr_watchlist_view where usr = ? and view = ?
     //     // remove records from usr_watchlist_artefact where usr = ? and view = ?
     // endforeach
     //
     db_begin();
     delete_records('view_access', 'view', $this->get('id'));
     delete_records('view_access_usr', 'view', $this->get('id'));
     delete_records('view_access_group', 'view', $this->get('id'));
     delete_records('view_access_token', 'view', $this->get('id'), 'visible', 1);
     $time = db_format_timestamp(time());
     // View access
     if ($accessdata) {
         foreach ($accessdata as $item) {
             $accessrecord = new StdClass();
             $accessrecord->view = $this->get('id');
             if (isset($item['startdate'])) {
                 $accessrecord->startdate = db_format_timestamp($item['startdate']);
             }
             if (isset($item['stopdate'])) {
                 $accessrecord->stopdate = db_format_timestamp($item['stopdate']);
             }
             switch ($item['type']) {
                 case 'public':
                 case 'loggedin':
                 case 'friends':
                     $accessrecord->accesstype = $item['type'];
                     insert_record('view_access', $accessrecord);
                     break;
                 case 'user':
                     $accessrecord->usr = $item['id'];
                     insert_record('view_access_usr', $accessrecord);
                     break;
                 case 'group':
                     $accessrecord->group = $item['id'];
                     if ($item['role']) {
                         // Don't insert a record for a role the group doesn't have
                         $roleinfo = group_get_role_info($item['id']);
                         if (!isset($roleinfo[$item['role']])) {
                             break;
                         }
                         $accessrecord->role = $item['role'];
                     }
                     insert_record('view_access_group', $accessrecord);
                     break;
                 case 'token':
                     $accessrecord->token = $item['id'];
                     insert_record('view_access_token', $accessrecord);
                     break;
             }
         }
     }
     $data = new StdClass();
     $data->view = $this->get('id');
     $data->owner = $USER->get('id');
     $data->oldusers = $beforeusers;
     activity_occurred('viewaccess', $data);
     handle_event('saveview', $this->get('id'));
     db_commit();
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:101,代码来源:view.php

示例15: dirname

<?php

include_once dirname(__FILE__) . "/../lib/utilities.php";
include_once dirname(__FILE__) . "/../lib/app.php";
$fixture = file_get_contents("test_status.json");
handle_event($fixture);
开发者ID:alexandrubordei,项目名称:basic_marathon_orchestration,代码行数:6,代码来源:test_handler.php


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