예제 #1
0
 public function get_newest_log($pid, $limit)
 {
     $list = Model_OperateLog::data_access()->filter(Model_OperateLog::PID, intval($pid))->limit(intval($limit))->sort(Model_OperateLog::ID)->find();
     if (empty($list)) {
         return $list;
     }
     $ids = array();
     $uids = array();
     foreach ($list as $row) {
         $ids[] = $row->id;
         if (!in_array($row->user_id, $uids)) {
             $uids[] = $row->user_id;
         }
     }
     $users = Biz_User::get_instance()->get_users_map($uids);
     foreach ($list as $key => $row) {
         if (array_key_exists($row->user_id, $users)) {
             $list[$key]->user = $users[$row->user_id];
         }
     }
     $cmds = Biz_Command::get_instance()->get_cmds_map($ids);
     foreach ($list as $key => $row) {
         if (array_key_exists($row->id, $cmds)) {
             $list[$key]->cmd = $cmds[$row->id];
         }
     }
     return $list;
 }
예제 #2
0
 public static function get_instance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #3
0
 private function _get_diff_file($project, $v1, $v2)
 {
     if ($v1 === '' || $v2 === '') {
         return '';
     }
     $update_path = APF::get_instance()->get_config("update_path");
     $is_git = Biz_Command::get_instance()->is_git($project->id);
     if ($is_git) {
         $git_diff_format = APF::get_instance()->get_config("git_diff_format");
         $cmd = sprintf($git_diff_format, $update_path, $project->name, $v1, $v2);
     } else {
         $svn_diff_format = APF::get_instance()->get_config("svn_diff_format");
         $cmd = sprintf($svn_diff_format, $v1, $v2, $update_path, $project->name);
     }
     $retval = shell_exec($cmd);
     return $retval;
 }
예제 #4
0
 private function _op()
 {
     if (!isset($this->_param['pid']) || empty($this->_param['pid'])) {
         $this->_response->redirect(PageHelper::get_domain() . '/project/list');
     }
     $pid = intval($this->_param['pid']);
     $project = Biz_Project::get_instance()->get_info($pid);
     $is_git = Biz_Command::get_instance()->is_git($pid);
     $sdk = Biz_Sdk::get_instance()->get_sdk($pid);
     $this->_request->set_attribute('project', $project);
     $this->_request->set_attribute('is_git', $is_git);
     $this->_request->set_attribute('page_title', $project->name);
     $this->_request->set_attribute('viewpage', 'project/op');
     $this->_request->set_attribute('menu_id', 1);
     $this->_request->set_attribute('sdk', $sdk);
     return "Abstract";
 }
예제 #5
0
 private function _switch()
 {
     $pid = intval($this->_param['pid']);
     $param = isset($this->_param['param']) ? trim($this->_param['param']) : '';
     $desc = isset($this->_param['desc']) ? trim($this->_param['desc']) : '';
     $project = Biz_Project::get_instance()->get_info($pid);
     $input = array();
     $input['pid'] = $pid;
     $input['user_id'] = $this->_user->id;
     $input['op'] = 2;
     $input['param'] = $param;
     $input['desc'] = $desc;
     $input['status'] = 0;
     $oplog_id = Biz_OperateLog::get_instance()->insert($input);
     $input['id'] = $oplog_id;
     Biz_Command::get_instance()->insert($input);
     Biz_Project::get_instance()->update($pid, array('pversion' => $project->version, 'version' => $param));
     $this->_response->redirect(PageHelper::get_domain() . '/project/op?pid=' . $pid);
 }
예제 #6
0
         }
     } catch (Exception $ex) {
     }
 }
 #$msg = system("{$c->command} >> /tmp/ipublish.log 2>&1",$exit_val);
 $msg = system($c->command, $exit_val);
 $status = 0;
 if ($exit_val == 0) {
     $status = 1;
     //insert sync log
     try {
         $oplog = Model_OperateLog::data_access()->filter(Model_OperateLog::ID, $c->id)->find_one();
         if ($oplog->op == 1) {
             $project = Model_Project::data_access()->filter(Model_Project::ID, $c->pid)->find_one();
             $dir = APF::get_instance()->get_config('update_path') . '/' . $project->name;
             $is_git = Biz_Command::get_instance()->is_git($c->pid) ? 1 : 0;
             $script_path = APF::get_instance()->get_config('script_path');
             $command = "sh {$script_path}/get_version.sh -d '{$dir}' -i '{$is_git}'";
             $identify = system($command, $vers_exit);
             if ($vers_exit == 0) {
                 $synclog = new Model_SyncLog();
                 $synclog->pid = $c->pid;
                 $synclog->param = $oplog->param;
                 $synclog->identify = $identify;
                 $synclog->save();
             }
         }
     } catch (Exception $ex) {
     }
 } else {
     $status = $exit_val;