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


PHP Network::approve_all方法代码示例

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


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

示例1: save

 /**
  * Saves network to databse.
  * used for creating and updating the network
  * @access public.
  * called after $this->set_params()
  */
 public function save()
 {
     global $error, $error_msg;
     $error = false;
     Logger::log("[ Enter: function Network::save]\n");
     //first check whether it is insert or update
     // global var $path_prefix has been removed - please, use PA::$path static variable
     if ($this->network_id) {
         $old_type = Network::find_network_type($this->network_id);
         //update
         $update_fields = array('name', 'tagline', 'category_id', 'description', 'extra', 'type', 'inner_logo_image');
         $sql = " UPDATE {networks} SET changed = ? ";
         $data_array = array(time());
         foreach ($update_fields as $field) {
             if (isset($this->{$field})) {
                 $sql .= " , {$field} = ? ";
                 array_push($data_array, $this->{$field});
             }
         }
         $sql .= " WHERE network_id = ? ";
         array_push($data_array, $this->network_id);
         $res = Dal::query($sql, $data_array);
         //fix for changing a network from private to public
         //the waiting_members must be changed to members
         $new_type = $this->type;
         if ($old_type == PRIVATE_NETWORK_TYPE && $new_type == REGULAR_NETWORK_TYPE) {
             Network::approve_all($this->network_id);
         }
     } else {
         //insert
         // here we have to do a lot of steps
         //first check if network already exists with same address
         if (Network::check_already($this->address)) {
             Logger::log("Thowing Exception NETWORK_ALREADY_EXISTS");
             throw new PAException(NETWORK_ALREADY_EXISTS, "Network with same address already exists");
         }
         // checks the permissions of directory network
         $network_folder = PA::$project_dir . "/networks";
         if (!is_writable($network_folder)) {
             Logger::log("Thowing Exception NETWORK_DIRECTORY_PERMISSION_ERROR");
             throw new PAException(NETWORK_DIRECTORY_PERMISSION_ERROR, "Network folder ({$network_folder}) is not writable. Please check the permissions");
         }
         //if we have come this far we can insert the network easily
         // TODO add acl permission check
         //insert into networks
         $this->created = time();
         $this->type = $this->type ? $this->type : REGULAR_NETWORK_TYPE;
         $res = Dal::query("INSERT INTO {networks} (name, address, tagline, type,category_id, description,is_active, created, changed, extra, member_count, owner_id, inner_logo_image) VALUES ( ?, ?, ?,?, ?, ?, ?, ?, ?, ?, 1, ?, ? )", array($this->name, $this->address, $this->tagline, $this->type, $this->category_id, $this->description, 1, $this->created, $this->changed, $this->extra, $this->user_id, $this->inner_logo_image));
         $this->network_id = Dal::insert_id();
         //insert into networks_users
         $user_created = Dal::query_first("SELECT created FROM users WHERE user_id=?", $this->user_id);
         $res = Dal::query("INSERT INTO {networks_users} (network_id, user_id, user_type, created) VALUES (?, ?, ?, ?)", array($this->network_id, $this->user_id, NETWORK_OWNER, $user_created));
         //Now we have inserted new network we need to create other directory and config files as well
         try {
             $this->do_network_setup();
         } catch (PAException $e) {
             $error = TRUE;
             $error_msg = "{$e->message}";
         }
         if ($error) {
             $this->do_rollback();
             throw new PAException(NETWORK_INTERNAL_ERROR, "Some internal error occured while setting up the network. Message: {$error_msg}");
         }
     }
     //.. insert
     Logger::log("[ Exit: function Network::save]\n");
     return $this->network_id;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:74,代码来源:Network.php

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