dao->select('*')->from(TABLE_PROJECT) ->where('iscat')->eq(0) ->andWhere('template')->ne('') ->andWhere('program')->eq(0) ->andWhere('deleted')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi() ->beginIF($status != 'all')->andWhere('status')->eq($status)->fi() ->beginIF($this->cookie->mine) ->andWhere('openedBy', true)->eq($this->app->user->account) ->orWhere('PM')->eq($this->app->user->account) ->markRight(1) ->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); } public function getPairs() { return $this->dao->select('id, name')->from(TABLE_PROJECT) ->where('iscat')->eq(0) ->andWhere('program')->eq(0) ->andWhere('deleted')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi() ->fetchPairs(); } public function getPairsByTemplate($template) { return $this->dao->select('id, name')->from(TABLE_PROJECT) ->where('iscat')->eq(0) ->andWhere('template')->eq($template) ->andWhere('program')->eq(0) ->andWhere('deleted')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi() ->fetchPairs(); } /** * Show accessDenied response. * * @access private * @return void */ public function accessDenied() { echo(js::alert($this->lang->program->accessDenied)); if(!$this->server->http_referer) die(js::locate(helper::createLink('program', 'browse'))); $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; if(strpos($this->server->http_referer, $loginLink) !== false) die(js::locate(helper::createLink('program', 'browse'))); die(js::locate('back')); } public function create() { $this->lang->project->team = $this->lang->project->teamname; $project = fixer::input('post') ->setDefault('status', 'wait') ->add('type', 'program') ->setIF($this->post->acl != 'custom', 'whitelist', '') ->setDefault('openedBy', $this->app->user->account) ->setDefault('openedDate', helper::now()) ->setDefault('team', substr($this->post->name,0, 30)) ->join('whitelist', ',') ->cleanInt('budget') ->stripTags($this->config->project->editor->create['id'], $this->config->allowedTags) ->remove('products, workDays, delta, branch, uid, plans') ->get(); $project = $this->loadModel('file')->processImgURL($project, $this->config->project->editor->create['id'], $this->post->uid); $this->dao->insert(TABLE_PROJECT)->data($project) ->autoCheck() ->batchcheck($this->config->project->create->requiredFields, 'notempty') ->check('name', 'unique', "deleted='0'") ->check('code', 'unique', "deleted='0'") ->exec(); /* Add the creater to the team. */ if(!dao::isError()) { $programID = $this->dao->lastInsertId(); $today = helper::today(); if($project->acl != 'open') $this->loadModel('user')->updateUserView($programID, 'program'); /* Save order. */ $this->dao->update(TABLE_PROJECT)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec(); $this->file->updateObjectID($this->post->uid, $programID, 'project'); if($project->parent > 0) { $this->dao->update(TABLE_PROJECT)->set('isCat')->eq(1)->where('id')->eq($project->parent)->exec(); $this->fixPath($programID); } /* Add program admin.*/ $groupPriv = $this->dao->select('t1.*')->from(TABLE_USERGROUP)->alias('t1') ->leftJoin(TABLE_GROUP)->alias('t2')->on('t1.group = t2.id') ->where('t1.account')->eq($this->app->user->account) ->andWhere('t2.role')->eq('pgmadmin') ->fetch(); if(!empty($groupPriv)) { $newProgram = $groupPriv->program . ",$programID"; $this->dao->update(TABLE_USERGROUP)->set('program')->eq($newProgram)->where('account')->eq($groupPriv->account)->andWhere('`group`')->eq($groupPriv->group)->exec(); } else { $pgmAdminID = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->eq('pgmadmin')->fetch('id'); $groupPriv = new stdclass(); $groupPriv->account = $this->app->user->account; $groupPriv->group = $pgmAdminID; $groupPriv->program = $programID; $this->dao->insert(TABLE_USERGROUP)->data($groupPriv)->exec(); } if($project->template == 'cmmi') { $product = new stdclass(); $product->name = $project->name; $product->program = $programID; $product->status = 'normal'; $product->createdBy = $this->app->user->account; $product->createdDate = helper::now(); $this->dao->insert(TABLE_PRODUCT)->data($product)->exec(); $productID = $this->dao->lastInsertId(); $this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($productID * 5)->where('id')->eq($productID)->exec(); /* Create doc lib. */ $this->app->loadLang('doc'); $lib = new stdclass(); $lib->product = $productID; $lib->name = $this->lang->doclib->main['product']; $lib->type = 'product'; $lib->main = '1'; $lib->acl = 'default'; $this->dao->insert(TABLE_DOCLIB)->data($lib)->exec(); $docLibID = $this->dao->lastInsertId(); $this->loadModel('doc')->syncDocModule($docLibID); $data = new stdclass(); $data->project = $programID; $data->product = $productID; $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec(); } return $programID; } } public function getSwapper($programs, $programID, $currentModule, $currentMethod, $extra = '') { $this->loadModel('project'); $currentProgramName = ''; if($programID) { setCookie("lastProgram", $programID, $this->config->cookieLife, $this->config->webRoot, '', false, true); $currentProgram = $this->project->getById($programID); $currentProgramName = $currentProgram->name; } if($currentModule == 'program' && $currentMethod == 'browse') $currentProgramName = $this->lang->program->all; $dropMenuLink = helper::createLink('program', 'ajaxGetDropMenu', "objectID=$programID&module=$currentModule&method=$currentMethod&extra=$extra"); $output = "