function saveCommunityToolAction() { @($code = DevblocksPlatform::importGPC($_POST['portal'], 'string')); @($name = DevblocksPlatform::importGPC($_POST['portal_name'], 'string', '')); @($iDelete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0)); UmPortalHelper::setCode($code); if (DEMO_MODE) { if ($iDelete) { DevblocksPlatform::redirect(new DevblocksHttpResponse(array('config', 'communities'))); } else { self::getCommunityToolAction(); } return; } if (null != ($instance = DAO_CommunityTool::getByCode($code))) { // Deleting? if (!empty($iDelete)) { $tool = DAO_CommunityTool::getByCode($code); /* @var $tool Model_CommunityTool */ DAO_CommunityTool::delete($tool->id); DevblocksPlatform::redirect(new DevblocksHttpResponse(array('config', 'communities'))); return; } else { $manifest = DevblocksPlatform::getExtension($instance->extension_id, false, true); $tool = $manifest->createInstance(); /* @var $tool Extension_UsermeetTool */ // Update the tool name if it has changed if (0 != strcmp($instance->name, $name)) { DAO_CommunityTool::update($instance->id, array(DAO_CommunityTool::NAME => $name)); } // Defer the rest to tool instances and extensions $tool->saveConfiguration(); } } self::getCommunityToolAction(); }
function doBulkUpdate($filter, $do, $ids = array()) { @set_time_limit(600); // [TODO] Temp! $change_fields = array(); $custom_fields = array(); // Make sure we have actions 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 'status': // if(1==intval($v)) { // completed // $change_fields[DAO_Task::IS_COMPLETED] = 1; // $change_fields[DAO_Task::COMPLETED_DATE] = time(); // } else { // active // $change_fields[DAO_Task::IS_COMPLETED] = 0; // $change_fields[DAO_Task::COMPLETED_DATE] = 0; // } // break; default: // Custom fields if (substr($k, 0, 3) == "cf_") { $custom_fields[substr($k, 3)] = $v; } } } } $pg = 0; if (empty($ids)) { do { list($objects, $null) = DAO_CommunityTool::search(array(), $this->params, 100, $pg++, SearchFields_CommunityTool::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); DAO_CommunityTool::update($batch_ids, $change_fields); // Custom Fields self::_doBulkSetCustomFields(CustomFieldSource_CommunityPortal::ID, $custom_fields, $batch_ids); unset($batch_ids); } unset($ids); }