Example #1
0
/**
 * List of methods that assist with handling recording groups.
 * @package Client
 * @subpackage PrebuiltForms.
 */
function group_authorise_form($args, $readAuth)
{
    if (!empty($args['limit_to_group_id']) && $args['limit_to_group_id'] !== (empty($_GET['group_id']) ? '' : $_GET['group_id'])) {
        // page owned by a different group, so throw them out
        hostsite_show_message(lang::get('This page is a private recording group page which you cannot access.'), 'alert');
        hostsite_goto_page('<front>');
    }
    if (!empty($_GET['group_id'])) {
        // loading data into a recording group. Are they a member or is the page public?
        // @todo: consider performance - 2 web services hits required to check permissions.
        if (hostsite_get_user_field('indicia_user_id')) {
            $gu = data_entry_helper::get_population_data(array('table' => 'groups_user', 'extraParams' => $readAuth + array('group_id' => $_GET['group_id'], 'user_id' => hostsite_get_user_field('indicia_user_id')), 'nocache' => true));
        } else {
            $gu = array();
        }
        $gp = data_entry_helper::get_population_data(array('table' => 'group_page', 'extraParams' => $readAuth + array('group_id' => $_GET['group_id'], 'path' => drupal_get_path_alias($_GET['q']))));
        if (count($gp) === 0) {
            hostsite_show_message(lang::get('You are trying to access a page which is not available for this group.'), 'alert');
            hostsite_goto_page('<front>');
        } elseif (count($gu) === 0 && $gp[0]['administrator'] !== NULL) {
            // not a group member, so throw them out
            hostsite_show_message(lang::get('You are trying to access a page for a group you do not belong to.'), 'alert');
            hostsite_goto_page('<front>');
        }
    }
}
 /**
  * Given a maybe response, leave the invite alone, and redirect to the groups home page.
  * @param array $args Form config arguments
  * @param array $invite Invitation record
  * @param array $auth Authorisation tokens
  */
 private static function maybe($args, $invite, $auth)
 {
     hostsite_show_message(lang::get('Just follow the link in your invitation email if and when you are ready to join.'));
     hostsite_goto_page($args['groups_page_path']);
 }
Example #3
0
 private static function abort($msg, $args)
 {
     hostsite_show_message($msg);
     // if there is a main page for groups, and this page was deliberately called (i.e. not just a cron indexing scan) then
     // we can go back.
     if (!empty($_GET['group_id']) && !empty($args['groups_page_path'])) {
         hostsite_goto_page($args['groups_page_path']);
     }
 }
 private static function abort($msg, $args)
 {
     hostsite_show_message(lang::get($msg));
     if (!empty($_GET['group_id']) && !empty($args['groups_page_path'])) {
         hostsite_goto_page($args['groups_page_path']);
     }
 }
 /**
  * Performs the sending of invitation emails.
  * @param array $args Form configuration arguments
  * @param array $auth Authorisation tokens
  * @todo Integrate with notifications for logged in users.
  */
 private static function sendInvites($args, $auth)
 {
     global $user;
     $emails = helper_base::explode_lines($_POST['invitee_emails']);
     // first task is to populate the groups_invitations table
     $base = uniqid();
     $success = true;
     $failedRecipients = array();
     foreach ($emails as $idx => $email) {
         if (!empty($email)) {
             $trimmedEmail = trim($email);
         }
         if (!empty($trimmedEmail)) {
             $values = array('group_invitation:group_id' => $_GET['group_id'], 'group_invitation:email' => $email, 'group_invitation:token' => $base . $idx, 'website_id' => $args['website_id']);
             $s = submission_builder::build_submission($values, array('model' => 'group_invitation'));
             $r = data_entry_helper::forward_post_to('group_invitation', $s, $auth['write_tokens']);
             $pathParam = function_exists('variable_get') && variable_get('clean_url', 0) == '0' ? 'q' : '';
             $rootFolder = data_entry_helper::getRootFolder() . (empty($pathParam) ? '' : "?{$pathParam}=");
             $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
             $acceptUrl = $protocol . $_SERVER['HTTP_HOST'] . $rootFolder . $args['accept_invite_path'] . (empty($pathParam) ? '?' : '&') . 'token=' . $base . $idx;
             $body = $_POST['invite_message'] . "<br/><br/>" . '<a href="' . $acceptUrl . '">' . lang::get('Accept this invitation') . '</a>';
             $message = array('id' => 'iform_group_invite', 'to' => trim($email), 'subject' => lang::get('Invitation to join a recording group'), 'body' => $body, 'headers' => array('MIME-Version' => '1.0', 'Content-type' => 'text/html; charset=iso-8859-1', 'From' => variable_get('site_mail', ''), 'Reply-To' => $user->mail));
             $mimeheaders = array();
             foreach ($message['headers'] as $name => $value) {
                 $mimeheaders[] = $name . ': ' . mime_header_encode($value);
             }
             $thismailsuccess = mail($message['to'], mime_header_encode($message['subject']), str_replace("\r", '', $message['body']), join("\n", $mimeheaders));
             if (!$thismailsuccess) {
                 $failedRecipients[$message['to']] = $acceptUrl;
             }
             $success = $success && $thismailsuccess;
         }
     }
     if ($success) {
         drupal_set_message(lang::get('Invitation emails sent'));
     } else {
         drupal_set_message(lang::get('The emails could not be sent due to a server configuration issue. Please contact the site admin. ' . 'The list below gives the emails and the links you need to send to each invitee which they need to click on in order to join the group.'), 'warning');
         $list = array();
         foreach ($failedRecipients as $email => $link) {
             $list[] = lang::get("Send link {1} to {2}.", $link, $email);
         }
         drupal_set_message(implode('<br/>', $list), 'warning');
     }
     hostsite_goto_page($args['redirect_on_success']);
 }