Exemplo n.º 1
0
 protected function check_auth_and_is_mypage($member_id = 0, $is_api = false)
 {
     $is_mypage = false;
     $access_from = 'guest';
     $member = null;
     $member_id = (int) $member_id;
     if (!$member_id) {
         $this->check_auth_and_redirect(false);
         $is_mypage = true;
         $member = $this->u;
         $access_from = 'self';
     } elseif ($this->check_is_mypage($member_id)) {
         $is_mypage = true;
         $member = $this->u;
         $access_from = 'self';
     } else {
         $member = Model_Member::check_authority($member_id);
         if (Auth::check()) {
             $access_from = 'member';
             if (Model_MemberRelation::check_relation('friend', $this->u->id, $member_id)) {
                 $access_from = 'friend';
             }
         }
     }
     return array($is_mypage, $member, $access_from);
 }
Exemplo n.º 2
0
 public static function get_access_from_member_relation($member_id, $self_member_id = 0)
 {
     if (!$self_member_id) {
         return 'others';
     }
     if ($member_id == $self_member_id) {
         return 'self';
     }
     if (Model_MemberRelation::check_relation('friend', $self_member_id, $member_id)) {
         return 'friend';
     }
     return 'member';
 }
Exemplo n.º 3
0
<?php

if (empty($size)) {
    $size = 'sm';
}
$default_attrs = array('class' => array('btn', 'btn-default', 'js-update_toggle', 'btn-' . $size), 'id' => 'btn_follow_' . $member_id_to, 'data-uri' => sprintf('member/relation/api/update/%d/follow.json', $member_id_to));
if (!isset($attrs)) {
    $attrs = array();
}
$attrs = array_merge_recursive($default_attrs, $attrs);
if (empty($name)) {
    $name = $default_attrs['id'];
}
if (Model_MemberRelation::check_relation('follow', $member_id_from, $member_id_to)) {
    $label = '<span class="glyphicon glyphicon-ok"></span> ' . term('followed');
    $attrs['class'][] = 'btn-primary';
} else {
    $label = term('do_follow');
    $attrs['class'][] = 'btn-default';
}
$attrs = Util_Array::conv_arrays2str($attrs);
echo Form::button($name, $label, $attrs);