/**
  * delete deletes the given entry
  * 
  * @param int $cid entry-id for calendar
  * @return string html-string
  */
 private function delete($cid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.CalendarView#page#caption#delete') . ": {$cid}");
     // check rights
     if (Rights::check_rights($cid, 'calendar')) {
         // prepare return
         $output = '';
         // smarty-templates
         $sConfirmation = new JudoIntranetSmarty();
         $form = new HTML_QuickForm2('confirm', 'post', array('name' => 'confirm', 'action' => 'calendar.php?id=delete&cid=' . $this->get('cid')));
         // add button
         $form->addElement('submit', 'yes', array('value' => parent::lang('class.CalendarView#delete#form#yes')));
         // smarty-link
         $link = array('params' => '', 'href' => 'calendar.php?id=listall', 'title' => parent::lang('class.CalendarView#delete#title#cancel'), 'content' => parent::lang('class.CalendarView#delete#form#cancel'));
         $sConfirmation->assign('link', $link);
         $sConfirmation->assign('spanparams', 'id="cancel"');
         $sConfirmation->assign('message', parent::lang('class.CalendarView#delete#message#confirm'));
         $sConfirmation->assign('form', $form);
         // validate
         if ($form->validate()) {
             // get calendar-object
             $calendar = new Calendar($cid);
             // disable entry
             $calendar->update(array('valid' => 0));
             // smarty
             $sConfirmation->assign('message', parent::lang('class.CalendarView#delete#message#done'));
             $sConfirmation->assign('form', '');
             // write entry
             try {
                 $calendar->write_db('update');
             } catch (Exception $e) {
                 $GLOBALS['Error']->handle_error($e);
                 return $GLOBALS['Error']->to_html($e);
             }
         }
         // smarty return
         return $sConfirmation->fetch('smarty.confirmation.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
 /**
  * decissions shows the decissions of this or all protocols
  * 
  * @param int $pid entry-id for protocol
  * @return string html of the decissions page
  */
 private function decisions($pid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#decisions'));
     // check rights
     if (Rights::check_rights($pid, 'protocol', true) || $pid == false) {
         // prepare template
         $sD = new JudoIntranetSmarty();
         // check pid all or single
         if ($pid === false) {
             // get protocol ids
             $pids = Protocol::return_protocols();
             // create protocol objects to sort
             $protocols = array();
             foreach ($pids as $pid) {
                 $protocols[] = new Protocol($pid);
             }
             // sort array by protocols date
             usort($protocols, array($this, 'callback_compare_protocols'));
             // walk through ids
             $counter = 0;
             foreach ($protocols as $protocol) {
                 // assign data
                 $data[$counter] = array('date' => $protocol->get_date('d.m.Y'), 'type' => $protocol->get_type(), 'location' => $protocol->get_location(), 'decisions' => $this->parseHtml($protocol->get_protocol(), '<p class="tmceDecision">|</p>'));
                 // check if protocol has decisions
                 if (count($data[$counter]['decisions']) == 0) {
                     unset($data[$counter]);
                 }
                 $data = array_merge($data);
                 // add to template
                 $sD->assign('data', $data);
                 // increment counter
                 $counter++;
             }
         } else {
             // get protocol object
             $protocol = new Protocol($pid);
             // assign data
             $data[] = array('date' => $protocol->get_date('d.m.Y'), 'type' => $protocol->get_type(), 'location' => $protocol->get_location(), 'decisions' => $this->parseHtml($protocol->get_protocol(), '<p class="tmceDecision">|</p>'));
             // add to template
             $sD->assign('data', $data);
         }
         // return
         return $sD->fetch('smarty.protocol.showdecisions.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
 /**
  * shows the details of the entry as pdf
  * 
  * @return string pdf-string
  */
 private function topdf()
 {
     // check cid and pid given
     if ($this->get('cid') !== false && $this->get('pid') !== false) {
         // check cid and pid exists
         if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
             // check if announcement has values
             if (Calendar::check_ann_value($this->get('cid'))) {
                 // prepare return
                 $return = '';
                 // get preset
                 $preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
                 // smarty
                 $sA = new JudoIntranetSmarty();
                 // get calendar
                 $calendar = new Calendar($this->get('cid'));
                 // prepare marker-array
                 $announcement = array('version' => date('dmy'));
                 // add calendar-fields to array
                 $calendar->add_marks($announcement);
                 // add field-names and -values to array
                 $preset->add_marks($announcement);
                 // smarty
                 $sA->assign('a', $announcement);
                 // check marks in values
                 foreach ($announcement as $k => $v) {
                     if (preg_match('/\\{\\$a\\..*\\}/U', $v)) {
                         $announcement[$k] = $sA->fetch('string:' . $v);
                     }
                 }
                 // smarty
                 $sA->assign('a', $announcement);
                 $pdf_out = $sA->fetch($preset->get_path());
                 // get HTML2PDF-object
                 $pdf = new HTML2PDF('P', 'A4', 'de', true, 'UTF-8', array(0, 0, 0, 0));
                 // convert
                 $pdf->writeHTML($pdf_out, false);
                 // output
                 $pdf_filename = $this->replace_umlaute(html_entity_decode($sA->fetch('string:' . $preset->get_filename()), ENT_XHTML, 'ISO-8859-1'));
                 $pdf->Output($pdf_filename, 'D');
                 // return
                 return $return;
             } else {
                 // error
                 $errno = $GLOBALS['Error']->error_raised('AnnNotExists', 'entry:' . $this->get('cid') . '|' . $this->get('pid'), $this->get('cid') . '|' . $this->get('pid'));
                 $GLOBALS['Error']->handle_error($errno);
                 return $GLOBALS['Error']->to_html($errno);
             }
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('WrongParams', 'entry:cid_or_pid', 'cid_or_pid');
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('MissingParams', 'entry:cid_or_pid', 'cid_or_pid');
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
 /**
  * defaultContent returns the content if nothing else is given
  * 
  * @return string default content as html-string
  */
 protected function defaultContent()
 {
     // smatry-template
     $sD = new JudoIntranetSmarty();
     $sD->assign('caption', parent::lang('class.PageView#defaultContent#text#caption'));
     $text[] = array('caption' => '', 'text' => parent::lang('class.PageView#defaultContent#text#content'));
     $sD->assign('text', $text);
     // return
     return $sD->fetch('smarty.default.content.tpl');
 }
Ejemplo n.º 5
0
 /**
  * logout logs the user out and sets all properties back to public access,
  * returns logout-message
  * 
  * @return string html-string of logout-message
  */
 public function logout()
 {
     // smarty-template
     $sLogout = new JudoIntranetSmarty();
     // set user-properties to public access
     $this->set_id(0);
     $this->set_groups(array(0));
     $this->set_loggedin(false);
     $this->set_login_message('class.User#login#message#default');
     $this->set_userinfo(array());
     // cleanup session
     foreach ($_SESSION as $name => $session) {
         // check if $_SESSION['user']
         if ($name != 'user') {
             unset($_SESSION[$name]);
         }
     }
     // read config again
     $_SESSION['GC'] = new Config();
     // logout-message
     // smarty
     $sLogout->assign('caption', parent::lang('class.User#logout#logout#caption'));
     $sLogout->assign('message', parent::lang('class.User#logout#logout#message'));
     $sLogout->assign('form', '');
     //		// return
     // smarty
     return $sLogout->fetch('smarty.login.tpl');
 }
 /**
  * movement returns the details of a movement-entry as html
  * 
  * @param int $mid entry-id for the movement
  * @return string html-string with the details of the movement entry
  */
 private function movement($mid)
 {
     // get db-object
     $db = Db::newDb();
     // get movement details
     // prepare sql-statement
     $sql = "SELECT m.inventory_id\n\t\t\t\tFROM inventory_movement AS m\n\t\t\t\tWHERE m.id = {$mid}";
     // execute
     $result = $db->query($sql);
     // fetch result
     list($inventory_id) = $result->fetch_array(MYSQL_NUM);
     // get invetory-object
     $inventory = new Inventory($inventory_id);
     // get preset
     $preset = $inventory->get_preset();
     // get fields
     $fields = $preset->get_fields();
     // check rights
     if (Rights::check_rights($inventory->get_id(), 'inventory')) {
         //smarty-template
         $sM = new JudoIntranetSmarty();
         // prepare sql
         $sql = "SELECT m.id,m.user_id,m.action,m.date_time\n\t\t\t\t\tFROM inventory_movement AS m\n\t\t\t\t\tWHERE m.inventory_id=" . $inventory->get_id() . "\n\t\t\t\t\tORDER BY m.date_time ASC";
         // execute
         $result = $db->query($sql);
         // fetch result
         $i = 0;
         $movements_data = array();
         while (list($m_id, $m_user_id, $m_action, $m_date_time) = $result->fetch_array(MYSQL_NUM)) {
             $movements_data[$i]['id'] = $m_id;
             $movements_data[$i]['user_id'] = $m_user_id;
             $movements_data[$i]['action'] = $m_action;
             $movements_data[$i]['date_time'] = $m_date_time;
             $i++;
         }
         // get actual movement data
         $data = array();
         for ($i = 0; $i < count($movements_data); $i++) {
             // check actual mid and previous
             if ($movements_data[$i]['id'] == $mid) {
                 $data[0]['id'] = $movements_data[$i]['id'];
                 $data[0]['user_id'] = $movements_data[$i]['user_id'];
                 $data[0]['action'] = $movements_data[$i]['action'];
                 $data[0]['date_time'] = $movements_data[$i]['date_time'];
                 // check first
                 if ($i != 0) {
                     $data[1]['id'] = $movements_data[$i - 1]['id'];
                     $data[1]['user_id'] = $movements_data[$i - 2]['user_id'];
                     $data[1]['action'] = $movements_data[$i - 1]['action'];
                 }
             }
         }
         $sM->assign('inventory', parent::lang('class.InventoryView#movement#hx#movement') . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
         $sM->assign('date', parent::lang('class.InventoryView#movement#hx#at') . date('d.m.Y', strtotime($data[0]['date_time'])));
         $back = array('href' => 'javascript:history.back(1)', 'title' => parent::lang('class.InventoryView#movement#back#title'), 'content' => parent::lang('class.InventoryView#movement#back#name'));
         $sM->assign('back', $back);
         foreach ($data as $movement) {
             // get user
             $user = new User();
             $user->change_user($movement['user_id'], false, 'id');
             // prepare fields
             $fields_out = array();
             foreach ($fields as $field) {
                 // get values
                 $data = array('table' => 'inventory_movement', 'table_id' => $movement['id'], 'field_id' => $field->get_id());
                 $field->read_value($data);
                 $fields_out[] = $field->value_to_html();
             }
             $sM->assign('data', $fields_out);
             $sM->assign('user', parent::lang('class.InventoryView#movement#fields#' . $movement['action']) . ' ' . $user->get_userinfo('name'));
         }
         // return
         return $sM->fetch('smarty.inventory.movement.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $mid);
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
 /**
  * defaults handles the administration of the default-values
  * 
  * @return string html-string with the field-administration-page
  */
 private function defaults()
 {
     // prepare content
     $content = '';
     $rid = $this->get('rid');
     // check $_GET['field']
     if ($this->get('rid') !== false || $this->get('action') == 'new') {
         // pagecaption
         $this->tpl->assign('pagecaption', parent::lang('class.AdministrationView#page#caption#defaults'));
         // check if row exists
         if ($this->row_exists('defaults', $rid) || $this->get('action') == 'new') {
             // check $_GET['action']
             if ($this->get('action') == 'new') {
                 $content .= $this->new_row('defaults');
             } elseif ($this->get('action') == 'edit') {
                 $content .= $this->edit_row('defaults', $rid);
             } elseif ($this->get('action') == 'disable') {
                 // check if row is enabled
                 if ($this->is_valid('defaults', $rid)) {
                     // set valid 0
                     $this->set_valid('defaults', $rid, 0);
                     // list table content
                     $content .= $this->list_table_content('defaults', $this->get('page'));
                 } else {
                     // give link to enable
                     // smarty
                     $sE = new JudoIntranetSmarty();
                     $sE->assign('message', parent::lang('class.AdministrationView#defaults#disable#rowNotEnabled'));
                     $sE->assign('href', 'administration.php?id=' . $this->get('id') . '&action=enable&rid=' . $rid);
                     $sE->assign('title', parent::lang('class.AdministrationView#defaults#disable#rowNotEnabled.enable'));
                     $sE->assign('content', parent::lang('class.AdministrationView#defaults#disable#rowNotEnabled.enable'));
                     $content .= $sE->fetch('smarty.admin.dis-enable.tpl');
                 }
             } elseif ($this->get('action') == 'enable') {
                 // check if row is disabled
                 if (!$this->is_valid('defaults', $rid)) {
                     // set valid 1
                     $this->set_valid('defaults', $rid, 1);
                     // list table content
                     $content .= $this->list_table_content('defaults', $this->get('page'));
                 } else {
                     // give link to disable
                     // smarty
                     $sE = new JudoIntranetSmarty();
                     $sE->assign('message', parent::lang('class.AdministrationView#defaults#enable#rowNotDisabled'));
                     $sE->assign('href', 'administration.php?id=' . $this->get('id') . '&action=disable&rid=' . $rid);
                     $sE->assign('title', parent::lang('class.AdministrationView#defaults#enable#rowNotDisabled.disable'));
                     $sE->assign('content', parent::lang('class.AdministrationView#defaults#enable#rowNotDisabled.disable'));
                     $content .= $sE->fetch('smarty.admin.dis-enable.tpl');
                 }
             } elseif ($this->get('action') == 'delete') {
                 $content .= $this->delete_row('defaults', $rid);
             } else {
                 $content .= $this->list_table_content('defaults', $this->get('page'));
             }
         } else {
             $errno = $GLOBALS['Error']->error_raised('RowNotExists', $this->get('rid'));
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // add default content
         $content .= $this->list_table_content('defaults', $this->get('page'));
     }
     // smarty
     $this->tpl->assign('caption', parent::lang('class.AdministrationView#defaults#caption#name'));
     $this->tpl->assign('tablelinks', '');
     // return
     return $content;
 }
 /**
  * user controles the actions for usersettings
  * 
  * @return string the html-string of usersettings-page
  */
 private function user()
 {
     // smarty-template
     $sUserPasswd = new JudoIntranetSmarty();
     // prepare return
     $return = '';
     // check login
     if ($_SESSION['user']->get_loggedin()) {
         // smarty
         $sUserPasswd->assign('pagecaption', parent::lang('class.MainView#user#caption#general') . ' ' . $_SESSION['user']->get_userinfo('name'));
         // check action
         if ($this->get('action') == 'passwd') {
             // smarty
             $sUserPasswd->assign('section', parent::lang('class.MainView#user#caption#passwd'));
             // prepare form
             $form = new HTML_QuickForm2('passwd', 'post', array('name' => 'passwd', 'action' => 'index.php?id=user&action=passwd'));
             // add elementgroup
             $passwd = $form->addElement('group', 'password', array());
             // add fields
             $passwd1 = $passwd->addElement('password', 'password1', array());
             $passwd2 = $passwd->addElement('password', 'password2', array());
             // add label
             $passwd->setLabel(parent::lang('class.MainView#user#passwd#label') . ':');
             // submit-button
             $form->addSubmit('submit', array('value' => parent::lang('class.MainView#user#passwd#submitButton')));
             // renderer
             $renderer = HTML_QuickForm2_Renderer::factory('default');
             $renderer->setOption('required_note', parent::lang('class.MainView#user#form#requiredNote'));
             // add rules
             $passwd->addRule('required', parent::lang('class.MainView#user#rule#required'));
             $passwd->addRule('callback', parent::lang('class.MainView#user#rule#checkPasswd'), array($this, 'callback_check_passwd'));
             // validate
             if ($form->validate()) {
                 // get values
                 $data = $form->getValue();
                 // get db-object
                 $db = Db::newDb();
                 // prepare sql-statement
                 $sql = "UPDATE user\n\t\t\t\t\t\t\tSET password='******'password']['password1']) . "'\n\t\t\t\t\t\t\tWHERE id=" . $_SESSION['user']->get_id();
                 // execute statement
                 $result = $db->query($sql);
                 // smarty message
                 $sUserPasswd->assign('message', parent::lang('class.MainView#user#validate#passwdChanged'));
             } else {
                 // smarty form and return
                 $sUserPasswd->assign('form', $form->render($renderer));
             }
             return $sUserPasswd->fetch('smarty.user.passwd.tpl');
         } else {
             return 'default content';
         }
     } else {
         // not authorized
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }