/** * Contruct controller and execute specific action * * @access public * @param string $controller_name * @param string $action * @return null */ static function executeAction($controller_name, $action) { $max_users = config_option('max_users'); if ($max_users && Contacts::count() > $max_users) { echo lang("error").": ".lang("maximum number of users exceeded error"); return; } ajx_check_login(); Env::useController($controller_name); $controller_class = Env::getControllerClass($controller_name); if(!class_exists($controller_class, false)) { throw new ControllerDnxError($controller_name); } // if $controller = new $controller_class(); if(!instance_of($controller, 'Controller')) { throw new ControllerDnxError($controller_name); } // if if (is_ajax_request()) { // if request is an ajax request return a json response // execute the action $controller->setAutoRender(false); $controller->execute($action); // fill the response $response = AjaxResponse::instance(); if (!$response->hasCurrent()) { // set the current content $response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel()); } $response->setEvents(evt_pop()); $error = flash_pop('error'); $success = flash_pop('success'); if (!is_null($error)) { $response->setError(1, clean($error)); } else if (!is_null($success)) { $response->setError(0, clean($success)); } // display the object as json tpl_assign("object", $response); $content = tpl_fetch(Env::getTemplatePath("json")); tpl_assign("content_for_layout", $content); TimeIt::start("Transfer"); if (is_iframe_request()) { tpl_display(Env::getLayoutPath("iframe")); } else { tpl_display(Env::getLayoutPath("json")); } TimeIt::stop(); } else { return $controller->execute($action); } } // executeAction
function quick_add_form() { ajx_current("empty"); $this->setLayout('empty'); $dimension_id = array_var($_GET, 'dimension_id'); $dimension = is_numeric($dimension_id) ? Dimensions::instance()->findById($dimension_id) : null; if ($dimension instanceof Dimension) { $object_Types = array(); $parent_member_id = array_var($_GET, 'parent_member_id'); $parent_member = Members::instance()->findById($parent_member_id); if ($parent_member instanceof Member) { $object_types = DimensionObjectTypes::getChildObjectTypes($parent_member); if (count($object_types) == 0) { $parent_member = null; $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')")); } } else { $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')")); } $obj_types = array(); $editUrls = array(); foreach ($object_types as $object_type) { $options = $object_type->getOptions(1); if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") { $editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add'); } else { $t = ObjectTypes::instance()->findById($object_type->getObjectTypeId()); $obj_types[$t->getId()] = $t; $class_name = ucfirst($t->getName()) . "Controller"; $controller_exists = controller_exists($t->getName(), $t->getPluginId()); if ($controller_exists) { Env::useController(ucfirst($t->getName())); eval('$controller = new ' . $class_name . '();'); } if ($t && controller_exists($t->getName(), $t->getPluginId()) && $t->getHandlerClass() != '' && $controller_exists && method_exists($controller, 'add')) { $params = array("type" => $t->getId()); if ($parent_member instanceof Member) { $params['parent'] = $parent_member->getId(); } $editUrls[$t->getId()] = get_url($t->getName(), 'add', $params); } else { $params = array("dim_id" => $dimension_id, "type" => $t->getId()); if ($parent_member instanceof Member) { $params['parent'] = $parent_member->getId(); } $editUrls[$t->getId()] = get_url('member', 'add', $params); } } } $urls = array(); foreach ($editUrls as $ot_id => $url) { $ot = array_var($obj_types, $ot_id); if ($ot instanceof ObjectType) { $link_text = ucfirst(strtolower(lang('new ' . $ot->getName()))); $iconcls = $ot->getIconClass(); } else { $link_text = lang('new'); $iconcls = ""; } $urls[] = array('link_text' => $link_text, 'url' => $url, 'iconcls' => $iconcls); } Hook::fire('member_quick_add_urls', array('dimension' => $dimension, 'object_types' => $object_types, 'parent_member' => $parent_member), $urls); if (count($urls) > 1) { ajx_extra_data(array('draw_menu' => 1, 'urls' => $urls)); } else { ajx_extra_data(array('urls' => $urls)); } } else { Logger::log("Invalid dimension: {$dimension_id}"); } }
/** * Contruct controller and execute specific action * * @access public * @param string $controller_name * @param string $action * @return null */ static function executeAction($controller_name, $action) { $max_users = config_option('max_users'); if ($max_users && Users::count() > $max_users) { echo lang("error") . ": " . lang("maximum number of users exceeded error"); return; } ajx_check_login(); if (isset($_GET['active_project']) && logged_user() instanceof User) { $dont_update = false; if (GlobalCache::isAvailable()) { $option_value = GlobalCache::get('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $success); if ($success) { $dont_update = $option_value == $_GET['active_project']; } } if (!$dont_update) { set_user_config_option('lastAccessedWorkspace', $_GET['active_project'], logged_user()->getId()); if (GlobalCache::isAvailable()) { GlobalCache::update('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $_GET['active_project']); } } } Env::useController($controller_name); $controller_class = Env::getControllerClass($controller_name); if (!class_exists($controller_class, false)) { throw new ControllerDnxError($controller_name); } // if $controller = new $controller_class(); if (!instance_of($controller, 'Controller')) { throw new ControllerDnxError($controller_name); } // if if (is_ajax_request()) { // if request is an ajax request return a json response // execute the action $controller->setAutoRender(false); $controller->execute($action); // fill the response $response = AjaxResponse::instance(); if (!$response->hasCurrent()) { // set the current content $response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel()); } $response->setEvents(evt_pop()); $error = flash_pop('error'); $success = flash_pop('success'); if (!is_null($error)) { $response->setError(1, clean($error)); } else { if (!is_null($success)) { $response->setError(0, clean($success)); } } // display the object as json tpl_assign("object", $response); $content = tpl_fetch(Env::getTemplatePath("json")); tpl_assign("content_for_layout", $content); TimeIt::start("Transfer"); if (is_iframe_request()) { tpl_display(Env::getLayoutPath("iframe")); } else { tpl_display(Env::getLayoutPath("json")); } TimeIt::stop(); } else { return $controller->execute($action); } }
/** * Contruct controller and execute specific action * * @access public * @param string $controller_name * @param string $action * @return null */ static function executeAction($controller_name, $action) { trace(__FILE__, "executeAction({$controller_name}, {$action})"); Env::useController($controller_name); $controller_class = Env::getControllerClass($controller_name); if (!class_exists($controller_class, false)) { trace(__FILE__, "executeAction({$controller_name}, {$action}) - {$controller_class} does not exist"); throw new ControllerDnxError($controller_name); } // if trace(__FILE__, "executeAction({$controller_name}, {$action}) - new {$controller_class}()"); $controller = new $controller_class(); if (!instance_of($controller, 'Controller')) { trace(__FILE__, "executeAction({$controller_name}, {$action}) - {$controller_class} not Controller"); throw new ControllerDnxError($controller_name); } // if trace(__FILE__, "executeAction({$controller_name}, {$action}) - {$controller_class} -> execute({$action})"); return $controller->execute($action); }
/** * Contruct controller and execute specific action * * @access public * @param string $controller_name * @param string $action * @return null */ static function executeAction($controller_name, $action) { Env::useController($controller_name); $controller_class = Env::getControllerClass($controller_name); if (!class_exists($controller_class, false)) { throw new ControllerDnxError($controller_name); } // if $controller = new $controller_class(); if (!instance_of($controller, 'Controller')) { throw new ControllerDnxError($controller_name); } // if return $controller->execute($action); }