Esempio n. 1
0
 public function permission(OpenpearMaintainer $maintainer, $throw = false)
 {
     if ($this->maintainer_to_id() == $maintainer->id() || $this->maintainer_from_id() == $maintainer->id()) {
         return true;
     }
     if ($throw) {
         throw new OpenpearException('permission denied');
     }
     return false;
 }
Esempio n. 2
0
 public final function isme(OpenpearMaintainer $maintainer)
 {
     if ($this->user instanceof OpenpearMaintainer && $this->user->id() == $maintainer->id()) {
         return true;
     }
     return false;
 }
Esempio n. 3
0
 public static function get_by_maintainer(OpenpearMaintainer $maintainer, $limit = 20)
 {
     try {
         $favorites = C(OpenpearFavorite)->find_all(Q::eq('maintainer_id', $maintainer->id()));
         $charges = C(OpenpearCharge)->find_all(Q::eq('maintainer_id', $maintainer->id()));
         $ids = array();
         foreach ($favorites as $f) {
             $ids[] = $f->package_id();
         }
         foreach ($charges as $c) {
             $ids[] = $c->package_id();
         }
         return C(OpenpearTimeline)->find_all(new Paginator($limit), Q::in('package_id', array_unique($ids)), Q::order('-id'));
     } catch (Exception $e) {
         return array();
     }
 }
Esempio n. 4
0
 public static function packages(OpenpearMaintainer $maintainer)
 {
     $store_key = array('charges_maintainer', $maintainer->id());
     if (Store::has($store_key, self::CACHE_TIMEOUT)) {
         $packages = Store::get($store_key);
     } else {
         try {
             $packages = array();
             $charges = C(OpenpearCharge)->find_all(Q::eq('maintainer_id', $maintainer->id()));
             foreach ($charges as $charge) {
                 $packages[] = $charge->package();
             }
         } catch (Exception $e) {
             $packages = array();
         }
         Store::set($store_key, $packages, self::CACHE_TIMEOUT);
     }
     return $packages;
 }
Esempio n. 5
0
 /**
  * メンテナを追加する
  * @param OpenpearMaintainer $maintainer
  * @param string $role
  * @return void
  **/
 public function add_maintainer(OpenpearMaintainer $maintainer, $role = 'lead')
 {
     $charge = new OpenpearCharge();
     $charge->maintainer_id($maintainer->id());
     $charge->package_id($this->id());
     $charge->role($role);
     $charge->save();
 }
Esempio n. 6
0
 /**
  * 新規登録
  * @context boolean $openid
  */
 public function signup()
 {
     // TODO 仕様の確認
     if ($this->in_sessions('openid_identity')) {
         $this->vars('openid', true);
         $this->vars('openid_identity', $this->in_sessions('openid_identity'));
     } else {
         $this->vars('openid', false);
     }
     $account = new OpenpearMaintainer();
     try {
         if ($this->is_post()) {
             $account->cp($this->vars());
             $account->new_password($this->in_vars('new_password'));
             $account->new_password_conf($this->in_vars('new_password_conf'));
             $account->save();
             if ($this->is_sessions('openid_identity')) {
                 $openid_maintainer = new OpenpearOpenidMaintainer();
                 $openid_maintainer->maintainer_id($account->id());
                 $openid_maintainer->url($this->in_sessions('openid_identity'));
                 $openid_maintainer->save();
                 $this->rm_sessions('openid_identity');
             }
             $this->user($account);
             parent::login();
             $this->redirect_by_map("success_redirect");
         }
     } catch (Exception $e) {
         Dao::rollback_all();
         Log::debug($e);
     }
     $this->cp($account);
 }