[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9095] registration: approve pending users
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9095] registration: approve pending users |
Date: |
Tue, 03 Apr 2012 13:46:28 +0000 |
Revision: 9095
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9095
Author: sigurdne
Date: 2012-04-03 13:46:28 +0000 (Tue, 03 Apr 2012)
Log Message:
-----------
registration: approve pending users
Modified Paths:
--------------
trunk/property/inc/class.hook_helper.inc.php
trunk/property/setup/setup.inc.php
trunk/registration/inc/class.bopending.inc.php
trunk/registration/inc/class.boreg.inc.php
trunk/registration/inc/class.soreg.inc.php
Modified: trunk/property/inc/class.hook_helper.inc.php
===================================================================
--- trunk/property/inc/class.hook_helper.inc.php 2012-04-03 12:46:01 UTC
(rev 9094)
+++ trunk/property/inc/class.hook_helper.inc.php 2012-04-03 13:46:28 UTC
(rev 9095)
@@ -44,4 +44,27 @@
$message =lang('%1 userlists cleared from
cache',$cleared);
phpgwapi_cache::message_set($message, 'message');
}
+
+ /**
+ * Add a contact to a location
+ *
+ * @return void
+ */
+ public function add_location_contact($data)
+ {
+ $value_set = array();
+ $value_set['location_code'] = $data['location_code'];
+ $value_set['contact_id'] = $data['contact_id'];
+ $value_set['user_id'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $value_set['entry_date'] = time();
+ $value_set['modified_date'] = time();
+
+ $cols = implode(',', array_keys($value_set));
+ $values =
$GLOBALS['phpgw_setup']->oProc->validate_insert(array_values($value_set));
+ $sql = "INSERT INTO fm_location_contact ({$cols})
VALUES ({$values})";
+ $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+
+ $message =lang('user %1 added to
%2',$data['account_lid'],$data['location_code']);
+ phpgwapi_cache::message_set($message, 'message');
+ }
}
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2012-04-03 12:46:01 UTC (rev 9094)
+++ trunk/property/setup/setup.inc.php 2012-04-03 13:46:28 UTC (rev 9095)
@@ -221,7 +221,8 @@
'deleteaccount' => 'property.hook_helper.clear_userlist',
'addgroup' =>
'property.hook_helper.clear_userlist',
'deletegroup' => 'property.hook_helper.clear_userlist',
- 'editgroup' => 'property.hook_helper.clear_userlist'
+ 'editgroup' =>
'property.hook_helper.clear_userlist',
+ 'registration' => 'property.hook_helper.add_location_contact'
);
/* Dependencies for this app to work */
Modified: trunk/registration/inc/class.bopending.inc.php
===================================================================
--- trunk/registration/inc/class.bopending.inc.php 2012-04-03 12:46:01 UTC
(rev 9094)
+++ trunk/registration/inc/class.bopending.inc.php 2012-04-03 13:46:28 UTC
(rev 9095)
@@ -236,8 +236,79 @@
* @return array receipt
*/
- function process_users($values)
+ function process_users($data)
{
+ $so = createobject('registration.soreg');
+ $ui = createobject('registration.uireg');
+
+ $process_approval = array();
+ if(isset($data['pending_users']) &&
is_array($data['pending_users']))
+ {
+ foreach($data['pending_users'] as $reg_id)
+ {
+ $process_approval[] = $reg_id;
+ }
+ }
+
+ unset($reg_id);
+
+ $url = $GLOBALS['phpgw']->link('/login.php',array(
'logindomain' => $GLOBALS['phpgw_info']['user']['domain']),false,true);
+
+ if ($this->config['support_email'])
+ {
+ $support_email_text = lang ('Report all
problems and abuse to');
+ $support_email =
$this->config['support_email'];
+ }
+
+ $smtp = createobject('phpgwapi.send');
+ $subject = $this->config['subject_confirm'] ?
lang($this->config['subject_confirm']) : lang('Account registration');
+ $noreply = $this->config['mail_nobody'] ? ('No reply <'
. $this->config['mail_nobody'] . '>') : ('No reply <noreply@' .
$GLOBALS['phpgw_info']['server']['hostname'] . '>');
+
+ foreach ($process_approval as $reg_id)
+ {
+ $reg_info = $so->valid_reg($reg_id);
+
+ if (!$reg_info || ! $reg_info['reg_approved'])
+ {
+ continue;
+ }
+
+
if($so->create_account($reg_info['reg_lid'],$reg_info['reg_info']))
+ {
+ $info =
unserialize(base64_decode($reg_info['reg_info']));
+ unset($info['passwd']);
+ unset($info['passwd_confirm']);
+
+ $body = <<<HTML
+
+ Hi {$info['n_given']} {$info['n_family']},
+
+ This is a confirmation email for your new account on
{$GLOBALS['phpgw_info']['server']['system_name']}::{$GLOBALS['phpgw_info']['server']['site_title']}.
+ Click on the following link to log into your account.
+
+ <a href='$url'>Login.</a>
+
+ If you did not request this account, simply ignore this message.
+ {$support_email_text} {$support_email}
+
+HTML;
+ try
+ {
+ $info['email'] =
'address@hidden';
+ $rcpt =
$smtp->msg('email',$info['email'],$subject,nl2br($body),'','','',$noreply,'','html');
+ }
+ catch(Exception $e)
+ {
+
phpgwapi_cache::message_set($e->getMessage(), 'error');
+ }
+
+ if($rcpt)
+ {
+
phpgwapi_cache::message_set("Confirmation sent to {$info['email']}", 'message');
+ }
+ // $so->delete_reg_info($reg_id);
+ }
+ }
}
/**
@@ -248,7 +319,6 @@
* @return array receipt
*/
-
function edit($values)
{
$receipt = $this->so->edit($values);
Modified: trunk/registration/inc/class.boreg.inc.php
===================================================================
--- trunk/registration/inc/class.boreg.inc.php 2012-04-03 12:46:01 UTC (rev
9094)
+++ trunk/registration/inc/class.boreg.inc.php 2012-04-03 13:46:28 UTC (rev
9095)
@@ -241,7 +241,7 @@
$ui = createobject('registration.uireg');
$reg_info = $so->valid_reg($reg_id);
- if (! is_array($reg_info))
+ if (!$reg_info)
{
$ui->simple_screen('error_confirm.tpl');
return False;
@@ -259,7 +259,7 @@
{
$so = createobject('registration.soreg');
$reg_info = $so->valid_reg($reg_id);
- if($reg_info['reg_info'])
+ if(isset($reg_info['reg_info']) &&
$reg_info['reg_info'])
{
$reg_info['reg_info'] =
unserialize(base64_decode($reg_info['reg_info']));
unset($reg_info['reg_info']['passwd']);
@@ -320,7 +320,7 @@
$ui = createobject('registration.uireg');
$reg_info = $so->valid_reg($reg_id);
- if (! is_array($reg_info))
+ if (!$reg_info)
{
$ui->simple_screen('error_confirm.tpl');
return False;
Modified: trunk/registration/inc/class.soreg.inc.php
===================================================================
--- trunk/registration/inc/class.soreg.inc.php 2012-04-03 12:46:01 UTC (rev
9094)
+++ trunk/registration/inc/class.soreg.inc.php 2012-04-03 13:46:28 UTC (rev
9095)
@@ -216,12 +216,13 @@
function valid_reg($reg_id)
{
+ $values = array();
$this->db->query("SELECT * FROM phpgw_reg_accounts
WHERE reg_id='$reg_id'",__LINE__,__FILE__);
$this->db->next_record();
-
if ($this->db->f('reg_id'))
{
- return array(
+ $values = array
+ (
'reg_id' =>
$this->db->f('reg_id'),
'reg_lid' =>
$this->db->f('reg_lid'),
'reg_info' =>
$this->db->f('reg_info'),
@@ -229,10 +230,7 @@
'reg_approved' =>
$this->db->f('reg_approved')
);
}
- else
- {
- echo False;
- }
+ return $values;
}
function delete_reg_info($reg_id)
@@ -243,7 +241,7 @@
function create_account($account_lid,$_reg_info)
{
$fields =
unserialize(base64_decode($_reg_info));
-//_debug_array($fields);
+
$fields['lid'] = "*$account_lid*";
$default_group_id = $this->config['default_group_id'];
@@ -277,7 +275,7 @@
if (!$account_id)
{
- return False;
+ return false;
}
$contacts = createobject('phpgwapi.contacts');
@@ -351,12 +349,31 @@
$GLOBALS['phpgw']->accounts->account = $account;
$GLOBALS['phpgw']->accounts->save_repository();
- if(isset($this->config['messenger_welcome_message']) &&
$this->config['messenger_welcome_message'] &&
isset($GLOBALS['phpgw_info']['apps']['messenger']))
+ if(isset($this->config['messenger_welcome_message']) &&
$this->config['messenger_welcome_message'])
{
- if(@stat(PHPGW_SERVER_ROOT .
'/messenger/inc/hook_registration.inc.php'))
- {
- include(PHPGW_SERVER_ROOT .
'/messenger/inc/hook_registration.inc.php');
- }
+ $args = array
+ (
+ 'location' =>
'registration',
+ 'message' =>
$this->config['messenger_welcome_message'],
+ 'account_lid' => $account_lid
+ );
+
+ $GLOBALS['phpgw']->hooks->single($args,
'registration');
}
+
+ if(isset($fields['location_code']) &&
$fields['location_code'])
+ {
+ $args = array
+ (
+ 'location' =>
'add_location_contact',
+ 'location_code' =>
$fields['location_code'],
+ 'contact_id' => $person_id,
+ 'account_lid' => $account_lid
+ );
+
+ $GLOBALS['phpgw']->hooks->single($args,
'property');
+ }
+
+ return $account_id;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9095] registration: approve pending users,
Sigurd Nes <=