Пример #1
0
 public static function getDefaultLangId()
 {
     if (!isset(self::$_defaultLangId)) {
         $lang = Model\Language::model()->findSingleByAttribute('language', \GO::language()->getLanguage());
         self::$_defaultLangId = $lang ? $lang->id : 1;
     }
     return self::$_defaultLangId;
 }
Пример #2
0
 public function init()
 {
     try {
         $this->uploadTarget = \Site::urlManager()->createUrl('site/front/ajaxWidget', array('widget_method' => 'upload', 'widget_class' => $this->className()));
         if (empty($this->max_file_size)) {
             $this->max_file_size = \GO::config()->max_file_size;
         }
         \Site::scripts()->registerGapiScript('jquery');
         \Site::scripts()->registerGapiScript('jquery-ui');
         $assetUrl = \Site::assetManager()->publish(\GO::config()->root_path . 'modules/site/widget/plupload/assets');
         $this->_swfUrl = $assetUrl . '/assets/js/plupload.flash.swf';
         \Site::scripts()->registerCssFile($assetUrl . '/assets/style.css');
         \Site::scripts()->registerScriptFile($assetUrl . '/assets/js/plupload.full.js');
         \Site::scripts()->registerScriptFile($assetUrl . '/assets/js/jquery.plupload.queue/jquery.plupload.queue.js');
         $langFile = '/assets/js/i18n/' . \GO::language()->getLanguage() . '.js';
         //			if(file_exists(\Site::assetManager()->getBasePath().$langFile)){
         \Site::scripts()->registerScriptFile($assetUrl . $langFile);
         //			}
     } catch (\Exception $e) {
         echo '<h2 style="color:red;">AN ERROR HAS OCCURED</h2>';
         //echo '<p style="color:red;">'.$e->getMessage().'</p>';
         echo '<p style="color:red;">Please check if the folder( <b>' . \GO::config()->assets_path . '</b> ) is writable for the webserver.<br />This path is also configurable in the Group-Office <b>config.php</b> file.<br />Please check the options: <b>assets_path</b> and <b>assets_url</b></p>';
     }
 }
Пример #3
0
 /**
  * Render a login page 
  */
 public function actionLogin()
 {
     $model = new \GO\Base\Model\User();
     if (\GO\Base\Util\Http::isPostRequest() && isset($_POST['User'])) {
         $model->username = $_POST['User']['username'];
         $password = $_POST['User']['password'];
         $user = \GO::session()->login($model->username, $password);
         //reset language after login
         if (!empty(\Site::model()->language)) {
             \GO::language()->setLanguage(\Site::model()->language);
         }
         if (!$user) {
             \Site::notifier()->setMessage('error', \GO::t('badLogin'));
             // set the correct login failure message
         } else {
             if (!empty($_POST['rememberMe'])) {
                 $encUsername = \GO\Base\Util\Crypt::encrypt($model->username);
                 if ($encUsername) {
                     $encUsername = $model->username;
                 }
                 $encPassword = \GO\Base\Util\Crypt::encrypt($password);
                 if ($encPassword) {
                     $encPassword = $password;
                 }
                 \GO\Base\Util\Http::setCookie('GO_UN', $encUsername);
                 \GO\Base\Util\Http::setCookie('GO_PW', $encPassword);
             }
             $this->redirect($this->getReturnUrl());
         }
     } elseif (isset($_GET['ref'])) {
         // url to go to after login
         \GO::session()->values['sites']['returnUrl'] = $_GET['ref'];
     }
     echo $this->render('login', array('model' => $model));
 }
Пример #4
0
		},true);
				
	require(["converse"], function (converse) {
        converse.initialize({
								//allow_chat_pending_contacts: true,
								bosh_service_url: "' . \GO\Chat\ChatModule::getBoshUri() . '", // Please use this connection manager only for testing purposes
								roster_groups: true,
								auto_login: true,
								authentication: "login",
								play_sounds: true,
                                allow_otr: true,
                                auto_list_rooms: true,
                                //auto_subscribe: true,
                                debug: false,
                                hide_muc_server: true,
                                i18n: locales["' . GO::language()->getLanguage() . '"], // Refer to ./locale/locales.js to see which locales are supported
                                show_controlbox_by_default: true,
                                xhr_user_search: false,
								jid: "' . GO::user()->username . '@puan.ddns.net",
								password: "******",
                                //fullname: "' . GO::user()->name . '"
								
								allow_registration: false
                });


		var name = converseJs.select("input.new-chatroom-name");
		name.value="conference.' . \GO\Chat\ChatModule::getXmppHost() . '";
			
		var nick = converseJs.select("input.new-chatroom-nick");
		nick.value="' . \GO\Base\Util\String::escape_javascript(GO::user()->name) . '";
Пример #5
0
 function generate($order = null)
 {
     $this->endPage();
     if ($order) {
         $this->_order = $order;
         $this->_orderAttr = $order->getAttributes('formatted');
         $this->_template = $order->status->getLanguage($this->_order->language_id)->template->getAttributes('raw');
         $this->init();
         $this->_headerPrinted = false;
         //Reset crap
         $this->cols = array();
         if ($this->_template['stationery_paper']) {
             $stationeryPaper = \GO::config()->file_storage_path . $this->_template['stationery_paper'];
         }
         if (!empty($stationeryPaper)) {
             $this->templateFile = $stationeryPaper;
         } else {
             $this->templateFile = null;
         }
     }
     $oldLangIso = \GO::language()->setLanguage($this->_order->language->language);
     $this->AddPage();
     //restore margins
     $this->SetMargins($this->lMargin, $this->_template['margin_top']);
     if (!empty($this->_orderAttr['frontpage_text']) && $this->_orderAttr['frontpage_text'] != '<br>') {
         $this->SetFont($this->font, '', 10);
         $this->writeHTMLCell($this->pageWidth, 12, $this->getX(), $this->getY(), $this->prepare_html($this->_orderAttr['frontpage_text']), 0, 1);
         if ($this->_orderAttr['pagebreak'] == '1') {
             $this->AddPage();
         } else {
             $this->Ln(20);
         }
     }
     $discount = false;
     //$supplier_product_id = false;
     $i = 0;
     $items = array();
     //		if (count($this->supplier)) {
     //			$this->_orderAttr['costs'] = 0;
     //			$this->_orderAttr['subtotal'] = 0;
     //			$this->_orderAttr['total'] = 0;
     //		}
     $stmt = $this->_order->items;
     $this->_inTable = true;
     while ($item = $stmt->fetch()) {
         if ($item->item_group_id > 0) {
             $itemGroup = Model\ItemGroup::model()->findByPk($item->item_group_id);
             if ($itemGroup) {
                 $suppressPrice = empty($itemGroup->summarize) && !$itemGroup->show_individual_prices;
             }
         }
         $items[$i]['heading'] = $item->unit_price == 0 && $item->amount == 0;
         //$items[$i]['product_id'] = $items[$i]['supplier_product_id'] = $item->supplier_product_id;
         if ($this->_IS_PURCHASE_INVOICE && $this->_template['show_supplier_product_id'] == '1') {
             $items[$i]['supplier_product_id'] = $item->product ? $item->product->supplier_product_id : "";
         }
         $items[$i]['discount'] = $item->discount > 0 ? $item->discount : 0;
         $items[$i]['amount'] = $item->amount;
         $items[$i]['description'] = $item->getParsedDescription();
         //$items[$i]['description'] = $billing2->replace_item_description($items[$i]['description'], $this->order);
         $items[$i]['id'] = $item->id;
         $items[$i]['article_id'] = !empty($item->product) ? $item->product->article_id : '';
         $items[$i]['cost_code'] = $item->cost_code;
         if ($this->_IS_PURCHASE_INVOICE) {
             $items[$i]['unit_cost'] = $item->unit_cost;
             $items[$i]['unit_total_cost'] = $item->unit_cost * ((100 + $item->vat) / 100);
             $items[$i]['total_cost'] = $item->amount * $item->unit_cost;
             $items[$i]['totalincl_cost'] = $item->amount * $items[$i]['unit_total_cost'];
         } else {
             $items[$i]['unit_price'] = $item->unit_price;
             $items[$i]['unit_list'] = $item->unit_list;
             $items[$i]['unit_total'] = $item->unit_total;
             $items[$i]['total'] = $item->amount * $item->unit_price;
             $items[$i]['totalincl'] = $item->amount * $item->unit_total;
         }
         $items[$i]['vat'] = $item->vat;
         $price = !empty($item->unit_price) ? $item->unit_price : $item->unit_list;
         $netUnitPrice = (100 + (double) $item->vat) * (double) $price / 100;
         $items[$i]['gross_unit_price'] = $netUnitPrice;
         $items[$i]['gross_total_price'] = (double) $item->amount * $netUnitPrice;
         $items[$i]['unit'] = $item->unit;
         $items[$i]['markup'] = $item->markup;
         $items[$i]['item_group_name'] = isset($item->item_group_name) ? $item->item_group_name : '';
         $items[$i]['summarize'] = !empty($item->summarize);
         $items[$i]['suppress_price'] = !empty($suppressPrice);
         //$items[$i]['item_price'] = $items[$i]['amount'] * $items[$i]['unit_price'];
         if ($item->discount > 0) {
             $discount = true;
         }
         //			if ($item->supplier_product_id > 0) {
         //				$supplier_product_id = true;
         //			}
         $i++;
     }
     //
     //		var_dump($items);
     //		exit();
     //$new_item_group = $item_group_name != $billing->f('item_group_name');
     //$item_group_name = $billing->f('item_group_name');
     //			if (count($this->supplier)) {
     //				$this->_orderAttr['costs'] += $billing->f('amount') * $billing->f('unit_cost');
     //				$this->_orderAttr['subtotal'] += $billing->f('amount') * $billing->f('unit_price');
     //				$this->_orderAttr['total'] += $billing->f('amount') * $billing->f('unit_total');
     //			}
     //			if (!empty($item_group_name)) {
     //				if ($billing->f('summarize')) {
     //					if (!empty($new_item_group)) {
     //						$items[$i]['heading'] = false;
     //						$items[$i]['amount'] = 1;
     //						$items[$i]['description'] = $item_group_name;
     //						$total_vat = $billing->f('vat') * $billing->f('amount');
     //						$total_amount = $billing->f('amount');
     //						$items[$i]['vat'] = $total_vat / $total_amount;
     ////															$items[$i]['unit_cost']=$billing->f('unit_cost');
     ////															$items[$i]['unit_price']=$billing->f('unit_price');
     ////															$items[$i]['unit_list']=$billing->f('unit_list');
     ////															$items[$i]['unit_total']=$billing->f('unit_total');
     //						$items[$i]['unit_list'] = $items[$i]['unit_total'] = $items[$i]['unit_price'] = $items[$i]['item_total'] = $items[$i]['total'] = $billing->f('total');
     //						$items[$i]['item_price'] = $billing->f('amount') * $items[$i]['unit_price'];
     //					} else {
     //						$i--;
     ////															$items[$i]['unit_cost']+=$billing->f('unit_cost');
     ////															$items[$i]['unit_price']+=$billing->f('unit_price');
     ////															$items[$i]['unit_list']+=$billing->f('unit_list');
     ////															$items[$i]['unit_total']+=$billing->f('amount')*$billing->f('unit_total');
     //						$total_vat += $billing->f('vat') * $billing->f('amount');
     //						$total_amount += $billing->f('amount');
     //						$items[$i]['vat'] = $total_vat / $total_amount;
     //						$items[$i]['unit_list'] = $items[$i]['unit_total'] = $items[$i]['unit_price'] = $items[$i]['item_total'] = $items[$i]['total']+=$billing->f('total');
     //						$items[$i]['item_price']+=$billing->f('amount') * $items[$i]['unit_price'];
     //					}
     //				} else {
     //					if (!empty($new_item_group)) {
     //						$items[$i]['heading'] = true;
     //						$items[$i]['amount'] = 0;
     //						$items[$i]['unit_price'] = 0;
     //						$items[$i]['total'] = 0;
     //						$items[$i]['description'] = $item_group_name;
     //						$i++;
     //					}
     //					$items[$i] = $this->createItem($billing, $billing2);
     //				}
     //			} else {
     //				$items[$i] = $this->createItem($billing, $billing2);
     //
     //				if ($billing->f('discount') > 0) {
     //					$discount = true;
     //				}
     //				if ($billing->f('supplier_product_id') > 0) {
     //					$supplier_product_id = true;
     //				}
     //			}
     //		$i++;
     //		}
     //$this->_description_width = $discount ? $this->pageWidth-270 : $this->pageWidth-210;
     $this->_description_width = $this->pageWidth;
     if ($discount) {
         $this->_description_width -= 50;
     }
     if ($this->_IS_PURCHASE_INVOICE && $this->_template['show_supplier_product_id'] == '1') {
         $this->_description_width -= 100;
     }
     if ($this->_template['show_amounts'] == '1') {
         $this->_description_width -= 50;
     }
     //		if ($this->_IS_PURCHASE_INVOICE) { //$this->_template['show_unit_cost'] == '1') {
     //			$this->_description_width -=240;
     //		} else {
     if ($this->_template['show_units'] == '1') {
         $this->_description_width -= 50;
     }
     if ($this->_template['show_nett_unit_price'] == '1') {
         $this->_description_width -= 90;
     }
     if ($this->_template['show_nett_total_price'] == '1') {
         $this->_description_width -= 80;
     }
     if ($this->_template['show_gross_unit_price'] == '1') {
         $this->_description_width -= 90;
     }
     if ($this->_template['show_gross_total_price'] == '1') {
         $this->_description_width -= 80;
     }
     if ($this->_template['show_product_number'] == '1') {
         $this->_description_width -= 60;
     }
     if ($this->_template['show_item_id'] == '1') {
         $this->_description_width -= 40;
     }
     if ($this->_template['show_cost_code'] == '1') {
         $this->_description_width -= 60;
     }
     //		}
     if ($this->_template['show_vat'] == '1') {
         $this->_description_width -= 30;
     }
     //start items table
     if ($this->_template['show_item_id'] == '1') {
         $this->cols[] = array('index' => 'id', 'name' => 'ID', 'width' => 40, 'align' => 'R');
     }
     if ($this->_template['show_product_number'] == '1') {
         $this->cols[] = array('index' => 'article_id', 'name' => \GO::t('artNr', 'billing'), 'width' => 60, 'align' => 'R');
     }
     $this->cols[] = array('index' => 'description', 'name' => \GO::t('item_description', 'billing'), 'width' => $this->_description_width, 'align' => 'L');
     if ($this->_template['show_cost_code'] == '1') {
         $this->cols[] = array('index' => 'cost_code', 'name' => \GO::t('costCode', 'billing'), 'width' => 60, 'align' => 'R');
     }
     if ($this->_template['show_amounts'] == '1') {
         $this->cols[] = array('index' => 'amount', 'name' => \GO::t('amount', 'billing'), 'width' => 50, 'align' => 'R');
     }
     if ($this->_template['show_units'] == '1') {
         $this->cols[] = array('index' => 'unit', 'name' => \GO::t('unit', 'billing'), 'width' => 50, 'align' => 'R');
     }
     if ($this->_IS_PURCHASE_INVOICE && $this->_template['show_supplier_product_id'] == '1') {
         $this->cols[] = array('index' => 'supplier_product_id', 'name' => \GO::t('supplier_prod_no', 'billing'), 'width' => 100, 'align' => 'L');
     }
     if ($discount) {
         $this->cols[] = array('index' => 'discount', 'name' => \GO::t('discount', 'billing'), 'width' => 50, 'align' => 'R', 'renderer' => 'render_discount');
     }
     if ($this->_template['show_vat'] == '1') {
         $this->cols[] = array('index' => 'vat', 'name' => \GO::t('vat', 'billing'), 'width' => 40, 'align' => 'R', 'renderer' => 'render_discount');
     }
     if ($this->_IS_PURCHASE_INVOICE) {
         //$this->_template['show_unit_cost'] == '1') {
         if ($this->_template['show_nett_unit_price'] == '1') {
             $this->cols[] = array('index' => 'unit_cost', 'name' => \GO::t('invoice_unit_cost', 'billing'), 'width' => 90, 'align' => 'R', 'renderer' => 'render_currency');
         }
         if ($this->_template['show_gross_unit_price'] == '1') {
             $this->cols[] = array('index' => 'unit_total_cost', 'name' => \GO::t('invoice_gross_unit_cost', 'billing'), 'width' => 90, 'align' => 'R', 'renderer' => 'render_currency');
         }
         if ($this->_template['show_nett_total_price'] == '1') {
             $this->cols[] = array('index' => 'total_cost', 'name' => \GO::t('invoice_total_cost', 'billing'), 'width' => 80, 'align' => 'R', 'renderer' => 'render_currency');
         }
         if ($this->_template['show_gross_total_price'] == '1') {
             $this->cols[] = array('index' => 'totalincl_cost', 'name' => \GO::t('grossTotalPrice', 'billing'), 'width' => 80, 'align' => 'R', 'renderer' => 'render_currency');
         }
     } else {
         if ($this->_template['show_nett_unit_price'] == '1') {
             $this->cols[] = array('index' => 'unit_price', 'name' => \GO::t('invoice_unit_price', 'billing'), 'width' => 90, 'align' => 'R', 'renderer' => 'render_currency');
         }
         if ($this->_template['show_gross_unit_price'] == '1') {
             $this->cols[] = array('index' => 'gross_unit_price', 'name' => \GO::t('grossUnitPrice', 'billing'), 'width' => 90, 'align' => 'R', 'renderer' => 'render_currency');
         }
         if ($this->_template['show_nett_total_price'] == '1') {
             $this->cols[] = array('index' => 'total', 'name' => \GO::t('total', 'billing'), 'width' => 80, 'align' => 'R', 'renderer' => 'render_currency');
         }
         if ($this->_template['show_gross_total_price'] == '1') {
             $this->cols[] = array('index' => 'gross_total_price', 'name' => \GO::t('grossTotalPrice', 'billing'), 'width' => 80, 'align' => 'R', 'renderer' => 'render_currency');
         }
     }
     /* else
     	  {
     	  $this->cols[]=array('index'=>'unit_price', 'name'=>'', 'width'=>90, 'align'=>'R', '');
     	  $this->cols[]=array('index'=>'total', 'name'=>'', 'width'=>80, 'align'=>'R', '');
     	  } */
     $rows = array();
     //		if ($this->_template['use_html_table'] != '1') {
     $this->table_header();
     //		}
     $startY = $this->GetY();
     $startX = $this->GetX();
     //		if ($this->_template['use_html_table'] == '1') {
     //			$currencies = array('unit_cost', 'unit_price', 'unit_list', 'unit_total', 'item_price', 'item_total');
     //			$html_table_totals_column = 0;
     //			$html_table_columns_num = 0;
     //
     //			$html = '<table border="0" cellpadding="3" width="100%">';
     //
     //			preg_match('/\{thead([^}]*)\}(.*)\{\/thead\}/sU', $this->_template['html_table'], $matched_col_tags);
     //			if (isset($matched_col_tags[2])) {
     //				preg_match_all('/\<td([^}]*)\>(.*)\<\/td\>/sU', $matched_col_tags[2], $matched_col_cells);
     //				if (isset($matched_col_cells[0])) {
     //					for ($i = 0; $i < count($matched_col_cells[0]); $i++) {
     //						preg_match('/\<td([^}]*)\>(.*)\<\/td\>/sU', $matched_col_cells[0][$i], $cell_parameters);
     //						if (isset($cell_parameters) && strpos($cell_parameters[1], 'totals="') !== false) {
     //							$html_table_totals_column = $i + 1;
     //						}
     //
     //						$html_table_columns_num++;
     //					}
     //				}
     //
     //				$html .= '<thead>' . $matched_col_tags[2] . '</thead>';
     //			}
     //
     //			if (count($items)) {
     //				preg_match('/\{row([^}]*)\}(.*)\{\/row\}/sU', $this->_template['html_table'], $matched_row_tags);
     //				if (isset($matched_row_tags[2])) {
     //					foreach ($items as $item) {
     //						$v = $matched_row_tags[2];
     //						foreach ($item as $key => $value) {
     //							if ($key == 'description') {
     //								$value = nl2br($value);
     //							}
     //							if (in_array($key, $currencies)) {
     //								$value = $this->render_currency($value);
     //							}
     //
     //							$v = str_replace('{' . $key . '}', $value, $v);
     //						}
     //						$html .= $v;
     //					}
     //				}
     //			} else {
     //				preg_match('/\{norows([^}]*)\}(.*)\{\/norows\}/sU', $this->_template['html_table'], $matched_norows_tags);
     //				$html .= $matched_norows_tags[2];
     //			}
     //		} else {
     $lastItem = array('group_name' => '', 'total' => 0, 'total_incl' => 0);
     $summarizedItem = array();
     foreach ($items as $k => $item) {
         $this->_checkPageBreak();
         if (!empty($item['item_group_name']) && $lastItem['group_name'] != $item['item_group_name']) {
             $this->_onNewGroup($item, $summarizedItem, $lastItem);
         }
         // The following 18 lines are for either adding up the numbers for the
         // summarized item, otherwise for the normal printing of the current
         // (non-summarized) item.
         $lastItem['total'] += !$this->_IS_PURCHASE_INVOICE ? $item['total'] : $item['total_cost'];
         $lastItem['total_incl'] += !$this->_IS_PURCHASE_INVOICE ? $item['totalincl'] : $item['totalincl_cost'];
         $this->_handleSingleItem($item, $summarizedItem);
     }
     if (!empty($summarizedItem)) {
         $this->_printItem($summarizedItem);
     } elseif (!empty($lastItem['group_name'])) {
         $w = 80;
         if ($this->_template['show_nett_total_price'] == '1' && $this->_template['show_gross_total_price'] == '1') {
             $this->MultiCell($w, 16, $this->_order->book->currency . ' ' . \GO\Base\Util\Number::localize($lastItem['total']), 'T', 'R', false, 0, $this->pageWidth + $this->lMargin - $w * 2);
         } elseif ($this->_template['show_nett_total_price'] == '1') {
             $this->MultiCell($w, 16, $this->_order->book->currency . ' ' . \GO\Base\Util\Number::localize($lastItem['total']), 'T', 'R', false, 1, $this->pageWidth + $this->lMargin - $w);
         }
         if ($this->_template['show_gross_total_price'] == '1') {
             $this->MultiCell($w, 16, $this->_order->book->currency . ' ' . \GO\Base\Util\Number::localize($lastItem['total_incl']), 'T', 'R', false, 1, $this->pageWidth + $this->lMargin - $w);
         }
         $this->ln(4);
     }
     $this->_checkPageBreak();
     //		}
     //		if ($this->_template['use_html_table'] != '1') {
     $this->table_line();
     //		}
     $this->_inTable = false;
     //		if ($this->_IS_PURCHASE_INVOICE) {
     //
     //			$this->Ln(10);
     //
     //			$width = 0;
     //			for ($i = 0; $i < count($this->cols) - 1; $i++) {
     //				$width += $this->cols[$i]['width'];
     //			}
     //
     //			$first_col_width = $width;
     //			$second_col_width = $this->cols[count($this->cols) - 1]['width'];
     //
     //			$costsTotals = $this->_order->getCostsTotals();
     //
     //			$this->Cell($first_col_width, 16, \GO::t('subtotal','billing') . ': ' . $this->_order->book->currency, 0, 0, 'R');
     //			$this->Cell($second_col_width, 16, \GO\Base\Util\Number::localize($costsTotals['subtotal']), 0, 0, 'R');
     //			$this->Ln();
     //
     //			$vatTotals = $this->_order->totalsCostsPerVatPercentage();
     //
     //			$count = count($vatTotals);
     //			while ($record = array_shift($vatTotals)) {
     //				$count--;
     //
     //				$border = $count == 0 ? 'B' : 0;
     //				$vat = $record['amount'] * $record['vat'] / 100;
     //
     //				if ($this->_template['use_html_table'] != '1') {
     //					$this->Cell($first_col_width, 16, \GO::t('vat','billing'). ' (' . $record['vat'] . '%): ' . $this->_order->book->currency, 0, 0, 'R');
     //					$this->Cell($second_col_width, 16, \GO\Base\Util\Number::localize($vat), $border, 0, 'R');
     //					$this->Ln();
     //				}
     //			}
     //
     //			$this->Ln();
     //
     //			$this->Cell($first_col_width, 16, \GO::t('total','billing') . ': ' . $this->_order->book->currency, 0, 0, 'R');
     //			$this->Cell($second_col_width, 16, \GO\Base\Util\Number::localize($costsTotals['total']), 0, 0, 'R');
     //
     //			$this->Ln(40);
     //
     //		} else
     if ($this->_template['show_summary_totals'] == 1 || $this->_template['use_html_table'] == 1) {
         //			if ($this->_template['use_html_table'] != '1') {
         $this->Ln(10);
         $width = 0;
         for ($i = 0; $i < count($this->cols) - 1; $i++) {
             $width += $this->cols[$i]['width'];
         }
         if ($this->_template['show_nett_total_price'] == 0 && $this->_template['show_nett_unit_price'] == 0 && $this->_template['show_gross_unit_price'] == 0 && $this->_template['show_gross_total_price'] == 0 && $this->_template['show_gross_total_cost'] == 0) {
             $first_col_width = 70;
             $second_col_width = 60;
             $this->setX($this->pageWidth - 100);
         } else {
             $first_col_width = $width;
             $second_col_width = $this->cols[count($this->cols) - 1]['width'];
         }
         if ($this->_IS_PURCHASE_INVOICE) {
             $vatTotals = $this->_order->totalsCostsPerVatPercentage();
         } else {
             $vatTotals = $this->_order->totalsPerVatPercentage();
         }
         $count = count($vatTotals);
         if ($this->_tooLittleSpace($count)) {
             $this->AddPage();
         }
         $this->Cell($first_col_width, 16, \GO::t('subtotal', 'billing') . ': ' . $this->_order->book->currency, 0, 0, 'R');
         if ($this->_IS_PURCHASE_INVOICE) {
             $costsTotals = $this->_order->getCostsTotals();
             $this->Cell($second_col_width, 16, \GO\Base\Util\Number::localize($costsTotals['subtotal']), 0, 0, 'R');
         } else {
             $this->Cell($second_col_width, 16, $this->_orderAttr['subtotal'], 0, 0, 'R');
         }
         $this->Ln();
         //			} else {
         //				$html_total_column_left[] = \GO::t('subtotal','billing') . ': ' .$this->_order->book->currency;
         //				$html_total_column_right[] = $this->_orderAttr['subtotal'];
         //			}
         while ($record = array_shift($vatTotals)) {
             $count--;
             $border = $count == 0 ? 'B' : 0;
             $vat = $record['amount'] * $record['vat'] / 100;
             if ($this->_template['use_html_table'] != '1') {
                 if ($this->_template['show_nett_total_price'] == 0 && $this->_template['show_nett_unit_price'] == 0 && $this->_template['show_gross_unit_price'] == 0 && $this->_template['show_gross_total_price'] == 0) {
                     $this->setX($this->pageWidth - 100);
                 }
                 $this->Cell($first_col_width, 16, \GO::t('vat', 'billing') . ' (' . $record['vat'] . '%): ' . $this->_order->book->currency, 0, 0, 'R');
                 $this->Cell($second_col_width, 16, \GO\Base\Util\Number::localize($vat), $border, 0, 'R');
                 $this->Ln();
             }
             //				} else {
             //					$html_total_column_left[] = \GO::t('vat','billing') . ' (' . $record['vat'] . '%): ' . $this->_order->book->currency;
             //					$html_total_column_right[] = \GO\Base\Util\Number::localize($vat);
             //				}
         }
         //			if ($this->_template['use_html_table'] != '1') {
         $this->Ln();
         if ($this->_template['show_nett_total_price'] == 0 && $this->_template['show_nett_unit_price'] == 0 && $this->_template['show_gross_unit_price'] == 0 && $this->_template['show_gross_total_price'] == 0) {
             $this->setX($this->pageWidth - 100);
         }
         $this->Cell($first_col_width, 16, \GO::t('total', 'billing') . ': ' . $this->_order->book->currency, 0, 0, 'R');
         if ($this->_IS_PURCHASE_INVOICE) {
             $this->Cell($second_col_width, 16, \GO\Base\Util\Number::localize($costsTotals['total']), 0, 0, 'R');
         } else {
             $this->Cell($second_col_width, 16, $this->_orderAttr['total'], 0, 0, 'R');
             if ($this->_template['show_total_paid'] == 1) {
                 $this->Ln();
                 if ($this->_template['show_nett_total_price'] == 0 && $this->_template['show_nett_unit_price'] == 0 && $this->_template['show_gross_unit_price'] == 0 && $this->_template['show_gross_total_price'] == 0) {
                     $this->setX($this->pageWidth - 100);
                 }
                 $this->Cell($first_col_width, 16, \GO::t('totalPaid', 'billing') . ': ' . $this->_order->book->currency, 0, 0, 'R');
                 $this->Cell($second_col_width, 16, $this->_orderAttr['total_paid'], 0, 0, 'R');
             }
         }
         //			} else {
         //				$html_total_column_left[] = \GO::t('total','billing') . ': ' . $this->_order->book->currency;
         //				$html_total_column_right[] = $this->_orderAttr['total'];
         //
         //				$html .= '<tr>'
         //								. '<td colspan="' . $html_table_columns_num . '" style="border-top: #000 1px solid;">&nbsp;</td>'
         //								. '</tr>';
         //
         //				if ($html_table_totals_column > $html_table_columns_num) {
         //					$html_table_totals_column = $html_table_columns_num;
         //				}
         //
         //				for ($i = 0; $i < count($html_total_column_left); $i++) {
         //					$html .= '<tr>';
         //
         //					if ($html_table_totals_column > 2) {
         //						$html .= '<td colspan="' . ($html_table_totals_column - 2) . '"></td>';
         //					}
         //
         //					$html .= '<td align="right">' . $html_total_column_left[$i] . '</td>';
         //					$html .= '<td align="right">' . $html_total_column_right[$i] . '</td>';
         //
         //					if ($html_table_columns_num != $html_table_totals_column) {
         //						$html .= '<td colspan="' . ($html_table_columns_num - $html_table_totals_column) . '"></td>';
         //					}
         //
         //					$html .= '</tr>';
         //				}
         //
         //				$html .= '</table>';
         //
         //				$this->writeHTML($html, false, false, false, false, '');
         //
         //				$this->Ln(3);
         //			}
         $this->Ln(40);
     } else {
         //large whiytespaces occur without this
         $this->Cell(0, 10, ' ');
     }
     if (!empty($this->_template['closing'])) {
         if ($this->_order->total_paid == $this->_order->total) {
             $paidStatus = 'fully_paid';
         } elseif ($this->_order->total_paid == 0) {
             $paidStatus = 'nothing_paid';
         } else {
             $paidStatus = 'partially_paid';
         }
         $templateParser = new \GO\Base\Util\TemplateParser();
         $this->_template['closing'] = $templateParser->parse($this->_template['closing'], array($paidStatus => true, 'total' => $this->_order->book->currency . \GO\Base\Util\Number::localize($this->_order->total), 'total_paid' => $this->_order->book->currency . \GO\Base\Util\Number::localize($this->_order->total_paid), 'to_be_paid' => $this->_order->book->currency . \GO\Base\Util\Number::localize($this->_order->total - $this->_order->total_paid)), true);
         // Also enable the template tags in the closing text
         $this->_template['closing'] = $this->_order->replaceTemplateTags($this->_template['closing'], false);
         ////
         $this->_template['closing'] = $this->prepare_html($this->_template['closing']);
         $closing = $this->_replaceFields($this->_template['closing']) . "\n<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
         //$this->writeHTMLCell($this->pageWidth, 16, 0,0, $closing);
         //var_dump($closing);exit();
         $this->writeHTML($closing);
         //$this->ln(10);
     }
     //		$params = array(&$this);
     //		if (\GO::modules()->isInstalled('projects')) {
     //
     //			/**
     //			 * If there are any detailed (unsummarized) hour items for this order,
     //			 * print them here.
     //			 */
     //
     //			$unsumItemsStmt = \GO\Projects\Model\OrderUnsummarizedItem::model()
     //				->findByAttribute('order_id',$this->_orderAttr['id'], \GO\Base\Db\FindParams::newInstance()->select('t.*'));
     //			if ($unsumItemsStmt->rowCount() > 0) {
     //
     //				$nextPenPosition = array(
     //					'endOfCurrentLine' => 0,
     //					'beginningOfNextLine' => 1,
     //					'onderaan' => 2
     //				);
     //
     //				$columnAttributes = array(
     //					array(
     //						'name' => \GO::t('nUnits','projects'),
     //						'fieldId' => 'amount',
     //						'width' => 60,
     //						'height' => 17,
     //						'textAlign' => 'R'
     //					),
     //					array(
     //						'name' => \GO::t('descriptionCol','projects'),
     //						'fieldId' => 'description',
     //						'width' => 320,
     //						'height' => 17,
     //						'textAlign' => 'L'
     //					),
     //					array(
     //						'name' => \GO::t('unitPrice','projects'),
     //						'fieldId' => 'unit_price',
     //						'width' => 60,
     //						'height' => 17,
     //						'textAlign' => 'L'
     //					),
     //					array(
     //						'name' => str_replace(array('<b>','</b>'),array('',''),\GO::t('total','projects')),
     //						'fieldId' => 'totalPrice',
     //						'width' => 80,
     //						'height' => 17,
     //						'textAlign' => 'L'
     //					)
     //				);
     //
     //				$headerAttributes = array(
     //					'borderWidth' => 0,
     //					'firstTextAlign' => 'R',
     //					'textAlign' => 'L',
     //					'lastTextAlign' => 'L',
     //					'paintBackground' => false,
     //					'url' => '',
     //					'nextPosition' => $nextPenPosition['endOfCurrentLine'],
     //				);
     //
     ////				$rowAttributes = array(
     ////					'borderWidth' => 1
     ////				);
     //
     //				$rows = array();
     //
     //				$this->AddPage();
     //
     //				$this->SetFont($this->font, '', 10);
     //
     //				$this->writeHTMLCell($this->pageWidth, 12, $this->getX(), $this->getY(), $this->prepare_html(\GO::t('daySpecs','billing')), 0, 1);
     //
     //				$this->Ln(20);
     //
     //				$this->_detailedHoursHeader($columnAttributes, $headerAttributes);
     //
     //				// Second part: write a table row for every item.
     //				while ($item = $unsumItemsStmt->fetch())
     //					$this->_detailedHoursRow($columnAttributes,$item->getAttributes(),$headerAttributes);
     //
     //				$this->table_line();
     //			}
     //
     //			$this->Cell(10,10, ' ');
     //
     //			\GO::language()->setLanguage($oldLangIso);
     //		}
 }
Пример #6
0
 /**
  * Sets current user for the entire session. Use it wisely!
  * @param int/Model\User $user_id
  */
 public function setCurrentUser($user_id)
 {
     //		if(\GO::modules()->isInstalled("log"))
     //			\GO\Log\Model\Log::create ("setcurrentuser", "Set user ID to $user_id");
     if ($user_id instanceof Model\User) {
         $this->_user = $user_id;
         $this->values['user_id'] = $user_id->id;
     } else {
         //remember user id in session
         $this->values['user_id'] = $user_id;
     }
     if (!\GO::user()) {
         throw new \Exception("Could not set user with id " . $user_id . " in Session::setCurrentUser()!");
     }
     date_default_timezone_set(\GO::user()->timezone);
     \GO::language()->setLanguage(\GO::user()->language);
     //for logging
     \GO::session()->values['username'] = \GO::user()->username;
 }
Пример #7
0
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (\GO\Base\Html\Error::checkRequired()) {
        foreach ($_POST as $key => $value) {
            \GO::config()->{$key} = $value;
        }
        \GO::config()->save();
        redirect("smtp.php");
    }
}
printHead();
?>
<h1>Regional settings</h1>

<?php 
\GO\Base\Html\Select::render(array("required" => true, 'label' => 'Country', 'value' => \GO::config()->default_country, 'name' => "default_country", 'options' => \GO::language()->getCountries()));
\GO\Base\Html\Select::render(array("required" => true, 'label' => 'Language', 'value' => \GO::config()->language, 'name' => "language", 'options' => \GO::language()->getLanguages()));
$tz = array();
foreach (DateTimeZone::listIdentifiers() as $id) {
    $tz[$id] = $id;
}
\GO\Base\Html\Select::render(array("required" => true, 'label' => 'Timezone', 'value' => \GO::config()->default_timezone, 'name' => "default_timezone", 'options' => $tz));
$dateFormats = array();
foreach (\GO::config()->date_formats as $format) {
    $dateFormats[$format] = str_replace(array('Y', 'm', 'd'), array('Year ', 'Month ', 'Day '), $format);
}
\GO\Base\Html\Select::render(array("required" => true, 'label' => 'Date format', 'value' => \GO::config()->default_date_format, 'name' => "default_date_format", 'options' => $dateFormats));
\GO\Base\Html\Input::render(array("required" => true, "label" => "Date separator", "name" => "default_date_separator", "value" => \GO::config()->default_date_separator));
$timeFormats = array();
foreach (\GO::config()->time_formats as $format) {
    $timeFormats[$format] = trim(str_replace(array('h', 'H', 'a', 'i', ':'), array('12h ', '24h ', '', ''), $format));
}
Пример #8
0
 private function _getAllLanguageFiles()
 {
     $files = array();
     $languages = array_keys(\GO::language()->getLanguages());
     $commonLangFolder = new \GO\Base\Fs\Folder(\GO::config()->root_path . 'language/');
     $folders = $commonLangFolder->ls();
     $modules = \GO::modules()->getAllModules();
     foreach ($modules as $module) {
         $folder = new \GO\Base\Fs\Folder($module->path . 'language');
         if ($folder->exists()) {
             $folders[] = $folder;
         }
     }
     foreach ($folders as $folder) {
         foreach ($languages as $language) {
             if ($file = $folder->child($language . '.php')) {
                 $files[] = $file;
             }
         }
     }
     return $files;
 }
Пример #9
0
 /**
  * Sends a meeting request to all participants. If the participant is not a Group-Office user
  * or the organizer has no permissions to schedule an event it will include an
  * icalendar attachment so the calendar software can schedule it.
  * 
  * @return boolean
  * @throws Exception
  */
 public function sendMeetingRequest($newParticipantsOnly = false, $update = false)
 {
     if (!$this->is_organizer) {
         throw new \Exception("Meeting request can only be send from the organizer's event");
     }
     $stmt = $this->participants;
     //handle missing user
     if (!$this->user) {
         $this->user_id = 1;
         $this->save(true);
     }
     while ($participant = $stmt->fetch()) {
         if (!$newParticipantsOnly || isset(\GO::session()->values['new_participant_ids']) && in_array($participant->user_id, \GO::session()->values['new_participant_ids'])) {
             //don't invite organizer
             if ($participant->is_organizer) {
                 continue;
             }
             // Set the language of the email to the language of the participant.
             $language = false;
             if (!empty($participant->user_id)) {
                 $user = \GO\Base\Model\User::model()->findByPk($participant->user_id);
                 if ($user) {
                     \GO::language()->setLanguage($user->language);
                 }
             }
             //if participant status is pending then send a new inviation subject. Otherwise send it as update
             if (!$update) {
                 $subject = \GO::t('invitation', 'calendar') . ': ' . $this->name;
                 $bodyLine = \GO::t('invited', 'calendar');
             } else {
                 $subject = \GO::t('invitation_update', 'calendar') . ': ' . $this->name;
                 $bodyLine = \GO::t('eventUpdated', 'calendar');
             }
             //create e-mail message
             $message = \GO\Base\Mail\Message::newInstance($subject)->setFrom($this->user->email, $this->user->name)->addTo($participant->email, $participant->name);
             //check if we have a Group-Office event. If so, we can handle accepting
             //and declining in Group-Office. Otherwise we'll use ICS calendar objects by mail
             $participantEvent = $participant->getParticipantEvent();
             $body = '<p>' . $bodyLine . ': </p>' . $this->toHtml();
             //				if(!$participantEvent){
             //build message for external program
             $acceptUrl = \GO::url("calendar/event/invitation", array("id" => $this->id, 'accept' => 1, 'email' => $participant->email, 'participantToken' => $participant->getSecurityToken()), false);
             $declineUrl = \GO::url("calendar/event/invitation", array("id" => $this->id, 'accept' => 0, 'email' => $participant->email, 'participantToken' => $participant->getSecurityToken()), false);
             //				if($participantEvent){
             //hide confusing buttons if user has a GO event.
             $body .= '<div class="go-hidden">';
             //				}
             $body .= '<p><br /><b>' . \GO::t('linkIfCalendarNotSupported', 'calendar') . '</b></p>' . '<p>' . \GO::t('acccept_question', 'calendar') . '</p>' . '<a href="' . $acceptUrl . '">' . \GO::t('accept', 'calendar') . '</a>' . '&nbsp;|&nbsp;' . '<a href="' . $declineUrl . '">' . \GO::t('decline', 'calendar') . '</a>';
             //				if($participantEvent){
             $body .= '</div>';
             //				}
             $ics = $this->toICS("REQUEST");
             $a = \Swift_Attachment::newInstance($ics, \GO\Base\Fs\File::stripInvalidChars($this->name) . '.ics', 'text/calendar; METHOD="REQUEST"');
             $a->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder("8bit"));
             $a->setDisposition("inline");
             $message->attach($a);
             //for outlook 2003 compatibility
             $a2 = \Swift_Attachment::newInstance($ics, 'invite.ics', 'application/ics');
             $a2->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder("8bit"));
             $message->attach($a2);
             if ($participantEvent) {
                 $url = \GO::createExternalUrl('calendar', 'openCalendar', array('unixtime' => $this->start_time));
                 $body .= '<br /><a href="' . $url . '">' . \GO::t('openCalendar', 'calendar') . '</a>';
             }
             $message->setHtmlAlternateBody($body);
             // Set back the original language
             if ($language !== false) {
                 \GO::language()->setLanguage($language);
             }
             \GO\Base\Mail\Mailer::newGoInstance()->send($message);
         }
     }
     unset(\GO::session()->values['new_participant_ids']);
     return true;
 }
Пример #10
0
					<td><?php 
echo $form->label($company, 'state');
?>
</td>
					<td><?php 
echo $form->textField($company, 'state');
echo $form->error($company, 'state');
?>
</td>	
				</tr>
				<tr>
					<td><?php 
echo $form->label($company, 'country');
?>
					<td><?php 
echo $form->dropDownList($company, 'country', \GO::language()->getCountries());
echo $form->error($company, 'country');
?>
</td>
				</tr>
<!--				<tr>
					<td><?php 
//echo $form->label($company, 'postAddressIsEqual');
?>
</td>
					<td><?php 
//echo $form->checkBox($company, 'postAddressIsEqual');
?>
</td>
			</tr>-->
<!--				<tr>
Пример #11
0
             $lines = explode("\n", $data);
             foreach ($lines as $line) {
                 if (!empty($line)) {
                     $scripts[] = $root_uri . $line;
                 }
             }
         }
         $modules[] = $module->id . $module->permissionLevel;
     }
 }
 //two modules may include the same script
 $scripts = array_map('trim', $scripts);
 $scripts = array_unique($scripts);
 //include config file location because in some cases different URL's point to
 //the same database and this can break things if the settings are cached.
 $file = $user_id . '-' . md5(\GO::config()->mtime . \GO::config()->get_config_file() . ':' . \GO::language()->getLanguage() . ':' . $modulesCacheStr) . '.js';
 $path = $cacheFolder->path() . '/' . $file;
 if (!\GO::config()->debug) {
     if (!file_exists($path)) {
         $js = '';
         file_put_contents($cacheFolder->path() . '/' . $user_id . '-modules.js', 'GO.settings.modules = Ext.decode("' . addslashes(json_encode(\GO::view()->exportModules())) . '");');
         array_unshift($scripts, $cacheFolder->path() . '/' . $user_id . '-modules.js');
         foreach ($scripts as $script) {
             //file_put_contents($path,"\n\n".file_get_contents($script),FILE_APPEND);
             $js .= "\n\n" . file_get_contents($script);
         }
         if (\GO::config()->minify) {
             $js = \GO\Base\Util\Minify\JSMin::minify($js);
         }
         file_put_contents($path, $js, FILE_APPEND);
     }
Пример #12
0
 protected function actionLogin($params)
 {
     if (!empty($params["login_language"])) {
         GO::language()->setLanguage($params["login_language"]);
     }
     if (!empty($params['domain'])) {
         $params['username'] .= $params['domain'];
     }
     $response = array();
     if (!$this->fireEvent('beforelogin', array(&$params, &$response))) {
         $response['success'] = false;
         if (!isset($response['feedback'])) {
             $response['feedback'] = GO::t('badLogin');
         }
         return $response;
     }
     $user = \GO::session()->login($params['username'], $params['password']);
     $response['success'] = $user != false;
     if (!$response['success']) {
         $response['feedback'] = \GO::t('badLogin');
     } else {
         if (!empty($params['remind'])) {
             $encUsername = \GO\Base\Util\Crypt::encrypt($params['username']);
             if (!$encUsername) {
                 $encUsername = $params['username'];
             }
             $encPassword = \GO\Base\Util\Crypt::encrypt($params['password']);
             if (!$encPassword) {
                 $encPassword = $params['password'];
             }
             \GO\Base\Util\Http::setCookie('GO_UN', $encUsername);
             \GO\Base\Util\Http::setCookie('GO_PW', $encPassword);
         }
         $response['groupoffice_version'] = \GO::config()->version;
         $response['user_id'] = $user->id;
         $response['security_token'] = \GO::session()->values["security_token"];
         $response['sid'] = session_id();
         if (!empty($params['return_user_info'])) {
             $response['modules'] = array();
             foreach (\GO::modules()->getAllModules() as $module) {
                 $response['modules'][] = $module->id;
             }
             $response['user'] = \GO::user()->getAttributes();
         }
         if (!empty($params["login_language"])) {
             GO::language()->setLanguage($params["login_language"]);
             \GO::user()->language = \GO::language()->getLanguage();
             \GO::user()->save();
         }
     }
     //		return $response;
     if (\GO\Base\Util\Http::isAjaxRequest()) {
         return $response;
     } else {
         $this->redirect();
     }
 }
Пример #13
0
 function process_form()
 {
     \GO::$ignoreAclPermissions = true;
     $this->check_required();
     if (!isset($_POST['salutation'])) {
         $_POST['salutation'] = isset($_POST['sex']) ? \GO::t('default_salutation_' . $_POST['sex']) : \GO::t('default_salutation_unknown');
     }
     //user registation
     //		if(!empty($_POST['username'])){
     //			$credentials = array ('username','first_name','middle_name','last_name','title','initials','sex','email',
     //			'home_phone','fax','cellular','address','address_no',
     //			'zip','city','state','country','company','department','function','work_phone',
     //			'work_fax');
     //
     //			if($_POST['password1'] != $_POST['password2'])
     //			{
     //				throw new Exception(\GO::t('error_match_pass','users'));
     //			}
     //
     //			foreach($credentials as $key)
     //			{
     //				if(!empty($_REQUEST[$key]))
     //				{
     //					$userCredentials[$key] = $_REQUEST[$key];
     //				}
     //			}
     //			$userCredentials['password']=$_POST['password1'];
     //
     //			$userModel = new \GO\Base\Model\User();
     //			$userModel->setAttributes($userCredentials);
     //			$userModel->save();
     //			foreach($this->user_groups as $groupId) {
     //				$currentGroupModel = \GO\Base\Model\Group::model()->findByPk($groupId);
     //				if($groupId>0 && $groupId!=\GO::config()->group_everyone && !$currentGroupModel->hasUser($userModel->id)) {
     //					$currentGroupModel->addUser($userModel->id);
     //				}
     //			}
     //			foreach($this->visible_user_groups as $groupId) {
     //				$userAclModel = \GO\Base\Model\Acl::model()->findByPk($userModel->acl_id);
     //				if($groupId>0 && !empty($userAclModel) && $userAclModel->hasGroup($groupId)) {
     //					$userAclModel->addGroup($groupId);
     //				}
     //			}
     //
     //			\GO::session()->login($userCredentials['username'], $userCredentials['password']);
     //		}
     if (!empty($_POST['email']) && !\GO\Base\Util\String::validate_email($_POST['email'])) {
         throw new Exception(\GO::t('invalidEmailError'));
     }
     if (!empty($_REQUEST['addressbook'])) {
         //			require($GO_LANGUAGE->get_language_file('addressbook'));
         //			require_once($GO_MODULES->modules['addressbook']['class_path'].'addressbook.class.inc.php');
         //			$ab = new addressbook();
         //
         //			$addressbook = $ab->get_addressbook_by_name($_REQUEST['addressbook']);
         $addressbookModel = \GO\Addressbook\Model\Addressbook::model()->findSingleByAttribute('name', $_REQUEST['addressbook']);
         if (!$addressbookModel) {
             throw new Exception('Addressbook not found!');
         }
         $credentials = array('first_name', 'middle_name', 'last_name', 'title', 'initials', 'sex', 'email', 'email2', 'email3', 'home_phone', 'fax', 'cellular', 'comment', 'address', 'address_no', 'zip', 'city', 'state', 'country', 'company', 'department', 'function', 'work_phone', 'work_fax', 'salutation', 'url_linkedin', 'url_facebook', 'url_twitter', 'skype_name');
         foreach ($credentials as $key) {
             if (!empty($_REQUEST[$key])) {
                 $contactCredentials[$key] = $_REQUEST[$key];
             }
         }
         if (isset($contactCredentials['comment']) && is_array($contactCredentials['comment'])) {
             $comments = '';
             foreach ($contactCredentials['comment'] as $key => $value) {
                 if ($value == 'date') {
                     $value = date($_SESSION['GO_SESSION']['date_format'] . ' ' . $_SESSION['GO_SESSION']['time_format']);
                 }
                 if (!empty($value)) {
                     $comments .= trim($key) . ":\n" . trim($value) . "\n\n";
                 }
             }
             $contactCredentials['comment'] = $comments;
         }
         if ($this->no_urls && isset($contactCredentials['comment']) && stripos($contactCredentials['comment'], 'http')) {
             throw new Exception('Sorry, but to prevent spamming we don\'t allow URL\'s in the message');
         }
         $contactCredentials['addressbook_id'] = $addressbookModel->id;
         $contactCredentials['email_allowed'] = isset($_POST['email_allowed']) ? '1' : '0';
         if (!empty($contactCredentials['company']) && empty($contactCredentials['company_id'])) {
             $companyModel = \GO\Addressbook\Model\Company::model()->findSingleByAttributes(array('name' => $contactCredentials['company'], 'addressbook_id' => $contactCredentials['addressbook_id']));
             if (empty($companyModel)) {
                 $companyModel = new \GO\Addressbook\Model\Company();
                 $companyModel->addressbook_id = $contactCredentials['addressbook_id'];
                 $companyModel->name = $contactCredentials['company'];
                 // bedrijfsnaam
                 $companyModel->user_id = \GO::user()->id;
                 $companyModel->save();
                 $contactCredentials['company_id'] = $companyModel->id;
             }
         }
         if (isset($_POST['birthday'])) {
             try {
                 $contactCredentials['birthday'] = \GO\Base\Util\Date::to_db_date($_POST['birthday'], false);
             } catch (Exception $e) {
                 throw new Exception(\GO::t('birthdayFormatMustBe') . ': ' . $_SESSION['GO_SESSION']['date_format'] . '.');
             }
             if (!empty($_POST['birthday']) && $contactCredentials['birthday'] == '0000-00-00') {
                 throw new Exception(\GO::t('invalidDateError'));
             }
         }
         unset($contactCredentials['company']);
         $existingContactModel = false;
         if (!empty($_POST['contact_id'])) {
             $existingContactModel = \GO\Addressbook\Model\Contact::model()->findByPk($_POST['contact_id']);
         } elseif (!empty($contactCredentials['email'])) {
             $existingContactModel = \GO\Addressbook\Model\Contact::model()->findSingleByAttributes(array('email' => $contactCredentials['email'], 'addressbook_id' => $contactCredentials['addressbook_id']));
         }
         if ($existingContactModel) {
             $this->contact_id = $contactId = $existingContactModel->id;
             $filesFolderId = $existingContactModel->files_folder_id = $existingContactModel->getFilesFolder()->id;
             /*
              * Only update empty fields
              */
             if (empty($_POST['contact_id'])) {
                 foreach ($contactCredentials as $key => $value) {
                     if ($key != 'comment') {
                         if (!empty($existingContactModel->{$key})) {
                             unset($contactCredentials[$key]);
                         }
                     }
                 }
             }
             $contactCredentials['id'] = $contactId;
             if (!empty($existingContactModel->comment) && !empty($contactCredentials['comment'])) {
                 $contactCredentials['comment'] = $existingContactModel->comment . "\n\n----\n\n" . $contactCredentials['comment'];
             }
             if (empty($contactCredentials['comment'])) {
                 unset($contactCredentials['comment']);
             }
             $existingContactModel->setAttributes($contactCredentials);
             $existingContactModel->save();
         } else {
             $newContactModel = new \GO\Addressbook\Model\Contact();
             $newContactModel->setAttributes($contactCredentials);
             $newContactModel->save();
             $this->contact_id = $contactId = $newContactModel->id;
             $filesFolderId = $newContactModel->files_folder_id = $newContactModel->getFilesFolder()->id;
             $newContactModel->save();
             if (isset($_POST['contact_id']) && empty($userId) && \GO::user()->id > 0) {
                 $userId = $this->user_id = \GO::user()->id;
             }
             if (!empty($userId)) {
                 $userModel = \GO\Base\Model\User::model()->findByPk($userId);
                 $userModel->contact_id = $contactId;
                 $userModel->save();
             }
         }
         if (!$contactId) {
             throw new Exception(\GO::t('saveError'));
         }
         if (\GO::modules()->isInstalled('files')) {
             $folderModel = \GO\Files\Model\Folder::model()->findByPk($filesFolderId);
             $path = $folderModel->path;
             $response['files_folder_id'] = $filesFolderId;
             $full_path = \GO::config()->file_storage_path . $path;
             foreach ($_FILES as $key => $file) {
                 if ($key != 'photo') {
                     //photo is handled later
                     if (is_uploaded_file($file['tmp_name'])) {
                         $fsFile = new \GO\Base\Fs\File($file['tmp_name']);
                         $fsFile->move(new \GO\Base\Fs\Folder($full_path), $file['name'], false, true);
                         $fsFile->setDefaultPermissions();
                         \GO\Files\Model\File::importFromFilesystem($fsFile);
                     }
                 }
             }
         }
         if (\GO::modules()->isInstalled('customfields')) {
             $cfFields = array();
             foreach ($_POST as $k => $v) {
                 if (strpos($k, 'col_') === 0) {
                     $cfFields[$k] = $v;
                 }
             }
             $contactCfModel = \GO\Addressbook\Customfields\Model\Contact::model()->findByPk($contactId);
             if (!$contactCfModel) {
                 $contactCfModel = new \GO\Addressbook\Customfields\Model\Contact();
                 $contactCfModel->model_id = $contactId;
             }
             $contactCfModel->setAttributes($cfFields);
             $contactCfModel->save();
         }
         if (isset($_POST['mailings'])) {
             foreach ($_POST['mailings'] as $mailingName) {
                 if (!empty($mailingName)) {
                     $addresslistModel = \GO\Addressbook\Model\Addresslist::model()->findSingleByAttribute('name', $mailingName);
                     if (empty($addresslistModel)) {
                         throw new Exception('Addresslist not found!');
                     }
                     $addresslistModel->addManyMany('contacts', $contactId);
                 }
             }
         }
         if ($this->contact_id > 0) {
             if (isset($_FILES['photo']['tmp_name']) && is_uploaded_file($_FILES['photo']['tmp_name'])) {
                 $fsFile = new \GO\Base\Fs\File($_FILES['photo']['tmp_name']);
                 $fsFile->move(new \GO\Base\Fs\Folder(\GO::config()->tmpdir), $_FILES['photo']['name'], false, false);
                 $contactModel = \GO\Addressbook\Model\Contact::model()->findByPk($contactId);
                 $contactModel->setPhoto(\GO::config()->tmpdir . $_FILES['photo']['name']);
             }
         }
         if (!isset($_POST['contact_id'])) {
             /**
              * Send notification of new contact to (1) users specified by 'notify_users'
              * in the form itself and to (2) the addressbook owner if so specified. 
              */
             // Send the email to the admin users in the language of the addressbook owner.
             $oldLanguage = \GO::language()->getLanguage();
             \GO::language()->setLanguage($addressbookModel->user->language);
             $usersToNotify = isset($_POST['notify_users']) ? explode(',', $_POST['notify_users']) : array();
             if (!empty($_POST['notify_addressbook_owner'])) {
                 $usersToNotify[] = $addressbookModel->user_id;
             }
             $mailTo = array();
             foreach ($usersToNotify as $userToNotifyId) {
                 $userModel = \GO\Base\Model\User::model()->findByPk($userToNotifyId);
                 $mailTo[] = $userModel->email;
             }
             if (count($mailTo)) {
                 $viewContactUrl = \GO::createExternalUrl('addressbook', 'showContact', array($contactId));
                 $contactModel = \GO\Addressbook\Model\Contact::model()->findByPk($contactId);
                 $companyModel = \GO\Addressbook\Model\Company::model()->findByPk($contactModel->company_id);
                 if (!empty($companyModel)) {
                     $companyName = $companyModel->name;
                 } else {
                     $companyName = '';
                 }
                 $values = array('address_no', 'address', 'zip', 'city', 'state', 'country');
                 $formatted_address = nl2br(\GO\Base\Util\Common::formatAddress('{country}', '{address}', '{address_no}', '{zip}', '{city}', '{state}'));
                 foreach ($values as $val) {
                     $formatted_address = str_replace('{' . $val . '}', $contactModel->{$val}, $formatted_address);
                 }
                 $body = \GO::t('newContactFromSite', 'addressbook') . ':<br />';
                 $body .= \GO::t('name', 'addressbook') . ': ' . $contactModel->addressbook->name . '<br />';
                 $body .= "<br />" . $contactModel->name;
                 $body .= "<br />" . $formatted_address;
                 if (!empty($contactModel->home_phone)) {
                     $body .= "<br />" . \GO::t('phone') . ': ' . $contactModel->home_phone;
                 }
                 if (!empty($contactModel->cellular)) {
                     $body .= "<br />" . \GO::t('cellular') . ': ' . $contactModel->cellular;
                 }
                 if (!empty($companyName)) {
                     $body .= "<br /><br />" . $companyName;
                 }
                 if (!empty($contactModel->work_phone)) {
                     $body .= "<br />" . \GO::t('workphone') . ': ' . $contactModel->work_phone;
                 }
                 $body .= '<br /><a href="' . $viewContactUrl . '">' . \GO::t('clickHereToView', 'addressbook') . '</a>' . "<br />";
                 $mailFrom = !empty($_POST['mail_from']) ? $_POST['mail_from'] : \GO::config()->webmaster_email;
                 $mailMessage = \GO\Base\Mail\Message::newInstance(\GO::t('newContactAdded', 'addressbook'), $body, 'text/html')->setFrom($mailFrom, \GO::config()->title);
                 foreach ($mailTo as $v) {
                     $mailMessage->addTo($v);
                 }
                 \GO\Base\Mail\Mailer::newGoInstance()->send($mailMessage);
             }
             // Restore the language
             \GO::language()->setLanguage($oldLanguage);
         }
         //
         //
         //	Maybe make this workable with GO 4.0 later....
         //
         //
         //			if(isset($_POST['confirmation_template']))
         //			{
         //				if(empty($_POST['email']))
         //				{
         //					throw new Exception('Fatal error: No email given for confirmation e-mail!');
         //				}
         //
         //				$url = create_direct_url('addressbook', 'showContact', array($contactId));
         //				$body = $lang['addressbook']['newContactFromSite'].'<br /><a href="'.$url.'">'.$lang['addressbook']['clickHereToView'].'</a>';
         //
         //				global $smarty;
         //				$email = $smarty->fetch($_POST['confirmation_template']);
         //
         //				$pos = strpos($email,"\n");
         //
         //				$subject = trim(substr($email, 0, $pos));
         //				$body = trim(substr($email,$pos));
         //
         //				require_once(\GO::config()->class_path.'mail/GoSwift.class.inc.php');
         //				$swift = new GoSwift($_POST['email'], $subject);
         //				$swift->set_body($body);
         //				$swift->set_from(\GO::config()->webmaster_email, \GO::config()->title);
         //				$swift->sendmail();
         //			}
         if (isset($_POST['confirmation_email']) && !empty($_POST['email'])) {
             if (strpos($_POST['confirmation_email'], '../') !== false || strpos($_POST['confirmation_email'], '..\\') !== false) {
                 throw new Exception('Invalid path');
             }
             $path = \GO::config()->file_storage_path . $_POST['confirmation_email'];
             if (!file_exists($path)) {
                 $path = dirname(\GO::config()->get_config_file()) . '/' . $_POST['confirmation_email'];
             }
             //$email = file_get_contents($path);
             //$messageModel = \GO\Email\Model\SavedMessage::model()->createFromMimeFile($path);
             //				$htmlBodyString = \GO\Addressbook\Model\Template::model()->replaceUserTags($messageModel->getHtmlBody());
             //				$htmlBodyString = \GO\Addressbook\Model\Template::model()
             //								->replaceContactTags(
             //												$htmlBodyString,
             //												\GO\Addressbook\Model\Contact::model()->findByPk($contactId),
             //												false);
             //				$messageModel->body =
             $mailMessage = \GO\Base\Mail\Message::newInstance()->loadMimeMessage(file_get_contents($path));
             $htmlBodyString = $mailMessage->getBody();
             foreach ($this->confirmation_replacements as $tag => $replacement) {
                 $htmlBodyString = str_replace('{' . $tag . '}', $replacement, $htmlBodyString);
             }
             $htmlBodyString = \GO\Addressbook\Model\Template::model()->replaceUserTags($htmlBodyString, true);
             $htmlBodyString = \GO\Addressbook\Model\Template::model()->replaceContactTags($htmlBodyString, \GO\Addressbook\Model\Contact::model()->findByPk($contactId), false);
             $mailMessage->setBody($htmlBodyString);
             $mailMessage->setFrom($mailMessage->getFrom(), $mailMessage->getSender());
             $mailMessage->addTo($_POST['email']);
             \GO\Base\Mail\Mailer::newGoInstance()->send($mailMessage);
         }
     }
 }
Пример #14
0
 /**
  * Find's the site model by server name or GET param site_id and runs the site.
  * 
  * @throws \GO\Base\Exception\NotFound
  */
 public static function launch($site_id = null)
 {
     if (isset($site_id)) {
         self::$_site = \GO\Site\Model\Site::model()->findByPk($site_id, false, true);
         // Find the website model from its id
     } else {
         if (isset($_GET['site_id'])) {
             GO::session()->values['site_id'] = $_GET['site_id'];
         }
         if (isset(GO::session()->values['site_id'])) {
             self::$_site = \GO\Site\Model\Site::model()->findByPk(GO::session()->values['site_id'], false, true);
         } else {
             self::$_site = \GO\Site\Model\Site::model()->findSingleByAttribute('domain', $_SERVER["SERVER_NAME"]);
         }
         // Find the website model from its domainname
     }
     if (!self::$_site) {
         self::$_site = \GO\Site\Model\Site::model()->findSingleByAttribute('domain', '*');
     }
     // Find the website model from its domainname
     if (!self::$_site) {
         throw new \GO\Base\Exception\NotFound('Website for domain ' . $_SERVER["SERVER_NAME"] . ' not found in database');
     }
     \GO::session()->loginWithCookies();
     if (!empty(self::model()->language)) {
         \GO::language()->setLanguage(self::model()->language);
     }
     self::router()->runController();
 }