function exponent_workflow_post($object, $table, $loc, $userdata = null) { global $db, $user; $policy = exponent_workflow_getPolicy($loc->mod, $loc->src); $is_post = false; if (isset($object->id)) { // Updating an existing $object->approved = 2; $fake = null; $fake->approved = 2; $fake->id = $object->id; $db->updateObject($fake, $table); $object->wf_original = $object->id; // SET ACTIONTYPE FOR RUNACTIONS $object->wf_type = SYS_WORKFLOW_ACTION_EDITED; } else { $is_post = true; $object->approved = 0; $object->wf_original = $db->insertObject($object, $table); $object->wf_type = SYS_WORKFLOW_ACTION_POSTED; } $object->wf_major = $db->max($table . "_wf_revision", "wf_major", "wf_original", "wf_original=" . $object->wf_original); if ($object->wf_major == null) { $object->wf_major = 0; } $object->wf_minor = 1; $state = array(array($user->id + 0), array($user->id => 1)); $object->wf_state_data = serialize($state); $object->wf_user_id = $user->id; // Now check approval right off the bat. Admin is always exempt from workflow if (exponent_workflow_checkApprovalState($state, $policy) || $user->is_acting_admin == 1) { $object->wf_major++; $object->wf_minor = 0; $real_object = exponent_workflow_convertToObject($object); $real_object->approved = 1; $object->wf_updated = time(); $db->updateObject($real_object, $table); // Call spidering for implicit / admin approval. if (is_callable(array($loc->mod, "spiderContent"))) { call_user_func(array($loc->mod, "spiderContent"), $real_object); } if ($user->is_acting_admin == 1) { $object->wf_type = SYS_WORKFLOW_ACTION_POSTED_ADMIN; } else { $object->wf_type = SYS_WORKFLOW_ACTION_IMPLICIT_APPROVAL; } } else { $info = exponent_workflow_updateInfoFromRevision($object, null); $info->location_data = $object->location_data; $info->policy_id = $policy->id; $info->open_slots = $policy->max_approvers; $info->updated = time(); $db->insertObject($info, $table . "_wf_info"); $object->wf_updated = time(); } unset($object->id); $db->insertObject($object, $table . "_wf_revision"); exponent_workflow_deleteOldRevisions($table, $object->wf_original); // Now that we are almost done, we need to call the onWorkflow stuff. if (is_callable(array($table, 'onWorkflowPost'))) { if (!isset($real_object)) { $real_object = exponent_workflow_convertToObject($object); $real_object->id = $object->wf_original; } call_user_func(array($table, 'onWorkflowPost'), $real_object, $is_post, $userdata); } if ($policy != null) { // run actions, either EDIT or POST or IMPLICIT_APPROVAL exponent_workflow_runActions($policy, $object->wf_type, $object); } else { // Catch-all redirect - in case its a new post, implicitly approved, with no policy exponent_flow_redirect(); } }
function show($view, $loc = null, $title = '') { $i18n = exponent_lang_loadFile('modules/ContainerModule/class.php'); $source_select = array(); $clickable_mods = null; // Show all $dest = null; $singleview = '_container'; $singlemodule = 'ContainerModule'; if (exponent_sessions_isset('source_select') && defined('SELECTOR')) { $source_select = exponent_sessions_get('source_select'); $singleview = $source_select['view']; $singlemodule = $source_select['module']; $clickable_mods = $source_select['showmodules']; if (!is_array($clickable_mods)) { $clickable_mods = null; } $dest = $source_select['dest']; } global $db; $container = null; if (!isset($this) || !isset($this->_hasParent) || $this->_hasParent == 0) { // Top level container. $container = $db->selectObject('container', "external='" . serialize(null) . "' AND internal='" . serialize($loc) . "'"); if ($container == null) { $container->external = serialize(null); $container->internal = serialize($loc); $container->view = $view; $container->title = $title; $container->id = $db->insertObject($container, 'container'); } if (!defined('PREVIEW_READONLY') || defined('SELECTOR')) { $view = $container->view; } $title = $container->title; } $template = new template('ContainerModule', $view, $loc); if ($dest) { $template->assign('dest', $dest); } $template->assign('singleview', $singleview); $template->assign('singlemodule', $singlemodule); $template->assign('top', $container); $containers = array(); $container_key = serialize($loc); if (!isset($_SESSION['containers_cache'][$container_key])) { foreach ($db->selectObjects('container', "external='" . serialize($loc) . "'") as $c) { if ($c->is_private == 0 || exponent_permissions_check('view', exponent_core_makeLocation($loc->mod, $loc->src, $c->id))) { $containers[$c->rank] = $c; } } $_SESSION['containers_cache'][$container_key] = serialize($containers); } else { $containers = unserialize($_SESSION['containers_cache'][$container_key]); } if (!defined('SYS_WORKFLOW')) { include_once BASE . 'subsystems/workflow.php'; } ksort($containers); foreach (array_keys($containers) as $i) { $location = unserialize($containers[$i]->internal); $modclass = $location->mod; if (class_exists($modclass)) { $mod = new $modclass(); ob_start(); $mod->_hasParent = 1; $mod->show($containers[$i]->view, $location, $containers[$i]->title); $containers[$i]->output = trim(ob_get_contents()); ob_end_clean(); $policy = exponent_workflow_getPolicy($modclass, $location->src); $containers[$i]->info = array('module' => $mod->name(), 'source' => $location->src, 'hasContent' => $mod->hasContent(), 'hasSources' => $mod->hasSources(), 'hasViews' => $mod->hasViews(), 'class' => $modclass, 'supportsWorkflow' => $mod->supportsWorkflow() ? 1 : 0, 'workflowPolicy' => $policy ? $policy->name : '', 'workflowUsesDefault' => exponent_workflow_moduleUsesDefaultPolicy($location->mod, $location->src) ? 1 : 0, 'clickable' => $clickable_mods == null || in_array($modclass, $clickable_mods)); } else { $containers[$i]->output = sprintf($i18n['mod_not_found'], $location->mod); $containers[$i]->info = array('module' => sprintf($i18n['unknown'], $location->mod), 'source' => $location->src, 'hasContent' => 0, 'hasSources' => 0, 'hasViews' => 0, 'class' => $modclass, 'supportsWorkflow' => 0, 'workflowPolicy' => '', 'workflowUsesDefault' => 0, 'clickable' => 0); } $containers[$i]->moduleLocation = $location; $cloc = null; $cloc->mod = $loc->mod; $cloc->src = $loc->src; $cloc->int = $containers[$i]->id; $containers[$i]->permissions = array('administrate' => exponent_permissions_check('administrate', $location) ? 1 : 0, 'configure' => exponent_permissions_check('configure', $location) ? 1 : 0); } $template->assign('containers', $containers); $template->assign('hasParent', isset($this) && isset($this->_hasParent) ? 1 : 0); $template->register_permissions(array('administrate', 'add_module', 'edit_module', 'delete_module', 'order_modules'), $loc); $template->output(); }