Userbase-programmers
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
May 2011
- 6 participants
- 108 discussions
Author: cwalker
Date: 2011-05-02 13:34:29 -0500 (Mon, 02 May 2011)
New Revision: 84
Added:
core/ssh2.php
Modified:
modules/core/event_script.php
Log:
missing ssh lib, missing exec order in queue
Added: core/ssh2.php
===================================================================
--- core/ssh2.php (rev 0)
+++ core/ssh2.php 2011-05-02 18:34:29 UTC (rev 84)
@@ -0,0 +1,288 @@
+<?php
+// +----------------------------------------------------------------------+
+// | SSH2 1.3 |
+// | Wrapper to use SSH from PHP |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004-2008 |
+// | SEO Egghead, Inc. |
+// | http://www.seoegghead.com/ |
+// | |
+// | This program is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU General Public License |
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// | GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
+// +----------------------------------------------------------------------+
+
+class SSH2
+{
+
+ var $_host;
+ var $_port;
+
+ var $_username;
+ var $_pubkey;
+ var $_privatekey;
+
+ var $_c;
+
+ var $_current_stream;
+
+ var $_sftp;
+
+ var $_log_reads = false;
+ var $_log_writes = false;
+
+ var $_log_buf = '';
+
+ function SSH2($host, $port = 22, $callbacks = array())
+ {
+ if (!function_exists('ssh2_connect')) {
+ echo 'ERROR: PECL ssh2 must be installed!';
+ die();
+ }
+
+ $this->_host = $host;
+ $this->_port = $port;
+ $this->_c = ssh2_connect($this->_host, $this->_port, array(), $callbacks);
+ }
+
+ public function isConnected()
+ {
+ return (is_resource($this->_c));
+ }
+
+ function setLogReads($setting = true)
+ {
+ $this->_log_reads = $setting;
+ }
+
+ function setLogWrites($setting = true)
+ {
+ $this->_log_writes = $setting;
+ }
+
+ function loginWithPassword($username, $password)
+ {
+ return ssh2_auth_password($this->_c, $username, $password);
+ }
+
+ function loginWithKey($username, $pubkey, $privatekey)
+ {
+ return ssh2_auth_pubkey_file($this->c, $username, $pubkey, $privatekey);
+
+ }
+
+ // WARNING: Blocking only really works as expected if reading data afterwards.
+ function execCommand($command, $set_blocking = false, $pty = null,
+ $env = array())
+ {
+ if (!$pty) $pty = null;
+ $stream = ssh2_exec($this->_c, $command, $pty, $env);
+ $this->_current_stream = $stream;
+ if ($set_blocking) stream_set_blocking($stream, true);
+ return $stream;
+ }
+
+ function _generateCommand($command, $get_stdout = true, $get_stderr = false,
+ $append_output = '')
+ {
+ $command = ' ( ' . $command . ' ) ';
+
+ if ($get_stdout && $get_stderr) {
+ $command .= ' 2>&1 ';
+ } elseif ($get_stdout && !$get_stderr) {
+ $command .= ' 2>/dev/null ';
+ } elseif (!$get_stdout && $get_stderr) {
+ $command = ' ( ' . $command . ' 1>/dev/null ) 2>&1 ';
+ } else {
+ $command .= ' >/dev/null 2>&1 ';
+ }
+
+ $command = ' sh -c ' . escapeshellarg($command);
+ if ($append_output) $command .= ' ; echo ' .
+ escapeshellarg($append_output) . ' ; ';
+ return $command;
+ }
+
+ // Use this if you want to wait until the command is executed.
+ function execCommandBlockNoOutput($command, $not_used = true, $pty = null,
+ $env = array())
+ {
+ $command = SSH2::_generateCommand($command, false, false, '@');
+ $stream = $this->execCommand($command, true, $pty, $env);
+ $this->waitPrompt('@');
+ return $stream;
+ }
+
+ // Use this if you want to wait until the command is executed and want the output.
+ // This is an old implementation of execCommandBlockING(); it has a b64encode dependency.
+ function execCommandBlock($command, $not_used = true, $pty = null,
+ $env = array(), $get_stderr = false)
+ {
+ $command = SSH2::_generateCommand($command, true, $get_stderr);
+ $command .= ' | b64encode - | sed 1d | sed \'$d\' ';
+ $command .= ' ; echo \'@\'; ';
+ $stream = $this->execCommand($command, true, $pty, $env);
+ $this->waitPrompt('@', $_buf);
+ return base64_decode($_buf);
+ }
+
+ // Use this if you want to wait until the command is executed and want the output.
+ function execCommandBlocking($command, $not_used = true, $pty = null,
+ $env = array(), $get_stderr = false)
+ {
+ $command = SSH2::_generateCommand($command, true, $get_stderr);
+ $stream = $this->execCommand($command, true, $pty, $env);
+ $buf = ''; while (!$this->feof()) $buf .= $this->getStreamOutput();
+ if ($this->_log_reads) $this->_log_buf .= $buf;
+ return $buf;
+ }
+
+ function getShell($set_blocking = false, $term_type = 'vt102',
+ $env = array(), $width = null, $height = null)
+ {
+ $stream = ssh2_shell($this->_c, $term_type, $env, $width, $height,
+ ($width && $height) ? SSH2_TERM_UNIT_CHARS : null);
+ $this->_current_stream = $stream;
+ if ($set_blocking) stream_set_blocking($stream, true);
+ return $stream;
+ }
+
+ function waitPrompt($prompt_regex = '> $', &$buf = '',
+ $timeout_secs = 0, $stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ if ($timeout_secs) {
+
+ $_ver = preg_replace('#-.*?$#', '', phpversion('ssh2'));
+ if (version_compare($_ver, '0.11.0', '<')) {
+ echo "ERROR: Using old version of PECL ssh2 ($_ver); timeouts broken!";
+ die();
+ }
+
+ $end = time() + $timeout_secs;
+
+ $saved_meta_info = $this->getMeta($stream);
+ stream_set_blocking($stream, false);
+
+ while (!$_r = preg_match("#$prompt_regex#", $buf .= fread($stream, 4096))) {
+ if (time() > $end) break;
+ fflush($stream);
+ usleep(1);
+ }
+
+ stream_set_blocking($stream, $saved_meta_info['blocked']);
+
+ } else {
+ while (!$_r = preg_match("#$prompt_regex#", $buf .= fread($stream, 4096)))
+ fflush($stream);
+ }
+
+ if ($this->_log_reads) $this->_log_buf .= $buf;
+ return $_r;
+ }
+
+ function writePrompt($command, $add_newline = true, $stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ fflush($stream);
+ $_command = ($command . ($add_newline ? "\n" : ''));
+ $num_bytes = fwrite($stream, $_command);
+ fflush($stream);
+ if ($this->_log_writes) $this->_log_buf .= substr($_command, 0, $num_bytes);
+ return $num_bytes;
+ }
+
+ function getStreamOutput($length = 4096, $stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ $buf = fread($stream, $length);
+ if ($this->_log_reads) $this->_log_buf .= $buf;
+ return $buf;
+ }
+
+ // WARNING: This may not necessarily get all data.
+ function getAllStreamOutput($stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ $buf = stream_get_contents($stream);
+ if ($this->_log_reads) $this->_log_buf .= $buf;
+ return $buf;
+ }
+
+ function closeStream($stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ return fclose($stream);
+ }
+
+ function fetchSTDERR($set_blocking = false, $stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ $err_stream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
+ if ($set_blocking) stream_set_blocking($err_stream, true);
+ return $err_stream;
+ }
+
+ function SCPSend($local_file, $remote_file, $create_mode = null)
+ {
+ return ssh2_scp_send($this->_c, $local_file, $remote_file, $create_mode);
+ }
+
+ function sendContents($file_contents, $remote_file, $create_mode = null,
+ $set_blocking = false)
+ {
+ $fp = fopen("ssh2.sftp://" . $this->_sftp . "$remote_file", $create_mode);
+ if ($set_blocking) stream_set_blocking($fp, true);
+ return fwrite($fp, $file_contents, strlen($file_contents));
+ }
+
+ function sendStream($input_stream, $remote_file, $create_mode = null,
+ $set_blocking = false)
+ {
+ $fp = fopen("ssh2.sftp://" . $this->_sftp . "$remote_file", $create_mode);
+ if ($set_blocking) stream_set_blocking($fp, true);
+ $bytes = stream_copy_to_stream($input_stream, $fp);
+ fclose($fp);
+ return $bytes;
+ }
+
+ function SCPReceive($remote_file, $local_file)
+ {
+ return ssh2_scp_recv($this->_c, $remote_file, $local_file);
+ }
+
+ function openSFTP()
+ {
+ $this->_sftp = ssh2_sftp($this->_c);
+ }
+
+ function unlink($filename)
+ {
+ return ssh2_sftp_unlink($this->_sftp, $filename);
+ }
+
+ function feof($stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ return feof($stream);
+ }
+
+ function getMeta($stream = null)
+ {
+ if (!$stream) $stream = $this->_current_stream;
+ return stream_get_meta_data($stream);
+ }
+
+ // Use file wrappers for other functionality.
+
+}
\ No newline at end of file
Modified: modules/core/event_script.php
===================================================================
--- modules/core/event_script.php 2011-05-02 18:28:38 UTC (rev 83)
+++ modules/core/event_script.php 2011-05-02 18:34:29 UTC (rev 84)
@@ -78,7 +78,7 @@
{
$args = $this->UnescapeTemplate($this->get("script_arguments"));
$exec_str = $this->get("script_path")." ".$item->ParseTemplateText($args);
- $objExecQueue->AddToQueue($this->get("id"),$exec_str,$item->get("id"));
+ $objExecQueue->AddToQueue($this->get("id"),$exec_str,$item->get("id"),$this->get("exec_order"));
}
return true;
}
1
0
02 May '11
Author: cwalker
Date: 2011-05-02 13:28:38 -0500 (Mon, 02 May 2011)
New Revision: 83
Modified:
core/db/clsDB_mysql.php
modules/core/clsEventManager.php
modules/core/clsUserbaseActionHandler.php
modules/core/event_script.php
modules/mysql/account.php
modules/mysql/resource_account.php
www/tpl/admin/queue/item.tpl
www/tpl/admin/queue/item_alt.tpl
www/tpl/admin/queue/list.tpl
Log:
Added execution order to script queue and event script editing to allow us to ensure script run order, in the event that one script needs to run before another doeson the same event.
Fixed the account add API call to ensure the status-based events fire when an account is added with the state set
Modified: core/db/clsDB_mysql.php
===================================================================
--- core/db/clsDB_mysql.php 2011-05-02 15:54:51 UTC (rev 82)
+++ core/db/clsDB_mysql.php 2011-05-02 18:28:38 UTC (rev 83)
@@ -164,7 +164,6 @@
}
else
{
- mysql_close($this->conn);
return 0;
}
}
Modified: modules/core/clsEventManager.php
===================================================================
--- modules/core/clsEventManager.php 2011-05-02 15:54:51 UTC (rev 82)
+++ modules/core/clsEventManager.php 2011-05-02 18:28:38 UTC (rev 83)
@@ -13,6 +13,7 @@
'script_id' => array('datatype'=>INTEGER,'datasize'=>4),
'item_id' => array('datatype'=>INTEGER,'datasize'=>4),
'attempts' => array('datatype'=>INTEGER,'datasize'=>4),
+ 'exec_order' => array('datatype'=>INTEGER,'datasize'=>4),
'state'=>array('datatype'=>ENUM, 'datasize'=>array('queued','running','complete','failed','canceled','delayed'),'label'=>"State",'section'=>"General",'display_order'=>7),
'last_attempt'=>array('datatype'=>SQLDATE,
'datasize'=>0,
@@ -60,7 +61,8 @@
$s = $this->NamedRelationObject("EventScript");
$id = $this->get("item_id");
$obj = getDomainObject($s->get("item_class"),$id);
- $ret = $obj->GetDefaultText();
+ if(is_object($obj))
+ $ret = $obj->GetDefaultText();
return $ret;
}
@@ -174,7 +176,7 @@
$this->SearchFields["admin"] = array();
}
- function AddToQueue($script_id,$exec_str,$item_id=0)
+ function AddToQueue($script_id,$exec_str,$item_id=0,$exec_order=0)
{
$q = new QueueItem();
$q->set("script_id",$script_id);
@@ -184,6 +186,7 @@
$q->set('last_attempt','0000-00-00');
$q->set("attempts",0);
$q->set("executable",$exec_str);
+ $q->set("exec_order",$exec_order);
return $q->commit();
}
@@ -213,7 +216,7 @@
break;
case "runqueue":
$t = $this->table;
- $sql = "select $t.* FROM $t WHERE state='queued' ORDER BY queued_date ASC, attempts ASC";
+ $sql = "select $t.* FROM $t WHERE state='queued' ORDER BY exec_order ASC, queued_date ASC, attempts ASC";
break;
default:
$sql = parent::BuildListSQL($ListName);
Modified: modules/core/clsUserbaseActionHandler.php
===================================================================
--- modules/core/clsUserbaseActionHandler.php 2011-05-02 15:54:51 UTC (rev 82)
+++ modules/core/clsUserbaseActionHandler.php 2011-05-02 18:28:38 UTC (rev 83)
@@ -69,7 +69,8 @@
{
foreach($el->Items as $e)
{
- $ret = $ret || $e->execute($objItem);
+ $r = $e->execute($objItem);
+ $ret = $ret || $r;
}
}
return $ret;
@@ -100,6 +101,30 @@
);
}
+ public function add($data=null)
+ {
+ $item = parent::add($data);
+ if(is_object($item))
+ {
+ switch($data["state"])
+ {
+ case "active":
+ $this->MyAPI()->activate($item);
+ break;
+ case "inactive":
+ $this->MyAPI()->disable($item);
+ break;
+ case "expire":
+ $this->MyAPI()->expire($item);
+ break;
+ case "denied":
+ $this->MyAPI()->deny($item);
+ break;
+ }
+ }
+ return $item;
+ }
+
public function edit($ItemId=null,$data=null)
{
$item = new $this->ItemClassName();
Modified: modules/core/event_script.php
===================================================================
--- modules/core/event_script.php 2011-05-02 15:54:51 UTC (rev 82)
+++ modules/core/event_script.php 2011-05-02 18:28:38 UTC (rev 83)
@@ -29,6 +29,8 @@
'failure_notify'=>array('datatype'=>VARCHAR,'datasize'=>64,'label'=>"Notify on Failure",'section'=>"General",'display_order'=>10),
'max_attempts'=>array('datatype'=>INTEGER,'datasize'=>4,'label'=>"Max Attempts",'section'=>"General",'display_order'=>10),
'attempt_delay'=>array('datatype'=>INTEGER,'datasize'=>4,'label'=>"Attempt Delay (seconds)",'section'=>"General",'display_order'=>10),
+ 'exec_order'=>array('datatype'=>INTEGER,'datasize'=>4,'label'=>"Execution Order",'section'=>"General",'display_order'=>10),
+
'domain_id' => array('datatype'=>INTEGER,'datasize'=>4)
);
Modified: modules/mysql/account.php
===================================================================
--- modules/mysql/account.php 2011-05-02 15:54:51 UTC (rev 82)
+++ modules/mysql/account.php 2011-05-02 18:28:38 UTC (rev 83)
@@ -209,6 +209,7 @@
public function activate($account)
{
+ $objAccount = false;
if(!is_object($account))
{
$objAccount = getDomainObject("Account",$account);
@@ -220,10 +221,12 @@
{
$objAccount->Activate();
}
+ return $objAccount;
}
public function deny($account)
{
+ $objAccount = false;
if(!is_object($account))
{
$objAccount = getDomainObject("Account",$account);
@@ -235,10 +238,12 @@
{
$objAccount->deny();
}
+ return $objAccount;
}
public function disable($account)
{
+ $objAccount = false;
if(!is_object($account))
{
$objAccount = getDomainObject("Account",$account);
@@ -250,10 +255,12 @@
{
$objAccount->Deactivate();
}
+ return $objAccount;
}
public function expire($account)
{
+ $objAccount = false;
if(!is_object($account))
{
$objAccount = getDomainObject("Account",$account);
@@ -265,6 +272,7 @@
{
$objAccount->Expire();
}
+ return $objAccount;
}
public function accept($account)
Modified: modules/mysql/resource_account.php
===================================================================
--- modules/mysql/resource_account.php 2011-05-02 15:54:51 UTC (rev 82)
+++ modules/mysql/resource_account.php 2011-05-02 18:28:38 UTC (rev 83)
@@ -45,6 +45,7 @@
public function activate($item=null)
{
+ $objItem = false;
if(is_object($item))
{
$objItem = $item;
@@ -65,6 +66,7 @@
public function disable($item=null)
{
+ $objItem = false;
if(is_object($item))
{
$objItem = $item;
@@ -85,6 +87,7 @@
public function deny($item=null)
{
+ $objItem = false;
if(is_object($item))
{
$objItem = $item;
@@ -105,6 +108,7 @@
public function expire($item=null)
{
+ $objItem = false;
if(is_object($item))
{
$objItem = $item;
Modified: www/tpl/admin/queue/item.tpl
===================================================================
--- www/tpl/admin/queue/item.tpl 2011-05-02 15:54:51 UTC (rev 82)
+++ www/tpl/admin/queue/item.tpl 2011-05-02 18:28:38 UTC (rev 83)
@@ -5,6 +5,7 @@
<td><item:this _Field="item_class" /></td>
<td><item:this _Field="item_name" /></td>
<td><item:this _Field="event_name" /></td>
+ <td><item:this _Field="exec_order" /></td>
<td><item:this _Field="state" /></td>
<td><item:this _Field="attempts" /></td>
<td><item:this _Field="last_attempt" /></td>
Modified: www/tpl/admin/queue/item_alt.tpl
===================================================================
--- www/tpl/admin/queue/item_alt.tpl 2011-05-02 15:54:51 UTC (rev 82)
+++ www/tpl/admin/queue/item_alt.tpl 2011-05-02 18:28:38 UTC (rev 83)
@@ -5,6 +5,7 @@
<td><item:this _Field="item_class" /></td>
<td><item:this _Field="item_name" /></td>
<td><item:this _Field="event_name" /></td>
+ <td><item:this _Field="exec_order" /></td>
<td><item:this _Field="state" /></td>
<td><item:this _Field="attempts" /></td>
<td><item:this _Field="last_attempt" /></td>
Modified: www/tpl/admin/queue/list.tpl
===================================================================
--- www/tpl/admin/queue/list.tpl 2011-05-02 15:54:51 UTC (rev 82)
+++ www/tpl/admin/queue/list.tpl 2011-05-02 18:28:38 UTC (rev 83)
@@ -47,6 +47,12 @@
<img src="<list:sorticon _Item="QueueItem" _ListType="admin" _Column="event_name" _DescIcon="images/admin/header_arrow_down.gif" _AscIcon="images/admin/header_arrow_up.gif" />" border=0 align="top">
</td>
<td class="adminListHeader">
+ <A HREF="<list:sorturl _Item="QueueItem" _ListType="admin" _Column="exec_order" />">
+ Order
+ </A>
+ <img src="<list:sorticon _Item="QueueItem" _ListType="admin" _Column="exec_order" _DescIcon="images/admin/header_arrow_down.gif" _AscIcon="images/admin/header_arrow_up.gif" />" border=0 align="top">
+ </td>
+ <td class="adminListHeader">
<A HREF="<list:sorturl _Item="QueueItem" _ListType="admin" _Column="state" />">
Status
</A>
1
0
Author: cwalker
Date: 2011-05-02 10:54:51 -0500 (Mon, 02 May 2011)
New Revision: 82
Modified:
domains/ci/resource.php
modules/mysql/resource.php
Log:
Added method to resource object to test if an account is active on a resource
Modified: domains/ci/resource.php
===================================================================
--- domains/ci/resource.php 2011-05-02 15:53:51 UTC (rev 81)
+++ domains/ci/resource.php 2011-05-02 15:54:51 UTC (rev 82)
@@ -127,6 +127,16 @@
return $ar;
}
+ public function IsAccountActivated($objAccount)
+ {
+ $ar = $this->GetResourceAccountObject($objAccount);
+ if(is_object($ar))
+ {
+ return ($ar->get("state"=="active"));
+ }
+ return false;
+ }
+
public function GetResourceAccountObject($acct)
{
if(is_object($acct))
Modified: modules/mysql/resource.php
===================================================================
--- modules/mysql/resource.php 2011-05-02 15:53:51 UTC (rev 81)
+++ modules/mysql/resource.php 2011-05-02 15:54:51 UTC (rev 82)
@@ -12,6 +12,7 @@
abstract public function ResourceGroups();
abstract public function RemoveFromResourceGroup($r);
abstract public function IsCredentialAccepted($objCredential);
+ abstract public function IsAccountActivated($objAccount);
function __construct($id=null)
{
1
0
Author: cwalker
Date: 2011-05-02 10:53:51 -0500 (Mon, 02 May 2011)
New Revision: 81
Added:
domains/ci/bin/ldap_add_to_group.php
domains/ci/bin/ldap_add_to_netgroup.php
domains/ci/bin/ldap_remove_from_group.php
domains/ci/bin/ldap_remove_from_netgroup.php
Removed:
domains/ci/bin/add_to_netgroup.php
domains/ci/bin/remove_from_netgroup.php
Modified:
bin/include/core_options.php
bin/manage_event_queue.php
modules/mysql/resource.php
Log:
Wrote add to group scripts, renamed ldap scripts to be consistent
Modified: bin/include/core_options.php
===================================================================
--- bin/include/core_options.php 2011-05-02 15:12:41 UTC (rev 80)
+++ bin/include/core_options.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -232,8 +232,8 @@
{
// echo "short - ".$this->build_short_list()."\n";
$opt = getopt($this->build_short_list(),$this->build_long_list());
- echo "\nOptions:\n";
- print_r($opt);
+ //echo "\nOptions:\n";
+ //print_r($opt);
//die();
foreach($opt as $name=>$value)
{
@@ -362,8 +362,10 @@
}
}
- public function GetInteractiveValues()
+ public function GetInteractiveValues($domain)
{
+ global $CLI;
+
$cats = $this->getCategories();
if(count($cats)>0)
{
@@ -374,6 +376,15 @@
foreach($cat_options as $o)
{
$val = $o->get_value();
+ if(!strlen($val))
+ {
+ $def = trim(@$CLI[$domain][$o->name]);
+ if(strlen($def)>0)
+ {
+ $o->set_value($def);
+ $val = $def;
+ }
+ }
if(!strlen($val) && $o->is_required())
{
if(!$bHeaderSent)
Modified: bin/manage_event_queue.php
===================================================================
--- bin/manage_event_queue.php 2011-05-02 15:12:41 UTC (rev 80)
+++ bin/manage_event_queue.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -35,27 +35,29 @@
}
}
-$objOptions->GetInteractiveValues();
-
$domain = $objOptions->GetValue("domain");
-/* The *userbase* username and password of the person running this script */
-$username = $objOptions->GetValue("username");
-$password = $objOptions->GetValue("password");
-
if(strlen($domain)==0)
- die('No Domain Provided');
+ die('No Domain Provided');
$objDomain = new clsDomainBase();
$objDomain->fetchByName($domain);
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ $d = getCurrentDomain();
+}
+$objOptions->GetInteractiveValues($domain);
+/* The *userbase* username and password of the person running this script */
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+
$objUserAccount = null;
$objCurrentUser = null;
if($objDomain->get("id")>0)
{
- $objDomain->setAsCurrent();
- $d = getCurrentDomain();
- echo $objDomain->get("name")." Set As Current Domain\n";
+ //echo $objDomain->get("name")." Set As Current Domain\n";
$objUserAccount = getDomainObject("Account");
$objUserAccount->fetchByUsername($username);
if($objDomain->AuthenticateUser($objUserAccount,$password))
@@ -93,4 +95,4 @@
}
}
}
-}
\ No newline at end of file
+}
Deleted: domains/ci/bin/add_to_netgroup.php
===================================================================
--- domains/ci/bin/add_to_netgroup.php 2011-05-02 15:12:41 UTC (rev 80)
+++ domains/ci/bin/add_to_netgroup.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -1,178 +0,0 @@
-#!/usr/bin/php -q
-<?php
-
-$f = "/etc/userbase2.conf";
-
-if(file_exists($f))
-{
- $Config = parse_ini_file($f);
-}
-
-$pathtoroot = $Config['pathtoroot'];
-/* define STDIN in case we need it for user input */
-
-if(!defined("STDIN")) {
-define("STDIN", fopen('php://stdin','r'));
-}
-
-require_once($pathtoroot."bin/include/core_options.php");
-
-/* add script specific options */
-$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
-$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
-$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
-$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
-$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
-$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
-
-$objOptions->AddOption("account","A","account",true,false,"Account username");
-$objOptions->AddOption("netgroup","N","netgroup",true,true,"Netgroup CN");
-
-/*read command line options */
-$objOptions->ParseOptions();
-
-/* bootstrap the platform */
-include_once($pathtoroot."bin/include/cli_loader.php");
-
-$username = $objOptions->GetValue("username");
-
-/* default to the shell user, if set */
-if(!strlen($username))
-{
- $username = GetArrayValue($_SERVER,"user","");
- if(strlen($username))
- {
- $objOptions->SetValue("username",$username);
- }
-}
-$domain = $objOptions->GetValue("domain");
-$objOptions->GetInteractiveValues($domain);
-
-$username = $objOptions->GetValue("username");
-$password = $objOptions->GetValue("password");
-$ldap_host = $objOptions->GetValue("ldap_host");
-$ldap_authdn = $objOptions->GetValue("ldap_authdn");
-$ldap_basedn = $objOptions->GetValue("ldap_basedn");
-$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
-$account_username = $objOptions->GetValue("account",0);
-$netgroup = $objOptions->GetValue("netgroup","");
-
-if(strlen($domain)==0)
- die('No Domain Provided');
-
-$objDomain = new clsDomainBase();
-$objDomain->fetchByName($domain);
-
-$objUserAccount = null;
-$objCurrentUser = null;
-
-if($objDomain->get("id")>0)
-{
- $objDomain->setAsCurrent();
- echo $objDomain->get("name")." Set As Current Domain\n";
- $objUserAccount = getDomainObject("Account");
- $objUserAccount->fetchByUsername($username);
- if($objDomain->AuthenticateUser($objUserAccount,$password))
- {
- $objCurrentUser = setCurrentAccountUser($objUserAccount);
- }
- else
- $objCurrentUser = false;
-}
-
-if(!is_object($objCurrentUser))
-{
- $u = new clsUser();
- $u->fetchByValue(array("username"=>$username,"domain_id",0));
- if($u->get("id")>0)
- {
- $objSession->SetUser($u->get("id"));
- $objCurrentUser = $u;
- }
-}
-
-if(strlen($ldap_host)==0)
-{
- $ldap_host = $objDomain->GetLDAPServer();
-}
-
-$objIdentityList = new clsIdentityList();
-$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
-
-$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
-$objLdap->uid_field = $uidfield;
-
-
-if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
-{
- die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
-}
-
-$objAccount = getDomainObject("Account");
-$objAccount->fetchByUsername($account_username);
-
-if(!$objAccount->IsActive())
-{
- echo "Account {$objAccount->GetDefaultText()} not active";
- exit(0);
-}
-
-if(strlen($netgroup))
-{
- $netgroups = array($netgroup);
-}
-else
-{
- $objResourceList = $objAccount->Resources("active");
- if($objResourceList->NumItems()>0)
- {
- foreach($objResourceList->Items as $r)
- {
- if(strlen($r->get("ldap_netgroup"))>0)
- {
- $netgroups[] = $r->get("ldap_netgroup");
- }
- }
- }
-}
-
-foreach($netgroups as $netgroup)
-{
- $result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
- if(!$result)
- {
- $data=array();
- $data['objectClass']='nisNetgroup';
- $data['nisNetgroupTriple']=",$account_username,";
-
- $objLdap->AddDN("cn=$netgroup,ou=netgroups,$ldap_basedn",$data);
- }
- else
- {
- $members = GetArrayValue($result,"nisNetgroupTriple",array());
- if(!is_array($members))
- $members = array($members);
- $bMatched = false;
- foreach($members as $m)
- {
- $ma = explode(",",$m);
- $um = @$ma[1];
- if($um==$account_username)
- {
- $bMatched=true;
- }
- }
- if(!$bMatched)
- {
- if(count($members)==0)
- {
- $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>",$account_username,"));
- }
- else
- {
- $members[]=",$account_username,";
- $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$members));
- }
- }
- }
-}
\ No newline at end of file
Added: domains/ci/bin/ldap_add_to_group.php
===================================================================
--- domains/ci/bin/ldap_add_to_group.php (rev 0)
+++ domains/ci/bin/ldap_add_to_group.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -0,0 +1,184 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("account","A","account",true,false,"Account username");
+$objOptions->AddOption("ldapgroup","G","ldapgroup",true,true,"LDAP group to add user to");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+$domain = $objOptions->GetValue("domain");
+$objOptions->GetInteractiveValues($domain);
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$account_username = $objOptions->GetValue("account",0);
+$group = $objOptions->GetValue("ldapgroup","");
+
+if(strlen($domain)==0)
+ die('No Domain Provided');
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ echo $objDomain->get("name")." Set As Current Domain\n";
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+if(!$objAccount->IsActive())
+{
+ echo "Account {$objAccount->GetDefaultText()} not active";
+ exit(0);
+}
+
+$objResourceGroup = getDomainObject("ResourceGroup");
+$objResourcegroup->fetchByValue("name"=>"Unix Groups");
+
+if($objResourceGroup->get("id")>0)
+{
+ if(strlen($group))
+ {
+ $groups = array($group);
+ }
+ else
+ {
+ $objResourceList = $objResourceGroup->Resourcees(); // $objAccount->Resources("active");
+ if($objResourceList->NumItems()>0)
+ {
+ foreach($objResourceList->Items as $r)
+ {
+ if(strlen($r->get("gidNumber"))>0 && $r->IsAccountActivated($objAccount))
+ {
+ $groups[] = $r->get("name");
+ }
+ }
+ }
+ }
+}
+
+foreach($groups as $group)
+{
+ $result = $objLdap->GetDN("cn=$group,ou=group,".$ldap_basedn);
+ if(!$result)
+ {
+ $data=array();
+ $data['objectClass']='posixGroup';
+ $data['memberUid']=",$account_username,";
+
+ $objLdap->AddDN("cn=$group,ou=group,$ldap_basedn",$data);
+ }
+ else
+ {
+ $members = GetArrayValue($result,"memberUid",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ foreach($members as $m)
+ {
+ $ma = explode(",",$m);
+ $um = @$ma[1];
+ if($um==$account_username)
+ {
+ $bMatched=true;
+ }
+ }
+ if(!$bMatched)
+ {
+ if(count($members)==0)
+ {
+ $objLdap->AddAttribute("cn=$group,ou=group,$ldap_basedn",array("memberUid"=>",$account_username,"));
+ }
+ else
+ {
+ $members[]=",$account_username,";
+ $objLdap->ReplaceAttribute("cn=$group,ou=group,$ldap_basedn",array("memberUid"=>$members));
+ }
+ }
+ }
+}
Property changes on: domains/ci/bin/ldap_add_to_group.php
___________________________________________________________________
Added: svn:executable
+ *
Copied: domains/ci/bin/ldap_add_to_netgroup.php (from rev 80, domains/ci/bin/add_to_netgroup.php)
===================================================================
--- domains/ci/bin/ldap_add_to_netgroup.php (rev 0)
+++ domains/ci/bin/ldap_add_to_netgroup.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -0,0 +1,178 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("account","A","account",true,false,"Account username");
+$objOptions->AddOption("netgroup","N","netgroup",true,true,"Netgroup CN");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+$domain = $objOptions->GetValue("domain");
+$objOptions->GetInteractiveValues($domain);
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$account_username = $objOptions->GetValue("account",0);
+$netgroup = $objOptions->GetValue("netgroup","");
+
+if(strlen($domain)==0)
+ die('No Domain Provided');
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ echo $objDomain->get("name")." Set As Current Domain\n";
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+if(!$objAccount->IsActive())
+{
+ echo "Account {$objAccount->GetDefaultText()} not active";
+ exit(0);
+}
+
+if(strlen($netgroup))
+{
+ $netgroups = array($netgroup);
+}
+else
+{
+ $objResourceList = $objAccount->Resources("active");
+ if($objResourceList->NumItems()>0)
+ {
+ foreach($objResourceList->Items as $r)
+ {
+ if(strlen($r->get("ldap_netgroup"))>0)
+ {
+ $netgroups[] = $r->get("ldap_netgroup");
+ }
+ }
+ }
+}
+
+foreach($netgroups as $netgroup)
+{
+ $result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
+ if(!$result)
+ {
+ $data=array();
+ $data['objectClass']='nisNetgroup';
+ $data['nisNetgroupTriple']=",$account_username,";
+
+ $objLdap->AddDN("cn=$netgroup,ou=netgroups,$ldap_basedn",$data);
+ }
+ else
+ {
+ $members = GetArrayValue($result,"nisNetgroupTriple",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ foreach($members as $m)
+ {
+ $ma = explode(",",$m);
+ $um = @$ma[1];
+ if($um==$account_username)
+ {
+ $bMatched=true;
+ }
+ }
+ if(!$bMatched)
+ {
+ if(count($members)==0)
+ {
+ $objLdap->AddAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>",$account_username,"));
+ }
+ else
+ {
+ $members[]=",$account_username,";
+ $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$members));
+ }
+ }
+ }
+}
\ No newline at end of file
Added: domains/ci/bin/ldap_remove_from_group.php
===================================================================
--- domains/ci/bin/ldap_remove_from_group.php (rev 0)
+++ domains/ci/bin/ldap_remove_from_group.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -0,0 +1,159 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("account","A","account",true,false,"Account username");
+$objOptions->AddOption("ldapgroup","G","ldapgroup",true,true,"Group Name");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+
+$domain = $objOptions->GetValue("domain");
+if(strlen($domain)==0)
+ die('No Domain Provided');
+
+$objOptions->GetInteractiveValues($domain);
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$account_username = $objOptions->GetValue("account",0);
+$group = $objOptions->GetValue("ldapgroup","");
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+if(strlen($group))
+{
+ $groups = array($group);
+}
+else
+{
+ $objResourceList = $objAccount->Resources("active");
+ if($objResourceList->NumItems()>0)
+ {
+ foreach($objResourceList->Items as $r)
+ {
+ if(strlen($r->get("gidNumber"))>0)
+ {
+ $netgroups[] = $r->get("name");
+ }
+ }
+ }
+}
+
+function filter_members($var)
+{
+ global $account_username;
+ return ($var != ",$account_username,");
+}
+
+foreach($groups as $group)
+{
+ $result = $objLdap->GetDN("cn=$group,ou=group,".$ldap_basedn);
+ if($result)
+ {
+ $members = GetArrayValue($result,"memberUid",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ $val = ",$account_username,";
+ $m = array_values(array_filter($members,"filter_members"));
+ if(count($m)>0)
+ {
+ $objLdap->ReplaceAttribute("cn=$group,ou=group,$ldap_basedn",array("memberUid"=>$m));
+ }
+ else
+ {
+ $objLdap->DeleteAttribute("cn=$group,ou=group,$ldap_basedn",array("memberUid"=>array()));
+ }
+ }
+}
Property changes on: domains/ci/bin/ldap_remove_from_group.php
___________________________________________________________________
Added: svn:executable
+ *
Copied: domains/ci/bin/ldap_remove_from_netgroup.php (from rev 80, domains/ci/bin/remove_from_netgroup.php)
===================================================================
--- domains/ci/bin/ldap_remove_from_netgroup.php (rev 0)
+++ domains/ci/bin/ldap_remove_from_netgroup.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -0,0 +1,159 @@
+#!/usr/bin/php -q
+<?php
+
+$f = "/etc/userbase2.conf";
+
+if(file_exists($f))
+{
+ $Config = parse_ini_file($f);
+}
+
+$pathtoroot = $Config['pathtoroot'];
+/* define STDIN in case we need it for user input */
+
+if(!defined("STDIN")) {
+define("STDIN", fopen('php://stdin','r'));
+}
+
+require_once($pathtoroot."bin/include/core_options.php");
+
+/* add script specific options */
+$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
+$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
+$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
+$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
+$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
+$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
+
+$objOptions->AddOption("account","A","account",true,false,"Account username");
+$objOptions->AddOption("netgroup","N","netgroup",true,true,"Netgroup CN");
+
+/*read command line options */
+$objOptions->ParseOptions();
+
+/* bootstrap the platform */
+include_once($pathtoroot."bin/include/cli_loader.php");
+
+$username = $objOptions->GetValue("username");
+
+/* default to the shell user, if set */
+if(!strlen($username))
+{
+ $username = GetArrayValue($_SERVER,"user","");
+ if(strlen($username))
+ {
+ $objOptions->SetValue("username",$username);
+ }
+}
+
+$domain = $objOptions->GetValue("domain");
+if(strlen($domain)==0)
+ die('No Domain Provided');
+
+$objOptions->GetInteractiveValues($domain);
+
+$username = $objOptions->GetValue("username");
+$password = $objOptions->GetValue("password");
+$ldap_host = $objOptions->GetValue("ldap_host");
+$ldap_authdn = $objOptions->GetValue("ldap_authdn");
+$ldap_basedn = $objOptions->GetValue("ldap_basedn");
+$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
+$account_username = $objOptions->GetValue("account",0);
+$netgroup = $objOptions->GetValue("netgroup","");
+
+$objDomain = new clsDomainBase();
+$objDomain->fetchByName($domain);
+
+$objUserAccount = null;
+$objCurrentUser = null;
+
+if($objDomain->get("id")>0)
+{
+ $objDomain->setAsCurrent();
+ $objUserAccount = getDomainObject("Account");
+ $objUserAccount->fetchByUsername($username);
+ if($objDomain->AuthenticateUser($objUserAccount,$password))
+ {
+ $objCurrentUser = setCurrentAccountUser($objUserAccount);
+ }
+ else
+ $objCurrentUser = false;
+}
+
+if(!is_object($objCurrentUser))
+{
+ $u = new clsUser();
+ $u->fetchByValue(array("username"=>$username,"domain_id",0));
+ if($u->get("id")>0)
+ {
+ $objSession->SetUser($u->get("id"));
+ $objCurrentUser = $u;
+ }
+}
+
+if(strlen($ldap_host)==0)
+{
+ $ldap_host = $objDomain->GetLDAPServer();
+}
+
+$objIdentityList = new clsIdentityList();
+$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
+
+$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
+$objLdap->uid_field = $uidfield;
+
+
+if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
+{
+ die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
+}
+
+$objAccount = getDomainObject("Account");
+$objAccount->fetchByUsername($account_username);
+
+if(strlen($netgroup))
+{
+ $netgroups = array($netgroup);
+}
+else
+{
+ $objResourceList = $objAccount->Resources("active");
+ if($objResourceList->NumItems()>0)
+ {
+ foreach($objResourceList->Items as $r)
+ {
+ if(strlen($r->get("ldap_netgroup"))>0)
+ {
+ $netgroups[] = $r->get("ldap_netgroup");
+ }
+ }
+ }
+}
+
+function filter_members($var)
+{
+ global $account_username;
+ return ($var != ",$account_username,");
+}
+
+foreach($netgroups as $netgroup)
+{
+ $result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
+ if($result)
+ {
+ $members = GetArrayValue($result,"nisNetgroupTriple",array());
+ if(!is_array($members))
+ $members = array($members);
+ $bMatched = false;
+ $val = ",$account_username,";
+ $m = array_values(array_filter($members,"filter_members"));
+ if(count($m)>0)
+ {
+ $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$m));
+ }
+ else
+ {
+ $objLdap->DeleteAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>array()));
+ }
+ }
+}
Deleted: domains/ci/bin/remove_from_netgroup.php
===================================================================
--- domains/ci/bin/remove_from_netgroup.php 2011-05-02 15:12:41 UTC (rev 80)
+++ domains/ci/bin/remove_from_netgroup.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -1,159 +0,0 @@
-#!/usr/bin/php -q
-<?php
-
-$f = "/etc/userbase2.conf";
-
-if(file_exists($f))
-{
- $Config = parse_ini_file($f);
-}
-
-$pathtoroot = $Config['pathtoroot'];
-/* define STDIN in case we need it for user input */
-
-if(!defined("STDIN")) {
-define("STDIN", fopen('php://stdin','r'));
-}
-
-require_once($pathtoroot."bin/include/core_options.php");
-
-/* add script specific options */
-$objOptions->AddOption("ldap_host","H","ldaphost",true,false,"LDAP Hostname","LDAP");
-$objOptions->AddOption("ldap_authdn","a","ldapauth",true,false,"LDAP Auth DN","LDAP");
-$objOptions->AddOption("ldap_basedn","B","ldapbase",true,false,"LDAP Base DN","LDAP");
-$objOptions->AddOption("ldap_uidfield","U","ldapuid",true,false,"LDAP uid field name","LDAP");
-$objOptions->AddOption("ldap_bind_user","","ldapuser",true,false,"LDAP Bind User","LDAP");
-$objOptions->AddOption("ldap_bind_pass","","ldappass",true,true,"LDAP Bind Password","LDAP");
-
-$objOptions->AddOption("account","A","account",true,false,"Account username");
-$objOptions->AddOption("netgroup","N","netgroup",true,true,"Netgroup CN");
-
-/*read command line options */
-$objOptions->ParseOptions();
-
-/* bootstrap the platform */
-include_once($pathtoroot."bin/include/cli_loader.php");
-
-$username = $objOptions->GetValue("username");
-
-/* default to the shell user, if set */
-if(!strlen($username))
-{
- $username = GetArrayValue($_SERVER,"user","");
- if(strlen($username))
- {
- $objOptions->SetValue("username",$username);
- }
-}
-
-$domain = $objOptions->GetValue("domain");
-if(strlen($domain)==0)
- die('No Domain Provided');
-
-$objOptions->GetInteractiveValues($domain);
-
-$username = $objOptions->GetValue("username");
-$password = $objOptions->GetValue("password");
-$ldap_host = $objOptions->GetValue("ldap_host");
-$ldap_authdn = $objOptions->GetValue("ldap_authdn");
-$ldap_basedn = $objOptions->GetValue("ldap_basedn");
-$uidfield = $objOptions->GetValue("ldap_uidfield","uid");
-$account_username = $objOptions->GetValue("account",0);
-$netgroup = $objOptions->GetValue("netgroup","");
-
-$objDomain = new clsDomainBase();
-$objDomain->fetchByName($domain);
-
-$objUserAccount = null;
-$objCurrentUser = null;
-
-if($objDomain->get("id")>0)
-{
- $objDomain->setAsCurrent();
- $objUserAccount = getDomainObject("Account");
- $objUserAccount->fetchByUsername($username);
- if($objDomain->AuthenticateUser($objUserAccount,$password))
- {
- $objCurrentUser = setCurrentAccountUser($objUserAccount);
- }
- else
- $objCurrentUser = false;
-}
-
-if(!is_object($objCurrentUser))
-{
- $u = new clsUser();
- $u->fetchByValue(array("username"=>$username,"domain_id",0));
- if($u->get("id")>0)
- {
- $objSession->SetUser($u->get("id"));
- $objCurrentUser = $u;
- }
-}
-
-if(strlen($ldap_host)==0)
-{
- $ldap_host = $objDomain->GetLDAPServer();
-}
-
-$objIdentityList = new clsIdentityList();
-$objIdentityAPI = getApiObject("identity"); //new clsIdentityActions();
-
-$objLdap = new clsLdapServer($ldap_host,"",$ldap_authdn);
-$objLdap->uid_field = $uidfield;
-
-
-if(!$objLdap->Authenticate($objOptions->GetValue("ldap_bind_user"),$objOptions->GetValue("ldap_bind_pass")))
-{
- die("Unable to bind {$ldap_authdn} to ldap server $ldap_host\n");
-}
-
-$objAccount = getDomainObject("Account");
-$objAccount->fetchByUsername($account_username);
-
-if(strlen($netgroup))
-{
- $netgroups = array($netgroup);
-}
-else
-{
- $objResourceList = $objAccount->Resources("active");
- if($objResourceList->NumItems()>0)
- {
- foreach($objResourceList->Items as $r)
- {
- if(strlen($r->get("ldap_netgroup"))>0)
- {
- $netgroups[] = $r->get("ldap_netgroup");
- }
- }
- }
-}
-
-function filter_members($var)
-{
- global $account_username;
- return ($var != ",$account_username,");
-}
-
-foreach($netgroups as $netgroup)
-{
- $result = $objLdap->GetDN("cn=$netgroup,ou=netgroups,".$ldap_basedn);
- if($result)
- {
- $members = GetArrayValue($result,"nisNetgroupTriple",array());
- if(!is_array($members))
- $members = array($members);
- $bMatched = false;
- $val = ",$account_username,";
- $m = array_values(array_filter($members,"filter_members"));
- if(count($m)>0)
- {
- $objLdap->ReplaceAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>$m));
- }
- else
- {
- $objLdap->DeleteAttribute("cn=$netgroup,ou=netgroups,$ldap_basedn",array("nisNetgroupTriple"=>array()));
- }
- }
-}
Modified: modules/mysql/resource.php
===================================================================
--- modules/mysql/resource.php 2011-05-02 15:12:41 UTC (rev 80)
+++ modules/mysql/resource.php 2011-05-02 15:53:51 UTC (rev 81)
@@ -643,4 +643,4 @@
}
}
-?>
\ No newline at end of file
+?>
1
0
Author: cwalker
Date: 2011-05-02 10:12:41 -0500 (Mon, 02 May 2011)
New Revision: 80
Modified:
core/db/clsDDLManager.php
core/logs/clsLogEntry.php
Log:
Added logging to the DDL manager to isolate database updates
Modified: core/db/clsDDLManager.php
===================================================================
--- core/db/clsDDLManager.php 2011-05-02 14:59:43 UTC (rev 79)
+++ core/db/clsDDLManager.php 2011-05-02 15:12:41 UTC (rev 80)
@@ -58,7 +58,7 @@
$db = $objDB;
if(!self::TableExists($obj->table,$db))
{
- $obj->CreateTable();
+ $obj->CreateTable($logger);
}
else
{
@@ -66,6 +66,7 @@
if(strlen($alter_sql))
{
$db->doSQL($alter_sql);
+ $logger->Log($alter_sql,KLogger::INFO);
//echo $alter_sql;
}
}
@@ -80,6 +81,7 @@
$rsql .="{$jt["localfield"]} INT,\n";
$rsql .="{$jt["foreignfield"]} INT);\n";
$db->doSQL($rsql);
+ $logger->Log($rsql,KLogger::INFO);
//echo $rsql;
}
}
Modified: core/logs/clsLogEntry.php
===================================================================
--- core/logs/clsLogEntry.php 2011-05-02 14:59:43 UTC (rev 79)
+++ core/logs/clsLogEntry.php 2011-05-02 15:12:41 UTC (rev 80)
@@ -27,6 +27,8 @@
$this->ItemObj = null;
$this->bEnableCustomFields = false;
parent::__construct();
+ $this->SetFieldExtraDef("id","AUTO_INCREMENT");
+ clsDDLManager::RegisterObject($this);
if($id)
{
$this->fetch($id);
1
0
Author: cwalker
Date: 2011-05-02 09:59:43 -0500 (Mon, 02 May 2011)
New Revision: 79
Modified:
core/db/clsDBItem.php
core/db/clsDDLManager.php
Log:
Added logging to the DDL manager to isolate database updates
Modified: core/db/clsDBItem.php
===================================================================
--- core/db/clsDBItem.php 2011-05-02 14:47:07 UTC (rev 78)
+++ core/db/clsDBItem.php 2011-05-02 14:59:43 UTC (rev 79)
@@ -754,9 +754,11 @@
}
}
- public function CreateTable()
+ public function CreateTable($logger)
{
- $this->doSQL($this->GenerateCreateSQL(true));
+ $sql = $this->GenerateCreateSQL(true);
+ $logger->Log($sql,KLogger::INFO);
+ $this->doSQL($sql);
}
public function TableExists()
Modified: core/db/clsDDLManager.php
===================================================================
--- core/db/clsDDLManager.php 2011-05-02 14:47:07 UTC (rev 78)
+++ core/db/clsDDLManager.php 2011-05-02 14:59:43 UTC (rev 79)
@@ -43,8 +43,10 @@
public static function ValidateTables()
{
- global $objDB;
+ global $objDB, $LogBaseDir, $ApplicationLogLevel;
+ $filename = $LogBaseDir."ddl.log";
+ $logger = new KLogger($filename,$ApplicationLogLevel);
//print_r(self::$tables);
foreach(self::$tables as $t)
{
1
0
Author: cwalker
Date: 2011-05-02 09:47:07 -0500 (Mon, 02 May 2011)
New Revision: 78
Modified:
core/db/clsDB_mysql.php
Log:
Errors in logging the database queries
Modified: core/db/clsDB_mysql.php
===================================================================
--- core/db/clsDB_mysql.php 2011-05-02 14:09:20 UTC (rev 77)
+++ core/db/clsDB_mysql.php 2011-05-02 14:47:07 UTC (rev 78)
@@ -158,7 +158,7 @@
if($this->doSQL($q)>0)
{
$id = mysql_insert_id($this->conn);
- $this->LogQuery($q,mysql_error($this->conn),mysql_affected_rows($r));
+ $this->LogQuery($q,mysql_error($this->conn),mysql_affected_rows($this->conn));
mysql_close($this->conn);
return $id;
}
@@ -198,7 +198,6 @@
*/
public function doDeleteSQL($q) {
$ret = $this->doSQL($q);
- $this->LogQuery($q,mysql_error($this->conn),mysql_affected_rows($ret));
mysql_close($this->conn);
return $ret;
}
1
0
r77 - core/db core/itembase core/logs domains/ci modules/core modules/identity modules/mysql www/tpl/admin/scripts www/tpl/common/misc
by cwalker@mcs.anl.gov 02 May '11
by cwalker@mcs.anl.gov 02 May '11
02 May '11
Author: cwalker
Date: 2011-05-02 09:09:20 -0500 (Mon, 02 May 2011)
New Revision: 77
Modified:
core/db/clsDB_mysql.php
core/db/clsMysqlActionHandler.php
core/itembase/clsParsedItemBase.php
core/logs/clsLogEntry.php
domains/ci/account.php
domains/ci/account_resource_credential.php
domains/ci/identity_affiliation.php
domains/ci/resource_account.php
modules/core/clsUserbaseActionHandler.php
modules/identity/identity.php
modules/identity/identity_credential.php
modules/identity/identityaddress.php
modules/identity/identityemail.php
modules/identity/identityphone.php
modules/mysql/account.php
modules/mysql/account_resource_credential.php
modules/mysql/identity_affiliation.php
modules/mysql/resource_account.php
www/tpl/admin/scripts/list.tpl
www/tpl/common/misc/dialog_history.tpl
www/tpl/common/misc/dialog_history_item.tpl
www/tpl/common/misc/dialog_history_item_alt.tpl
Log:
Many issues resolved regarding the audit trail.
Modified: core/db/clsDB_mysql.php
===================================================================
--- core/db/clsDB_mysql.php 2011-04-29 18:21:40 UTC (rev 76)
+++ core/db/clsDB_mysql.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -158,6 +158,7 @@
if($this->doSQL($q)>0)
{
$id = mysql_insert_id($this->conn);
+ $this->LogQuery($q,mysql_error($this->conn),mysql_affected_rows($r));
mysql_close($this->conn);
return $id;
}
@@ -197,6 +198,7 @@
*/
public function doDeleteSQL($q) {
$ret = $this->doSQL($q);
+ $this->LogQuery($q,mysql_error($this->conn),mysql_affected_rows($ret));
mysql_close($this->conn);
return $ret;
}
Modified: core/db/clsMysqlActionHandler.php
===================================================================
--- core/db/clsMysqlActionHandler.php 2011-04-29 18:21:40 UTC (rev 76)
+++ core/db/clsMysqlActionHandler.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -169,8 +169,9 @@
{
$itemlist = new $this->ListClassName();
$item = new $this->ItemClassName($ItemId);
- setUserFeedback($this->ItemName." \"".$item->GetDefaultText()."\" Removed from System");
-
+ $result_str = $this->ItemName." \"".$item->GetDefaultText()."\" Removed from System";
+ setUserFeedback($result_str);
+ $item->LogEvent("delete",$item->GetDefaultText()." Deleted");
if(method_exists($itemlist,"RemoveFromAll"))
{
$itemlist->RemoveFromAll($ItemId);
@@ -231,8 +232,10 @@
$id = $item->commit();
if($id)
{
- setUserFeedback($this->ItemName." \"".$item->GetDefaultText()."\" Added.");
+ $result_str = $this->ItemName." \"".$item->GetDefaultText()."\" Added.";
+ setUserFeedback($result_str);
$this->handlefileUploads($item);
+ $item->LogEvent("add",$result_str);
return $item;
}
}
@@ -241,6 +244,8 @@
public function edit($ItemId=null,$data=null)
{
+ global $objFactory;
+
if(is_null($ItemId) || (int)$ItemId==0)
{
$ItemId = getItemId();
@@ -251,11 +256,12 @@
}
if(is_array($data))
{
- $item = new $this->ItemClassName();
+ $item = $objFactory->GetObject($this->ItemClassName); // new $this->ItemClassName();
if(pageHasContext())
$item->SetContext(GetArrayValue($_GET,"Context",""),GetArrayValue($_GET,"ContextValue",0));
$item->fetch($ItemId);
+ //$org = clone($item);
$org = new $this->ItemClassName();
if(pageHasContext())
$org->SetContext(GetArrayValue($_GET,"Context",""),GetArrayValue($_GET,"ContextValue",0));
Modified: core/itembase/clsParsedItemBase.php
===================================================================
--- core/itembase/clsParsedItemBase.php 2011-04-29 18:21:40 UTC (rev 76)
+++ core/itembase/clsParsedItemBase.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -55,31 +55,40 @@
return "";
}
- public function LogChanges($NewObj, $EntryType="edit", $user_id=0)
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
{
- global $objItemLog;
+ global $objItemLog, $objSession;
+ if(!$user_id)
+ {
+ $user_id = $objSession->get("user_id");
+ }
$diffs = array();
if($EntryType=="add")
{
- $objItemLog->AddEntry($this->get("id"),$this->className,$EntryType,"Item Created",$user_id);
+ $objItemLog->AddEntry($this->get("id"),$this->className,$EntryType,"Item Created",$user_id,$parent_id,$parent_class);
}
else
{
$diffs = $this->FieldDiffs($NewObj);
if(count($diffs)>0)
{
- $objItemLog->AddEntry($this->get("id"),$this->className,$EntryType,implode("\n",$diffs),$user_id);
+ $objItemLog->AddEntry($this->get("id"),$this->className,$EntryType,implode("\n",$diffs),$user_id,$parent_id,$parent_class);
}
}
return $diffs;
}
- public function LogEvent($EntryType,$EntryText,$user_id=0)
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
{
- global $objItemLog;
+ global $objItemLog, $objSession;
- $objItemLog->AddEntry($this->get("id"),$this->className,$EntryType,$EntryText,$user_id);
+ if(!$user_id)
+ {
+ $user_id = $objSession->get("user_id");
+ }
+
+ $objItemLog->AddEntry($this->get("id"),$this->className,$EntryType,$EntryText,$user_id,$parent_id,$parent_class);
}
protected function GetItemDelegate($del_name)
Modified: core/logs/clsLogEntry.php
===================================================================
--- core/logs/clsLogEntry.php 2011-04-29 18:21:40 UTC (rev 76)
+++ core/logs/clsLogEntry.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -14,6 +14,8 @@
'user_id' => array('datatype'=>INTEGER, 'datasize'=>4),
'item_id' => array('datatype'=>INTEGER, 'datasize'=>4),
'classname' => array('datatype'=>VARCHAR, 'datasize'=>255),
+ 'parent_item_id' => array('datatype'=>INTEGER, 'datasize'=>4),
+ 'parent_classname' => array('datatype'=>VARCHAR, 'datasize'=>255),
'entry_type' => array('datatype'=>VARCHAR, 'datasize'=>255),
'entry_date' => array('datatype'=>SQLDATETIME, 'datasize'=>0),
'entry_data' => array('datatype'=>TEXT,'datasize'=>0)
@@ -59,6 +61,11 @@
return $ret;
}
+ protected function item_classname($attributes,$extra_attribs="")
+ {
+ return $this->get("classname");
+ }
+
}
class clsLogList extends clsDBParsedCollection
@@ -116,7 +123,7 @@
return $sql;
}
- function AddEntry($item_id,$item_class,$type,$text,$uid)
+ function AddEntry($item_id,$item_class,$type,$text,$uid,$parent_id,$parent_class)
{
global $objSession;
@@ -127,12 +134,14 @@
$l->set("entry_type",$type);
$l->set("entry_date",date("Y-m-d H:i:s"));
$l->set("entry_data",$text);
+ $l->set("parent_item_id",$parent_id);
+ $l->set("parent_classname",$parent_class);
return $l->commit();
}
function LoadItemHistory($item_id,$classname,$type="")
{
- $sql = "select * FROM ".$this->table." where classname='$classname' AND item_id=$item_id";
+ $sql = "select * FROM ".$this->table." where (classname='$classname' AND item_id=$item_id) OR (parent_classname='$classname' AND parent_item_id=$item_id)";
if(strlen($type)>0)
{
$sql .=" and entry_type='$type'";
Modified: domains/ci/account.php
===================================================================
--- domains/ci/account.php 2011-04-29 18:21:40 UTC (rev 76)
+++ domains/ci/account.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -52,6 +52,13 @@
}
}
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
function IsHomeDirTaken($dir)
{
$sql = "select count(*) as c FROM {$this->table} WHERE home_dir='$dir'";
Modified: domains/ci/account_resource_credential.php
===================================================================
--- domains/ci/account_resource_credential.php 2011-04-29 18:21:40 UTC (rev 76)
+++ domains/ci/account_resource_credential.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -24,7 +24,9 @@
{
return $this->get("id");
}
-
+
+
+
}
class CI_clsAccountResourceCredentialList extends MySQL_clsAccountResourceCredentialList
Modified: domains/ci/identity_affiliation.php
===================================================================
--- domains/ci/identity_affiliation.php 2011-04-29 18:21:40 UTC (rev 76)
+++ domains/ci/identity_affiliation.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -44,6 +44,13 @@
$this->fetch($id);
}
}
+
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
public function SetNewAffiliation($name,$category="")
{
Modified: domains/ci/resource_account.php
===================================================================
--- domains/ci/resource_account.php 2011-04-29 18:21:40 UTC (rev 76)
+++ domains/ci/resource_account.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -32,7 +32,18 @@
}
}
-
+
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $a = $this->NamedRelationObject("Account");
+ $a->LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+
+ $r = $this->NamedRelationObject("Resource");
+ $r->LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+
+ return true;
+ }
+
public function delete()
{
$this->set("state","deleted");
Modified: modules/core/clsUserbaseActionHandler.php
===================================================================
--- modules/core/clsUserbaseActionHandler.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/core/clsUserbaseActionHandler.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -125,6 +125,7 @@
break;
}
}
+ return $ret;
}
protected function MyAPI()
Modified: modules/identity/identity.php
===================================================================
--- modules/identity/identity.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/identity/identity.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -898,10 +898,13 @@
$api = getApiObject("identityaddress");
if($AddressId)
{
- $a = $api->edit($this->get("id"), $data);
+ $a = $api->edit($AddressId, $data);
}
else
- $a = $api->add($this->get("id"), $data);
+ {
+ $data["identity_id"] = $this->get("id");
+ $a = $api->add($data);
+ }
return $a;
}
else
@@ -937,17 +940,14 @@
$api = getApiObject("account");
if(!$AccountId)
{
+ $data["identity_id"]=$this->get("id");
$a = $api->add($data);
}
else
{
$a = $api->edit($AccountId,$data);
}
- if($a->get("id")>0)
- {
- $a->AssignToIdentity($this->get("id"));
- return $a;
- }
+ return $a;
}
return false;
}
Modified: modules/identity/identity_credential.php
===================================================================
--- modules/identity/identity_credential.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/identity/identity_credential.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -41,7 +41,19 @@
return $c->GetDefaultText();
}
-
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogEvent($EntryText, $EntryType, $user_id, $parent_id, $parent_class);
+ }
}
class clsIdentityCredentialList extends clsDBParsedCollection
Modified: modules/identity/identityaddress.php
===================================================================
--- modules/identity/identityaddress.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/identity/identityaddress.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -62,8 +62,20 @@
{
return ($this->get("primary")==1);
}
-
-
+
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogEvent($EntryText, $EntryType, $user_id, $parent_id, $parent_class);
+ }
}
class clsIdentityAddressList extends clsDBParsedCollection
@@ -123,7 +135,7 @@
parent::__construct("clsIdentityAddressList","IdentityAddress","Identity Address","Identity Addresses");
}
- public function add($IdentityId=null,$data=null)
+ public function add($data=null)
{
if((is_null($IdentityId) || (int)$IdentityId==0) && GetArrayValue($_GET,"Context","")=="Identity")
{
@@ -137,7 +149,6 @@
{
if(count($data)>0)
{
- $data["identity_id"] = $IdentityId;
return parent::add($data);
}
}
Modified: modules/identity/identityemail.php
===================================================================
--- modules/identity/identityemail.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/identity/identityemail.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -45,8 +45,20 @@
{
return $this->get("email");
}
+
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
-
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogEvent($EntryText, $EntryType, $user_id, $parent_id, $parent_class);
+ }
}
class clsIdentityEmailList extends clsDBParsedCollection
Modified: modules/identity/identityphone.php
===================================================================
--- modules/identity/identityphone.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/identity/identityphone.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -47,7 +47,19 @@
return $this->get("phone")." (".$this->get("number_type").")";
}
-
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogEvent($EntryText, $EntryType, $user_id, $parent_id, $parent_class);
+ }
}
class clsIdentityPhoneList extends clsDBParsedCollection
Modified: modules/mysql/account.php
===================================================================
--- modules/mysql/account.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/mysql/account.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -32,6 +32,20 @@
parent::__construct($id);
}
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogEvent($EntryText, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
protected function _is_context_type($attributes,$extra_attribs="")
{
return parent::_is_context_type($attributes,$extra_attribs="");
Modified: modules/mysql/account_resource_credential.php
===================================================================
--- modules/mysql/account_resource_credential.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/mysql/account_resource_credential.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -22,6 +22,17 @@
}
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $a = $this->NamedRelationObject("Account");
+ $a->LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+
+ $r = $this->NamedRelationObject("Resource");
+ $r->LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+
+ return true;
+ }
+
public function delete()
{
$this->set("state","deleted");
Modified: modules/mysql/identity_affiliation.php
===================================================================
--- modules/mysql/identity_affiliation.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/mysql/identity_affiliation.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -14,7 +14,21 @@
{
return $this->get("title");
}
-
+
+ public function LogChanges($NewObj, $EntryType="edit", $user_id=0, $parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogChanges($NewObj, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
+ public function LogEvent($EntryType,$EntryText,$user_id=0,$parent_id=0, $parent_class="")
+ {
+ $parent_id = $this->get("identity_id");
+ $parent_class = "Identity";
+ return parent::LogEvent($EntryText, $EntryType, $user_id, $parent_id, $parent_class);
+ }
+
abstract public function SetIdentity($identity_id);
}
Modified: modules/mysql/resource_account.php
===================================================================
--- modules/mysql/resource_account.php 2011-04-29 18:21:40 UTC (rev 76)
+++ modules/mysql/resource_account.php 2011-05-02 14:09:20 UTC (rev 77)
@@ -25,8 +25,7 @@
case "approved":
if($objRequest->get("foreign_state")=='approved' || $objRequest->get("foreign_state")=='none')
{
- $this->Activate();
-
+ $this->Activate();
}
break;
case "expired":
Modified: www/tpl/admin/scripts/list.tpl
===================================================================
--- www/tpl/admin/scripts/list.tpl 2011-04-29 18:21:40 UTC (rev 76)
+++ www/tpl/admin/scripts/list.tpl 2011-05-02 14:09:20 UTC (rev 77)
@@ -36,10 +36,10 @@
<tr class="adminListHeader">
<td> </td>
<td >
- <A HREF="<list:sorturl _Item="EventScript" _ListType="domain_admin" _Column="class_name" />">
+ <A HREF="<list:sorturl _Item="EventScript" _ListType="domain_admin" _Column="item_class" />">
Object Type
</A>
- <img src="<list:sorticon _Item="EventScript" _ListType="domain_admin" _Column="class_name" _DescIcon="images/admin/header_arrow_down.gif" _AscIcon="images/admin/header_arrow_up.gif" />" border=0 align="top">
+ <img src="<list:sorticon _Item="EventScript" _ListType="domain_admin" _Column="item_class" _DescIcon="images/admin/header_arrow_down.gif" _AscIcon="images/admin/header_arrow_up.gif" />" border=0 align="top">
</td>
<td class="adminListHeader">
<A HREF="<list:sorturl _Item="EventScript" _ListType="domain_admin" _Column="event_name" />">
Modified: www/tpl/common/misc/dialog_history.tpl
===================================================================
--- www/tpl/common/misc/dialog_history.tpl 2011-04-29 18:21:40 UTC (rev 76)
+++ www/tpl/common/misc/dialog_history.tpl 2011-05-02 14:09:20 UTC (rev 77)
@@ -10,6 +10,7 @@
<table class="dialog_history_list">
<tr class="list_header">
<td>Date/User</td>
+ <td>Item</td>
<td>Entry Type</td>
<td>Entry</td>
</tr>
Modified: www/tpl/common/misc/dialog_history_item.tpl
===================================================================
--- www/tpl/common/misc/dialog_history_item.tpl 2011-04-29 18:21:40 UTC (rev 76)
+++ www/tpl/common/misc/dialog_history_item.tpl 2011-05-02 14:09:20 UTC (rev 77)
@@ -4,6 +4,10 @@
<item:this _Object="User" _Field="full_name" /> (<item:this _Object="User" _Field="username" />)<br />
</td>
<td>
+ <item:this _Field="item" _ItemField="classname" />:
+ <item:this _Field="item" _ItemField="tostring" />
+ </td>
+ <td>
<item:this _Field="entry_type" />
</td>
<td>
Modified: www/tpl/common/misc/dialog_history_item_alt.tpl
===================================================================
--- www/tpl/common/misc/dialog_history_item_alt.tpl 2011-04-29 18:21:40 UTC (rev 76)
+++ www/tpl/common/misc/dialog_history_item_alt.tpl 2011-05-02 14:09:20 UTC (rev 77)
@@ -1,9 +1,13 @@
<tr class="list_item_alt">
<td>
<item:this _Field="date" _DateField="entry_date" /><br />
- <item:this _Object="User::Identity" _Field="tostring" /><br />
+ <item:this _Object="User" _Field="full_name" /> (<item:this _Object="User" _Field="username" />)<br />
</td>
<td>
+ <item:this _Field="item" _ItemField="classname" />:
+ <item:this _Field="item" _ItemField="tostring" />
+ </td>
+ <td>
<item:this _Field="entry_type" />
</td>
<td>
1
0