예제 #1
0
 /**
  * Updates fixed widgets on profile and dashboard
  *
  * @param string  $hook_name    name of the hook
  * @param string  $entity_type  type of the hook
  * @param unknown $return_value return value
  * @param unknown $params       hook parameters
  *
  * @return void
  */
 public static function checkFixedWidgets($hook_name, $entity_type, $return_value, $params)
 {
     $context = elgg_get_context();
     if (!in_array($context, ['profile', 'dashboard'])) {
         // only check things if you are viewing a profile or dashboard page
         return;
     }
     $page_owner_guid = elgg_get_page_owner_guid();
     if (empty($page_owner_guid)) {
         return;
     }
     $fixed_ts = elgg_get_plugin_setting($context . '_fixed_ts', 'widget_manager');
     if (empty($fixed_ts)) {
         // there should always be a fixed ts, so fix it now. This situation only occurs after activating widget_manager the first time.
         $fixed_ts = time();
         elgg_set_plugin_setting($context . '_fixed_ts', $fixed_ts, 'widget_manager');
     }
     // get the ts of the profile/dashboard you are viewing
     $user_fixed_ts = elgg_get_plugin_user_setting($context . '_fixed_ts', $page_owner_guid, 'widget_manager');
     if ($user_fixed_ts < $fixed_ts) {
         widget_manager_update_fixed_widgets($context, $page_owner_guid);
     }
 }
예제 #2
0
파일: start.php 프로젝트: n8b/VMN
/**
 * Function that runs on system pagesetup.
 *
 * @return void
 */
function widget_manager_pagesetup()
{
    $context = elgg_get_context();
    if (elgg_is_admin_logged_in() && $context == "admin") {
        // move defaultwidgets menu item
        elgg_unregister_menu_item("page", "appearance:default_widgets");
        elgg_register_menu_item('page', array('name' => "appearance:default_widgets", 'href' => "admin/appearance/default_widgets", 'text' => elgg_echo("admin:appearance:default_widgets"), 'context' => 'admin', 'parent_name' => "widgets", 'section' => "configure"));
        // add own menu items
        elgg_register_admin_menu_item('configure', 'manage', 'widgets');
        if (elgg_get_plugin_setting("custom_index", "widget_manager") == "1|0") {
            // a special link to manage homepages that are only available if logged out
            elgg_register_menu_item('page', array('name' => "admin:widgets:manage:index", 'href' => elgg_get_site_url() . "?override=true", 'text' => elgg_echo("admin:widgets:manage:index"), 'context' => 'admin', 'parent_name' => "widgets", 'section' => "configure"));
        }
    }
    // update fixed widgets if needed
    if (in_array($context, array("profile", "dashboard")) && ($page_owner_guid = elgg_get_page_owner_guid())) {
        // only check things if you are viewing a profile or dashboard page
        $fixed_ts = elgg_get_plugin_setting($context . "_fixed_ts", "widget_manager");
        if (empty($fixed_ts)) {
            // there should always be a fixed ts, so fix it now. This situation only occurs after activating widget_manager the first time.
            $fixed_ts = time();
            elgg_set_plugin_setting($context . "_fixed_ts", $fixed_ts, "widget_manager");
        }
        // get the ts of the profile/dashboard you are viewing
        $user_fixed_ts = elgg_get_plugin_user_setting($context . "_fixed_ts", $page_owner_guid, "widget_manager");
        if ($user_fixed_ts < $fixed_ts) {
            widget_manager_update_fixed_widgets($context, $page_owner_guid);
        }
    }
}