Update of
/var/cvs/Geeklog-2.x/Geeklog-2.x/plugins/link/models
In directory
iowaoutdoors:/tmp/cvs-serv12756/plugins/link/models
Modified Files:
Gl2LinkPeer.php
Log Message:
Basic testing of Link SOAP interface OK.
Added 10 initial unit tests, OK.
No transaction in Peer::saveLinks, doesn't work with one in
there??
Index: Gl2LinkPeer.php
============================================================
=======
RCS file:
/var/cvs/Geeklog-2.x/Geeklog-2.x/plugins/link/models/Gl2Link
Peer.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Gl2LinkPeer.php 7 Jun 2006 04:06:21 -0000 1.2
--- Gl2LinkPeer.php 13 Jun 2006 04:00:50 -0000 1.3
***************
*** 1,3 ****
! <?php
// The parent class
require_once
'plugins/link/models/om/BaseGl2LinkPeer.php';
--- 1,3 ----
! s<?php
// The parent class
require_once
'plugins/link/models/om/BaseGl2LinkPeer.php';
***************
*** 13,16 ****
--- 13,17 ----
require_once 'ActionManager.php';
+ require_once 'UrlUtility.php';
/**
***************
*** 115,135 ****
// Start a database transaction.
! $dao->beginTransaction();
$ret = 0;
! $savedLinks = array();
foreach ($linkArray as $linkToSave) {
$item = null;
$link = null;
! if ((empty($linkToSave->linkId) ||
$linkToSave->linkId == 0)) {
! if ($create !== TRUE) {
! throw new Exception('One or more new
links were submitted, but the create flag was not set to
true.');
}
$link = new Gl2Link();
$item = new Gl2Item();
! $item->setGl2User($user);
!
! // Default date created to current time
! $item->setDateCreated(time());
// Assign the initial state
--- 116,135 ----
// Start a database transaction.
! //$dao->beginTransaction();
$ret = 0;
! // $savedLinks = array();
foreach ($linkArray as $linkToSave) {
$item = null;
$link = null;
! $testId = $linkToSave->getLinkId();
! $userobj =
Gl2UserPeer::retrieveByPK($user->getUserId());
! if (empty($testId) || $testId == 0) {
! if (!$create) {
! throw new Exception('Specify create =
true to create new links.');
}
$link = new Gl2Link();
$item = new Gl2Item();
! $item->setGl2User($userobj);
// Assign the initial state
***************
*** 142,145 ****
--- 142,147 ----
$link = $dao->get($linkToSave);
$item = $link->getGl2Item();
+
+
$glDao->deleteWithCondition('deleteItemAcls',
array($item->getItemId()));
}
***************
*** 156,172 ****
$link->setSiteName($linkToSave->getSiteName());
// Before we do anything else, let's verify
the URL works
! if ($validate === TRUE) {
! if
(!Geeklog_UrlUtility::isValidUrl($link->getUrl())) {
! throw new Exception("URL
{$link->getUrl()} could not be verified. Either it does
not exist or there are network issues");
! } else {
$link->setLastValidated(time());
}
}
-
$glDao->deleteWithCondition('deleteItemAcls',
array($item->getItemId()));
-
// Add ACLs to the gl2_item record that
represents the link
! foreach ($aclLocal as $aclItem) {
$item->addGl2ItemAcl($aclItem);
}
--- 158,183 ----
$link->setSiteName($linkToSave->getSiteName());
+ $item->setDateCreated(time());
+ $todTemp = gettimeofday();
+ $micro = (int)$todTemp['usec'];
+ $item->setRewriteId(date('YmdHis') .
$micro);
+ $item->setLeftIndex(1);
+ $item->setRightIndex(1);
+
// Before we do anything else, let's verify
the URL works
! if ($validate) {
! $url = $link->getUrl();
! $timeout = 3;
! if (Geeklog_UrlUtility::isValidUrl($url,
$timeout)) {
$link->setLastValidated(time());
+ } else {
+ //$msg = 'A URL could not be
verified. Either it does not exist or there are network
issues';
+ $msg = "The specified URL could
not be validated: $url";
+ throw new Exception($msg);
}
}
// Add ACLs to the gl2_item record that
represents the link
! foreach ($ACLArray as $aclItem) {
$item->addGl2ItemAcl($aclItem);
}
***************
*** 181,200 ****
// 4) It will assign the user to the item
try {
- //print_r($link); exit;
$dao->save($link);
} catch (Exception $e) {
! $dao->rollback();
! throw $e;
}
$ret++;
! $savedLinks[] = $link;
}
!
! $dao->commit();
!
// Notify any other plugins about the set of links
that were just saved
! require_once 'ActionManager.php';
! Geeklog_ActionManager::notify('LINK_SAVE',
$savedLinks);
return $ret;
--- 192,215 ----
// 4) It will assign the user to the item
try {
$dao->save($link);
+
+ // Notify any other plugins about the set
of links that were just saved
+ require_once 'ActionManager.php';
+
Geeklog_ActionManager::notify('LINK_SAVE', array($link));
+
} catch (Exception $e) {
! //$dao->rollback();
! throw new Exception('Rolled back a link
transaction: '.$e->getMessage());
}
$ret++;
! // $savedLinks[] = $link;
}
!
! //$dao->commit();
!
// Notify any other plugins about the set of links
that were just saved
! // require_once 'ActionManager.php';
! // Geeklog_ActionManager::notify('LINK_SAVE',
$savedLinks);
return $ret;
_______________________________________________
geeklog2-cvs mailing list
geeklog2-cvs lists.geeklog.net
http://lists.geeklog.net/mailman/listinfo/geeklog2-cvs
|