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


PHP Network::save方法代码示例

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


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

示例1: postNetwork

 public function postNetwork()
 {
     $posted = Input::all();
     $Network = new Network();
     $Network->category_id = $posted['category_id'];
     $Network->country_id = $posted['country_id'];
     $Network->network_name = $posted['network_name'];
     $Network->delivery_time = $posted['delivery_time'];
     $Network->price = $posted['price'];
     $Network->save();
     return Redirect::back()->with('success', 'Network has been successfully added');
 }
开发者ID:bernardowiredu,项目名称:unlocking-site,代码行数:12,代码来源:NetworkController.php

示例2: actionCreate

 public function actionCreate()
 {
     $uloginAuthUrl = 'http://ulogin.ru/token.php?token=';
     if (isset($_POST['token'])) {
         $data = json_decode(file_get_contents($uloginAuthUrl . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']), true);
         $nw = new Network();
         $nw->userId = Yii::app()->user->id;
         $nw->setAttributes($data);
         if ($nw->save()) {
             $this->renderPartial('application.views.forms.success', array('msg' => 'Соцсеть успешно добавлена!'));
         } else {
             echo CHtml::errorSummary($nw);
         }
     } else {
         throw new CHttpException(403);
     }
 }
开发者ID:hit-shappens,项目名称:testapp,代码行数:17,代码来源:NetworkController.php

示例3: save

 public function save($id = null)
 {
     if ($this->perm->can_create == 'y') {
         if ($_POST) {
             $save = new Network();
             if ($_POST['id'] == '') {
                 $show_no = $this->db->query("SELECT MAX(show_no)show_no FROM acm_network")->result();
                 $_POST['show_no'] = @$show_no[0]->show_no < 1 ? 1 : $show_no[0]->show_no + 1;
                 $_POST['created_by'] = $this->user->id;
             } else {
                 $_POST['updated_by'] = $this->user->id;
             }
             $save->from_array($_POST);
             $save->save();
             $action = $_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
             save_logs($this->menu_id, $action, @$save->id, $action . ' ' . $save->title . ' Network');
         }
     }
     redirect("admin/networks");
 }
开发者ID:ultraauchz,项目名称:asean_cultural_mapping,代码行数:20,代码来源:networks.php

示例4: authenticate

 public function authenticate($uloginModel = null)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'identity=:identity AND network=:network';
     $criteria->params = array(':identity' => $uloginModel->identity, ':network' => $uloginModel->network);
     $userNetwork = Network::model()->find($criteria);
     if (null !== $userNetwork) {
         $user = $userNetwork->user;
         $this->id = $user->id;
         $this->name = $user->email;
     } else {
         $user = new User();
         $user->email = $uloginModel->email;
         $user->firstName = $uloginModel->first_name;
         $user->lastName = $uloginModel->last_name;
         $user->sex = $uloginModel->sex;
         $user->phone = $uloginModel->phone;
         $user->bDate = $this->convertDate($uloginModel->bdate);
         $user->city = $uloginModel->city;
         $user->country = $uloginModel->country;
         $user->ava = $uloginModel->photo;
         $user->ava_full = $uloginModel->photo_big;
         $user->activated = true;
         if (!$user->save()) {
             return false;
         }
         $nw = new Network();
         $nw->identity = $uloginModel->identity;
         $nw->network = $uloginModel->network;
         $nw->userId = $user->id;
         $nw->save();
         $this->id = $user->id;
         $this->name = $user->username;
     }
     $this->isAuthenticated = true;
     return true;
 }
开发者ID:hit-shappens,项目名称:testapp,代码行数:37,代码来源:UloginUserIdentity.php

示例5: 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

示例6: array

        }
        $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}";
        }
    }
}
//...$_POST if ends
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:network_statistics.php

示例7: connectFacebook

 public function connectFacebook()
 {
     $provider = new Facebook(Config::get('social.facebook'));
     try {
         $network_type = 'facebook';
         $token = $provider->getAccessToken('authorizationCode', array('code' => Input::get('code')));
         $access_token = $token->accessToken;
         $client = new GuzzleHttp\Client();
         $res = $client->get('https://graph.facebook.com/me', array('query' => array('access_token' => $access_token)));
         $response_body = $res->getBody();
         $response_body = json_decode($response_body, true);
         $id = $response_body['id'];
         $name = $response_body['name'];
         if (!Auth::check()) {
             $user = User::where('social_id', '=', $id)->where('type', '=', 'facebook')->first();
             if (empty($user)) {
                 $user['inputs'] = array('username' => $name, 'email' => '', 'type' => $network_type, 'social_id' => $id);
                 Event::fire('user.create', array($user));
             }
         }
         if (Auth::check()) {
             $res = $client->get('https://graph.facebook.com/oauth/access_token', array('query' => array('grant_type' => 'fb_exchange_token', 'client_id' => Config::get('social.facebook.clientId'), 'client_secret' => Config::get('social.facebook.clientSecret'), 'fb_exchange_token' => $access_token)));
             $extended_accesstoken_response_body = $res->getBody();
             $extended_accesstoken = str_replace('access_token=', '', $extended_accesstoken_response_body);
             $extended_accesstoken = preg_replace('/&expires\\=[0-9]*/', '', $extended_accesstoken);
             $user_id = Auth::user()->id;
             $network = Network::where('user_id', '=', $user_id)->where('network', '=', $network_type)->where('network_id', '=', $id)->first();
             if (!empty($network)) {
                 $network->user_token = $extended_accesstoken;
                 $network->save();
             } else {
                 $network = new Network();
                 $network->user_id = $user_id;
                 $network->network = $network_type;
                 $network->user_token = $extended_accesstoken;
                 $network->network_id = $id;
                 $network->username = $name;
                 $network->save();
             }
             //get pages
             $res = $client->get('https://graph.facebook.com/me/accounts', array('query' => array('access_token' => $extended_accesstoken)));
             $response_body = $res->getBody();
             $pages = json_decode($response_body, true);
             if (!empty($pages['data'])) {
                 foreach ($pages['data'] as $page) {
                     if (in_array('CREATE_CONTENT', $page['perms'])) {
                         $page_id = $page['id'];
                         $page_name = $page['name'];
                         $page_accesstoken = $page['access_token'];
                         $network = Network::where('user_id', '=', $user_id)->where('network', '=', $network_type)->where('network_id', '=', $page_id)->first();
                         if (!empty($network)) {
                             $network->user_token = $page_accesstoken;
                             $network->save();
                         } else {
                             $network = new Network();
                             $network->user_id = $user_id;
                             $network->network = $network_type;
                             $network->user_token = $page_accesstoken;
                             $network->network_id = $page_id;
                             $network->username = $page_name;
                             $network->save();
                         }
                     }
                 }
             }
             return Redirect::to('/networks')->with('message', array('type' => 'success', 'text' => 'You have successfully connected your Facebook account!'));
         }
     } catch (Exception $e) {
         return Redirect::to('/networks')->with('message', array('type' => 'danger', 'text' => 'Something went wrong while trying to connect to your Facebook account. Please try again.'));
     }
 }
开发者ID:anchetaWern,项目名称:ahead,代码行数:71,代码来源:SocialController.php

示例8: create

   /**
	 * Create new item.
	 *
	 * @return mixed
	 */



  public function create() {

  $rules =array(

  	'n_name'=>'required', 
    'n_ip'=>'required',
     'n_status'=>'required'
  	);


     $validators = Validator::make(Input::all(), $rules);

                if ($validator->fails()) {
                

                return Redirect::to('networks/create')->withErrors($validators);
                
                } 

                 else {

                 $network = new Network;
                 $network->n_name = Input::get('n_name');
                 $network->n_ip = Input::get('n_ip'); 
                 $network->n_status = Input::get('n_status');
                 $network->save(); 


             return Redirect::to('networks/index')->with('message', 'New item was saved ok!');

        }


  }
开发者ID:alur86,项目名称:PHP_Code_Samples,代码行数:42,代码来源:NetworksController.php

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