function initializeModule($request_method, $request_data) { global $error_msg; $error = false; $msg = array(); $form_data = NULL; $edit = false; $message = NULL; // check permissions! $user_may = false; $user_may = PermissionsHandler::can_user(PA::$login_uid, array('permissions' => 'manage_ads')); // check for manageads of group permissions if (!empty($_REQUEST['gid']) && !$user_may) { // we do this checl only if the user is not already permitted to manage ads $gp_access = PermissionsHandler::can_group_user(PA::$login_uid, $_REQUEST['gid'], array('permissions' => 'manage_ads')); $user_may = $gp_access; } if (!$user_may) { $error_msg = __("You do not have permission to manage Ads."); return "skip"; } // paging if (!empty($request_data['page'])) { $this->Paging["page"] = (int) $request_data['page']; } if (!empty($request_data['action']) && $request_data['action'] == 'edit' && !empty($request_data['ad_id'])) { $edit = TRUE; $res = Advertisement::get($params = NULL, $condition = array('ad_id' => (int) $request_data['ad_id'])); if (!empty($res)) { $form_data['ad_id'] = $res[0]->ad_id; $form_data['ad_image'] = $res[0]->ad_image; $form_data['ad_script'] = $res[0]->ad_script; $form_data['ad_url'] = $res[0]->url; $form_data['ad_title'] = $res[0]->title; $form_data['ad_description'] = $res[0]->description; $form_data['ad_page_id'] = $res[0]->page_id; $form_data['orientation'] = $res[0]->orientation; $form_data['created'] = $res[0]->created; } } else { if (!empty($request_data['action']) && $request_data['action'] == 'delete' && !empty($request_data['ad_id'])) { if (!empty($request_data['ad_id'])) { try { Advertisement::delete((int) $request_data['ad_id']); $error_msg = 19013; } catch (CNException $e) { $msg[] = $e->message; } } } else { if (!empty($request_data['action']) && !empty($request_data['ad_id'])) { $update = false; switch ($request_data['action']) { case 'disable': $field_value = DELETED; $msg_id = 19010; $update = true; break; case 'enable': $field_value = ACTIVE; $msg_id = 19011; $update = true; break; } if ($update) { $update_fields = array('is_active' => $field_value); $condition = array('ad_id' => $request_data['ad_id']); try { Advertisement::update($update_fields, $condition); $error_msg = $msg_id; } catch (CNException $e) { $msg[] = $e->message; } } } } } $advertisement = new Advertisement(); if (!$error && $request_method == 'POST' && $request_data['btn_apply_name']) { // if page is submitted if (!empty($request_data['ad_id'])) { $advertisement->ad_id = $request_data['ad_id']; $advertisement->created = $request_data['created']; $msg_id = 19007; } else { $msg_id = 19008; $advertisement->created = time(); } if (!empty($_FILES['ad_image']['name'])) { $filename = $_FILES['ad_image']['name']; $uploadfile = PA::$upload_path . basename($filename); $myUploadobj = new FileUploader(); $file = $myUploadobj->upload_file(PA::$upload_path, 'ad_image', TRUE, TRUE, 'image'); $advertisement->ad_image = $form_data['ad_image'] = $file; if ($file == FALSE) { $error = TRUE; $msg[] = $myUploadobj->error; } } else { if (!empty($request_data['ad_id'])) { $advertisement->ad_image = $request_data['edit_image']; } } if (empty($request_data['ad_url']) && empty($request_data['ad_script'])) { $error = TRUE; $msg[] = MessagesHandler::get_message(19012); } if (!empty($request_data['ad_url'])) { // if url is given then validate $request_data['ad_url'] = Validation::validate_url($request_data['ad_url']); if (!Validation::isValidURL($request_data['ad_url'])) { $error = TRUE; $msg[] = MessagesHandler::get_message(19009); } } $advertisement->user_id = PA::$login_uid; $advertisement->url = $form_data['ad_url'] = $request_data['ad_url']; $advertisement->ad_script = $form_data['ad_script'] = $request_data['ad_script']; $advertisement->title = $form_data['ad_title'] = $request_data['ad_title']; $advertisement->description = $form_data['ad_description'] = $request_data['ad_description']; $advertisement->page_id = $form_data['ad_page_id'] = $request_data['ad_page_id']; $advertisement->orientation = $form_data['orientation'] = $request_data['x_loc'] . ',' . $request_data['y_loc']; $advertisement->changed = time(); $advertisement->is_active = ACTIVE; if (!empty($_REQUEST['gid'])) { $advertisement->group_id = (int) $_REQUEST['gid']; } if (!$error) { try { $ad_id = $advertisement->save(); if (!empty($file)) { Storage::link($file, array("role" => "ad", "ad" => $ad_id)); } $error_msg = $msg_id; } catch (CNException $e) { $error_msg = $e->message; } } else { $error_msg = implode("<br/>", $msg); } } $this->form_data = $form_data; $this->edit = $edit; $this->message = $message; }
/** Purpose : this function is core funtion of this Navigation class. It is used to make links level_1,level_2,level_3 Some links need extra parameters append them here but first set them in their methods e.g. public function set_group_id($group_id){ $this->group_id = $group_id; } public function get_group_id() { return $this->group_id(); } Scope : public @param - it needs no direct input @return - it sets class variables level_1,level_2,level_3 which can be used further. **/ function make_links() { $user_id = isset($_SESSION['user']['id']) ? $_SESSION['user']['id'] : 0; ////These are level 1 links shown in top navigation bar $level_1 = array('home_network' => array('caption' => __('Return to home network'), 'url' => $this->mothership_info['url'])); // Display network directory, if network operation is enabled. if (PA::$network_capable) { $level_1['networks_directory'] = array('caption' => __('Network directory'), 'url' => $this->base_url . '/' . FILE_NETWORKS_HOME); } $owner = Network::is_admin($this->network_info->network_id, $user_id); //is_member will be true when user is registered member of the nework. $is_member = Network::member_exists($this->network_info->network_id, $this->get_uid()); if (!$this->is_anonymous && $this->network_info && !$is_member && $this->network_info->type != MOTHER_NETWORK_TYPE) { $level_1['join_network'] = array('caption' => __('JOIN Network'), 'url' => $this->base_url . '/' . FILE_NETWORK_ACTION . '?action=join&nid=' . $this->network_info->network_id . '&cid=' . $this->network_info->category_id); } else { if (!$this->is_anonymous && $is_member && !$owner && $this->network_info->type != MOTHER_NETWORK_TYPE) { $level_1['unjoin_network'] = array('caption' => __('Unjoin Network'), 'url' => $this->base_url . '/' . FILE_NETWORK_ACTION . '?action=leave&nid=' . $this->network_info->network_id . '&cid=' . $this->network_info->category_id); } else { if (Network::is_admin($this->network_info->network_id, (int) $user_id)) { $level_1['configure_network'] = array('caption' => __('Configure'), 'url' => $this->base_url . PA_ROUTE_CONFIGURE_NETWORK); } } } if ($this->network_info->type == MOTHER_NETWORK_TYPE) { unset($level_1['home_network']); } if (PA::$config->enable_network_spawning) { $level_1['create_network'] = array('caption' => __('Create a network'), 'url' => $this->mothership_info['extra']['links']['create_network']); } ////END OF These are level 1 links shown in top navigation bar ////These are level 2 links shown in second navigation bar $level_2 = array('home' => array('caption' => __('Home'), 'url' => $this->base_url . PA_ROUTE_HOME_PAGE), 'user' => array('caption' => __(PA::$mypage_noun), 'url' => $this->base_url . PA_ROUTE_USER_PRIVATE), 'people' => array('caption' => __(PA::$people_noun), 'url' => $this->base_url . PA_ROUTE_PEOPLES_PAGE), 'groups' => array('caption' => __(PA::$group_noun_plural), 'url' => $this->base_url . PA_ROUTE_GROUPS)); if (!empty(PA::$config->useTypedGroups)) { $level_2 = $level_2 + array('directory' => array('caption' => __('Orgs'), 'url' => $this->base_url . PA_ROUTE_TYPED_DIRECTORY)); if (!empty(PA::$config->simple['use_families'])) { $level_2 = $level_2 + array('families' => array('caption' => __('Neighbors'), 'url' => $this->base_url . PA_ROUTE_FAMILY_DIRECTORY)); } } $level_2 = $level_2 + array('forum' => array('caption' => __('Forum'), 'url' => $this->base_url . PA_ROUTE_FORUMS . "/network_id=" . $this->network_info->network_id), 'search' => array('caption' => __('Search'), 'url' => $this->base_url . PA_ROUTE_SEARCH_HOME . '/btn_searchContent=Search+Content')); ////END OF These are level 2 links shown in second navigation bar /// children of user 2nd level link $uid = $this->get_uid(); //we need uid for some links $user_children = array(); $user_children = $user_children + array('user_private' => array('caption' => __('My Page'), 'url' => $this->base_url . PA_ROUTE_USER_PRIVATE)); $user_children = $user_children + array('user_widgets' => array('caption' => __('My Widgets'), 'url' => $this->base_url . '/' . FILE_WIDGET)); $user_children = $user_children + array('messages' => array('caption' => __('My Messages'), 'url' => $this->base_url . PA_ROUTE_MYMESSAGE)); $user_children = $user_children + array('my_gallery' => array('caption' => __('My Gallery'), 'url' => $this->base_url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid={$uid}")); $user_children = $user_children + array('my_events' => array('caption' => __('My Events'), 'url' => $this->base_url . '/' . FILE_USER_CALENDAR), 'my_friends' => array('caption' => __('My Friends'), 'url' => $this->base_url . "/view_all_members.php?view_type=in_relations&uid={$uid}")); $user_children = $user_children + array('my_forum' => array('caption' => __('My Forum'), 'url' => $this->base_url . PA_ROUTE_FORUMS . "/network_id=" . $this->network_info->network_id . '&user_id=' . $uid)); $user_children = $user_children + array('my_points' => array('caption' => __('My Points'), 'url' => $this->base_url . PA_ROUTE_POINTS_DIRECTORY . "?uid={$uid}")); if (!empty(PA::$config->simple['use_families'])) { // get this users Family or Families require_once "api/Entity/TypedGroupEntityRelation.php"; $userfamilyRelations = TypedGroupEntityRelation::get_relation_for_user($uid, 'family'); if (count($userfamilyRelations) == 1) { $user_children = $user_children + array('my_family' => array('caption' => __('My Family'), 'url' => $this->base_url . PA_ROUTE_FAMILY . "?gid=" . $userfamilyRelations[0]->object_id)); } else { $html = "<ul>"; foreach ($userfamilyRelations as $i => $relation) { $group = ContentCollection::load_collection((int) $relation->object_id, PA::$login_uid); $html .= "<li>"; $html .= "<a href=\"" . $this->base_url . PA_ROUTE_FAMILY . "?gid=" . $relation->object_id . "\">" . $group->title . "</a>"; $html .= "</li>"; } $html .= "</ul>"; $user_children = $user_children + array('my_family' => array('caption' => __('My Families'), 'html' => $html)); } } // end of !empty(PA::$config->simple['use_families']) $user_children = $user_children + array('settings' => array('caption' => __('Edit My Account'), 'url' => $this->base_url . PA_ROUTE_EDIT_PROFILE)); $user_children = $user_children + array('customize_ui' => array('caption' => __('Themes'), 'url' => $this->base_url . PA_ROUTE_CUSTOMIZE_USER_GUI . "/theme/uid={$uid}")); if ($this->is_anonymous) { //these links are not for anonymous unset($user_children); } ///END OF children of user 2nd level link /// children of people 2nd level link //required friend id in some places $friend_id = $this->get_friend_uid(); $people_children = array('find_people' => array('caption' => sprintf(__('Find %s'), __(PA::$people_noun)), 'url' => $this->base_url . PA_ROUTE_PEOPLES_PAGE), 'my_friends' => array('caption' => __('My friends'), 'url' => $this->base_url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=relations&uid=' . $uid), 'friends_gallery' => array('caption' => __('Friends gallery'), 'url' => $this->base_url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid={$friend_id}&view=friends")); if ($this->is_anonymous) { //these links are not for anonymous unset($people_children); } ///EOF children of people 2nd level link $family_children = array('neighbors' => array('caption' => __("Neighbors"), 'url' => $this->base_url . PA_ROUTE_FAMILY_DIRECTORY), 'family_home' => array('caption' => __("Family Homepage"), 'url' => $this->base_url . PA_ROUTE_FAMILY . "/gid=" . $this->group_id), 'family_members' => array('caption' => __("Family Members"), 'url' => $this->base_url . PA_ROUTE_FAMILY_MEMBERS . "/gid=" . $this->group_id)); /// group general children // $users_first_group_id = $this->get_users_first_group_id(); $groups_general = array('find_groups' => array('caption' => sprintf(__('Find %s'), __(PA::$group_noun_plural)), 'url' => $this->base_url . PA_ROUTE_GROUPS), 'create_group' => array('caption' => __('Create'), 'url' => $this->base_url . '/' . FILE_ADDGROUP), 'invite' => array('caption' => __('Invite'), 'url' => $this->base_url . '/' . FILE_GROUP_INVITATION)); if ($this->is_anonymous) { //these links are not for anonymous unset($groups_general['create_group']); unset($groups_general['invite']); unset($groups_general['group_media_gallery']); } /// EOF group general children ///group specific menu children $gid = $group_id = $this->get_group_id(); $group_specific = array('group_home' => array('caption' => sprintf(__('%s Home'), __(PA::$group_noun)), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id), 'group_forum' => array('caption' => sprintf(__('%s Forum'), __(PA::$group_noun)), 'url' => $this->base_url . PA_ROUTE_FORUMS . "/network_id=" . $this->network_info->network_id . '&gid=' . $group_id), 'group_members' => array('caption' => sprintf(__('%s Members'), __(PA::$group_noun)), 'url' => $this->base_url . '/' . FILE_VIEW_ALL_MEMBERS . '?gid=' . $group_id), 'group_gallery' => array('caption' => sprintf(__('%s Gallery'), __(PA::$group_noun)), 'url' => $this->base_url . PA_ROUTE_MEDIA_GALLEY_IMAGES . '/view=groups_media&gid=' . $group_id), 'group_events' => array('caption' => sprintf(__('%s Events'), __(PA::$group_noun)), 'url' => $this->base_url . '/' . FILE_GROUP_CALENDAR . '?gid=' . $group_id)); $group_member = FALSE; $group_may_post = FALSE; $group_may_invite = FALSE; $group_moderator = FALSE; $group_manange_ads = FALSE; $group_owner = FALSE; if (PA::$login_uid) { if (Group::member_exists($gid, PA::$login_uid)) { $group_member = TRUE; // TODO: split this out to it's own perm check $group_may_post = TRUE; $group_may_invite = TRUE; } if (PermissionsHandler::can_group_user(PA::$login_uid, $gid, array('permissions' => 'manage_groups, manage_roles')) || Group::is_admin($gid, PA::$login_uid)) { $group_owner = TRUE; $group_moderator = TRUE; } else { if (PermissionsHandler::can_group_user(PA::$login_uid, $gid, array('permissions' => 'manage_groups'))) { $group_moderator = TRUE; } } // network level ad manager? $group_manange_ads = PermissionsHandler::can_user(PA::$login_uid, array('permissions' => 'manage_ads')); // check for manageads of group permissions if (!$group_manange_ads) { // we do this check only if the user is not already permitted to manage ads $group_manange_ads = PermissionsHandler::can_group_user(PA::$login_uid, $gid, array('permissions' => 'manage_ads')); } if ($group_may_invite) { $group_specific = array('invite' => array('caption' => __("Invite a Friend"), 'url' => PA::$url . PA_ROUTE_GROUP_INVITE . '/gid=' . $gid)) + $group_specific; } if ($group_may_post) { // member get's a 'Create Post' link on top $group_specific = array('create_post' => array('caption' => __("Create post"), 'url' => PA::$url . '/post_content.php?ccid=' . $gid)) + $group_specific; } // admin / owner if ($group_owner) { $group_specific = $group_specific + array('settings' => array('caption' => __("Group Settings"), 'url' => PA::$url . '/addgroup.php?gid=' . $gid), 'group_poll_select' => array('caption' => sprintf(__('%s Poll Select'), __(PA::$group_noun)), 'url' => $this->base_url . '/group_poll.php?gid=' . $group_id . '&type=select'), 'group_poll_create' => array('caption' => sprintf(__('%s Poll Create'), __(PA::$group_noun)), 'url' => $this->base_url . '/group_poll.php?gid=' . $group_id . '&type=create')); } // admin / moderator if ($group_moderator) { $group_specific = $group_specific + array('bulletin' => array('caption' => __("Group Bulletin"), 'url' => PA::$url . PA_ROUTE_GROUP_BULLETINS . '?gid=' . $gid), 'moderate' => array('caption' => __("Moderate"), 'url' => PA::$url . PA_ROUTE_GROUP_MODERATION . '/view=members&gid=' . $gid), 'manage_members' => array('caption' => __("Manage Content"), 'url' => PA::$url . '/manage_group_content.php?gid=' . $gid), 'group_customize_ui' => array('caption' => __('Group Appearance'), 'url' => $this->base_url . PA_ROUTE_CUSTOMIZE_GROUP_GUI . '/theme/gid=' . $group_id)); } // ads if ($group_manange_ads) { $group_specific = $group_specific + array('ads' => array('caption' => __("Manage Ads"), 'url' => PA::$url . PA_ROUTE_GROUP_AD_CENTER . '?gid=' . $gid)); } // the join/unjoin/delete go last if ($group_owner) { // only the owner can delete $group_specific = $group_specific + array('delete_group' => array('caption' => __('Delete'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/action=delete&gid=' . $group_id, 'extra' => ' onclick ="return delete_confirmation_msg(\'' . __('Are you sure you want to delete this group') . '?\') "')); } else { // anyone else if ($group_member) { $group_specific = $group_specific + array('unjoin' => array('caption' => __('Unjoin'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id . '&action=leave')); } else { $group_specific = $group_specific + array('join' => array('caption' => __('Join'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id . '&action=join')); } } } ///EOF group specific menu children /// children of group $groups_children = array('groups_general' => $groups_general, 'group_specific' => $group_specific); ///EOF children of group //for network option at 3 level $network = array('configure_network' => array('caption' => __('Configure'), 'url' => $this->base_url . PA_ROUTE_CONFIGURE_NETWORK)) + $level_2; $network_notify = array('email_notification' => array('caption' => __('Email Notification'), 'url' => $this->base_url . '/' . FILE_EMAIL_NOTIFICATION), 'network_bulletins' => array('caption' => __('Bulletins'), 'url' => $this->base_url . '/' . FILE_NETWORK_BULLETINS)); $network_setting = array('network_feature' => array('caption' => __('Set Feature Network'), 'url' => $this->base_url . '/' . FILE_NETWORK_FEATURE), 'manage_emblem' => array('caption' => __('Manage Emblem'), 'url' => $this->base_url . '/' . FILE_MANAGE_EMBLEM), 'manage_taketour' => array('caption' => __('Personalized Video'), 'url' => $this->base_url . '/' . FILE_MANAGE_TAKETOUR), 'splash_page' => array('caption' => __('Configure Splash Page'), 'url' => $this->base_url . '/' . FILE_CONFIGURE_SPLASH_PAGE), 'top_bar' => array('caption' => __('Top Bar Enable/Disable'), 'url' => '#')); $network_default = array('new_user_by_admin' => array('caption' => __('Create User'), 'url' => $this->base_url . '/' . FILE_NEW_USER_BY_ADMIN), 'user_defaults' => array('caption' => __('User Defaults'), 'url' => $this->base_url . '/' . FILE_NETWORK_USER_DEFAULTS), 'relationship_settings' => array('caption' => __('Relationships'), 'url' => $this->base_url . '/' . FILE_RELATIONSHIP_SETTINGS)); $manage_network = array('manage_user' => array('caption' => __('Manage Users'), 'url' => $this->base_url . '/' . FILE_NETWORK_MANAGE_USER), 'manage_content' => array('caption' => __('Manage Contents'), 'url' => $this->base_url . '/' . FILE_NETWORK_MANAGE_CONTENT), 'manage_links' => array('caption' => __('Manage Links'), 'url' => $this->base_url . '/' . FILE_NETWORK_LINKS)); $network_stats = array('statistics' => array('caption' => __('General'), 'url' => $this->base_url . PA_ROUTE_CONFIGURE_NETWORK), 'customize_ui' => array('caption' => __('Customize UI'), 'url' => $this->base_url . '/' . FILE_NETWORK_CUSTOMIZE_UI_PAGE)); $network_module_selector = array('home_page_id' => array('caption' => __('Home Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=home_page_id'), 'user_default_page_id' => array('caption' => __('User Default Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=user_default_page_id'), 'group_directory_page_id' => array('caption' => __('Group Directory Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=group_directory_page_id'), 'network_directory_page_id' => array('caption' => __('Network Directory Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=network_directory_page_id')); if ($this->network_info->type != MOTHER_NETWORK_TYPE) { unset($network['meta_network']); } if ($this->network_info->type != MOTHER_NETWORK_TYPE) { unset($network['manage_taketour']); unset($network['manage_emblem']); } //end /// second level menu for network $level_3 = array('user' => @$user_children, 'people' => @$people_children, 'family' => @$family_children, 'groups' => $groups_children, 'network' => $network, 'network_notify' => $network_notify, 'network_module_selector' => $network_module_selector, 'network_setting' => $network_setting, 'network_default' => $network_default, 'manage_network' => $manage_network, 'network_stats' => $network_stats); ///EOF second level menu children ///set level menu items $this->level_1 = $level_1; $this->level_2 = $level_2; $this->level_3 = $level_3; }
function __construct($cb, $page_id, $title, $page_template = "homepage_pa.tpl", $header_template = "header.tpl", $default_mode = PRI, $default_block_type = HOMEPAGE, $network_info_ = NULL, $onload = NULL, $setting_data = NULL) { global $app, $page; if (PA::$profiler) { PA::$profiler->startTimer('PageRenderer_init'); } // we may want to know the page_tpe elsewhere too PA::$config->page_type = $page_id; // NOTE: PA::$config->page_type var = $page_id and should be removed! $this->page_id = $page_id; $this->debugging = isset($_GET['debug']); $this->page_template = $page_template; $this->top_navigation_template = 'top_navigation_bar.tpl'; //TO DO: Remove this hardcoded text afterwards $this->header_template = $header_template; //settings for current network $this->network_info = $network_info_ ? $network_info_ : PA::$network_info; //FIXME: does this have to be a parameter? can't we just always use the global PA::$network_info? $this->module_arrays = array(); // the function hide_message_window is added here // so whenever html page is loaded the message window's ok button gets focus // here if previouly some function is defined as // onload = "ajax_call_method(ajax_titles, $uid, ajax_urls);" // now it will look like // onload = "ajax_call_method(ajax_titles, $uid, ajax_urls); hide_message_window();" $this->onload = "{$onload} hide_message_window('confirm_btn');"; $this->page_title = $title; $this->html_body_attributes = ""; // default settings for the tiers $this->main_tier = @$_GET['tier_one']; $this->second_tier = @$_GET['tier_two']; $this->third_tier = @$_GET['tier_three']; $navigation = new Navigation(); $this->navigation_links = $navigation->get_links(); $this->message_count = null; if (!isset(PA::$login_uid)) { PA::$login_uid = @$_SESSION['user']['id']; } if (PA::$login_uid) { $this->message_count = Message::get_new_msg_count(PA::$login_uid); } if (!isset($dynamic_page)) { $dynamic_page = new DynamicPage($this->page_id); if (!is_object($dynamic_page) or !$dynamic_page->docLoaded) { throw new Exception("Page XML config file for page ID: {$page_id} - not found!"); } $dynamic_page->initialize(); } if (false !== strpos($dynamic_page->page_type, 'group') && (!empty($_REQUEST['gid']) || !empty($_REQUEST['ccid']))) { // page is a group page - get group module settings $_gr_id = !empty($_REQUEST['gid']) ? $_REQUEST['gid'] : $_REQUEST['ccid']; $this->setting_data = ModuleSetting::load_setting($this->page_id, $_gr_id, 'group'); $this->page_template = $this->setting_data['page_template']; if (empty($this->setting_data['access_permission'])) { // no permissions required to access page $access_permission = true; } else { $access_permission = PermissionsHandler::can_group_user(PA::$login_uid, $_gr_id, array('permissions' => $this->setting_data['access_permission'])); } } else { if (false !== strpos($dynamic_page->page_type, 'user') && !empty(PA::$login_uid)) { // page is an user page - get user module settings // echo "POSTING TO USER PAGE"; die(); $this->setting_data = ModuleSetting::load_setting($this->page_id, PA::$login_uid, 'user'); $this->page_template = $this->setting_data['page_template']; if (empty($this->setting_data['access_permission'])) { // no permissions required to access page $access_permission = true; } else { $access_permission = PermissionsHandler::can_user(PA::$login_uid, array('permissions' => $this->setting_data['access_permission'])); } } else { // page is a network page - get network module settings $this->setting_data = ModuleSetting::load_setting($this->page_id, PA::$network_info->network_id, 'network'); $this->page_template = $this->setting_data['page_template']; if (empty($this->setting_data['access_permission'])) { // no permissions required to access page $access_permission = true; } else { $access_permission = PermissionsHandler::can_network_user(PA::$login_uid, PA::$network_info->network_id, array('permissions' => $this->setting_data['access_permission'])); } } } $this->page = new Template(CURRENT_THEME_FSPATH . "/" . $this->page_template); $this->page->set('current_theme_path', PA::$theme_url); $this->page->set('current_theme_rel_path', PA::$theme_rel); // Loading the templates variables for the Outer templates files $this->page->set('outer_class', get_class_name(PA::$config->page_type)); $this->top_navigation_bar = new Template(CURRENT_THEME_FSPATH . "/" . $this->top_navigation_template); $this->top_navigation_bar->set('current_theme_path', PA::$theme_url); $this->top_navigation_bar->set('current_theme_rel_path', PA::$theme_rel); $this->top_navigation_bar->set('navigation_links', $this->navigation_links); $this->setHeader($this->header_template); $this->footer = new Template(CURRENT_THEME_FSPATH . "/footer.tpl"); $this->footer->set('current_theme_path', PA::$theme_url); $this->footer->set('page_name', $title); $page = $this; $this->preInitialize($this->setting_data); $this->initNew($cb, $default_mode, $default_block_type, $this->setting_data); if (!$access_permission) { $configure = unserialize(ModuleData::get('configure')); if (PA::logged_in()) { $redir_url = PA::$url . PA_ROUTE_USER_PRIVATE; } else { if (!isset($configure['show_splash_page']) || $configure['show_splash_page'] == INACTIVE) { $redir_url = PA::$url . '/' . FILE_LOGIN; } else { $redir_url = PA::$url; } } $er_msg = urlencode("Sorry! you are not authorized to to access this page."); $this->showDialog($er_msg, $type = 'error', $redir_url, 10); } if (PA::$profiler) { PA::$profiler->stopTimer('PageRenderer_init'); } }
--> <option value=""> Select group blogs </option> <?php $var_groups = ""; for ($counter = 0; $counter < count($user_groups); $counter++) { $grp_id = $user_groups[$counter]['gid']; if ($grp_id == $ccid || in_array($grp_id, $existing_route_targets_group)) { $selected = "selected"; } else { $selected = ""; } $var_groups = $var_groups . $user_groups[$counter]['gid'] . ','; ?> <?php $permission_to_post = PermissionsHandler::can_group_user(PA::$login_uid, $user_groups[$counter]['gid'], array('permissions' => 'post_to_group')); if ($permission_to_post) { ?> <option value="<?php echo $user_groups[$counter]['gid']; ?> " <?php echo $selected; ?> ><?php echo chop_string(stripslashes($user_groups[$counter]['name']), NAME_LENGTH); ?> </option> <?php } ?>
* The lastest version of Cyberspace Networks CoreSystem can be obtained from: * http://developer.cyberspace-networks.com/ * For questions, help, comments, discussion, etc. please visit * https://github.com/CyberspaceNetworks/CoreSystem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ require_once "api/CNPermissions/CNPermissionsHandler.php"; require_once "web/includes/classes/CNTinyMCE.php"; $tiny = new CNTinyMCE('blog'); echo $tiny->installTinyMCE(); /* require_once "web/includes/tinymce.php"; install_tinymce('full'); */ if (!empty($_REQUEST['ccid'])) { $permission_to_upload = PermissionsHandler::can_group_user(PA::$login_uid, $_REQUEST['ccid'], array('permissions' => 'upload_images, upload_videos')); } else { $permission_to_upload = PermissionsHandler::can_network_user(PA::$login_uid, PA::$network_info->network_id, array('permissions' => 'upload_images, upload_videos')); } ?> <fieldset> <input id="blog_type" name="blog_type" type="hidden" value="<?php echo $blog_type == 'Suggestion' ? 'Suggestion' : 'CNBlogPost'; ?> " /> <input id="redirect" name="redirect" type="hidden" value="<?php echo urldecode(stripslashes($redirect)); ?> " /> <div class="field" > <label for="title"><span class="required"> * </span><b> <?php
/** * Saves Group data to database * @access public * @param int $user_id ID of the user trying to save */ public function save($user_id = NULL) { Logger::log('Enter: Group::save() | Args: \\$user_id = ' . $user_id); if (!empty($user_id)) { $this->author_id = $user_id; } if (empty($this->title)) { Logger::log('Exit: Group::save(). Title of the group is not specified.'); throw new PAException(GROUP_NAME_NOT_EXIST, 'Title of the group is not specified'); } if (!isset($this->access_type)) { Logger::log('Exit: Group::save(). Access type for the group is not specifed'); throw new PAException(GROUP_ACCESS_TYPE_NOT_EXIST, 'Access type for the group is not specifed'); } if (!isset($this->reg_type)) { Logger::log('Exit: Group::save(). User registration type is not specified for the group.'); throw new PAException(GROUP_REGISTRATION_TYPE_NOT_EXIST, 'User registration type is not specified for the group.'); } if (!isset($this->is_moderated)) { Logger::log('Exit: Group::save(). Moderation type is not specifed for the group.'); throw new PAException(GROUP_IS_MODERATED_NOT_EXIST, 'Moderation type is not specifed for the group.'); } if (!empty($this->extra)) { $this->extra = serialize($this->extra); } //if collection_id exists the update else insert if ($this->collection_id) { // $user_type = Group::get_user_type ($this->author_id, $this->collection_id); // $access = $this->acl_object->acl_check( 'action', 'edit', 'users', $user_type, 'group', 'all' ); $access = PermissionsHandler::can_group_user(Group::get_owner_id((int) $this->collection_id), $this->collection_id, array('permissions' => 'manage_groups')); if (!$access) { throw new PAException(OPERATION_NOT_PERMITTED, 'You are not authorized to edit this group.'); } $sql = "UPDATE {groups} SET access_type = ?, reg_type = ?, is_moderated = ?, category_id = ? , header_image = ? , header_image_action = ?, display_header_image = ?, group_type =?, extra=? WHERE group_id = ?"; try { $res = Dal::query($sql, array($this->access_type, $this->reg_type, $this->is_moderated, $this->category_id, $this->header_image, $this->header_image_action, $this->display_header_image, $this->group_type, @$this->extra, $this->collection_id)); parent::save(); } catch (Exception $e) { Dal::rollback(); throw $e; } } else { //only registered user can create a group // This already has been taken care via session // we can add further modification if not use session user_id try { parent::save(); $sql = "INSERT INTO {groups} (group_id, access_type, reg_type, is_moderated, category_id, header_image, header_image_action, display_header_image, group_type, extra) VALUES (?, ?, ?, ?, ?,?,?,?, ?, ?)"; $data = array($this->collection_id, $this->access_type, $this->reg_type, $this->is_moderated, $this->category_id, $this->header_image, $this->header_image_action, $this->display_header_image, $this->group_type, @$this->extra); $res = Dal::query($sql, $data); $this->created = time(); $sql = "INSERT INTO {groups_users} (group_id, user_id, user_type, created) VALUES (?, ?, ?, ?)"; $res = Dal::query($sql, array($this->collection_id, $this->author_id, OWNER, $this->created)); foreach ($this->moderators as $mod) { $sql = "INSERT INTO {groups_users} (group_id, user_id, user_type, created) VALUES (?, ?, ?, ?)"; $res = Dal::query($sql, array($this->collection_id, $mod, MODERATOR, $this->created)); } Dal::commit(); // setup extra permissions for group owner // so, we need to assign group admin role to group owner now: $role_extra = array('user' => false, 'network' => false, 'groups' => array($this->collection_id)); $user_roles[] = array('role_id' => GROUP_ADMIN_ROLE, 'extra' => serialize($role_extra)); $group_owner = new User(); $group_owner->load($this->author_id); $group_owner->set_user_role($user_roles); } catch (Exception $e) { Dal::rollback(); throw $e; } } Logger::log("Exit: Group::save()"); return $this->collection_id; }
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(); } } } }