当前位置: 首页>>代码示例>>PHP>>正文


PHP Protocol::update方法代码示例

本文整理汇总了PHP中Protocol::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Protocol::update方法的具体用法?PHP Protocol::update怎么用?PHP Protocol::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Protocol的用法示例。


在下文中一共展示了Protocol::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: correct

 /**
  * correct handles the corrections of the protocol
  * 
  * @param int $pid entry-id for protocol
  * @return string html of the correction page
  */
 private function correct($pid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#correct'));
     // get protocol object
     $protocol = new Protocol($pid);
     $correctable = $protocol->get_correctable(false);
     // js tiny_mce
     $tmce = array('element' => 'protocol-0', 'css' => 'templates/protocols/tmce_' . $protocol->get_preset()->get_path() . '.css', 'transitem' => parent::lang('class.ProtocolView#new_entry#tmce#item'), 'transdecision' => parent::lang('class.ProtocolView#new_entry#tmce#decision'));
     // smarty
     $this->tpl->assign('tmce', $tmce);
     // check rights
     if (Rights::check_rights($pid, 'protocol', true) && (in_array($_SESSION['user']->get_id(), $correctable['correctors']) || $_SESSION['user']->get_userinfo('name') == $protocol->get_owner())) {
         // check owner
         if ($_SESSION['user']->get_userinfo('name') == $protocol->get_owner()) {
             // smarty
             $sPCo = new JudoIntranetSmarty();
             // check action
             if ($this->get('action') == 'diff' && $this->get('uid') !== false) {
                 // diff correction of $uid
                 // get correction
                 $correction = new ProtocolCorrection($protocol, $this->get('uid'));
                 // clean protocols for diff
                 $diffBase = html_entity_decode(preg_replace('/<.*>/U', '', $protocol->get_protocol()));
                 $diffNew = html_entity_decode(preg_replace('/<.*>/U', '', $correction->get_protocol()));
                 // smarty
                 $sJsDL = new JudoIntranetSmarty();
                 // activate difflib js-files
                 $this->tpl->assign('jsdifflib', true);
                 // set values for difflib
                 $difflib = array('protDiffBase' => 'protDiffBase-0', 'protDiffNew' => 'protDiffNew-0', 'protDiffOut' => 'diffOut', 'protDiffBaseCaption' => parent::lang('class.ProtocolView#correct#diff#baseCaption'), 'protDiffNewCaption' => parent::lang('class.ProtocolView#correct#diff#newCaption'));
                 // add difflib values to js-template
                 $sJsDL->assign('dl', $difflib);
                 $this->add_jquery($sJsDL->fetch('smarty.js-jsdifflib.tpl'));
                 // add diffOut to template
                 $sPCo->assign('diffOut', 'diffOut');
                 // build form
                 $form = new HTML_QuickForm2('diffCorrection', 'post', array('name' => 'diffCorrection', 'action' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid')));
                 $datasource = array('protocol' => $protocol->get_protocol(), 'protDiffBase' => $diffBase, 'protDiffNew' => $diffNew);
                 // add datasource
                 $form->addDataSource(new HTML_QuickForm2_DataSource_Array($datasource));
                 // renderer
                 $renderer = HTML_QuickForm2_Renderer::factory('default');
                 $renderer->setOption('required_note', parent::lang('class.ProtocolView#entry#form#requiredNote'));
                 // elements
                 // protocol text
                 $protocolTA = $form->addElement('textarea', 'protocol');
                 $protocolTA->setLabel(parent::lang('class.ProtocolView#entry#form#protocol') . ':');
                 $protocolTA->addRule('regex', parent::lang('class.ProtocolView#entry#rule#regexp.allowedChars') . ' [' . $_SESSION['GC']->get_config('textarea.desc') . ']', $_SESSION['GC']->get_config('textarea.regexp'));
                 // checkbox to mark correction as finished
                 $finished = $form->addElement('checkbox', 'finished');
                 $finished->setLabel(parent::lang('class.ProtocolView#entry#form#finished') . ':');
                 // hidden textareas for texts to diff
                 $protocolBase = $form->addElement('textarea', 'protDiffBase');
                 $protocolNew = $form->addElement('textarea', 'protDiffNew');
                 // submit-button
                 $form->addElement('submit', 'submit', array('value' => parent::lang('class.ProtocolView#entry#form#submitButton')));
                 // add form to template
                 $sPCo->assign('c', true);
                 $sPCo->assign('form', $form->render($renderer));
                 // validate
                 if ($form->validate()) {
                     // get form data
                     $data = $form->getValue();
                     // check finished
                     if (!isset($data['finished'])) {
                         $data['finished'] = 0;
                     }
                     $correctionUpdate = array('finished' => $data['finished']);
                     $protocolUpdate = array('protocol' => $data['protocol']);
                     // update
                     $protocol->update($protocolUpdate);
                     $correction->update($correctionUpdate);
                     $protocol->writeDb('update');
                     $correction->writeDb('update');
                     // message
                     $message = array('message' => parent::lang('class.ProtocolView#correct#message#corrected'), 'href' => 'protocol.php?id=correct&pid=' . $pid . '&action=diff&uid=' . $this->get('uid'), 'title' => parent::lang('class.ProtocolView#correct#message#back'), 'text' => parent::lang('class.ProtocolView#correct#message#back'));
                     // assign to template
                     $sPCo->assign('c', false);
                     $sPCo->assign('message', $message);
                 }
             } else {
                 // list all corrections
                 // get corrections
                 $corrections = ProtocolCorrection::listCorrections($pid);
                 // put information together
                 $list = array();
                 $user = new User();
                 foreach ($corrections as $correction) {
                     // change user
                     $user->change_user($correction['uid'], false, 'id');
                     // fill list
                     $img = false;
                     if ($correction['finished'] == 1) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:101,代码来源:class.ProtocolView.php


注:本文中的Protocol::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。