Beispiel #1
0
 /**
  * Get all selected recipients for the field
  * @return array of usersIds which are recipients of the notification
  * @access public
  */
 private function _getRecipients($objectID)
 {
     $params = $this->getParamsValues();
     $recipients = array();
     if (isset($params['usersGroupsField']) && $params['usersGroupsField']) {
         //instanciate related item
         $item = CMS_poly_object_catalog::getObjectByID($objectID, false, true);
         if (!is_object($item) || $item->hasError()) {
             return $recipients;
         }
         //does selected field represent users or groups ?
         $field = new CMS_poly_object_field($params['usersGroupsField']);
         $isGroup = $field->getParameter('isGroup');
         //get item field value
         $ids = $item->objectValues($params['usersGroupsField'])->getValue('ids');
         if (!$ids) {
             return array();
         }
         //get users ids
         if ($isGroup) {
             foreach ($ids as $groupId) {
                 $usersIds = CMS_profile_usersGroupsCatalog::getGroupUsers($groupId, false);
                 foreach ($usersIds as $userId) {
                     $recipients[$userId] = $userId;
                 }
             }
         } else {
             $recipients = $ids;
         }
     } else {
         //get all active users ids
         $allUsers = CMS_profile_usersCatalog::getAll(true, false, false);
         //check if user is in included or excluded parameters lists
         $selectedGroups = $params['disableGroups'] ? explode(';', $params['disableGroups']) : array();
         $selectedUsers = $params['disableUsers'] ? explode(';', $params['disableUsers']) : array();
         //check all users to see if it match selection parameters
         foreach ($allUsers as $userId) {
             if ($params['includeExclude']) {
                 //user must be in selected groups or users to get email
                 $userSelected = false;
                 if (is_array($selectedGroups) && $selectedGroups) {
                     foreach ($selectedGroups as $groupId) {
                         if (CMS_profile_usersGroupsCatalog::userBelongsToGroup($userId, $groupId)) {
                             $userSelected = true;
                         }
                     }
                 }
                 if (is_array($selectedUsers) && $selectedUsers && in_array($userId, $selectedUsers)) {
                     $userSelected = true;
                 }
             } else {
                 //user must NOT be in selected groups or users to get email
                 $userSelected = true;
                 if (is_array($selectedGroups) && $selectedGroups) {
                     foreach ($selectedGroups as $groupId) {
                         if (CMS_profile_usersGroupsCatalog::userBelongsToGroup($userId, $groupId)) {
                             $userSelected = false;
                         }
                     }
                 }
                 if (is_array($selectedUsers) && $selectedUsers && in_array($userId, $selectedUsers)) {
                     $userSelected = false;
                 }
             }
             if ($userSelected) {
                 $recipients[] = $userId;
             }
         }
     }
     return $recipients;
 }
Beispiel #2
0
 $items = array();
 switch ($type) {
     case 'rows':
         $rows = CMS_rowsCatalog::getAll(true, '', array(), array_keys($results));
         foreach ($rows as $row) {
             $items[] = $row->getJSonDescription($cms_user, $cms_language, false);
         }
         break;
     case 'templates':
         $tpls = CMS_pageTemplatesCatalog::getAll(true, '', array(), '', array_keys($results));
         foreach ($tpls as $tpl) {
             $items[] = $tpl->getJSonDescription($cms_user, $cms_language, false);
         }
         break;
     case 'users':
         $users = CMS_profile_usersCatalog::getAll(false, false, true, array('id_pru' => array_keys($results)));
         foreach ($users as $user) {
             $items[] = $user->getJSonDescription($cms_user, $cms_language, false);
         }
         break;
     case 'groups':
         $groups = CMS_profile_usersGroupsCatalog::search('', '', false, array_keys($results));
         foreach ($groups as $group) {
             $items[] = $group->getJSonDescription($cms_user, $cms_language, false);
         }
         break;
     default:
         $module = CMS_modulesCatalog::getByCodename($type);
         $items = $module->getSearchResults(array_keys($results), $cms_user);
         break;
 }
 /**
  * Search users by xml definition. Return XML
  * 
  * @access public
  * @param string $searchConditions XML definition to search with ('id','login','firstName','lastName','contactData','profile','language')
  * @return string XML definition of users IDs
  */
 static function soapSearch($searchConditions = '')
 {
     $xml = '';
     $attrs = array();
     if ($searchConditions) {
         $domdocument = new CMS_DOMDocument();
         try {
             $domdocument->loadXML($searchConditions, 0, false);
         } catch (DOMException $e) {
             CMS_profile_usersCatalog::raiseError('Parse error for xml : ' . $e->getMessage() . " :\n" . $xml);
             return $xml;
         }
         // Conditions tag must be the root tag
         $conditionsTags = $domdocument->getElementsByTagName('conditions');
         if (count($conditionsTags) == 1) {
             $conditionTags = $domdocument->getElementsByTagName('condition');
             foreach ($conditionTags as $conditionTag) {
                 $type = $conditionTag->getAttribute('type');
                 $value = $conditionTag->nodeValue;
                 $attrs[$type . '_pru'] = $value;
             }
         }
     }
     $items = CMS_profile_usersCatalog::getAll(true, false, false, $attrs);
     if ($items) {
         $xml .= '<results count="' . count($items) . '">' . "\n";
         foreach ($items as $itemID) {
             $xml .= '<result>' . $itemID . '</result>' . "\n";
         }
         $xml .= '</results>';
     }
     return $xml;
 }