public static function sync($data)
 {
     $entity = (object) array('entity_service' => 'typedGroup', 'entity_type' => $data['type'], 'entity_id' => $data['group_id'], 'entity_name' => $data['name'], 'attributes' => $data);
     parent::sync($entity);
     // also update the group that this corresponds to
     $g = new Group();
     try {
         $g->load((int) $data['group_id']);
         $g->group_type = 'typedgroup';
         $g->save();
     } catch (PAException $e) {
         throw $e;
     }
 }
Example #2
0
 public function getFriends($groupId = '', $friendLimit = '')
 {
     if ($groupId != '') {
         $this->groupId1 = $groupId;
     }
     $friends = $this->find();
     $result = array();
     foreach ($friends as $friend) {
         $group = new Group();
         $group->id = $friend->groupId2;
         $group->load();
         array_push($result, $group);
     }
     return $result;
 }
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;
    }
}
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;
}
    } catch (PAException $e) {
        $msg = "Error occured in retreiving category information\n";
        $msg .= "<br><center><font color=\"red\">" . $e->message . "</font></center>";
        $error_code = $e->code;
        $load_error = TRUE;
    }
    if ($load_error) {
        $redirect_msg = "Category does not exist.";
        $back_to_page = $base_url . '/forums.php';
        header("Location: {$base_url}/generic_error.php?msg={$redirect_msg}&back_to_page={$back_to_page}");
        exit;
    }
} elseif ($group_id) {
    $obj_group = new Group();
    try {
        $obj_group->load($group_id);
        $parent_name = stripslashes($obj_group->title);
        //$parent_description = stripslashes($obj_group->description);
    } catch (PAException $e) {
        $msg = "Error occured in retreiving group information\n";
        $msg .= "<br><center><font color=\"red\">" . $e->message . "</font></center>";
        $error_code = $e->code;
        $load_error = TRUE;
    }
    if (!Group::member_exists((int) $obj_group->collection_id, (int) $_SESSION['user']['id'])) {
        $load_error = TRUE;
    }
    if ($load_error) {
        $redirect_msg = "Group does not exist.";
        $back_to_page = $base_url . '/forums.php';
        header("Location: {$base_url}/generic_error.php?msg={$redirect_msg}&back_to_page={$back_to_page}");
Example #6
0
 public static function getGroup($id)
 {
     $objGroup = new Group();
     $objGroup->load($id);
     return $objGroup;
 }
Example #7
0
 /**
  * Remove group from this node
  *
  * @param string $groupid
  * @return Node object (this) (or Error object)
  */
 function removeGroup($groupid)
 {
     global $DB, $CFG, $USER, $HUB_SQL, $HUB_CACHE;
     //check user owns the node
     try {
         $this->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     if (isset($HUB_CACHE)) {
         $HUB_CACHE->deleteData($this->urlid . $this->style);
     }
     //check user member of group
     $group = new Group($groupid);
     $group->load();
     if (!$group->ismember($USER->userid)) {
         return access_denied_error();
     }
     // check group not already in node
     $params = array();
     $params[0] = $this->urlid;
     $params[1] = $groupid;
     $res = $DB->delete($HUB_SQL->DATAMODEL_URL_GROUP_DELETE, $params);
     if (!res) {
         return database_error();
     }
     return $this->load();
 }
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;
    }
}
$setting_data = ModuleSetting::load_setting(PAGE_ADDGROUP, PA::$login_uid);
$page = new PageRenderer("setup_module", PAGE_ADDGROUP, "{$title} - " . PA::$network_info->name, 'container_three_column.tpl', $header, PRI, HOMEPAGE, PA::$network_info, NULL, $setting_data);
/**
This function is used for loading the information from the get variables
Usage:on forum page for message board
**/
function load_info()
{
    $request_info = array();
    if (!empty($_REQUEST['gid'])) {
        $request_info['parent_id'] = $_REQUEST['gid'];
        $request_info['parent_name_hidden'] = 'gid';
        $request_info['parent_type'] = PARENT_TYPE_COLLECTION;
        $obj = new Group();
        $obj->load($_REQUEST['gid']);
        $request_info['header_title'] = stripslashes($obj->title);
    } else {
        if (!empty($_REQUEST['mid'])) {
            $request_info['parent_id'] = $_REQUEST['mid'];
            $request_info['parent_name_hidden'] = 'mid';
            $request_info['parent_type'] = PARENT_TYPE_MESSAGE;
            $obj = new MessageBoard();
            $data = $obj->get_by_id($_REQUEST['mid']);
            $request_info['header_title'] = stripslashes($data['title']);
        } else {
            if (!empty($_REQUEST['cid'])) {
                $content = Content::load_content((int) $_REQUEST['cid'], (int) PA::$login_uid);
                $ccid = $content->parent_collection_id;
                if ($ccid != 0 && $ccid != -1) {
                    //here parent collection 0 is for deleted content and -1 is for home page routed thus checking that its not a group id
                    $content_collection = ContentCollection::load_collection((int) $ccid, PA::$login_uid);
                    if ($content_collection->type == GROUP_COLLECTION_TYPE) {
                        $request_info['parent_id'] = $ccid;
                        $request_info['parent_name_hidden'] = 'gid';
                        $request_info['parent_type'] = PARENT_TYPE_COLLECTION;
                    }
                }
            } else {
                return false;
            }
        }
    }
    return $request_info;
}
 /**
  * Loads the data for the connection from the database
  *
  * @param String $style (optional - default 'long') may be 'short' or 'long' of 'cif'
  * @return Connection object (this) or Error
  */
 function load($style = 'long')
 {
     global $DB, $CFG, $HUB_SQL;
     try {
         $this->canview();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $this->style = $style;
     $params = array();
     $params[0] = $this->connid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT, $params);
     $count = count($resArray);
     if ($count == 0) {
         $ERROR = new error();
         $ERROR->createConnectionNotFoundError($this->connid);
         return $ERROR;
     }
     $fromid = 0;
     $toid = 0;
     for ($i = 0; $i < $count; $i++) {
         $array = $resArray[$i];
         $fromid = trim($array['FromID']);
         $toid = trim($array['ToID']);
         $this->fromcontexttypeid = trim($array['FromContextTypeID']);
         $this->tocontexttypeid = trim($array['ToContextTypeID']);
         $this->creationdate = trim($array['CreationDate']);
         $this->modificationdate = trim($array['ModificationDate']);
         $this->userid = trim($array['UserID']);
         $this->users = array();
         $this->users[0] = getUser($this->userid, $style);
         $this->linktypeid = trim($array['LinkTypeID']);
         $this->private = $array['Private'];
         $this->description = $array['Description'];
     }
     //now add in from/to nodes. Try from the cache first?
     $from = new CNode($fromid);
     $this->from = $from->load($style);
     $to = new CNode($toid);
     $this->to = $to->load($style);
     $r = new Role($this->fromcontexttypeid);
     $this->fromrole = $r->load();
     $r = new Role($this->tocontexttypeid);
     $this->torole = $r->load();
     $l = new LinkType($this->linktypeid);
     $this->linktype = $l->load();
     if ($style == 'long') {
         // add in the groups
         $resArray2 = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT_GROUP, $params);
         $count2 = count($resArray2);
         if ($count2 > 0) {
             $this->groups = array();
             for ($i = 0; $i < $count2; $i++) {
                 $array = $resArray2[$i];
                 $group = new Group(trim($array['GroupID']));
                 array_push($this->groups, $group->load());
             }
         }
         //now add in any tags
         $resArray3 = $DB->select($HUB_SQL->DATAMODEL_CONNECTION_SELECT_TAGS, $params);
         $count3 = count($resArray3);
         if ($count3 > 0) {
             $this->tags = array();
             for ($i = 0; $i < $count3; $i++) {
                 $array = $resArray3[$i];
                 $tag = new Tag(trim($array['TagID']));
                 array_push($this->tags, $tag->load());
             }
         }
     }
     if ($style != 'cif') {
         $this->loadVotes();
     }
     return $this;
 }
Example #11
0
<?php

$f3 = (require "lib/base.php");
$f3->set("AUTOLOAD", "../lib");
$test = new Test();
$group = new Group(new DB\SQL("sqlite:/tmp/test.sqlite"));
$group->name = "My Group";
$group->save();
$test->expect($group->_id > 0, "Group was saved");
$group->load(array("id = ?", $group->_id));
$test->expect($group->erase(), "Group was deleted");
foreach ($test->results() as $result) {
    echo $result['text'] . "\t";
    if ($result['status']) {
        echo 'Pass';
    } else {
        echo 'Fail (' . $result['source'] . ')';
    }
    echo "\n";
}
Example #12
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;
}
Example #13
0
 /**
  * @param $name
  * @param bool $email
  * @param bool $id
  * @return User
  */
 public function load($name, $email = false, $id = false)
 {
     $sql = self::sql();
     if (!$sql instanceof SQLModule) {
         return;
     }
     //Should never happen
     $t = $sql->get_config("SQL", "sql_prefix") . "_users";
     $query = "SELECT id, user_password, user_email, user_group, user_permissions, user_avatar, user_ip, user_registered, logged_in, user_banned, user_online, user_activated, activation_key FROM `" . $t . "` WHERE user_name = ?";
     if ($email) {
         $query = "SELECT id, user_password, user_name, user_group, user_permissions, user_avatar, user_ip, user_registered, logged_in, user_banned, user_online, user_activated, activation_key FROM `" . $t . "` WHERE user_email = ?";
     }
     if ($id) {
         $query = "SELECT user_password, user_email, user_name, user_group, user_permissions, user_avatar, user_ip, user_registered, logged_in, user_banned, user_online, user_activated, activation_key FROM `" . $t . "` WHERE id = ?";
     }
     $user = new User();
     $stmt = $sql->get_pdo()->prepare($query);
     $stmt->execute(array($name));
     $result = $stmt->fetch(PDO::FETCH_ASSOC);
     $user->id = $id ? $name : $result['id'];
     $user->ip = $result['user_ip'];
     $user->avatar = $result['user_avatar'];
     $user->name = $email ? $result['user_name'] : $id ? $result['user_name'] : $name;
     $user->password = $result['user_password'];
     $user->group = Group::load($result['user_group']);
     $user->permissions = explode(",", $result['user_permissions']);
     $user->email = $email ? $name : $result['user_email'];
     $user->registered = $result['user_registered'];
     $user->logged_in = $result['logged_in'];
     $user->activation_key = $result['activation_key'];
     $user->activated = $result['user_activated'];
     $user->banned = $result['user_banned'];
     $user->online = $result['user_online'];
     return $user;
 }
 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);
 }
 /**
  * load in the groups for the given SQL statement
  *
  * @param string $sql
  * @param array $params the parameters that go into the sql statement
  * @param int $start starting from record item
  * @param int $max for a record limit of this given count
  * @param string $orderby the name of the field to sort by
  * @param string $sort 'ASC' or 'DESC' (ascending or descending ordering)
  * @param string the style of each record in the collection (defaults to 'long' , can be 'short');
  * @return GroupSet (this)
  */
 function loadFromUsers($sql, $params, $start, $max, $orderby, $sort, $style = 'long')
 {
     global $DB, $HUB_SQL;
     if (!isset($params)) {
         $params = array();
     }
     // get the total count of the connection records.
     $csql = $HUB_SQL->DATAMODEL_GROUP_LOAD_PART1;
     $csql .= $sql;
     $csql .= $HUB_SQL->DATAMODEL_GROUP_LOAD_PART2;
     $carray = $DB->select($csql, $params);
     $totalconns = $carray[0]["totalusers"];
     // get the connection records for the given parameters, start, max etc.
     // ADD SORTING
     $sql = $DB->userOrderString($sql, $orderby, $sort);
     // ADD LIMITING
     $sql = $DB->addLimitingResults($sql, $start, $max);
     $resArray = $DB->select($sql, $params);
     $count = count($resArray);
     $this->totalno = $totalconns;
     $this->start = $start;
     $this->count = $count;
     for ($i = 0; $i < $count; $i++) {
         $array = $resArray[$i];
         $g = new Group($array["UserID"]);
         $this->add($g->load());
     }
     return $this;
 }
 /** !!
  * This handles the data that is POSTed back to the page upon
  * submission of the form. There is a lot happening in here,
  * but it basically looks at the submitted data, figures out
  * what it is supposed to do with it (based on if the group is
  * being created or modified), then creates a new group or
  * updates the current data using the {@link handle_entity() } method.
  *
  * @param array $request_data  All of the data POSTed back to the form.
  */
 public function handlePOST($request_data)
 {
     require_once "web/includes/classes/CNFileUploader.php";
     require_once "api/CNActivities/CNActivities.php";
     require_once "api/cnapi_constants.php";
     if ($request_data['addgroup']) {
         filter_all_post($request_data);
         $groupname = trim($request_data['groupname']);
         $body = trim($request_data['groupdesc']);
         $tag_entry = trim($request_data['group_tags']);
         $group_category = $request_data['group_category'];
         $header_image = NULL;
         $header_image_action = @$request_data['header_image_action'];
         $display_header_image = @$request_data['display_header_image'];
         $collection_id = NULL;
         $this->extra = NULL;
         if ($request_data['ccid']) {
             $collection_id = (int) $request_data['ccid'];
             $group = new Group();
             $group->load($collection_id);
             // preserve group info we are not editing in this module
             // load group extra
             $extra = $group->extra;
             if (!empty($extra)) {
                 $this->extra = unserialize($extra);
             }
             $header_image = $group->header_image;
             $header_image_action = $group->header_image_action;
             $display_header_image = $group->display_header_image;
         }
         $access = 0;
         // default access is 0 means public
         $reg_type = $request_data['reg_type'];
         if ($reg_type == REG_INVITE) {
             // if reg. type = "Invite" access is PRIVATE
             $access = ACCESS_PRIVATE;
         }
         $is_moderated = 0;
         // is moderated is 0 means contents appear immediately
         $group_tags = $request_data['group_tags'];
         if (empty($request_data['groupname'])) {
             $error_msg = 90222;
         } else {
             if (empty($group_category) && empty($error_msg)) {
                 $error_msg = 90224;
             } else {
                 if (empty($error_msg)) {
                     try {
                         if (empty($_FILES['groupphoto']['name'])) {
                             $upfile = $request_data['file'];
                         } else {
                             $myUploadobj = new FileUploader();
                             //creating instance of file.
                             $image_type = 'image';
                             $file = $myUploadobj->upload_file(PA::$upload_path, 'groupphoto', true, true, $image_type);
                             if ($file == false) {
                                 throw new CNException(GROUP_PARAMETER_ERROR, __("File upload error: ") . $myUploadobj->error);
                             }
                             $upfile = $file;
                             $avatar_uploaded = TRUE;
                         }
                         $exception_message = NULL;
                         $result = Group::save_new_group($collection_id, $_SESSION['user']['id'], $groupname, $body, $upfile, $group_tags, $group_category, $access, $reg_type, $is_moderated, $header_image, $header_image_action, $display_header_image, $this->extra);
                         $ccid = $result;
                         $exception_message = 'Group creation failed: ' . $result;
                         if (!is_numeric($result)) {
                             throw new CNException(GROUP_CREATION_FAILED, $exception_message);
                         } else {
                             if (@$avatar_uploaded) {
                                 Storage::link($upfile, array("role" => "avatar", "group" => (int) $result));
                             }
                             if (@$header_uploaded) {
                                 Storage::link($header_image, array("role" => "header", "group" => (int) $result));
                             }
                             $this->gid = $this->id = $result;
                             if (empty($request_data['gid'])) {
                                 $mail_type = $activity = 'group_created';
                                 $act_text = ' created a new group';
                             } else {
                                 $mail_type = $activity = 'group_settings_updated';
                                 $act_text = ' changed group settings ';
                             }
                             $group = new Group();
                             $group->load((int) $this->gid);
                             PANotify::send($mail_type, PA::$network_info, PA::$login_user, $group);
                             // notify network onwer
                             $_group_url = PA::$url . PA_ROUTE_GROUP . '/gid=' . $result;
                             $group_owner = new User();
                             $group_owner->load((int) $_SESSION['user']['id']);
                             $activity_extra['info'] = $group_owner->first_name . $act_text;
                             $activity_extra['group_name'] = $groupname;
                             $activity_extra['group_id'] = $result;
                             $activity_extra['group_url'] = $_group_url;
                             $extra = serialize($activity_extra);
                             $object = $result;
                             if ($reg_type != REG_INVITE) {
                                 Activities::save($group_owner->user_id, $activity, $object, $extra);
                             }
                             // if we reached here than the group is created
                             if (empty($request_data['gid'])) {
                                 // when a new group is created
                                 // so, we need to assign group admin role to group owner now:
                                 $role_extra = array('user' => false, 'network' => false, 'groups' => array($this->gid));
                                 $user_roles[] = array('role_id' => GROUP_ADMIN_ROLE, 'extra' => serialize($role_extra));
                                 $group_owner->set_user_role($user_roles);
                             }
                             if (!empty(PA::$config->useTypedGroups) && !empty($request_data['type'])) {
                                 $this->gid = $this->id;
                                 switch ($request_data['op']) {
                                     case 'create_entity':
                                     case 'edit_entity':
                                         $this->handleEntity($request_data);
                                         break;
                                 }
                             }
                         }
                     } catch (CNException $e) {
                         if ($e->code == GROUP_PARAMETER_ERROR) {
                             $error_msg = $e->message;
                             if (empty($groupname)) {
                                 $error_msg = 90222;
                             } else {
                                 if (empty($group_category)) {
                                     $error_msg = 90224;
                                 }
                             }
                         } else {
                             $error_msg = $e->message;
                         }
                     }
                 }
             }
         }
     }
     //if form is posted
     $msg_array = array();
     $msg_array['failure_msg'] = @$error_msg;
     $msg_array['success_msg'] = !empty($this->id) ? 90231 : 90221;
     $redirect_url = PA::$url . PA_ROUTE_GROUP;
     $query_str = "?gid=" . @$result;
     set_web_variables($msg_array, $redirect_url, $query_str);
 }
 function render()
 {
     $login_uid = @PA::$login_user->user_id;
     $this->gid = @$this->params['blog_id'];
     $this->blog_name = @$this->params['blog_name'];
     $this->note = '';
     if ($this->blog_name) {
         $this->find_or_create_blog();
     }
     if ($this->gid) {
         $this->type == 'group';
         $group = new Group();
         $group->collection_id = $this->gid;
         $group->load($this->gid);
         $this->group_member = Group::member_exists($group->collection_id, $login_uid) ? TRUE : FALSE;
         switch ($this->view) {
             case "recent_post":
                 // load content
                 $this->contents = $group->get_contents_for_collection($type = 'all', $cnt = FALSE, 1, 1, 'created', 'DESC');
                 $this->inner_template = 'recent_post.tpl';
                 break;
             case 'user':
                 // load content
                 if (@$this->params['cid']) {
                     // permalink, load only this one
                     $bp = new BlogPost();
                     try {
                         $bp->load((int) $this->params['cid']);
                         $this->count = 1;
                         $content = array();
                         foreach ($bp as $k => $v) {
                             $content[$k] = $v;
                         }
                         $this->contents[] = $content;
                     } catch (PAException $e) {
                         $this->err = __("Couldn't load BlogPost. ") . $e->getMessage();
                     }
                 } else {
                     $this->count = $group->get_contents_for_collection($type = 'all', $cnt = TRUE, 'all', 0, $sort_by = 'created', $direction = 'DESC');
                     $this->contents = $group->get_contents_for_collection($type = 'all', $cnt = FALSE, $this->show, $this->page, 'created', 'DESC');
                 }
                 break;
             case "admin":
                 $this->title = "Managing authors for " . $this->blog_name;
                 $this->inner_template = 'manageauthors.tpl';
                 // find members
                 $this->members = $group->get_members();
                 $this->member_count = count($this->members);
                 break;
         }
         // load Items for all BlogPosts -> for Comments to work
         foreach ($this->contents as $i => $post) {
             $item_params = array("type" => 'blogpost', "id" => $post['content_id'], "name" => $post['content_id'], "thumbnail" => "", "thumbnail_w" => "0", "thumbnail_h" => "0", "genres" => "blog", "url" => $this->blog_url . "?b_cid=" . $post['content_id']);
             Item::sync($item_params);
             // create or update row in 'items' database table
             $item = Item::find_by_subject('blogpost', $post['content_id']);
             $this->contents[$i]['comment_count'] = $item->comment_count;
         }
     } else {
         $this->err = __("No Blog found.");
     }
     $tmp_file = dirname(__FILE__) . "/" . $this->skin . "_" . $this->inner_template;
     $inner_html_gen =& new Template($tmp_file, $this);
     $this->inner_HTML = $inner_html_gen->fetch();
     $content = parent::render();
     return $content;
 }
 $params['cid'] = $new_video->content_id;
 $params['media_title'] = $new_video->title;
 $params['content_url'] = $redirect_url . '/' . FILE_CONTENT . '?cid=' . $new_video->content_id;
 $params['config_site_name'] = $config_site_name;
 $params['media_full_view_url'] = $redirect_url . '/' . FILE_MEDIA_FULL_VIEW . '?cid=' . $new_video->content_id;
 $params['content_moderation_url'] = $redirect_url . '/' . FILE_NETWORK_MANAGE_CONTENT;
 $params['network_name'] = PA::$network_info->name;
 //   auto_email_notification('media_uploaded', $params, $network_details);
 $moderation = FALSE;
 if (!empty($_GET['group_id'])) {
     $activity = 'group_video_upload';
     //for rivers of people
     $location = $redirect_url . '/media/gallery/Videos/view=groups_media&gid=' . $_GET['group_id'];
     $params['media_full_view_url'] = $redirect_url . '/' . FILE_MEDIA_FULL_VIEW . '?cid=' . $new_video->content_id;
     $group = new Group();
     $group->load((int) $_GET['group_id']);
     if ($group->reg_type == REG_MODERATED && !in_array(PA::$login_uid, $group->moderators)) {
         $moderation = TRUE;
         $params['media_full_view_url'] = $redirect_url . '/group_moderation.php?view=content&gid=' . $_GET['group_id'];
     }
 } else {
     $activity = 'user_video_upload';
     //for rivers of people
     $location = $redirect_url . '/media/gallery/Videos/uid=' . PA::$login_uid;
 }
 $task = Roles::check_permission_by_value(PA::$login_uid, 'manage_content');
 if (($network_extra['network_content_moderation'] == NET_YES && $network_details->owner_id != PA::$login_uid || $moderation) && PA::$login_uid != SUPER_USER_ID) {
     Network::moderate_network_content($new_video->parent_collection_id, $new_video->content_id);
     // is_active = 2 for unverified content
     //     $location .= 1005;
 } else {
 public function getMessageSpecificData()
 {
     if (is_array($this->associated_obj)) {
         // to keep compatibility with some old code, we must accept parameters given in arrays also
         foreach ($this->associated_obj as $name => $value) {
             $this->template_vars["%{$name}%"] = $value;
         }
     } else {
         if (is_object($this->associated_obj)) {
             if (is_a($this->associated_obj, 'User')) {
                 $this->addUserData($this->associated_obj, 'related.user');
             } else {
                 if (is_a($this->associated_obj, 'Content')) {
                     $author = new User();
                     $author->load((int) $this->associated_obj->author_id);
                     $this->addUserData($author, 'content.author');
                     $this->template_vars["%content.title%"] = $this->associated_obj->title;
                     $this->template_vars["%content.url%"] = UrlHelper::url_for(PA_ROUTE_CONTENT, array('cid' => $this->associated_obj->content_id));
                     $this->template_vars["%content.link%"] = UrlHelper::link_to(PA_ROUTE_CONTENT, $this->associated_obj->title, null, array('cid' => $this->associated_obj->content_id));
                     $this->template_vars["%content.delete_url%"] = UrlHelper::url_for(PA_ROUTE_CONTENT, array('cid' => $this->associated_obj->content_id, 'action' => 'deleteContent'));
                     $this->template_vars["%content.delete_link%"] = UrlHelper::link_to(PA_ROUTE_CONTENT, $this->template_vars["%content.delete_url%"], null, array('cid' => $this->associated_obj->content_id, 'action' => 'deleteContent'));
                     $this->template_vars["%content.moderation_url%"] = UrlHelper::url_for(PA::$url . '/' . FILE_NETWORK_MANAGE_CONTENT);
                     $this->template_vars["%content.moderation_link%"] = UrlHelper::link_to(PA::$url . '/' . FILE_NETWORK_MANAGE_CONTENT, $this->template_vars["%content.moderation_url%"]);
                     if (get_class($this->associated_obj) == 'Image' || get_class($this->associated_obj) == 'Audio' || get_class($this->associated_obj) == 'Video') {
                         if (!empty($this->associated_obj->group_id)) {
                             // if Group Media
                             $this->group = new Group();
                             $this->group->load((int) $this->associated_obj->group_id);
                             $this->addGroupData($this->group);
                         }
                         $this->template_vars["%media.title%"] = $this->associated_obj->title;
                         $this->template_vars["%media.full_view_url%"] = UrlHelper::url_for(PA::$url . '/' . FILE_MEDIA_FULL_VIEW, array('cid' => $this->associated_obj->content_id, 'login_required' => 'true'));
                         $this->template_vars["%media.full_view_link%"] = UrlHelper::link_to(PA::$url . '/' . FILE_MEDIA_FULL_VIEW, $this->template_vars["%media.full_view_url%"], null, array('cid' => $this->associated_obj->content_id, 'login_required' => 'true'));
                     }
                 } else {
                     if (is_a($this->associated_obj, 'Comment')) {
                         $author = new User();
                         $author->load((int) $this->associated_obj->user_id);
                         $this->addUserData($author, 'comment.author');
                         $this->template_vars["%comment.text%"] = $this->associated_obj->comment;
                         $this->template_vars["%comment.url%"] = UrlHelper::url_for(PA_ROUTE_CONTENT, array('cid' => $this->associated_obj->content_id));
                         $this->template_vars["%comment.link%"] = UrlHelper::link_to(PA_ROUTE_CONTENT, $this->template_vars["%comment.url%"], null, array('cid' => $this->associated_obj->content_id));
                         $this->template_vars["%comment.delete_url%"] = UrlHelper::url_for(PA::$url . '/deletecomment.php', array('comment_id' => $this->associated_obj->comment_id));
                         $this->template_vars["%comment.delete_link%"] = UrlHelper::link_to(PA::$url . '/deletecomment.php', $this->template_vars["%comment.delete_url%"], null, array('comment_id' => $this->associated_obj->comment_id));
                     } else {
                         if (is_a($this->associated_obj, 'Invitation')) {
                             $inviter = new User();
                             $inviter->load((int) $this->associated_obj->user_id);
                             $this->addUserData($inviter, 'invite.inviter');
                             if (!empty($this->associated_obj->inv_collection_id) && $this->associated_obj->inv_collection_id != -1) {
                                 $group = new Group();
                                 $group->load((int) $this->associated_obj->inv_collection_id);
                                 $this->group = $group;
                                 $this->addGroupData($this->group);
                             }
                             if (empty($this->associated_obj->inv_user_id) || $this->associated_obj->inv_summary == "internal_invitation") {
                                 // invitation sent
                                 $reg_link_desc = abbreviate_text($this->associated_obj->register_url, 52, 36);
                                 $acc_link_desc = abbreviate_text($this->associated_obj->accept_url, 52, 36);
                                 $reg_link = "<a href=\"{$this->associated_obj->register_url}\">{$reg_link_desc}</a>";
                                 $acc_link = "<a href=\"{$this->associated_obj->accept_url}\">{$acc_link_desc}</a>";
                                 $this->template_vars["%invite.message%"] = $this->associated_obj->inv_message;
                                 $this->template_vars["%invite.accept_url%"] = $this->associated_obj->accept_url;
                                 $this->template_vars["%invite.accept_link%"] = $acc_link;
                                 $this->template_vars["%invite.register_url%"] = $this->associated_obj->register_url;
                                 $this->template_vars["%invite.register_link%"] = $reg_link;
                                 $this->template_vars["%invite.invited_user_name%"] = $this->associated_obj->inv_user_first_name;
                                 $this->template_vars["%invite.invited_user_email%"] = $this->associated_obj->inv_email;
                                 $this->template_vars["%recipient.email_address%"] = $this->associated_obj->inv_email;
                             } else {
                                 // invitation accepted
                                 $invited = new User();
                                 $invited->load((int) $this->associated_obj->inv_user_id);
                                 $this->addUserData($invited, 'invite.invited');
                                 if (!empty($this->associated_obj->inv_relation_type)) {
                                     $this->template_vars["%invite.relation_type%"] = $this->associated_obj->inv_relation_type;
                                 }
                             }
                         } else {
                             if (is_a($this->associated_obj, 'RelationData')) {
                                 $requester = new User();
                                 $relateduser = new User();
                                 $requester->load((int) $this->associated_obj->user_id);
                                 $relateduser->load((int) $this->associated_obj->relation_id);
                                 $this->addUserData($requester, 'relation.inviter');
                                 $this->addUserData($relateduser, 'relation.invited');
                                 $this->template_vars["%relation.type%"] = Relation::lookup_relation_type($this->associated_obj->relationship_type);
                                 $this->template_vars["%relation.friend_list_url%"] = UrlHelper::url_for(PA::$url . '/' . FILE_VIEW_ALL_MEMBERS, array('view_type' => 'in_relations', 'uid' => $this->associated_obj->user_id, 'login_required' => 'true'));
                                 $this->template_vars["%relation.friend_list_link%"] = UrlHelper::link_to(PA::$url . '/' . FILE_VIEW_ALL_MEMBERS, $this->template_vars["%relation.friend_list_url%"], null, array('view_type' => 'in_relations', 'uid' => $this->associated_obj->user_id, 'login_required' => 'true'));
                                 $this->template_vars["%relation.appr_deny_url%"] = UrlHelper::url_for(PA::$url . '/' . FILE_VIEW_ALL_MEMBERS, array('view_type' => 'in_relations', 'uid' => $this->associated_obj->relation_id, 'login_required' => 'true'));
                                 $this->template_vars["%relation.appr_deny_link%"] = UrlHelper::link_to(PA::$url . '/' . FILE_VIEW_ALL_MEMBERS, $this->template_vars["%relation.appr_deny_url%"], null, array('view_type' => 'in_relations', 'uid' => $this->associated_obj->relation_id, 'login_required' => 'true'));
                             } else {
                                 if (is_a($this->associated_obj, 'ReportAbuse')) {
                                     $author = new User();
                                     $author->load((int) $this->associated_obj->reporter_id);
                                     $this->addUserData($author, 'abuse.reporter');
                                     $this->template_vars["%abuse.report%"] = $this->associated_obj->body;
                                     $this->template_vars["%abuse.url%"] = UrlHelper::url_for(PA_ROUTE_CONTENT, array('cid' => $this->associated_obj->parent_id));
                                     $this->template_vars["%abuse.link%"] = UrlHelper::link_to(PA_ROUTE_CONTENT, $this->template_vars["%abuse.url%"], null, array('cid' => $this->associated_obj->parent_id));
                                     $this->template_vars["%abuse.delete_comment_url%"] = UrlHelper::url_for(PA::$url . '/deletecomment.php', array('comment_id' => $this->associated_obj->parent_id));
                                     $this->template_vars["%abuse.delete_comment_link%"] = UrlHelper::link_to(PA::$url . '/deletecomment.php', $this->template_vars["%abuse.delete_comment_url%"], null, array('comment_id' => $this->associated_obj->parent_id));
                                     $this->template_vars["%abuse.delete_content_url%"] = UrlHelper::url_for(PA::$url . '/deletecontent.php', array('cid' => $this->associated_obj->parent_id));
                                     $this->template_vars["%abuse.delete_content_link%"] = UrlHelper::link_to(PA::$url . '/deletecontent.php', $this->template_vars["%abuse.delete_content_url%"], null, array('cid' => $this->associated_obj->parent_id));
                                 } else {
                                     if (is_a($this->associated_obj, 'Group')) {
                                         $this->addGroupData($this->associated_obj);
                                     } else {
                                         Logger::log("Error exit: function MessageRenderer::getMessageSpecificData() - Unknown associated object type.");
                                         throw new Exception("MessageRenderer::getMessageSpecificData() - Unknown associated object type.");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
function api_validate_album_context($context, $user, $access = "write")
{
    if (preg_match("/^group:(\\d+)\$/", $context, $m)) {
        // group album
        $collection_id = $m[1];
        // load group and verify access
        $obj = new Group();
        $obj->load($collection_id);
        $obj->assert_user_access($user->user_id);
    } elseif (preg_match("/^user:\\d+:album:(\\d+)\$/", $context, $m)) {
        // personal album
        $collection_id = $m[1];
        // load album and verify access
        $obj = new Album();
        $obj->load($collection_id);
        if ($access != "read") {
            if ($obj->author_id != $user->user_id) {
                throw new PAException(USER_ACCESS_DENIED, "You are not the creator of this album");
            }
        }
    } else {
        throw new PAException(INVALID_ID, "File context must be an album or group ID");
    }
    return array($collection_id, $obj);
}
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&amp;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&amp;gid={$group_id}";
                    $access_array['caption'] = 'Join';
                }
                break;
            case MEMBER:
                $access_array['hyper_link'] = PA::$url . PA_ROUTE_GROUP . "/action=leave&amp;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&amp;gid={$group_id}";
        $access_array['caption'] = 'Join';
    }
    return $access_array;
}
Example #22
0
        if (@$groups['enabled']) {
            $html .= "<h4>My groups</h4>";
            $grp = Group::get_user_groups($user->user_id, FALSE, 1000, 1);
            $grp_ids = array();
            foreach ($grp as $g) {
                $grp_ids[] = $g['gid'];
            }
            $grp_incl = @$groups['included'];
            $max_groups = 8;
            // show 8 groups (this should be configurable)
            $grp_show = select_random_subset($grp_incl, $groups['show'], $grp_ids, 'ids', $max_groups);
            $items_html = array();
            foreach ($grp_show as $grp_id) {
                $group_url_enc = "{$base_url}/group.php?gid={$grp_id}";
                $grp = new Group();
                $grp->load((int) $grp_id);
                $img = uihelper_resize_mk_img("files/" . $grp->picture, 75, 75, DEFAULT_USER_PHOTO_REL);
                $group_name_enc = htmlspecialchars($grp->title);
                $h = <<<EOS
<div class="badge_person">
<a href="{$group_url_enc}" target="_blank"><div class="person_image">{$img}</div><div class="person_name">{$group_name_enc}</div></a>
</div>
EOS;
                $items_html[] = array("item", $h);
            }
            $html .= badge_render_section($items_html);
        }
        $networks =& $badge['networks'];
        if (@$networks['enabled']) {
            $html .= "<h4>My networks</h4>";
            $nets = Network::get_user_networks($user->user_id, FALSE, 1000, 1);
    function render_group_image($grp_or_id) {
	$grp = new Group();
	if (is_numeric($grp_or_id)) {
	    // it's an id
	    $grp->load((int)$grp_or_id);
	} else {
	    $grp->load($grp_or_id['gid']);
	}

	$groups = $this->state['groups'];
	$included = isset($groups['included'][(int)$grp->collection_id]);

	$img = uihelper_resize_mk_user_img($grp->picture, 75, 75);
	$name = $grp->title;
	$cls = "friend_pic";
	if ($included) $cls .= " included_friend";
	$include_op = $included ? "exclude" : "include";

	$onclick = "badge.include_obj('groups', 'group_$grp->collection_id', $grp->collection_id, '$include_op');";
	return <<<ENS
<div class="$cls" onclick="$onclick" title="Click to $include_op this group.">
	<p>$img</p>
	<p>$name</p>
</div>
ENS;
    }
Example #24
0
 if (!$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;
         }
     }
     $valid_cnt = count($valid_email);
     $invitation_message = nl2br($_POST['message']);
     for ($counter = 0; $counter < $valid_cnt; $counter++) {
         $group = new Group();
         $group->load((int) $gid);
         $inv = new Invitation();
         $inv->user_id = $login_uid;
         $inv->username = $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("{$base_url}/register.php?GInvID={$inv->inv_id}", 120, "<br>", 1);
         $inv->register_url = "<a href=\"{$base_url}/register.php?GInvID={$inv->inv_id}\">{$link_desc}</a>";
         $acc_link_desc = wordwrap("{$base_url}/login.php?action=accept&GInvID={$inv->inv_id}{$token}", 120, "<br>", 1);
         $inv->accept_url = "<a href=\"{$base_url}/login.php?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];
Example #25
0
/**
 * Is the given user in the given group.
 *
 * @param string $groupid
 * @param string $userid
 * @return true if member else false
 */
function isGroupMember($groupid, $userid)
{
    $g = new Group($groupid);
    $g->load();
    return $g->ismember($userid);
}
Example #26
0
 /**
  * Load groups
  */
 function loadGroups()
 {
     global $DB, $CFG, $USER, $HUB_SQL;
     $params = array();
     $params[0] = $this->nodeid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_GROUPS, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count > 0) {
             $this->groups = array();
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $group = new Group(trim($array['GroupID']));
                 array_push($this->groups, $group->load());
             }
         }
     } else {
         return database_error();
     }
 }
 /**
  * Remove group from this Connection
  *
  * @param string $groupid
  * @return Connection object (this) (or Error object)
  */
 function removeGroup($groupid)
 {
     global $DB, $CFG, $USER, $HUB_SQL;
     //check user owns the connection
     try {
         $this->canedit();
     } catch (Exception $e) {
         return access_denied_error();
     }
     //check user member of group
     $group = new Group($groupid);
     $group->load();
     if (!$group->ismember($USER->userid)) {
         return access_denied_error();
     }
     $params = array();
     $params[0] = $this->connid;
     $params[1] = $groupid;
     $res = $DB->delete($HUB_SQL->DATAMODEL_CONNECTION_GROUP_DELETE, $params);
     if (!$res) {
         return database_error();
     }
     return $this->load();
 }
 function initializeModule($request_method, $request_data)
 {
     if (empty($this->shared_data['group_info'])) {
         return 'skip';
     }
     $this->group_details = $this->shared_data['group_info'];
     if (empty($request_data['gid'])) {
         return 'skip';
     }
     // sanity check
     // we do this check only if the user is not already permitted to manage ads
     $gp_access = PermissionsHandler::can_group_user(PA::$login_uid, $request_data['gid'], array('permissions' => 'manage_groups'));
     if (!$gp_access) {
         return 'skip';
     }
     // user shoudn't have gotten here in the first place, just don't show anything
     $error_msg = false;
     if ($request_method == 'POST') {
         $value_to_validate = array('title' => 'Title', 'bulletin_body' => 'Bulletin body');
         foreach ($value_to_validate as $key => $value) {
             $request_data[$key] = trim($request_data[$key]);
             if (empty($request_data[$key])) {
                 $error_msg .= $value . ' can not be empty<br>';
             }
         }
         if (!$error_msg) {
             // if no errors yet
             $subject = $request_data['title'];
             $bull_message = $request_data['bulletin_body'];
             $group = new Group();
             $group->load($request_data['gid']);
             if (!empty($request_data['bulletins'])) {
                 // send to all members
                 $gms = $group->get_members();
                 foreach ($gms as $i => $m) {
                     $u = new User();
                     $u->load((int) $m['user_id']);
                     $to_members[] = $u;
                 }
             } else {
                 if (!empty($request_data['send_to_me_only'])) {
                     // test send to admin user
                     $to_members = array(PA::$login_user);
                 }
             }
             $this->sent_to = array();
             // send it
             if (!empty($to_members)) {
                 foreach ($to_members as $recipient) {
                     $this->sent_to[] = $recipient->display_name;
                     PANotify::send("group_bulletin_sent", $recipient, $group, array('bulletin.message' => $bull_message, 'bulletin.subject' => $subject));
                 }
             }
             // wannt a preview with that?
             if (!empty($request_data['preview'])) {
                 // if preview is selected.
                 $container_html = 'default_email_container.tpl';
                 $email_container = new Template('config/email_containers/' . $container_html);
                 $email_container->set('subject', $subject);
                 $email_container->set('message', $bull_message);
                 $this->preview_msg = $email_container->fetch();
             }
         }
     }
 }