コード例 #1
0
 public function editAction($dealerId = NULL)
 {
     $this->view->setVar("title", "Редагування дилера");
     $user = $this->session->get("user");
     $methodistBrands = \BrandsMethodists::find("user_id=" . $user->id)->toArray();
     $methodistActivities = \ActivitiesMethodists::find("user_id=" . $user->id)->toArray();
     $dealer = $dealerId ? \Dealers::findFirst($dealerId) : new \Dealers();
     if ($dealerId and !$dealer->id) {
         // не найден такой диллер
         $this->view->pick("dealer/not-found");
         return;
     }
     $city = $dealer->City;
     $this->view->regionId = $city ? $city->Region->id : NULL;
     $dealerBrands = $dealer->id ? $dealer->DealersBrands->toArray() : array();
     $dealerActivities = $dealer->id ? \DealersActivities::find("dealer_id=" . $dealer->id)->toArray() : array();
     $this->view->dealers = \Dealers::find(array('order' => 'title'));
     $this->view->regions = \Region::find();
     $this->view->regionFirst = $this->view->regions[0];
     $this->view->cities = \City::find();
     $this->view->staffListGroup = \StafflistGroup::find();
     $this->view->brands = BrandsService::getForChosenEntity(\Brands::find()->toArray(), $methodistBrands, $dealerBrands);
     $this->view->activities = ActivitiesService::getForChosenEntity(\Activities::find()->toArray(), $methodistActivities, $dealerActivities);
     $this->view->dealerStatuses = \DealerStatuses::find();
     $controllers = \Users::query()->rightJoin("UserGroups")->where("UserGroups.group_id = 3")->execute();
     $this->view->controllers = $controllers;
     $this->view->dealerControllers = $dealer->DealersControllers;
     $this->view->dealer = $dealer;
     $this->view->saved = $this->request->get("saved");
 }
コード例 #2
0
 function addnewAction($system_id)
 {
     $system = Systems::findFirstById($system_id);
     $last_version_date = Versions::last_version_date();
     $last_version = Versions::last_version();
     $activities = Activities::find(array("date > '{$last_version_date}' "));
     $form = new VersionsForm();
     $this->view->system = $system;
     $this->view->last_version_date = $last_version_date;
     $this->view->last_version = $last_version;
     $this->view->activities = $activities;
     $this->view->form = $form;
 }
コード例 #3
0
 function initializeModule($request_method, $request_data)
 {
     global $error_msg;
     if ($this->column == 'middle') {
         $this->page_size = 10;
         $this->page = !empty($request_data['page']) ? $request_data['page'] : 0;
         $this->title = PA::$network_info->name . ' ' . __('Leader Board');
         $this->outer_template = 'outer_public_center_module.tpl';
         $this->set_inner_template('module_middle.tpl.php');
     } else {
         $this->page = 0;
         $this->title = __('Leader Board');
         $this->page_size = 5;
         $this->outer_template = 'outer_public_side_module.tpl';
         $this->set_inner_template('module_default.tpl.php');
         $this->view_all_url = PA::$url . PA_ROUTE_LEADER_BOARD;
     }
     $pagination_links = null;
     $users_ranking = array();
     $act = array();
     $users_counter_increment = 0;
     $nb_items = UserPopularity::countUserPopularity();
     if ($nb_items > 0) {
         $rankings = UserPopularity::listUserPopularity(null, 'popularity', 'DESC');
         $max_rank = $rankings[0]->get_popularity();
         $pagination = UserPopularity::getPagging($rankings, $this->page_size, $this->page);
         $page_items = $pagination->getPageItems();
         foreach ($page_items as $idx => $item) {
             try {
                 $user = new User();
                 $user->load((int) $item->get_user_id());
                 $user_generaldata = User::load_user_profile($item->get_user_id(), PA::$login_uid, GENERAL);
                 $user->profile_info = sanitize_user_data($user_generaldata);
                 $user->ranking_points = $item->get_popularity();
                 $user->ranking_stars = intval($user->ranking_points * 5 / $max_rank);
                 $user->last_activity = $item->get_time();
                 $users_ranking[$idx] = $user;
                 // Grab the recent activities of the user
                 $act[$idx] = Activities::get_activities(array("limit" => 3), array("subject" => $item->get_user_id(), "status" => "new"));
             } catch (Exception $e) {
                 $error_msg = "Exception in LeaderBoardModule, message: <br />" . $e->getMessage();
                 return 'skip';
             }
         }
         $pagination_links = $pagination->getPaggingLinks(PA::$url . PA_ROUTE_LEADER_BOARD, 'page', 'pagging', 'pagging_selected');
         $users_counter_increment = $this->page_size * $this->page;
     }
     $this->inner_HTML = $this->generate_inner_html(array('page_id' => $this->page_id, 'users_ranking' => $users_ranking, 'pagination_links' => $pagination_links, 'increment' => $users_counter_increment, 'activities' => $act));
 }
コード例 #4
0
ファイル: rpc_activity_hook.php プロジェクト: rair/yacs
 /**
  * add one activity record
  *
  * @param array e.g., array('anchor' => 'article:123', 'action' => 'edit')
  * @return mixed some error array, or 'OK'
  */
 function post($parameters)
 {
     global $context;
     // look for an anchor
     if (empty($parameters['anchor'])) {
         return array('code' => -32602, 'message' => 'Invalid param "anchor"');
     }
     // look for an action
     if (empty($parameters['action'])) {
         return array('code' => -32602, 'message' => 'Invalid param "action"');
     }
     // save this in the database
     Activities::post($parameters['anchor'], $parameters['action']);
     // done
     return 'OK';
 }
コード例 #5
0
 function generate_inner_html()
 {
     switch (@$this->page_type) {
         case 'user_personal':
             $tmp_file = dirname(__FILE__) . '/side_inner_public.tpl';
             $this->title = 'Recent in system';
             $params = array();
             $params['limit'] = 5;
             $list = Activities::get_activities($params);
             break;
         default:
             $list = array();
             $tmp_file = dirname(__FILE__) . '/side_inner_public.tpl';
             break;
     }
     $inner_html_gen =& new Template($tmp_file);
     $inner_html_gen->set('list', $list);
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }
コード例 #6
0
 function render()
 {
     if (empty(PA::$login_user->user_id)) {
         return '';
     }
     // login required
     $params = array();
     $params['limit'] = $this->show;
     switch ($this->view) {
         case 'user':
             if ($this->uid != PA::$login_user->user_id) {
                 return "";
                 // no display in this case
             }
             // get relations, we are only interested in Activities for Friends
             $this->relations = array();
             $this->relations[] = '-1';
             // add one bogus to workaround empty array issue in Activities
             // it would otherwise return ALL activities, unfiltered
             $relations = Relation::get_all_relations((int) $this->uid);
             foreach ($relations as $i => $rel) {
                 if ($rel['status'] != PENDING) {
                     $this->relations[] = $relations[$i]['user_id'];
                 }
             }
             $params['relation_ids'] = $this->relations;
             break;
         default:
             break;
     }
     $this->activities = Activities::get_activities($params);
     $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;
 }
コード例 #7
0
function route2groups()
{
    global $user, $is_edit;
    $extra = unserialize(PA::$network_info->extra);
    $tags = preg_split('/\\s*,\\s*/', strtolower($_POST['tags']));
    $tags = array_unique($tags);
    $net_owner = new User();
    $net_owner->load((int) PA::$network_info->owner_id);
    $valid_post_types = array('BlogPost', 'Contribution', 'Suggestion');
    $type = isset($_POST) && isset($_POST['blog_type']) && in_array($_POST['blog_type'], $valid_post_types) ? $_POST['blog_type'] : 'BlogPost';
    //find tag entry
    $terms = array();
    foreach ($tags as $term) {
        $tr = trim($term);
        if ($tr) {
            $terms[] = $tr;
        }
    }
    if (!empty($_POST['route_to_pa_home']) && $_POST['route_to_pa_home'] == 1) {
        $display_on_homepage = DISPLAY_ON_HOMEPAGE;
        //its zero
    } else {
        $display_on_homepage = NO_DISPLAY_ON_HOMEPAGE;
        //This will not show up on homepage - flag has opposite values
    }
    if (is_array($_POST['route_targets_group'])) {
        if (in_array(-2, $_POST['route_targets_group'])) {
            //-2 means Select none of group
            // no need to post in any group
        } elseif (in_array(-1, $_POST['route_targets_group'])) {
            //-1 means select all the groups
            // post in all the groups
            $group_array = explode(',', $_POST['Allgroups']);
            foreach ($group_array as $gid) {
                // post to all the groups
                $_group = Group::load_group_by_id((int) $gid);
                $login_required_str = null;
                if ($_group->access_type == ACCESS_PRIVATE) {
                    $login_required_str = '&login_required=true';
                }
                switch ($type) {
                    case 'BlogPost':
                    default:
                        $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Contribution':
                        $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Suggestion':
                        $res = Suggetion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                }
                $permalink_cid = $res['cid'];
                // NOTE: would this notification message be sent for each group ???
                $content_obj = Content::load_content((int) $permalink_cid);
                PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
                // notify network owner (maybe group owner would be better?)
                if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
                    PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
                }
                //-------
                //for rivers of people
                $activity = 'group_post_a_blog';
                $activity_extra['info'] = $user->first_name . 'posted a new blog';
                $activity_extra['blog_name'] = $_POST["blog_title"];
                $activity_extra['blog_id'] = $permalink_cid;
                $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
                $extra = serialize($activity_extra);
                $object = $gid;
                // update status to unverified
                $group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
                if ($group->reg_type == REG_MODERATED) {
                    Network::moderate_network_content((int) $gid, $permalink_cid);
                } else {
                    if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
                        Network::moderate_network_content($gid, $permalink_cid);
                    }
                }
                if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
                    //Write to activity log only when moderation is off
                    Activities::save($user->user_id, $activity, $object, $extra);
                }
            }
        } else {
            // post in selected groups
            foreach ($_POST['route_targets_group'] as $gid) {
                //only send to selected groups
                $_group = Group::load_group_by_id((int) $gid);
                $login_required_str = null;
                if ($_group->access_type == ACCESS_PRIVATE) {
                    $login_required_str = '&login_required=true';
                }
                switch ($type) {
                    case 'BlogPost':
                    default:
                        $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Contribution':
                        $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Suggestion':
                        $res = Suggestion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                }
                $permalink_cid = $res['cid'];
                $content_obj = Content::load_content((int) $permalink_cid);
                PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
                // notify network owner (maybe group owner would be better?)
                if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
                    PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
                }
                //for rivers of people
                $activity = 'group_post_a_blog';
                $activity_extra['info'] = $user->first_name . 'posted a new blog';
                $activity_extra['blog_name'] = $_POST["blog_title"];
                $activity_extra['blog_id'] = $permalink_cid;
                $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
                $extra = serialize($activity_extra);
                $object = $gid;
                // update status to unverified
                $group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
                if ($group->reg_type == REG_MODERATED) {
                    Network::moderate_network_content((int) $gid, $permalink_cid);
                } else {
                    if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
                        Network::moderate_network_content($gid, $permalink_cid);
                    }
                }
                if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
                    //Write to activity log only when moderation is off
                    Activities::save($user->user_id, $activity, $object, $extra);
                }
            }
        }
    }
    return TRUE;
}
コード例 #8
0
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a video in group id =' . $_GET['gid'];
            break;
        case 'Audios':
            $activity = 'group_audio_upload';
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a audio in group id =' . $_GET['gid'];
            break;
        default:
            break;
    }
    $activities_extra['collection_id'] = $upload[collection_id];
    $activities_extra['content_id'] = $upload[content_id];
    $extra = serialize($activities_extra);
    $object = $_GET['gid'];
    Activities::save($login_uid, $activity, $object, $extra, $activities_array);
}
// Code for Re-Direction  After Successfull deletion
if (!empty($success_delete) || !empty($success)) {
    $gid = $_GET['gid'];
    $type = $_GET['type'];
    $location = "{$base_url}/group_media_gallery.php?type={$type}&msg_id={$msg_id}&gid={$gid}";
    header("Location: {$location}");
    exit;
}
$setting_data = array('middle' => array('UploadMediaModule'));
/* This function is a Callback function which initialize the value for the BLOCK MODULES */
function setup_module($column, $moduleName, $obj)
{
    /* in this module we have to set user_id , group_id, as well as netwrok_id */
    global $uid, $type, $album_id;
コード例 #9
0
    $permission = TRUE;
    $user_id = $_SESSION['user']['id'];
    $location = $base_url . '/homepage.php';
} else {
    if (!($user_id = $_GET['uid'])) {
        $location .= '?msg=7005';
    }
}
if ($user_id && $permission) {
    $message_array = array();
    if ($network_info->type == MOTHER_NETWORK_TYPE) {
        //user delete for SU
        //deleting user data from mothership
        try {
            User::delete_user($user_id);
            Activities::delete_for_user($user_id);
        } catch (PAException $e) {
            $message_array[] = $e->message;
        }
        $user_networks = Network::get_user_networks($user_id);
        if (count($user_networks)) {
            foreach ($user_networks as $network) {
                if ($network->user_type != NETWORK_OWNER) {
                    $network_prefix = $network->address;
                    try {
                        User::delete_user($user_id);
                        Network::leave($network->network_id, $user_id);
                        //leave
                    } catch (PAException $e) {
                        $message_array[] = $e->message;
                    }
コード例 #10
0
 function editAction($activity_id, $system_id)
 {
     $activity = Activities::findFirstById($activity_id);
     $system = Systems::findFirstById($system_id);
     $form = new ActivityForm($activity);
     $bugs_id = new Select('bugs_id', Bugs::find(), array('useEmpty' => true));
     $bugs_id->setLabel('Select Bugs');
     $bugs_id->setDefault(array($activity->bugs_id));
     $array = [];
     foreach (Bugs::find(array('system_id = ' . $system_id)) as $bug) {
         if ($bug->modules_id) {
             $modules_name = '[' . $bug->modules->name . '] - ';
         } else {
             $modules_name = '';
         }
         $array[$bug->id] = $modules_name . ' ' . $bug->description;
     }
     $bugs_id->setOptions($array);
     $form->add($bugs_id);
     /*=======  Modules  =======*/
     $modulesId = new Select('modules_id', Modules::find(array('system_id = ' . $system_id)), array('using' => array('id', 'name'), 'useEmpty' => true));
     $modulesId->setLabel('Select Modules');
     $modulesId->setDefault(array($activity->modules_id));
     $form->add($modulesId);
     $this->view->activity = $activity;
     $this->view->system = $system;
     $this->view->page = 'Modules';
     $this->view->form = $form;
     if ($this->request->isPost()) {
         $activities = new Activities();
         $activity_id = $this->request->getPost('id');
         $activities = Activities::find($activity_id);
         if ($activities->update($this->request->getPost()) == false) {
             foreach ($activities->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Edit Activity Success');
             $this->response->redirect('activity/system/' . $system_id);
         }
     }
 }
コード例 #11
0
/**
 * @author   Z.Hron
 * @name     delete_users
 * @brief    This function delete array of users
 * @return   array of error messages
 *
 *
 */
function delete_users($params, $true_delete = FALSE)
{
    $message_array = array();
    $user_id_array = $params['user_id_array'];
    foreach ($user_id_array as $user_id) {
        if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
            if (!Network::member_exists(PA::$network_info->network_id, (int) $user_id)) {
                $message_array[] = "UserID {$user_id} does not exists.";
                continue;
            }
            //deleting user data from mothership
            try {
                User::delete_user($user_id);
                Activities::delete_for_user($user_id);
            } catch (CNException $e) {
                $message_array[] = $e->message;
            }
            $user_networks = Network::get_user_networks($user_id);
            if (count($user_networks)) {
                foreach ($user_networks as $network) {
                    if ($network->user_type != NETWORK_OWNER) {
                        $network_prefix = $network->address;
                        try {
                            User::delete_user($user_id);
                            Activities::delete_for_user($user_id);
                            Network::leave($network->network_id, $user_id);
                            //leave
                        } catch (CNException $e) {
                            $message_array[] = $e->message;
                        }
                    } else {
                        try {
                            Network::delete($network->network_id);
                        } catch (CNException $e) {
                            $message_array[] = $e->message;
                        }
                    }
                }
            }
            //deleting user
            try {
                User::delete($user_id, $true_delete);
            } catch (CNException $e) {
                Logger::log('User has been already deleted');
            }
        } else {
            //user delete for network owner
            if (!Network::member_exists(PA::$network_info->network_id, (int) $user_id)) {
                $message_array[] = "UserID {$user_id} does not exists.";
                continue;
            }
            $network_prefix = PA::$network_info->address;
            try {
                User::delete_user($user_id);
                Activities::delete_for_user($user_id);
                Network::leave(PA::$network_info->network_id, $user_id);
                //network leave
            } catch (CNException $e) {
                $message_array[] = $e->message;
            }
        }
    }
    return $message_array;
}
コード例 #12
0
 /** !!
  * Called by web/dynamic.php, which does the page generation.
  *
  * @param string $request_method Not used. But here for standards.
  * @param array $request_data POST data to save.
  */
 public function handleRequest($request_method, $request_data)
 {
     $msg = NULL;
     $action = isset($request_data['do']) ? $request_data['do'] : NULL;
     if ($action == 'delete') {
         $this->delete_id = $this->relation_uid;
         Relation::delete_relation($this->uid, $this->delete_id, PA::$network_info->network_id);
         $this->cache_id = 'relation_private_' . $this->uid;
         CachedTemplate::invalidate_cache($this->cache_id);
         $this->cache_id = 'relation_public_' . $this->uid;
         CachedTemplate::invalidate_cache($this->cache_id);
         // invalidate cache of user who is being added in relation module
         $this->cache_id = 'in_relation_private_' . $this->delete_id;
         CachedTemplate::invalidate_cache($this->cache_id);
         $this->cache_id = 'in_relation_public_' . $this->delete_id;
         CachedTemplate::invalidate_cache($this->cache_id);
         header('Location:' . PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $this->delete_id . '&delete=1');
     }
     //getting relations of logged in user
     $this->all_relations = Relation::get_all_relations((int) $this->uid);
     $this->relationship_level = 2;
     //default relation level id is 2 for friend
     foreach ($this->all_relations as $relation) {
         if ($this->relation_uid == $relation['user_id']) {
             $this->relationship_level = $relation['relation_type_id'];
             $this->in_family = $relation['in_family'];
             $this->status = $relation['status'];
             if ($this->status == PENDING) {
                 if (PA::$extra['reciprocated_relationship'] == NET_YES && $action == 'add') {
                     $msg = sprintf(__('Your request for adding %s as a relation has already been sent'), $relation['display_name']);
                 }
             }
         }
     }
     try {
         $this->user->load((int) $this->relation_uid);
         $this->title = __('Edit Relationship') . ' - ' . $this->user->display_name;
         //title of the web page
         //picture and login relation
         $this->relation_picture = $this->user->picture;
         $this->login_name = $this->user->login_name;
         $this->display_name = $this->user->display_name;
     } catch (PAException $e) {
         $mesg = $e->message;
         $this->is_error = TRUE;
     }
     if (isset($request_data['submit'])) {
         $this->rel_creater = PA::$user;
         $this->relationship_level = $request_data['level'];
         if (PA::$extra['reciprocated_relationship'] == NET_YES) {
             if (Relation::getRelationData($this->relation_uid, $this->uid, PA::$network_info->network_id)) {
                 Relation::update_relation_status($this->relation_uid, $this->uid, APPROVED, PA::$network_info->network_id);
                 Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED);
                 $relation_obj = Relation::getRelationData($this->relation_uid, $this->uid, PA::$network_info->network_id);
                 PANotify::send("reciprocated_relation_estab", PA::$network_info, PA::$login_user, $relation_obj);
                 // recipient is network owner
                 $location = PA_ROUTE_USER_PRIVATE . '/msg=' . urlencode(__("The relationship request was approved."));
                 header('Location:' . PA::$url . $location);
                 exit;
             }
             $this->status = PENDING;
         } else {
             $this->status = APPROVED;
         }
         try {
             $this->relation = Relation::get_relation($this->rel_creater->user_id, $this->relation_uid, PA::$network_info->network_id);
             $this->edit = $this->relation ? TRUE : FALSE;
         } catch (PAException $e) {
             $this->edit = FALSE;
         }
         try {
             if (isset($request_data['in_family'])) {
                 // If the user has checked the in_family checkbox.
                 Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, $this->status);
             } else {
                 Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, NULL, $this->status);
             }
             $this->user = PA::$user;
             // relationship establisher image
             $relation_obj = Relation::getRelationData($this->uid, $this->relation_uid, PA::$network_info->network_id);
             if ($this->edit == FALSE) {
                 if (PA::$extra['reciprocated_relationship'] == NET_YES) {
                     PANotify::send("friend_request_sent", PA::$user, PA::$login_user, $relation_obj);
                 } else {
                     PANotify::send("relation_added", PA::$network_info, PA::$login_user, $relation_obj);
                     // recipient is network owner
                     PANotify::send("relationship_created_with_other_member", PA::$user, PA::$login_user, $relation_obj);
                     //for rivers of people
                     $activity = 'user_friend_added';
                     //for rivers of people
                     $activities_extra['info'] = $this->display_name . ' added new friend with id =' . $request_data['uid'];
                     $extra = serialize($activities_extra);
                     $object = $this->relation_uid;
                     Activities::save(PA::$login_uid, $activity, $object, $extra);
                 }
             }
             //invalidate cache of logged in user's relation module
             $this->cache_id = 'relation_private_' . $this->uid;
             CachedTemplate::invalidate_cache($this->cache_id);
             $this->cache_id = 'relation_public_' . $this->uid;
             CachedTemplate::invalidate_cache($this->cache_id);
             // invalidate cache of user who is being added in relation module
             $this->cache_id = 'in_relation_private_' . $this->relation_uid;
             CachedTemplate::invalidate_cache($this->cache_id);
             $this->cache_id = 'in_relation_public_' . $this->relation_uid;
             CachedTemplate::invalidate_cache($this->cache_id);
             if (PA::$extra['reciprocated_relationship'] == NET_NO) {
                 if ($request_data['do']) {
                     $location = PA_ROUTE_USER_PUBLIC . '/' . $this->relation_uid . "&msg=" . urlencode(__("Relationship estabilished."));
                 }
             } else {
                 $location = PA_ROUTE_USER_PRIVATE . '/msg_id=' . urlencode(__("Your request has been sent for approval"));
             }
             header('Location:' . PA::$url . $location);
         } catch (PAException $e) {
             $message = $e->message;
         }
     }
     $msg_array = array();
     $msg_array['failure_msg'] = $msg;
     $msg_array['success_msg'] = NULL;
     $redirect_url = NULL;
     $query_str = NULL;
     set_web_variables($msg_array, $redirect_url, $query_str);
 }
コード例 #13
0
 /** !!
  * This generates the page specific html to be passed on to the render function.
  * It uses the standard templates to achieve this. It also determines the
  * type of activity that each data is, depending on what type of page
  * it is and the type of activity being reported.
  *
  * @return string $inner_html  The aforementioned page specific html
  */
 function generate_inner_html()
 {
     $params = array('limit' => $this->limit);
     $conditions = array();
     switch ($this->page_type) {
         case 'group':
             $params['activity_type'] = array('group_joined', 'group_image_upload', 'group_video_upload', 'group_audio_upload', 'group_post_a_blog', 'group_settings_updated');
             $conditions['object'] = $this->subject;
             $this->selected = 1;
             break;
         case 'user_public':
             $conditions['subject'] = $this->subject;
             $this->selected = 3;
             break;
         case 'user_private':
         case 'user_friends':
             $params['relation_ids'] = Relation::get_relations(PA::$login_uid, APPROVED, PA::$network_info->network_id);
             if (count($params['relation_ids']) == 0) {
                 $this->do_skip = TRUE;
                 return '<div style="margin:8px">No Feeds</div>';
             }
             $this->selected = 2;
             break;
     }
     $conditions['status'] = 'new';
     $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/side_inner_public.tpl';
     $inner_html_gen = new Template($tmp_file);
     $list = Activities::get_activities($params, $conditions);
     if (empty($list)) {
         $this->do_skip = TRUE;
         return '<div style="margin:8px">No Feeds</div>';
     }
     $inner_html_gen->set('list', $list);
     $inner_html_gen->set('options', $this->sel_options);
     $inner_html_gen->set('selected_option', $this->selected);
     $inner_html_gen->set('ajax_url', $this->ajax_url);
     $inner_html_gen->set('block_name', $this->html_block_id);
     $inner_html_gen->set('request_method', $this->request_method);
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }
コード例 #14
0
 function render_for_ajax()
 {
     $op = $this->params["op"];
     // if (empty(PA::$login_user) && $op != "paging") return __("Login required");
     switch ($op) {
         case "flagthis":
             if (empty(PA::$login_user)) {
                 $this->err = __("Please log in or register to flag a review!");
                 break;
             }
             // file the abuse report
             try {
                 list($foo, $review_id) = split(':', $this->params['flag']);
                 $abuse_obj = new ReportAbuse();
                 $abuse_obj->parent_type = 'review';
                 $abuse_obj->parent_id = $review_id;
                 $abuse_obj->reporter_id = PA::$login_uid;
                 // TODO: possibly make this user input
                 $abuse_obj->body = "This review was flagged.";
                 $id = $abuse_obj->save();
                 $this->note = "Your abuse report was filed.";
             } catch (PAException $e) {
                 $this->err = __("There was a problem flagging this review: ") . $e->message;
             }
             break;
         case "add_review":
             do {
                 if (empty(PA::$login_user)) {
                     $this->err = __("Please log in or register to add a review!");
                     break;
                 }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = __("Please enter a review!");
                     break;
                 }
                 // validation done - now save the review
                 $rev = new Review();
                 $rev->author_id = PA::$login_user->user_id;
                 $rev->subject_type = $this->params["subject_type"];
                 $rev->subject_id = $this->params["subject_id"];
                 $rev->title = "";
                 // $title;
                 $rev->body = $body;
                 if (!$rev->save()) {
                     $this->err = __("Save failed.");
                     break;
                 }
                 $this->note = __("Review added - thank you for participating!");
                 // handle tags
                 $tags = trim($this->params["tags"]);
                 if (!empty($tags)) {
                     $tags_array = preg_split('/\\s*,\\s*/', $tags);
                     ItemTags::save_tags_for_item(PA::$login_user->user_id, $this->params["subject_type"], $this->params["subject_id"], $tags_array);
                 }
                 // for rivers of people
                 $activity = 'user_post_a_review';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a review.', 'subject_type' => $rev->subject_type, 'subject_id' => $rev->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } while (0);
             break;
         default:
             // just ignore unknown ops
             break;
     }
     return $this->render();
 }
コード例 #15
0
    if (!empty($_GET['action']) && $_GET['action'] == 'delete') {
        $gid = (int) $_GET['gid'];
        $group = ContentCollection::load_collection((int) $gid, $login_uid);
        $group->delete();
        //Deleting all the activities of this group from activities table for rivers of people module
        Activities::delete_for_group($gid);
        $message = "Group deleted successfully";
    }
    if (!empty($_POST['gid'])) {
        $group_ids = $_POST['gid'];
        $cnt = count($group_ids);
        for ($i = 0; $i < $cnt; $i++) {
            $group = ContentCollection::load_collection((int) $group_ids[$i], $login_uid);
            $group->delete();
            //Deleting all the activities of this group from activities table for rivers of people module
            Activities::delete_for_group($group_ids[$i]);
        }
        $msg = uihelper_plural($cnt, 'group');
        $message = $msg . " deleted successfully";
    }
}
function setup_module($column, $module, $obj)
{
    global $configure_permission;
    switch ($module) {
        case 'ManageGroupsModule':
            if (!$configure_permission) {
                return 'skip';
            }
    }
}
コード例 #16
0
ファイル: files.php プロジェクト: rair/yacs
 /**
  * process uploaded file
  *
  * This function processes files from the temporary directory, and put them at their definitive
  * place.
  *
  * It returns FALSE if there is a disk error, or if some virus has been detected, or if
  * the operation fails for some other reason (e.g., file size).
  *
  * @param array usually, $_FILES['upload']
  * @param string target location for the file
  * @param mixed reference to the target anchor, of a function to parse every file individually
  * @return mixed file name or array of file names or FALSE if an error has occured
  */
 public static function upload($input, $file_path, $target = NULL, $overlay = NULL)
 {
     global $context, $_REQUEST;
     // size exceeds php.ini settings -- UPLOAD_ERR_INI_SIZE
     if (isset($input['error']) && $input['error'] == 1) {
         Logger::error(i18n::s('The size of this file is over limit.'));
     } elseif (isset($input['error']) && $input['error'] == 2) {
         Logger::error(i18n::s('The size of this file is over limit.'));
     } elseif (isset($input['error']) && $input['error'] == 3) {
         Logger::error(i18n::s('No file has been transmitted.'));
     } elseif (isset($input['error']) && $input['error'] == 4) {
         Logger::error(i18n::s('No file has been transmitted.'));
     } elseif (!$input['size']) {
         Logger::error(i18n::s('No file has been transmitted.'));
     }
     // do we have a file?
     if (!isset($input['name']) || !$input['name'] || $input['name'] == 'none') {
         return FALSE;
     }
     // access the temporary uploaded file
     $file_upload = $input['tmp_name'];
     // $_FILES transcoding to utf8 is not automatic
     $input['name'] = utf8::encode($input['name']);
     // enhance file name
     $file_name = $input['name'];
     $file_extension = '';
     $position = strrpos($input['name'], '.');
     if ($position !== FALSE) {
         $file_name = substr($input['name'], 0, $position);
         $file_extension = strtolower(substr($input['name'], $position + 1));
     }
     $input['name'] = $file_name;
     if ($file_extension) {
         $input['name'] .= '.' . $file_extension;
     }
     // ensure we have a file name
     $file_name = utf8::to_ascii($input['name']);
     // uploads are not allowed
     if (!Surfer::may_upload()) {
         Logger::error(i18n::s('You are not allowed to perform this operation.'));
     } elseif (!Files::is_authorized($input['name'])) {
         Logger::error(i18n::s('This type of file is not allowed.'));
     } elseif ($file_path && !Safe::is_uploaded_file($file_upload)) {
         Logger::error(i18n::s('Possible file attack.'));
     } else {
         // create folders
         if ($file_path) {
             Safe::make_path($file_path);
         }
         // sanity check
         if ($file_path && $file_path[strlen($file_path) - 1] != '/') {
             $file_path .= '/';
         }
         // move the uploaded file
         if ($file_path && !Safe::move_uploaded_file($file_upload, $context['path_to_root'] . $file_path . $file_name)) {
             Logger::error(sprintf(i18n::s('Impossible to move the upload file to %s.'), $file_path . $file_name));
         } else {
             // process the file where it is
             if (!$file_path) {
                 $file_path = str_replace($context['path_to_root'], '', dirname($file_upload));
                 $file_name = basename($file_upload);
             }
             // check against viruses
             $result = Files::has_virus($context['path_to_root'] . $file_path . '/' . $file_name);
             // no virus has been found in this file
             if ($result == 'N') {
                 $context['text'] .= Skin::build_block(i18n::s('No virus has been found.'), 'note');
             }
             // this file has been infected!
             if ($result == 'Y') {
                 // delete this file immediately
                 Safe::unlink($file_path . '/' . $file_name);
                 Logger::error(i18n::s('This file has been infected by a virus and has been rejected!'));
                 return FALSE;
             }
             // explode a .zip file
             include_once $context['path_to_root'] . 'shared/zipfile.php';
             if (preg_match('/\\.zip$/i', $file_name) && isset($_REQUEST['explode_files'])) {
                 $zipfile = new zipfile();
                 // check files extracted from the archive file
                 function explode_callback($name)
                 {
                     global $context;
                     // reject all files put in sub-folders
                     if (($path = substr($name, strlen($context['uploaded_path'] . '/'))) && strpos($path, '/') !== FALSE) {
                         Safe::unlink($name);
                     } elseif (!Files::is_authorized($name)) {
                         Safe::unlink($name);
                     } else {
                         // make it easy to download
                         $ascii = utf8::to_ascii(basename($name));
                         Safe::rename($name, $context['uploaded_path'] . '/' . $ascii);
                         // remember this name
                         $context['uploaded_files'][] = $ascii;
                     }
                 }
                 // extract archive components and save them in mentioned directory
                 $context['uploaded_files'] = array();
                 $context['uploaded_path'] = $file_path;
                 if (!($count = $zipfile->explode($context['path_to_root'] . $file_path . '/' . $file_name, $file_path, '', 'explode_callback'))) {
                     Logger::error(sprintf('Nothing has been extracted from %s.', $file_name));
                     return FALSE;
                 }
                 // one single file has been uploaded
             } else {
                 $context['uploaded_files'] = array($file_name);
             }
             // ensure we know the surfer
             Surfer::check_default_editor($_REQUEST);
             // post-process all uploaded files
             foreach ($context['uploaded_files'] as $file_name) {
                 // this will be filtered by umask anyway
                 Safe::chmod($context['path_to_root'] . $file_path . $file_name, $context['file_mask']);
                 // invoke post-processing function
                 if ($target && is_callable($target)) {
                     call_user_func($target, $file_name, $context['path_to_root'] . $file_path);
                     // we have to update an anchor page
                 } elseif ($target && is_string($target)) {
                     $fields = array();
                     // update a file with the same name for this anchor
                     if ($matching =& Files::get_by_anchor_and_name($target, $file_name)) {
                         $fields['id'] = $matching['id'];
                     } elseif (isset($input['id']) && ($matching = Files::get($input['id']))) {
                         $fields['id'] = $matching['id'];
                         // silently delete the previous version of the file
                         if (isset($matching['file_name'])) {
                             Safe::unlink($file_path . '/' . $matching['file_name']);
                         }
                     }
                     // prepare file record
                     $fields['file_name'] = $file_name;
                     $fields['file_size'] = filesize($context['path_to_root'] . $file_path . $file_name);
                     $fields['file_href'] = '';
                     $fields['anchor'] = $target;
                     // change title
                     if (isset($_REQUEST['title'])) {
                         $fields['title'] = $_REQUEST['title'];
                     }
                     // change has been documented
                     if (!isset($_REQUEST['version']) || !$_REQUEST['version']) {
                         $_REQUEST['version'] = '';
                     } else {
                         $_REQUEST['version'] = ' - ' . $_REQUEST['version'];
                     }
                     // always remember file uploads, for traceability
                     $_REQUEST['version'] = $fields['file_name'] . ' (' . Skin::build_number($fields['file_size'], i18n::s('bytes')) . ')' . $_REQUEST['version'];
                     // add to file history
                     $fields['description'] = Files::add_to_history($matching, $_REQUEST['version']);
                     // if this is an image, maybe we can derive a thumbnail for it?
                     if (Files::is_image($file_name)) {
                         include_once $context['path_to_root'] . 'images/image.php';
                         Image::shrink($context['path_to_root'] . $file_path . $file_name, $context['path_to_root'] . $file_path . 'thumbs/' . $file_name);
                         if (file_exists($context['path_to_root'] . $file_path . 'thumbs/' . $file_name)) {
                             $fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . $file_path . 'thumbs/' . rawurlencode($file_name);
                         }
                     }
                     // change active_set
                     if (isset($_REQUEST['active_set'])) {
                         $fields['active_set'] = $_REQUEST['active_set'];
                     }
                     // change source
                     if (isset($_REQUEST['source'])) {
                         $fields['source'] = $_REQUEST['source'];
                     }
                     // change keywords
                     if (isset($_REQUEST['keywords'])) {
                         $fields['keywords'] = $_REQUEST['keywords'];
                     }
                     // change alternate_href
                     if (isset($_REQUEST['alternate_href'])) {
                         $fields['alternate_href'] = $_REQUEST['alternate_href'];
                     }
                     // overlay, if any
                     if (is_object($overlay)) {
                         // allow for change detection
                         $overlay->snapshot();
                         // update the overlay from form content
                         $overlay->parse_fields($_REQUEST);
                         // save content of the overlay in this item
                         $fields['overlay'] = $overlay->save();
                         $fields['overlay_id'] = $overlay->get_id();
                     }
                     // create the record in the database
                     if (!($fields['id'] = Files::post($fields))) {
                         return FALSE;
                     }
                     // record surfer activity
                     Activities::post('file:' . $fields['id'], 'upload');
                 }
             }
             // so far so good
             if (count($context['uploaded_files']) == 1) {
                 return $context['uploaded_files'][0];
             } else {
                 return $context['uploaded_files'];
             }
         }
     }
     // some error has occured
     return FALSE;
 }
コード例 #17
0
ファイル: ProjectsModel.php プロジェクト: cesarcruzc/workbook
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getActivities()
 {
     return $this->hasMany(Activities::className(), ['idProjects' => 'idProjects']);
 }
コード例 #18
0
 function handlePOST_submitComment($request_data)
 {
     global $error_msg;
     if ($request_data['action'] == 'submitComment' && !empty(PA::$login_uid)) {
         $ccid_string = "";
         if (!empty($request_data['ccid'])) {
             $ccid_string = "&ccid=" . $request_data['ccid'];
         }
         $error_msg = "";
         if (strlen(trim(strip_tags($request_data['comment']))) == 0) {
             $error_msg = "Your comment contains some illegal characters. Please try again.<br>";
         }
         if (trim($request_data['comment']) == '') {
             $error_msg = "Comment can not be left blank<br>";
         }
         if (isset($request_data['name']) && trim($request_data['name']) == '') {
             $error_msg .= "Please enter name<br>";
         }
         if (isset($request_data['email']) && trim($request_data['email']) == '') {
             $error_msg .= "Please enter email address";
         } else {
             if (isset($request_data['email']) && !validate_email($request_data['email'])) {
                 $error_msg .= "Please enter a valid email address";
             }
         }
         /*
               if(strlen($error_msg) > 0) {
                 $location = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $request_data["cid"];
                 $this->controller->redirect($location);
               }
         */
         /* Function for Filtering the POST data Array */
         filter_all_post($request_data);
         if (empty($error_msg)) {
             // no errors occured
             $comment = new Comment();
             $id = trim($request_data['cid']);
             $comment->content_id = $id;
             $comment->subject = '';
             $comment->comment = trim($request_data['comment']);
             if (PA::$login_uid) {
                 $user = new User();
                 $user->load((int) PA::$login_uid);
                 $comment->user_id = $user->user_id;
                 $comment->name = '';
                 $comment->email = '';
                 $comment->homepage = '';
                 unset($request_data['err']);
             } else {
                 $comment->name = trim($request_data['name']);
                 $comment->email = trim($request_data['email']);
                 if (!empty($request_data['homepage'])) {
                     $comment->homepage = validate_url(trim($request_data['homepage']));
                 } else {
                     $comment->homepage = "";
                 }
             }
             // In old method
             $comment->parent_type = TYPE_CONTENT;
             $comment->parent_id = $id;
             if ($comment->spam_check()) {
                 $error_msg = "Sorry, your comment cannot be posted as it looks like spam.  Try removing any links to possibly suspect sites, and re-submitting.";
                 Logger::log("Comment rejected by spam filter", LOGGER_ACTION);
             } else {
                 $error_msg = 'Your comment has been posted successfully';
                 $comment->save();
                 if ($comment->spam_state != SPAM_STATE_OK) {
                     $error_msg = "Sorry, your comment cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites.  Please check the links in your post, and that your name and e-mail address are correct.";
                 } else {
                     //for rivers of people
                     $activity = 'user_post_a_comment';
                     $activity_extra['info'] = $user->display_name . 'has left a comment';
                     $activity_extra['comment_id'] = $comment->comment_id;
                     $activity_extra['content_url'] = PA::$url . PA_ROUTE_CONTENT . "/cid={$id}";
                     $extra = serialize($activity_extra);
                     Activities::save($user->user_id, $activity, $comment->comment_id, $extra);
                     //TO DO: comment should be posted to contents of other network rather then just mother network
                     //$params['cid'] = $comment->content_id;
                     //auto_email_notification('comment_posted', $params );
                     //** when uncommenting the above line, don't forget to uncomment the include of auto_email_notify.php at the top of this file too!
                     unset($request_data);
                     //invalidate cache of content block as it is modified now
                     if (PA::$network_info) {
                         $nid = '_network_' . PA::$network_info->network_id;
                     } else {
                         $nid = '';
                     }
                     //unique name
                     $cache_id = 'content_' . $id . $nid;
                     CachedTemplate::invalidate_cache($cache_id);
                 }
             }
         }
     }
 }
コード例 #19
0
 $params['content_moderation_url'] = PA::$url . '/' . FILE_NETWORK_MANAGE_CONTENT;
 $params['config_site_name'] = $config_site_name;
 $params['network_owner_name'] = $network_owner_name[$network_info->owner_id];
 auto_email_notification('content_posted', $params);
 if ($_POST['route_to_pa_home'] == 1) {
     auto_email_notification('content_posted_to_comm_blog', $params);
 }
 //for rivers of people
 $activity = 'user_post_a_blog';
 $activity_extra['info'] = $user->first_name . 'posted a new blog';
 $activity_extra['blog_name'] = $params['content_title'];
 $activity_extra['blog_id'] = $permalink_cid;
 $activity_extra['blog_url'] = $params['content_url'];
 $extra = serialize($activity_extra);
 $object = $permalink_cid;
 Activities::save($user->user_id, $activity, $object, $extra, $activities_array);
 //save post in groups
 $routed_to_groups = route2groups();
 // save post to outputthis
 route_to_outputthis($_POST["blog_title"], $_POST["description"]);
 //we have saved it in all the locations lets redirect it to various locations
 if ($_GET['ccid']) {
     $gid = $_GET['ccid'];
     $group = ContentCollection::load_collection((int) $gid, $login_uid);
     $is_member = Group::get_user_type((int) $login_uid, (int) $gid);
     if ($is_member == NOT_A_MEMBER) {
         $msg = "&msg_id=7028";
     } else {
         if ($group->reg_type == REG_MODERATED) {
             $msg = "&msg_id=1004";
         } else {
    echo $this->tag->linkTo(array('versions/edit/' . $version->id . '/' . $version->system_id, '<span class="glyphicon glyphicon-pencil"></span>'));
    ?>
				&nbsp; <?php 
    echo $this->tag->linkTo(array('versions/delete/' . $version->id . '/' . $version->system_id, '<span class="glyphicon glyphicon-trash"></span>'));
    ?>
			</span></p>
		
		<?php 
    $last_version = Versions::findFirst(array("date < '{$version->date}'", "order" => "date DESC", "limit" => 1));
    if ($last_version) {
        $last_date = $last_version->date;
    } else {
        $last_date = '0000-00-00';
    }
    $date = $version->date;
    $activities = Activities::query()->where('date <= :date:')->andWhere('system_id = :system_id: ')->andWhere('date > :last_date: ')->bind(array('date' => $version->date, 'system_id' => $version->system_id, 'last_date' => $last_date))->order('date')->execute();
    ?>
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>No</th>
						<th>Date</th>
						<th>Time</th>
						<th>Description</th>
						<th>Module</th>
					</tr>
				</thead>
					<?php 
    $i = 1;
    ?>
				<?php 
コード例 #21
0
ファイル: fetch.php プロジェクト: rair/yacs
    $menu[] = Skin::build_submit_button(i18n::s('Download this file'), NULL, NULL, 'confirmed', 'no_spin_on_click');
    $menu[] = Skin::build_link($anchor->get_url('files'), i18n::s('Cancel'), 'span');
    // to get the actual file
    $target_href = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
    // render commands
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>' . "\n" . Skin::finalize_list($menu, 'assistant_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="action" value="confirm" />' . "\n" . '</div></form>' . "\n";
    // set the focus
    Page::insert_script('$("#confirmed").focus();');
    //actual transfer
} elseif ($item['id'] && $item['anchor']) {
    // increment the count of downloads
    if (!Surfer::is_crawler()) {
        Files::increment_hits($item['id']);
    }
    // record surfer activity
    Activities::post('file:' . $item['id'], 'fetch');
    $anchor->touch('file:fetch', 'file:' . $item['id'], true);
    // if we have an external reference, use it
    if (isset($item['file_href']) && $item['file_href']) {
        $target_href = $item['file_href'];
        // we have direct access to the file
    } else {
        // ensure a valid file name
        $file_name = utf8::to_ascii($item['file_name']);
        // where the file is located
        $path = Files::get_path($item['anchor']) . '/' . $item['file_name'];
        // file attributes
        $attributes = array();
        // transmit file content
        if (!headers_sent() && ($handle = Safe::fopen($context['path_to_root'] . $path, "rb")) && ($stat = Safe::fstat($handle))) {
            // stream FLV files if required to do so
コード例 #22
0
 /** !!
  * 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);
 }
コード例 #23
0
 private function handleGET_delete($request_data)
 {
     global $error_msg;
     if (PA::$login_uid && !empty($this->shared_data['group_info']) && @$_POST['content_type'] != 'media') {
         $group = $this->shared_data['group_info'];
         $user = PA::$login_user;
         if (Group::is_admin((int) $request_data['gid'], (int) PA::$login_uid)) {
             $group->delete();
             // Deleting all the activities of this group from activities table for rivers of people module
             Activities::delete_for_group($request_data['gid']);
             if (!empty(PA::$config->useTypedGroups)) {
                 require_once 'api/Entity/TypedGroupEntity.php';
                 require_once "api/Entity/TypedGroupEntityRelation.php";
                 TypedGroupEntityRelation::delete_all_relations($request_data['gid']);
                 TypedGroupEntity::delete_for_group($request_data['gid']);
             }
             $this->controller->redirect(PA::$url . PA_ROUTE_GROUPS . "?error_msg=" . __("Group sucessfully deleted."));
         }
     }
 }
コード例 #24
0
ファイル: group.php プロジェクト: CivicCommons/oldBellCaPA
                 $x = $group->leave((int) $login_uid);
             } catch (PAException $e) {
                 $group_top_mesg = "Operation failed (" . $e->message . "). Please try again";
             }
         } else {
             $group_top_mesg = "You are not member of " . stripslashes($group->title) . " group.";
         }
     }
     if ($x) {
         $group_top_mesg = "You have left the \"" . stripslashes($group->title) . "\" group successfully.";
     }
 } elseif (@$_GET['action'] == 'delete' && $_POST['content_type'] != 'media') {
     if (Group::is_admin((int) $_REQUEST['gid'], (int) $login_uid)) {
         $group->delete();
         //Deleting all the activities of this group from activities table for rivers of people module
         Activities::delete_for_group($_REQUEST['gid']);
         header("location:groups_home.php");
         exit;
     } else {
         if ($_POST['content_type'] == 'media') {
             $med_type = ucfirst($_POST['media_type']);
             $group_top_mesg = "Your {$med_type} file has been deleted.";
         } else {
             $group_top_mesg = "You dont have permissions to delete this group";
         }
     }
 } else {
     if ((@$_POST['submit'] || @$_POST['submit_audio'] || @$_POST['submit_video']) && @$_POST['content_type'] == 'media') {
         $error_media = FALSE;
         $med_type = ucfirst($_POST['media_type']);
         if (!empty($upload_array)) {
コード例 #25
0
 public function editAction($id = NULL)
 {
     $this->view->title = "Редагувати студента";
     $this->view->nothing = true;
     $this->view->ind_code = $this->request->get("ind_code");
     if (!is_null($this->view->ind_code) && $this->checkINN($this->view->ind_code) || !is_null($id)) {
         $this->view->nothing = false;
         $this->view->student = is_null($id) ? \Students::findFirst("ind_code = " . $this->view->ind_code) : \Students::findFirst($id);
         $this->view->user = $this->session->get("user");
         $methodistBrands = \BrandsMethodists::find("user_id=" . $this->view->user->id)->toArray();
         $methodistActivities = \ActivitiesMethodists::find("user_id=" . $this->view->user->id)->toArray();
         if ($this->view->student != NULL) {
             $this->view->ind_code = $this->view->student->ind_code;
             $this->view->user = \Users::findFirst($this->view->student->user_id);
             $studentBrands = BrandsService::getStudentBrands($this->view->student);
             $studentActivities = ActivitiesService::getStudentActivities($this->view->student);
             $studentPostsJSON = array();
             if ($this->view->student->StudentsPosts != NULL) {
                 foreach ($this->view->student->StudentsPosts as $sp) {
                     //{"dealer":"1","post":"2","brands":["2", "5"],"activities":["1"],"rate":"1.0","appoint_date":"2015-04-01"}
                     $studentPostsJSON[$sp->id] = array();
                     $studentPostsJSON[$sp->id]["dealer"] = $sp->dealer;
                     $studentPostsJSON[$sp->id]["post"] = $sp->post;
                     $array = array();
                     foreach ($sp->StudentsPostsBrands as $spb) {
                         $array[] = $spb->Brands->id;
                     }
                     $studentPostsJSON[$sp->id]["brands"] = $array;
                     $array = array();
                     foreach ($sp->StudentsPostsActivities as $spa) {
                         $array[] = $spa->Activities->id;
                     }
                     $studentPostsJSON[$sp->id]["activities"] = $array;
                     $studentPostsJSON[$sp->id]["rate"] = $sp->rate;
                     $studentPostsJSON[$sp->id]["appoint_date"] = $sp->appoint_date;
                 }
             }
             //$this->view->student->StudentsEducation;
         } else {
             $this->view->student = new \Students();
             $this->view->user = new \Users();
             $studentPostsJSON = array();
             $studentBrands = array();
             $studentActivities = array();
         }
         $this->view->brands = BrandsService::getForChosenEntity(\Brands::find()->toArray(), $methodistBrands, $studentBrands);
         $this->view->activities = ActivitiesService::getForChosenEntity(\Activities::find()->toArray(), $methodistActivities, $studentActivities);
         $this->view->allEducations = \Educations::find("parent_id is NULL");
         $this->view->allDealers = \Dealers::find();
         $this->view->studentPostsJSON = $studentPostsJSON;
     }
 }
コード例 #26
0
        $gid = (int) $_GET['delete_gid'];
        $group = ContentCollection::load_collection((int) $gid, $login_uid);
        $group->delete();
        //Deleting all the activities of this group from activities table for rivers of people module
        Activities::delete_for_group($gid);
        $message = __("Group deleted successfully");
        unset($_GET['delete_gid']);
    }
}
if (!empty($_POST['gid'])) {
    $group_ids = $_POST['gid'];
    foreach ($group_ids as $i => $delete_gid) {
        $group = ContentCollection::load_collection((int) $delete_gid, $login_uid);
        $group->delete();
        //Deleting all the activities of this group from activities table for rivers of people module
        Activities::delete_for_group($delete_gid);
        unset($_POST['gid']);
    }
    $msg = uihelper_plural(count($group_ids), 'group');
    $message = sprintf(__("%s groups deleted successfully"), $msg);
}
function setup_module($column, $module, $obj)
{
    switch ($module) {
        case 'ManageGroupsModule':
            if (!empty($_GET['sort_by'])) {
                $obj->set_sort_by($_GET['sort_by']);
            }
            if (!empty($_GET['sort_dir'])) {
                $obj->set_sort_dir($_GET['sort_dir']);
            }
コード例 #27
0
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a video in group id =' . $_GET['gid'];
            break;
        case 'Audios':
            $activity = 'group_audio_upload';
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a audio in group id =' . $_GET['gid'];
            break;
        default:
            break;
    }
    $activities_extra['collection_id'] = $upload['collection_id'];
    $activities_extra['content_id'] = $upload['content_id'];
    $extra = serialize($activities_extra);
    $object = $_GET['gid'];
    Activities::save($login_uid, $activity, $object, $extra);
}
// Code for Re-Direction  After Successfull deletion
if (!empty($success_delete) || !empty($success)) {
    $gid = $_GET['gid'];
    $type = $_GET['type'];
    $location = $ret_url . "&msg_id={$msg_id}";
    header("Location: {$location}");
    exit;
}
$setting_data = array('middle' => array('UploadMediaModule'));
/* This function is a Callback function which initialize the value for the BLOCK MODULES */
function setup_module($column, $moduleName, $obj)
{
    /* in this module we have to set user_id , group_id, as well as netwrok_id */
    global $uid, $type, $album_id;
コード例 #28
0
ファイル: view.php プロジェクト: rair/yacs
 //				."\n"
 //			.'	// use a definition list to enable customization of the download box'."\n"
 //				.'	document.write(\'<dl class="download">\');'."\n"
 //				.'	document.write(\'<dt><a onclick="edit_in_word()" title="'.addcslashes($title, "'").'">'.addcslashes($label, "'").'</a></dt>\');'."\n"
 //				.'	document.write(\'<dd>'.addcslashes($description, "'").'</dd></dl>\');'."\n"
 //			.'}'."\n"
 //			.JS_SUFFIX."\n";
 //	}
 //
 // link to download the file
 //
 // download description
 $description = '';
 // the list of people who have fetched this file, for owners and associates
 if (Files::allow_modification($item, $anchor) && ($users = Activities::list_users_at('file:' . $item['id'], 'fetch', 30, 'comma'))) {
     $count = Activities::count_users_at('file:' . $item['id'], 'fetch');
     if ($count > 30) {
         $more = ' ...';
     } else {
         $more = '';
     }
     $description .= '<p>' . Skin::build_number($item['hits'], i18n::ns('download', 'downloads', $item['hits'])) . sprintf(i18n::ns(', including %d authenticated person: %s', ', including %d authenticated persons: %s', $count), $count, $users) . "</p>\n";
 }
 // add some help depending on the file type
 $extension = strtolower(@array_pop(@explode('.', @basename($item['file_name']))));
 switch ($extension) {
     case '3gp':
         // video/3gpp
         $description .= '<p>' . sprintf(i18n::s('You are about to download a small video. To take the most of it we recommend you to use %s (open source).'), Skin::build_link(i18n::s('http://www.videolan.org/vlc/'), i18n::s('VLC media player'), 'external')) . '</p>';
         break;
     case 'ai':
コード例 #29
0
ファイル: links.php プロジェクト: rair/yacs
 /**
  * record a click
  *
  * @param string the external url that is targeted
  *
  */
 public static function click($url)
 {
     global $context;
     // we record only GET requests
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
         return;
     }
     // do not count crawling
     if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blo\\.gs|\\bblog|bot\\b|crawler\\b|frontier\\b|slurp\\b|spider\\b)/i', $_SERVER['HTTP_USER_AGENT'])) {
         return;
     }
     // record the activity
     Activities::post($url, 'click');
     // do not record clicks driving to search engines
     if (preg_match('/\\b(google|yahoo)\\b/i', $url)) {
         return;
     }
     // if this url is known
     $query = "SELECT * FROM " . SQL::table_name('links') . " AS links" . " WHERE links.link_url LIKE '" . SQL::escape($url) . "'";
     if ($item = SQL::query_first($query)) {
         // increment the number of clicks
         $query = "UPDATE " . SQL::table_name('links') . " SET hits=hits+1 WHERE id = " . SQL::escape($item['id']);
         SQL::query($query);
         // else create a new record with a count of one click
     } else {
         // get the section for clicks
         $anchor = Sections::lookup('clicks');
         // no section yet, create one
         if (!$anchor) {
             $fields['nick_name'] = 'clicks';
             $fields['title'] = i18n::c('Clicks');
             $fields['introduction'] = i18n::c('Clicked links are referenced here.');
             $fields['description'] = i18n::c('YACS ties automatically external links to this section on use. Therefore, you will have below a global picture of external sites that are referenced through your site.');
             $fields['active_set'] = 'N';
             // for associates only
             $fields['locked'] = 'Y';
             // no direct contributions
             $fields['index_map'] = 'N';
             // listd only to associates
             $fields['rank'] = 20000;
             // towards the end of the list
             // reference the new section
             if ($fields['id'] = Sections::post($fields)) {
                 $anchor = 'section:' . $fields['id'];
             }
         }
         // create a new link in the database
         $fields = array();
         $fields['anchor'] = $anchor;
         $fields['link_url'] = $url;
         $fields['hits'] = 1;
         Surfer::check_default_editor($fields);
         if ($fields['id'] = Links::post($fields)) {
             Links::clear($fields);
         }
     }
 }
コード例 #30
0
ファイル: edit.php プロジェクト: rair/yacs
        }
        if (is_object($anchor) && Surfer::may_upload()) {
            $menu = array_merge($menu, array('files/edit.php?anchor=' . $anchor->get_reference() => i18n::s('Upload another file')));
        }
        $follow_up .= Skin::build_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
        // forward to the updated page
    } else {
        // touch the related anchor
        $anchor->touch('file:update', $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
        // clear cache
        Files::clear($_REQUEST);
        // increment the post counter of the surfer
        Users::increment_posts(Surfer::get_id());
        // record surfer activity
        Activities::post('file:' . $_REQUEST['id'], 'upload');
        if ($render_overlaid) {
            echo 'post done';
            die;
        }
        // forward to the anchor page
        Safe::redirect($anchor->get_url('files'));
    }
    // display the form on GET
} else {
    $with_form = TRUE;
}
// display the form
if ($with_form) {
    // prevent updates from section owner or associate
    if (isset($item['assign_id']) && $item['assign_id'] && !Surfer::is($item['assign_id'])) {