示例#1
0
 function doBulkUpdate($filter, $do, $ids = array())
 {
     @set_time_limit(600);
     // [TODO] Temp!
     $change_fields = array();
     $deleted = false;
     $custom_fields = array();
     if (empty($do)) {
         return;
     }
     // Make sure we have checked items if we want a checked list
     if (0 == strcasecmp($filter, "checks") && empty($ids)) {
         return;
     }
     if (is_array($do)) {
         foreach ($do as $k => $v) {
             switch ($k) {
                 case 'deleted':
                     $deleted = true;
                     break;
                 default:
                     // Custom fields
                     if (substr($k, 0, 3) == "cf_") {
                         $custom_fields[substr($k, 3)] = $v;
                     }
                     break;
             }
         }
     }
     $pg = 0;
     if (empty($ids)) {
         do {
             list($objects, $null) = DAO_DevblocksTemplate::search(array(), $this->params, 100, $pg++, DAO_DevblocksTemplate::ID, true, false);
             $ids = array_merge($ids, array_keys($objects));
         } while (!empty($objects));
     }
     $batch_total = count($ids);
     for ($x = 0; $x <= $batch_total; $x += 100) {
         $batch_ids = array_slice($ids, $x, 100);
         if (!$deleted) {
             DAO_DevblocksTemplate::update($batch_ids, $change_fields);
         } else {
             DAO_DevblocksTemplate::delete($batch_ids);
         }
         // Custom Fields
         //			self::_doBulkSetCustomFields(ChCustomFieldSource_Worker::ID, $custom_fields, $batch_ids);
         unset($batch_ids);
     }
     if ($deleted) {
         // Clear template cache
         $tpl = DevblocksPlatform::getTemplateService();
         $tpl->clear_compiled_tpl();
     }
     unset($ids);
 }
示例#2
0
 static function get_timestamp($tpl_name, &$tpl_timestamp, $smarty_obj)
 {
     /* @var $smarty_obj Smarty */
     list($plugin_id, $tag, $tpl_path) = explode(':', $tpl_name, 3);
     if (empty($plugin_id) || empty($tpl_path)) {
         return false;
     }
     $plugins = DevblocksPlatform::getPluginRegistry();
     $db = DevblocksPlatform::getDatabaseService();
     if (null == ($plugin = @$plugins[$plugin_id])) {
         /* @var $plugin DevblocksPluginManifest */
         return false;
     }
     // Check if template is overloaded in DB/cache
     $matches = DAO_DevblocksTemplate::getWhere(sprintf("plugin_id = %s AND path = %s %s", $db->qstr($plugin_id), $db->qstr($tpl_path), !empty($tag) ? sprintf("AND tag = %s ", $db->qstr($tag)) : ""));
     if (!empty($matches)) {
         $match = array_shift($matches);
         /* @var $match Model_DevblocksTemplate */
         //			echo time(),"==(DB)",$match->last_updated,"<BR>";
         $tpl_timestamp = $match->last_updated;
         return true;
     }
     // If not in DB, check plugin's relative path on disk
     $path = APP_PATH . '/' . $plugin->dir . '/templates/' . $tpl_path;
     if (!file_exists($path)) {
         return false;
     }
     $stat = stat($path);
     $tpl_timestamp = $stat['mtime'];
     //		echo time(),"==(DISK)",$stat['mtime'],"<BR>";
     return true;
 }
示例#3
0
文件: classes.php 项目: Hildy/cerb5
 function saveExportTemplatesPeekAction()
 {
     if (null == ($active_worker = CerberusApplication::getActiveWorker()) || !$active_worker->is_superuser) {
         exit;
     }
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     @($portal = DevblocksPlatform::importGPC($_REQUEST['portal'], 'string', ''));
     @($filename = DevblocksPlatform::importGPC($_REQUEST['filename'], 'string', ''));
     @($author = DevblocksPlatform::importGPC($_REQUEST['author'], 'string', ''));
     @($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string', ''));
     // Build XML file
     $xml = simplexml_load_string('<?xml version="1.0" encoding="' . LANG_CHARSET_CODE . '"?>' . '<cerb5>' . '<templates>' . '</templates>' . '</cerb5>');
     /* @var $xml SimpleXMLElement */
     // Author
     $eAuthor =& $xml->templates->addChild('author');
     /* @var $eAuthor SimpleXMLElement */
     $eAuthor->addChild('name', htmlspecialchars($author));
     $eAuthor->addChild('email', htmlspecialchars($email));
     // Load view
     if (null == ($view = C4_AbstractViewLoader::getView($view_id))) {
         exit;
     }
     // Load all data
     $view->renderLimit = -1;
     $view->renderPage = 0;
     list($results, $null) = $view->getData();
     // Add template
     if (is_array($results)) {
         foreach ($results as $result) {
             // Load content
             if (null == ($template = DAO_DevblocksTemplate::get($result[SearchFields_DevblocksTemplate::ID]))) {
                 continue;
             }
             $eTemplate =& $xml->templates->addChild('template', htmlspecialchars($template->content));
             /* @var $eTemplate SimpleXMLElement */
             $eTemplate->addAttribute('plugin_id', htmlspecialchars($template->plugin_id));
             $eTemplate->addAttribute('path', htmlspecialchars($template->path));
         }
     }
     // Format download file
     $imp = new DOMImplementation();
     $doc = $imp->createDocument("", "");
     $doc->encoding = LANG_CHARSET_CODE;
     $doc->formatOutput = true;
     $simplexml = dom_import_simplexml($xml);
     /* @var $dom DOMElement */
     $simplexml = $doc->importNode($simplexml, true);
     $simplexml = $doc->appendChild($simplexml);
     header("Content-type: text/xml");
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     echo $doc->saveXML();
     exit;
 }