Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Tue, Jun 24, 11:27 PM

in-portal

Index: branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php (revision 5437)
@@ -0,0 +1,379 @@
+<?php
+
+ class AdminTagProcessor extends kDBTagProcessor {
+
+ function SetConst($params)
+ {
+ $name = $this->SelectParam($params, 'name,const');
+ safeDefine($name, $params['value']);
+ }
+
+ /**
+ * Allows to execute js script after the page is fully loaded
+ *
+ * @param Array $params
+ * @return string
+ */
+ function AfterScript($params)
+ {
+ $after_script = $this->Application->GetVar('after_script');
+ if ($after_script) {
+ return '<script type="text/javascript">'.$after_script.'</script>';
+ }
+ return '';
+ }
+
+ /**
+ * Returns section title with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionTitle($params)
+ {
+ $params['name'] = replaceModuleSection($params['phrase']);
+ return $this->Application->ProcessParsedTag('m', 'Phrase', $params);
+ }
+
+ /**
+ * Returns section icon with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionIcon($params)
+ {
+ return replaceModuleSection($params['icon']);
+ }
+
+ /**
+ * Allows to detect if current template is one of listed ones
+ *
+ * @param Array $params
+ * @return int
+ */
+ function TemplateMatches($params)
+ {
+ $templates = explode(',' ,$params['templates']);
+ $t = $this->Application->GetVar('t');
+ return in_array($t, $templates) ? 1 : 0;
+ }
+
+ /**
+ * Save return script in cases, when old sections are opened from new sections
+ *
+ * @param Array $params
+ */
+ function SaveReturnScript($params)
+ {
+ // admin/save_redirect.php?do=
+ $url = str_replace($this->Application->BaseURL(), '', $this->Application->ProcessParsedTag('m', 'Link', $params) );
+ $url = explode('?', $url, 2);
+ $url = 'save_redirect.php?'.$url[1].'&do='.$url[0];
+
+ $this->Application->StoreVar('ReturnScript', $url);
+ }
+
+ /**
+ * Redirects to correct next import step template based on import script data
+ *
+ * @param Array $params
+ */
+ function ImportRedirect($params)
+ {
+ $import_id = $this->Application->GetVar('import_id');
+ if ($import_id) {
+ // redirect forward to step3 (import parameters coosing)
+ $this->Application->StoreVar('ImportScriptID', $import_id);
+
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'ImportScripts
+ WHERE is_id = '.$import_id;
+
+ $db =& $this->Application->GetADODBConnection();
+ $is_params = $db->GetRow($sql);
+
+ if ($is_params['is_type'] == 'db') {
+ $this->Application->Redirect('', null, '', 'import/step3.php');
+ }
+ elseif ($is_params['is_type'] == 'csv') {
+ $module = strtolower($is_params['is_Module']);
+ $template = $module.'/import';
+ $module_info = $this->Application->findModule('Name', $module);
+
+ $item_prefix = $module_info['Var'];
+ $pass_params = Array('m_opener' => 'd', $item_prefix.'.import_id' => 0, $item_prefix.'.import_event' => 'OnNew', 'pass' => 'm,'.$item_prefix.'.import', 'm_cat_id' => $module_info['RootCat']);
+
+ $this->Application->Redirect($template, $pass_params);
+ }
+ }
+ else {
+ // redirect back to step2 (import type choosing)
+ $this->Application->Redirect('', null, '', 'import/step2.php');
+ }
+ }
+
+ /**
+ * Returns version of module by name
+ *
+ * @param Array $params
+ * @return string
+ */
+ function ModuleVersion($params)
+ {
+ return $this->Application->findModule('Name', $params['module'], 'Version');
+ }
+
+ /**
+ * Used in table form section drawing
+ *
+ * @param Array $params
+ * @return string
+ */
+ function DrawTree($params)
+ {
+ static $deep_level = 0;
+
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+ $params['deep_level'] = $deep_level++;
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ if (!isset($section_data['children'])) {
+ return $ret;
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $ret .= $this->DrawTree($params);
+ $deep_level--;
+ }
+
+
+ return $ret;
+ }
+
+
+ function PrintSection($params)
+ {
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $params['section_name'] = $section_name;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret = $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+
+ return $ret;
+ }
+
+ /**
+ * Used in XML drawing for tree
+ *
+ * @param Array $params
+ * @return string
+ */
+ function PrintSections($params)
+ {
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ if (!isset($section_data['children'])) {
+ return '';
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ if (isset($section_data['tabs_only']) && $section_data['tabs_only']) {
+ $perm_status = false;
+ $folder_label = $section_data['label'];
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+ $perm_status = $this->Application->CheckPermission($section_name.'.view', 1);
+ if ($perm_status) {
+ break;
+ }
+ }
+ if (!$perm_status) {
+ // no permission for all tabs -> don't display tree node either
+ continue;
+ }
+
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+ $section_data['label'] = $folder_label; // use folder label in tree
+ $section_data['is_tab'] = 1;
+ }
+ elseif (!$this->Application->CheckPermission($section_name.'.view', 1)) {
+ continue;
+ }
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+
+ $late_load = getArrayValue($section_data, 'late_load');
+ if ($late_load) {
+ $t = $late_load['t'];
+ unset($late_load['t']);
+ $section_data['late_load'] = $this->Application->HREF($t, '', $late_load);
+ $params['children_count'] = 99;
+ }
+ else {
+ $section_data['late_load'] = '';
+ }
+
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ $params['section_name'] = $section_name;
+ }
+
+ return preg_replace("/\r\n|\n/", '', $ret);
+ }
+
+ function ListSectionPermissions($params)
+ {
+ $section_name = isset($params['section_name']) ? $params['section_name'] : $this->Application->GetVar('section_name');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $block_params = array_merge_recursive2($section_data, Array('name' => $params['render_as'], 'section_name' => $section_name));
+
+ $ret = '';
+ foreach ($section_data['permissions'] as $perm_name) {
+ if (preg_match('/^advanced:(.*)/', $perm_name) != $params['type']) continue;
+ $block_params['perm_name'] = $perm_name;
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+ return $ret;
+ }
+
+ function ModuleInclude($params)
+ {
+ foreach ($params as $param_name => $param_value) {
+ $params[$param_name] = replaceModuleSection($param_value);
+ }
+
+ return $this->Application->ProcessParsedTag('m', 'ModuleInclude', $params);
+ }
+
+ function TodayDate($params)
+ {
+ return date($params['format']);
+ }
+
+ function TreeEditWarrning($params)
+ {
+ $ret = $this->Application->Phrase($params['label']);
+ $ret = str_replace(Array('&lt;', '&gt;', 'br/', 'br /', "\n", "\r"), Array('<', '>', 'br', 'br', '', ''), $ret);
+ if (getArrayValue($params, 'escape')) {
+ $ret = addslashes($ret);
+ }
+ $ret = str_replace('<br>', '\n', $ret);
+ return $ret;
+ }
+
+ /**
+ * Draws section tabs using block name passed
+ *
+ * @param Array $params
+ */
+ function ListTabs($params)
+ {
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($params['section_name']);
+
+ $ret = '';
+ $block_params = Array('name' => $params['render_as']);
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+ if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue;
+
+ $tab_data =& $sections_helper->getSectionData($section_name);
+ $block_params['t'] = $tab_data['url']['t'];
+ $block_params['title'] = $tab_data['label'];
+ $block_params['main_prefix'] = $section_data['SectionPrefix'];
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+
+
+ return $ret;
+ }
+
+ /**
+ * Returns list of module item tabs that have view permission in current category
+ *
+ * @param Array $params
+ */
+ function ListCatalogTabs($params)
+ {
+ $ret = '';
+ $special = isset($params['special']) ? $params['special'] : '';
+ $skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array();
+ $block_params = Array('name' => $params['render_as']);
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ $prefix = $module_info['Var'];
+ if (in_array($prefix, $skip_prefixes)) continue;
+ $label = $this->Application->getUnitOption($prefix, $params['title_property']);
+ $block_params['title'] = $label;
+ $block_params['prefix'] = $prefix;
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+ return $ret;
+ }
+
+ function FCKEditor($params)
+ {
+ include_once(FULL_PATH.'/admin/editor/cmseditor/fckeditor.php');
+ $oFCKeditor = new FCKeditor($params['name']);
+ $oFCKeditor->BasePath = BASE_PATH.'/admin/editor/cmseditor/';
+ $oFCKeditor->Width = $params['width'] ;
+ $oFCKeditor->Height = $params['height'] ;
+ $oFCKeditor->ToolbarSet = 'Advanced' ;
+ $oFCKeditor->Value = '' ;
+ $oFCKeditor->Config = Array(
+ //'UserFilesPath' => $pathtoroot.'kernel/user_files',
+ 'ProjectPath' => BASE_PATH.'/',
+ 'CustomConfigurationsPath' => $this->Application->BaseURL().'admin/editor/inp_fckconfig.js',
+ 'EditorAreaCSS' => $this->Application->BaseURL().'/themes/inportal_site/inc/inportal.css', //GetThemeCSS(),
+ //'StylesXmlPath' => '../../inp_styles.xml',
+// 'Debug' => 1,
+ 'Admin' => 1,
+ );
+ return $oFCKeditor->CreateHtml();
+
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/kernel/units/admin/admin_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.24
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.24.2/kernel/units/email_events/email_events_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/kernel/units/email_events/email_events_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.24.2/kernel/units/email_events/email_events_event_handler.php (revision 5437)
@@ -0,0 +1,270 @@
+<?php
+
+ class EmailEventsEventsHandler extends InpDBEventHandler
+ {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnFrontOnly' => Array('self' => 'edit'),
+ 'OnSaveSelected' => Array('self' => 'view'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Changes permission section to one from REQUEST, not from config
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ $module = $this->Application->GetVar('module');
+ $module = explode(':', $module, 2);
+
+ if (count($module) == 1) {
+ $main_prefix = $this->Application->findModule('Name', $module[0], 'Var');
+ }
+ else {
+ $exceptions = Array('Category' => 'c', 'Users' => 'u');
+ $main_prefix = $exceptions[ $module[1] ];
+ }
+ $section = $this->Application->getUnitOption($main_prefix.'.email', 'PermSection');
+
+ $event->setEventParam('PermSection', $section);
+ return parent::CheckPermission($event);
+ }
+
+ /**
+ * Apply any custom changes to list's sql query
+ *
+ * @param kEvent $event
+ * @access protected
+ * @see OnListBuild
+ */
+ function SetCustomQuery(&$event)
+ {
+ if ($event->Special == 'module') {
+ $object =& $event->getObject();
+ $module = $this->Application->GetVar('module');
+ $object->addFilter('module_filter', '%1$s.Module = '.$this->Conn->qstr($module));
+ }
+ }
+
+ /**
+ * Sets status Front-End Only to selected email events
+ *
+ * @param kEvent $event
+ */
+ function OnFrontOnly(&$event)
+ {
+ $ids = implode(',', $this->StoreSelectedIDs($event));
+
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'UPDATE '.$table_name.'
+ SET Enabled = 2
+ WHERE EventId IN ('.$ids.')';
+ $this->Conn->Query($sql);
+ }
+
+ /**
+ * Sets selected user to email events selected
+ *
+ * @param kEvent $event
+ */
+ function OnSelectUser(&$event)
+ {
+ $items_info = $this->Application->GetVar('u');
+ if ($items_info) {
+ $user_id = array_shift( array_keys($items_info) );
+
+ $ids = $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids');
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'UPDATE '.$table_name.'
+ SET '.$this->Application->RecallVar('dst_field').' = '.$user_id.'
+ WHERE '.$id_field.' IN ('.$ids.')';
+ $this->Conn->Query($sql);
+ }
+
+ $this->finalizePopup($event);
+ }
+
+ /**
+ * Saves selected ids to session
+ *
+ * @param kEvent $event
+ */
+ function OnSaveSelected(&$event)
+ {
+ $this->StoreSelectedIDs($event);
+ }
+
+ /**
+ * Raised when email message shoul be sent
+ *
+ * @param kEvent $event
+ */
+ function OnEmailEvent(&$event){
+
+ $email_event = $event->getEventParam('EmailEventName');
+ if( strpos($email_event, '_') !== false )
+ {
+ trigger_error('<span class="debug_error">Invalid email event name</span> <b>'.$email_event.'</b>. Use only <b>UPPERCASE characters</b> and <b>dots</b> as email event names', E_USER_ERROR);
+ }
+
+ $to_user_id = $event->getEventParam('EmailEventToUserId');
+ $email_event_type = $event->getEventParam('EmailEventType');
+
+ $message_object = &$this->Application->recallObject('emailmessages', null, Array('skip_autoload' => true));
+ $event_table = $this->Application->getUnitOption('emailevents', 'TableName');
+
+ $event_object = &$event->getObject();
+ $event_object->Load(array('Event'=>$email_event, 'Type'=>$email_event_type));
+
+ $event_id = $event_object->GetDBField('EventId');
+ $from_user_id = $event_object->GetDBField('FromUserId');
+ $type = $event_object->GetDBField('Type');
+ $enabled = $event_object->GetDBField('Enabled');
+
+ $direct_send_params = $event->getEventParam('DirectSendParams');
+
+ if ($enabled == 0) return; // disabled event
+ if ($enabled == 2 && $this->Application->IsAdmin() ) return; // event only for front-end
+
+ if ($type == 1){
+ // For type "Admin" recipient is a user from field FromUserId which means From/To user in Email events list
+ $to_user_id = $from_user_id;
+ $from_user_id = -1;
+ }
+ /*
+ if (!($to_user_id > 0) && !$direct_send_params){
+ // if we can not determine recepient we will not send email
+ return;
+ }
+ */
+ //Parse Message Template
+ $message_object->Load(array('EventId' => $event_id, 'LanguageId' => $this->Application->GetVar('m_lang')));
+ $message_type = $message_object->GetDBField('MessageType');
+
+ $email_object = &$this->Application->recallObject('kEmailMessage');
+ $email_object->Clear();
+
+ // add footer: begin
+ $sql = 'SELECT em.Template
+ FROM '.$message_object->TableName.' em
+ LEFT JOIN '.TABLE_PREFIX.'Events e ON e.EventId = em.EventId
+ WHERE em.LanguageId = '.$message_object->GetDBField('LanguageId').' AND e.Event = "COMMON.FOOTER"';
+ $footer = explode("\n\n", $this->Conn->GetOne($sql));
+ $footer = $message_object->GetDBField('MessageType') == 'text' ? $email_object->convertHTMLtoPlain($footer[1]) : $footer[1];
+ $message_template = $message_object->GetDBField('Template')."\r\n".$footer;
+ // add footer: end
+
+ $from_user_object = &$this->Application->recallObject('u.-email'.$from_user_id, null, Array('skip_autoload' => true));
+ $from_user_object->Load($from_user_id);
+ // here if we don't have from_user loaded, it takes a default user from config values
+ if ( $from_user_object->IsLoaded() ) {
+ $from_user_email = $from_user_object->GetDBField('Email');
+ $from_user_name = trim($from_user_object->GetDBField('FirstName').' '.$from_user_object->GetDBField('LastName'));
+ }
+ else {
+ $from_user_email = $this->Application->ConfigValue('Smtp_AdminMailFrom');
+ }
+
+ $to_user_object = &$this->Application->recallObject('u.-email'.$to_user_id, null, Array('skip_autoload' => true));
+ $to_user_object->Load($to_user_id);
+ $to_user_email = $to_user_object->GetDBField('Email');
+ $to_user_name = trim($to_user_object->GetDBField('FirstName').' '.$to_user_object->GetDBField('LastName'));
+
+ if($direct_send_params){
+ $to_user_email = ( $direct_send_params['to_email'] ? $direct_send_params['to_email'] : $to_user_email );
+ $to_user_name = ( $direct_send_params['to_name'] ? $direct_send_params['to_name'] : $to_user_name );
+ $from_user_email = ( $direct_send_params['from_email'] ? $direct_send_params['from_email'] : $from_user_email);
+ $from_user_name = ( $direct_send_params['from_name'] ? $direct_send_params['from_name'] : $from_user_name );
+ $message_body_additional = $direct_send_params['message'];
+ }
+
+ $to_user_email = $to_user_email ? $to_user_email : $this->Application->ConfigValue('Smtp_AdminMailFrom');
+
+ $this->Application->makeClass('Template');
+ $this->Application->InitParser();
+ $parser_params = $this->Application->Parser->Params;
+ $direct_send_params['message_text'] = $message_body_additional;
+ $this->Application->Parser->Params = array_merge_recursive2($this->Application->Parser->Params, $direct_send_params);
+ $message_template = str_replace('<inp:touser _Field', '<inp2:u_Field name', $message_template);
+ $message_template = $this->Application->Parser->Parse($message_template, 'email_template', 0);
+ $this->Application->Parser->Params = $parser_params;
+
+ $message_template = str_replace("\r", "", $message_template);
+
+ list($message_headers, $message_body) = explode("\n\n", $message_template, 2);
+
+
+ $email_object->setFrom($from_user_email, $from_user_name);
+ $email_object->setTo($to_user_email, $to_user_name);
+ $email_object->setSubject('Mail message');
+
+
+ $email_object->setHeaders($message_headers);
+
+ if ($message_type == 'html'){
+ $email_object->setHTMLBody($message_body);
+ }
+ else {
+ $email_object->setTextBody($message_body);
+ }
+
+ $smtp_object = &$this->Application->recallObject('kSmtpClient');
+ $smtp_object->debug = $this->Application->isDebugMode() && constOn('DBG_SMTP');
+
+ $smtp_server = $this->Application->ConfigValue('Smtp_Server');
+ $smtp_port = $this->Application->ConfigValue('Smtp_Port');
+
+ $smtp_authenticate = $this->Application->ConfigValue('Smtp_Authenticate');
+ if ($smtp_authenticate){
+ $smtp_user = $this->Application->ConfigValue('Smtp_User');
+ $smtp_pass = $this->Application->ConfigValue('Smtp_Pass');
+ }else{
+ $smtp_user = '';
+ $smtp_pass = '';
+ }
+
+
+ if ($smtp_server){
+ if ($email_object->sendSMTP($smtp_object, $smtp_server, $smtp_user, $smtp_pass, $smtp_authenticate)){
+ $event->status=erSUCCESS;
+ }
+ else {
+ $event->status=erFAIL;
+ }
+ }else{
+ if($email_object->send()){
+ $event->status=erSUCCESS;
+ }
+ else {
+ $event->status=erFAIL;
+ }
+ }
+
+ if ($event->status == erSUCCESS){
+ if (!$from_user_name) {
+ $from_user_name = strip_tags( $this->Application->ConfigValue('Site_Name') );
+ }
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'EmailLog SET
+ fromuser = '.$this->Conn->qstr($from_user_name.' ('.$from_user_email.')').',
+ addressto = '.$this->Conn->qstr($to_user_name.' ('.$to_user_email.')').',
+ subject = '.$this->Conn->qstr($email_object->Subject).',
+ timestamp = UNIX_TIMESTAMP(),
+ event = '.$this->Conn->qstr($email_event);
+ $this->Conn->Query($sql);
+ }
+
+ return $event;
+ }
+ }
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/kernel/units/email_events/email_events_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.24
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.24.2/kernel/include/config.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/kernel/include/config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.24.2/kernel/include/config.php (revision 5437)
@@ -0,0 +1,523 @@
+<?php
+
+class clsConfig
+{
+ var $config;
+ var $m_dirty_session;
+ var $m_IsDirty;
+ var $m_DirtyFields;
+ var $m_VarType;
+ var $adodbConnection;
+
+ function clsConfig()
+ {
+ $this->m_IsDirty=false;
+ $this->adodbConnection = &GetADODBConnection();
+ $this->config = array();
+ $this->m_IsDefault = array();
+ $this->VarType = array();
+ }
+
+ function SetDebugLevel($value)
+ {
+ }
+
+
+ function Load()
+ {
+ if(is_object($this->adodbConnection))
+ {
+ LogEntry("Config Load Start\n");
+ $sql = "select VariableName, VariableValue from ".GetTablePrefix()."ConfigurationValues";
+ $rs = $this->adodbConnection->Execute($sql);
+ unset($this->config);
+ #this->config=array();
+ $count=0;
+ while($rs && !$rs->EOF)
+ {
+ $this->config[$rs->fields["VariableName"]] = $rs->fields["VariableValue"];
+ $this->m_VarType[$rs->fields["VariableName"]] = 0;
+ // $this->Set($rs->fields["VariableName"],$rs->fields["VariableValue"],0);
+ if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 )
+ {
+ adodb_movenext($rs);
+ }
+ else
+ $rs->MoveNext();
+ $count++;
+ }
+ LogEntry("Config Load End - $count Variables\n");
+ }
+ unset($this->m_DirtyFields);
+ $this->m_IsDirty=false;
+ if (defined('DBG_SITE_PATH')) {
+ $this->config['Site_Path'] = DBG_SITE_PATH;
+ }
+ }
+
+ function Get($property)
+ {
+ if( isset($this->config[$property]) )
+ {
+ return $this->config[$property];
+ }
+ elseif( isset($this->config[ strtolower($property)] ) )
+ {
+ return $this->config[ strtolower($property) ];
+ }
+ else
+ {
+ return '';
+ }
+ }
+
+ function Set($property, $value,$type=0,$force=FALSE)
+ {
+ if(is_array($this->config) && strlen($property)>0)
+ {
+ if(array_key_exists($property,$this->config))
+ {
+ $current = $this->config[$property];
+ $changed = ($current != $value);
+ }
+ else
+ $changed = true;
+ }
+ else
+ $changed = false;
+ $this->config[$property]=$value;
+ $this->m_IsDirty = ($this->m_IsDirty or $changed or $force);
+ if($changed || $force)
+ {
+ $this->m_DirtyFields[$property] = $value;
+ }
+ $this->m_VarType[$property] = $type;
+ }
+
+ function Save()
+ {
+ if($this->m_IsDirty==TRUE)
+ {
+ foreach($this->m_DirtyFields as $field=>$value)
+ {
+ if($this->m_VarType[$field]==0)
+ {
+// $sql = sprintf("UPDATE ".GetTablePrefix()."ConfigurationValues SET VariableValue=%s WHERE VariableName=%s", $this->adodbConnection->qstr($value), $this->adodbConnection->qstr($field));
+ $sql = 'UPDATE '.GetTablePrefix().'ConfigurationValues SET VariableValue="'.addslashes($value).'" WHERE VariableName="'.addslashes($field).'"';
+ // echo $sql."<br>\n";
+
+ $rs = $this->adodbConnection->execute($sql);
+ }
+ }
+ }
+ $this->m_IsDirty=FALSE;
+ unset($this->m_DirtyFields);
+ }
+
+ function TimeFormat()
+ {
+ return is12HourMode() ? 'g:i:s A' : 'H:i:s';
+ }
+
+ /* vartype should be either 1 or 2, 1 = perstant data, 2 = session data */
+ function GetDirtySessionValues($VarType)
+ {
+ $result = array();
+
+ if(is_array($this->m_DirtyFields))
+ {
+ foreach($this->m_DirtyFields as $property=>$values)
+ {
+ if($this->m_VarType[$property]==$VarType)
+ $result[$property] = $values;
+ }
+ }
+ return $result;
+ }
+
+ function GetConfigValues($postfix = '')
+ {
+ // return only varibles, that match specified criteria
+ if(!$postfix) return $this->config;
+ $result = Array();
+ $postfix_len = $postfix ? strlen($postfix) : 0;
+ foreach($this->config as $config_var => $var_value)
+ {
+ if( substr($config_var, - $postfix_len) == $postfix )
+ $result[$config_var] = $var_value;
+ }
+ return $result;
+ }
+}/* clsConfig */
+
+/*
+To create the configuration forms in the admin section, populate the table ConfigurationAdmin and
+ConfigurationValues.
+
+ The tables are fairly straight-forward. The fields of concern in the ConfigurationValues table is
+ModuleOwner and Section. ModuleOwner should either be the module name or In-Portal for kernel related stuff.
+(Items which should appear under 'System Configuration').
+
+ The Section field determines the NavMenu section the value is associated with. For example,
+in-portal:configure_general refers to items listed under System Configuration->General.
+
+ In the ConfigurationAdmin table, ensure the VariableName field is the same as the one in ConfigurationValues
+(this is the field that creates the natural join.) The prompt field is the text displayed to the left of the form element
+in the table. This should contain LANGUAGE ELEMENT IDENTIFIERS that are plugged into the Language function.
+
+ The element_type field describes the type of form element is associated with this item. Possible values are:
+ - text : textbox
+ - checkbox : a simple checkbox
+ - select : creates a dropdown box. In this case, the ValueList field should be populated with a comma-separated list
+ in name=value,name=value format (each element is translated to:
+ <option VALUE="[value]">[name]</option>
+
+ To add dynamic data to this list, enclose an SQL statement with <SQL></SQL> tags for example:
+ <SQL>SELECT FieldLabel as OptionName, FieldName as OptionValue FROM <prefix>CustomField WHERE <prefix>.CustomFieldType=3></SQL>
+
+ note the specific field labels OptionName and OptionValue. They are required by the parser.
+ use the <prefix> tag to insert the system's table prefix into the sql statement as appropriate
+
+*/
+class clsConfigAdminItem
+{
+ var $name;
+ var $heading;
+ var $prompt;
+ var $ElementType;
+ var $ValueList; /* comma-separated list in name=value pair format*/
+ var $ValidationRules;
+ var $default_value;
+ var $adodbConnection;
+ var $NextItem=NULL;
+ var $Section;
+
+ var $DisplayOrder = null;
+
+ var $TabIndex = 0;
+
+ function clsConfigAdminItem($config_name=NULL)
+ {
+ $this->adodbConnection = &GetADODBConnection();
+ if($config_name)
+ $this->LoadSetting($config_name);
+ }
+
+ function LoadSetting($config_name)
+ {
+ $sql = "SELECT * FROM ".GetTablePrefix()."ConfigurationAdmin INNER JOIN ".GetTablePrefix()."ConfigurationValues Using(VariableName) WHERE ".GetTablePrefix()."ConfigurationAdmin.VariableName='".$config_name."'";
+ $rs = $this->adodbConnection->Execute($sql);
+ if($rs && !$rs->EOF)
+ {
+ $this->name = $rs->fields["VariableName"];
+ $this->heading = $rs->fields["heading"];
+ $this->prompt = $rs->fields["prompt"];
+ $this->ElementType = $rs->fields["element_type"];
+ $this->ValidationRules=$rs->fields["validation"];
+ $this->default_value = $rs->fields["VariableValue"];
+ $this->ValueList=$rs->fields["ValueList"];
+ $this->Section = $rs->fields["Section"];
+ $this->DisplayOrder = $rs->fields['DisplayOrder'];
+ }
+ }
+
+ function explode_sql($sql)
+ {
+ $s = "";
+
+ $rs = $this->adodbConnection->Execute($sql);
+
+ while ($rs && !$rs->EOF)
+ {
+ if(strlen(trim($rs->fields["OptionName"]))>0 && strlen(trim($rs->fields["OptionValue"]))>0)
+ {
+ if(strlen($s))
+ $s .= ",";
+ $s .= $rs->fields["OptionValue"]."="."+".$rs->fields["OptionName"];
+ }
+ $rs->MoveNext();
+ }
+ return $s;
+ }
+
+ function replace_sql($string, $start_mark = '<SQL>')
+ {
+ $mark_length = strlen($start_mark);
+ $string = str_replace("<PREFIX>",GetTablePrefix(),$string);
+
+ $start = strpos($string, $start_mark);
+
+ while($start)
+ {
+ $end = strpos($string,"</SQL>");
+ if(!$end)
+ {
+ $end = strlen($string);
+ }
+ $len = $end - $start;
+ $sql = substr($string,$start + $mark_length,$len - $mark_length);
+
+ $sql_val = $this->explode_sql($sql);
+ $s = substr($string, 0, $start) . $sql_val . substr($string, $end + $mark_length + 1);
+
+ $string = $s;
+ $start = strpos($string, $start_mark);
+ }
+
+ if ($start_mark == '<SQL>') {
+ // to prevent recursion. check new style of sqls too
+ $string = $this->replace_sql($string, '<SQL+>');
+ }
+
+ return preg_replace('/(.*)$,/','\\1', $string);
+ }
+
+ function ItemFormElement($StartFrom=1)
+ {
+ global $objConfig;
+
+ if(!$this->TabIndex) $this->TabIndex = $StartFrom;
+
+ $o = '';
+ if( $objConfig->Get($this->name) != '' )
+ {
+ $this->default_value = $objConfig->Get($this->name);
+ }
+ $this->default_value = inp_htmlize($this->default_value);
+ switch($this->ElementType)
+ {
+ case 'text':
+ $o .= '<input type="text" tabindex="'.($this->TabIndex++).'" name="'.$this->name.'" ';
+ $o .= 'value="'.$this->default_value.'">';
+ break;
+
+ case 'checkbox':
+ $o .= '<input type="checkbox" name="'.$this->name.'" tabindex="'.($this->TabIndex++).'"';
+ $o .= $this->default_value ? ' checked>' : '>';
+ break;
+
+ case 'password':
+ /* To exclude config form from populating with Root (md5) password */
+ if( $this->Section == 'in-portal:configure_users' ) $this->default_value = '';
+
+ $o .= '<input type="password" tabindex="'.($this->TabIndex++).'" name="'.$this->name.'" ';
+ $o .= 'value="'.$this->default_value.'">';
+ break;
+
+ case 'textarea':
+ $o .= '<textarea tabindex="'.($this->TabIndex++).'" '.$this->ValueList.' name="'.$this->name.'">'.$this->default_value.'</textarea>';
+ break;
+
+ case 'label':
+ if ($this->default_value) {
+ $tag_params = clsHtmlTag::ParseAttributes($this->ValueList);
+ if (isset($tag_params['cut_first'])) {
+ $cut_first = $tag_params['cut_first'];
+ if (strlen($this->default_value) > $cut_first) {
+ $o .= substr($this->default_value, 0, $cut_first).' ...';
+ }
+ else {
+ $o .= $this->default_value;
+ }
+ }
+ else {
+ $o .= $this->default_value;
+ }
+ }
+ break;
+
+ case 'radio':
+ $radioname = $this->name;
+ $ValList = $this->replace_sql($this->ValueList);
+
+ $this->TabIndex++;
+ $val = explode(',',$ValList);
+ for($i=0;$i<=count($val);$i++)
+ {
+ if(strlen($val[$i]))
+ {
+ $parts = explode('=',$val[$i]);
+ $s = $parts[1];
+ if(strlen($s)==0)
+ $s = '';
+ $o .= '<input type="radio" tabindex="'.$this->TabIndex.'" name="'.$this->name.'" value="'.$parts[0].'"';
+ $o .= ($this->default_value == $parts[0]) ? ' checked>' : '>';
+
+ $o .= (substr($s,0,1)=="+") ? $s : prompt_language($s);
+ }
+ }
+ $this->TabIndex++;
+ break;
+
+ case 'select':
+ $o .= '<select name="'.$this->name.'" tabindex="'.($this->TabIndex++).'">';
+ $ValList = $this->replace_sql($this->ValueList);
+ $val = explode(',', $ValList);
+ for($i=0;$i<=count($val);$i++)
+ {
+ if(strlen($val[$i]))
+ {
+ $parts = explode('=',$val[$i]);
+ $s = $parts[1];
+ if(strlen($s)==0) $s = '';
+ $selected = '';
+ if($this->default_value==$parts[0]) $selected = ' selected';
+
+ $title = (substr($s,0,1) == '+') ? substr($s,1) : admin_language($s);
+ $o .= '<option value="'.$parts[0].'" '.$selected.'>'.$title.'</option>';
+ }
+ }
+ $o .= '</select>';
+ break;
+ }
+ return $o;
+ }
+
+ function GetPrompt()
+ {
+ $ret = prompt_language($this->prompt);
+ return $ret;
+ }
+}
+
+class clsConfigAdmin
+{
+ var $module;
+ var $section;
+ var $Items;
+
+ function clsConfigAdmin($module="",$section="",$Inst=FALSE)
+ {
+ $this->module = $module;
+ $this->section = $section;
+ $this->Items= array();
+ if(strlen($module) && strlen($section))
+ $this->LoadItems(TRUE,$Inst);
+ }
+
+ function Clear()
+ {
+ unset($this->Items);
+ $this->Items = array();
+ }
+
+ function NumItems()
+ {
+ if(is_array($this->Items))
+ {
+ return count($this->Items);
+ }
+ else
+ return 0;
+ }
+
+ function LoadItems($CheckNextItems=TRUE, $inst=FALSE)
+ {
+ $this->Clear();
+ if(!$inst)
+ {
+ $sql = "SELECT * FROM ".GetTablePrefix()."ConfigurationAdmin INNER JOIN ".GetTablePrefix()."ConfigurationValues Using(VariableName)
+ WHERE ModuleOwner='".$this->module."' AND Section='".$this->section."' ORDER BY DisplayOrder ASC";
+ }
+ else
+ {
+
+ $sql = "SELECT * FROM ".GetTablePrefix()."ConfigurationAdmin INNER JOIN ".GetTablePrefix()."ConfigurationValues Using(VariableName)
+ WHERE ModuleOwner='".$this->module."' AND Section='".$this->section."' AND Install=1 ORDER BY DisplayOrder ASC";
+ }
+ if( $GLOBALS['debuglevel'] ) echo $sql."<br>\n";
+ $adodbConnection = &GetADODBConnection();
+ $rs = $adodbConnection->Execute($sql);
+ $i = null;
+ $last = '';
+ while($rs && !$rs->EOF)
+ {
+ $data = $rs->fields;
+ if(is_object($i) && $CheckNextItems)
+ {
+ $last = $i->prompt;
+ unset($i);
+ }
+ $i = new clsConfigAdminItem(NULL);
+ $i->name = $data["VariableName"];
+ $i->default_value = $data["VariableValue"];
+ $i->heading = $data["heading"];
+ $i->prompt = $data["prompt"];
+ $i->ElementType = $data["element_type"];
+ $i->ValueList = $data["ValueList"];
+ $i->ValidationRules = isset($data['validaton']) ? $data['validaton'] : '';
+ $i->Section = $data["Section"];
+ $i->DisplayOrder = $data['DisplayOrder'];
+
+ if(strlen($last)>0)
+ {
+ if($i->prompt==$last)
+ {
+ $this->Items[count($this->Items)-1]->NextItem=$i;
+ }
+ else
+ {
+ $i->NextItem=NULL;
+ array_push($this->Items,$i);
+ }
+ }
+ else
+ {
+ $i->NextItem=NULL;
+ array_push($this->Items,$i);
+ }
+ //unset($i);
+ $rs->MoveNext();
+ }
+ }
+
+ function SaveItems($POSTVARS, $force=FALSE)
+ {
+ global $objConfig;
+
+ foreach($this->Items as $i)
+ {
+ if($i->ElementType != "label")
+ {
+ if($i->ElementType != "checkbox")
+ {
+ $objConfig->Set($i->name,stripslashes($POSTVARS[$i->name]));
+ }
+ else
+ {
+ if($POSTVARS[$i->name]=="on")
+ {
+ $value=1;
+ }
+ else
+ $value = (int)$POSTVARS[$i->name];
+ $objConfig->Set($i->name,stripslashes($value),0,$force);
+ }
+ }
+ }
+ $objConfig->Save();
+ }
+
+ function GetHeadingList()
+ {
+ $res = array();
+ foreach($this->Items as $i)
+ {
+ $res[$i->heading]=1;
+ }
+ reset($res);
+ return array_keys($res);
+ }
+
+ function GetHeadingItems($heading)
+ {
+ $res = array();
+ foreach($this->Items as $i)
+ {
+ if($i->heading==$heading)
+ array_push($res,$i);
+ }
+ return $res;
+ }
+}
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/kernel/include/config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.24
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (revision 5437)
@@ -0,0 +1,563 @@
+<?php
+
+k4_include_once(KERNEL_PATH.'/parser/tags.php');
+k4_include_once(KERNEL_PATH.'/parser/construct_tags.php');
+
+class TemplateParser extends kBase {
+ var $Template;
+ var $Output = '';
+ var $Position = 0;
+ var $LastPosition = 0;
+
+ var $Ses;
+ var $Recursion = Array();
+ var $RecursionIndex = 0;
+ var $SkipMode = 0;
+ var $Params = Array();
+ var $Pattern = Array();
+ var $ForSort = Array();
+ var $Values = Array();
+ var $Buffers = Array();
+ var $Args;
+
+ var $ParamsRecursionIndex = 0;
+ var $ParamsStack = Array();
+
+ var $CompiledBuffer;
+
+ var $DataExists = false;
+
+ function TemplateParser()
+ {
+ parent::kBase();
+ $this->Ses =& $this->Application->recallObject('Session');
+ }
+
+ function AddParam($pattern, $value, $dont_sort=0)
+ {
+ $this->ForSort[] = Array($pattern, $value);
+ if (!$dont_sort) //used when mass-adding params, to escape sorting after every new param
+ $this->SortParams(); //but do sort by default!
+ }
+
+ //We need to sort params by its name length desc, so that params starting with same word get parsed correctly
+ function SortParams()
+ {
+ uasort($this->ForSort, array ("TemplateParser", "CmpParams"));
+ $this->Pattern = Array();
+ $this->Values = Array();
+ foreach($this->ForSort as $pair)
+ {
+ $this->Pattern[] = $pair[0];
+ $this->Values[] = $pair[1];
+ }
+ }
+
+ function CmpParams($a, $b)
+ {
+ $a_len = strlen($a[0]);
+ $b_len = strlen($b[0]);
+ if ($a_len == $b_len) return 0;
+ return $a_len > $b_len ? -1 : 1;
+ }
+
+ function SetParams($params)
+ {
+ if (!is_array($params)) $params = Array();
+
+ $this->ForSort = array();
+ $this->Params = $params;
+ $this->ParamsStack[$this->ParamsRecursionIndex] = $params;
+
+ foreach ($params as $key => $val) {
+ $this->AddParam('/[{]{0,1}\$'.$key.'[}]{0,1}/i', $val, 1); //Do not sort every time
+ }
+ $this->SortParams(); //Sort once after adding is done
+ }
+
+ function GetParam($name)
+ {
+ //return isset($this->Params[strtolower($name)]) ? $this->Params[strtolower($name)] : false;
+ return isset($this->Params[$name]) ? $this->Params[$name] : false;
+ }
+
+ /**
+ * Set's template parser parameter, that could be retrieved from template
+ *
+ * @param string $name
+ * @param mixed $value
+ */
+ function SetParam($name, $value)
+ {
+ $this->Params[strtolower($name)] = $value;
+ $this->AddParam('/[{]{0,1}\$'.$name.'[}]{0,1}/i', $val, 0);
+ }
+
+ function SetBuffer($body)
+ {
+ $this->Buffers[$this->RecursionIndex] = $body;
+ }
+
+ function GetBuffer()
+ {
+ return $this->Buffers[$this->RecursionIndex];
+ }
+
+ function GetCode()
+ {
+ return $this->Code[$this->RecursionIndex];
+ }
+
+ function AppendBuffer($append)
+ {
+ $this->Buffers[$this->RecursionIndex] .= $append;
+ $this->AppendCode( $this->ConvertToCode($append) );
+ }
+
+ function AppendOutput($append, $append_code=false)
+ {
+ if ($this->SkipMode == parse) {
+ $this->Output .= $append; //append to Ouput only if we are parsing
+ if ($append_code) $this->AppendCompiledHTML($append);
+ }
+ elseif ($this->SkipMode == skip) {
+ if ($append_code) $this->AppendCompiledHTML($append);
+ }
+ elseif ($this->SkipMode == skip_tags) {
+ $this->AppendBuffer($append); //append to buffer if we are skipping tags
+ }
+ }
+
+ function ConvertToCode($data)
+ {
+ $code = '$o .= \''. str_replace("'", "\'", $data) .'\';';
+ $code = explode("\n", $code);
+ return $code;
+ }
+
+ function AppendCode($code)
+ {
+ if (defined('EXPERIMENTAL_PRE_PARSE')) {
+ if (!isset($this->Code[$this->RecursionIndex])) {
+ $this->Code[$this->RecursionIndex] = Array();
+ }
+ if (is_array($code)) {
+ foreach ($code as $line) {
+ $this->Code[$this->RecursionIndex][] = rtrim($line, "\n")."\n";
+ }
+ }
+ else {
+ $this->Code[$this->RecursionIndex][] .= rtrim($code, "\n")."\n";
+ }
+ }
+ }
+
+ function AppendCompiledFunction($f_name, $f_body)
+ {
+ $real_name = 'f_'.abs(crc32($this->TemplateName)).'_'.$f_name;
+ if (defined('EXPERIMENTAL_PRE_PARSE')) {
+ // if such function already compiled
+ if ( isset($this->Application->CompiledFunctions[$f_name]) ||
+ function_exists($real_name)
+ )
+ {
+ if (!isset($this->Application->CompiledFunctions[$f_name])) {
+ $real_name = $real_name.'_';
+ }
+ else {
+ $real_name = $this->Application->CompiledFunctions[$f_name].'_';
+ }
+ }
+
+ $this->CompiledBuffer .= 'if (!function_exists(\''.$real_name.'\')) {'."\n";
+
+
+ $this->CompiledBuffer .= "\t".'$application->PreParsedBlocks[\''.$f_name.'\'] = \''.$real_name.'\';';
+ $this->CompiledBuffer .= "\n\t".'function '.$real_name.'($params)'."\n\t{\n";
+ $this->CompiledBuffer .= $f_body;
+ $this->CompiledBuffer .= "\t}\n\n";
+
+ $this->CompiledBuffer .= '}'."\n";
+
+ $this->Application->CompiledFunctions[$f_name] = $real_name;
+
+ }
+ }
+
+ function AppendCompiledCode($code)
+ {
+ if (defined('EXPERIMENTAL_PRE_PARSE')) {
+ if (is_array($code)) {
+ foreach ($code as $line) {
+ $this->CompiledBuffer .= "\t".rtrim($line, "\n")."\n";
+ }
+ }
+ else {
+ $this->CompiledBuffer .= $code;
+ }
+ $this->CompiledBuffer .= "\t".'echo $o;'."\n\t".'$o = \'\';'."\n";
+ }
+ }
+
+ function AppendCompiledHTML($append)
+ {
+ if (defined('EXPERIMENTAL_PRE_PARSE')) {
+ $this->CompiledBuffer .= '?'.'>'."\n";
+ $this->CompiledBuffer .= rtrim($append, "\t");
+ $this->CompiledBuffer .= '<'.'?php'."\n";
+ }
+ }
+
+ function ResetCode()
+ {
+ $this->Code[$this->RecursionIndex] = Array();
+ }
+
+ function FindTag2()
+ {
+ $openings = Array('<%' => '%>', '<inp2:' => Array('>', '/>'), '</inp2:' => '>', '</inp2>' => '', '<!--' => '-->');
+
+ $tag_open_pos = false;
+ foreach ($openings as $an_opening => $closings) {
+ $pos = strpos($this->Template, $an_opening, $this->Position);
+ if ($pos !== false && ($tag_open_pos === false || (int) $pos <= (int) $tag_open_pos)) {
+ $tag_open_pos = $pos;
+ $open_len = strlen($an_opening);
+ $opening_tag = $an_opening;
+ $tag_closings = $closings;
+ }
+ }
+
+ if ($tag_open_pos === false) { //If no tags left - adding all other data
+ $this->AppendOutput(substr($this->Template, $this->Position), true);
+ return false;
+ }
+
+ //Adding all data before tag open
+ $this->AppendOutput(substr($this->Template, $this->Position, $tag_open_pos - $this->Position), true);
+
+ if (is_array($tag_closings)) {
+ $tag_close_pos = false;
+ foreach ($tag_closings as $a_closing) {
+ $pos = strpos($this->Template, $a_closing, $tag_open_pos);
+ if ($pos !== false && ($tag_close_pos === false || (int) $pos <= (int) $tag_close_pos)) {
+ $tag_close_pos = $pos;
+ $closing_tag = $a_closing;
+ }
+ }
+ }
+ elseif ($opening_tag == '</inp2>') {
+ $closing_tag = '';
+ $tag_close_pos = $tag_open_pos + $open_len;
+ }
+ else {
+ $closing_tag = $tag_closings;
+ $tag_close_pos = strpos($this->Template, $closing_tag, $tag_open_pos);
+ }
+ $close_len = strlen($closing_tag);
+
+ //Cutting out the tag itself
+ $tag = substr($this->Template, $tag_open_pos + $open_len, $tag_close_pos - $tag_open_pos - $open_len);
+
+
+ if ($opening_tag == '<inp2:') {
+ //getting prefix_tag upto first space, tab or line break into regs[1]
+ preg_match("/^([^ \t\n]*)(.*)/", $tag, $regs);
+ $tag_part = $regs[1];
+
+ if (strpos($tag_part, '_') !== false) {
+ list($prefix, $the_tag) = explode('_', $tag, 2);
+ /*preg_match('/(.*)_(.*)/', $tag_part, $rets);
+ $prefix = $rets[1];
+ $the_tag = $rets[2].$regs[2];*/
+
+ $tag = $prefix.':'.$the_tag;
+ }
+ else {
+ $the_tag = $tag;
+ $tag = ':'.$tag;
+ }
+ }
+
+ if ($opening_tag == '</inp2>') { //empty closing means old style in-portal if <inp2:tag>....</inp2>
+ $tag = 'm:endif';
+ }
+
+ if ($opening_tag == '</inp2:') {
+ preg_match("/^([^ \t\n]*)(.*)/", $tag, $regs);
+ $tag_part = $regs[1];
+ if (strpos($tag_part, '_') !== false) {
+ list($prefix, $the_tag) = explode('_', $tag, 2);
+ $tag = $prefix.':'.$the_tag;
+ }
+ $tag .= ' _closing_tag_="1"';
+ }
+
+ // if there is no prefix for the tag
+ if (strpos($tag, ':') === 0) {
+ $prefix = getArrayValue($this->Params, 'PrefixSpecial');
+ $tag = $prefix.$tag;
+ }
+
+ // temporary - for backward compatability with in-portal style if
+ if ($opening_tag == '<inp2:' && $closing_tag == '>' && $tag_part != 'm_if' && $tag_part != 'm_DefineElement') {
+ if (strpos($the_tag, ' ') !== false) {
+ list($function, $params) = explode(' ', $the_tag, 2);
+ }
+ else {
+ $function = $the_tag;
+ $params = '';
+ }
+ $tag = 'm:if prefix="'.$prefix.'" function="'.$function.'" '.$params;
+ }
+
+ if ($opening_tag == '<!--') {
+ $this->AppendOutput('<!-- '.$tag. '-->');
+ $tag = '__COMMENT__';
+ }
+
+ $this->Position = $tag_close_pos + $close_len;
+ return $tag;
+ }
+
+ function CurrentLineNumber()
+ {
+ return substr_count(substr($this->Template, 0, $this->Position), "\n")+1;
+ }
+
+ function SkipModeName()
+ {
+ switch ($this->SkipMode) {
+ case skip: return 'skip';
+ case skip_tags: return 'skip_tags';
+ case parse: return 'parse';
+ }
+ }
+
+ function CheckDir($dir)
+ {
+ if (file_exists($dir)) {
+ return;
+ }
+ else {
+ $segments = explode('/', $dir);
+ $cur_path = '';
+ foreach ($segments as $segment) {
+ // do not add leading / for windows paths (c:\...)
+ $cur_path .= preg_match('/^[a-zA-Z]{1}:/', $segment) ? $segment : '/'.$segment;
+ if (!file_exists($cur_path)) {
+ mkdir($cur_path);
+ }
+ }
+ }
+ }
+
+ function Parse($template, $name='unknown', $pre_parse = 1)
+ {
+ $this->Template = $template;
+ $this->TemplateName = $name;
+ $this->Position = 0;
+ $this->Output = '';
+ $this->TagHolder = new MyTagHolder();
+
+ $has_inp_tags = false;
+
+ if ($this->GetParam('from_inportal')) $pre_parse = 0;
+
+ if (defined('EXPERIMENTAL_PRE_PARSE') && $pre_parse) {
+ $template_cache =& $this->Application->recallObject('TemplatesCache');
+ $fname = $template_cache->GetRealFilename($this->TemplateName).'.php';
+
+ $fname = str_replace(FULL_PATH, FULL_PATH.'/kernel/cache', $fname);
+
+ if (!defined('SAFE_MODE') || !SAFE_MODE) {
+ $this->CheckDir(dirname($fname));
+ }
+
+ $tname = $template_cache->GetRealFilename($this->TemplateName).'.tpl';
+ $output = '';
+ $is_cached = false;
+ ob_start();
+ if (defined('SAFE_MODE') && SAFE_MODE) {
+ $conn =& $this->Application->GetADODBConnection();
+ $cached = $conn->GetRow('SELECT * FROM '.TABLE_PREFIX.'Cache WHERE VarName = "'.$fname.'"');
+ if ($cached !== false && $cached['Cached'] > filemtime($tname)) {
+ eval('?'.'>'.$cached['Data']);
+ $is_cached = true;
+ }
+ }
+ else {
+ if (file_exists($fname) && file_exists($tname) && filemtime($fname) > filemtime($tname)) {
+ include($fname);
+ $is_cached = true;
+ }
+ }
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ if ( $is_cached && !$this->GetParam('from_inportal') ) {
+ if ( strpos($output, '<inp:') !== false) {
+ $inp1_parser =& $this->Application->recallObject('Inp1Parser');
+ $output = $inp1_parser->Parse($name, $output);
+ }
+ return $output;
+ }
+
+ $this->CompiledBuffer .= '<'.'?php'."\n";
+ $this->CompiledBuffer .= 'global $application;'."\n";
+
+ $this->CompiledBuffer .= '$params =& $application->Parser->Params;'."\n";
+ $this->CompiledBuffer .= 'extract($params);'."\n";
+
+ $this->CompiledBuffer .= '$o = \'\';'."\n";
+ }
+
+ if (!getArrayValue($this->Params, 'PrefixSpecial')) {
+ $this->Params['PrefixSpecial'] = '$PrefixSpecial';
+ }
+
+ //While we have more tags
+ while ($tag_data = $this->FindTag2())
+ {
+ if ($tag_data == '__COMMENT__') continue;
+ //Create tag object from passed tag data
+ if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
+ {
+ global $debugger;
+ $debugger->appendHTML('mode: '.$this->SkipModeName().' tag '.$debugger->highlightString($tag_data).' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
+ }
+// $tag =& new MyTag($tag_data, $this);
+ $tag =& $this->TagHolder->GetTag($tag_data, $this);
+
+ if (!$this->CheckRecursion($tag)) //we do NOT process closing tags
+ {
+ $tag->Process();
+ }
+ }
+
+ if ( !$this->GetParam('from_inportal') ) {
+ if ( strpos($this->Output, '<inp:') !== false) {
+ $inp1_parser =& $this->Application->recallObject('Inp1Parser');
+ $this->Output = $inp1_parser->Parse($name, $this->Output);
+ $has_inp_tags = true;
+ }
+ }
+
+
+ if (defined('EXPERIMENTAL_PRE_PARSE') && $pre_parse && !$has_inp_tags) {
+// $this->CompiledBuffer .= 'echo $o;'."\n";
+ $this->CompiledBuffer .= '?'.'>'."\n";
+
+ if (defined('SAFE_MODE') && SAFE_MODE) {
+ if (!isset($conn)) $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('REPLACE INTO '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ('.$conn->qstr($fname).','.$conn->qstr($this->CompiledBuffer).','.adodb_mktime().')');
+ }
+ else {
+ $compiled = fopen($fname, 'w');
+ fwrite($compiled, $this->CompiledBuffer);
+ fclose($compiled);
+ }
+ }
+
+ return $this->Output;
+ }
+
+ function ParseBlock($params, $force_pass_params=0, $as_template=false)
+ {
+ if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
+ {
+ global $debugger;
+ $debugger->appendHTML('ParseBlock '.$params['name'].' pass_params is '.$params['pass_params'].' force is '.$force_pass_params.' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
+
+ }
+ /*if ( $this->Application->isDebugMode() && constOn('DBG_PRE_PARSE') ) {
+ global $debugger;
+ $debugger->CurrentPreParsedBlock = $params['name'];
+ }*/
+ if (defined('EXPERIMENTAL_PRE_PARSE')) {
+ $this->MainParser = false;
+ if (isset($this->Application->PreParsedBlocks[$params['name']]) ) {
+
+ if ($this->ParamsRecursionIndex == 0) {
+ $this->ParamsStack[$this->ParamsRecursionIndex] = $this->Params;
+ }
+
+ if (isset($params['pass_params']) || $force_pass_params) {
+ $pass_params = array_merge($this->ParamsStack[$this->ParamsRecursionIndex], $params);
+ }
+ else {
+ $pass_params = $params;
+ }
+
+ $this->ParamsStack[++$this->ParamsRecursionIndex] = $pass_params;
+ $this->Params = $pass_params;
+
+ $f = $this->Application->PreParsedBlocks[$params['name']];
+
+// $this->ParamsRecursionIndex--;
+
+ //$this->SetParams($params);
+ if( !isset($pass_params['PrefixSpecial']) && isset($pass_params['prefix']) ) $pass_params['PrefixSpecial'] = $pass_params['prefix'];
+
+ $ret = $f($pass_params);
+
+ unset($this->ParamsStack[$this->ParamsRecursionIndex--]);
+ $this->Params = $this->ParamsStack[$this->ParamsRecursionIndex];
+ $this->MainParser = true;
+ return $ret;
+ }
+ }
+
+ $BlockParser =& $this->Application->makeClass('TemplateParser');
+ if (isset($params['pass_params']) || $force_pass_params) {
+ $BlockParser->SetParams(array_merge($this->Params, $params));
+ }
+ else
+ $BlockParser->SetParams($params);
+ $this->Application->Parser =& $BlockParser;
+ if (!isset($params['name'])) trigger_error('<b>***Error: Block name not passed to ParseBlock</b>', E_USER_ERROR);
+ $templates_cache =& $this->Application->recallObject('TemplatesCache');
+
+ $template_name = $as_template ? $params['name'] : $templates_cache->GetTemplateFileName($params['name']) . '-block:'.$params['name'];
+
+ $silent = getArrayValue($params, 'from_inportal') && !defined('DBG_TEMPLATE_FAILURE');
+
+ $o = $BlockParser->Parse(
+ $templates_cache->GetTemplateBody($params['name'], $silent),
+ $template_name
+ );
+ if (getArrayValue($params, 'BlockNoData') && !$BlockParser->DataExists) {
+ $template_name = $as_template ? $params['BlockNoData'] : $templates_cache->GetTemplateFileName($params['BlockNoData']) . '-block:'.$params['BlockNoData'];
+ $o = $BlockParser->Parse(
+ $templates_cache->GetTemplateBody($params['BlockNoData'], $silent),
+ $template_name
+ );
+ }
+ $this->Application->Parser =& $this;
+ $this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
+ return $o;
+ }
+
+ function Recurve(&$tag)
+ {
+ $this->Recursion[++$this->RecursionIndex] =& $tag;
+ }
+
+ function CheckRecursion(&$tag)
+ {
+ if ($this->RecursionIndex > 0) { //If we are inside the recursion
+ if ($this->Recursion[$this->RecursionIndex]->CheckRecursion($tag)) { //If we can close this recursion
+ unset($this->Recursion[$this->RecursionIndex--]); //unsetting current recursion level and decreasing it at the same time
+ return true; //we should inform not to process closing tag
+ }
+ }
+ return false;
+ }
+
+ function SetSkipMode($mode)
+ {
+ $this->SkipMode = $mode;
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.24
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php (revision 5437)
@@ -0,0 +1,379 @@
+<?php
+
+ class AdminTagProcessor extends kDBTagProcessor {
+
+ function SetConst($params)
+ {
+ $name = $this->SelectParam($params, 'name,const');
+ safeDefine($name, $params['value']);
+ }
+
+ /**
+ * Allows to execute js script after the page is fully loaded
+ *
+ * @param Array $params
+ * @return string
+ */
+ function AfterScript($params)
+ {
+ $after_script = $this->Application->GetVar('after_script');
+ if ($after_script) {
+ return '<script type="text/javascript">'.$after_script.'</script>';
+ }
+ return '';
+ }
+
+ /**
+ * Returns section title with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionTitle($params)
+ {
+ $params['name'] = replaceModuleSection($params['phrase']);
+ return $this->Application->ProcessParsedTag('m', 'Phrase', $params);
+ }
+
+ /**
+ * Returns section icon with #section# keyword replaced with current section
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetSectionIcon($params)
+ {
+ return replaceModuleSection($params['icon']);
+ }
+
+ /**
+ * Allows to detect if current template is one of listed ones
+ *
+ * @param Array $params
+ * @return int
+ */
+ function TemplateMatches($params)
+ {
+ $templates = explode(',' ,$params['templates']);
+ $t = $this->Application->GetVar('t');
+ return in_array($t, $templates) ? 1 : 0;
+ }
+
+ /**
+ * Save return script in cases, when old sections are opened from new sections
+ *
+ * @param Array $params
+ */
+ function SaveReturnScript($params)
+ {
+ // admin/save_redirect.php?do=
+ $url = str_replace($this->Application->BaseURL(), '', $this->Application->ProcessParsedTag('m', 'Link', $params) );
+ $url = explode('?', $url, 2);
+ $url = 'save_redirect.php?'.$url[1].'&do='.$url[0];
+
+ $this->Application->StoreVar('ReturnScript', $url);
+ }
+
+ /**
+ * Redirects to correct next import step template based on import script data
+ *
+ * @param Array $params
+ */
+ function ImportRedirect($params)
+ {
+ $import_id = $this->Application->GetVar('import_id');
+ if ($import_id) {
+ // redirect forward to step3 (import parameters coosing)
+ $this->Application->StoreVar('ImportScriptID', $import_id);
+
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'ImportScripts
+ WHERE is_id = '.$import_id;
+
+ $db =& $this->Application->GetADODBConnection();
+ $is_params = $db->GetRow($sql);
+
+ if ($is_params['is_type'] == 'db') {
+ $this->Application->Redirect('', null, '', 'import/step3.php');
+ }
+ elseif ($is_params['is_type'] == 'csv') {
+ $module = strtolower($is_params['is_Module']);
+ $template = $module.'/import';
+ $module_info = $this->Application->findModule('Name', $module);
+
+ $item_prefix = $module_info['Var'];
+ $pass_params = Array('m_opener' => 'd', $item_prefix.'.import_id' => 0, $item_prefix.'.import_event' => 'OnNew', 'pass' => 'm,'.$item_prefix.'.import', 'm_cat_id' => $module_info['RootCat']);
+
+ $this->Application->Redirect($template, $pass_params);
+ }
+ }
+ else {
+ // redirect back to step2 (import type choosing)
+ $this->Application->Redirect('', null, '', 'import/step2.php');
+ }
+ }
+
+ /**
+ * Returns version of module by name
+ *
+ * @param Array $params
+ * @return string
+ */
+ function ModuleVersion($params)
+ {
+ return $this->Application->findModule('Name', $params['module'], 'Version');
+ }
+
+ /**
+ * Used in table form section drawing
+ *
+ * @param Array $params
+ * @return string
+ */
+ function DrawTree($params)
+ {
+ static $deep_level = 0;
+
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+ $params['deep_level'] = $deep_level++;
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ if (!isset($section_data['children'])) {
+ return $ret;
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $ret .= $this->DrawTree($params);
+ $deep_level--;
+ }
+
+
+ return $ret;
+ }
+
+
+ function PrintSection($params)
+ {
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ $params['section_name'] = $section_name;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+ $ret = $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+
+ return $ret;
+ }
+
+ /**
+ * Used in XML drawing for tree
+ *
+ * @param Array $params
+ * @return string
+ */
+ function PrintSections($params)
+ {
+ // when processings, then sort children by priority (key of children array)
+ $ret = '';
+ $section_name = $params['section_name'];
+ if ($section_name == '#session#') {
+ $section_name = $this->Application->RecallVar('section');
+ }
+
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $params['name'] = $this->SelectParam($params, 'name,render_as,block');
+ if (!isset($section_data['children'])) {
+ return '';
+ }
+
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $section_name) {
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ if (isset($section_data['tabs_only']) && $section_data['tabs_only']) {
+ $perm_status = false;
+ $folder_label = $section_data['label'];
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+ $perm_status = $this->Application->CheckPermission($section_name.'.view', 1);
+ if ($perm_status) {
+ break;
+ }
+ }
+ if (!$perm_status) {
+ // no permission for all tabs -> don't display tree node either
+ continue;
+ }
+
+ $params['section_name'] = $section_name;
+ $section_data =& $sections_helper->getSectionData($section_name);
+ $section_data['label'] = $folder_label; // use folder label in tree
+ $section_data['is_tab'] = 1;
+ }
+ elseif (!$this->Application->CheckPermission($section_name.'.view', 1)) {
+ continue;
+ }
+
+ $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0;
+
+ $template = $section_data['url']['t'];
+ unset($section_data['url']['t']);
+
+ $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']);
+
+ $late_load = getArrayValue($section_data, 'late_load');
+ if ($late_load) {
+ $t = $late_load['t'];
+ unset($late_load['t']);
+ $section_data['late_load'] = $this->Application->HREF($t, '', $late_load);
+ $params['children_count'] = 99;
+ }
+ else {
+ $section_data['late_load'] = '';
+ }
+
+ $ret .= $this->Application->ParseBlock( array_merge_recursive2($params, $section_data) );
+ $params['section_name'] = $section_name;
+ }
+
+ return preg_replace("/\r\n|\n/", '', $ret);
+ }
+
+ function ListSectionPermissions($params)
+ {
+ $section_name = isset($params['section_name']) ? $params['section_name'] : $this->Application->GetVar('section_name');
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($section_name);
+
+ $block_params = array_merge_recursive2($section_data, Array('name' => $params['render_as'], 'section_name' => $section_name));
+
+ $ret = '';
+ foreach ($section_data['permissions'] as $perm_name) {
+ if (preg_match('/^advanced:(.*)/', $perm_name) != $params['type']) continue;
+ $block_params['perm_name'] = $perm_name;
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+ return $ret;
+ }
+
+ function ModuleInclude($params)
+ {
+ foreach ($params as $param_name => $param_value) {
+ $params[$param_name] = replaceModuleSection($param_value);
+ }
+
+ return $this->Application->ProcessParsedTag('m', 'ModuleInclude', $params);
+ }
+
+ function TodayDate($params)
+ {
+ return date($params['format']);
+ }
+
+ function TreeEditWarrning($params)
+ {
+ $ret = $this->Application->Phrase($params['label']);
+ $ret = str_replace(Array('&lt;', '&gt;', 'br/', 'br /', "\n", "\r"), Array('<', '>', 'br', 'br', '', ''), $ret);
+ if (getArrayValue($params, 'escape')) {
+ $ret = addslashes($ret);
+ }
+ $ret = str_replace('<br>', '\n', $ret);
+ return $ret;
+ }
+
+ /**
+ * Draws section tabs using block name passed
+ *
+ * @param Array $params
+ */
+ function ListTabs($params)
+ {
+ $sections_helper =& $this->Application->recallObject('SectionsHelper');
+ $section_data =& $sections_helper->getSectionData($params['section_name']);
+
+ $ret = '';
+ $block_params = Array('name' => $params['render_as']);
+ ksort($section_data['children'], SORT_NUMERIC);
+ foreach ($section_data['children'] as $priority => $section_name) {
+ if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue;
+
+ $tab_data =& $sections_helper->getSectionData($section_name);
+ $block_params['t'] = $tab_data['url']['t'];
+ $block_params['title'] = $tab_data['label'];
+ $block_params['main_prefix'] = $section_data['SectionPrefix'];
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+
+
+ return $ret;
+ }
+
+ /**
+ * Returns list of module item tabs that have view permission in current category
+ *
+ * @param Array $params
+ */
+ function ListCatalogTabs($params)
+ {
+ $ret = '';
+ $special = isset($params['special']) ? $params['special'] : '';
+ $skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array();
+ $block_params = Array('name' => $params['render_as']);
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ $prefix = $module_info['Var'];
+ if (in_array($prefix, $skip_prefixes)) continue;
+ $label = $this->Application->getUnitOption($prefix, $params['title_property']);
+ $block_params['title'] = $label;
+ $block_params['prefix'] = $prefix;
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+ return $ret;
+ }
+
+ function FCKEditor($params)
+ {
+ include_once(FULL_PATH.'/admin/editor/cmseditor/fckeditor.php');
+ $oFCKeditor = new FCKeditor($params['name']);
+ $oFCKeditor->BasePath = BASE_PATH.'/admin/editor/cmseditor/';
+ $oFCKeditor->Width = $params['width'] ;
+ $oFCKeditor->Height = $params['height'] ;
+ $oFCKeditor->ToolbarSet = 'Advanced' ;
+ $oFCKeditor->Value = '' ;
+ $oFCKeditor->Config = Array(
+ //'UserFilesPath' => $pathtoroot.'kernel/user_files',
+ 'ProjectPath' => BASE_PATH.'/',
+ 'CustomConfigurationsPath' => $this->Application->BaseURL().'admin/editor/inp_fckconfig.js',
+ 'EditorAreaCSS' => $this->Application->BaseURL().'/themes/inportal_site/inc/inportal.css', //GetThemeCSS(),
+ //'StylesXmlPath' => '../../inp_styles.xml',
+// 'Debug' => 1,
+ 'Admin' => 1,
+ );
+ return $oFCKeditor->CreateHtml();
+
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/core/units/admin/admin_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.24
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.24.2/core/units/email_events/email_events_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/core/units/email_events/email_events_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.24.2/core/units/email_events/email_events_event_handler.php (revision 5437)
@@ -0,0 +1,270 @@
+<?php
+
+ class EmailEventsEventsHandler extends InpDBEventHandler
+ {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnFrontOnly' => Array('self' => 'edit'),
+ 'OnSaveSelected' => Array('self' => 'view'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Changes permission section to one from REQUEST, not from config
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ $module = $this->Application->GetVar('module');
+ $module = explode(':', $module, 2);
+
+ if (count($module) == 1) {
+ $main_prefix = $this->Application->findModule('Name', $module[0], 'Var');
+ }
+ else {
+ $exceptions = Array('Category' => 'c', 'Users' => 'u');
+ $main_prefix = $exceptions[ $module[1] ];
+ }
+ $section = $this->Application->getUnitOption($main_prefix.'.email', 'PermSection');
+
+ $event->setEventParam('PermSection', $section);
+ return parent::CheckPermission($event);
+ }
+
+ /**
+ * Apply any custom changes to list's sql query
+ *
+ * @param kEvent $event
+ * @access protected
+ * @see OnListBuild
+ */
+ function SetCustomQuery(&$event)
+ {
+ if ($event->Special == 'module') {
+ $object =& $event->getObject();
+ $module = $this->Application->GetVar('module');
+ $object->addFilter('module_filter', '%1$s.Module = '.$this->Conn->qstr($module));
+ }
+ }
+
+ /**
+ * Sets status Front-End Only to selected email events
+ *
+ * @param kEvent $event
+ */
+ function OnFrontOnly(&$event)
+ {
+ $ids = implode(',', $this->StoreSelectedIDs($event));
+
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'UPDATE '.$table_name.'
+ SET Enabled = 2
+ WHERE EventId IN ('.$ids.')';
+ $this->Conn->Query($sql);
+ }
+
+ /**
+ * Sets selected user to email events selected
+ *
+ * @param kEvent $event
+ */
+ function OnSelectUser(&$event)
+ {
+ $items_info = $this->Application->GetVar('u');
+ if ($items_info) {
+ $user_id = array_shift( array_keys($items_info) );
+
+ $ids = $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids');
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'UPDATE '.$table_name.'
+ SET '.$this->Application->RecallVar('dst_field').' = '.$user_id.'
+ WHERE '.$id_field.' IN ('.$ids.')';
+ $this->Conn->Query($sql);
+ }
+
+ $this->finalizePopup($event);
+ }
+
+ /**
+ * Saves selected ids to session
+ *
+ * @param kEvent $event
+ */
+ function OnSaveSelected(&$event)
+ {
+ $this->StoreSelectedIDs($event);
+ }
+
+ /**
+ * Raised when email message shoul be sent
+ *
+ * @param kEvent $event
+ */
+ function OnEmailEvent(&$event){
+
+ $email_event = $event->getEventParam('EmailEventName');
+ if( strpos($email_event, '_') !== false )
+ {
+ trigger_error('<span class="debug_error">Invalid email event name</span> <b>'.$email_event.'</b>. Use only <b>UPPERCASE characters</b> and <b>dots</b> as email event names', E_USER_ERROR);
+ }
+
+ $to_user_id = $event->getEventParam('EmailEventToUserId');
+ $email_event_type = $event->getEventParam('EmailEventType');
+
+ $message_object = &$this->Application->recallObject('emailmessages', null, Array('skip_autoload' => true));
+ $event_table = $this->Application->getUnitOption('emailevents', 'TableName');
+
+ $event_object = &$event->getObject();
+ $event_object->Load(array('Event'=>$email_event, 'Type'=>$email_event_type));
+
+ $event_id = $event_object->GetDBField('EventId');
+ $from_user_id = $event_object->GetDBField('FromUserId');
+ $type = $event_object->GetDBField('Type');
+ $enabled = $event_object->GetDBField('Enabled');
+
+ $direct_send_params = $event->getEventParam('DirectSendParams');
+
+ if ($enabled == 0) return; // disabled event
+ if ($enabled == 2 && $this->Application->IsAdmin() ) return; // event only for front-end
+
+ if ($type == 1){
+ // For type "Admin" recipient is a user from field FromUserId which means From/To user in Email events list
+ $to_user_id = $from_user_id;
+ $from_user_id = -1;
+ }
+ /*
+ if (!($to_user_id > 0) && !$direct_send_params){
+ // if we can not determine recepient we will not send email
+ return;
+ }
+ */
+ //Parse Message Template
+ $message_object->Load(array('EventId' => $event_id, 'LanguageId' => $this->Application->GetVar('m_lang')));
+ $message_type = $message_object->GetDBField('MessageType');
+
+ $email_object = &$this->Application->recallObject('kEmailMessage');
+ $email_object->Clear();
+
+ // add footer: begin
+ $sql = 'SELECT em.Template
+ FROM '.$message_object->TableName.' em
+ LEFT JOIN '.TABLE_PREFIX.'Events e ON e.EventId = em.EventId
+ WHERE em.LanguageId = '.$message_object->GetDBField('LanguageId').' AND e.Event = "COMMON.FOOTER"';
+ $footer = explode("\n\n", $this->Conn->GetOne($sql));
+ $footer = $message_object->GetDBField('MessageType') == 'text' ? $email_object->convertHTMLtoPlain($footer[1]) : $footer[1];
+ $message_template = $message_object->GetDBField('Template')."\r\n".$footer;
+ // add footer: end
+
+ $from_user_object = &$this->Application->recallObject('u.-email'.$from_user_id, null, Array('skip_autoload' => true));
+ $from_user_object->Load($from_user_id);
+ // here if we don't have from_user loaded, it takes a default user from config values
+ if ( $from_user_object->IsLoaded() ) {
+ $from_user_email = $from_user_object->GetDBField('Email');
+ $from_user_name = trim($from_user_object->GetDBField('FirstName').' '.$from_user_object->GetDBField('LastName'));
+ }
+ else {
+ $from_user_email = $this->Application->ConfigValue('Smtp_AdminMailFrom');
+ }
+
+ $to_user_object = &$this->Application->recallObject('u.-email'.$to_user_id, null, Array('skip_autoload' => true));
+ $to_user_object->Load($to_user_id);
+ $to_user_email = $to_user_object->GetDBField('Email');
+ $to_user_name = trim($to_user_object->GetDBField('FirstName').' '.$to_user_object->GetDBField('LastName'));
+
+ if($direct_send_params){
+ $to_user_email = ( $direct_send_params['to_email'] ? $direct_send_params['to_email'] : $to_user_email );
+ $to_user_name = ( $direct_send_params['to_name'] ? $direct_send_params['to_name'] : $to_user_name );
+ $from_user_email = ( $direct_send_params['from_email'] ? $direct_send_params['from_email'] : $from_user_email);
+ $from_user_name = ( $direct_send_params['from_name'] ? $direct_send_params['from_name'] : $from_user_name );
+ $message_body_additional = $direct_send_params['message'];
+ }
+
+ $to_user_email = $to_user_email ? $to_user_email : $this->Application->ConfigValue('Smtp_AdminMailFrom');
+
+ $this->Application->makeClass('Template');
+ $this->Application->InitParser();
+ $parser_params = $this->Application->Parser->Params;
+ $direct_send_params['message_text'] = $message_body_additional;
+ $this->Application->Parser->Params = array_merge_recursive2($this->Application->Parser->Params, $direct_send_params);
+ $message_template = str_replace('<inp:touser _Field', '<inp2:u_Field name', $message_template);
+ $message_template = $this->Application->Parser->Parse($message_template, 'email_template', 0);
+ $this->Application->Parser->Params = $parser_params;
+
+ $message_template = str_replace("\r", "", $message_template);
+
+ list($message_headers, $message_body) = explode("\n\n", $message_template, 2);
+
+
+ $email_object->setFrom($from_user_email, $from_user_name);
+ $email_object->setTo($to_user_email, $to_user_name);
+ $email_object->setSubject('Mail message');
+
+
+ $email_object->setHeaders($message_headers);
+
+ if ($message_type == 'html'){
+ $email_object->setHTMLBody($message_body);
+ }
+ else {
+ $email_object->setTextBody($message_body);
+ }
+
+ $smtp_object = &$this->Application->recallObject('kSmtpClient');
+ $smtp_object->debug = $this->Application->isDebugMode() && constOn('DBG_SMTP');
+
+ $smtp_server = $this->Application->ConfigValue('Smtp_Server');
+ $smtp_port = $this->Application->ConfigValue('Smtp_Port');
+
+ $smtp_authenticate = $this->Application->ConfigValue('Smtp_Authenticate');
+ if ($smtp_authenticate){
+ $smtp_user = $this->Application->ConfigValue('Smtp_User');
+ $smtp_pass = $this->Application->ConfigValue('Smtp_Pass');
+ }else{
+ $smtp_user = '';
+ $smtp_pass = '';
+ }
+
+
+ if ($smtp_server){
+ if ($email_object->sendSMTP($smtp_object, $smtp_server, $smtp_user, $smtp_pass, $smtp_authenticate)){
+ $event->status=erSUCCESS;
+ }
+ else {
+ $event->status=erFAIL;
+ }
+ }else{
+ if($email_object->send()){
+ $event->status=erSUCCESS;
+ }
+ else {
+ $event->status=erFAIL;
+ }
+ }
+
+ if ($event->status == erSUCCESS){
+ if (!$from_user_name) {
+ $from_user_name = strip_tags( $this->Application->ConfigValue('Site_Name') );
+ }
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'EmailLog SET
+ fromuser = '.$this->Conn->qstr($from_user_name.' ('.$from_user_email.')').',
+ addressto = '.$this->Conn->qstr($to_user_name.' ('.$to_user_email.')').',
+ subject = '.$this->Conn->qstr($email_object->Subject).',
+ timestamp = UNIX_TIMESTAMP(),
+ event = '.$this->Conn->qstr($email_event);
+ $this->Conn->Query($sql);
+ }
+
+ return $event;
+ }
+ }
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/core/units/email_events/email_events_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.24
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline