예제 #1
0
 /**
  * AJAX: the api to recive the file posted through ajax.
  * 
  * @param  string $uid 
  * @access public
  * @return array
  */
 public function ajaxUpload($uid)
 {
     if (RUN_MODE == 'front' and !commonModel::isAvailable('forum')) {
         exit;
     }
     if (!$this->loadModel('file')->canUpload()) {
         $this->send(array('error' => 1, 'message' => $this->lang->file->uploadForbidden));
     }
     $file = $this->file->getUpload('imgFile');
     $file = $file[0];
     if ($file) {
         if (!$this->file->checkSavePath()) {
             $this->send(array('error' => 1, 'message' => $this->lang->file->errorUnwritable));
         }
         if (!in_array(strtolower($file['extension']), $this->config->file->imageExtensions)) {
             $this->send(array('error' => 1, 'message' => $this->lang->fail));
         }
         move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);
         if (in_array(strtolower($file['extension']), $this->config->file->imageExtensions) !== false) {
             $this->file->compressImage($this->file->savePath . $file['pathname']);
             $imageSize = $this->file->getImageSize($this->file->savePath . $file['pathname']);
             $file['width'] = $imageSize['width'];
             $file['height'] = $imageSize['height'];
         }
         $url = $this->file->webPath . $file['pathname'];
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = helper::now();
         $file['editor'] = 1;
         unset($file['tmpname']);
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
         $_SESSION['album'][$uid][] = $this->dao->lastInsertID();
         die(json_encode(array('error' => 0, 'url' => $url)));
     }
 }
예제 #2
0
파일: model.php 프로젝트: leowh/colla
 /**
  * Create resume. 
  * 
  * @param  int    $contactID 
  * @param  object $resume 
  * @access public
  * @return int
  */
 public function create($contactID, $resume = null)
 {
     if (empty($resume)) {
         $resume = fixer::input('post')->add('contact', $contactID)->remove('newCustomer,type,size,status,level,name')->get();
         if ($this->post->newCustomer) {
             $customer = new stdclass();
             $customer->name = $this->post->name;
             $customer->type = $this->post->type;
             $customer->size = $this->post->size;
             $customer->status = $this->post->status;
             $customer->level = $this->post->level;
             $customer->assignedTo = $this->app->user->account;
             $customer->createdBy = $this->app->user->account;
             $customer->createdDate = helper::now();
             $return = $this->loadModel('customer')->create($customer);
             if ($return['result'] == 'fail') {
                 return false;
             }
             $resume->customer = $return['customerID'];
             $this->loadModel('action')->create('customer', $resume->customer, 'Created');
         }
     }
     $this->dao->insert(TABLE_RESUME)->data($resume)->autoCheck()->batchCheck($this->config->resume->require->create, 'notempty')->exec();
     if (!dao::isError()) {
         $resumeID = $this->dao->lastInsertID();
         $this->dao->update(TABLE_CONTACT)->set('resume')->eq($resumeID)->where('id')->eq($contactID)->exec();
         return $resumeID;
     }
     return false;
 }
예제 #3
0
파일: model.php 프로젝트: leowh/colla
 /**
  * Update a product.
  * 
  * @param  int $productID 
  * @access public
  * @return void
  */
 public function update($productID)
 {
     $oldProduct = $this->getByID($productID);
     $product = fixer::input('post')->add('editedBy', $this->app->user->account)->add('editedDate', helper::now())->get();
     $this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck()->batchCheck($this->config->product->require->edit, 'notempty')->where('id')->eq($productID)->exec();
     if (dao::isError()) {
         return false;
     }
     return commonModel::createChanges($oldProduct, $product);
 }
예제 #4
0
파일: control.php 프로젝트: leowh/colla
 /**
  * keep logon function.
  * 
  * @access public
  * @return void
  */
 public function ping($notice = '')
 {
     /* Save attend info. */
     $this->loadModel('attend', 'oa')->signOut();
     /* Save online status. */
     $this->loadModel('user')->online();
     /* Get notices. */
     $notices = $this->loadModel('action')->getUnreadNotice('', $skipNotice = $notice);
     $res = new stdclass();
     $res->time = helper::now();
     $res->notices = $notices;
     die(json_encode($res));
 }
예제 #5
0
 /**
  * set company basic info.
  * 
  * @access public
  * @return void
  */
 public function setBasic()
 {
     if (!empty($_POST)) {
         $now = helper::now();
         $company = fixer::input('post')->add('setDate', $now)->stripTags('desc,content', $this->config->allowedTags->admin)->remove('uid')->get();
         $result = $this->loadModel('setting')->setItems('system.common.company', $company);
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
         }
         $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
     }
     $this->view->title = $this->lang->company->setBasic;
     $this->display();
 }
예제 #6
0
파일: control.php 프로젝트: leowh/colla
 /**
  * set company basic info.
  * 
  * @access public
  * @return void
  */
 public function setBasic()
 {
     if (!empty($_POST)) {
         $now = helper::now();
         $company = fixer::input('post')->stripTags('content', $this->config->allowedTags->admin)->get();
         $company = $this->loadModel('file')->processEditor($company, $this->config->company->editor->setbasic['id']);
         $result = $this->loadModel('setting')->setItems('system.sys.common.company', $company);
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
         }
         $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
     }
     $this->view->title = $this->lang->company->setBasic;
     $this->display();
 }
예제 #7
0
 /**
  * Create an consulting.
  * 
  * @param  string $type 
  * @access public
  * @return int|bool
  */
 public function create()
 {
     $now = helper::now();
     $consulting = fixer::input('post')->setDefault('addedDate', $now)->get();
     $consult = $this->dao->select('*')->from(TABLE_CONSULTING)->where('realname')->eq($consulting->realname)->andWhere('mobile')->eq($consulting->mobile)->andWhere('email')->eq($consulting->email)->fetch();
     if ($consult) {
         return array('result' => 'fail', 'message' => '请不要重复提交!<a href="javascript:history.back();">返回</a>');
     } else {
         $this->dao->insert(TABLE_CONSULTING)->data($consulting)->exec();
         $consultingID = $this->dao->lastInsertID();
         if (dao::isError()) {
             return array('result' => 'fail', 'message' => dao::getError());
         }
         return array('result' => 'success', 'message' => '提交成功!');
     }
 }
예제 #8
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Create a action.
  * 
  * @param  string $objectType 
  * @param  int    $objectID 
  * @param  string $actionType 
  * @param  string $comment 
  * @param  string $extra        the extra info of this action, according to different modules and actions, can set different extra.
  * @access public
  * @return int
  */
 public function create($objectType, $objectID, $actionType, $comment = '', $extra = '')
 {
     $objectType = str_replace('`', '', $objectType);
     $action->objectType = strtolower($objectType);
     $action->objectID = $objectID;
     $action->actor = $this->app->user->account;
     $action->action = strtolower($actionType);
     $action->date = helper::now();
     $action->comment = htmlspecialchars($comment);
     $action->extra = $extra;
     /* Get product and project for this object. */
     $productAndProject = $this->getProductAndProject($objectType, $objectID);
     $action->product = $productAndProject['product'];
     $action->project = $productAndProject['project'];
     $this->dao->insert(TABLE_ACTION)->data($action)->autoCheck()->exec();
     return $this->dbh->lastInsertID();
 }
예제 #9
0
파일: control.php 프로젝트: leowh/colla
 /**
  * AJAX: the api to recive the file posted through ajax.
  * 
  * @param  string $uid 
  * @access public
  * @return array
  */
 public function ajaxUpload($uid)
 {
     $file = $this->file->getUpload('imgFile');
     $file = $file[0];
     if ($file) {
         if (!$this->file->checkSavePath()) {
             $this->send(array('error' => 1, 'message' => $this->lang->file->errorUnwritable));
         }
         move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);
         $url = $this->file->webPath . $file['pathname'];
         $file['createdBy'] = $this->app->user->account;
         $file['createdDate'] = helper::now();
         $file['editor'] = 1;
         unset($file['tmpname']);
         $this->dao->insert(TABLE_FILE)->data($file, false)->exec();
         $_SESSION['album'][$uid][] = $this->dao->lastInsertID();
         die(json_encode(array('error' => 0, 'url' => $url)));
     }
 }
예제 #10
0
파일: model.php 프로젝트: jnan77/chanzhieps
 /**
  * Update status of boards.
  * 
  * @param  int    $boardID 
  * @access public
  * @return void
  */
 public function updateBoardStats($boardID)
 {
     /* Get threads and replies. */
     $stats = $this->dao->select('COUNT(id) as threads, SUM(replies) as replies')->from(TABLE_THREAD)->where('board')->eq($boardID)->andWhere('addedDate')->le(helper::now())->andWhere('hidden')->eq('0')->fetch();
     /* Get postID and replyID. */
     $post = $this->dao->select('id as postID, replyID, repliedDate as postedDate, repliedBy, author')->from(TABLE_THREAD)->where('board')->eq($boardID)->andWhere('addedDate')->le(helper::now())->andWhere('hidden')->eq('0')->orderBy('repliedDate desc')->limit(1)->fetch();
     $data = new stdclass();
     $data->threads = $stats->threads;
     $data->posts = $stats->threads + $stats->replies;
     if ($post) {
         $data->postID = $post->postID;
         $data->replyID = $post->replyID;
         $data->postedDate = $post->postedDate;
         $data->postedBy = $post->repliedBy ? $post->repliedBy : $post->author;
     } else {
         $data->postID = 0;
         $data->replyID = 0;
         $data->postedBy = '';
     }
     $this->dao->update(TABLE_CATEGORY)->data($data)->where('id')->eq($boardID)->exec();
 }
예제 #11
0
파일: model.php 프로젝트: jnan77/chanzhieps
 /**
  * get search results of keywords.
  * 
  * @param  string    $keywords 
  * @param  object    $pager 
  * @access public
  * @return array
  */
 public function getList($keywords, $pager)
 {
     $spliter = $this->app->loadClass('spliter');
     $words = explode(' ', seo::unify($keywords, ' '));
     $against = '';
     foreach ($words as $word) {
         $splitedWords = $spliter->utf8Split($word);
         $against .= '"' . $splitedWords['words'] . '"';
     }
     $words = str_replace('"', '', $against);
     $words = str_pad($words, 5, '_');
     $scoreColumn = "((1 * (MATCH(title) AGAINST('{$against}' IN BOOLEAN MODE))) + (0.6 * (MATCH(title) AGAINST('{$against}' IN BOOLEAN MODE))) )";
     $results = $this->dao->select("*, {$scoreColumn} as score")->from(TABLE_SEARCH_INDEX)->where("MATCH(title,content) AGAINST('+{$against}' IN BOOLEAN MODE) >= 1")->andWhere('status')->eq('normal')->andWhere('addedDate')->le(helper::now())->orderBy('score_desc, editedDate_desc')->page($pager)->fetchAll('id');
     foreach ($results as $record) {
         $record->title = str_replace('</span> ', '</span>', $this->decode($this->markKeywords($record->title, $words)));
         $record->title = str_replace('_', '', $this->decode($this->markKeywords($record->title, $words)));
         $record->summary = $this->getSummary($record->content, $words);
         $record->summary = str_replace('_', '', $record->summary);
     }
     return $this->processLinks($results);
 }
예제 #12
0
파일: model.php 프로젝트: XMGmen/zentao
 public function uploadImg($filename = '')
 {
     if ($_FILES['myFile']['size'] == 0) {
         return;
     }
     $file['title'] = $_FILES['myFile']['name'];
     $file['extension'] = $this->getExtension($file['title']);
     $file['size'] = $_FILES['myFile']['size'];
     $file['pathname'] = $this->setPathName(0, $file['extension']);
     $file['objectType'] = 'user';
     $file['objectID'] = $this->app->user->id;
     $file['addedBy'] = $this->app->user->account;
     $file['addedDate'] = helper::now();
     $file['extra'] = '';
     $oldFile = $this->getFile($this->app->user->id);
     if (move_uploaded_file($_FILES['myFile']["tmp_name"], $this->getSavePath() . $file['pathname'])) {
         if (!empty($oldFile->id)) {
             unlink("../../www/data/upload/{$this->app->company->id}/{$oldFile->pathname}");
         }
         $this->dao->delete()->from(TABLE_FILE)->where('objectID')->eq((int) $this->app->user->id)->exec();
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
     }
 }
예제 #13
0
파일: model.php 프로젝트: huokedu/zentao
 public function update($assetID)
 {
     $skipFields = '';
     $skipFields .= $this->loadModel('custom')->dealWithCustomArrayField();
     $oldAsset = $this->getAssetById($assetID);
     $now = helper::now();
     $address = fixer::input('post')->get('address');
     $extendaddress = fixer::input('post')->get('extendaddress');
     $devicenumber = fixer::input('post')->get('devicenumber');
     $code = fixer::input('post')->get('code');
     $module = $this->loadModel('info')->getAllChildId(fixer::input('post')->cleanInt('module')->setDefault('module', 0)->get('module'), 'asset');
     $result1 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('address')->eq($extendaddress)->andWhere('address')->ne('IP Format Error')->andWhere('address')->ne('Conflict!')->andWhere('address')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
     $result2 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('extendaddress')->eq($address)->andWhere('extendaddress')->ne('IP Format Error')->andWhere('extendaddress')->ne('Conflict!')->andWhere('extendaddress')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
     $asset = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->setDefault('lenddate', '0000-00-00')->setDefault('returndate', '0000-00-00')->setDefault('product', '0')->setDefault('project', '0')->setIF(!(strlen(trim($extendaddress)) == 0) && !validater::checkIP($extendaddress), 'extendaddress', 'IP Format Error')->setIF(!(strlen(trim($address)) == 0) && !validater::checkIP($address), 'address', 'IP Format Error')->removeIF(trim($address) == trim($extendaddress), 'extendaddress')->setIF($result1, 'extendaddress', 'Conflict!')->setIF($result2, 'address', 'Conflict!')->get();
     $condition = "`lib` = '{$asset->lib}' AND module = '{$asset->module}' and id != '{$assetID}'";
     $conditionaddress = $condition . " and address != 'IP Format Error' and address != 'Conflict!'";
     $conditionextaddress = $condition . " and extendaddress != 'IP Format Error' and extendaddress != 'Conflict!'";
     $this->dao->update(TABLE_INFOASSET)->data($asset)->autoCheck($skipFields)->batchCheck($this->config->asset->edit->requiredFields, 'notempty')->check('hostname', 'unique', $condition)->checkIF(!(strlen(trim($address)) == 0), 'address', 'unique', $conditionaddress)->checkIF(!(strlen(trim($extendaddress)) == 0), 'extendaddress', 'unique', $conditionextaddress)->checkIF(!(strlen(trim($devicenumber)) == 0), 'devicenumber', 'unique', $condition)->checkIF(!(strlen(trim($code)) == 0), 'code', 'unique', $condition)->where('id')->eq((int) $assetID)->exec();
     $asset->editedCount = $asset->editedCount - 1;
     if (!dao::isError()) {
         return common::createChanges($oldAsset, $asset);
     }
 }
예제 #14
0
 /**
  * Save visitor info.
  * 
  * @access public
  * @return object
  */
 public function saveVisitor()
 {
     $browserName = helper::getBrowser();
     $browserVersion = helper::getBrowserVersion();
     if (!empty($_COOKIE['vid'])) {
         $visitor = $this->getVisitorByID($this->cookie->vid);
         if (!empty($visitor)) {
             $visitor->new = false;
             if ($visitor->browserName == $browserName and $visitor->browserVersion = $browserVersion and $visitor->osName == helper::getOS()) {
                 return $visitor;
             }
         }
     }
     $visitor = fixer::input('get')->add('device', $this->app->device)->add('osName', helper::getOS())->add('browserName', helper::getBrowser())->add('browserVersion', helper::getBrowserVersion())->add('createdTime', helper::now())->get();
     if ($visitor->browserName == 'ie') {
         $visitor->browserName .= $visitor->browserVersion;
     }
     $this->dao->insert(TABLE_STATVISITOR)->data($visitor, 'referer')->autocheck()->exec();
     $visitor->new = true;
     $vid = $this->dao->lastInsertId();
     setcookie('vid', $vid, strtotime('+5 year'));
     $visitor->id = $vid;
     return $visitor;
 }
예제 #15
0
파일: model.php 프로젝트: leowh/colla
 /**
  * Create a trip.
  * 
  * @access public
  * @return bool
  */
 public function create()
 {
     $trip = fixer::input('post')->add('createdBy', $this->app->user->account)->add('createdDate', helper::now())->get();
     if (isset($trip->begin) and $trip->begin != '') {
         $trip->year = substr($trip->begin, 0, 4);
     }
     $dates = range(strtotime($trip->begin), strtotime($trip->end), 60 * 60 * 24);
     foreach ($dates as $date) {
         $date = date('Y-m-d', $date);
         $existTrip = $this->getByDate($date, $this->app->user->account);
         if ($existTrip) {
             return array('result' => 'fail', 'message' => sprintf($this->lang->trip->unique, $date));
         }
         $existLeave = $this->loadModel('leave')->getByDate($date, $this->app->user->account);
         if ($existLeave) {
             return array('result' => 'fail', 'message' => sprintf($this->lang->leave->unique, $date));
         }
     }
     $this->dao->insert(TABLE_TRIP)->data($trip)->autoCheck()->batchCheck($this->config->trip->require->create, 'notempty')->check('end', 'ge', $trip->begin)->exec();
     if (!dao::isError()) {
         $this->loadModel('attend')->batchUpdate($dates, $this->app->user->account, 'trip', '', $trip);
     }
     return !dao::isError();
 }
예제 #16
0
 /**
  * Import task from Bug. 
  * 
  * @param  int    $projectID 
  * @access public
  * @return void
  */
 public function importBug($projectID)
 {
     $this->loadModel('bug');
     $this->loadModel('task');
     $this->loadModel('story');
     $now = helper::now();
     $modules = $this->loadModel('tree')->getTaskOptionMenu($projectID);
     $bugToTasks = fixer::input('post')->get();
     $bugs = $this->bug->getByList(array_keys($bugToTasks->import));
     foreach ($bugToTasks->import as $key => $value) {
         $bug = $bugs[$key];
         $task = new stdClass();
         $task->project = $projectID;
         $task->story = $bug->story;
         $task->storyVersion = $bug->storyVersion;
         $task->module = isset($modules[$bug->module]) ? $bug->module : 0;
         $task->fromBug = $key;
         $task->name = $bug->title;
         $task->type = 'devel';
         $task->pri = $bugToTasks->pri[$key];
         $task->consumed = 0;
         $task->status = 'wait';
         $task->desc = $this->lang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID={$key}"), sprintf('%03d', $key));
         $task->openedDate = $now;
         $task->openedBy = $this->app->user->account;
         if (!empty($bugToTasks->estimate[$key])) {
             $task->estimate = $bugToTasks->estimate[$key];
             $task->left = $task->estimate;
         }
         if (!empty($bugToTasks->assignedTo[$key])) {
             $task->assignedTo = $bugToTasks->assignedTo[$key];
             $task->assignedDate = $now;
         }
         if (!$bug->confirmed) {
             $this->dao->update(TABLE_BUG)->set('confirmed')->eq(1)->where('id')->eq($bug->id)->exec();
         }
         $this->dao->insert(TABLE_TASK)->data($task)->checkIF($bugToTasks->estimate[$key] != '', 'estimate', 'float')->exec();
         if (dao::isError()) {
             echo js::error(dao::getError());
             die(js::reload('parent'));
         }
         $taskID = $this->dao->lastInsertID();
         if ($task->story != false) {
             $this->story->setStage($task->story);
         }
         $actionID = $this->loadModel('action')->create('task', $taskID, 'Opened', '');
         $mails[$key] = new stdClass();
         $mails[$key]->taskID = $taskID;
         $mails[$key]->actionID = $actionID;
         $this->action->create('bug', $key, 'Totask', '', $taskID);
         $this->dao->update(TABLE_BUG)->set('toTask')->eq($taskID)->where('id')->eq($key)->exec();
         /* activate bug if bug postponed. */
         if ($bug->status == 'resolved' && $bug->resolution == 'postponed') {
             $newBug = new stdclass();
             $newBug->lastEditedBy = $this->app->user->account;
             $newBug->lastEditedDate = $now;
             $newBug->assignedDate = $now;
             $newBug->status = 'active';
             $newBug->resolvedDate = '0000-00-00';
             $newBug->resolution = '';
             $newBug->resolvedBy = '';
             $newBug->resolvedBuild = '';
             $newBug->closedBy = '';
             $newBug->closedDate = '0000-00-00';
             $newBug->duplicateBug = '0';
             $this->dao->update(TABLE_BUG)->data($newBug)->autoCheck()->where('id')->eq($key)->exec();
             $this->dao->update(TABLE_BUG)->set('activatedCount = activatedCount + 1')->where('id')->eq($key)->exec();
             $actionID = $this->action->create('bug', $key, 'Activated');
             $changes = common::createChanges($bug, $newBug);
             $this->action->logHistory($actionID, $changes);
         }
         if (isset($task->assignedTo) and $task->assignedTo and $task->assignedTo != $bug->assignedTo) {
             $newBug = new stdClass();
             $newBug->lastEditedBy = $this->app->user->account;
             $newBug->lastEditedDate = $now;
             $newBug->assignedTo = $task->assignedTo;
             $newBug->assignedDate = $now;
             $this->dao->update(TABLE_BUG)->data($newBug)->where('id')->eq($key)->exec();
             if (dao::isError()) {
                 die(js::error(dao::getError()));
             }
             $changes = common::createChanges($bug, $newBug);
             $actionID = $this->action->create('bug', $key, 'Assigned', '', $newBug->assignedTo);
             $this->action->logHistory($actionID, $changes);
         }
     }
     return $mails;
 }
예제 #17
0
파일: model.php 프로젝트: huokedu/zentao
 /**
  * Create test result 
  * 
  * @param  int   $runID 
  * @access public
  * @return void
  */
 public function createResult($runID = 0)
 {
     /* Compute the test result. 
      *
      * 1. if there result in the post, use it.
      * 2. if no result, set default is pass.
      * 3. then check the steps to compute result.
      * 
      * */
     $caseResult = $this->post->result ? $this->post->result : 'pass';
     if (isset($_POST['passall']) and $this->post->passall == false) {
         if ($this->post->steps) {
             foreach ($this->post->steps as $stepID => $stepResult) {
                 if ($stepResult != 'pass' and $stepResult != 'n/a') {
                     $caseResult = $stepResult;
                     break;
                 }
             }
         }
     }
     /* Create result of every step. */
     if ($this->post->steps) {
         foreach ($this->post->steps as $stepID => $stepResult) {
             $step['result'] = $stepResult;
             $step['real'] = $this->post->reals[$stepID];
             $stepResults[$stepID] = $step;
         }
     } else {
         $stepResults = array();
     }
     /* Insert into testResult table. */
     $now = helper::now();
     $result = fixer::input('post')->add('run', $runID)->add('caseResult', $caseResult)->setForce('stepResults', serialize($stepResults))->add('lastRunner', $this->app->user->account)->add('date', $now)->remove('steps,reals,passall,result')->get();
     $this->dao->insert(TABLE_TESTRESULT)->data($result)->autoCheck()->exec();
     $this->dao->update(TABLE_CASE)->set('lastRunner')->eq($this->app->user->account)->set('lastRunDate')->eq($now)->set('lastRunResult')->eq($caseResult)->where('id')->eq($this->post->case)->exec();
     if ($runID) {
         /* Update testRun's status. */
         if (!dao::isError()) {
             $runStatus = $caseResult == 'blocked' ? 'blocked' : 'done';
             $this->dao->update(TABLE_TESTRUN)->set('lastRunResult')->eq($caseResult)->set('status')->eq($runStatus)->set('lastRunner')->eq($this->app->user->account)->set('lastRunDate')->eq($now)->where('id')->eq($runID)->exec();
         }
     }
 }
 public function betaResolved($bugID)
 {
     $oldBug = $this->getById($bugID);
     $now = helper::now();
     $bug = fixer::input('post')->add('assignedDate', $now)->add('status', 'betaResolved')->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->add('confirmed', 1)->remove('comment')->get();
     $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int) $bugID)->exec();
 }
예제 #19
0
파일: model.php 프로젝트: laiello/zentaoms
 /**
  * Activate a story.
  * 
  * @param  int    $storyID 
  * @access public
  * @return bool
  */
 public function activate($storyID)
 {
     $oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
     $now = helper::now();
     $story = fixer::input('post')->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->add('assignedDate', $now)->add('status', 'active')->add('closedBy', '')->add('closedReason', '')->add('closedDate', '0000-00-00')->add('reviewedBy', '')->add('reviewedDate', '0000-00-00')->remove('comment')->get();
     $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq($storyID)->exec();
     return true;
 }
예제 #20
0
 /**
  * Save admin login log. 
  * 
  * @param  string $account 
  * @access public
  * @return bool
  */
 public function saveLog($account, $result)
 {
     $this->app->loadClass('IP');
     $ip = helper::getRemoteIP();
     $location = IP::find($ip);
     $extData = new stdclass();
     $extData->userAgent = $this->server->http_user_agent;
     $data = new stdclass();
     $data->account = $account;
     $data->date = helper::now();
     $data->ip = $ip;
     $data->location = is_array($location) ? join(' ', $location) : $location;
     $data->browser = helper::getBrowser() . ' ' . helper::getBrowserVersion();
     $data->type = 'adminlogin';
     $data->desc = $result;
     $data->lang = 'all';
     $data->ext = json_encode($extData);
     $this->dao->insert(TABLE_LOG)->data($data)->exec();
     return !dao::isError();
 }
예제 #21
0
 /**
  * Update a reply.
  * 
  * @param  int      $replyID 
  * @access public
  * @return void
  */
 public function update($replyID)
 {
     $allowedTags = $this->app->user->admin == 'super' ? $this->config->allowedTags->admin : $this->config->allowedTags->front;
     $reply = fixer::input('post')->setForce('editor', $this->session->user->account)->setForce('editedDate', helper::now())->stripTags('content', $allowedTags)->remove('files,labels,hidden')->get();
     $this->dao->update(TABLE_REPLY)->data($reply, $skip = 'captcha, uid')->autoCheck()->batchCheck($this->config->reply->require->post, 'notempty')->check('captcha', 'captcha')->where('id')->eq($replyID)->exec();
     $this->loadModel('file')->updateObjectID($this->post->uid, $replyID, 'reply');
     if (!dao::isError()) {
         $this->loadModel('file')->saveUpload('reply', $replyID);
         return true;
     }
     return false;
 }
예제 #22
0
파일: model.php 프로젝트: XMGmen/zentao
 /**
  * Update a doc.
  * 
  * @param  int    $docID 
  * @access public
  * @return void
  */
 public function update($docID)
 {
     $oldDoc = $this->getById($docID);
     $now = helper::now();
     $doc = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->setIF($this->post->lib == 'product', 'project', 0)->setIF($this->post->lib != 'product' and $this->post->lib != 'project', 'project', 0)->setIF($this->post->lib != 'product' and $this->post->lib != 'project', 'product', 0)->stripTags($this->config->doc->editor->edit['id'], $this->config->allowedTags)->encodeURL('url')->add('editedBy', $this->app->user->account)->add('editedDate', $now)->remove('comment,files, labels')->get();
     $condition = "lib = '{$doc->lib}' AND module = {$doc->module} AND id != {$docID}";
     $this->dao->update(TABLE_DOC)->data($doc)->autoCheck()->batchCheck($this->config->doc->edit->requiredFields, 'notempty')->check('title', 'unique', $condition)->where('id')->eq((int) $docID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldDoc, $doc);
     }
 }
예제 #23
0
파일: model.php 프로젝트: ppmon/ppm
 /**
  * Get product stats.
  * 
  * @param  string $orderBy 
  * @param  int    $pager 
  * @access public
  * @return array 
  */
 public function getStats($orderBy = 'order_desc', $pager = null, $status = 'noclosed')
 {
     $this->loadModel('report');
     $this->loadModel('story');
     $this->loadModel('bug');
     $products = $this->getList($status);
     foreach ($products as $productID => $product) {
         if (!$this->checkPriv($product)) {
             unset($products[$productID]);
         }
     }
     $products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in(array_keys($products))->orderBy($orderBy)->page($pager)->fetchAll('id');
     $stats = array();
     $stories = $this->dao->select('product, status, count(status) AS count')->from(TABLE_STORY)->where('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->groupBy('product, status')->fetchGroup('product', 'status');
     /* Padding the stories to sure all products have records. */
     $emptyStory = array_keys($this->lang->story->statusList);
     foreach (array_keys($products) as $productID) {
         if (!isset($stories[$productID])) {
             $stories[$productID] = $emptyStory;
         }
     }
     /* Padding the stories to sure all status have records. */
     foreach ($stories as $key => $story) {
         foreach (array_keys($this->lang->story->statusList) as $status) {
             $story[$status] = isset($story[$status]) ? $story[$status]->count : 0;
         }
         $stories[$key] = $story;
     }
     $plans = $this->dao->select('product, count(*) AS count')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->andWhere('end')->gt(helper::now())->groupBy('product')->fetchPairs();
     $releases = $this->dao->select('product, count(*) AS count')->from(TABLE_RELEASE)->where('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->groupBy('product')->fetchPairs();
     $bugs = $this->dao->select('product,count(*) AS conut')->from(TABLE_BUG)->where('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->groupBy('product')->fetchPairs();
     $unResolved = $this->dao->select('product,count(*) AS count')->from(TABLE_BUG)->where('status')->eq('active')->andwhere('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->groupBy('product')->fetchPairs();
     $assignToNull = $this->dao->select('product,count(*) AS count')->from(TABLE_BUG)->where('AssignedTo')->eq('')->andwhere('deleted')->eq(0)->andWhere('product')->in(array_keys($products))->groupBy('product')->fetchPairs();
     foreach ($products as $key => $product) {
         $product->stories = $stories[$product->id];
         $product->plans = isset($plans[$product->id]) ? $plans[$product->id] : 0;
         $product->releases = isset($releases[$product->id]) ? $releases[$product->id] : 0;
         $product->bugs = isset($bugs[$product->id]) ? $bugs[$product->id] : 0;
         $product->unResolved = isset($unResolved[$product->id]) ? $unResolved[$product->id] : 0;
         $product->assignToNull = isset($assignToNull[$product->id]) ? $assignToNull[$product->id] : 0;
         $stats[] = $product;
     }
     return $stats;
 }
예제 #24
0
 /**
  * upload image for slide. 
  *
  * @access public
  * @return string webPath
  */
 public function uploadImage($groupID)
 {
     $fileTitles = array();
     $imageSize = array('width' => 0, 'height' => 0);
     $files = $this->getUpload();
     foreach ($files as $id => $file) {
         if (!in_array(strtolower($file['extension']), $this->config->file->imageExtensions, true)) {
             return false;
         }
         $file['objectType'] = 'slide';
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = helper::now();
         $file['lang'] = 'all';
         $this->dao->insert(TABLE_FILE)->data($file, $skip = 'tmpname')->exec();
         $fileID = $this->dao->lastInsertId();
         $file['title'] = $groupID . '_' . $fileID;
         $file['pathname'] = 'slides/' . $file['title'] . '.' . $file['extension'];
         $imagePath = $this->app->getDataRoot() . $file['pathname'];
         if (!move_uploaded_file($file['tmpname'], $imagePath)) {
             $this->dao->delete()->from(TABLE_FILE)->where('id')->eq($fileID)->exec();
             return false;
         }
         $imageSize = $this->file->getImageSize($imagePath);
         $file['width'] = $imageSize['width'];
         $file['height'] = $imageSize['height'];
         $this->dao->update(TABLE_FILE)->data($file, $skip = 'tmpname')->where('id')->eq($fileID)->exec();
         $fileTitles[$fileID] = $file['title'];
     }
     $this->loadModel('setting')->setItems('system.common.site', array('lastUpload' => time()));
     if (!$fileTitles) {
         return false;
     }
     $imageIdList = array_keys($fileTitles);
     $image = $this->dao->select('*')->from(TABLE_FILE)->where('id')->eq($imageIdList[0])->fetch();
     $image->webPath = '/data/' . $image->pathname;
     return $image->webPath;
 }
예제 #25
0
파일: model.php 프로젝트: jnan77/chanzhieps
 /**
  * Reply a message.
  *
  * @param  int    $messageID
  * @access public
  * @return void
  */
 public function reply($messageID)
 {
     $account = $this->app->user->account;
     $admin = $this->app->user->admin;
     $message = $this->getByID($messageID);
     $reply = fixer::input('post')->add('objectType', $message->type == 'reply' ? $message->objectType : $message->type)->add('objectID', $message->id)->add('to', $message->account)->add('type', 'reply')->add('date', helper::now())->add('status', '0')->add('public', 1)->setIF($account != 'guest', 'account', $account)->setIF($admin == 'super', 'status', '1')->add('ip', $this->server->REMOTE_ADDR)->get();
     $this->dao->insert(TABLE_MESSAGE)->data($reply, $skip = 'captcha')->autoCheck()->check('captcha', 'captcha')->check('type', 'in', $this->config->message->types)->batchCheck($this->config->message->require->reply, 'notempty')->exec();
     $replyID = $this->dao->lastInsertId();
     if (!dao::isError()) {
         if ($admin == 'super') {
             $this->dao->update(TABLE_MESSAGE)->set('status')->eq(1)->where('status')->eq(0)->andWhere('id')->eq($messageID)->exec();
             if (dao::isError()) {
                 return false;
             }
         }
         /* if message type is comment , check is user want to receive email reminder  */
         if (validater::checkEmail($message->email) && ($message->type != 'comment' || $message->receiveEmail)) {
             $mail = new stdclass();
             $mail->to = $message->email;
             $mail->subject = sprintf($this->lang->message->replySubject, $this->config->site->name);
             $mail->body = $reply->content;
             $this->loadModel('mail')->send($mail->to, $mail->subject, $mail->body);
         }
         return $replyID;
     }
     return false;
 }
예제 #26
0
 /**
  * Confirm delivery.
  * 
  * @param  int    $orderID 
  * @access public
  * @return void
  */
 public function confirmDelivery($orderID)
 {
     $this->dao->update(TABLE_ORDER)->set('deliveryStatus')->eq('confirmed')->set('confirmedDate')->eq(helper::now())->where('id')->eq($orderID)->andWhere('account')->eq($this->app->user->account)->exec();
     return !dao::isError();
 }
예제 #27
0
파일: model.php 프로젝트: leowh/colla
 /**
  * Update a balance.
  * 
  * @param  int    $balanceID 
  * @access public
  * @return string|bool
  */
 public function update($balanceID)
 {
     $oldBalance = $this->getByID($balanceID);
     $depositor = $this->loadModel('depositor')->getByID($this->post->depositor);
     $balance = fixer::input('post')->add('currency', $depositor->currency)->add('editedBy', $this->app->user->account)->add('editedDate', helper::now())->removeIF($this->post->type == 'cash', 'public')->get();
     $this->dao->delete()->from(TABLE_BALANCE)->where('depositor')->eq($balance->depositor)->andWhere('date')->eq($balance->date)->andWhere('id')->ne($balanceID)->exec();
     $this->dao->update(TABLE_BALANCE)->data($balance)->autoCheck()->where('id')->eq($balanceID)->exec();
     if (!dao::isError()) {
         return commonModel::createChanges($oldBalance, $balance);
     }
     return false;
 }
예제 #28
0
 /**
  * Update comment of a action.
  * 
  * @param  int    $actionID 
  * @access public
  * @return void
  */
 public function updateComment($actionID)
 {
     $this->dao->update(TABLE_ACTION)->set('date')->eq(helper::now())->set('comment')->eq(trim(strip_tags($this->post->lastComment, $this->config->allowedTags)))->where('id')->eq($actionID)->exec();
 }
예제 #29
0
 /**
  * Replace a file.
  *
  * @access public
  * @return bool
  */
 public function replaceFile($fileID, $postName = 'upFile')
 {
     if ($files = $this->getUpload($postName)) {
         $file = $files[0];
         $filePath = $this->dao->select('pathname')->from(TABLE_FILE)->where('id')->eq($fileID)->fetch();
         $pathName = $filePath->pathname;
         $realPathName = $this->savePath . $pathName;
         if (!is_dir(dirname($realPathName))) {
             mkdir(dirname($realPathName));
         }
         move_uploaded_file($file['tmpname'], $realPathName);
         $fileInfo->addedBy = $this->app->user->account;
         $fileInfo->addedDate = helper::now();
         $fileInfo->size = $file['size'];
         $this->dao->update(TABLE_FILE)->data($fileInfo)->where('id')->eq($fileID)->exec();
         return true;
     } else {
         return false;
     }
 }
예제 #30
-1
파일: model.php 프로젝트: XMGmen/zentao
 public function uploadExcel($filename = '', $productID, $planID, $sprintID)
 {
     if ($_FILES['excelFile']['size'] == 0) {
         return;
     }
     // uploadFile
     $filePath = $this->getSavePath();
     $fname = $this->setPathName(0, $file['extension']);
     $uploadfile = $filePath . $fname;
     $tmp_name = $_FILES['excelFile']["tmp_name"];
     require_once 'PHPExcel.php';
     require_once 'PHPExcel/IOFactory.php';
     require_once 'PHPExcel/Reader/Excel2007.php';
     $result = move_uploaded_file($_FILES['excelFile']["tmp_name"], $this->getSavePath() . $fname);
     if ($result) {
         $objReader = PHPExcel_IOFactory::createReader('Excel2007');
         $objPHPExcel = PHPExcel_IOFactory::load($uploadfile);
         $sheet = $objPHPExcel->getSheet(0);
         $highestRow = $sheet->getHighestRow();
         $highestColumn = $sheet->getHighestColumn();
         for ($j = 2; $j <= $highestRow; $j++) {
             $str = "";
             for ($k = 'A'; $k <= $highestColumn; $k++) {
                 // $str .= iconv('utf-8', 'gbk', $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue())."|";//读取单元格
                 $str .= $objPHPExcel->getActiveSheet()->getCell("{$k}{$j}")->getValue() . "|";
                 //读取单元格
             }
             $strs = explode("|", $str);
             $bug = new stdclass();
             $bug->product = $productID;
             $bug->plan = $planID;
             if ($sprintID) {
                 $bug->project = $sprintID;
             }
             $bug->title = $strs[0];
             $bug->stage = $this->lang->importbugs->stageMap[$strs[1]];
             $bug->type = $this->lang->importbugs->typeMap[$strs[2]];
             $bug->severity = $strs[3];
             $bug->steps = $strs[4];
             $bug->openedBy = $this->app->user->account;
             $this->dao->insert(TABLE_BUG)->data($bug)->exec();
             $bugID = $this->dao->lastInsertID();
             $action = new stdclass();
             $action->objectType = 'bug';
             $action->objectID = $bugID;
             $action->product = $productID;
             $action->project = $sprintID;
             $action->actor = $this->app->user->account;
             $action->action = 'opened';
             $action->date = helper::now();
             $action->read = 0;
             $this->dao->insert(TABLE_ACTION)->data($action)->exec();
         }
         unlink($uploadfile);
         $msg = $this->lang->importbugs->success;
     } else {
         $msg = $this->lang->importbugs->fail;
     }
     return $msg;
 }