Logo Search packages:      
Sourcecode: egroupware version File versions  Download package

mail_msg_wrappers::save_session_cache_item ( data_name = 'misc',
data,
acctnum = '',
extra_keys = '' 
)

folder_status_info appsession cached when using extreme-mode Data Param ARRIVES to this function like this folder_status_info $data param arrives into this function like this: $folder_status_info = $data; because folder_status_info has in it a fldball item we can use $folder_status_info[foldball] has the fldball data we can use that already provided

The "extra_keys" string is the extra KEY which is "FOLDER" where "FOLDER" is the "long" foldername, meaning it has the Namespace_Delimiter prefixing it. NOTE this is less info than some other data items use in their "extra_keys", other data may require extra_keys that is "FOLDER_UID" where UID is the message UID, but this data is for "folder_status_info" so no message UID is necessary, nor applicable, to this. That "extra_keys" string is used in the "location" param of the appsession to access this specific data which is part of a larger set of data, BUT we do not need to use sub array because that single KEY will let us directly access this data.

msg_structure and phpgw_header unique handling The theory is correct and still applied, but the sub-array style is OLD OLD OLD and has been changed to "extra_keys" in the "location" These 2 data items are cached ONLY IF this->session_cache_extreme IS TRUE. Notes on this data caching (see 4 notes, 2 in discussion and 2 in syntax): (1) Fetchstructure data can ONLY BE OBTAINED for the currently selected folder, so we automatically know which folder this data is applies to by calling get_arg_value("folder") HOWEVER in order to break free from this limitation in grabbing the data we are about to cache, ALWAYS pass a msgball WITH a folder value, even though it is obvious now, it may not be later. Note: folder name must be in urlencoded form, because it may contain "database unfriendly" chars This applies to "phpgw_header" data also. (Note: a msgball without a folder is *extremely* rare, and probably never occurs.) (2) "msg_structure" and "phpgw_header" caching scheme is UNUSUAL because it requires "extra_keys" param with BOTH folder AND message UID. You can provide such an "extra_keys" param BUT that is NOT necessary because we will make the "extra_keys" string here, using the data from the "msgball" element of the data structure, see "syntax" below for how you MUST pass data into this function to save this data type. (3) The "extra_keys" string is the extra KEY which is "FOLDER_UID" where "FOLDER" is the "long" foldername, meaning it has the Namespace_Delimiter prefixing it, and where "_" is an underscore char, and where "UID" is the msgnum UID that the mailserver has given the message. That "extra_keys" string is used in the "location" param of the appsession to access this specific data which is part of a larger set of data, BUT we do not need to use sub array because that single KEY will let us directly access this data.

(4) Data Param ARRIVES to this function like this msg_structure $data param arrives into this function like this: $data['msgball'] = $msgball; $data['msg_structure'] = $data;

phpgw_header $data param arrives into this function like this: $data['msgball'] = $msgball; $data['phpgw_header'] = $data;

Author:
Angles

Definition at line 3869 of file class.mail_msg_wrappers.inc.php.

References get_acctnum(), get_arg_value(), get_folder_status_info(), and mail_msg_base::prep_folder_out().

Referenced by get_folder_status_info(), get_msgball_list(), phpgw_fetchbody(), phpgw_fetchstructure(), and phpgw_header().

            {
                  if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): ENTERED, $this->session_cache_enabled='.serialize($this->session_cache_enabled).', $data_name: ['.$data_name.'], $acctnum (optional): ['.$acctnum.'], $extra_keys: ['.$extra_keys.']<br>'); }
                  $has_handler = False;
                  
                  if ((!isset($acctnum))
                  || ((string)$acctnum == ''))
                  {
                        $acctnum = $this->get_acctnum();
                  }
                  
                  if ($this->session_cache_enabled == False)
                  {
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, because $this->session_cache_enabled='.serialize($this->session_cache_enabled).', so not this basic stuff, and not the extra "extreme cache" stuff, nothing can use the appsession cache.<br>'); }
                        // LEAVING
                        return False;
                  }
                  // IF EMPTY DATA - LEAVE
                  if (!$data)
                  {
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with ERROR, no $data param was provided for $data_name ['.$data_name.'] $acctnum ['.$acctnum.'], we gotta return false because no data was saved<br>'); } 
                        // LEAVING
                        return False;
                  }
                  
                  if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): extra param (if provided) $extra_keys: ['.serialize($extra_keys).'] <br>'); } 
                  
                  // 1st -- session_cache_enabled stuff 
                  // this stuff is cached REGARDLESS of extreme mode, extreme mode is *extra* caching in addition to the "session_cache_enabled" stuff
                  // process the data according to what it is
                  if ($data_name == 'msgball_list')
                  {
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): session_cache_enabled and data exists AND $data_name ['.$data_name.'] has a handler<br>'); }
                        
                        // we damn well better have a msgball_list or else we have nothing to save
                        if ((isset($data['msgball_list']) == False)
                        || (!$data['msgball_list']))
                        {
                              $this->dbug->out('mail_msg: save_session_cache_item: LEAVING on ERROR, FIXME line '.__LINE__.' we have no msgball_list, sometimes caused when you ask call get_msgball_list on an empty folder, or if trying to use imap sockets<br>');
                              echo 'mail_msg: save_session_cache_item: LEAVING on ERROR, FIXME line '.__LINE__.' we have no msgball_list, check: is this an empty folder, is php_imap installed <br>';
                              // LEAVING ERROR
                              return False;
                        }
                        
                        // FIRST do a CACHE SANITY CHECK
                        // anglemail table is good for about 8,000 to 10,000 item msgball list
                        // while php4 sessions and sessions_db are good for much less than that
                        // if we put too much data into a store that can not handle it, we get an error on retieving that data
                        // which error will stop page view and because php has no excepion handler, we must avoid the error before it happens
                        $msgball_list_count = count($data['msgball_list']);
                        if 
                        (
                          (
                              (($this->use_private_table == True)
                              && ($msgball_list_count > 9000))
                          )
                         ||
                          (
                              (($this->use_private_table == False)
                              && ($msgball_list_count > 2000))
                          )
                        )
                        {
                              if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item: LEAVING on $msgball_list_count ['.$msgball_list_count.'] TOO LARGE, line '.__LINE__.' test indicates msgball_list too big for data store <br>'); }
                              // LEAVING ERROR
                              return False;
                        }
                        
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): $data_name ['.$data_name.'] is saved with validity data from "get_folder_status_info" for later staleness testing<br>'); }
                        
                        // NOTE 1: if you provide this 1 thing:
                        //    data['msgball_list'] 
                        // the rest will be filled in for you based on current folder and account (as determined above via acctnum param or the current acctnum arg)
                        
                        // NOTE 2: if you provide these 2 things
                        //    data['msgball_list'] 
                        //    data['validity']['fldball']
                        // the "folder_status_info" will be filled in for you SPECIFICALLY for that fldball EVEN IF it is not the current folder or account
                        
                        // NOTE 3: if you provide these 2 things
                        //    data['msgball_list'] 
                        //    data['validity']['folder_status_info']
                        // the "fldball" will be filled from your "folder_status_info" which has a fldball data in it
                        // a FOLDER_STATUS_INFO fldball PREVAILS, it overrules data['validity']['fldball'] 
                        
                        // NOTE 4: if you provide these 3 things
                        //    data['msgball_list'] 
                        //    data['validity']['fldball']
                        //    data['validity']['folder_status_info']
                        // then you have provided EVERYTHING we need
                        
                        // NOTE 5: NOW we also use folder as a data key, so each folder has its own msgball_list
                        // so later we will use this folder data for what is called $extra_keys, but it is just the folder name here
                        // update to make it easier to understand I call this $folder_name now
                        
                        // easy way is "note 1", at this point providing the other stuff is not needed for normal operation
                        // perhaps if you already have the other stuff and you know it has not changed ("folder_status_info" still good) 
                        // then *maybe* it might save some time passing "folder_status_info" you already have 
                        // if you have many accounts open and the "current account" is hard to discerrn, pass a fldball make sure everything will match
                        
                        // we need an acctnum, either 
                        //  (a) from the fldball, or 
                        //  (b) from the fldball in the "folder_status_info", or
                        // (c) what was passed as the acctnum (which itself is optional, then it will be the "current acctnum"
                        
                        // we use folder_info for validity testing of data "stale" or not when we retrieve the cached data later
                        // either data has INCLUDED with it a fldball or we make one based on current account info
                        if ((isset($data['validity']['folder_status_info']['fldball']['folder']) == True)
                        && ((string)$data['validity']['folder_status_info']['fldball']['folder'] != '')
                        && ((string)$data['validity']['folder_status_info']['fldball']['acctnum'] != ''))
                        {
                              // folder_status_info IF PROVIDED has PRIORITY of fldball and therefor PRIORITY of acctnum
                              $acctnum = $data['validity']['folder_status_info']['fldball']['acctnum'];
                              // make a fldball, ADD IT TO DATA
                              $data['validity']['fldball'] = array();
                              $data['validity']['fldball']['acctnum'] = $acctnum;
                              $data['validity']['fldball']['folder'] = $data['validity']['folder_status_info']['fldball']['folder'];
                        }
                        elseif ((isset($data['validity']['fldball']['folder']) == True)
                        && ((string)$data['validity']['fldball']['folder'] != '')
                        && ((string)$data['validity']['fldball']['acctnum'] != ''))
                        {
                              // the next place to look for acctnum is here
                              $acctnum = $data['validity']['fldball']['acctnum'];
                              // in this case WE CAN NOT RELY on folder_status_info if provided because it is not complete
                              if (isset($data['validity']['folder_status_info']) == True)
                              {
                                    $data['validity']['folder_status_info'] == array();
                                    unset($data['validity']['folder_status_info']);
                              }
                        }
                        else
                        {
                              // fallback: using genericly obtained acctnum, make a fldball and add it to DATA
                              $data['validity']['fldball'] = array();
                              $data['validity']['fldball']['acctnum'] = $acctnum;
                              $data['validity']['fldball']['folder'] = $this->prep_folder_out($this->get_arg_value('folder', $acctnum));
                              // just in case incomplete "folder_status_info" was passed, unset it
                              if (isset($data['validity']['folder_status_info']) == True)
                              {
                                    $data['validity']['folder_status_info'] == array();
                                    unset($data['validity']['folder_status_info']);
                              }
                        }
                        
                        // this is really for backwards compat right now
                        if (isset($data['validity']['folder_long']) == False)
                        {
                              $data['validity']['folder_long'] = $data['validity']['fldball']['folder'];
                        }
                        
                        // OK now we know we have a fldball, SO we know we have an ACCTNUM, from now on USE THAT ACCTNUM if calling other functions b4 we save this data
                        // $extra_keys if provided is enabling new stuff, it was not used before for msgball_list data
                        // IF it is provided (not yet used) it will probably be a folder name in urlencoded form, but NOT SURE YET
                        // we know what to do here, so this data "has a handler"
                        $has_handler = True;
                        
                        // either data has INCLUDED with it "folder_status_info" or we obtain it based on that fldball
                        if ((isset($data['validity']['folder_status_info']) == False)
                        || (!$data['validity']['folder_status_info']))
                        {
                              // obtain folder stats, ADD IT TO DATA
                              $data['validity']['folder_status_info'] = array();
                              $data['validity']['folder_status_info'] = $this->get_folder_status_info($data['validity']['fldball']);
                        }
                        // ADDITIONAL info that we need for validity testing when we later want to read this info
                        // ADD IT IF NOT PROVIDED
                        if (isset($data['validity']['sort']) == False)
                        {
                              $data['validity']['sort'] = $this->get_arg_value('sort', $data['validity']['fldball']['acctnum']);
                        }
                        if (isset($data['validity']['order']) == False)
                        {
                              $data['validity']['order'] = $this->get_arg_value('order', $data['validity']['fldball']['acctnum']);
                        }
                        if ((isset($data['validity']['mailsvr_callstr']) == False)
                        || (isset($data['validity']['mailsvr_account_username']) == False))
                        {
                              // these two things are REALLY linked together, the better be obtained as a pair
                              $data['validity']['mailsvr_callstr'] = $this->get_arg_value('mailsvr_callstr', $data['validity']['fldball']['acctnum']);
                              $data['validity']['mailsvr_account_username'] = $this->get_arg_value('mailsvr_account_username', $data['validity']['fldball']['acctnum']);
                        }
                        
                        // only is admin is using DB as session store, if "php4" session is used instead, this is not necessary
                        //if (($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                        //&& (strstr($data['validity']['mailsvr_callstr'] ,'{')) )
                        //{
                        //    // NOTE: YOU BETTER BASE64 ENCODE "DEFANG" the "mailsvr_callstr" OR RISK b0rking your database!!!
                        //    // applies to DBs where ' " / \ and other offensive chars are not handled at the api level in phpgw
                        //    $data['validity']['mailsvr_callstr'] = base64_encode($data['validity']['mailsvr_callstr']);
                        //    // COMMENT THAT OUT if you can prove that DBs are immune to this b0rking
                        //}
                        
                        // we have ALL the data we need now                   
                        // RECAST DATA ready for saving in appsession
                        //$data = serialize($data);
                        
                        // NOW WE USE FOLDER INFO TOO SO EVERY FOLDER GETS ITS OWN MSGBALL_LIST
                        $folder_name = $data['validity']['fldball']['folder'];
                        if (($this->debug_session_caching > 2) && ($this->debug_allow_magball_list_dumps)) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): [email][dat]['.$acctnum.']['.$data_name.']['.$folder_name.'] DUMP:', $data); } 
                        // SET DATA
                        //$this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name] = $data;
                        // SET DATA USING FOLDER ALSO
                        $this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$folder_name] = $data;
                        
                        // for DB sessions_db ONLY
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                        || ($this->use_private_table == True))
                        {
                              //$my_location = (string)$acctnum.';'.$data_name;
                              // SET DATA USING FOLDER ALSO
                              $my_location = (string)$acctnum.';'.$data_name.';'.$folder_name;
                              if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this additional step to put data into database anglemail table, $my_location ['.$my_location.']<br>'); } 
                              if ($this->use_private_table == True)
                              {
                                    //$this->so->so_set_data($my_location, $data);
                                    // TRY USING COMPRESSION
                                    $this->so->so_set_data($my_location, $data, True);
                              }
                              else
                              {
                                    // NOTE compression not available for appsession table
                                    $GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
                              }
                        }
                        
                        $data = array();
                        unset($data);
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for location: [email][dat][$acctnum][$data_name][$extra_keys] :: [email][dat]['.$acctnum.']['.$data_name.']['.$folder_name.'] <br>'); }
                        return True;
                  }
                  // DEFANG special handler for data that might b0rk a database, stuff like ' " / \ and maybe some others, only "mailsvr_callstr" needs this right now
                  elseif ($data_name == 'mailsvr_callstr_OLD_HANDLER')
                  //elseif ($data_name == 'mailsvr_callstr')
                  {
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): session_cache_enabled and DEFANG because $GLOBALS[phpgw_info][server][sessions_type] is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] and data exists for "'.$data_name.'" AND has a handler *here* because phpgw db code may be sensitive to the chars in this data.<br>'); } 
                        // we know what to do here, so this data "has a handler"
                        $has_handler = True;
                        //$location = 'acctnum='.(string)$acctnum.';data_name='.$data_name.$extra_keys;
                        //$app = 'email';
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): "'.$data_name.'" before encoding: '.serialize($data).'<br>'); }
                        // DATABASE DEFANG, this item has "database unfriendly" chars in it so we encode it before it goes to appsession cache
                        $data = base64_encode($data);
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): "'.$data_name.'" AFTER encoding: '.serialize($data).'<br>'); }
                        
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): [email][dat]['.$acctnum.']['.$data_name.'] DUMP:', $data); } 
                        // SET DATA
                        $this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name] = $data;
                        $data = array();
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for location: [email][dat][$acctnum][$data_name] :: [email][dat]['.$acctnum.']['.$data_name.'] <br>'); }
                        unset($data);
                        return True;
                  }
                  // ANYTHING that is non extreme-mode cachable that requires NO special treatment, add it to this block here
                  elseif (($data_name == 'mailsvr_namespace')
                  || ($data_name == 'folder_list')
                  || ($data_name == 'mailsvr_callstr'))
                  {
                        // note "mailsvr_callstr" is handled here is php4 session is used, because no "defanging" is necessary since data does not go into a database via the phpgw api
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): session_cache_enabled and data exists for "'.$data_name.'" AND has a handler<br>'); }
                        // we know what to do here, so this data "has a handler"
                        $has_handler = True;
                        //$location = 'acctnum='.(string)$acctnum.';data_name='.$data_name.$extra_keys;
                        //$app = 'email';
                        // NO CHANGE TO INPUT DATA NECESSARY because the data is in ready to save form
                        
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): [email][dat]['.$acctnum.']['.$data_name.'] DUMP:', $data); } 
                        // SET DATA
                        $this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name] = $data;
                        // session_db backwards_compat
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                        || ($this->use_private_table == True))
                        {
                              $my_location = (string)$acctnum.';'.$data_name;
                              if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this additional step to put data into phpgw_app_sessions table, $my_location ['.$my_location.']<br>'); } 
                              if ($this->use_private_table == True)
                              {
                                    $this->so->so_set_data($my_location, $data);
                              }
                              else
                              {
                                    $GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
                              }
                        }
                        
                        $data = array();
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for location: [email][dat][$acctnum][$data_name] :: [email][dat]['.$acctnum.']['.$data_name.'] <br>'); }
                        unset($data);
                        return True;
                  }
                  else
                  {
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): in non-extreme mode block, $data_name ['.$data_name.'] has no handler, so Your data better be handled in the extreme mode block or you are SOL!<br>'); }
                  }
                  
                  // 2nd -- "session_cache_extreme" stuff, ADDITIONAL EXTRA CACHED ITEMS
                  if ($this->session_cache_extreme == False)
                  {
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, return False, because $this->session_cache_extreme='.serialize($this->session_cache_extreme).', so the extra "extreme cache" stuff can NOT use the appsession cache.<br>'); }
                        return False;
                  }
                  elseif ($data_name == 'folder_status_info')
                  {
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): (extreme-mode) data exists for "'.$data_name.'" AND has a handler<br>'); }
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): "'.$data_name.'" ARRIVING param $data as it is passed into this function DUMP:', $data); } 
                        // DATA REQUIRING "extra_keys" because it is probably one element of a larger group of related data
                        // we will not waste time making a sub array, instead we add the "extra_keys" to the "location"
                        // that way we can directly access this individual datUM without the hastle of a sub array
                        
                        /*!
                        @capability folder_status_info appsession cached when using extreme-mode
                        @syntax Data Param ARRIVES to this function like this
                        folder_status_info $data param arrives into this function like this:
                              $folder_status_info = $data;
                        because folder_status_info has in it a fldball item we can use
                              $folder_status_info[foldball] 
                        has the fldball data we can use that already provided
                        
                        @discussion The "extra_keys" string is the extra KEY which is "FOLDER" 
                        where "FOLDER" is the "long" foldername, meaning it has the Namespace_Delimiter prefixing it.
                        NOTE this is less info than some other data items use in their "extra_keys", other data 
                        may require extra_keys that is "FOLDER_UID" where UID is the message UID, but this 
                        data is for "folder_status_info" so no message UID is necessary, nor applicable, to this.
                        That "extra_keys" string is used in the "location" param of the appsession to access this specific data 
                        which is part of a larger set of data, BUT we do not need to use sub array because that single KEY 
                        will let us directly access this data.
                        */
                        
                        if (!$extra_keys)
                        {
                              // (a) make the key, value pair that we will add to the cache
                              // EXTRA_KEYS = FOLDERNAME_MSGNUM
                              // we know the acctnum, so we already know the username and server name is correct
                              // but within that account there are many folders, all data for those folders is indexed by a unique KEY
                              // by using KEY of msgnum and foldername, we know everything we need to identify the exact data we need
                              
                              if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item: ('.__LINE__.') ['.$data_name.'] needs folder stats to have a PLAIN (not urlencoded) "folder" value ['.$data[$data_name]['folder'].'] so we can urlencode it to make the $specific_key<br>'); } 
                              // $data has info to generate out specific key
                              // KEY MUST BE FOLDER IN URLENCODED FORM
                              //$specific_key = $this->prep_folder_out($data[$data_name]['folder']);
                              // ****************
                              // fix this data structure, i.e. it should arrive here as one thing and we get the folder from IT itself
                              // just a temp hack while fixing other stuff
                              // IS THIS FOLDER NAME ALREADY URLENCODED? IT SHOULD BE.
                              // but we are only using it as a "extra_keys" so maybe just be consistant with the other data?
                              //$extra_keys = urlencode($data['folder_status_info']['fldball']['folder']);
                              //$extra_keys = $data['folder_status_info']['fldball']['folder'];
                              $extra_keys = $data['fldball']['folder'];
                              
                        }
                        // we know what to do here, so this data "has a handler"
                        $has_handler = True;
                        
                        // RECAST DATA ready for saving in appsession
                        //$data = serialize($data);
                        
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): [email][dat]['.$acctnum.']['.$data_name.']['.$extra_keys.'] DUMP:', $data); } 
                        // SET DATA
                        $this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$extra_keys] = $data;
                        // for DB sessions_db ONLY
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                        || ($this->use_private_table == True))
                        {
                              $my_location = (string)$acctnum.';'.$data_name.';'.$extra_keys;
                              if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this additional step to put data into phpgw_app_sessions table, $my_location ['.$my_location.']<br>'); } 
                              if ($this->use_private_table == True)
                              {
                                    $this->so->so_set_data($my_location, $data);
                              }
                              else
                              {
                                    $GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
                              }
                        }
                        $data = array();
                        unset($data);
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for location: [email][dat][$acctnum][$data_name][$extra_keys] :: [email][dat]['.$acctnum.']['.$data_name.']['.$extra_keys.'] <br>'); }
                        return True;
                  }
                  elseif (($data_name == 'msg_structure')
                  || ($data_name == 'phpgw_header'))
                  {
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): (extreme-mode) data exists for "'.$data_name.'" AND has a handler<br>'); }
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): "'.$data_name.'" ARRIVING param $data as it is passed into this function DUMP:', $data); } 
                        // DATA REQUIRING "extra_keys" because it is probably one element of a larger group of related data
                        // we will not waste time making a sub array, instead we add the "extra_keys" to the "location"
                        // that way we can directly access this individual datUM without the hastle of a sub array
                        
                        // "flat_pgw_struct" also known as "part_nice"
                        
                        /*!
                        @capability msg_structure and phpgw_header unique handling
                        @abstract The theory is correct and still applied, but the sub-array style is OLD OLD OLD 
                        and has been changed to "extra_keys" in the "location"
                        @discussion These 2 data items are cached ONLY IF this->session_cache_extreme IS TRUE. 
                        Notes on this data caching (see 4 notes, 2 in discussion and 2 in syntax): 
                        (1) Fetchstructure data can ONLY BE OBTAINED for the currently selected folder, 
                        so we automatically know which folder this data is applies to by calling get_arg_value("folder") 
                        HOWEVER in order to break free from this limitation in grabbing the data we are about to cache, 
                        ALWAYS pass a msgball WITH a folder value, even though it is obvious now, it may not be later. 
                        Note: folder name must be in urlencoded form, because it may contain "database unfriendly" chars 
                        This applies to "phpgw_header" data also. 
                        (Note: a msgball without a folder is *extremely* rare, and probably never occurs.) 
                        (2) "msg_structure" and "phpgw_header" caching scheme is UNUSUAL because 
                        it requires "extra_keys" param with BOTH folder AND message UID. 
                        You can provide such an  "extra_keys" param BUT that is NOT necessary because we will make 
                        the "extra_keys" string here, using the data from the "msgball" element of the data structure, 
                        see "syntax" below for how you MUST pass data into this function to save this data type. 
                        @syntax (3) The "extra_keys" string is the extra KEY which is "FOLDER_UID" 
                        where "FOLDER" is the "long" foldername, meaning it has the Namespace_Delimiter prefixing it, and 
                        where "_" is an underscore char, and
                        where "UID" is the msgnum UID that the mailserver has given the message. 
                        That "extra_keys" string is used in the "location" param of the appsession to access this specific data 
                        which is part of a larger set of data, BUT we do not need to use sub array because that single KEY 
                        will let us directly access this data.
                        
                        (4) Data Param ARRIVES to this function like this
                        msg_structure $data param arrives into this function like this:
                              $data['msgball'] = $msgball;
                              $data['msg_structure'] = $data;
                         
                        phpgw_header $data param arrives into this function like this:
                              $data['msgball'] = $msgball;
                              $data['phpgw_header'] = $data;
                        @author Angles
                        */
                        
                        if (!$extra_keys)
                        {
                              // (a) make the key, value pair that we will add to the cache
                              // EXTRA_KEYS = FOLDERNAME_MSGNUM
                              // we know the acctnum, so we already know the username and server name is correct
                              // but within that account there are many folders, all data for those folders is indexed by a unique KEY
                              // by using KEY of msgnum and foldername, we know everything we need to identify the exact data we need
                              
                              //$extra_keys = (string)$data['msgball']['msgnum'].'_'.$data['msgball']['folder'];
                              // OLD WAY -- DEPRECIATED
                              $extra_keys = $data['msgball']['folder'].'_'.(string)$data['msgball']['msgnum'];
                        }
                        // NEW METHOD -- USE THIS
                        $ex_folder = $data['msgball']['folder'];
                        $ex_msgnum = $data['msgball']['msgnum'];
                        // we know what to do here, so this data "has a handler"
                        $has_handler = True;
                        
                        // RECAST DATA ready for saving in appsession
                        //$data = serialize($data[$data_name]);
                        $data = $data[$data_name];
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): [email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.'] DUMP:', $data); } 
                        // SET DATA
                        $this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum] = $data;
                        // for DB sessions_db ONLY
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                        || ($this->use_private_table == True))
                        {
                              $my_location = (string)$acctnum.';'.$data_name.';'.$ex_folder.';'.$ex_msgnum;
                              if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this additional step to put data into phpgw_app_sessions table, $my_location ['.$my_location.']<br>'); } 
                              if ($this->use_private_table == True)
                              {
                                    $this->so->so_set_data($my_location, $data);
                              }
                              else
                              {
                                    $GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
                              }
                        }
                        $data = array();
                        unset($data);
                        //if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for location: [email][dat][$acctnum][$data_name][$ex_folder][$ex_msgnum] :: [email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.'] <br>'); }
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for [email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.'] <br>'); }
                        return True;
                  }
                  elseif ($data_name == 'phpgw_fetchbody')
                  {
                        if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): (extreme-mode) data exists for "'.$data_name.'" AND has a handler<br>'); }
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): "'.$data_name.'" ARRIVING param $data as it is passed into this function DUMP:', $data); } 
                        
                        //(1) Data Param ARRIVES to this function like this
                        //msg_structure $data param arrives into this function like this:
                        //    $data['msgball'] = $msgball;
                        //    $data['phpgw_fetchbody'] = $data;
                        //
                        //(2) Data Param $data['msgball'] SHOULD HAVE ELEMENT "part_no" !!!!
                        //    $data['msgball']['acctnum']
                        //    $data['msgball']['folder']
                        //    $data['msgball']['msgnum']
                        //    $data['msgball']['part_no']
                        
                        if ((!isset($data['msgball']['part_no']))
                        || (!$data['msgball']['part_no']))
                        {
                              // LEAVING
                              if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with ERROR, returning FALSE, insufficient data for ['.$data_name.'] because NOT GIVEN $data[msgball][part_no];  $data[msgball] was ['.serialize($data['msgball']).'] <br>'); }
                              return False;
                        }
                        $strlen_phpgw_fetchbody = strlen($data['phpgw_fetchbody']);
                        if ($strlen_phpgw_fetchbody > 60000)
                        {
                              // LEAVING
                              if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with ERROR, returning FALSE, data TOO LARGE for ['.$data_name.']; $strlen_phpgw_fetchbody;  $data[msgball] was ['.$strlen_phpgw_fetchbody.'] <br>'); }
                              return False;
                        }
                        
                        $ex_folder = $data['msgball']['folder'];
                        $ex_msgnum = $data['msgball']['msgnum'];
                        $ex_part_no = $data['msgball']['part_no'];
                        // we know what to do here, so this data "has a handler"
                        $has_handler = True;
                        
                        // RECAST DATA ready for saving in appsession
                        //$data = serialize($data[$data_name]);
                        $data = $data[$data_name];
                        if ($this->debug_session_caching > 2) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): [email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']['.$ex_part_no.'] DUMP:', $data); } 
                        // SET DATA
                        $this->ref_SESSION['phpgw_session']['phpgw_app_sessions']['email']['dat'][$acctnum][$data_name][$ex_folder][$ex_msgnum][$ex_part_no] = $data;
                        // for DB sessions_db ONLY
                        if (($GLOBALS['phpgw_info']['server']['sessions_type'] == 'db')
                        || ($this->use_private_table == True))
                        {
                              $my_location = (string)$acctnum.';'.$data_name.';'.$ex_folder.';'.$ex_msgnum.';'.$ex_part_no;
                              if ($this->debug_session_caching > 1) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): AM Table in use or sessions_type is ['.$GLOBALS['phpgw_info']['server']['sessions_type'].'] SO we have this additional step to put data into a table table, $my_location ['.$my_location.'], this is always needed for AM table<br>'); } 
                              if ($this->use_private_table == True)
                              {
                                    $this->so->so_set_data($my_location, $data);
                              }
                              else
                              {
                                    $GLOBALS['phpgw']->session->appsession($my_location, 'email', $data);
                              }
                        }
                        $data = array();
                        unset($data);
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did SET data for [email][dat]['.$acctnum.']['.$data_name.']['.$ex_folder.']['.$ex_msgnum.']['.$ex_part_no.'] <br>'); }
                        return True;
                  }
                  else
                  {
                        // this data_name has no specific handler
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): NOTE: no handler for data_name='.$data_name.' in extreme-mode block<br>'); }
                        //echo 'mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with ERROR: NO HANDLER for data_name='.$data_name.' in extreme-mode block, DATA WILL NOT BE SAVED, returning False<br>';
                        // LEAVING
                        if ($this->debug_session_caching > 0) { $this->dbug->out('mail_msg: save_session_cache_item('.__LINE__.'): LEAVING with ERROR, no data handler for: [email][dat][$acctnum][$data_name][$extra_keys] :: [email][dat]['.$acctnum.']['.$data_name.']['.$extra_keys.'] <br>'); }
                        return False;
                  }
                  
                  /*
                  // save data, assuming we've "handled" it
                  // perhaps we already saved and exited above, or even exited on error above
                  if ((isset($data) == True)
                  && ($has_handler == True))
                  {
                        if ($this->debug_session_caching > 1) { echo 'mail_msg: save_session_cache_item('.__LINE__.'): location: ['.$location.'] $app='.$app.'; $meta dump:<pre>'; print_r($data); echo '</pre>'; }
                        if ($this->session_cache_debug_nosave == False)
                        {
                              $GLOBALS['phpgw']->session->appsession($location,$app,$data);
                        }
                        else
                        {
                              echo 'mail_msg: save_session_cache_item('.__LINE__.'): session_cache_debug_nosave disallows actual saving of data<br>';
                        }
                        if ($this->debug_session_caching > 0) { echo 'mail_msg: save_session_cache_item('.__LINE__.'): LEAVING, did set data for $data_name ['.$data_name.'] $acctnum ['.$acctnum.'], returning True<br>'; }
                        return True;
                  }
                  else
                  {
                        if ($this->debug_session_caching > 0) { echo 'mail_msg: save_session_cache_item('.__LINE__.'): LEAVING on ERROR, no handler for $data_name ['.$data_name.'] $acctnum ['.$acctnum.'], OR data was empty AFTER we messed with, we screwed it up? returning False<br>'; } 
                        return False;
                  }
                  */
            }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index