Example #1
0
 /**
  * update an address. 
  * 
  * @param  int    $id 
  * @access public
  * @return void
  */
 public function update($id)
 {
     $product = new stdclass();
     $address = fixer::input('post')->add('account', $this->app->user->account)->get();
     $this->dao->update(TABLE_ADDRESS)->data($address)->where('id')->eq($id)->beginIf(RUN_MODE == 'front')->andWhere('account')->eq($this->app->user->account)->fi()->batchCheck($this->config->address->require->edit, 'notempty')->exec();
     return !dao::isError();
 }
Example #2
0
 public function gererateCustomField($type = 'info', $method = 'add')
 {
     $this->app->loadClass('infoextdao', $static = true);
     //echo $_REQUEST['Null'][0]."\n";
     $oldField = '';
     if (empty($_REQUEST['Field']) && $_REQUEST['Field'] != '0') {
         echo js::alert($this->lang->custom->fieldEmpty);
         return false;
     }
     if (!(empty($_REQUEST['oldField']) && $_REQUEST['oldField'] != '0')) {
         $oldField = $_REQUEST['oldField'];
         $oldField = infoextdao::backquote($this->config->customFieldPrefix . $oldField);
         //echo js::alert($oldField);
     }
     $custom = fixer::input('post')->setDefault('Collation', 'utf8_general_ci')->setDefault('Attribute', '')->setDefault('Extra', false)->get();
     $field_primary = array();
     //var_dump($custom);
     $definition = ' ' . strtoupper($method) . ' ' . $oldField . ' ' . infoextdao::generateFieldSpec($this->config->customFieldPrefix . $custom->Field, $custom->Type, $custom->Length, $custom->Attribute, $custom->Collation, isset($_REQUEST['NULL'][0]) ? $_REQUEST['NULL'][0] : 'NOT NULL', $custom->DefaultType, $custom->DefaultValue, $custom->Extra, $custom->Comment, $field_primary, 0);
     $table = $this->config->custom->typeToTable[$type];
     $sql_query = 'ALTER TABLE ' . infoextdao::backquote($table) . ' ' . $definition;
     //echo js::alert($sql_query);
     try {
         $result = $this->app->dbh->query($sql_query);
     } catch (Exception $e) {
         //echo 'Message: ' .$e->getMessage();
         echo js::alert(addslashes($sql_query));
         echo js::alert($this->lang->custom->alterTableFailed);
         return false;
     }
     return true;
 }
 /**
  * Delete all data for Sunyard 
  * 
  * @access public
  * @return void
  */
 public function deleteSunyard()
 {
     $deleteProjects = fixer::input('post')->get();
     foreach ($deleteProjects->projects as $projectID) {
         $this->dao->delete()->from(TABLE_SUNEFFORTEVERYDAY)->where('project')->eq($projectID)->exec();
         $this->dao->delete()->from(TABLE_SUNPROJECTESTIMATE)->where('project')->eq($projectID)->exec();
     }
 }
Example #4
0
 /**
  * Update a release.
  * 
  * @param  int    $releaseID 
  * @access public
  * @return void
  */
 public function update($releaseID)
 {
     $oldRelease = $this->getByID($releaseID);
     $release = fixer::input('post')->stripTags('name')->setDefault('stories', '')->setDefault('bugs', '')->join('stories', ',')->join('bugs', ',')->get();
     $this->dao->update(TABLE_RELEASE)->data($release)->autoCheck()->batchCheck($this->config->release->edit->requiredFields, 'notempty')->check('name', 'unique', "id != {$releaseID}")->where('id')->eq((int) $releaseID)->exec();
     $this->dao->update(TABLE_STORY)->set('stage')->eq('released')->where('id')->in($release->stories)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldRelease, $release);
     }
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * Set lang. 
  * 
  * @param  string    $module 
  * @param  string    $field 
  * @access public
  * @return void
  */
 public function lang($module, $field, $appName = '')
 {
     $clientLang = $this->app->getClientLang();
     if (empty($appName)) {
         $appName = $this->app->getAppName();
     }
     $this->app->loadLang($module, $appName);
     if ($module == 'user' and $field == 'roleList' and $appName == 'sys') {
         $this->lang->menuGroups->setting = 'user';
     }
     if (!empty($_POST)) {
         if ($module == 'common' and $field == 'currencyList') {
             $setting = fixer::input('post')->join('currency', ',')->setDefault('currency', '')->get();
             $this->setting->setItems('system.sys.setting', $setting);
             if (dao::isError()) {
                 $this->send(array('result' => 'fail', 'message' => dao::getError()));
             }
             $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('lang', "module={$module}&field={$field}&appName={$appName}")));
         }
         $lang = $_POST['lang'];
         $appendField = isset($this->config->setting->appendLang[$module][$field]) ? $this->config->setting->appendLang[$module][$field] : '';
         $this->setting->deleteItems("lang={$lang}&app={$appName}&module={$module}&section={$field}", $type = 'lang');
         if ($appendField) {
             $this->setting->deleteItems("lang={$lang}&app={$appName}&module={$module}&section={$appendField}", $type = 'lang');
         }
         foreach ($_POST['keys'] as $index => $key) {
             $value = $_POST['values'][$index];
             if (!$value or !$key) {
                 continue;
             }
             $system = $_POST['systems'][$index];
             $this->setting->setItem("{$lang}.{$appName}.{$module}.{$field}.{$key}.{$system}", $value, $type = 'lang');
             /* Save additional item. */
             if ($appendField) {
                 $this->setting->setItem("{$lang}.{$appName}.{$module}.{$appendField}.{$key}.{$system}", $_POST[$appendField][$index], $type = 'lang');
             }
         }
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('lang', "module={$module}&field={$field}&appName={$appName}")));
     }
     $dbFields = $this->setting->getItems("lang={$clientLang},all&app={$appName}&module={$module}&section={$field}", 'lang');
     $systemField = array();
     foreach ($dbFields as $dbField) {
         $systemField[$dbField->key] = $dbField->system;
     }
     $this->view->fieldList = $module == 'common' ? $this->lang->{$field} : $this->lang->{$module}->{$field};
     $this->view->module = $module;
     $this->view->field = $field;
     $this->view->clientLang = $clientLang;
     $this->view->systemField = $systemField;
     $this->view->appName = $appName;
     $this->display();
 }
Example #7
0
 /**
  * Update a company.
  * 
  * @access public
  * @return void
  */
 public function update()
 {
     $company = fixer::input('post')->get();
     if ($company->website == 'http://') {
         $company->website = '';
     }
     if ($company->backyard == 'http://') {
         $company->backyard = '';
     }
     $companyID = $this->app->company->id;
     $this->dao->update(TABLE_COMPANY)->data($company)->autoCheck()->batchCheck($this->config->company->edit->requiredFields, 'notempty')->batchCheck('name', 'unique', "id != '{$companyID}'")->where('id')->eq($companyID)->exec();
 }
Example #8
0
 /**
  * Save params 
  * 
  * @param  int    $index 
  * @param  string $type 
  * @param  string $appName 
  * @param  int    $blockID 
  * @access public
  * @return void
  */
 public function save($index, $type = 'system', $appName = 'sys', $blockID = 0)
 {
     $data = fixer::input('post')->add('account', $this->app->user->account)->add('order', $index)->add('app', $appName)->add('hidden', 0)->setIF($type != 'system', 'block', $type)->setIF($blockID, 'id', $blockID)->setDefault('grid', '4')->setDefault('source', $appName)->setDefault('params', array())->get();
     if ($type != 'system') {
         $data->source = '';
     }
     if ($type == 'html') {
         $data->params['html'] = $data->html;
         unset($data->html);
     }
     $data->params = helper::jsonEncode($data->params);
     $this->dao->replace(TABLE_BLOCK)->data($data, 'uid')->exec();
 }
Example #9
0
 /**
  * Set link for a tag.
  * 
  * @param  int    $tagID 
  * @access public
  * @return void
  */
 public function link($tagID)
 {
     if ($_POST) {
         $link = fixer::input('post')->stripTags('link', $this->config->allowedTags->admin)->get();
         $this->dao->update(TABLE_TAG)->data($link)->autoCheck()->where('id')->eq($tagID)->exec();
         if (!dao::isError()) {
             $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
         }
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $this->view->title = "<i class='icon-edit'></i> " . $this->lang->tag->editLink;
     $this->view->tag = $this->dao->select('*')->from(TABLE_TAG)->where('id')->eq($tagID)->fetch();
     $this->display();
 }
Example #10
0
 /**
  * Custom 
  * 
  * @param  string $module 
  * @param  string $field 
  * @access public
  * @return void
  */
 public function set($module = 'story', $field = 'priList')
 {
     if ($module == 'user' and $field == 'priList') {
         $field = 'roleList';
     }
     $currentLang = $this->app->getClientLang();
     $this->app->loadLang($module);
     $this->app->loadConfig('story');
     $fieldList = $this->lang->{$module}->{$field};
     if ($module == 'bug' and $field == 'typeList') {
         unset($fieldList['designchange']);
         unset($fieldList['newfeature']);
         unset($fieldList['trackthings']);
     }
     if (!empty($_POST)) {
         if ($module == 'story' && $field == 'review') {
             $this->loadModel('setting')->setItem('system.story.needReview', fixer::input('post')->get()->needReview);
         } else {
             $lang = $_POST['lang'];
             $this->custom->deleteItems("lang={$lang}&module={$module}&section={$field}");
             foreach ($_POST['keys'] as $index => $key) {
                 $value = $_POST['values'][$index];
                 if (!$value or !$key) {
                     continue;
                 }
                 $system = $_POST['systems'][$index];
                 /* the length of role is 20, check it when save. */
                 if ($module == 'user' and $field == 'roleList' and strlen($key) > 20) {
                     die(js::alert($this->lang->custom->notice->userRole));
                 }
                 $this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $value);
             }
         }
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         die(js::reload('parent'));
     }
     $this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->{$module}->common;
     $this->view->position[] = $this->lang->custom->common;
     $this->view->position[] = $this->lang->{$module}->common;
     $this->view->needReview = $this->config->story->needReview;
     $this->view->fieldList = $fieldList;
     $this->view->dbFields = $this->custom->getItems("lang={$currentLang},all&module={$module}&section={$field}");
     $this->view->field = $field;
     $this->view->module = $module;
     $this->view->currentLang = $currentLang;
     $this->view->canAdd = strpos($this->config->custom->canAdd[$module], $field) !== false;
     $this->display();
 }
Example #11
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();
 }
Example #12
0
 /**
  * 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();
 }
Example #13
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' => '提交成功!');
     }
 }
Example #14
0
 /**
  * Update a slide.
  *
  * @param int $id
  * @access public
  * @return bool
  */
 public function update($id)
 {
     $image = $this->uploadImage();
     $slide = fixer::input('post')->stripTags('summary', $this->config->allowedTags->front)->setIf(!empty($image), 'image', $image)->remove('files')->get();
     if ($slide->backgroundType == 'color') {
         $this->dao->insert('slide')->data($slide, 'label,buttonClass,buttonUrl,buttonTarget')->batchCheck($this->config->slide->require->edit, 'notempty')->check('height', 'ge', 100);
         if (dao::isError()) {
             return false;
         }
     }
     $slide->label = array_values($slide->label);
     $slide->buttonClass = array_values($slide->buttonClass);
     $slide->buttonUrl = array_values($slide->buttonUrl);
     $slide->buttonTarget = array_values($slide->buttonTarget);
     $slide->createdDate = time();
     $this->dao->update(TABLE_CONFIG)->set('value')->eq(helper::jsonEncode($slide))->where('id')->eq($id)->exec();
     return !dao::isError();
 }
Example #15
0
 /**
  * Copy a group.
  * 
  * @param  int    $groupID 
  * @access public
  * @return void
  */
 public function copy($groupID)
 {
     $group = fixer::input('post')->remove('options')->get();
     $this->dao->insert(TABLE_GROUP)->data($group)->check('name', 'unique')->check('name', 'notempty')->exec();
     if ($this->post->options == false) {
         return;
     }
     if (!dao::isError()) {
         $newGroupID = $this->dao->lastInsertID();
         $options = join(',', $this->post->options);
         if (strpos($options, 'copyPriv') !== false) {
             $this->copyPriv($groupID, $newGroupID);
         }
         if (strpos($options, 'copyUser') !== false) {
             $this->copyUser($groupID, $newGroupID);
         }
     }
 }
Example #16
0
 public function manage($productID)
 {
     $oldBranches = $this->getPairs($productID, 'noempty');
     $data = fixer::input('post')->get();
     if (isset($data->branch)) {
         foreach ($data->branch as $branchID => $branch) {
             if ($oldBranches[$branchID] != $branch) {
                 $this->dao->update(TABLE_BRANCH)->set('name')->eq($branch)->where('id')->eq($branchID)->exec();
             }
         }
     }
     foreach ($data->newbranch as $branch) {
         if (empty($branch)) {
             continue;
         }
         $this->dao->insert(TABLE_BRANCH)->set('name')->eq($branch)->set('product')->eq($productID)->exec();
     }
     return dao::isError();
 }
Example #17
0
 /**
  * set site basic info.
  *
  * @access public
  * @return void
  */
 public function setBasic()
 {
     $allowedTags = $this->app->user->admin == 'super' ? $this->config->allowedTags->admin : $this->config->allowedTags->front;
     if (!empty($_POST)) {
         $setting = fixer::input('post')->stripTags('meta', $allowedTags)->stripTags('tongji', $allowedTags)->join('modules', ',')->remove('allowedFiles')->setDefault('modules', '')->stripTags('pauseTip', $allowedTags)->remove('uid,lang,cn2tw,defaultLang,requestType')->get();
         if (strpos($setting->modules, 'shop') !== false && strpos($setting->modules, 'user') === false) {
             $setting->modules = 'user,' . $setting->modules;
         }
         if ($setting->modules == 'initial') {
             unset($setting->modules);
         }
         $result = $this->loadModel('setting')->setItems('system.common.site', $setting);
         if (!$result) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
         }
         /* Set global settings. */
         $globalSetting = new stdclass();
         if ($this->post->lang) {
             $globalSetting->lang = join(',', $this->post->lang);
             $globalSetting->cn2tw = join('', $this->post->cn2tw);
             $globalSetting->defaultLang = $this->post->defaultLang;
         }
         if ($this->post->requestType) {
             $globalSetting->requestType = $this->post->requestType;
         }
         $result = $this->loadModel('setting')->setItems('system.common.site', $globalSetting, 'all');
         if (!$result) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
         }
         /* Switch to desktop device if mobile template closed. */
         if ($setting->mobileTemplate == 'close') {
             $this->session->set('device', 'desktop');
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setbasic')));
     }
     $this->view->title = $this->lang->site->common;
     $this->display();
 }
Example #18
0
 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);
     }
 }
Example #19
0
 public function updateDefaultPwd()
 {
     $data = fixer::input('post')->get();
     $pwdList = $this->post->pwdList ? $this->post->pwdList : array();
     if (!empty($pwdList)) {
         /* Initialize todos from the post data. */
         foreach ($pwdList as $pwdID) {
             $pwd = $data->password[$pwdID];
             if ('' === $pwd) {
                 continue;
             }
             if ($pwdID > 0) {
                 $this->updatePwd($pwdID, $pwd);
             } else {
                 $this->setdefaultpwd($pwd);
             }
         }
     }
     if (dao::isError()) {
         echo js::error(dao::getError());
         die(js::reload('parent'));
     }
 }
Example #20
0
 /**
  * Bind user. 
  * 
  * @access public
  * @return object
  */
 public function bind()
 {
     $data = fixer::input('post')->get();
     if ($data->bindType == 'bind') {
         if (empty($data->bindPassword)) {
             die(js::alert($this->lang->sso->bindNoPassword));
         }
         $password = md5($data->bindPassword);
         $user = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($data->bindUser)->andWhere('password')->eq($password)->andWhere('deleted')->eq('0')->fetch();
         if (empty($user)) {
             die(js::alert($this->lang->sso->bindNoUser));
         }
         $user->ranzhi = $this->session->ssoData->account;
         $this->dao->update(TABLE_USER)->set('ranzhi')->eq($user->ranzhi)->where('id')->eq($user->id)->exec();
     } elseif ($data->bindType == 'add') {
         if (!$this->loadModel('user')->checkPassword()) {
             return;
         }
         $user = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($data->account)->fetch();
         if ($user) {
             die(js::alert($this->lang->sso->bindHasAccount));
         }
         if (isset($this->config->safe->mode) and $this->user->computePasswordStrength($data->password1) < $this->config->safe->mode) {
             dao::$errors['password1'][] = $this->lang->user->weakPassword;
             return false;
         }
         $user = new stdclass();
         $user->account = $data->account;
         $user->password = md5($data->password1);
         $user->realname = $data->realname;
         $user->gender = isset($data->gender) ? $data->gender : '';
         $user->email = $data->email;
         $user->ranzhi = $this->session->ssoData->account;
         $this->dao->insert(TABLE_USER)->data($user)->autoCheck()->batchCheck($this->config->user->create->requiredFields, 'notempty')->check('account', 'unique')->check('account', 'account')->checkIF($user->email != false, 'email', 'email')->exec();
     }
     return $user;
 }
Example #21
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;
 }
Example #22
0
 /**
  * Set upload configures.
  * 
  * @access public
  * @return void
  */
 public function setUpload()
 {
     if (!empty($_POST)) {
         $setting = fixer::input('post')->remove('allowedFiles')->setDefault('allowUpload', '0')->get();
         $dangers = explode(',', $this->config->file->dangers);
         $allowedFiles = trim(strtolower($this->post->allowedFiles), ',');
         $allowedFiles = str_replace($dangers, '', $allowedFiles);
         $allowedFiles = seo::unify($allowedFiles, ',');
         $allowedFiles = ',' . $allowedFiles . ',';
         $fileConfig = array('allowed' => $allowedFiles);
         $this->loadModel('setting')->setItems('system.common.file', $fileConfig);
         $result = $this->loadModel('setting')->setItems('system.common.site', $setting);
         $cache = $this->loadModel('cache')->createConfigCache();
         if (!$cache) {
             $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->error->noWritable, $this->app->getTmpRoot() . 'cache')));
         }
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setupload')));
         }
         $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
     }
     $this->view->title = $this->lang->site->setBasic;
     $this->display();
 }
Example #23
0
 /**
  * Update a slide.
  *
  * @param int $id
  * @access public
  * @return bool
  */
 public function update($id)
 {
     $slide = $this->getByID($id);
     $image = $this->uploadImage($slide->group);
     $data = fixer::input('post')->stripTags('summary', $this->config->allowedTags->front)->setIf(!empty($image), 'image', $image)->remove('files')->get();
     $data->label = helper::jsonEncode(array_values($data->label));
     $data->buttonClass = helper::jsonEncode(array_values($data->buttonClass));
     $data->buttonUrl = helper::jsonEncode(array_values($data->buttonUrl));
     $data->buttonTarget = helper::jsonEncode(array_values($data->buttonTarget));
     $this->dao->update(TABLE_SLIDE)->data($data, $skip = 'uid')->batchCheckIF($this->post->backgroundType == 'color', $this->config->slide->require->create, 'notempty')->checkIF($this->post->backgroundType == 'color', 'height', 'ge', 100)->where('id')->eq($id)->exec();
     if ($image) {
         $pathname = str_replace('/data/', '', $image);
         $this->dao->update(TABLE_FILE)->set('objectID')->eq($id)->where('pathname')->eq($pathname)->exec();
     }
     return !dao::isError();
 }
Example #24
0
 /**
  * Delivery products of an order.
  * 
  * @param  int    $orderID 
  * @access public
  * @return void
  */
 public function delivery($orderID)
 {
     $order = $this->getByID($orderID);
     $delivery = fixer::input('post')->add('deliveriedBy', $this->app->user->account)->add('deliveryStatus', 'send')->get();
     $this->dao->update(TABLE_ORDER)->data($delivery)->where('id')->eq($orderID)->exec();
     if (dao::isError()) {
         return false;
     }
     if ($order->payment == 'COD' and isset($this->config->product->stock)) {
         return $this->fixStocks($orderID);
     }
     return true;
 }
Example #25
0
 /**
  * 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;
 }
Example #26
0
 /**
  * Fix burn for first day.
  * 
  * @param  int    $projectID 
  * @access public
  * @return void
  */
 public function fixFirst($projectID)
 {
     $project = $this->getById($projectID);
     $burn = $this->dao->select('*')->from(TABLE_BURN)->where('project')->eq($projectID)->andWhere('date')->eq($project->begin)->fetch();
     $data = fixer::input('post')->add('project', $projectID)->add('date', $project->begin)->add('consumed', empty($burn) ? 0 : $burn->consumed)->get();
     if (!is_numeric($data->left)) {
         return false;
     }
     $this->dao->replace(TABLE_BURN)->data($data)->exec();
 }
Example #27
0
 /**
  * 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();
         }
     }
 }
Example #28
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;
 }
Example #29
0
 /**
  * Edit holiday. 
  * 
  * @access public
  * @return bool
  */
 public function update($id)
 {
     $holiday = fixer::input('post')->get();
     $holiday->year = substr($holiday->begin, 0, 4);
     $this->dao->update(TABLE_HOLIDAY)->data($holiday)->autoCheck()->batchCheck($this->config->holiday->require->edit, 'notempty')->check('end', 'ge', $holiday->begin)->where('id')->eq($id)->exec();
     return !dao::isError();
 }
Example #30
0
 /**
  * Update a plan
  * 
  * @param  int    $planID 
  * @access public
  * @return array
  */
 public function update($planID)
 {
     $oldPlan = $this->getById($planID);
     $plan = fixer::input('post')->stripTags('title')->get();
     $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->batchCheck($this->config->productplan->edit->requiredFields, 'notempty')->check('end', 'gt', $plan->begin)->where('id')->eq((int) $planID)->exec();
     if (!dao::isError()) {
         return common::createChanges($oldPlan, $plan);
     }
 }