Esempio n. 1
0
 /**
  * Edit a reply.
  * 
  * @param string $replyID 
  * @access public
  * @return void
  */
 public function edit($replyID)
 {
     if ($this->app->user->account == 'guest') {
         die(js::locate($this->createLink('user', 'login')));
     }
     /* Judge current user has priviledge to edit the reply or not. */
     $reply = $this->reply->getByID($replyID);
     if (!$reply) {
         die(js::locate('back'));
     }
     $thread = $this->loadModel('thread')->getByID($reply->thread);
     if (!$this->thread->canManage($thread->board, $reply->author)) {
         die(js::locate('back'));
     }
     $this->thread->setEditor($thread->board, 'edit');
     if ($_POST) {
         $this->reply->update($replyID);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('thread', 'view', "threaID={$thread->id}")));
     }
     $this->view->title = $this->lang->reply->edit . $this->lang->colon . $thread->title;
     $this->view->reply = $reply;
     $this->view->thread = $thread;
     $this->view->board = $this->loadModel('tree')->getById($thread->board);
     $this->view->boards = $this->loadModel('forum')->getBoards();
     $this->display();
 }
Esempio n. 2
0
 /**
  * Block Admin Page.
  * 
  * @param  int    $index 
  * @param  string $blockID 
  * @access public
  * @return void
  */
 public function admin($index = 0, $blockID = '')
 {
     $this->app->loadLang('block', 'sys');
     $title = $index == 0 ? $this->lang->block->createBlock : $this->lang->block->editBlock;
     if (!$index) {
         $index = $this->block->getLastKey('team') + 1;
     }
     if ($_POST) {
         $this->block->save($index, 'system', 'team');
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::geterror()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->server->http_referer));
     }
     $block = $this->block->getBlock($index, 'team');
     $blockID = $blockID ? $blockID : ($block ? $block->block : '');
     $blocks = json_decode($this->block->getAvailableBlocks(), true);
     $this->view->blocks = array_merge(array(''), $blocks);
     $this->view->title = $title;
     $this->view->params = $blockID ? json_decode($this->block->{'get' . ucfirst($blockID) . 'Params'}(), true) : array();
     $this->view->blockID = $blockID;
     $this->view->block = $block;
     $this->view->index = $index;
     $this->display();
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * Edit a build.
  * 
  * @param  int    $buildID 
  * @access public
  * @return void
  */
 public function edit($buildID)
 {
     if (!empty($_POST)) {
         $changes = $this->build->update($buildID);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         if ($changes) {
             $actionID = $this->loadModel('action')->create('build', $buildID, 'edited');
             $this->action->logHistory($actionID, $changes);
         }
         die(js::locate(inlink('view', "buildID={$buildID}"), 'parent'));
     }
     $this->loadModel('story');
     $this->loadModel('bug');
     $this->loadModel('project');
     /* Set menu. */
     $build = $this->build->getById((int) $buildID);
     $this->project->setMenu($this->project->getPairs(), $build->project);
     /* Get stories and bugs. */
     $orderBy = 'status_asc, stage_asc, id_desc';
     $stories = $this->story->getProjectStories($build->project, $orderBy);
     $bugs = $this->bug->getProjectBugs($build->project);
     /* Assign. */
     $this->view->title = $this->lang->build->edit;
     $this->view->position[] = $this->lang->build->edit;
     $this->view->products = $this->project->getProducts($build->project);
     $this->view->build = $build;
     $this->view->users = $this->loadModel('user')->getPairs('nodeleted', $build->builder);
     $this->view->stories = $stories;
     $this->view->bugs = $bugs;
     $this->view->orderBy = $orderBy;
     $this->display();
 }
 /**
  * Create a batch case.
  * 
  * @access public
  * @return void
  */
 function batchCreate($productID)
 {
     $now = helper::now();
     $cases = fixer::input('post')->get();
     for ($i = 0; $i < $this->config->testcase->batchCreate; $i++) {
         if ($cases->type[$i] != '' and $cases->title[$i] != '') {
             $data[$i]->product = $productID;
             $data[$i]->module = $cases->module[$i] == 'same' ? $i == 0 ? 0 : $data[$i - 1]->module : $cases->module[$i];
             $data[$i]->type = $cases->type[$i] == 'same' ? $i == 0 ? '' : $data[$i - 1]->type : $cases->type[$i];
             $data[$i]->story = $cases->story[$i] == 'same' ? $i == 0 ? 0 : $data[$i - 1]->story : $cases->story[$i];
             $data[$i]->title = $cases->title[$i];
             $data[$i]->openedBy = $this->app->user->account;
             $data[$i]->openedDate = $now;
             $data[$i]->status = 'normal';
             $data[$i]->version = 1;
             if ($data[$i]->story != 0) {
                 $data[$i]->storyVersion = $this->loadModel('story')->getVersion($this->post->story);
             }
             $this->dao->insert(TABLE_CASE)->data($data[$i])->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->exec();
             if (dao::isError()) {
                 echo js::error(dao::getError());
                 die(js::reload('parent'));
             }
             $caseID = $this->dao->lastInsertID();
             $actionID = $this->loadModel('action')->create('case', $caseID, 'Opened');
         } else {
             unset($cases->module[$i]);
             unset($cases->type[$i]);
             unset($cases->story[$i]);
             unset($cases->title[$i]);
         }
     }
 }
 /**
  * Edit a release.
  * 
  * @param  int    $releaseID 
  * @access public
  * @return void
  */
 public function edit($releaseID)
 {
     if (!empty($_POST)) {
         $changes = $this->release->update($releaseID);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         if ($changes) {
             $actionID = $this->loadModel('action')->create('release', $releaseID, 'edited');
             $this->action->logHistory($actionID, $changes);
         }
         die(js::locate(inlink('view', "releaseID={$releaseID}"), 'parent'));
     }
     $this->loadModel('story');
     $this->loadModel('bug');
     $this->loadModel('build');
     /* Get release and build. */
     $release = $this->release->getById((int) $releaseID);
     $this->commonAction($release->product);
     $build = $this->build->getById($release->build);
     /* Get stories and bugs. */
     $orderBy = 'status_asc, stage_asc, id_desc';
     $stories = $this->story->getProjectStories($build->project, $orderBy);
     $bugs = $this->bug->getProjectBugs($build->project);
     $this->view->header->title = $this->lang->release->edit;
     $this->view->position[] = $this->lang->release->edit;
     $this->view->release = $release;
     $this->view->build = $build;
     $this->view->stories = $stories;
     $this->view->bugs = $bugs;
     $this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product);
     unset($this->view->builds['trunk']);
     $this->display();
 }
Esempio n. 7
0
 /**
  * Change password , if use default password ,go to change
  * 
  * @access public
  * @return void
  */
 public function changePassword()
 {
     if ($this->app->user->account == 'guest') {
         die(js::alert('guest') . js::locate('back'));
     }
     if (!empty($_POST)) {
         $password1 = $_POST['password1'];
         if (!$password1) {
             die(js::error('Please input password!'));
         }
         $isDefult = $this->dao->select('password')->from(TABLE_DEFAULTPASSWORD)->Where('password')->eq($this->post->password1)->fetchAll();
         //如果用户使用默认密码则跳到修改密码界面
         if ($isDefult) {
             die(js::error('Password can not in default list!') . js::locate($this->createLink('my', 'changePassword', 'type=forbidden'), 'parent'));
         }
         $this->user->updatePassword($this->app->user->id);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         die(js::locate($this->createLink('my', 'profile'), 'parent'));
     }
     $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->changePassword;
     $this->view->position[] = $this->lang->my->changePassword;
     $this->view->user = $this->user->getById($this->app->user->id);
     $this->display();
 }
Esempio n. 8
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();
 }
Esempio n. 9
0
 /**
  * Delete an address.
  * 
  * @param  int    $id 
  * @access public
  * @return void
  */
 public function delete($id)
 {
     $this->dao->delete()->from(TABLE_ADDRESS)->where('id')->eq($id)->andWhere('account')->eq($this->app->user->account)->exec();
     if (dao::isError()) {
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $this->send(array('result' => 'success', 'message' => $this->lang->deleteSuccess, 'locate' => inlink('browse')));
 }
Esempio n. 10
0
 /**
  * Install web app. 
  * 
  * @param  int    $webappID 
  * @access public
  * @return void
  */
 public function install($webappID)
 {
     $result = $this->webapp->install($webappID);
     if (dao::isError()) {
         $this->send(array('result' => 'fail', 'message' => dao::getError(), 'locate' => $this->createLink('webapp', 'obtain')));
     }
     $this->send(array('result' => 'success', 'message' => $this->lang->webapp->successInstall, 'locate' => $this->createLink('entry', 'admin'), 'entries' => $this->loadModel('entry')->getJSONEntries()));
 }
Esempio n. 11
0
 /**
  * Save search query.
  * 
  * @access public
  * @return void
  */
 public function saveQuery()
 {
     $this->search->saveQuery();
     if (dao::isError()) {
         die(js::error(dao::getError()));
     }
     die('success');
 }
Esempio n. 12
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);
 }
 /**
  * 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);
     }
 }
Esempio n. 14
0
 /**
  * Create an article.
  * 
  * @access public
  * @return void
  */
 public function create()
 {
     if (!empty($_POST)) {
         $blogID = $this->blog->create();
         if (dao::isError()) {
             die(js::error(dao::getError()) . js::locate('back'));
         }
         die(js::locate(inlink('index')));
     }
     $this->view->title = $this->lang->blog->add;
     $this->display();
 }
Esempio n. 15
0
 /**
  * Set link for a tag.
  * 
  * @param  int    $tagID 
  * @access public
  * @return void
  */
 public function link($tagID)
 {
     if ($_POST) {
         $this->dao->update(TABLE_TAG)->set('link')->eq($this->post->link)->where('id')->eq($tagID)->exec();
         if (!dao::isError()) {
             $this->send(array('result' => 'success'));
         }
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $this->view->tag = $this->dao->select('*')->from(TABLE_TAG)->where('id')->eq($tagID)->fetch();
     $this->display();
 }
Esempio n. 16
0
 public function setConfig($pubuConfig)
 {
     try {
         $this->loadModel('setting')->setItems('system.pubu', $pubuConfig);
         if (dao::isError()) {
             return dao::getError();
         } else {
         }
     } catch (Exception $err) {
         return $err;
     }
     return true;
 }
Esempio n. 17
0
 /**
  * Set link for a tag.
  * 
  * @param  int    $tagID 
  * @access public
  * @return void
  */
 public function link($tagID)
 {
     if ($_POST) {
         $this->dao->update(TABLE_TAG)->set('link')->eq($this->post->link)->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();
 }
Esempio n. 18
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();
 }
Esempio n. 19
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();
 }
Esempio n. 20
0
 /**
  * Edit holiday.
  * 
  * @param  int    $id 
  * @access public
  * @return void
  */
 public function edit($id)
 {
     $holiday = $this->holiday->getById($id);
     if ($_POST) {
         $this->holiday->update($id);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'reload'));
     }
     $this->view->title = $this->lang->holiday->edit;
     $this->view->holiday = $holiday;
     $this->display();
 }
Esempio n. 21
0
 /**
  * Add a prodcut to cart. 
  * 
  * @param  int    $productID 
  * @param  int    $count 
  * @access public
  * @return void
  */
 public function add($productID, $count)
 {
     $hasProduct = $this->dao->select('count(*) as count')->from(TABLE_CART)->where('account')->eq($this->app->user->account)->andWhere('product')->eq($productID)->fetch('count');
     if (!$hasProduct) {
         $product = new stdclass();
         $product->product = $productID;
         $product->account = $this->app->user->account;
         $product->count = $count;
         $this->dao->insert(TABLE_CART)->data($product)->exec();
     } else {
         $this->dao->update(TABLE_CART)->set("count= count + {$count}")->where('account')->eq($this->app->user->account)->andWhere('product')->eq($productID)->exec();
     }
     return !dao::isError();
 }
Esempio n. 22
0
 /**
  * Execute a module's model's method, return the result.
  * 
  * @param  string    $moduleName 
  * @param  string    $methodName 
  * @param  string    $params        param1=value1,param2=value2, don't use & to join them.
  * @access public
  * @return string
  */
 public function getModel($moduleName, $methodName, $params = '')
 {
     parse_str(str_replace(',', '&', $params), $params);
     $module = $this->loadModel($moduleName);
     $result = call_user_func_array(array(&$module, $methodName), $params);
     if (dao::isError()) {
         die(json_encode(dao::getError()));
     }
     $output['status'] = $result ? 'success' : 'fail';
     $output['data'] = json_encode($result);
     $output['md5'] = md5($output['data']);
     $this->output = json_encode($output);
     die($this->output);
 }
Esempio n. 23
0
 /**
  * Edit cron. 
  * 
  * @param  int    $cronID 
  * @access public
  * @return void
  */
 public function edit($cronID)
 {
     if ($_POST) {
         $this->cron->update($cronID);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         die(js::locate(inlink('index'), 'parent'));
     }
     $this->view->title = $this->lang->cron->edit . $this->lang->cron->common;
     $this->view->position[] = html::a(inlink('index'), $this->lang->cron->common);
     $this->view->position[] = $this->lang->cron->edit;
     $this->view->cron = $this->cron->getById($cronID);
     $this->display();
 }
Esempio n. 24
0
 /**
  * Build All index. 
  * 
  * @access public
  * @return void
  */
 public function buildIndex($type = 'article', $lastID = '')
 {
     if (helper::isAjaxRequest()) {
         $result = $this->search->buildAllIndex($type, $lastID);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         if (isset($result['finished']) and $result['finished']) {
             $this->send(array('result' => 'finished', 'message' => $this->lang->search->buildSuccessfully));
         } else {
             $this->send(array('result' => 'unfinished', 'message' => sprintf($this->lang->search->buildResult, $result['count']), 'next' => inlink('buildIndex', "type={$result['type']}&lastID={$result['lastID']}")));
         }
     }
     $this->view->title = $this->lang->search->buildIndex;
     $this->display();
 }
Esempio n. 25
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' => '提交成功!');
     }
 }
Esempio n. 26
0
 public function save()
 {
     if (!empty($_POST)) {
         $pubuConfig = new stdclass();
         $pubuConfig->webhook = trim($this->post->webhook);
         $this->loadModel('setting')->setItems('system.pubu', $pubuConfig);
         if (dao::isError()) {
             var_dump(dao::getError());
             error_log("DaoError: " . dao::getError() . "\n", 3, "/tmp/zentao.log");
             $this->pubu->sendNotification($pubuConfig->webhook, array('type' => 'error', 'data' => array('error' => dao::getError())));
             // die(js::error(dao::getError()));
         }
         $this->session->set('pubuConfig', '');
     }
     $this->view->position[] = html::a(inlink('index'), $this->lang->pubu->common);
     $this->view->position[] = '保存';
     $this->display();
 }
Esempio n. 27
0
 /**
  * Copy a group.
  * 
  * @param  int    $groupID 
  * @access public
  * @return void
  */
 public function copy($groupID)
 {
     $group = fixer::input('post')->specialChars('name, desc')->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);
         }
     }
 }
Esempio n. 28
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();
 }
Esempio n. 29
0
 /**
  * Edit a plan.
  * 
  * @param  int    $planID 
  * @access public
  * @return void
  */
 public function edit($planID)
 {
     if (!empty($_POST)) {
         $changes = $this->productplan->update($planID);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         if ($changes) {
             $actionID = $this->loadModel('action')->create('productplan', $planID, 'edited');
             $this->action->logHistory($actionID, $changes);
         }
         die(js::locate(inlink('view', "planID={$planID}"), 'parent'));
     }
     $plan = $this->productplan->getByID($planID);
     $this->commonAction($plan->product);
     $this->view->header->title = $this->lang->productplan->edit;
     $this->view->position[] = $this->lang->productplan->edit;
     $this->view->plan = $plan;
     $this->display();
 }
Esempio n. 30
0
 /**
  * Save tags.
  * 
  * @param  string    $tags 
  * @access public
  * @return void
  */
 public function save($tags)
 {
     $tags = array_unique(explode(',', $tags));
     foreach ($tags as $tag) {
         if (trim($tag) == '') {
             continue;
         }
         $rank = $this->countRank($tag);
         $count = $this->dao->select('count(*) as count')->from(TABLE_TAG)->where('tag')->eq($tag)->fetch('count');
         if ($count == 0) {
             $this->dao->insert(TABLE_TAG)->data(array('tag' => $tag, 'rank' => $rank))->exec();
         } else {
             $this->dao->update(TABLE_TAG)->set('rank')->eq($rank)->where('tag')->eq($tag)->exec();
         }
     }
     if (!dao::isError()) {
         return true;
     }
     return dao::geterror();
 }