コード例 #1
0
ファイル: Api.php プロジェクト: rohit1290/Roles
 /**
  * Checks if the configuration array has been updated and updates role objects accordingly if needed
  * @return void
  */
 public function checkUpdate()
 {
     $hash = elgg_get_plugin_setting('roles_hash', 'roles');
     $roles_array = elgg_trigger_plugin_hook('roles:config', 'role', array(), null);
     $current_hash = sha1(serialize($roles_array));
     if ($hash != $current_hash) {
         roles_create_from_config($roles_array);
         elgg_set_plugin_setting('roles_hash', $current_hash, 'roles');
     }
 }
コード例 #2
0
ファイル: activate.php プロジェクト: socialweb/PiGo
<?php

if (get_subtype_id('object', 'role')) {
    update_subtype('object', 'role', 'ElggRole');
} else {
    add_subtype('object', 'role', 'ElggRole');
}
elgg_register_library('roles', elgg_get_plugins_path() . 'roles/lib/roles.php');
elgg_register_library('roles_config', elgg_get_plugins_path() . 'roles/lib/config.php');
elgg_load_library('roles');
elgg_load_library('roles_config');
// Delete all role objects upon plugin activation. Not sure if it's a good decision to automatically delete existing roles
$roles = roles_get_all_roles();
foreach ($roles as $role) {
    $role->delete();
}
// Create the role objects from the configuration arrays
$roles_array = elgg_trigger_plugin_hook('roles:config', 'role', array(), null);
roles_create_from_config($roles_array);