Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update mail method, add phpcrypt library into plugin - refs BT#9092
- Loading branch information
Daniel Barreto
committed
Feb 10, 2015
1 parent
7825df0
commit 01bea28
Showing
60 changed files
with
12,897 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dbarreto | ||
* Date: 22/12/14 | ||
* Time: 01:51 PM | ||
*/ | ||
|
||
require_once '../config.php'; | ||
|
||
$plugin = AdvancedSubscriptionPlugin::create(); | ||
$data = isset($_REQUEST['data']) ? | ||
strlen($_REQUEST['data']) > 16 ? | ||
$plugin->decrypt(Security::remove_XSS($_REQUEST['data'])) : | ||
null : | ||
null; | ||
// Get data | ||
if (isset($data) && is_array($data)) { | ||
// Action code | ||
$a = isset($data['a']) ? $data['a'] : null; | ||
// User ID | ||
$u = isset($data['u']) ? $data['u'] : null; | ||
// Session ID | ||
$s = isset($data['s']) ? $data['s'] : null; | ||
// More data | ||
$params['is_connected'] = isset($data['is_connected']) ? $data['is_connected'] : false; | ||
$params['profile_completed'] = isset($data['profile_completed']) ? $data['profile_completed'] : 0; | ||
$params['accept'] = isset($data['accept']) ? $data['accept'] : false; | ||
} else { | ||
// Action code | ||
$a = isset($_REQUEST['a']) ? Security::remove_XSS($_REQUEST['a']) : null; | ||
// User ID | ||
$u = isset($_REQUEST['u']) ? Security::remove_XSS($_REQUEST['u']) : null; | ||
// Session ID | ||
$s = isset($_REQUEST['s']) ? Security::remove_XSS($_REQUEST['s']) : null; | ||
// More data | ||
$params['is_connected'] = isset($_REQUEST['is_connected']) ? $_REQUEST['is_connected'] : false; | ||
$params['profile_completed'] = isset($_REQUEST['profile_completed']) ? $_REQUEST['profile_completed'] : 0; | ||
$params['accept'] = isset($_REQUEST['accept']) ? $_REQUEST['accept'] : false; | ||
} | ||
// Init result array | ||
$result = array('error' => true, 'errorMessage' => 'There was an error'); | ||
if (!empty($a) && !empty($u)) { | ||
switch($a) { | ||
case 'first': // Check minimum requirements | ||
try { | ||
$res = AdvancedSubscriptionPlugin::create()->isAbleToRequest($u, $params); | ||
if ($res) { | ||
$result['error'] = false; | ||
$result['errorMessage'] = 'No error'; | ||
$result['pass'] = true; | ||
} else { | ||
$result['errorMessage'] = 'User can not be subscribed'; | ||
$result['pass'] = false; | ||
} | ||
} catch (\Exception $e) { | ||
$result['errorMessage'] = $e->getMessage(); | ||
} | ||
break; | ||
case 'second': // Subscription | ||
$res = AdvancedSubscriptionPlugin::create()->startSubscription($u, $s, $params); | ||
if ($res === true) { | ||
$result['error'] = false; | ||
$result['errorMessage'] = 'No error'; | ||
$result['pass'] = true; | ||
} else { | ||
if (is_string($res)) { | ||
$result['errorMessage'] = $res; | ||
} else { | ||
$result['errorMessage'] = 'User can not be subscribed'; | ||
} | ||
$result['pass'] = false; | ||
} | ||
break; | ||
case 'third': // Encrypt | ||
$plugin = AdvancedSubscriptionPlugin::create(); | ||
$res = $plugin->encrypt($data); | ||
if (!empty($res) && strlen($res) > 16) { | ||
$result['error'] = false; | ||
$result['errorMessage'] = 'No error'; | ||
$result['pass'] = true; | ||
} else { | ||
if (is_string($res)) { | ||
$result['errorMessage'] = $res; | ||
} else { | ||
$result['errorMessage'] = 'User can not be subscribed'; | ||
} | ||
$result['pass'] = false; | ||
} | ||
break; | ||
default: | ||
$result['errorMessage'] = 'Action do not exist!'; | ||
break; | ||
} | ||
} | ||
|
||
echo json_encode($result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* This script fixes a bloody issue with passwords getting out of sync between | ||
* course-subscriber and chamilo | ||
* @package chamilo | ||
* @author Daniel Barreto <daniel.barreto@beeznest.com> | ||
*/ | ||
|
||
/** | ||
* Init | ||
*/ | ||
require_once '../../../main/inc/global.inc.php'; | ||
|
||
/** | ||
* Get database handle | ||
*/ | ||
|
||
$nowUtc = api_get_utc_datetime(); | ||
$weekAgoUtc = api_get_utc_datetime(strtotime('-1 week')); | ||
$sTable = Database::get_main_table(TABLE_MAIN_SESSION); | ||
$uUserTable = Database::get_main_table(TABLE_MAIN_SESSION_USER); | ||
$limitArea = 'limit_area'; | ||
//define('USER_RELATION_TYPE_BOSS', 8); | ||
//define('TABLE_ADV_SUB_QUEUE', 'plugin_advsub_queue'); | ||
//define('TABLE_ADV_SUB_MAIL', 'plugin_advsub_mail'); | ||
|
||
$sessionAdvSub = array(); | ||
$sessionQueue = array(); | ||
$userAdmins = array(); | ||
|
||
$advSubQueueTable = TABLE_ADVSUB_QUEUE; | ||
$advSubMailTable = TABLE_ADVSUB_MAIL; | ||
$advSubMails = Database::select('id, created_at, user_id, status', $advSubMailTable); | ||
$advSubQueue = Database::select('id, status_id, user_id, updated_at', $advSubQueueTable, array('where' => array('start_date > ?' => $nowUtc))); | ||
$sessionIds = Database::select('id', $sTable, array('where' => array('start_date > ?' => $nowUtc))); | ||
$users = Database::select('user_id ASS boss_id, friend_user_id AS id', $uUserTable, array('where' => array('relation_type = ?' => USER_RELATION_TYPE_BOSS))); | ||
$sField = new ExtraField('session'); | ||
$sFieldValue = new ExtraFieldValue('session'); | ||
$areaCounts = array(); | ||
foreach ($users as $userId => $bossId) { | ||
$areaCounts[$bossId] ++; | ||
} | ||
foreach ($advSubMails as $id => $advSubMail) { | ||
$userSubMail[$advSubMail['user_id']][] = $id; | ||
} | ||
foreach ($sessionIds as $sessionId) { | ||
$bossId = $advSubQueue[$sessionQueue[$sessionId]]['user_id']; | ||
$sLimitArea = $sFieldValue->get_values_by_handler_and_field_variable($sessionId, $limitArea); | ||
if ($sLimitArea > $sQueueCount[$bossId]) { | ||
// Register data | ||
$chooseUser = true; | ||
} | ||
if ($advSubMail[end($userSubMail[$bossId])]['created_at'] < $weekAgoUtc) { | ||
// Send mail again | ||
// Session x Boss -> user, status, buttons | ||
if ($chooseUser) { | ||
// Use choose user tpl | ||
} | ||
} | ||
foreach ($userAdmins as $adminId => $userAdmin) { | ||
if ($advSubMail[end($userSubMail[$adminId])]['created_at'] < $weekAgoUtc) { | ||
// send queue status 2 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.project | ||
/.directory | ||
test/ |
Oops, something went wrong.