当前位置: 首页>>代码示例>>PHP>>正文


PHP Network::set_params方法代码示例

本文整理汇总了PHP中Network::set_params方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::set_params方法的具体用法?PHP Network::set_params怎么用?PHP Network::set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Network的用法示例。


在下文中一共展示了Network::set_params方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_new_network

function create_new_network($_form)
{
    // function checks initial settings for network creation
    $can_network_be_created = Network::can_network_be_created();
    if ($can_network_be_created['error'] == TRUE) {
        $config_error = TRUE;
        $error = TRUE;
        $error_msg = $can_network_be_created['error_msg'];
    } else {
        if (!PA::$login_uid) {
            $config_error = TRUE;
        }
    }
    //form_data is array used for form fields
    // its initialized by $_form
    $temp_data['action'] = 'add';
    $vartoset = array('address', 'name', 'tagline', 'category', 'desc', 'header_image', 'header_image_option', 'action', 'type', 'network_group_title', 'network_content_moderation');
    for ($i = 0; $i < count($vartoset); $i += 1) {
        $var = $vartoset[$i];
        if (!empty($_form[$var])) {
            $temp_data[$var] = trim($_form[$var]);
        }
        if ($var == 'type') {
            if (isset($_form[$var])) {
                $temp_data[$var] = $_form[$var];
            }
        }
    }
    if (empty($config_error)) {
        filter_all_post($_form);
        //filters all data of html
        $error_post = check_error();
        //validation check
        if ($error_post['error'] == TRUE) {
            $error = TRUE;
            $error_msg = $error_post['error_msg'];
        }
        if (!$error_post) {
            //upload file
            if (!empty($_FILES['network_image']['name'])) {
                $file_upload_result = do_file_upload();
                if ($file_upload_result['error']) {
                    $error = TRUE;
                    $error_msg = $file_upload_result['error_msg'];
                } else {
                    $header_image = $network_image = $file_upload_result['file'];
                }
            } else {
                //image hidden
                $header_image = $network_image = @$temp_data['header_image'];
            }
            //code to upload the icon image
            if (!empty($_FILES['inner_logo_image']['name'])) {
                $uploadfile = PA::$upload_path . basename($_FILES['inner_logo_image']['name']);
                $myUploadobj = new FileUploader();
                //creating instance of file.
                $image_type = 'image';
                $file = $myUploadobj->upload_file(PA::$upload_path, 'inner_logo_image', true, true, $image_type);
                if ($file == false) {
                    $error = TRUE;
                    $error_msg = $file_upload_result['error_msg'];
                    unset($data_icon_image);
                } else {
                    $data_icon_image = array('inner_logo_image' => $file);
                }
            } else {
                unset($data_icon_image);
            }
            //...code to upload the icon image
            $network_basic_controls = PA::$network_defaults;
            $network_basic_controls['basic']['header_image']['name'] = $header_image;
            $network_basic_controls['basic']['header_image']['option'] = @$_form['header_image_option'] ? $_form['header_image_option'] : DESKTOP_IMAGE_ACTION_STRETCH;
            // for title of network group
            $network_basic_controls['network_group_title'] = '';
            $network_basic_controls['network_group_title'] = $_form['network_group_title'];
            $network_basic_controls['network_content_moderation'] = @$_form['network_content_moderation'];
            $temp_data['address'] = strtolower($temp_data['address']);
            $data = array('user_id' => $_SESSION['user']['id'], 'name' => strip_tags($temp_data['name']), 'address' => $temp_data['address'], 'tagline' => strip_tags($temp_data['tagline']), 'category_id' => $temp_data['category'], 'type' => $temp_data['type'], 'description' => $temp_data['desc'], 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time());
            //add icon image
            if (!empty($data_icon_image['inner_logo_image'])) {
                $data = array_merge($data, $data_icon_image);
                $temp_data['inner_logo_image'] = $data_icon_image['inner_logo_image'];
            }
            $network = new Network();
            $network->set_params($data);
            try {
                $nid = $network->save();
                //default_page_setting($network->address); // populate page_default setting
            } catch (PAException $e) {
                $error = TRUE;
                $error_msg = "{$e->message}";
            }
            if (!empty($nid)) {
                $_extra = serialize(array('user' => true, 'network' => true, 'groups' => array()));
                Roles::set_user_role_for_network($network->user_id, ADMINISTRATOR_ROLE, $network->address, $_extra);
                $location = "http://" . $temp_data['address'] . '.' . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_CONFIGURE_NETWORK;
            }
        }
        $msg_array = array();
        $msg_array['failure_msg'] = @$error_msg;
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:101,代码来源:action.php

示例2: catch

         if ($suc) {
             // adding default relation
             if ($_SESSION['user']['id'] != SUPER_USER_ID) {
                 uihelper_add_default_relation($_SESSION['user']['id']);
             }
             // adding default media as well as album
             uihelper_add_default_media($_SESSION['user']['id']);
             uihelper_add_default_media($_SESSION['user']['id'], '_audio');
             uihelper_add_default_media($_SESSION['user']['id'], '_video');
             uihelper_add_default_blog($_SESSION['user']['id']);
         }
     } catch (PAException $e) {
         $msg = "{$e->message}";
     }
     $network = new Network();
     $network->set_params(array('network_id' => $nid));
     $netinfo = $network->get();
     $netinfo = $netinfo[0];
     $requester = new User();
     $requester->load((int) $_SESSION['user']['id']);
     $recipient = type_cast($netinfo, 'Network');
     // defined in helper_functions.php
     PANotify::send("network_join", $recipient, $requester, array());
     $redirect_url = "http://" . $netinfo->address . "." . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_HOME_PAGE . "/msg=7001";
     header("Location:{$redirect_url}");
     exit;
     // $msg = "You have successfully joined the '".stripslashes($netinfo->name)."' network. Click <a href='http://".$netinfo->address.".".PA::$domain_suffix.BASE_URL_REL."/homepage.php'>here</a> to go to network.";
 } else {
     //$msg = "Please login first to join the network.";
     header("Location: " . PA::$url . "/login.php?error=1&return=" . urlencode($_SERVER['REQUEST_URI']));
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:network_action.php

示例3: array

     if (!empty($_POST['top_navigation_bar'])) {
         $network_basic_controls['top_navigation_bar'] = NET_NO;
     }
     $network_basic_controls['network_content_moderation'] = NET_NO;
     if (!empty($_POST['network_content_moderation'])) {
         $network_basic_controls['network_content_moderation'] = NET_YES;
     }
     $data = array('name' => $form_data['name'], 'tagline' => $form_data['tagline'], 'category_id' => $form_data['category'], 'description' => $form_data['desc'], 'type' => $form_data['type'], 'extra' => serialize($network_basic_controls), 'network_id' => $network_info->network_id, 'changed' => time());
     //add icon image
     if (is_array(@$data_icon_image) && !empty($data_icon_image['inner_logo_image'])) {
         $data = array_merge($data, $data_icon_image);
         $form_data['inner_logo_image'] = $data_icon_image['inner_logo_image'];
     }
     //try following line
     $network = new Network();
     $network->set_params($data);
     try {
         $nid = $network->save();
         $network_info = get_network_info();
         //refreshing the network_info after saving it.
         //set $form_data['reciprocated_relationship']if reciprocated relationship is saved
         $form_data['reciprocated_relationship'] = $network_basic_controls['reciprocated_relationship'];
         $form_data['email_validation'] = $network_basic_controls['email_validation'];
         $form_data['top_navigation_bar'] = $network_basic_controls['top_navigation_bar'];
         $form_data['network_content_moderation'] = $network_basic_controls['network_content_moderation'];
         $error_msg = 'Network Information Successfully Updated';
     } catch (PAException $e) {
         $error = TRUE;
         $error_msg = "{$e->message}";
     }
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:network_statistics.php

示例4: testNetworkCreation

 function testNetworkCreation()
 {
     // check that we can create networks
     $can = Network::can_network_be_created();
     $this->assertFalse($can['error'], $can['error_msg']);
     // get network owner user and figure out name etc
     $user = Test::get_test_user();
     $name = "testnet" . rand(10000, 99999);
     $network_basic_controls = array();
     // with crossed fingers, we hope that it will succeed without any of the detail here!
     // make a new network
     $net = new Network();
     $net->set_params(array('user_id' => $user->user_id, 'name' => "auto-test network ({$name})", 'address' => $name, 'tagline' => "not much of a tagline", 'category_id' => 8, 'type' => 0, 'description' => "This network has been created automatically by a PHPUnit test.  If the test succeeds, it will be deleted, too!", 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time()));
     $net->save();
     //default_page_setting($net->address);
     // read it in again and see if it still works
     $net_read = Network::get_network_by_address($net->address);
     $this->assertEquals($net_read->network_id, $net->network_id);
     $this->assertEquals($net_read->type, 0);
     $this->assertEquals($net_read->member_count, 1);
     $this->assertEquals($net_read->owner_id, $user->user_id);
     // a user joins
     $user2 = Test::get_test_user(2);
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // a user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // make it into a moderated network
     $net->type = 2;
     $net->save();
     // check that it really is moderated
     $net_read = Network::get_network_by_address($net->address);
     $this->assertEquals($net_read->network_id, $net->network_id);
     $this->assertEquals($net_read->type, 2);
     // a user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // request approved
     Network::approve($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // all requests accepted (of course, there will only be the one)
     Network::approve_all($net->network_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // request denied
     Network::deny($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // delete network
     Network::delete($net->network_id);
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:62,代码来源:NetworkCreationTest.php


注:本文中的Network::set_params方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。