Exemplo n.º 1
0
Arquivo: Model.php Projeto: n8b/VMN
 /**
  * Get message types the user can send
  *
  * @param ElggUser $user User
  * @return array An array of message types
  */
 public function getOutgoingMessageTypes($user = null)
 {
     $return = array();
     if (!elgg_instanceof($user)) {
         $user = elgg_get_logged_in_user_entity();
         if (!$user) {
             return $return;
         }
     }
     if (isset($this->outgoingMessageTypes[$user->guid])) {
         return $this->outgoingMessageTypes[$user->guid];
     }
     $message_types = $this->config->getMessageTypes();
     $user_types = $this->config->getUserTypes();
     foreach ($message_types as $type => $options) {
         $policies = $options['policy'];
         if (!$policies) {
             if ($type != Config::TYPE_NOTIFICATION) {
                 $return[] = $type;
             }
             continue;
         }
         $getter_options = $this->getUserQueryOptions($type, $user);
         $getter_options['count'] = true;
         $valid_recipients_count = $this->getEntities($getter_options);
         foreach ($policies as $policy) {
             $sender_type = $policy['sender'];
             if ($sender_type == 'all' && $valid_recipients_count) {
                 $return[] = $type;
                 break;
             }
             $validator = $user_types[$sender_type]['validator'];
             if ($valid_recipients_count && is_callable($validator) && call_user_func($validator, $user, $sender_type)) {
                 $return[] = $type;
                 break;
             }
         }
     }
     return $return;
 }
Exemplo n.º 2
0
 /**
  * Add third party user types/roles to the config array
  *
  * @param string $hook   "config:user_types"
  * @param string $type   "framework:inbox"
  * @param array  $return User types config array
  * @param array  $params Hook params
  * @return array
  * @deprecated 6.0
  */
 public function filterUserTypes($hook, $type, $return, $params)
 {
     return Config::filterUserTypes($hook, $type, $return, $params);
 }