當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LogicHook類代碼示例

本文整理匯總了PHP中LogicHook的典型用法代碼示例。如果您正苦於以下問題:PHP LogicHook類的具體用法?PHP LogicHook怎麽用?PHP LogicHook使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LogicHook類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate_authenticated

 /**
  * Validate the provided session information is correct and current.  Load the session.
  *
  * @param String $session_id -- The session ID that was returned by a call to login.
  * @return true -- If the session is valid and loaded.
  * @return false -- if the session is not valid.
  */
 function validate_authenticated($session_id)
 {
     $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated');
     if (!empty($session_id)) {
         // only initialize session once in case this method is called multiple times
         if (!session_id()) {
             session_id($session_id);
             session_start();
         }
         if (!empty($_SESSION['is_valid_session']) && $this->is_valid_ip_address('ip_address') && $_SESSION['type'] == 'user') {
             global $current_user;
             require_once 'modules/Users/User.php';
             $current_user = BeanFactory::getBean('Users', $_SESSION['user_id']);
             $this->login_success();
             $GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated - passed');
             $GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated');
             return true;
         }
         $GLOBALS['log']->debug("calling destroy");
         session_destroy();
     }
     LogicHook::initialize();
     $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
     $GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated - validation failed');
     return false;
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:33,代碼來源:SugarWebServiceUtilv4_1.php

示例2: tearDown

 public function tearDown()
 {
     foreach ($this->renames as $file) {
         rename($file . ".bak", $file);
     }
     foreach ($this->deletes as $file) {
         unlink($file);
     }
     unset($GLOBALS['logic_hook']);
     LogicHook::refreshHooks();
 }
開發者ID:netconstructor,項目名稱:sugarcrm_dev,代碼行數:11,代碼來源:Bug46850Test.php

示例3: setUp

 public function setUp()
 {
     $this->user = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['current_user'] = $this->user;
     //Setup logichook files
     if (file_exists($this->casesHookFile)) {
         $this->hasCustomCasesLogicHookFile = true;
         copy($this->casesHookFile, $this->casesHookFile . '.bak');
     }
     $hook_array['after_relationship_add'][] = array(1, 'Cases increment count', $this->casesCountFile, 'CaseCount', 'countMe');
     write_array_to_file("hook_array", $hook_array, $this->casesHookFile);
     $this->useOutputBuffering = false;
     LogicHook::refreshHooks();
     //now  write out the script that the logichook executes.  This will keep track of times called
     global $hookRunCount;
     $hookRunCount = 0;
     $fileCont = '<?php class CaseCount {
         function countMe($bean, $event, $arguments){
             global $hookRunCount;
             if($event =="after_relationship_add" && $arguments["module"]=="Cases" && $arguments["related_module"]=="Emails")
                 $hookRunCount++;
             }}?>';
     file_put_contents($this->casesCountFile, $fileCont);
     //setup test account for case
     $this->account = new Account();
     $this->account->name = 'test account for bug 39855';
     $this->account->assigned_user_id = 'SugarUser';
     $this->account->save();
     //create case
     $this->case = new aCase();
     $this->case->name = 'test case for unitTest 49784';
     $this->case->account_id = $this->account->id;
     $this->case->status = 'New';
     $this->case->save();
     //retrieve so we have latest info (case number)
     $this->case->retrieve($this->case->id);
     //create email with case in subject
     $this->email = new Email();
     $this->email->type = 'inbound';
     $this->email->status = 'unread';
     $this->email->from_addr_name = $this->email->cleanEmails("sender@domain.eu");
     $this->email->to_addrs_names = $this->email->cleanEmails("to@domain.eu");
     $this->email->cc_addrs_names = $this->email->cleanEmails("cc@domain.eu");
     $this->email->name = 'RE: [CASE:' . $this->case->case_number . '] ' . $this->case->name;
     $this->email->save();
 }
開發者ID:jgera,項目名稱:sugarcrm_dev,代碼行數:46,代碼來源:Bug49784Test.php

示例4: setUp

 public function setUp()
 {
     //Setup mock logic hook files
     if (file_exists($this->modulesHookFile)) {
         $this->hasCustomModulesLogicHookFile = true;
         copy($this->modulesHookFile, $this->modulesHookFile . '.bak');
     } else {
         write_array_to_file("test", array(), $this->modulesHookFile);
     }
     if (file_exists($this->contactsHookFile)) {
         $this->hasCustomContactLogicHookFile = true;
         copy($this->contactsHookFile, $this->contactsHookFile . '.bak');
     } else {
         write_array_to_file("test", array(), $this->contactsHookFile);
     }
     $this->useOutputBuffering = false;
     LogicHook::refreshHooks();
 }
開發者ID:butschster,項目名稱:sugarcrm_dev,代碼行數:18,代碼來源:Bug46122Test.php

示例5: startSession

 function startSession()
 {
     $sessionIdCookie = isset($_COOKIE['PHPSESSID']) ? $_COOKIE['PHPSESSID'] : null;
     if (isset($_REQUEST['MSID'])) {
         session_id($_REQUEST['MSID']);
         session_start();
         if (isset($_SESSION['user_id']) && isset($_SESSION['seamless_login'])) {
             unset($_SESSION['seamless_login']);
         } else {
             if (isset($_COOKIE['PHPSESSID'])) {
                 self::setCookie('PHPSESSID', '', time() - 42000, '/');
             }
             sugar_cleanup(false);
             session_destroy();
             exit('Not a valid entry method');
         }
     } else {
         if (can_start_session()) {
             session_start();
         }
     }
     if (isset($_REQUEST['login_module']) && isset($_REQUEST['login_action']) && !($_REQUEST['login_module'] == 'Home' && $_REQUEST['login_action'] == 'index')) {
         if (!is_null($sessionIdCookie) && empty($_SESSION)) {
             self::setCookie('loginErrorMessage', 'LBL_SESSION_EXPIRED', time() + 30, '/');
         }
     }
     self::trackLogin();
     LogicHook::initialize()->call_custom_logic('', 'after_session_start');
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:29,代碼來源:SugarApplication.php

示例6: call_custom_logic

 /**
  * Trigger custom logic for this module that is defined for the provided hook
  * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php.
  * That file should define the $hook_version that should be used.
  * It should also define the $hook_array.  The $hook_array will be a two dimensional array
  * the first dimension is the name of the event, the second dimension is the information needed
  * to fire the hook.  Each entry in the top level array should be defined on a single line to make it
  * easier to automatically replace this file.  There should be no contents of this file that are not replacable.
  *
  * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1');
  * This sample line creates a before_save hook.  The hooks are procesed in the order in which they
  * are added to the array.  The second dimension is an array of:
  *		processing index (for sorting before exporting the array)
  *		A logic type hook
  *		label/type
  *		php file to include
  *		php class the method is in
  *		php method to call
  *
  * The method signature for version 1 hooks is:
  * function NAME(&$bean, $event, $arguments)
  * 		$bean - $this bean passed in by reference.
  *		$event - The string for the current event (i.e. before_save)
  * 		$arguments - An array of arguments that are specific to the event.
  */
 function call_custom_logic($event, $arguments = array())
 {
     if (!isset($this->processed) || $this->processed == false) {
         //add some logic to ensure we do not get into an infinite loop
         if (!empty($this->logicHookDepth[$event])) {
             if ($this->logicHookDepth[$event] > $this->max_logic_depth) {
                 return;
             }
         } else {
             $this->logicHookDepth[$event] = 0;
         }
         //we have to put the increment operator here
         //otherwise we may never increase the depth for that event in the case
         //where one event will trigger another as in the case of before_save and after_save
         //Also keeping the depth per event allow any number of hooks to be called on the bean
         //and we only will return if one event gets caught in a loop. We do not increment globally
         //for each event called.
         $this->logicHookDepth[$event]++;
         //method defined in 'include/utils/LogicHook.php'
         $logicHook = new LogicHook();
         $logicHook->setBean($this);
         $logicHook->call_custom_logic($this->module_dir, $event, $arguments);
         $this->logicHookDepth[$event]--;
         //Fire dependency manager dependencies here for some custom logic types.
         if (in_array($event, array('after_relationship_add', 'after_relationship_delete', 'before_delete'))) {
             $this->updateRelatedCalcFields(isset($arguments['link']) ? $arguments['link'] : "");
         }
     }
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:54,代碼來源:SugarBean.php

示例7: handleException

 /**
  * Handle exception
  * @param Exception $e
  */
 protected function handleException(Exception $e)
 {
     $GLOBALS['log']->fatal('Exception in Controller: ' . $e);
     $logicHook = new LogicHook();
     SugarMetric_Manager::getInstance()->handleException($e);
     if (isset($this->bean)) {
         $logicHook->setBean($this->bean);
         $logicHook->call_custom_logic($this->bean->module_dir, "handle_exception", $e);
     } else {
         $logicHook->call_custom_logic('', "handle_exception", $e);
     }
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:16,代碼來源:SugarController.php

示例8: foreach

 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
// record the last theme the user used
$current_user->setPreference('lastTheme', $theme);
$GLOBALS['current_user']->call_custom_logic('before_logout');
// submitted by Tim Scott from SugarCRM forums
foreach ($_SESSION as $key => $val) {
    $_SESSION[$key] = '';
    // cannot just overwrite session data, causes segfaults in some versions of PHP
}
if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time() - 42000, '/');
}
//Update the tracker_sessions table
$trackerManager = TrackerManager::getInstance();
if ($monitor = $trackerManager->getMonitor('tracker_sessions')) {
    $monitor->setValue('user_id', $GLOBALS['current_user']->id);
    $monitor->setValue('date_end', TimeDate::getInstance()->nowDb());
    $seconds = strtotime($monitor->date_end) - strtotime($monitor->date_start);
    $monitor->setValue('seconds', $seconds);
    $monitor->setValue('active', 0);
    $trackerManager->saveMonitor($monitor);
}
// clear out the authenticating flag
session_destroy();
LogicHook::initialize();
$GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout');
/** @var AuthenticationController $authController */
$authController->authController->logout();
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:31,代碼來源:Logout.php

示例9: logout

/**
 * Log out of the session.  This will destroy the session and prevent other's from using it.
 *
 * @param String $session -- Session ID returned by a previous call to login.
 * @return Empty error on success, Error on failure
 */
function logout($session)
{
    global $current_user;
    $error = new SoapError();
    LogicHook::initialize();
    if (validate_authenticated($session)) {
        $current_user->call_custom_logic('before_logout');
        session_destroy();
        $GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout');
        return $error->get_soap_array();
    }
    $error->set_error('no_session');
    $GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout');
    return $error->get_soap_array();
}
開發者ID:sunmo,項目名稱:snowlotus,代碼行數:21,代碼來源:SoapSugarUsers.php

示例10: handleException

 /**
  * Handle exception
  *
  * @param Exception $e
  */
 protected function handleException(Exception $e)
 {
     $logicHook = LogicHook::instance();
     $dir = '';
     Log::fatal("Exception in Controller: [{$e->getMessage()}]:[File: {$e->getFile()}:{$e->getLine()}]");
     if (isset($this->bean)) {
         $logicHook->setBean($this->bean);
         $dir = $this->bean->module_dir;
     }
     LogicHook::instance();
     $logicHook->call_custom_logic($dir, "handle_exception", $e);
 }
開發者ID:butschster,項目名稱:sugarcrm_dev,代碼行數:17,代碼來源:SugarController.php

示例11: sugar_cleanup

function sugar_cleanup($exit = false)
{
    static $called = false;
    if ($called) {
        return;
    }
    $called = true;
    set_include_path(realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path());
    chdir(realpath(dirname(__FILE__) . '/..'));
    global $sugar_config;
    LogicHook::initialize();
    $GLOBALS['logic_hook']->call_custom_logic('', 'server_round_trip');
    //added this check to avoid errors during install.
    if (empty($sugar_config['dbconfig'])) {
        if ($exit) {
            exit;
        } else {
            return;
        }
    }
    if (!class_exists('Tracker', true)) {
        require_once 'modules/Trackers/Tracker.php';
    }
    Tracker::logPage();
    // Now write the cached tracker_queries
    if (!empty($GLOBALS['savePreferencesToDB']) && $GLOBALS['savePreferencesToDB']) {
        if (!class_exists('UserPreference', true)) {
        }
        UserPreference::savePreferencesToDB();
    }
    pre_login_check();
    if (class_exists('DBManagerFactory')) {
        $db = DBManagerFactory::getInstance();
        $db->disconnect();
        if ($exit) {
            exit;
        }
    }
}
開發者ID:nerdystudmuffin,項目名稱:dashlet-subpanels,代碼行數:39,代碼來源:utils.php

示例12: setUp

 public function setUp()
 {
     $this->bean = new Account();
     Bug52113TestHook::$count = 0;
     LogicHook::refreshHooks();
 }
開發者ID:newLoki,項目名稱:sugarcrm_dev,代碼行數:6,代碼來源:Bug52133Test.php

示例13: session_id

        if (!empty($_COOKIE['PHPSESSID']) && strcmp($_GET['PHPSESSID'], $_COOKIE['PHPSESSID']) == 0) {
            session_id($_REQUEST['PHPSESSID']);
        } else {
            unset($_GET['PHPSESSID']);
        }
    }
    if (!empty($sugar_config['session_dir'])) {
        session_save_path($sugar_config['session_dir']);
    }
    SugarApplication::preLoadLanguages();
    $timedate = TimeDate::getInstance();
    $GLOBALS['sugar_version'] = $sugar_version;
    $GLOBALS['sugar_flavor'] = $sugar_flavor;
    $GLOBALS['timedate'] = $timedate;
    $GLOBALS['js_version_key'] = md5($GLOBALS['sugar_config']['unique_key'] . $GLOBALS['sugar_version'] . $GLOBALS['sugar_flavor']);
    $db = DBManagerFactory::getInstance();
    $db->resetQueryCount();
    $locale = new Localization();
    // Emails uses the REQUEST_URI later to construct dynamic URLs.
    // IIS does not pass this field to prevent an error, if it is not set, we will assign it to ''.
    if (!isset($_SERVER['REQUEST_URI'])) {
        $_SERVER['REQUEST_URI'] = '';
    }
    $current_user = new User();
    $current_entity = null;
    $system_config = new Administration();
    $system_config->retrieveSettings();
    LogicHook::instance()->call_custom_logic('core', 'after_entry_point');
}
////	END SETTING DEFAULT VAR VALUES
///////////////////////////////////////////////////////////////////////////////
開發者ID:butschster,項目名稱:sugarcrm_dev,代碼行數:31,代碼來源:entryPoint.php

示例14: process

 /**
  * This method will be called from the controller and is not meant to be overridden.
  */
 public function process()
 {
     LogicHook::initialize();
     $this->_checkModule();
     //trackView has to be here in order to track for breadcrumbs
     $this->_trackView();
     if ($this->_getOption('show_header')) {
         $this->displayHeader();
     } else {
         $this->renderJavascript();
     }
     $this->_buildModuleList();
     $this->preDisplay();
     $this->displayErrors();
     $this->display();
     if (!empty($this->module)) {
         $GLOBALS['logic_hook']->call_custom_logic($this->module, 'after_ui_frame');
     }
     $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_frame');
     if ($this->_getOption('show_subpanels')) {
         $this->_displaySubPanels();
     }
     if ($this->action === 'Login') {
         //this is needed for a faster loading login page ie won't render unless the tables are closed
         ob_flush();
     }
     if ($this->_getOption('show_footer')) {
         $this->displayFooter();
     }
     $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_footer');
     //Do not track if there is no module or if module is not a String
     $this->_track();
 }
開發者ID:nartnik,項目名稱:sugarcrm_test,代碼行數:36,代碼來源:SugarView.php

示例15: userAfterAuthenticate

 /**
  * Sets up a user after successful authentication and session setup
  *
  * @returns bool Was the login successful
  */
 protected function userAfterAuthenticate($userId, $oauthServer)
 {
     $valid = false;
     if (!empty($GLOBALS['current_user'])) {
         $valid = true;
         $GLOBALS['logic_hook']->call_custom_logic('', 'after_load_user');
     }
     if ($GLOBALS['current_user']->status == 'Inactive' || $GLOBALS['current_user']->deleted == true) {
         $valid = false;
     }
     if ($valid) {
         SugarApplication::trackLogin();
         // Setup visibility where needed
         $oauthServer->setupVisibility();
         LogicHook::initialize()->call_custom_logic('', 'after_session_start');
         $this->user = $GLOBALS['current_user'];
         $this->user->setupSession();
     }
     return $valid;
 }
開發者ID:jglaine,項目名稱:sugar761-ent,代碼行數:25,代碼來源:RestService.php


注:本文中的LogicHook類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。