$db_data->user_id = $user->id;
         } else {
             $db_data->user_id = 0;
         }
         $db_data->timestamp = time();
     }
     $db->insertObject($db_data, 'formbuilder_' . $f->table_name);
 }
 //Email stuff here...
 //Don't send email if this is an edit.
 if ($f->is_email == 1 && !isset($_POST['data_id'])) {
     //Building Email List...
     $emaillist = array();
     foreach ($db->selectObjects("formbuilder_address", "form_id=" . $f->id) as $address) {
         if ($address->group_id != 0) {
             foreach (exponent_users_getUsersInGroup(exponent_user_getGroupById($address->group_id)) as $locUser) {
                 if ($locUser->email != '') {
                     $emaillist[] = $locUser->email;
                 }
             }
         } else {
             if ($address->user_id != 0) {
                 $locUser = exponent_users_getUserById($address->user_id);
                 if ($locUser->email != '') {
                     $emaillist[] = $locUser->email;
                 }
             } else {
                 if ($address->email != '') {
                     $emaillist[] = $address->email;
                 }
             }
Esempio n. 2
0
         $banned[$b->user_id] = $b->user_id;
     } else {
         $banned[$b->user_id] = $b->owner;
     }
 }
 if (isset($_POST['replyto'])) {
     $recipients[] = $_POST['replyto'];
 }
 $gr = array();
 if (isset($_POST['group_recipients'])) {
     $gr = listbuildercontrol::parseData($_POST, 'group_recipients');
     foreach ($gr as $ginfo) {
         $toks = explode('_', $ginfo);
         $gid = $toks[1];
         if ($toks[0] == 'group') {
             foreach (exponent_users_getUsersInGroup(exponent_users_getGroupById($gid)) as $u) {
                 if (!in_array($u->id, $banned)) {
                     $recipients[] = $u->id;
                 }
             }
         } else {
             $list = $db->selectObject('inbox_contactlist', 'id=' . $gid);
             if ($list->owner == $user->id) {
                 foreach ($db->selectObjects('inbox_contactlist_member', 'list_id=' . $list->id) as $m) {
                     if (!in_array($u->id, $banned)) {
                         $recipients[] = $m->user_id;
                     }
                 }
             }
         }
     }
 function form($object)
 {
     $i18n = exponent_lang_loadFile('datatypes/inbox_contactlist.php');
     if (!defined('SYS_FORMS')) {
         include_once BASE . 'subsystems/forms.php';
     }
     exponent_forms_initialize();
     $form = new form();
     if (!isset($object->id)) {
         $object->name = '';
         $object->description = '';
         $object->_members = array();
     } else {
         $form->meta('id', $object->id);
     }
     $form->register('name', $i18n['name'], new textcontrol($object->name));
     $form->register('description', $i18n['description'], new texteditorcontrol($object->description));
     $users = array();
     if (!defined('SYS_USERS')) {
         require_once BASE . 'subsystems/users.php';
     }
     global $user;
     if (exponent_permissions_check('contact_all', exponent_core_makeLocation('InboxModule'))) {
         foreach (exponent_users_getAllUsers() as $u) {
             $users[$u->id] = $u;
         }
     } else {
         foreach (exponent_users_getGroupsForUser($user, 1, 0) as $g) {
             foreach (exponent_users_getUsersInGroup($g) as $u) {
                 $users[$u->id] = $u;
             }
         }
     }
     foreach (array_keys($users) as $i) {
         $users[$i] = $users[$i]->firstname . ' ' . $users[$i]->lastname . ' (' . $users[$i]->username . ')';
     }
     global $db;
     // Process other uses who the current user has blocked, and remove them from the list
     // Process other users who have blocked the current user, and remove them from the list.
     foreach ($db->selectObjects('inbox_contactbanned', 'owner=' . $user->id . ' OR user_id=' . $user->id) as $blocked) {
         if ($blocked->user_id == $user->id) {
             // Blocked by someone else.  Remove the owner (user who blocked us)
             unset($users[$blocked->owner]);
         } else {
             if ($blocked->owner == $user->id) {
                 // We blocked the user, remove the blocked user_id
                 unset($users[$blocked->user_id]);
             }
         }
     }
     $members = array();
     for ($i = 0; $i < count($object->_members); $i++) {
         $tmp = $object->_members[$i];
         $members[$tmp] = $users[$tmp];
         unset($users[$tmp]);
     }
     if (count($members) || count($users)) {
         $form->register('members', $i18n['members'], new listbuildercontrol($members, $users));
         $form->register('submit', '', new buttongroupcontrol($i18n['save'], '', $i18n['cancel']));
     } else {
         $submit = new buttongroupcontrol($i18n['save'], '', $i18n['cancel']);
         $submit->disabled = 1;
         $form->register(null, '', new htmlcontrol($i18n['nomembers']));
         $form->register('submit', '', $submit);
     }
     return $form;
 }
 function form($object)
 {
     $i18n = exponent_lang_loadFile('datatypes/privatemessage.php');
     if (!defined('SYS_FORMS')) {
         require_once BASE . 'subsystems/forms.php';
     }
     exponent_forms_initialize();
     $form = new form();
     $users = array();
     $groups = array();
     global $db, $user;
     if (!defined('SYS_USERS')) {
         require_once BASE . 'subsystems/users.php';
     }
     if (exponent_permissions_check('contact_all', exponent_core_makeLocation('InboxModule'))) {
         foreach (exponent_users_getAllUsers() as $u) {
             $users[$u->id] = $u->firstname . ' ' . $u->lastname . ' (' . $u->username . ')';
         }
     } else {
         foreach (exponent_users_getGroupsForUser($user, 1, 0) as $g) {
             foreach (exponent_users_getUsersInGroup($g) as $u) {
                 $users[$u->id] = $u->firstname . ' ' . $u->lastname . ' (' . $u->username . ')';
             }
         }
     }
     // Process other uses who the current user has blocked, and remove them from the list
     // Process other users who have blocked the current user, and remove them from the list.
     foreach ($db->selectObjects('inbox_contactbanned', 'owner=' . $user->id . ' OR user_id=' . $user->id) as $blocked) {
         if ($blocked->user_id == $user->id) {
             // Blocked by someone else.  Remove the owner (user who blocked us)
             unset($users[$blocked->owner]);
         } else {
             if ($blocked->owner == $user->id) {
                 // We blocked the user, remove the blocked user_id
                 unset($users[$blocked->user_id]);
             }
         }
     }
     uasort($users, 'strnatcmp');
     $groups = array();
     foreach ($db->selectObjects('inbox_contactlist', 'owner=' . $user->id) as $g) {
         $groups['list_' . $g->id] = $g->name . ' ' . $i18n['personal_list'];
     }
     if (exponent_permissions_check('contact_all', exponent_core_makeLocation('InboxModule'))) {
         foreach (exponent_users_getAllGroups(1, 0) as $g) {
             $groups['group_' . $g->id] = $g->name . ' ' . $i18n['system_group'];
         }
     } else {
         foreach (exponent_users_getGroupsForUser($user, 1, 0) as $g) {
             $groups['group_' . $g->id] = $g->name . ' ' . $i18n['system_group'];
         }
     }
     uasort($groups, 'strnatcmp');
     $recipient_caption = $i18n['recipient'];
     $group_recipient_caption = $i18n['group_recipient'];
     $btn = new buttongroupcontrol($i18n['save'], '', $i18n['cancel']);
     $object->group_recipient = array();
     if ($object == null || !isset($object->recipient)) {
         $object->subject = '';
         $object->body = '';
         $object->recipient = array();
         if (!count($users) && !count($groups)) {
             $btn->disabled = true;
         }
     } else {
         if (!defined('SYS_USERS')) {
             require_once BASE . 'subsystems/users.php';
         }
         $u = exponent_users_getUserById($object->recipient);
         $form->register(null, '', new htmlcontrol(sprintf($i18n['replyto'], $u->firstname . ' ' . $u->lastname . ' (' . $u->username . ')')));
         $form->meta('replyto', $object->recipient);
         $object->recipient = array();
         unset($users[$u->id]);
         $recipient_caption = $i18n['copyto'];
         $group_recipient_caption = $i18n['group_copyto'];
     }
     if (count($users)) {
         $form->register('recipients', $recipient_caption, new listbuildercontrol($object->recipient, $users));
     }
     if (count($groups)) {
         $form->register('group_recipients', $group_recipient_caption, new listbuildercontrol($object->group_recipient, $groups));
     }
     if (!count($groups) && !count($users)) {
         $form->register(null, '', new htmlcontrol('<div class="error">' . $i18n['nocontacts'] . '</div>'));
     }
     $form->register('subject', $i18n['subject'], new textcontrol($object->subject));
     $form->register('body', $i18n['body'], new htmleditorcontrol($object->body));
     $form->register('submit', '', $btn);
     return $form;
 }