Example #1
0
     }
     if (!empty($tidbit_relationships[$module])) {
         foreach ($tidbit_relationships[$module] as $rel) {
             if (!empty($obliterated[$rel['table']])) {
                 continue;
             }
             $obliterated[$rel['table']] = true;
             $GLOBALS['db']->query("DELETE FROM {$rel['table']} WHERE 1=1 AND id LIKE 'seed-%'");
         }
     }
     echo "DONE\n";
 }
 if (file_exists('Tidbit/Data/' . $bean->module_dir . '.php')) {
     require_once 'Tidbit/Data/' . $bean->module_dir . '.php';
 }
 $ibfd = new DataTool();
 $ibfd->fields = $bean->field_defs;
 $ibfd->table_name = $bean->table_name;
 $ibfd->module = $module;
 unset($GLOBALS['queryHead']);
 unset($GLOBALS['queries']);
 /* We need to insert $total records
  * into the DB.  We are using the module and table-name given by
  * $module and $bean->table_name. */
 for ($i = 0; $i < $total; $i++) {
     if (isset($_SESSION['iterator']) && $i <= $total_iterator) {
         continue;
     }
     $ibfd->count = $i;
     /* Don't turbo Users or Teams */
     if (!isset($_SESSION['turbo']) || !($i % $recordsPerPage) || $module != 'Users' || $module != 'Teams') {
Example #2
0
 /**
  * Cache datetime generation and convert to db format
  * Based on xhprof data, this operation in time consuming, so we need to cache that
  *
  * @return mixed
  */
 function getConvertDatetime()
 {
     static $datetime = '';
     self::$datetimeCacheIndex++;
     if (self::$datetimeCacheIndex > self::$datetimeIndexMax || empty($datetime)) {
         $datetime = $GLOBALS['db']->convert("'" . date('Y-m-d H:i:s') . "'", 'datetime');
         self::$datetimeCacheIndex = 0;
     }
     return $datetime;
 }
Example #3
0
 /**
  * Returns the value of $module's field called $fieldName. 
  * Calls accessLocalField($fieldName) on a separate DataTool object
  * for the remote module.
  * @param $module - Name of remote module to access.
  * @param $fieldName - Name of field in remote module to retrieve.
  */
 function accessRemoteField($module, $fieldName){
     /* Form is 'Module' => field */
     /* I need to call $this->getData. */
     /* I need to load the Data/Module.php file,
      * to make a proper call to getData. */
     /* I need the var_defs for the Module, so
      * I can access its type or dbType. (only if it's an enum...)*/
     /* I also need the remote count of the 'parent' or 'related'
      * module.  This count would be the one that I get when
      * I generate relationships or fill 'related' fields.
      */
     /* But getData looks at $this->module... ick */
     /* Well, I'm loading the vardefs for this class, so I might
      * as well load a new dataTool for it.
      */
     /* 1. Load Data/Module definitions
      * 2. Load class[Module]
      * 3. Identify related count - ?
      * 4. call getData on the one field we want.
      */
     
     /* Should one accidentally refer to itsself, just call local */
     if($module == $this->module) return $this->accessLocalField($fieldName);
     
     /* Check if a cached dataTool object exists. */
     if(!empty($GLOBALS['foreignDataTools']) && !empty($GLOBALS['foreignDataTools'][$module])){
     	$rbfd = $GLOBALS['foreignDataTools'][$module];
     }else{
         include('include/modules.php');
         $class = $beanList[$module];
         require_once($beanFiles[$class]);
         $bean = new $class();
         if(file_exists('Tidbit/Data/' . $bean->module_dir . '.php')){
             require_once('Tidbit/Data/' . $bean->module_dir . '.php');
         }
         $rbfd = new DataTool();
         $rbfd->fields = $bean->field_defs;
         $rbfd->table_name = $bean->table_name;
         $rbfd->module = $module;
         /* Cache the dataTool object. */
         $GLOBALS['foreignDataTools'][$module] = $rbfd;
     }
     $rbfd->clean();
     $rbfd->count = $this->getRelatedUpId($module);
     return $rbfd->accessLocalField($fieldName);
 }