Пример #1
0
 /**
  * ページ編集
  */
 public function edit($name)
 {
     $this->vars('name', $name);
     try {
         $current = C(WikiPage)->find_get(Q::eq('name', $name), Q::order('-version'));
     } catch (Exception $e) {
     }
     if ($this->is_post()) {
         try {
             $page = new WikiPage();
             $page->cp($this->vars());
             if (isset($current)) {
                 $page->version($current->version() + 1);
             }
             $page->save();
             C($page)->commit();
             $this->redirect_method('model', $name);
         } catch (Exception $e) {
             $this->vars('page', $page);
             $this->vars('body', $page->body());
         }
     } else {
         if (isset($current)) {
             $this->vars('page', $current);
             $this->vars('body', $current->body());
         } else {
             $default = new WikiPage();
             $default->name($name);
             $this->vars('page', $default);
             $this->vars('body', '*' . $name);
         }
     }
 }
Пример #2
0
 function play($stage_id)
 {
     $stage = $this->dbUtil->get(new Stage(), new C(Q::eq(Stage::columnId(), $stage_id)));
     if (!Variable::istype('Stage', $stage)) {
         $this->_notFound();
         return $this->parser();
     }
     $this->setVariable('object', $stage);
     if ($this->isPost()) {
         // add comment
         $this->setVariable('stage_id', $stage->id);
         if ($this->dbUtil->insert($this->toObject(new Comment()))) {
             Header::redirect(Rhaco::url('play/' . $stage->id));
         }
     }
     $stage_file_name = Rhaco::path(sprintf('stages/%d.apif', $stage->id));
     $stage_data = unserialize(file_get_contents($stage_file_name));
     foreach ($stage_data as &$v) {
         if (preg_match('/^images.*?gif$/', $v['value'])) {
             $v['value'] = Rhaco::url($v['value']);
         }
     }
     $this->setVariable('stage_data', $stage_data);
     $this->setVariable('comments', $this->dbUtil->select(new Comment(), new C(Q::eq(Comment::columnStageId(), $stage->id))));
     return $this->parser('play.html');
 }
Пример #3
0
 public function mark_all_as_read(OpenpearMaintainer $maintainer)
 {
     foreach (C(__CLASS__)->find_all(Q::eq('maintainer_to_id', $maintainer->id())) as $message) {
         $message->unread(false);
         $message->save();
     }
 }
Пример #4
0
 public static function recount_favorites($package_id)
 {
     try {
         $fav_count = C(OpenpearFavorite)->find_count(Q::eq('package_id', $package_id));
         $package = C(OpenpearPackage)->find_get(Q::eq('id', $package_id));
         $package->favored_count($fav_count);
         $package->save();
     } catch (Exception $e) {
     }
 }
Пример #5
0
 public function maintainer()
 {
     if ($this->maintainer instanceof OpenpearMaintainer === false) {
         try {
             $this->maintainer = C(OpenpearMaintainer)->find_get(Q::eq('id', $this->maintainer_id()));
         } catch (Exception $e) {
         }
     }
     return $this->maintainer;
 }
Пример #6
0
 function isActive($db)
 {
     if ($this->private) {
         return ExceptionTrigger::raise(new GenericException('このイベントに参加することは出来ません'));
     }
     if ($this->periodDate < time()) {
         return ExceptionTrigger::raise(new GenericException('参加登録期限が過ぎています'));
     }
     if ($db->count(new Participant(), new C(Q::eq(Participant::columnEvent(), $this->id))) >= $this->maxParticipant) {
         return ExceptionTrigger::raise(new GenericException('参加登録可能人数を超えています'));
     }
     return true;
 }
Пример #7
0
 public function packages()
 {
     if (!empty($this->packages)) {
         return $this->packages;
     }
     $packages = array();
     try {
         $package_tags = C(OpenpearPackageTag)->find_all(Q::eq('tag_id', $this->id()));
         foreach ($package_tags as $package_tag) {
             $packages[] = $package_tag->package();
         }
     } catch (Exception $e) {
     }
     $this->packages = $packages;
     return $packages;
 }
Пример #8
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();
     }
 }
Пример #9
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;
 }
Пример #10
0
 /**
  * メンテナ情報を取得する
  * @param int $id
  * @param bool $cache
  * @return OpenpearMaintainar
  **/
 public static function get_maintainer($id, $cache = true)
 {
     $cache_key = self::cache_key($id);
     if ($cache) {
         Log::debug('cache on');
         if (isset(self::$cached_maintainers[$id])) {
             return self::$cached_maintainers[$id];
         } else {
             if (Store::has($cache_key)) {
                 $maintainer = Store::get($cache_key);
                 self::$cached_maintainers[$id] = $maintainer;
                 return $maintainer;
             }
         }
     }
     $maintainer = C(__CLASS__)->find_get(Q::eq('id', $id));
     Store::set($cache_key, $maintainer, OpenpearConfig::object_cache_timeout(3600));
     return $maintainer;
 }
Пример #11
0
 public function login_condition(Request $request)
 {
     if ($request->user() instanceof OpenpearMaintainer) {
         return true;
     }
     if ($request->is_post() && $request->is_vars('login') && $request->is_vars('password')) {
         try {
             $user = C(OpenpearMaintainer)->find_get(Q::ob(Q::b(Q::eq('name', $request->in_vars('login'))), Q::b(Q::eq('mail', $request->in_vars('login')))));
             if ($user instanceof OpenpearMaintainer) {
                 if ($user->certify($request->in_vars('password'))) {
                     $request->user($user);
                     return true;
                 } else {
                     Exceptions::add(new Exception('password is incorrect'), 'password');
                 }
             }
         } catch (Exception $e) {
             Log::debug($e);
         }
     }
     return false;
 }
Пример #12
0
 protected function where_sql(\ebi\Dao $dao, &$from, \ebi\Q $q, array $self_columns, $require_where = null, $alias = true)
 {
     if ($q->is_block()) {
         $vars = $and_block_sql = $or_block_sql = [];
         $where_sql = '';
         foreach ($q->ar_and_block() as $qa) {
             list($where, $var) = $this->where_sql($dao, $from, $qa, $self_columns, null, $alias);
             if (!empty($where)) {
                 $and_block_sql[] = $where;
                 $vars = array_merge($vars, $var);
             }
         }
         if (!empty($and_block_sql)) {
             $where_sql .= ' (' . implode(' and ', $and_block_sql) . ') ';
         }
         foreach ($q->ar_or_block() as $or_block) {
             list($where, $var) = $this->where_sql($dao, $from, $or_block, $self_columns, null, $alias);
             if (!empty($where)) {
                 $or_block_sql[] = $where;
                 $vars = array_merge($vars, $var);
             }
         }
         if (!empty($or_block_sql)) {
             $where_sql .= (empty($where_sql) ? '' : ' and ') . ' (' . implode(' or ', $or_block_sql) . ') ';
         }
         if (empty($where_sql)) {
             $where_sql = $require_where;
         } else {
             if (!empty($require_where)) {
                 $where_sql = '(' . $require_where . ') and (' . $where_sql . ')';
             }
         }
         return [$where_sql, $vars];
     }
     if ($q->type() == Q::MATCH && sizeof($q->ar_arg1()) > 0) {
         $query = new \ebi\Q();
         $target = $q->ar_arg2();
         $ob = $columns = [];
         foreach ($self_columns as $column) {
             if (empty($target) || in_array($column->name(), $target)) {
                 $columns[$column->name()] = $dao->prop_anon($column->name(), 'type');
             }
         }
         foreach ($columns as $cn => $ct) {
             $and = [];
             foreach ($q->ar_arg1() as $cond) {
                 $op = null;
                 if (substr($cond, 0, 1) == '-') {
                     $cond = substr($cond, 1);
                     $op = Q::NOT;
                 }
                 switch ($ct) {
                     case 'number':
                     case 'serial':
                     case 'integer':
                     case 'timestamp':
                     case 'date':
                     case 'time':
                     case 'intdate':
                         $and[] = Q::eq($cn, $cond, $op);
                         break;
                     case 'string':
                     case 'email':
                     case 'alnum':
                         $and[] = Q::contains($cn, $cond, $op);
                         break;
                     case 'boolean':
                     case 'mixed':
                     default:
                 }
             }
             if (!empty($and)) {
                 $ob[] = call_user_func_array(['\\ebi\\Q', 'b'], $and);
             }
         }
         $query->add(call_user_func_array(['\\ebi\\Q', 'ob'], $ob));
         return $this->where_sql($dao, $from, $query, $self_columns, null, $alias);
     }
     $and = $vars = [];
     foreach ($q->ar_arg2() as $base_value) {
         $or = [];
         foreach ($q->ar_arg1() as $column_str) {
             $value = $base_value;
             $column = $this->get_column($column_str, $self_columns);
             $column_alias = $this->column_alias_sql($column, $q, $alias);
             $is_add_value = true;
             switch ($q->type()) {
                 case Q::EQ:
                     if ($value === null) {
                         $is_add_value = false;
                         $column_alias .= ' is null';
                         break;
                     }
                     $column_alias .= ' = ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::NEQ:
                     if ($value === null) {
                         $is_add_value = false;
                         $column_alias .= ' is not null';
                         break;
                     }
                     $column_alias .= ' <> ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::GT:
                     $column_alias .= ' > ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::GTE:
                     $column_alias .= ' >= ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::LT:
                     $column_alias .= ' < ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::LTE:
                     $column_alias .= ' <= ' . ($value instanceof \ebi\Daq ? '(' . $value->unique_sql() . ')' : '?');
                     break;
                 case Q::CONTAINS:
                 case Q::START_WITH:
                 case Q::END_WITH:
                     $column_alias = $this->format_column_alias_sql($column, $q, $alias);
                     $column_alias .= ($q->not() ? ' not' : '') . ' like(?)';
                     $value = ($q->type() == Q::CONTAINS || $q->type() == Q::END_WITH ? '%' : '') . $value . ($q->type() == Q::CONTAINS || $q->type() == Q::START_WITH ? '%' : '');
                     break;
                 case Q::IN:
                     $column_alias .= ($q->not() ? ' not' : '') . ($value instanceof \ebi\Daq ? ' in(' . $value->unique_sql() . ')' : ' in(' . substr(str_repeat('?,', sizeof($value)), 0, -1) . ')');
                     break;
                 case Q::DISCORD:
                     $and[] = '1 = 2';
                     $is_add_value = false;
                     break;
             }
             if ($value instanceof \ebi\Daq) {
                 $is_add_value = false;
                 $vars = array_merge($vars, $value->ar_vars());
             }
             $add_join_conds = $dao->join_conds($column->name());
             if (!empty($add_join_conds)) {
                 $column_alias .= ' and ' . $this->where_cond_columns($add_join_conds, $from);
             }
             $or[] = $column_alias;
             if ($is_add_value) {
                 if (is_array($value)) {
                     $values = [];
                     foreach ($value as $v) {
                         $values[] = $q->ignore_case() ? strtoupper($this->column_value($dao, $column->name(), $v)) : $this->column_value($dao, $column->name(), $v);
                     }
                     $vars = array_merge($vars, $values);
                 } else {
                     $vars[] = $q->ignore_case() ? strtoupper($this->column_value($dao, $column->name(), $value)) : $this->column_value($dao, $column->name(), $value);
                 }
             }
         }
         $and[] = ' (' . implode(' or ', $or) . ') ';
     }
     return [implode(' and ', $and), $vars];
 }
Пример #13
0
<?php

require_once '__init__.php';
Rhaco::import('generic.Urls');
Rhaco::import('model.Todo');
Rhaco::import('model.Category');
$db = new DbUtil(Category::connection());
$patterns = array('^$' => array('class' => 'generic.Views', 'method' => 'read', 'args' => array(new Todo(), new C(Q::eq(Todo::columnClose(), false), Q::fact())), 'template' => 'list.html'), '^detail/(\\d+)$' => array('method' => 'detail', 'args' => array(new Todo(), new C(Q::fact()))), '^create$' => array('method' => 'create', 'args' => array(new Todo(), Rhaco::url())), '^update/(\\d+)$' => array('method' => 'update', 'args' => array(new Todo(), null, Rhaco::url())), '^delete/(\\d+)$' => array('method' => 'delete', 'args' => array(new Todo(), null, Rhaco::url())), '^cat/(\\d+)$' => array('method' => 'detail', 'args' => array(new Category(), new C(Q::depend()))));
$parser = Urls::parser($patterns, $db);
$parser->setVariable('categories', $db->select(new Category()));
$parser->write();
Пример #14
0
 /**
  * パッケージのビルドとリリースを行う
  * @return void
  **/
 public function build()
 {
     $package = C(OpenpearPackage)->find_get(Q::eq('id', $this->package_id));
     $maintainer = C(OpenpearMaintainer)->find_get(Q::eq('id', $this->maintainer_id));
     $this->init_build_dir(work_path('build/' . $package->name() . '.' . date('YmdHis')));
     foreach (array('desc.txt', 'notes.txt', 'summary.txt') as $filename) {
         File::write($this->build_dir($filename), $package->description());
     }
     if ($package->is_external_repository()) {
         switch ($package->external_repository_type()) {
             case 'Git':
                 $cmd = 'git clone';
                 break;
             case 'Mercurial':
                 $cmd = 'hg clone';
                 break;
             case 'Subversion':
                 $cmd = 'svn export';
                 break;
             default:
                 throw new RuntimeException('unknown repository type');
         }
         $command = new Command(sprintf('%s %s %s', $cmd, escapeshellarg($package->external_repository()), escapeshellarg($this->build_dir('tmp'))));
     } else {
         // Openpear Repository
         $revision = is_numeric($this->revision) && $this->revision > 0 ? intval($this->revision) : 'HEAD';
         $repository_path = sprintf('%s/%s/trunk', OpenpearConfig::svn_root(), $package->name());
         $command = new Command(sprintf('svn export -r %s %s %s', $revision, escapeshellarg($repository_path), escapeshellarg($this->build_dir('tmp'))));
     }
     if ($command->end_code()) {
         throw new RuntimeException($command->stderr());
     }
     $build_path = $this->build_dir(implode('/', array('tmp', $this->build_path)));
     if (!File::exist($build_path)) {
         throw new RuntimeException(sprintf('build path is not found: %s', $build_path));
     }
     $mv = new Command(sprintf('mv %s %s', escapeshellarg($build_path), escapeshellarg($this->build_dir('src'))));
     if ($mv->stderr() || !is_dir($this->build_dir('src'))) {
         throw new RuntimeException('src dir is not found');
     }
     // ビルドする
     chdir($this->build_dir());
     $project = PEAR_PackageProjector::singleton()->load($this->build_dir());
     $project->configure($this->build_dir('build.conf'));
     $project->make();
     // リリースしたファイルはどこ?
     chdir($this->build_dir('release'));
     foreach (glob('*.tgz') as $filename) {
         $package_file = $this->build_dir('release') . '/' . $filename;
         break;
     }
     if (!file_exists($package_file)) {
         throw new RuntimeException('package file is not exists: ' . $package_file);
     }
     // サーバーに追加する
     $cfg = (include path('channel.config.php'));
     $server = new PEAR_Server2($cfg);
     $server->addPackage($package_file);
     // svn tag
     $build_conf = parse_ini_string($this->build_conf, true);
     $svn = new Command(sprintf('svn copy' . ' %s/%s/trunk/%s' . ' %s/%s/tags/%s-%s-%s' . ' -m "%s (%s-%s) (@%s)"' . ' --username openpear', OpenpearConfig::svn_root(), $package->name(), $this->build_path, OpenpearConfig::svn_root(), $package->name(), $build_conf['version']['release_ver'], $build_conf['version']['release_stab'], date('YmdHis'), 'package released', $build_conf['version']['release_ver'], $build_conf['version']['release_stab'], $maintainer->name()));
     // これ以降はエラーが起きてもドンマイ
     try {
         $release = new OpenpearRelease();
         $release->package_id($package->id());
         $release->maintainer_id($maintainer->id());
         $release->version($build_conf['version']['release_ver']);
         $release->version_stab($build_conf['version']['release_stab']);
         $release->notes($this->notes);
         $release->settings($this->build_conf);
         $release->save();
         $package->latest_release_id($release->id());
         $package->released_at(time());
         $package->save();
         $message_template = new Template();
         $message_template->vars('t', new Templf());
         $message_template->vars('package', $package);
         $message_template->vars('maintainer', $maintainer);
         $message = new OpenpearMessage('type=system');
         $message->maintainer_to_id($maintainer->id());
         $message->subject(trans('{1} package have been released.', $package->name()));
         $message->description($message_template->read('messages/released.txt'));
         $message->save();
     } catch (Exception $e) {
         Log::error($e);
     }
 }
Пример #15
0
 /**
  * DBの値と同じにする
  * @return $this
  */
 public function sync()
 {
     $query = new \ebi\Q();
     $query->add(new \ebi\Paginator(1, 1));
     foreach ($this->primary_columns() as $column) {
         $query->add(Q::eq($column->name(), $this->{$column->name()}()));
     }
     foreach (self::get_statement_iterator($this, $query) as $dao) {
         foreach (get_object_vars($dao) as $k => $v) {
             if ($k[0] != '_') {
                 $this->{$k}($v);
             }
         }
         return $this;
     }
     throw new \ebi\exception\NotFoundException('synchronization failed');
 }
Пример #16
0
 /**
  * ファイルアップロードからリリース
  * @param string $package_name パッケージ名
  **/
 public function package_release_by_upload($package_name)
 {
     $package = C(OpenpearPackage)->find_get(Q::eq('name', $package_name));
     $package->permission($this->user());
     if ($this->is_post() && $this->is_files('package_file') && $this->verify()) {
         try {
             $package_file = $this->in_files('package_file');
             $package_file->generate(work_path('upload/' . $package_name . '-' . date('YmdHis') . '.tgz'));
             if ($package_xml = simplexml_load_file(sprintf('phar://%s/package.xml', $package_file->fullname()))) {
                 if ($package_xml->name != $package->name()) {
                     throw new OpenpearException(Gettext::trans('incorrect package name'));
                 }
                 if ($package_xml->channel != OpenpearConfig::pear_domain('openpear.org')) {
                     $package_xml->channel = OpenpearConfig::pear_domain('openpear.org');
                     $pd = new PharData($package_file->fullname());
                     $pd->addFromString('package.xml', $package_xml->asXML());
                     unset($pd);
                 }
                 $upload_queue = new stdClass();
                 $upload_queue->package_id = $package->id();
                 $upload_queue->package_file = $package_file->fullname();
                 $upload_queue->maintainer_id = $this->user()->id();
                 $queue = new OpenpearQueue('type=upload_release');
                 $queue->data(serialize($upload_queue));
                 $queue->save();
                 $message = new OpenpearMessage('type=system_notice,mail=false');
                 $message->maintainer_to_id($this->user()->id());
                 $message->subject(trans('リリースキューに追加されました'));
                 $message->description(trans('{1}のリリースを受け付けました。リリースの完了後,メールでお知らせします。', $package->name()));
                 $message->save();
                 $this->redirect_by_map('dashboard');
             }
         } catch (Exception $e) {
             Log::debug($e);
             Exceptions::add($e);
         }
     }
     $this->vars('package', $package);
     $this->vars('package_id', $package->id());
 }
Пример #17
0
 /**
  * DBの値と同じにする
  * @return Dao
  */
 public final function sync()
 {
     $query = array();
     foreach ($this->primary_columns() as $column) {
         $query[] = Q::eq($column->name(), $this->{$column->name()}());
     }
     $this->cp(call_user_func_array(array(C($this->_class_), "find_get"), $query));
     return $this;
 }
Пример #18
0
 protected function where_match(Q $q, array $self_columns)
 {
     $query = new Q();
     foreach ($q->arArg1() as $cond) {
         if (strpos($cond, "=") !== false) {
             list($column, $value) = explode("=", $cond);
             $not = substr($value, 0, 1) == "!";
             $value = $not ? strlen($value) > 1 ? substr($value, 1) : "" : $value;
             if ($value === "") {
                 $query->add($not ? Q::neq($column, "") : Q::eq($column, ""));
             } else {
                 $query->add($not ? Q::contains($column, $value, $q->param() | Q::NOT) : Q::contains($column, $value, $q->param()));
             }
         } else {
             $columns = array();
             foreach ($self_columns as $column) {
                 $columns[] = $column->name();
             }
             $query->add(Q::contains(implode(",", $columns), explode(" ", $cond), $q->param()));
         }
     }
     return $query;
 }
Пример #19
0
<?php

require dirname(__FILE__) . '/__init__.php';
Rhaco::import('tag.HtmlParser');
$db = new DbUtil(Event::connection());
$p = new HtmlParser('index.html');
$p->setVariable('event', $db->get(new Event(), new C(Q::depend(), Q::eq(Event::columnId(), Rhaco::constant('CURRENT_EVENT', 1)))));
$p->setVariable('hatena', Rhaco::obj('HatenaSyntax', array('headlevel' => 4, 'id' => 'event_description')));
$p->write();
Пример #20
0
 public function model($id)
 {
     $this->vars('object', C(StatusMessage)->find_get(Q::eq('id', $id)));
     return $this;
 }
Пример #21
0
 public static function commit_hook($path, $revision, $message)
 {
     Log::debug(sprintf('commit hook: %s %d "%s"', $path, $revision, $message));
     $changed = Subversion::look('changed', array($path), array('revision' => $revision));
     $author = trim(Subversion::look('author', array($path), array('revision' => $revision)));
     $parsed_changed = self::parse_svnlook_changed($changed);
     list($package_name) = explode('/', $parsed_changed[0]['path']);
     try {
         $package = C(OpenpearPackage)->find_get(Q::eq('name', $package_name));
         $maintainer = null;
         try {
             if ($author == OpenpearConfig::system_user('openpear') && preg_match('/\\(@(.*?)\\)$/', trim($message), $match)) {
                 $author = $match[1];
             }
             $maintainer = C(OpenpearMaintainer)->find_get(Q::eq('name', $author));
         } catch (Exception $e) {
             Log::error($e);
             // throw $e;
         }
         $changeset = new self();
         $changeset->revision($revision);
         if ($maintainer instanceof OpenpearMaintainer) {
             $changeset->maintainer_id($maintainer->id());
         }
         $changeset->package_id($package->id());
         $changeset->changed(serialize($parsed_changed));
         $changeset->save();
         if ($maintainer instanceof OpenpearMaintainer) {
             $package->author_id($maintainer->id());
         }
         $package->recent_changeset($changeset->revision());
         $package->save(true);
     } catch (Exception $e) {
         throw $e;
     }
     try {
         chdir(OpenpearConfig::working_copy());
         ob_start();
         passthru('svn up');
         ob_end_clean();
     } catch (Exception $e) {
     }
 }
Пример #22
0
 public function package_tags()
 {
     // setting package tags
     if (empty($this->package_tags)) {
         try {
             $this->package_tags = C(OpenpearPackageTag)->find_all(Q::eq('package_id', $this->id()), Q::order('-prime'));
         } catch (Exception $e) {
         }
     }
     return $this->package_tags;
 }
Пример #23
0
 /**
  * メンテナのタイムラインをAtomフィードで出力
  * @param string $maintainer_name メンテナのアカウント名
  */
 public function timeline_atom_maintainer($maintainer_name)
 {
     // TODO 仕様の確認
     $maintainer = C(OpenpearMaintainer)->find_get(Q::eq('name', $maintainer_name));
     Atom::convert('Openpear Maintainer Timelines: ' . $maintainer->name(), url('timelines.atom'), C(OpenpearTimeline)->find_all(new Paginator(20), Q::eq('maintainer_id', $maintainer->id()), Q::order('-created')))->output();
 }
Пример #24
0
 public function tag()
 {
     if ($this->tag instanceof OpenpearTag) {
         return $this->tag;
     }
     try {
         $this->tag = C(OpenpearTag)->find_get(Q::eq('id', $this->tag_id()));
     } catch (Exception $e) {
     }
     return $this->tag;
 }
Пример #25
0
 public static function fetch_queues($type, $limit = 5)
 {
     return C(OpenpearQueue)->find_all(new Paginator($limit), Q::lt('locked', time()), Q::eq('type', $type), Q::order('updated'));
 }
Пример #26
0
        $queue->delete();
    } catch (Exception $e) {
        echo $e->getMessage();
        Log::error($e);
        C($queue)->rollback();
    }
}
foreach (OpenpearQueue::fetch_queues('upload_release') as $queue) {
    try {
        $queue->start(300);
        $upload_queue = $queue->fm_data();
        if (is_object($upload_queue) == false) {
            throw new RuntimeException('queue data is broken');
        }
        $maintainer = C(OpenpearMaintainer)->find_get(Q::eq('id', $upload_queue->maintainer_id));
        $package = C(OpenpearPackage)->find_get(Q::eq('id', $upload_queue->package_id));
        $package_file = $upload_queue->package_file;
        if (!file_exists($package_file)) {
            throw new RuntimeException('package_file is not found');
        }
        if (!Tag::setof($xml, file_get_contents(sprintf('phar://%s/package.xml', $package_file)), 'package')) {
            throw new RuntimeException('package.xml is unreadable');
        }
        $version = $xml->f('version.release.value()');
        $stab = $xml->f('stability.release.value()');
        // サーバーに追加する
        $cfg = (include path('channel.config.php'));
        $server = new PEAR_Server2($cfg);
        $server->addPackage($package_file);
        // これ以降はエラーが起きてもドンマイ
        try {