function render() { $op = $this->op = @$this->module_params['op']; if ($this->op) { if (!empty($this->module_params['comment'])) { $target = new Comment2(); $target->load($this->module_params['comment']); } else { if (!empty($this->module_params['review'])) { $target = new Review(); $target->load($this->module_params['review']); } else { if (!empty($this->module_params['uid'])) { $target = new ShadowUser('videoplay'); $target->load_by_pa((int) $this->module_params['uid']); } } } switch ($op) { case "delete": if (!empty($this->module_params['uid'])) { $target->remove(); } else { $target->delete(); } break; case "hide": case "show": if (!empty($this->module_params['uid'])) { $target->toggle_active($op == 'hide' ? -1 : 1); } else { $target->toggle_active($op == 'hide' ? 0 : 1); } break; } } switch ($this->mode) { case "comments": $inner_template = dirname(__FILE__) . '/admin_content.tpl'; list($this->contents, $this->n, $this->n_pages, $this->page, $this->per_page) = Comment2::get_recent($this->per_page, $this->page); break; case "reviews": $inner_template = dirname(__FILE__) . '/admin_content.tpl'; list($this->contents, $this->n, $this->n_pages, $this->page, $this->per_page) = Review::get_recent($this->per_page, $this->page); break; case "users": $inner_template = dirname(__FILE__) . '/admin_users.tpl'; list($this->users, $this->n, $this->n_pages, $this->page, $this->per_page) = ShadowUser::admin_paged('videoplay', $this->per_page, $this->page); break; default: return "Unknown display type.<pre>" . print_r($this, 1) . "</pre>"; break; } $inner_html_gen =& new Template($inner_template, $this); $this->inner_HTML = $inner_html_gen->fetch(); $content = parent::render(); return $content; }
public function testAddDeleteShadowUser() { // Dal::register_query_callback("explain_query"); global $network_info; echo "getting a user\n"; $user = Test::get_test_user(); $testusername = $user->first_name . " " . $user->last_name; echo "test user = {$testusername}\n"; $namespace = 'php_unit'; // testuser data $testdata = array('user_id' => "pa_" . $user->user_id, 'login_name' => 'testuser', 'email' => $namespace . $user->email, 'first_name' => $user->first_name, 'last_name' => $user->last_name); echo "TEST DATA:\n"; print_r($testdata); $shadow_user = new ShadowUser($namespace); echo "Test load this shadow user, this should fail\n"; $sh = $shadow_user->load($testdata['user_id']); $this->assertNull($sh); echo "Create a shadow user\n"; $shadow_user = ShadowUser::create($namespace, $testdata, $network_info); echo "SHADOW USER DATA:\n"; print_r($shadow_user); $this->assertNotNull($shadow_user); echo "Test updating the data\n"; $testdata2 = $testdata; $testdata2['email'] = $namespace . "add" . $user->email; $testdata2['login_name'] = "newlogin"; $testdata2['first_name'] = "newName"; print_r($testdata2); $su2 = new ShadowUser($namespace); // load this with new data $su2->load($testdata2); unset($su2); Cache::reset(); // now load it only via the original remote uid $su3 = new ShadowUser($namespace); $su3->load($testdata['user_id']); echo "UPDATED SHADOW USER DATA:\n"; print_r($su3); echo "Delete it\n"; ShadowUser::delete($shadow_user->user_id); // there should not be a shadow user of this id anymore $this->assertNull($shadow_user->load($testdata['user_id'])); }