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


PHP get_user_notification_settings函数代码示例

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


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

示例1: adminApprovalSubs

 /**
  * Get the subscribers for a new group which needs admin approval
  *
  * @param string $hook         the name of the hook
  * @param string $type         the type of the hook
  * @param array  $return_value current return value
  * @param array  $params       supplied params
  *
  * @return void|array
  */
 public static function adminApprovalSubs($hook, $type, $return_value, $params)
 {
     $event = elgg_extract('event', $params);
     if (!$event instanceof \Elgg\Notifications\Event) {
         return;
     }
     $group = $event->getObject();
     if (!$group instanceof \ElggGroup) {
         return;
     }
     $action = $event->getAction();
     if ($action !== 'admin_approval') {
         return;
     }
     // get all admins
     $dbprefix = elgg_get_config('dbprefix');
     $batch = new \ElggBatch('elgg_get_entities', ['type' => 'user', 'joins' => ["JOIN {$dbprefix}users_entity ue ON e.guid = ue.guid"], 'wheres' => ['ue.admin = "yes"']]);
     /* @var $user \ElggUser */
     foreach ($batch as $user) {
         $notification_settings = get_user_notification_settings($user->getGUID());
         if (empty($notification_settings)) {
             continue;
         }
         $return_value[$user->getGUID()] = [];
         foreach ($notification_settings as $method => $active) {
             if (!$active) {
                 continue;
             }
             $return_value[$user->getGUID()][] = $method;
         }
     }
     return $return_value;
 }
开发者ID:coldtrick,项目名称:group_tools,代码行数:43,代码来源:Notifications.php

示例2: notify_user

/**
 * Notify a user via their preferences.
 *
 * @param mixed $to Either a guid or an array of guid's to notify.
 * @param int $from GUID of the sender, which may be a user, site or object.
 * @param string $subject Message subject.
 * @param string $message Message body.
 * @param array $params Misc additional parameters specific to various methods.
 * @param mixed $methods_override A string, or an array of strings specifying the delivery methods to use - or leave blank
 * 				for delivery using the user's chosen delivery methods.
 * @return array Compound array of each delivery user/delivery method's success or failure.
 * @throws NotificationException
 */
function notify_user($to, $from, $subject, $message, array $params = NULL, $methods_override = "")
{
    global $NOTIFICATION_HANDLERS, $CONFIG;
    // Sanitise
    if (!is_array($to)) {
        $to = array((int) $to);
    }
    $from = (int) $from;
    //$subject = sanitise_string($subject);
    // Get notification methods
    if ($methods_override && !is_array($methods_override)) {
        $methods_override = array($methods_override);
    }
    $result = array();
    foreach ($to as $guid) {
        // Results for a user are...
        $result[$guid] = array();
        if ($guid) {
            // Is the guid > 0?
            // Are we overriding delivery?
            $methods = $methods_override;
            if (!$methods) {
                $tmp = (array) get_user_notification_settings($guid);
                $methods = array();
                foreach ($tmp as $k => $v) {
                    if ($v) {
                        $methods[] = $k;
                    }
                }
                // Add method if method is turned on for user!
            }
            if ($methods) {
                // Deliver
                foreach ($methods as $method) {
                    // Extract method details from list
                    $details = $NOTIFICATION_HANDLERS[$method];
                    $handler = $details->handler;
                    if (!$NOTIFICATION_HANDLERS[$method] || !$handler) {
                        error_log(sprintf(elgg_echo('NotificationException:NoHandlerFound'), $method));
                    }
                    if ($CONFIG->debug) {
                        error_log("Sending message to {$guid} using {$method}");
                    }
                    // Trigger handler and retrieve result.
                    try {
                        $result[$guid][$method] = $handler($from ? get_entity($from) : NULL, get_entity($guid), $subject, $message, $params);
                    } catch (Exception $e) {
                        error_log($e->getMessage());
                    }
                }
            }
        }
    }
    return $result;
}
开发者ID:eokyere,项目名称:elgg,代码行数:68,代码来源:notification.php

示例3: addDiscussionOwner

 /**
  * Add a discussion owner to the notified users
  *
  * @param string $hook         the name of the hook
  * @param stirng $type         the type of the hook
  * @param array  $return_value the current return value
  * @param array  $params       supplied values
  *
  * @return void|array
  */
 public static function addDiscussionOwner($hook, $type, $return_value, $params)
 {
     if (empty($params) || !is_array($params)) {
         return;
     }
     $event = elgg_extract('event', $params);
     if (!$event instanceof \Elgg\Notifications\Event) {
         return;
     }
     $discussion_reply = $event->getObject();
     if (!$discussion_reply instanceof \ElggDiscussionReply) {
         return;
     }
     $discussion = $discussion_reply->getContainerEntity();
     if (!elgg_instanceof($discussion, 'object', 'discussion')) {
         return;
     }
     $owner = $discussion->getOwnerEntity();
     if (!$owner instanceof \ElggUser) {
         return;
     }
     $user_notification_settings = get_user_notification_settings($owner->getGUID());
     if (empty($user_notification_settings)) {
         // user has no settings, so no notification
         return;
     }
     $temp = [];
     foreach ($user_notification_settings as $method => $enabled) {
         if (empty($enabled)) {
             // notification method not enabled
             continue;
         }
         $temp[] = $method;
     }
     if (empty($temp)) {
         // no enabled notification methods
         return;
     }
     $return_value[$owner->getGUID()] = $temp;
     return $return_value;
 }
开发者ID:coldtrick,项目名称:content_subscriptions,代码行数:51,代码来源:Subscriptions.php

示例4: get_user_notification_settings

<?php

/**
 * User settings for notifications.
 * 
 * @package Elgg
 * @subpackage Core
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider Ltd
 * @copyright Curverider Ltd 2008-2009
 * @link http://elgg.org/
 */
global $NOTIFICATION_HANDLERS;
$notification_settings = get_user_notification_settings(page_owner());
?>
	<h3><?php 
echo elgg_echo('notifications:usersettings');
?>
</h3>
	
	<p><?php 
echo elgg_echo('notifications:methods');
?>
	
	<table>
<?php 
// Loop through options
foreach ($NOTIFICATION_HANDLERS as $k => $v) {
    ?>
			<tr>
				<td><?php 
开发者ID:eokyere,项目名称:elgg,代码行数:31,代码来源:usersettings.php

示例5: _elgg_comments_add_content_owner_to_subscriptions

/**
 * Add the owner of the content being commented on to the subscribers
 *
 * @param string $hook        'get'
 * @param string $type        'subscribers'
 * @param array  $returnvalue current subscribers
 * @param array  $params      supplied params
 *
 * @return void|array
 *
 * @access private
 */
function _elgg_comments_add_content_owner_to_subscriptions($hook, $type, $returnvalue, $params)
{
    $event = elgg_extract('event', $params);
    if (!$event instanceof \Elgg\Notifications\Event) {
        return;
    }
    $object = $event->getObject();
    if (!elgg_instanceof($object, 'object', 'comment')) {
        // can't use instanceof ElggComment as discussion replies inherit
        return;
    }
    $content_owner = $object->getContainerEntity()->getOwnerEntity();
    if (!$content_owner instanceof ElggUser) {
        return;
    }
    $notification_settings = get_user_notification_settings($content_owner->getGUID());
    if (empty($notification_settings)) {
        return;
    }
    $returnvalue[$content_owner->getGUID()] = [];
    foreach ($notification_settings as $method => $enabled) {
        if (empty($enabled)) {
            continue;
        }
        $returnvalue[$content_owner->getGUID()][] = $method;
    }
    return $returnvalue;
}
开发者ID:elgg,项目名称:elgg,代码行数:40,代码来源:comments.php

示例6: zhsite_send_email_to_user

function zhsite_send_email_to_user($to_user, $subject, $message, $is_notificiation)
{
    if ($is_notificiation) {
        if ($notification_settings = get_user_notification_settings($to_user->guid)) {
            if (!$notification_settings->email) {
                return false;
            }
        } else {
            elgg_log("ZHError ,zhsite_send_email_to_user, error calling get_user_notification_settings, to_user_id {$to_user->guid}, " . "logged_user_id " . elgg_get_logged_in_user_guid(), "ERROR");
            return false;
        }
    }
    $end = zhaohuEmailUnsubEnd(null, $to_user->guid, $is_notificiation, false);
    $to_email = $to_user->name . "<" . $to_user->email . ">";
    return zhgroups_send_email(elgg_get_site_entity()->name, $to_email, $subject, $message, $end);
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:16,代码来源:notify.php

示例7: get_input

<?php

/**
 * Elgg notifications user preference save acion.
 *
 * @package Elgg
 * @subpackage Core
 */
$method = get_input('method');
$current_settings = get_user_notification_settings();
$result = false;
foreach ($method as $k => $v) {
    // check if setting has changed and skip if not
    if ($current_settings->{$k} == ($v == 'yes')) {
        continue;
    }
    $result = set_user_notification_setting(elgg_get_logged_in_user_guid(), $k, $v == 'yes' ? true : false);
    if (!$result) {
        register_error(elgg_echo('notifications:usersettings:save:fail'));
    }
}
if ($result) {
    system_message(elgg_echo('notifications:usersettings:save:ok'));
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:24,代码来源:save.php

示例8: elgg_echo

?>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class="namefield">
			<p>
				<?php 
echo elgg_echo('notifications:subscriptions:personal:description');
?>
			</p>
		</td>

<?php 
$fields = '';
$i = 0;
$notification_settings = get_user_notification_settings($user->guid);
if (!$notification_settings) {
    elgg_log("Error get_user_notification_settings for user {$user->guid}", "ERROR");
}
foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
    if ($notification_settings->{$method}) {
        $personalchecked[$method] = 'checked="checked"';
    } else {
        $personalchecked[$method] = '';
    }
    if ($i > 0) {
        $fields .= "<td class='spacercolumn'>&nbsp;</td>";
    }
    $fields .= <<<END
\t\t<td class="{$method}togglefield">
\t\t<a  border="0" id="{$method}personal" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}personal');">
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:31,代码来源:personal.php

示例9: get_user_notification_settings

<?php

/**
 * User settings for notifications.
 *
 * @package Elgg
 * @subpackage Core
 */
global $NOTIFICATION_HANDLERS;
$notification_settings = get_user_notification_settings(elgg_get_page_owner_guid());
$title = elgg_echo('notifications:usersettings');
$rows = '';
// Loop through options
foreach ($NOTIFICATION_HANDLERS as $k => $v) {
    if ($notification_settings->{$k}) {
        $val = "yes";
    } else {
        $val = "no";
    }
    $radio = elgg_view('input/radio', array('name' => "method[{$k}]", 'value' => $val, 'options' => array(elgg_echo('option:yes') => 'yes', elgg_echo('option:no') => 'no')));
    $cells = '<td class="prm pbl">' . elgg_echo("notification:method:{$k}") . ': </td>';
    $cells .= "<td>{$radio}</td>";
    $rows .= "<tr>{$cells}</tr>";
}
$content = elgg_echo('notifications:methods');
$content .= "<table>{$rows}</table>";
echo elgg_view_module('info', $title, $content);
开发者ID:duanhv,项目名称:mdg-social,代码行数:27,代码来源:notifications.php

示例10: thewire_add_original_poster

/**
 * Add temporary subscription for original poster if not already registered to
 * receive a notification of reply
 *
 * @param string $hook          Hook name
 * @param string $type          Hook type
 * @param array  $subscriptions Subscriptions for a notification event
 * @param array  $params        Parameters including the event
 * @return array
 */
function thewire_add_original_poster($hook, $type, $subscriptions, $params)
{
    $event = $params['event'];
    $entity = $event->getObject();
    if ($entity && elgg_instanceof($entity, 'object', 'thewire')) {
        $parent = $entity->getEntitiesFromRelationship(array('relationship' => 'parent'));
        if ($parent) {
            $parent = $parent[0];
            // do not add a subscription if reply was to self
            if ($parent->getOwnerGUID() !== $entity->getOwnerGUID()) {
                if (!array_key_exists($parent->getOwnerGUID(), $subscriptions)) {
                    $personal_methods = (array) get_user_notification_settings($parent->getOwnerGUID());
                    $methods = array();
                    foreach ($personal_methods as $method => $state) {
                        if ($state) {
                            $methods[] = $method;
                        }
                    }
                    if ($methods) {
                        $subscriptions[$parent->getOwnerGUID()] = $methods;
                        return $subscriptions;
                    }
                }
            }
        }
    }
}
开发者ID:elgg,项目名称:elgg,代码行数:37,代码来源:start.php

示例11: thewire_tools_get_notification_settings

/**
 * Get the subscription methods of the user
 *
 * @param int $user_guid the user_guid to check (default: current user)
 *
 * @return array
 */
function thewire_tools_get_notification_settings($user_guid = 0)
{
    $user_guid = sanitise_int($user_guid, false);
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    if (empty($user_guid)) {
        return array();
    }
    if (elgg_is_active_plugin("notifications")) {
        $saved = elgg_get_plugin_user_setting("notification_settings_saved", $user_guid, "thewire_tools");
        if (!empty($saved)) {
            $settings = elgg_get_plugin_user_setting("notification_settings", $user_guid, "thewire_tools");
            if (!empty($settings)) {
                return string_to_tag_array($settings);
            }
            return array();
        }
    }
    // default elgg settings
    $settings = get_user_notification_settings($user_guid);
    if (!empty($settings)) {
        $settings = (array) $settings;
        $res = array();
        foreach ($settings as $method => $value) {
            if (!empty($value)) {
                $res[] = $method;
            }
        }
        return $res;
    }
    return array();
}
开发者ID:Twizanex,项目名称:thewire_tools,代码行数:40,代码来源:functions.php

示例12: elgg_echo

		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class="namefield">
			<p>
				<?php 
echo elgg_echo('notifications:subscriptions:personal:description');
?>
			</p>
		</td>

<?php 
$fields = '';
$i = 0;
foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
    if ($notification_settings = get_user_notification_settings(elgg_get_logged_in_user_guid())) {
        if ($notification_settings->{$method}) {
            $personalchecked[$method] = 'checked="checked"';
        } else {
            $personalchecked[$method] = '';
        }
    }
    if ($i > 0) {
        $fields .= "<td class='spacercolumn'>&nbsp;</td>";
    }
    $fields .= <<<END
\t\t<td class="{$method}togglefield">
\t\t<a  border="0" id="{$method}personal" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}personal');">
\t\t<input type="checkbox" name="{$method}personal" id="{$method}checkbox" onclick="adjust{$method}('{$method}personal');" value="1" {$personalchecked[$method]} /></a></td>
END;
    $i++;
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:personal.php

示例13: user_support_get_subscriptions_support_ticket_hook

/**
 * Get the subscribers to the creation of a support ticket
 *
 * @param string $hook         the name of the hook
 * @param string $type         the type of the hook
 * @param array  $return_value current return value
 * @param array  $params       supplied params
 *
 * @return array
 */
function user_support_get_subscriptions_support_ticket_hook($hook, $type, $return_value, $params)
{
    if (empty($params) || !is_array($params)) {
        return $return_value;
    }
    $event = elgg_extract("event", $params);
    if (empty($event) || !$event instanceof Elgg_Notifications_Event) {
        return $return_value;
    }
    // ignore access
    $ia = elgg_set_ignore_access(true);
    // get object
    $object = $event->getObject();
    if (empty($object) || !elgg_instanceof($object, "object", UserSupportTicket::SUBTYPE)) {
        elgg_set_ignore_access($ia);
        return $return_value;
    }
    // by default notify nobody
    $return_value = array();
    // get all the admins to notify
    $users = user_support_get_admin_notify_users($object);
    if (empty($users) || !is_array($users)) {
        elgg_set_ignore_access($ia);
        return $return_value;
    }
    // pass all the guids of the admins/staff
    foreach ($users as $user) {
        $notification_settings = get_user_notification_settings($user->getGUID());
        if (empty($notification_settings)) {
            continue;
        }
        $methods = array();
        foreach ($notification_settings as $method => $subbed) {
            if ($subbed) {
                $methods[] = $method;
            }
        }
        if (!empty($methods)) {
            $return_value[$user->getGUID()] = $methods;
        }
    }
    // restore access
    elgg_set_ignore_access($ia);
    return $return_value;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:55,代码来源:hooks.php

示例14: register_error

if (!$group instanceof ElggGroup) {
    register_error(elgg_echo('error:missing_data'));
    forward(REFERER);
}
$user = elgg_get_logged_in_user_entity();
$notifications_enabled = \ColdTrick\GroupTools\Membership::notificationsEnabledForGroup($user, $group);
if ($notifications_enabled) {
    // user has notifications enabled, but wishes to disable this
    $NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethodsAsDeprecatedGlobal();
    foreach ($NOTIFICATION_HANDLERS as $method => $dummy) {
        elgg_remove_subscription($user->getGUID(), $method, $group->getGUID());
    }
    system_message(elgg_echo('group_tools:action:toggle_notifications:disabled', [$group->name]));
} else {
    // user has no notification settings for this group and wishes to enable this
    $user_settings = get_user_notification_settings($user->getGUID());
    $supported_notifications = ['site', 'email'];
    $found = [];
    if (!empty($user_settings)) {
        // check current user settings
        foreach ($user_settings as $method => $value) {
            if (!in_array($method, $supported_notifications)) {
                continue;
            }
            if (!empty($value)) {
                $found[] = $method;
            }
        }
    }
    // user has no base nofitication settings
    if (empty($found)) {
开发者ID:coldtrick,项目名称:group_tools,代码行数:31,代码来源:toggle_notifications.php

示例15: addAnswerOwnerToAnswerSubscribers

 /**
  * Add answer owner to the subscribers for an answer
  *
  * @param string $hook         the name of the hook
  * @param string $type         the type of the hook
  * @param array  $return_value current return value
  * @param array  $params       supplied params
  *
  * @return void|array
  */
 public static function addAnswerOwnerToAnswerSubscribers($hook, $type, $return_value, $params)
 {
     $event = elgg_extract('event', $params);
     if (!$event instanceof \Elgg\Notifications\Event) {
         return;
     }
     $answer = $event->getObject();
     if (!$answer instanceof \ElggAnswer) {
         return;
     }
     $owner = $answer->getOwnerEntity();
     $methods = get_user_notification_settings($owner->getGUID());
     if (empty($methods)) {
         return;
     }
     $filtered_methods = [];
     foreach ($methods as $method => $value) {
         if (empty($value)) {
             continue;
         }
         $filtered_methods[] = $method;
     }
     if (empty($filtered_methods)) {
         return;
     }
     $return_value[$owner->getGUID()] = $filtered_methods;
     return $return_value;
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:38,代码来源:Notifications.php


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