예제 #1
0
 public function create_comment_for_user_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $admin = user::lookup(2);
     $comment = comment::create($root, $admin, "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $this->assert_equal($admin->full_name, $comment->author_name());
     $this->assert_equal($admin->email, $comment->author_email());
     $this->assert_equal($admin->url, $comment->author_url());
     $this->assert_equal("text_{$rand}", $comment->text);
     $this->assert_equal(1, $comment->item_id);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
     $this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
     $this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
     $this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
     $this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
     $this->assert_equal("HTTP_HOST", $comment->server_http_host);
     $this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("QUERY_STRING", $comment->server_query_string);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
     $this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
     $this->assert_true(!empty($comment->created));
 }
예제 #2
0
 public function form_edit($id)
 {
     $user = user::lookup($id);
     if ($user->guest || $user->id != user::active()->id) {
         access::forbidden();
     }
     print $this->_get_edit_form($user);
 }
예제 #3
0
 public function form_edit($id)
 {
     $user = user::lookup($id);
     if ($user->guest || $user->id != identity::active_user()->id) {
         access::forbidden();
     }
     $v = new View("user_form.html");
     $v->form = $this->_get_edit_form($user);
     print $v;
 }
예제 #4
0
파일: log.php 프로젝트: CardinS2U/gallery3
 /**
  * @see ORM::__get()
  */
 public function __get($column)
 {
     if ($column == "user") {
         // This relationship depends on an outside module, which may not be present so handle
         // failures gracefully.
         try {
             return user::lookup($this->user_id);
         } catch (Exception $e) {
             return null;
         }
     } else {
         return parent::__get($column);
     }
 }
예제 #5
0
 public function remove_user_from_group($user_id, $group_id)
 {
     access::verify_csrf();
     $group = group::lookup($group_id);
     $user = user::lookup($user_id);
     $group->remove($user);
     $group->save();
 }
예제 #6
0
function evidence_get_assoc($snap, $variant_id)
{
    $rows =& evidence_get_report($snap, $variant_id);
    global $gWantKeysForAssoc;
    if (!is_array($gWantKeysForAssoc["variant"])) {
        foreach ($gWantKeysForAssoc as $k => &$v) {
            if ($k == "all") {
                continue;
            }
            $v = explode(" ", $gWantKeysForAssoc["all"] . " " . $v);
        }
    }
    $variant = array("genomes" => array(), "articles" => array(), "diseases" => array());
    for ($i = 0; $i < sizeof($rows); $i++) {
        $row =& $rows[$i];
        $editor = user::lookup($row["edit_oid"]);
        $row["editor_name"] = $editor->get("fullname");
        if (strlen($row["summary_long"]) == 0) {
            $row["summary_long"] = $row["summary_short"];
        }
        if ($row["article_pmid"] > 0) {
            $section =& $variant["articles"]["" . $row["article_pmid"]];
            $want_keys =& $gWantKeysForAssoc["article"];
        } else {
            if ($row["genome_id"] > 0) {
                $section =& $variant["genomes"]["" . $row["genome_id"]];
                $want_keys =& $gWantKeysForAssoc["genome"];
            } else {
                $section =& $variant;
                $want_keys =& $gWantKeysForAssoc["variant"];
                $row["aa_change"] = $row["variant_aa_from"] . $row["variant_aa_pos"] . $row["variant_aa_to"];
                $row["aa_change_short"] = aa_short_form($row["aa_change"]);
                // TODO: combine these into one array and add labels
                $row["quality_scores"] = str_split(str_pad($row["variant_quality"], 6, "-"));
                $row["quality_comments"] = $row["variant_quality_text"] ? json_decode($row["variant_quality_text"], true) : array();
                $diseases = evidence_get_all_oddsratios($rows);
                unset($max_or_id);
                foreach ($diseases as $id => &$d) {
                    if (!isset($max_or_id) || $diseases[$max_or_id]["figs"]["or"] < $d["figs"]["or"]) {
                        $max_or_id = $id;
                    }
                }
                if (isset($max_or_id)) {
                    $row["disease_max_or"] = $diseases[$max_or_id];
                }
            }
        }
        if ($row["disease_id"] > 0) {
            $section =& $section["diseases"]["" . $row["disease_id"]];
            if (ereg('^\\[', $row["summary_short"])) {
                $row = array_merge(json_decode($row["summary_short"], true), $row);
            }
            $want_keys =& $gWantKeysForAssoc["disease"];
        }
        foreach ($want_keys as $k) {
            list($inkey, $outkey) = explode(":", $k);
            if (!$outkey) {
                $outkey = $inkey;
            }
            $section[$outkey] = $row[$inkey];
        }
        unset($section);
    }
    foreach (array("articles", "genomes") as $section) {
        $variant[$section] = array_values($variant[$section]);
        foreach ($variant[$section] as &$x) {
            if (is_array($x["diseases"])) {
                $x["diseases"] = array_values($x["diseases"]);
            }
        }
    }
    return $variant;
}
예제 #7
0
파일: users.php 프로젝트: kandsten/gallery3
 public function form_change_email($id)
 {
     $user = user::lookup($id);
     if (!$user || $user->guest || $user->id != identity::active_user()->id) {
         access::forbidden();
     }
     print $this->_get_change_email_form($user);
 }
예제 #8
0
 /**
  * @see IdentityProvider_Driver::lookup_user.
  */
 public function lookup_user($id)
 {
     return user::lookup($id);
 }
예제 #9
0
 public function change_password($id, $password)
 {
     $user = user::lookup($id);
     print $this->_get_change_password_form($user, $password);
 }
        echo $layout;
        ?>
" data-width="180" data-show-faces="<?php 
        echo $show_faces;
        ?>
" data-action="<?php 
        echo $action;
        ?>
"></div>

<?php 
    }
}
?>
</div>
<?php 
/**
 * Only show the like button, css and JS if the item is vewable by the guest user 
 * as facebook is a guest user to get the thumb of the item.  If this is a dynamic 
 * album then use the root album to check to see if the guest has permissions.
 */
$guest = user::lookup("1");
$item = "";
if ($theme->item()) {
    $item = $theme->item();
} else {
    $item = ORM::factory("item", 1);
}
if (access::user_can($guest, "view", $item)) {
    $show_like_code = true;
}
예제 #11
0
 function author()
 {
     return user::lookup($this->author_id);
 }
예제 #12
0
파일: task.php 프로젝트: hiwilson/gallery3
 public function owner()
 {
     return user::lookup($this->owner_id);
 }
예제 #13
0
 public function i_can_edit_test()
 {
     // Create a new user that belongs to no groups
     $user = user::create("access_test", "Access Test", "");
     foreach ($user->groups as $group) {
         $user->remove($group);
     }
     $user->save();
     user::set_active($user);
     // This user can't edit anything
     $root = ORM::factory("item", 1);
     $this->assert_false(access::can("edit", $root));
     // Now add them to a group that has edit permission
     $group = group::create("access_test");
     $group->add($user);
     $group->save();
     access::allow($group, "edit", $root);
     $user = user::lookup($user->id);
     // reload() does not flush related columns
     user::set_active($user);
     // And verify that the user can edit.
     $this->assert_true(access::can("edit", $root));
 }