function form($object) { pathos_lang_loadDictionary('modules', 'inboxmodule'); pathos_lang_loadDictionary('standard', 'core'); if (!defined('SYS_FORMS')) { require_once BASE . 'subsystems/forms.php'; } pathos_forms_initialize(); $form = new form(); $users = array(); $groups = array(); global $db, $user; if (!defined('SYS_USERS')) { require_once BASE . 'subsystems/users.php'; } if (pathos_permissions_check('contact_all', pathos_core_makeLocation('inboxmodule'))) { foreach (pathos_users_getAllUsers() as $u) { $users[$u->id] = $u->firstname . ' ' . $u->lastname . ' (' . $u->username . ')'; } } else { foreach (pathos_users_getGroupsForUser($user, 1, 0) as $g) { foreach (pathos_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 . ' ' . TR_INBOXMODULE_PERSONALLIST; } if (pathos_permissions_check('contact_all', pathos_core_makeLocation('inboxmodule'))) { foreach (pathos_users_getAllGroups(1, 0) as $g) { $groups['group_' . $g->id] = $g->name . ' ' . TR_INBOXMODULE_SYSGROUP; } } else { foreach (pathos_users_getGroupsForUser($user, 1, 0) as $g) { $groups['group_' . $g->id] = $g->name . ' ' . TR_INBOXMODULE_SYSGROUP; } } uasort($groups, 'strnatcmp'); $recipient_caption = TR_INBOXMODULE_RECIPIENT; $group_recipient_caption = TR_INBOXMODULE_GROUPRECIPIENT; $btn = new buttongroupcontrol(TR_INBOXMODULE_SEND, '', TR_CORE_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 = pathos_users_getUserById($object->recipient); $form->register(null, '', new htmlcontrol(sprintf(TR_INBOXMODULE_REPLYTO, $u->firstname . ' ' . $u->lastname . ' (' . $u->username . ')'))); $form->meta('replyto', $object->recipient); $object->recipient = array(); unset($users[$u->id]); $recipient_caption = TR_INBOXMODULE_COPYTO; $group_recipient_caption = TR_INBOXMODULE_GROUPCOPYTO; } 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">' . TR_INBOXMODULE_NOCONTACTSWARNING . '</div>')); } $form->register('subject', TR_INBOXMODULE_SUBJECT, new textcontrol($object->subject)); $form->register('body', TR_INBOXMODULE_MESSAGE, new htmleditorcontrol($object->body)); $form->register('submit', '', $btn); return $form; }
function form($object) { pathos_lang_loadDictionary('modules', 'inboxmodule'); pathos_lang_loadDictionary('standard', 'core'); if (!defined('SYS_FORMS')) { require_once BASE . 'subsystems/forms.php'; } pathos_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', TR_INBOXMODULE_GROUPNAME, new textcontrol($object->name)); $form->register('description', TR_INBOXMODULE_DESCRIPTION, new texteditorcontrol($object->description)); $users = array(); if (!defined('SYS_USERS')) { require_once BASE . 'subsystems/users.php'; } global $user; if (pathos_permissions_check('contact_all', pathos_core_makeLocation('inboxmodule'))) { foreach (pathos_users_getAllUsers() as $u) { $users[$u->id] = $u; } } else { foreach (pathos_users_getGroupsForUser($user, 1, 0) as $g) { foreach (pathos_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', TR_INBOXMODULE_MEMBERS, new listbuildercontrol($members, $users)); $form->register('submit', '', new buttongroupcontrol(TR_CORE_SAVE, '', TR_CORE_CANCEL)); } else { $submit = new buttongroupcontrol(TR_CORE_SAVE, '', TR_CORE_CANCEL); $submit->disabled = 1; $form->register(null, '', new htmlcontrol(TR_INBOXMODULE_NOMEMBERS)); $form->register('submit', '', $submit); } return $form; }