public function process(Vtiger_Request $request)
	{
		$qualifiedModuleName = $request->getModule(false);
		$moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance();
		$status = false;

		if ($request->get('organizationname')) {
			$saveLogo = $status = true;
			if (!empty($_FILES['logo']['name'])) {
				$logoDetails = $_FILES['logo'];
				$fileType = explode('/', $logoDetails['type']);
				$fileType = $fileType[1];

				if (!$logoDetails['size'] || !in_array($fileType, Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
					$saveLogo = false;
				}

				//mime type check 
				$mimeType = Vtiger_Functions::getMimeContentType($logoDetails['tmp_name']);
				$mimeTypeContents = explode('/', $mimeType);
				if (!$logoDetails['size'] || $mimeTypeContents[0] != 'image' || !in_array($mimeTypeContents[1], Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
					$saveLogo = false;
				}

				// Check for php code injection
				$imageContents = file_get_contents($_FILES["logo"]["tmp_name"]);
				if (preg_match('/(<\?php?(.*?))/i', $imageContents) == 1) {
					$saveLogo = false;
				}
				if ($saveLogo) {
					$moduleModel->saveLogo();
				}
			} else {
				$saveLogo = true;
			}
			$fields = $moduleModel->getFields();
			foreach ($fields as $fieldName => $fieldType) {
				$fieldValue = $request->get($fieldName);
				if ($fieldName === 'logoname') {
					if (!empty($logoDetails['name'])) {
						$fieldValue = ltrim(basename(" " . $logoDetails['name']));
					} else {
						$fieldValue = $moduleModel->get($fieldName);
					}
				}
				$moduleModel->set($fieldName, $fieldValue);
			}
			$moduleModel->save();
		}

		$reloadUrl = $moduleModel->getIndexViewUrl();
		if ($saveLogo && $status) {
			
		} else if (!$saveLogo) {
			$reloadUrl .= '&error=LBL_INVALID_IMAGE';
		} else {
			$reloadUrl = $moduleModel->getEditViewUrl() . '&error=LBL_FIELDS_INFO_IS_EMPTY';
		}
		header('Location: ' . $reloadUrl);
	}
 public function process(Vtiger_Request $request)
 {
     $qualifiedModuleName = $request->getModule(false);
     $moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance();
     $saveLogo = $securityError = false;
     $logoDetails = $_FILES['logo'];
     $fileType = explode('/', $logoDetails['type']);
     $fileType = $fileType[1];
     $logoContent = file_get_contents($logoDetails['tmp_name']);
     if (preg_match('(<\\?php?(.*?))', $imageContent) != 0) {
         $securityError = true;
     }
     if (!$securityError) {
         if ($logoDetails['size'] && in_array($fileType, Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
             $saveLogo = true;
         }
         if ($saveLogo) {
             $moduleModel->saveLogo();
             $moduleModel->set('logoname', ltrim(basename(' ' . Vtiger_Util_Helper::sanitizeUploadFileName($logoDetails['name'], vglobal('upload_badext')))));
             $moduleModel->save();
         }
     }
     $reloadUrl = $moduleModel->getIndexViewUrl();
     if ($securityError) {
         $reloadUrl .= '&error=LBL_IMAGE_CORRUPTED';
     } else {
         if (!$saveLogo) {
             $reloadUrl .= '&error=LBL_INVALID_IMAGE';
         }
     }
     header('Location: ' . $reloadUrl);
 }
Esempio n. 3
0
 public function process(Vtiger_Request $request) {
     $newCompany = htmlentities($request->get('newCompany'), ENT_QUOTES);
     if( !empty($newCompany) && Settings_Vtiger_CompanyDetails_Model::addCompanyType($newCompany)) {
         header("Location: index.php?parent=Settings&module=Vtiger&view=CompanyDetails&company=" . html_entity_decode($newCompany, ENT_QUOTES));
     }else {
         header("Location: index.php?parent=Settings&module=Vtiger&view=CompanyDetails");
     }
 }
Esempio n. 4
0
 public function process(Vtiger_Request $request)
 {
     $qualifiedModuleName = $request->getModule(false);
     $moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance();
     $viewer = $this->getViewer($request);
     $viewer->assign('MODULE_MODEL', $moduleModel);
     $viewer->assign('ERROR_MESSAGE', $request->get('error'));
     $viewer->view('CompanyDetails.tpl', $qualifiedModuleName);
 }
 public function process(Vtiger_Request $request)
 {
     $qualifiedModuleName = $request->getModule(false);
     $supportedModules = Settings_Vtiger_CustomRecordNumberingModule_Model::getSupportedModules();
     $sourceModule = $request->get('sourceModule');
     if ($sourceModule) {
         $defaultModuleModel = $supportedModules[getTabid($sourceModule)];
     } else {
         $defaultModuleModel = reset($supportedModules);
     }
     $viewer = $this->getViewer($request);
     $viewer->assign('SUPPORTED_MODULES', $supportedModules);
     $viewer->assign('DEFAULT_MODULE_MODEL', $defaultModuleModel);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     // SalesPlatform.ru begin: Added separate numbering for self organizations
     $viewer->assign('HIDE_SP_COMPANY_ROW', Settings_Vtiger_CompanyDetails_Model::hideCompanyRow($defaultModuleModel));
     $viewer->assign('SP_PDF_COMPANIES', Settings_Vtiger_CompanyDetails_Model::getCompanies());
     // SalesPlatform.ru end
     $viewer->view('CustomRecordNumbering.tpl', $qualifiedModuleName);
 }
 public function process(Vtiger_Request $request)
 {
     $qualifiedModuleName = $request->getModule(false);
     //SalesPlatform.ru begin
     $selectedCompany = htmlspecialchars($request->get('company'), ENT_QUOTES);
     if ($selectedCompany == '') {
         $selectedCompany = 'Default';
     }
     $moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance($selectedCompany);
     //$moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance();
     //SalesPlatform.ru end
     $viewer = $this->getViewer($request);
     //SalesPlatform.ru begin
     $viewer->assign('SELECTED_COMPANY', htmlspecialchars($selectedCompany));
     //SalesPlatform.ru end
     $viewer->assign('MODULE_MODEL', $moduleModel);
     $viewer->assign('ERROR_MESSAGE', $request->get('error'));
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('CURRENT_USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->view('CompanyDetails.tpl', $qualifiedModuleName);
 }
Esempio n. 7
0
 /**
  * Display view.
  * @param Vtiger_Request $request
  */
 public function process(Vtiger_Request $request)
 {
     $recordModel = SPPDFTemplates_Record_Model::getInstanceById($request->get('templateid'));
     $moduleModel = new SPPDFTemplates_Module_Model();
     $pdfCompanies = array('All' => vtranslate('All'));
     foreach (Settings_Vtiger_CompanyDetails_Model::getCompanies() as $company) {
         $pdfCompanies[$company] = vtranslate($company, 'Settings:Vtiger');
     }
     if ($request->get('isDuplicate') != NULL) {
         $recordModel->toDuplicate();
     }
     $viewer = $this->getViewer($request);
     // SalesPlatform.ru begin Unifying method for EditView preparing
     $recordModel = prepareEditView($recordModel, $_REQUEST, $viewer);
     // SalesPlatform.ru end
     $viewer->assign('MODULE', $request->getModule());
     $viewer->assign('MODEL', $recordModel);
     $viewer->assign('MODULENAMES', $moduleModel->getModulesList());
     $viewer->assign('PAGE_ORIENTATIONS', $moduleModel->getPageOrientations());
     $viewer->assign('SP_PDF_COMPANIES', $pdfCompanies);
     $viewer->view('EditPDFTemplate.tpl', $request->getModule());
 }
Esempio n. 8
0
 /**
  * @param string $fieldname 
  * @return string 
  */
 public static function getSetting($fieldname)
 {
     $adb = PearDatabase::getInstance();
     if (!self::$settings) {
         self::$settings = $adb->database->GetRow("SELECT * FROM vtiger_organizationdetails");
     }
     return self::$settings[$fieldname];
 }
Esempio n. 9
0
 /** 
  * @param string $fieldname 
  * @return string 
  */
 public static function getSetting($fieldname)
 {
     global $adb;
     if (!self::$settings) {
         self::$settings = $adb->database->GetRow("SELECT * FROM vtiger_organizationdetails");
     }
     return self::$settings[$fieldname];
 }
 public function process(Vtiger_Request $request)
 {
     $log = vglobal('log');
     Settings_Vtiger_CompanyDetails_Model::addNewField($request);
     $log->info('Settings_Vtiger_CompanyFieldSave_Action::process - Add field started');
 }
Esempio n. 11
0
 /**
  * Function sends mail
  */
 public function send()
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $rootDirectory = vglobal('root_directory');
     $mailer = Emails_Mailer_Model::getInstance();
     $mailer->IsHTML(true);
     $fromEmail = $this->getFromEmailAddress();
     $replyTo = $currentUserModel->get('email1');
     $userName = $currentUserModel->getName();
     // To eliminate the empty value of an array
     $toEmailInfo = array_filter($this->get('toemailinfo'));
     $toMailNamesList = array_filter($this->get('toMailNamesList'));
     foreach ($toMailNamesList as $id => $emailData) {
         foreach ($emailData as $key => $email) {
             if ($toEmailInfo[$id]) {
                 array_push($toEmailInfo[$id], $email['value']);
             }
         }
     }
     $emailsInfo = array();
     foreach ($toEmailInfo as $id => $emails) {
         foreach ($emails as $key => $value) {
             array_push($emailsInfo, $value);
         }
     }
     $toFieldData = array_diff(explode(',', $this->get('saved_toid')), $emailsInfo);
     $toEmailsData = array();
     $i = 1;
     foreach ($toFieldData as $value) {
         $toEmailInfo['to' . $i++] = array($value);
     }
     $attachments = $this->getAttachmentDetails();
     $status = false;
     // Merge Users module merge tags based on current user.
     $mergedDescription = getMergedDescription($this->get('description'), $currentUserModel->getId(), 'Users');
     foreach ($toEmailInfo as $id => $emails) {
         $mailer->reinitialize();
         $mailer->ConfigSenderInfo($fromEmail, $userName, $replyTo);
         $old_mod_strings = vglobal('mod_strings');
         $description = $this->get('description');
         $parentModule = $this->getEntityType($id);
         if ($parentModule) {
             $currentLanguage = Vtiger_Language_Handler::getLanguage();
             $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $parentModule);
             vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
             if ($parentModule != 'Users') {
                 // Apply merge for non-Users module merge tags.
                 $description = getMergedDescription($mergedDescription, $id, $parentModule);
             } else {
                 // Re-merge the description for user tags based on actual user.
                 $description = getMergedDescription($description, $id, 'Users');
                 vglobal('mod_strings', $old_mod_strings);
             }
         }
         if (strpos($description, '$logo$')) {
             $description = str_replace('$logo$', "<img src='cid:logo' />", $description);
             $logo = true;
         }
         foreach ($emails as $email) {
             $mailer->Body = $description;
             $mailer->Signature = str_replace(array('\\r\\n', '\\n'), '<br>', $currentUserModel->get('signature'));
             if ($mailer->Signature != '') {
                 $mailer->Body .= '<br><br>' . decode_html($mailer->Signature);
             }
             $mailer->Subject = $this->get('subject');
             $mailer->AddAddress($email);
             //Adding attachments to mail
             if (is_array($attachments)) {
                 foreach ($attachments as $attachment) {
                     $fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
                     if (is_file($fileNameWithPath)) {
                         $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
                     }
                 }
             }
             if ($logo) {
                 //While sending email template and which has '$logo$' then it should replace with company logo
                 $company = Settings_Vtiger_CompanyDetails_Model::getInstance();
                 $logo = $company->getLogoPath('logoname');
                 $mailer->AddEmbeddedImage(dirname(__FILE__) . '/../../../' . $logo, 'logo', 'logo.jpg', 'base64', 'image/jpg');
             }
             $ccs = array_filter(explode(',', $this->get('ccmail')));
             $bccs = array_filter(explode(',', $this->get('bccmail')));
             if (!empty($ccs)) {
                 foreach ($ccs as $cc) {
                     $mailer->AddCC($cc);
                 }
             }
             if (!empty($bccs)) {
                 foreach ($bccs as $bcc) {
                     $mailer->AddBCC($bcc);
                 }
             }
         }
         $status = $mailer->Send(true);
         if (!$status) {
             $status = $mailer->getError();
         } else {
             $mailString = $mailer->getMailString();
             $mailBoxModel = MailManager_Mailbox_Model::activeInstance();
             $folderName = $mailBoxModel->folder();
             if (!empty($folderName) && !empty($mailString)) {
                 $connector = MailManager_Connector_Connector::connectorWithModel($mailBoxModel, '');
                 imap_append($connector->mBox, $connector->mBoxUrl . $folderName, $mailString, "\\Seen");
             }
         }
     }
     return $status;
 }
 public function process(Vtiger_Request $request)
 {
     Settings_Vtiger_CompanyDetails_Model::deleteCompanyType(htmlspecialchars($request->get('currentCompany'), ENT_QUOTES));
     header("Location: index.php?parent=Settings&module=Vtiger&view=CompanyDetails");
 }