Sfoglia il codice sorgente

Merge branch 'master' of https://github.com/boonex/dolphin

AntonLV 12 anni fa
parent
commit
dc856d38f7

+ 16 - 0
inc/classes/BxDolAccountQuery.php

@@ -181,6 +181,22 @@ class BxDolAccountQuery extends BxDolDb implements iBxDolSingleton {
         $sSql = $this->prepare("DELETE FROM `sys_accounts` WHERE `id` = ? LIMIT 1", $iID);
         return $this->query($sSql);
     }
+
+    /**
+     * Search account profile by keyword
+     */
+    public function searchByTerm($sTerm, $iLimit) 
+    {
+        $aFieldsQuickSearch = array('name', 'email');
+        $sWhere = '';
+        foreach ($aFieldsQuickSearch as $sField)
+            $sWhere .= $this->prepare(" OR `c`.`$sField` LIKE ? ", '%' . $sTerm . '%');
+
+        $sOrderBy = $this->prepare(" ORDER BY `added` DESC LIMIT ?", (int)$iLimit);
+
+        $sQuery = $this->prepare("SELECT `c`.`id` AS `content_id`, `p`.`account_id`, `p`.`id` AS `profile_id`, `p`.`status` AS `profile_status` FROM `sys_accounts` AS `c` INNER JOIN `sys_profiles` AS `p` ON (`p`.`content_id` = `c`.`id` AND `p`.`type` = ?) WHERE `p`.`status` = ?", 'system', BX_PROFILE_STATUS_ACTIVE);
+        return $this->getAll($sQuery . " AND (0 $sWhere) " . $sOrderBy);
+    }
 }
 
 /** @} */

+ 4 - 4
inc/classes/BxDolAcl.php

@@ -521,8 +521,8 @@ class BxDolAcl extends BxDol implements iBxDolSingleton {
     	    $this->oDb->deleteLevelByProfileId($iProfileId, true); ///< Delete any profile's membership level
 
         // set lifetime membership if 0 days is used.
-        $iDateExpires = $iDays != 0 ? (int)$iDateStarts + $iDays * $iSecInDay : 'NULL';
-    	if(!$this->insertLevelByProfileId($iProfileId, $iLevelId, $iDateStarts, $iDateExpires, $sTransactionId))
+        $iDateExpires = $iDays != 0 ? (int)$iDateStarts + $iDays * $iSecInDay : null;
+    	if(!$this->oDb->insertLevelByProfileId($iProfileId, $iLevelId, $iDateStarts, $iDateExpires, $sTransactionId))
     	   return false;
 
     	// raise membership alert
@@ -532,7 +532,7 @@ class BxDolAcl extends BxDol implements iBxDolSingleton {
     	
     	// Send notification
     	bx_import('BxDolEmailTemplates');
-        $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_MemChanged', array('membership_level' => $aLevel['name']), 0, $iProfileId);            
+        $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_MemChanged', array('membership_level' => _t($aLevel['name'])), 0, $iProfileId);
         if ($aTemplate)
             sendMail($sProfileEmail, $aTemplate['Subject'], $aTemplate['Body']);
 
@@ -665,7 +665,7 @@ class BxDolAcl extends BxDol implements iBxDolSingleton {
         $aMembership = $aMembershipCurrent;
         while ($aMembership['id'] != MEMBERSHIP_ID_STANDARD) {
             $aMembershipLast = $aMembership;
-            if((int)$aMembership['DateExpires'] == 0)
+            if(!isset($aMembership['DateExpires']) || (int)$aMembership['DateExpires'] == 0)
                 break;
 
             $aMembership = $this->getMemberMembershipInfoCurrent($iProfileId, $aMembership['date_expires']);

+ 1 - 1
inc/classes/BxDolAclQuery.php

@@ -246,7 +246,7 @@ class BxDolAclQuery extends BxDolDb implements iBxDolSingleton {
     }
 
     function insertLevelByProfileId($iProfileId, $iMembershipId, $iDateStarts, $iDateExpires, $sTransactionId) {
-        $sQuery = $this->prepare("INSERT `sys_acl_levels_members` (`IDMember`, `IDLevel`, `DateStarts`, `DateExpires`, `TransactionID`) VALUES (?, ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?), '?')", $iProfileId, $iMembershipId, $iDateStarts, $iDateExpires, $sTransactionId);
+        $sQuery = $this->prepare("INSERT `sys_acl_levels_members` (`IDMember`, `IDLevel`, `DateStarts`, `DateExpires`, `TransactionID`) VALUES (?, ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?), ?)", $iProfileId, $iMembershipId, $iDateStarts, $iDateExpires, $sTransactionId);
     	return (int)$this->query($sQuery) > 0;
     }
 

+ 25 - 0
inc/js/functions.js

@@ -284,6 +284,29 @@ function bx_menu_popup_inline (jSel, e, options) {
         $(jSel).dolPopup(o);
 }
 
+/**
+ * Show pointer popup with menu from URL.
+ * @param iProfileId - profile id to set acl level for
+ * @param iAclLevel - acl level id to assign to a given rofile
+ */
+function bx_set_acl_level (iProfileId, iAclLevel, mixedLoadingElement) {
+
+    if ('undefined' != typeof(mixedLoadingElement))
+        bx_loading($(mixedLoadingElement), true);
+
+    $.post(sUrlRoot + 'menu.php', {o:'sys_set_acl_level', 'profile_id': iProfileId, 'acl_level_id': iAclLevel}, function(data) {
+
+        if ('undefined' != typeof(mixedLoadingElement))
+            bx_loading($(mixedLoadingElement), false);
+
+        if (data.length) {
+            alert(data);
+        } else if ($(mixedLoadingElement).hasClass('bx-popup-applied')) {
+            $(mixedLoadingElement).dolPopupHide().remove();
+        }
+    });
+}
+
 function validateLoginForm(eForm) {
     return true;
 }
@@ -471,3 +494,5 @@ function on_filter_key_up (e, sCheckboxId)
         return true;
     }
 }
+
+

+ 3 - 3
inc/utils.inc.php

@@ -789,10 +789,10 @@ function encryptUserPwd($sPwd, $sSalt) {
     return sha1(md5($sPwd) . $sSalt);
 }
 
-function bx_get ($sName) {
-    if (isset($_GET[$sName]))
+function bx_get ($sName, $sMethod = false) {
+    if (isset($_GET[$sName]) && ('get' == $sMethod || !$sMethod))
         return $_GET[$sName];
-    elseif (isset($_POST[$sName]))
+    elseif (isset($_POST[$sName]) && ('post' == $sMethod || !$sMethod))
         return $_POST[$sName];
     else
         return false;

+ 10 - 2
install/sql/system.sql

@@ -460,6 +460,10 @@ INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`,
 ('system', 'delete account', NULL, '_sys_acl_action_delete_account', '_sys_acl_action_delete_account_desc', 0, 2147483646);
 SET @iIdActionAccountDelete = LAST_INSERT_ID();
 
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+('system', 'set acl level', NULL, '_sys_acl_action_set_acl_level', '_sys_acl_action_set_acl_level_desc', 0, 2147483646);
+SET @iIdActionSetAclLevel = LAST_INSERT_ID();
+
 
 CREATE TABLE `sys_acl_actions_track` (
   `IDAction` int(10) unsigned NOT NULL DEFAULT '0',
@@ -534,7 +538,10 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 (@iPending, @iIdActionAccountDelete),
 (@iModerator, @iIdActionAccountDelete),
 (@iAdministrator, @iIdActionAccountDelete),
-(@iPremium, @iIdActionAccountDelete);
+(@iPremium, @iIdActionAccountDelete),
+
+-- set acl level
+(@iAdministrator, @iIdActionSetAclLevel);
 
 
 CREATE TABLE `sys_acl_levels` (
@@ -2564,7 +2571,8 @@ INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `templa
 ('sys_account_notifications', '_sys_menu_title_account_notifications', 'sys_account_notifications', 'system', 13, 0, 1, 'BxTemplMenuAccountNotifications', ''),
 ('sys_profile_stats', '_sys_menu_title_profile_stats', 'sys_profile_stats', 'system', 6, 0, 1, 'BxTemplMenuProfileStats', ''),
 ('sys_switch_language', '_sys_menu_title_switch_language', 'sys_switch_language', 'system', 6, 0, 1, 'BxTemplMenuSwitchLanguage', ''),
-('sys_switch_template', '_sys_menu_title_switch_template', 'sys_switch_template', 'system', 6, 0, 1, 'BxTemplMenuSwitchTemplate', '');
+('sys_switch_template', '_sys_menu_title_switch_template', 'sys_switch_template', 'system', 6, 0, 1, 'BxTemplMenuSwitchTemplate', ''),
+('sys_set_acl_level', '_sys_menu_title_set_acl_level', '', 'system', 6, 0, 1, 'BxTemplMenuSetAclLevel', '');
 
 CREATE TABLE IF NOT EXISTS `sys_menu_sets` (
   `set_name` varchar(64) NOT NULL,

+ 17 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -172,6 +172,23 @@ class BxBaseModGeneralModule extends BxDolModule
         return _t('_sys_txt_access_denied');
     }
 
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedSetMembership (&$aDataEntry, $isPerformAction = false) 
+    {
+        // admin always has access
+        if (isAdmin($this->_iProfileId))
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+        // check ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'set acl level', 'system', $isPerformAction);
+        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return $aCheck[CHECK_ACTION_MESSAGE];
+
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
     // ====== PROTECTED METHODS
 
     protected function _serviceBrowse ($sMode, $aParams = false, $iDesignBox = BX_DB_PADDING_DEF, $bDisplayEmptyMsg = false, $bAjaxPaginate = true) 

+ 10 - 7
modules/boonex/english/data/langs/system.xml

@@ -1313,13 +1313,15 @@
 	<string name="_sys_acl_action_delete_account"><![CDATA[Delete Account]]></string>
 	<string name="_sys_acl_action_delete_account_desc"><![CDATA[Delete account also deletes account's content.]]></string>
 	<string name="_sys_acl_action_every_period"><![CDATA[ every {4} hours]]></string>
-	<string name="_sys_acl_action_limit_reached"><![CDATA[You have reached your limit for now. Your current membership (<b>{2}</b>) allows you to {1} no more than {3} times]]></string>
-	<string name="_sys_acl_action_not_allowed"><![CDATA[Your current membership (<b>{2}</b>) doesn't allow you to <b>{1}</b>.]]></string>
-	<string name="_sys_acl_action_not_allowed_after"><![CDATA[Your current membership (<b>{2}</b>) stopped to allow you to <b>{1}</b> <b>{5}</b>.]]></string>
-	<string name="_sys_acl_action_not_allowed_before"><![CDATA[Your current membership (<b>{2}</b>) will allow you to <b>{1}</b> <b>{6}</b>.]]></string>
+	<string name="_sys_acl_action_limit_reached"><![CDATA[You have reached your limit for now. Your current membership ({2}) allows you to {1} no more than {3} times]]></string>
+	<string name="_sys_acl_action_not_allowed"><![CDATA[Your current membership ({2}) doesn't allow you to '{1}'.]]></string>
+	<string name="_sys_acl_action_not_allowed_after"><![CDATA[Your current membership ({2}) stopped to allow you to '{1}' {5}.]]></string>
+	<string name="_sys_acl_action_not_allowed_before"><![CDATA[Your current membership ({2}) will allow you to '{1}' {6}.]]></string>
 	<string name="_sys_acl_action_pending"><![CDATA[You are currently not an active member. Please, ask the site <a href="mailto:{7}">administrator</a> to make you an active member so you would be able to <b>{1}</b>.]]></string>
-	<string name="_sys_acl_action_suspended"><![CDATA[You can't <b>{1}</b> becuase your profile was suspended, if you don't know why - try to send message to <a href="mailto:{7}">administrator</a>.]]></string>
-	<string name="_sys_acl_action_unauthenticated"><![CDATA[Not logged in users can't <b>{1}</b>.]]></string>
+	<string name="_sys_acl_action_set_acl_level"><![CDATA[Set membership level]]></string>
+	<string name="_sys_acl_action_set_acl_level_desc"><![CDATA[Set membership level for profiles]]></string>
+	<string name="_sys_acl_action_suspended"><![CDATA[You can't '{1}' becuase your profile was suspended, if you don't know why - try to send message to <a href="mailto:{7}">administrator</a>.]]></string>
+	<string name="_sys_acl_action_unauthenticated"><![CDATA[Not logged in users can't '{1}'.]]></string>
 	<string name="_sys_acl_action_unconfirmed"><![CDATA[You didn't confirm your profile. Please check your email with profile activation link. Unconfirmed members can't <b>{1}</b>.]]></string>
 	<string name="_sys_acl_action_vote"><![CDATA[Vote]]></string>
 	<string name="_sys_add_friend"><![CDATA[Add friend]]></string>
@@ -1434,7 +1436,6 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_et_txt_body_mem_changed"><![CDATA[<bx_include_auto:_email_header.html />
 <p>Hello,</p>
 <p>Your membership level was changed to: <b>{membership_level}</b></p>
-<p>Please refer to membership page for more details: <a href="{site_url}modules/?r=membership/index/">My Membership</a></p>
 <bx_include_auto:_email_footer.html />]]></string>
 	<string name="_sys_et_txt_body_mem_expiration"><![CDATA[<bx_include_auto:_email_header.html />
 <p>Hello,</p>
@@ -1688,6 +1689,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_item_title_logout"><![CDATA[Sign out]]></string>
 	<string name="_sys_menu_item_title_more"><![CDATA[More]]></string>
 	<string name="_sys_menu_item_title_profile"><![CDATA[Profile]]></string>
+	<string name="_sys_menu_item_title_set_acl_level"><![CDATA[Set membership]]></string>
 	<string name="_sys_menu_item_title_system_about"><![CDATA[About]]></string>
 	<string name="_sys_menu_item_title_system_switch_language"><![CDATA[Language]]></string>
 	<string name="_sys_menu_item_title_system_switch_template"><![CDATA[Template]]></string>
@@ -1710,6 +1712,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_item_title_system_main_menu"><![CDATA[Main Menu]]></string>
 	<string name="_sys_menu_item_title_system_more"><![CDATA[More]]></string>
 	<string name="_sys_menu_item_title_system_profile"><![CDATA[Profile]]></string>
+	<string name="_sys_menu_item_title_system_set_acl_level"><![CDATA[Set membership]]></string>
 	<string name="_sys_menu_set_title_account"><![CDATA[Account]]></string>
 	<string name="_sys_menu_set_title_account_settings"><![CDATA[Account Settings]]></string>
 	<string name="_sys_menu_set_title_account_settings_more"><![CDATA[Account Settings More]]></string>

+ 1 - 0
modules/boonex/organizations/classes/BxOrgsConfig.php

@@ -26,6 +26,7 @@ class BxOrgsConfig extends BxBaseModProfileConfig
             'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
             'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
             'profile-actions-more' => 'checkAllowedViewMoreMenu',
+            'profile-set-acl-level' => 'checkAllowedSetMembership',
         );
 
         $this->CNF = array (

+ 2 - 1
modules/boonex/organizations/install/sql/enable.sql

@@ -118,7 +118,8 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('bx_organizations_view_actions', 'bx_organizations', 'profile-friend-add', '_bx_orgs_menu_item_title_system_befriend', '{title_add_friend}', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_friends\', \'add\', \'{profile_id}\')', '', 'plus', '', 2147483647, 1, 0, 10),
 ('bx_organizations_view_actions', 'bx_organizations', 'profile-subscribe-add', '_bx_orgs_menu_item_title_system_subscribe', '_bx_orgs_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'check', '', 2147483647, 1, 0, 20),
-('bx_organizations_view_actions', 'bx_organizations', 'profile-actions-more', '_bx_orgs_menu_item_title_system_more_actions', '_bx_orgs_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_organizations_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_organizations_view_actions_more', 2147483647, 1, 0, 30);
+('bx_organizations_view_actions', 'bx_organizations', 'profile-set-acl-level', '_sys_menu_item_title_system_set_acl_level', '_sys_menu_item_title_set_acl_level', 'javascript:void(0)', 'bx_menu_popup(''sys_set_acl_level'', window, {}, {profile_id: {profile_id}});', '', 'certificate', '', 64, 1, 0, 1000),
+('bx_organizations_view_actions', 'bx_organizations', 'profile-actions-more', '_bx_orgs_menu_item_title_system_more_actions', '_bx_orgs_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_organizations_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_organizations_view_actions_more', 2147483647, 1, 0, 9999);
 
 -- MENU: view actions more
 

+ 1 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -26,6 +26,7 @@ class BxPersonsConfig extends BxBaseModProfileConfig
             'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
             'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
             'profile-actions-more' => 'checkAllowedViewMoreMenu',
+            'profile-set-acl-level' => 'checkAllowedSetMembership',
         );
 
         $this->CNF = array (

+ 2 - 1
modules/boonex/persons/install/sql/enable.sql

@@ -118,7 +118,8 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('bx_persons_view_actions', 'bx_persons', 'profile-friend-add', '_bx_persons_menu_item_title_system_befriend', '{title_add_friend}', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_friends\', \'add\', \'{profile_id}\')', '', 'plus', '', 2147483647, 1, 0, 10),
 ('bx_persons_view_actions', 'bx_persons', 'profile-subscribe-add', '_bx_persons_menu_item_title_system_subscribe', '_bx_persons_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'check', '', 2147483647, 1, 0, 20),
-('bx_persons_view_actions', 'bx_persons', 'profile-actions-more', '_bx_persons_menu_item_title_system_more_actions', '_bx_persons_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_persons_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_persons_view_actions_more', 2147483647, 1, 0, 30);
+('bx_persons_view_actions', 'bx_persons', 'profile-set-acl-level', '_sys_menu_item_title_system_set_acl_level', '_sys_menu_item_title_set_acl_level', 'javascript:void(0)', 'bx_menu_popup(''sys_set_acl_level'', window, {}, {profile_id: {profile_id}});', '', 'certificate', '', 64, 1, 0, 1000),
+('bx_persons_view_actions', 'bx_persons', 'profile-actions-more', '_bx_persons_menu_item_title_system_more_actions', '_bx_persons_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_persons_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_persons_view_actions_more', 2147483647, 1, 0, 9999);
 
 -- MENU: view actions more
 

+ 22 - 0
modules/boonex/uni/data/template/system/scripts/BxTemplMenuSetAclLevel.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxBaseMenuSetAclLevel');
+
+/**
+ * @see BxDolMenu
+ */
+class BxTemplMenuSetAclLevel extends BxBaseMenuSetAclLevel {
+
+    public function __construct ($aObject, $oTemplate = false) {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 49 - 0
plugins/phpmailer/PHPMailerAutoload.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * PHPMailer SPL autoloader.
+ * PHP Version 5
+ * @package PHPMailer
+ * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
+ * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
+ * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
+ * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
+ * @author Brent R. Matzelle (original founder)
+ * @copyright 2012 - 2014 Marcus Bointon
+ * @copyright 2010 - 2012 Jim Jagielski
+ * @copyright 2004 - 2009 Andy Prevost
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ * @note This program is distributed in the hope that it will be useful - WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/**
+ * PHPMailer SPL autoloader.
+ * @param string $classname The name of the class to load
+ */
+function PHPMailerAutoload($classname)
+{
+    //Can't use __DIR__ as it's only in PHP 5.3+
+    $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
+    if (is_readable($filename)) {
+        require $filename;
+    }
+}
+
+if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
+    //SPL autoloading was introduced in PHP 5.1.2
+    if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+        spl_autoload_register('PHPMailerAutoload', true, true);
+    } else {
+        spl_autoload_register('PHPMailerAutoload');
+    }
+} else {
+    /**
+     * Fall back to traditional autoload for old PHP versions
+     * @param string $classname The name of the class to load
+     */
+    function __autoload($classname)
+    {
+        PHPMailerAutoload($classname);
+    }
+}

+ 88 - 0
template/scripts/BxBaseMenuSetAclLevel.php

@@ -0,0 +1,88 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Menu to set acl level for profile
+ */
+class BxBaseMenuSetAclLevel extends BxTemplMenu 
+{
+    public function __construct ($aObject, $oTemplate) 
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function getCode () 
+    {
+        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && ($iProfileId = bx_get('profile_id', 'post')) && ($iAclLevelId = bx_get('acl_level_id', 'post'))) {
+
+            $sMsg = '';
+            bx_import('BxDolAcl');
+            
+            $aCheck = checkActionModule($iProfileId, 'set acl level', 'system', false);
+            if (isAdmin() || $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED) {
+
+                $oAcl = BxDolAcl::getInstance();
+                if ($oAcl->setMembership($iProfileId, $iAclLevelId, 0, true))
+                    checkActionModule($iProfileId, 'delete account', 'system', true); // perform action
+                else
+                    $sMsg = _t('_error occured');
+                
+            } else {
+                $sMsg = $aCheck[CHECK_ACTION_MESSAGE];
+            }
+
+            header('Content-type: text/html; charset=utf-8');
+            echo $sMsg;
+            exit;
+        }
+
+        return parent::getCode ();
+    }
+
+    public function getMenuItems () 
+    {
+		$this->loadData();
+    	return parent::getMenuItems();
+    }
+
+	protected function loadData() 
+    {
+        $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+
+        bx_import('BxDolAcl');
+        $oAcl = BxDolAcl::getInstance();
+        if (!$oAcl)
+            return;
+
+        $aProfileAclLevel = $oAcl->getMemberMembershipInfo($iProfileId);
+        $aAclLevels = $oAcl->getMemberships(false, true);
+
+
+        $this->setSelected('', $aProfileAclLevel['id']);
+
+        $aItems = array();
+        foreach ($aAclLevels as $iId => $sTitle) {        	
+        	$aItems[] = array(
+        		'id' => $iId, 
+        		'name' => $iId,
+        		'class' => '', 
+        		'title' => $sTitle, 
+        		'icon' => '',
+        		'link' => 'javascript:void(0);',
+        		'onclick' => "bx_set_acl_level({$iProfileId}, {$iId}, '#bx-popup-ajax-wrapper-sys_set_acl_level');"
+        	);
+        }
+
+        $this->_aObject['menu_items'] = $aItems;
+    }
+}
+
+/** @} */