function generate_group_links()
 {
     global $login_uid;
     // Getting all the information about that group
     $group_data = array();
     $group_info = array();
     $group_info['is_member'] = FALSE;
     $group_join_string = 'Join This Group';
     $group_data = ContentCollection::load_collection($this->gid, NULL);
     // Calculating user's type
     if (!empty($login_uid)) {
         $usr_type = Group::get_user_type($login_uid, $this->gid);
         $group_info['is_member'] = $usr_type == MEMBER ? TRUE : FALSE;
         if ($usr_type == OWNER) {
             $group_info['is_admin'] = TRUE;
             $group_info['is_member'] = TRUE;
         }
     }
     if ($group_data->reg_type == REG_MODERATED) {
         $group_join_string = "Request to join this group";
     }
     $group_info['title'] = $group_data->title;
     $group_info['description'] = $group_data->description;
     $group_info['picture'] = $group_data->picture;
     $group_info['collection_id'] = $group_data->collection_id;
     $group_info['join_str'] = $group_join_string;
     unset($group_data);
     return $group_info;
 }
function setup_module($column, $module, $obj)
{
    $group_var = new Group();
    $group_var->load($_REQUEST['gid']);
    $obj->title = sprintf(__('%s Events'), PA::$group_noun);
    $obj->assoc_type = 'group';
    $obj->assoc_id = $_REQUEST['gid'];
    $obj->assoc_title = $group_var->title;
    $is_member = Group::get_user_type((int) $_SESSION['user']['id'], (int) $_REQUEST['gid']);
    if ($is_member == NOT_A_MEMBER) {
        $obj->may_edit = false;
    } else {
        $obj->may_edit = true;
    }
}
 public function generate_group_links()
 {
     $user_type = FALSE;
     if (!empty(PA::$login_uid)) {
         $user_type = Group::get_user_type(PA::$login_uid, $this->group_details->collection_id);
         $this->is_member = $user_type == MEMBER ? TRUE : FALSE;
         if ($user_type == OWNER) {
             $this->is_member = TRUE;
             $this->is_admin = TRUE;
         }
     }
     if (!$this->is_member) {
         if ((!empty($this->group_details) ? $this->group_details->reg_type : NULL) && $this->group_details->reg_type == REG_MODERATED) {
             $this->join_this_group_string = __('Request to join this group');
         } else {
             $this->join_this_group_string = __('Join This Group');
         }
     }
 }
function setup_module($column, $module, $obj)
{
    $group_var = new Group();
    $group_var->load($_REQUEST['gid']);
    switch ($module) {
        case 'EventCalendarModule':
            $obj->title = 'Group Events';
            $obj->assoc_type = 'group';
            $obj->assoc_id = $_REQUEST['gid'];
            $obj->assoc_title = $group_var->title;
            $is_member = Group::get_user_type((int) $_SESSION['user']['id'], (int) $_REQUEST['gid']);
            if ($is_member == NOT_A_MEMBER) {
                $obj->may_edit = false;
            } else {
                $obj->may_edit = true;
            }
            break;
    }
    $obj->mode = PUB;
}
 public function initializeModule($request_method, $request_data)
 {
     if (empty($request_data['gid'])) {
         return 'skip';
     }
     $this->gid = $request_data['gid'];
     // NOTE:
     // The code bellow is temporrary solution and should be removed
     // when refactoring of all other pages that using this module
     // will be done!
     // ----------------------------------------------------------------------
     if (empty($this->shared_data['group_info']) && !empty($request_data['gid'])) {
         $group = ContentCollection::load_collection((int) $this->gid);
         $member_type = Group::get_user_type(PA::$login_uid, (int) $this->gid);
         $this->shared_data['member_type'] = $member_type;
         $this->shared_data['group_info'] = $group;
         $this->shared_data['members'] = Group::get_member_count((int) $this->gid);
         $owner = new User();
         $owner->load((int) Group::get_owner_id((int) $this->gid));
         $this->shared_data['author_picture'] = $owner->picture;
         $this->shared_data['author_name'] = $owner->login_name;
         $this->shared_data['access_type'] = $this->shared_data['group_info']->reg_type == $this->shared_data['group_info']->REG_OPEN ? ' Open' : ' Moderated';
     }
     // ----------------------------------------------------------------------
     switch ($this->page_id) {
         case PAGE_GROUP_THEME:
         case PAGE_GROUP_MODERATION:
         case PAGE_GROUP:
         case PAGE_SHOWCONTENT:
         case PAGE_PERMALINK:
             $this->group_details = $this->shared_data['group_info'];
             $this->group_details->author_picture = $this->shared_data['author_picture'];
             $this->group_details->author_name = $this->shared_data['author_name'];
             $this->group_details->members = $this->shared_data['members'];
             $this->access_type = $this->shared_data['access_type'];
             break;
         default:
             $this->group_details = $this->generate_group_links();
     }
 }
 private function can_manage_forum($params, $type)
 {
     $board_type = $params['board']->get_type();
     if ($board_type == 'group' && !empty($params['gid'])) {
         // it is a group forum
         $user_type = Group::get_user_type($params['user_id'], $params['gid']);
         if ($user_type == MODERATOR || $user_type == OWNER) {
             return true;
         }
         $group_permiss = @$this->user_permissions['groups'][$params['gid']];
         if (!empty($group_permiss)) {
             if (in_array('manage_content', $group_permiss)) {
                 return true;
             }
         }
     }
     if ($board_type == 'network') {
         $is_net_admin = Network::is_admin($params['board']->get_network_id(), $params['user_id']);
         if ($is_net_admin) {
             return true;
         }
         $net_permiss = @$this->user_permissions['network'];
         if (!empty($net_permiss)) {
             if (in_array('manage_content', $net_permiss)) {
                 return true;
             }
         }
     }
     if ($board_type == 'user') {
         if ($params['user_id'] == $params['board']->get_owner_id()) {
             return true;
         }
     }
     return false;
 }
function group_user_authentication($group_id)
{
    global $login_uid;
    $access_array = array();
    $access_array['style'] = "";
    if (!empty($login_uid)) {
        $user_type = Group::get_user_type($login_uid, $group_id);
        $group_var = new Group();
        $group_var->load($group_id);
        switch (trim($user_type)) {
            case NOT_A_MEMBER:
                if ($group_var->reg_type == REG_MODERATED) {
                    $access_array['hyper_link'] = PA::$url . PA_ROUTE_GROUP . "/action=join&gid={$group_id}";
                    $access_array['caption'] = 'Request to join';
                    $access_array['style'] = "style=\"width:160px;\"";
                } else {
                    $access_array['hyper_link'] = PA::$url . PA_ROUTE_GROUP . "/action=join&gid={$group_id}";
                    $access_array['caption'] = 'Join';
                }
                break;
            case MEMBER:
                $access_array['hyper_link'] = PA::$url . PA_ROUTE_GROUP . "/action=leave&gid={$group_id}";
                $access_array['caption'] = 'Unjoin';
                break;
            case OWNER:
                $access_array['hyper_link'] = PA::$url . "/cnaddgroup.php?gid={$group_id}";
                $access_array['caption'] = 'Edit';
                break;
            case MODERATOR:
                $access_array['hyper_link'] = PA::$url . PA_ROUTE_GROUP_MODERATION . "/view=content&gid={$group_id}";
                $access_array['caption'] = 'Moderate';
                $access_array['style'] = "style=\"width:80px;\"";
                break;
        }
    } else {
        $access_array['hyper_link'] = PA::$url . PA_ROUTE_GROUP . "/action=join&gid={$group_id}";
        $access_array['caption'] = 'Join';
    }
    return $access_array;
}
 private function handleGET_leave($request_data)
 {
     global $error_msg;
     if (PA::$login_uid && !empty($this->shared_data['group_info'])) {
         $group = $this->shared_data['group_info'];
         $user = PA::$login_user;
         $user_type = Group::get_user_type(PA::$login_uid, (int) $request_data['gid']);
         if (Group::is_admin((int) $request_data['gid'], (int) PA::$login_uid) && $user_type == OWNER) {
             // admin can leave a group but owner can't
             $error_msg = __("You can't leave your own group.");
         } else {
             if (Group::member_exists((int) $request_data['gid'], (int) PA::$login_uid)) {
                 try {
                     $x = $group->leave((int) PA::$login_uid);
                 } catch (PAException $e) {
                     $error_msg = "Operation failed (" . $e->message . "). Please try again";
                 }
             } else {
                 $error_msg = sprintf(__("You are not member of \"%s\"."), stripslashes($group->title));
             }
         }
         if (@$x) {
             $error_msg = sprintf(__("You have left \"%s\" successfully."), stripslashes($group->title));
             // also delete Family relation
             require_once 'api/Entity/TypedGroupEntityRelation.php';
             TypedGroupEntityRelation::delete_relation(PA::$login_uid, $request_data['gid'], PA::$network_info->network_id);
         }
     }
 }
 function is_author_group_member($author_id, $gid)
 {
     $author_perm = Group::get_user_type($author_id, (int) $gid);
     return $author_perm == NOT_A_MEMBER ? false : true;
 }
//TODO : Remove this when new UI is completely implemented.
include_once "web/includes/page.php";
require_once 'api/Category/Category.php';
require_once 'web/includes/classes/file_uploader.php';
require_once 'api/Message/Message.php';
require_once 'web/includes/functions/auto_email_notify.php';
require_once 'web/includes/functions/mailing.php';
default_exception();
$parameter = js_includes("all");
$header = 'header.tpl';
//default network header while creating groups. While group editing header_group.tpl will be used.
$edit = FALSE;
$title = __("Create Group");
if (!empty($_REQUEST['gid'])) {
    $title = __("Edit Group");
    $user_type = Group::get_user_type($_SESSION['user']['id'], $_REQUEST['gid']);
    $header = 'header_group.tpl';
    $edit = TRUE;
    $groups = new Group();
    $groups->load($_REQUEST['gid']);
    $group_type = $groups->group_type;
}
function setup_module($column, $module, $obj)
{
    global $login_uid, $paging, $page_uid, $super_groups_available, $user_type, $group_type;
    switch ($module) {
        case 'AddGroupModule':
            if (!empty($_REQUEST['gid'])) {
                $obj->id = $_REQUEST['gid'];
            }
            break;
Example #11
0
}
$users = $final_array;
//p($users);
if (Group::member_exists((int) $group->collection_id, (int) $login_uid)) {
    $is_member = TRUE;
    $header->is_member = TRUE;
}
$is_admin_member = FALSE;
// set the default value to
if (Group::is_admin((int) $_REQUEST['gid'], (int) $login_uid)) {
    $is_admin_member = TRUE;
    $header->is_admin_member = TRUE;
}
$group_details['is_member'] = $is_member;
$show_content = TRUE;
$member_type = Group::get_user_type($login_uid, (int) $gid);
function setup_module($column, $module, $obj)
{
    global $group_details, $users, $content_type, $request_info, $title, $body, $is_member, $paging, $msg, $access, $group, $upload_array, $post_type_message, $post_type, $group_top_mesg, $join_group_string, $member_type, $login_uid;
    $obj->group_details = $group_details;
    $obj->join_this_group_string = $join_group_string;
    if ($group->reg_type == REG_INVITE && $member_type == NOT_A_MEMBER) {
        $group_top_mesg = 9005;
        return "skip";
    }
    switch ($module) {
        case 'MembersFacewallModule':
            $obj->links = $users;
            $obj->gid = $_REQUEST['gid'];
            break;
        case 'EventCalendarSidebarModule':
Example #12
0
$use_theme = 'Beta';
//TODO : Remove this when new UI is completely implemented.
//including necessary files
include "includes/page.php";
include_once "{$path_prefix}/ext/Group/Group.php";
require_once "{$path_prefix}/api/MessageBoard/MessageBoard.php";
/*including Js files */
$parameter .= js_includes('common.js');
// for query count
global $query_count_on_page, $login_uid;
$query_count_on_page = 0;
$mid = $_REQUEST['mid'];
$request_info = load_info();
$parent_id = $request_info['parent_id'];
$parent_type = $request_info['parent_type'];
$member_type = Group::get_user_type($login_uid, $parent_id);
$gid = (int) $_GET['gid'];
$group_data = ContentCollection::load_collection((int) $gid, $login_uid);
$cat_obj = new MessageBoard();
$edit_data = $cat_obj->get_by_id($mid);
$params['action'] = 'edit_forum';
$params['group_owner'] = $group_data->author_id;
$params['forum_owner'] = $edit_data['user_id'];
if (user_can($params)) {
    $is_edit = TRUE;
} else {
    $is_edit = FALSE;
    $msg = 'You are not authorized to edit forum';
}
function setup_module($column, $module, $obj)
{
  // When we doesn't found type 
    $type = 'Images';
  } else {
    $type = $_GET['type'];
  }
  $module_name = $type.'MediaGalleryModule';
  $setting_data = array('middle' => array($module_name));

  
/* This function is a Callback function which initialize the value for the BLOCK MODULES */
if (!empty($_GET['gid'])) {
  $gid = (int)$_GET['gid'];
  $group_data = ContentCollection::load_collection($gid, $_SESSION['user']['id']);
  $group_name = $group_data->title;
  if ($_SESSION['user']['id']) {
    $is_member = Group::get_user_type($_SESSION['user']['id'], (int)$gid);
  }  
}
function setup_module($column, $module, $obj) {
/* in this module we have to set user_id , group_id, as well as netwrok_id */  
  global $type, $group_data, $is_member,  $msg, $show_view;
  $obj->type = $type;
  $obj->show_view = $show_view;
  switch ($module) {
  case 'ImagesMediaGalleryModule': 
  case 'AudiosMediaGalleryModule': 
  case 'VideosMediaGalleryModule':
      if ($group_data->reg_type == REG_INVITE && $is_member == NOT_A_MEMBER) {        
          $msg = MessagesHandler::get_message(9005);
          return "skip";
      }
 function initializeModule($request_method, $request_data)
 {
     if (empty($this->shared_data['group_info'])) {
         return 'skip';
     }
     $this->gid = $this->shared_data['group_info']->collection_id;
     if (empty(PA::$config->useTypedGroups)) {
         return 'skip';
     }
     $this->shared_data['member_type'] = $member_type = Group::get_user_type(PA::$login_uid, (int) $this->gid);
     $this->is_member = $member_type == MEMBER ? TRUE : FALSE;
     if ($member_type == OWNER) {
         $this->is_member = TRUE;
         $this->is_admin = TRUE;
     }
     $acl = new Access();
     // check for moderation of group permissions
     $gp_access = $acl->acl_check('action', 'edit', 'users', $member_type, 'group', 'all');
     if (PA::$login_uid == SUPER_USER_ID || $member_type == 'moderator') {
         $gp_access = 1;
     }
     $this->is_admin = $this->shared_data['moderation_permissions'] = $gp_access;
     $this->group_details = $this->shared_data['group_info'];
     if (!$this->is_member) {
         if ((!empty($this->group_details) ? $this->group_details->reg_type : NULL) && $this->group_details->reg_type == REG_MODERATED) {
             $this->join_this_group_string = __('Request to follow this organization as');
         } else {
             $this->join_this_group_string = __('Follow This Org As');
         }
     } else {
         // get the relationType for this user
         list($relType, $relLabel) = TypedGroupEntityRelation::get_relation_to_group(PA::$login_uid, (int) $this->gid);
         if (empty($relType)) {
             $relType = 'member';
             $relLabel = __('Member');
         }
         $this->relationType = $relType;
         $this->relationTypeString = sprintf(__("You are a %s"), $relLabel);
     }
     $this->availTypes = TypedGroupEntity::get_avail_types();
     $this->selectTypes = array();
     foreach ($this->availTypes as $k => $l) {
         $this->selectTypes[] = array('label' => $l, 'value' => $k);
     }
     // Do we already have a bound Entity?
     // we need to load the generic parent class, as we do noot yet know the type
     if ($typedEntity = TypedGroupEntity::load_for_group($this->gid)) {
         $this->entity = $typedEntity;
         // get info about what profile fields this has
         $type = $this->entity->entity_type;
         $classname = ucfirst($type) . "TypedGroupEntity";
         @(include_once "api/Entity/{$classname}.php");
         if (class_exists($classname)) {
             $instance = new $classname();
         } else {
             // just get default
             $instance = new TypedGroupEntity();
         }
         $this->profilefields = $instance->get_profile_fields();
         $this->availRelations = $instance->get_avail_relations();
         $this->selectRelations = array();
         foreach ($this->availRelations as $k => $l) {
             $this->selectRelations[] = array('label' => $l, 'value' => $k);
         }
         // does the admin want to edit it?
         if ($this->shared_data['moderation_permissions'] && !empty($request_data['edit_enityprofile'])) {
             //$this->title = sprintf(__("Edit %s profile"), $typedEntity->attributes['name']['value']);
             $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . "/edit_typedgroup_profile.tpl.php";
             // load into form
             $this->dynFields = new DynamicFormFields($this->entity->attributes);
         } else {
             // display only
             //$this->title = sprintf(__("%s profile"), $typedEntity->attributes['name']['value']);
             $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . "/typedgroup_profile.tpl.php";
         }
         $this->title = '';
     } else {
         return 'skip';
         /*
         // moderators only
         if(!$this->shared_data['moderation_permissions']) {
         	return 'skip';
         }
         */
     }
     switch ($this->column) {
         case 'middle':
             break;
         case 'left':
         case 'right':
         default:
             break;
     }
 }
Example #15
0
 $inv->inv_message = !empty($invitation_message) ? $invitation_message : NULL;
 try {
     $inv->send();
 } catch (PAException $e) {
     $save_msg = "{$e->message}";
     $save_error = TRUE;
 }
 if ($save_error == TRUE) {
     $msg[] = "Sorry: you are unable to invite a friend. <br /> Reason: " . $sav_msg;
 } else {
     // invitation has been sent, now send email
     $user = new User();
     $user->load((int) $login_uid);
     $invitee_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
     $group_icon_image = uihelper_resize_mk_img('files/' . $group->picture, 219, 35, 'files/' . DEFAULT_NETWORK_ICON, 'alt="' . $group->title . '"');
     $user_type = Group::get_user_type($login_uid, $gid);
     if ($user_type == OWNER) {
         $mail_type = 'invite_group';
     } else {
         if ($user_type == MEMBER) {
             $mail_type = 'invite_group_by_member';
         }
     }
     $group_url = $base_url . '/group.php?gid=' . $inv->inv_collection_id;
     $invitee_url = url_for('user_blog', array('login' => $user->login_name));
     $array_of_data = array('first_name' => $user->first_name, 'last_name' => $user->last_name, 'user_name' => $user->login_name, 'user_id' => $user->user_id, 'message' => $inv->inv_message, 'group_name' => $inv->inv_group_name, 'accept_url' => $inv->accept_url, 'register_url' => $inv->register_url, 'invited_user_name' => $inv->inv_user_first_name, 'invitee_image' => $invitee_image, 'group_id' => $inv->inv_collection_id, 'group_description' => $group->description, 'group_icon_image' => $group_icon_image, 'group_url' => $group_url, 'network_name' => $network_info->name, 'invitee_url' => $invitee_url, 'config_site_name' => $config_site_name);
     $check = pa_mail($inv->inv_email, $mail_type, $array_of_data, $user->email);
     $succ_msg .= $valid_user_first_emails[$counter] . ', ';
     if ($counter == $valid_cnt - 1) {
         $succ_msg = substr($succ_msg, 0, -2);
         //$msg_1[] = "Invitation has been sent successfully to -" . $succ_msg;
function setup_module($column, $moduleName, $obj)
{
    global $is_group_content, $group_details, $users, $gid, $content, $collection, $error_message, $media_gallery;
    if (!empty($group_details['collection_id'])) {
        // we are in a group
        $gid = (int) $group_details['collection_id'];
        $login_uid = @PA::$login_user->user_id;
        $group = ContentCollection::load_collection($gid, $login_uid);
        $member_type = Group::get_user_type($login_uid, $gid);
        if ($group->reg_type == REG_INVITE && $member_type == NOT_A_MEMBER) {
            $group_top_mesg = 9005;
            return "skip";
        }
    }
    if ($group_details['access_type'] == 'Private Moderated' && $member_type == NOT_A_MEMBER) {
        $group_top_mesg = 9005;
        return "skip";
    }
    switch ($moduleName) {
        case 'RecentCommentsModule':
            $obj->cid = $_REQUEST['cid'];
            $obj->block_type = HOMEPAGE;
            $obj->mode = PRI;
            break;
        case 'GroupAccessModule':
            $obj->group_details = $group_details;
            break;
        case 'MembersFacewallModule':
            $obj->group_details = $group_details;
            $obj->links = $group_details['users'];
            $obj->gid = $gid;
            $obj->mode = PRI;
            $obj->block_type = 'Homepage';
            break;
        case 'EventCalendarSidebarModule':
            if ($is_group_content) {
                $obj->assoc_type = "group";
                $obj->assoc_id = $gid;
                if (!isset($_GET['gid']) || $_GET['gid'] != $gid) {
                    $_GET['gid'] = $gid;
                    // make sure it get's passed so we can construct the right URLs
                }
                $obj->title = 'Group Events';
                $is_member = Group::get_user_type((int) PA::$login_uid, $gid);
                if ($is_member == NOT_A_MEMBER) {
                    $obj->may_edit = false;
                } else {
                    $obj->may_edit = true;
                }
            } else {
                $obj->assoc_id = $content->author_id;
                // displaying the calendar for the AUTHOR of this content
                $obj->assoc_type = "user";
                // this is the personal calendar
                if ((int) PA::$login_uid != $user->user_id) {
                    $obj->may_edit = false;
                } else {
                    $obj->may_edit = true;
                }
            }
        case 'PermalinkModule':
            if ($error_message == 9005 || $error_message == 1001) {
                return "skip";
            }
            if ($group_details['skip_group_modules']) {
                return "skip";
            }
            $obj->content_id = $_REQUEST['cid'];
            $obj->content = $content;
            break;
        case 'GroupStatsModule':
            $obj->group_details = $group_details;
            $obj->gid = $gid;
            $obj->block_type = 'GroupSideBlocks';
            break;
        case 'RecentPostModule':
            if (@$collection->type == GROUP_COLLECTION_TYPE) {
                $obj->type = 'group';
                $obj->gid = $collection->collection_id;
            } else {
                $obj->mode = PUB;
                $obj->type = 'permalink';
            }
            break;
        case 'ImagesModule':
            $obj->page = $media_gallery;
            $obj->group_details = $group_details;
            break;
    }
}
 public function handlePOST_GroupInvitationSubmit($request_data)
 {
     if (isset($request_data['submit'])) {
         filter_all_post($request_data);
         $gid = $request_data['groups'];
         $self_invite = FALSE;
         $error = FALSE;
         // check if groups are there
         if (empty($gid)) {
             $error = TRUE;
             $msg[] = __("Please select a group");
         }
         if (empty($error) && !empty($request_data['email_user_name'])) {
             // if login name are supplied
             $friend_user_name = trim($request_data['email_user_name']);
             $friend_user_name_array = explode(',', $friend_user_name);
             $cnt_usr_name = count($friend_user_name_array);
             for ($counter = 0; $counter < $cnt_usr_name; $counter++) {
                 try {
                     $user_obj = new User();
                     $user_obj->load(trim($friend_user_name_array[$counter]));
                     if ($user_obj->email == PA::$login_user->email) {
                         $self_invite = TRUE;
                         //you can not invite your self
                     } else {
                         $valid_user_login_names[] = $user_obj->login_name;
                         $valid_usr_name_email[] = $user_obj->email;
                     }
                 } catch (PAException $e) {
                     if (!empty($friend_user_name_array[$counter])) {
                         $invalid_login_msg .= $friend_user_name_array[$counter] . ', ';
                     }
                 }
             }
             // end for
             if (!empty($invalid_login_msg)) {
                 $invalid_login_msg = substr($invalid_login_msg, 0, -2);
                 $msg[] = sprintf(__('Invitation could not be sent to following login names- %s'), $invalid_login_msg);
             }
         }
         // end if : if user names are supplied.
         $invalid = null;
         if (empty($error) && !empty($request_data['email_id'])) {
             // if email ids are supplied
             $friend_email = trim($request_data['email_id']);
             $friend_email_array = explode(',', $friend_email);
             $cnt_email = count($friend_email_array);
             // Check for valid-invalid email addresses start
             for ($counter = 0; $counter < $cnt_email; $counter++) {
                 $email_validation = Validation::validate_email(trim($friend_email_array[$counter]));
                 if ($email_validation == '0') {
                     $invalid[] = trim($friend_email_array[$counter]);
                 } else {
                     if ($friend_email_array[$counter] == PA::$login_user->email) {
                         $self_invite = TRUE;
                     } else {
                         $valid_user_first_emails[] = $friend_email_array[$counter];
                         $valid_email[] = trim($friend_email_array[$counter]);
                     }
                 }
             }
         }
         // Check for valid-invalid email addresses end
         // Action for valid-invalid email addresses start
         if (empty($friend_email) && empty($friend_user_name)) {
             // if email field is left empty
             $msg[] = MessagesHandler::get_message(6001);
             $error = TRUE;
         } else {
             if (!empty($friend_email) && !empty($friend_user_name)) {
                 $msg = array();
                 $msg[] = MessagesHandler::get_message(7026);
                 $error = TRUE;
             } else {
                 if (!empty($self_invite) || sizeof($invalid) > 0) {
                     // if self invitation is made
                     if (!empty($self_invite)) {
                         $msg[] = MessagesHandler::get_message(6002);
                     }
                     if (!empty($invalid)) {
                         // if invalid email addresses are supplied
                         $invalid_cnt = count($invalid);
                         $invalid_msg = '';
                         for ($counter = 0; $counter < $invalid_cnt; $counter++) {
                             if (!empty($invalid[$counter])) {
                                 $invalid_msg .= $invalid[$counter] . ', ';
                             }
                         }
                         if (!empty($invalid_msg)) {
                             $invalid_msg = substr($invalid_msg, 0, -2);
                             $msg[] = sprintf(__('Invitation could not be sent to following email addresses- %s'), $invalid_msg);
                         }
                     }
                 }
             }
         }
         if (empty($error)) {
             // At this point invitation could be made
             if (!empty($valid_email) && !empty($valid_usr_name_email)) {
                 $valid_email = array_merge($valid_email, $valid_usr_name_email);
                 $valid_user_first_emails = array_merge($valid_user_first_emails, $valid_user_login_names);
             } else {
                 if (!empty($valid_usr_name_email)) {
                     $valid_email = $valid_usr_name_email;
                     $valid_user_first_emails = $valid_user_login_names;
                 }
             }
             if (!empty($valid_email)) {
                 $valid_cnt = count($valid_email);
                 $invitation_message = nl2br($request_data['message']);
                 for ($counter = 0; $counter < $valid_cnt; $counter++) {
                     $group = new Group();
                     $group->load((int) $gid);
                     $inv = new Invitation();
                     $inv->user_id = PA::$login_uid;
                     $inv->username = PA::$login_user->login_name;
                     // for invitation not for any group invitation collection id is -1
                     $inv->inv_collection_id = $gid;
                     $inv->inv_group_name = $group->title;
                     $inv->inv_status = INVITATION_PENDING;
                     $auth_token = get_invitation_token(LONG_EXPIRES, $valid_email[$counter]);
                     $token = '&amp;token=' . $auth_token;
                     $link_desc = wordwrap(PA::$url . '/' . FILE_REGISTER . "?GInvID={$inv->inv_id}", 120, "<br>", 1);
                     $inv->register_url = "<a href=\"" . PA::$url . '/' . FILE_REGISTER . "?GInvID={$inv->inv_id}\">{$link_desc}</a>";
                     $acc_link_desc = wordwrap(PA::$url . "/" . FILE_LOGIN . "?action=accept&GInvID={$inv->inv_id}{$token}", 120, "<br>", 1);
                     $inv->accept_url = "<a href=\"" . PA::$url . "/" . FILE_LOGIN . "?action=accept&GInvID={$inv->inv_id}{$token}\">{$acc_link_desc}</a>";
                     $inv->inv_user_id = null;
                     $inv->inv_user_first_name = $valid_user_first_emails[$counter];
                     $inv->inv_email = $valid_email[$counter];
                     $inv->inv_summary = sprintf(__("Invitation from %s %s to join %s"), PA::$login_user->first_name, PA::$login_user->last_name, $inv->inv_group_name);
                     $inv->inv_message = !empty($invitation_message) ? $invitation_message : null;
                     $save_error = false;
                     try {
                         $inv->send();
                     } catch (PAException $e) {
                         $save_msg = "{$e->message}";
                         $save_error = true;
                     }
                     if ($save_error == true) {
                         $msg[] = sprintf(__('Sorry: you are unable to invite a friend.  Reason: %s'), $sav_msg);
                     } else {
                         // invitation has been sent, now send email
                         $user_type = Group::get_user_type(PA::$login_uid, $gid);
                         if ($user_type == OWNER) {
                             $mail_type = 'invite_group';
                             $requester = $group;
                         } else {
                             if ($user_type == MEMBER) {
                                 $mail_type = 'invite_group_by_member';
                                 $requester = PA::$login_user;
                             }
                         }
                         PAMail::send($mail_type, $inv->inv_email, $requester, $inv);
                         $succ_msg .= $valid_user_first_emails[$counter] . ', ';
                         if ($counter == $valid_cnt - 1) {
                             $succ_msg = substr($succ_msg, 0, -2);
                             //$msg_1[] = "Invitation has been sent successfully to -" . $succ_msg;
                         }
                     }
                 }
                 // end for : invitation to multiple email
             }
         }
     }
     //..do invite
     if (!empty($msg)) {
         $msg = array_reverse($msg);
         $message = NULL;
         for ($counter = 0; $counter < count($msg); $counter++) {
             $message .= $msg[$counter] . "<br />";
         }
     }
     $msg_array = array();
     $msg_array['failure_msg'] = $message;
     $msg_array['success_msg'] = 6004;
     $redirect_url = PA::$url . PA_ROUTE_GROUP;
     if (!empty($request_data['groups'])) {
         $query_str = "gid=" . $request_data['groups'];
     }
     set_web_variables($msg_array, $redirect_url, $query_str);
 }
Example #18
0
 /**
  * remove content from group
  * @access public
  * @param int content_id ID of content to be removed
  * @param int  user_id ID of user trying to remove post
  */
 public function remove_post($content_id, $user_id)
 {
     Logger::log("Enter: Group::save() | Args: \$content_id = {$content_id}, \$user_id = {$user_id}");
     if (!$this->is_active) {
         throw new PAException(OPERATION_NOT_PERMITTED, "Trying to remove a post from a deleted group");
     }
     $user_type = Group::get_user_type($user_id, $this->collection_id);
     $access = $this->acl_object->acl_check('action', 'delete', 'users', $user_type, 'group', 'contents');
     if (!$access) {
         throw new PAException(USER_ACCESS_DENIED, "You are not authorized to access this page");
     }
     //TODO: Also delete from contentcollections_contents
     $content = Content::load_content($content_id, $user_id);
     $content->delete();
     Logger::log("Exit: Group::save()");
 }
     $appears_in[] = $assoc->assoc_target_type . ":" . $assoc->assoc_target_id;
     echo "<li>";
     echo __("Calendar for") . " " . $assoc->assoc_target_type . " " . $assoc->assoc_target_name;
     // add remove link if we are allowed to
     $may_remove = false;
     // user is creator/owner
     if ($assoc->user_id == PA::$login_user->user_id) {
         $may_remove = true;
     }
     // user is target
     if ($assoc->assoc_target_type == 'user' && $assoc->assoc_target_id == PA::$login_user->user_id) {
         $may_remove = true;
     }
     // user is admin
     if ($assoc->assoc_target_type == 'group') {
         $is_member = Group::get_user_type((int) PA::$login_user->user_id, (int) $assoc->assoc_target_id);
         if ($is_member == 'owner') {
             $may_remove = true;
         }
     }
     if ($may_remove) {
         if ($assoc->user_id == PA::$login_user->user_id && ($assoc->assoc_target_type == 'user' && $assoc->assoc_target_id == PA::$login_user->user_id)) {
             // special case:
             // owner is also target
             echo "&nbsp;" . __("(This event will always appear in the creator's calendar.)");
         } else {
             echo " <input type=\"submit\" name=\"remove_assoc_" . $assoc->assoc_id . "\" value=\"" . __("Remove") . "\" />";
         }
     }
     echo "</li>\n";
 }
 $activity_extra['info'] = $user->first_name . 'posted a new blog';
 $activity_extra['blog_name'] = $params['content_title'];
 $activity_extra['blog_id'] = $permalink_cid;
 $activity_extra['blog_url'] = $params['content_url'];
 $extra = serialize($activity_extra);
 $object = $permalink_cid;
 Activities::save($user->user_id, $activity, $object, $extra, $activities_array);
 //save post in groups
 $routed_to_groups = route2groups();
 // save post to outputthis
 route_to_outputthis($_POST["blog_title"], $_POST["description"]);
 //we have saved it in all the locations lets redirect it to various locations
 if ($_GET['ccid']) {
     $gid = $_GET['ccid'];
     $group = ContentCollection::load_collection((int) $gid, $login_uid);
     $is_member = Group::get_user_type((int) $login_uid, (int) $gid);
     if ($is_member == NOT_A_MEMBER) {
         $msg = "&msg_id=7028";
     } else {
         if ($group->reg_type == REG_MODERATED) {
             $msg = "&msg_id=1004";
         } else {
             $msg = "&msg_id=7027";
         }
     }
     // it means user is coming from group's page then redirect it to group
     //load group to see if group is if it is moderated
     $location = "{$base_url}/group.php?gid=" . $_REQUEST['ccid'] . $msg;
     header("location:{$location}");
     exit;
 } else {
Example #21
0
function group_user_authentication($group_id)
{
    global $login_uid, $base_url;
    $access_array = array();
    $access_array['style'] = "";
    if (!empty($login_uid)) {
        $user_type = Group::get_user_type($login_uid, $group_id);
        $group_var = new Group();
        $group_var->load($group_id);
        switch (trim($user_type)) {
            case NOT_A_MEMBER:
                if ($group_var->reg_type == REG_MODERATED) {
                    $access_array['hyper_link'] = "{$base_url}/group.php?action=join&amp;gid={$group_id}";
                    $access_array['caption'] = 'Request to join';
                    $access_array['style'] = "style=\"width:160px;\"";
                } else {
                    $access_array['hyper_link'] = "{$base_url}/group.php?action=join&amp;gid={$group_id}";
                    $access_array['caption'] = 'Join';
                }
                break;
            case MEMBER:
                $access_array['hyper_link'] = "{$base_url}/group.php?action=leave&amp;gid={$group_id}";
                $access_array['caption'] = 'Unjoin';
                break;
            case OWNER:
                $access_array['hyper_link'] = "{$base_url}/addgroup.php?gid={$group_id}";
                $access_array['caption'] = 'Edit';
                break;
        }
    } else {
        $access_array['hyper_link'] = "{$base_url}/group.php?action=join&amp;gid={$group_id}";
        $access_array['caption'] = 'Join';
    }
    return $access_array;
}