From: <wis...@us...> - 2012-05-26 08:30:27
|
Revision: 9593 http://xoops.svn.sourceforge.net/xoops/?rev=9593&view=rev Author: wishcraft Date: 2012-05-26 08:30:17 +0000 (Sat, 26 May 2012) Log Message: ----------- LinkedINBomb 1.01 - Prealpha - Still in development phase. Need a break ;-) Added Paths: ----------- XoopsModules/linkedinbomb/ XoopsModules/linkedinbomb/branches/ XoopsModules/linkedinbomb/releases/ XoopsModules/linkedinbomb/trunk/ XoopsModules/linkedinbomb/trunk/docs/ XoopsModules/linkedinbomb/trunk/htdocs/ XoopsModules/linkedinbomb/trunk/htdocs/modules/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/admin/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/blocks/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/blocks/linkedin_signin.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/callback/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/callback/index.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/addresses.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr_http_headers.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/authorities.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/causes.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies_type.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/connections.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/contact_info.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/countries.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/following_companies.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/industry.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/languages.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/locations.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/oauth.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/organization.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/persons.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/proficiencies.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_certifications.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_companies.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_courses.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_educations.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_ims.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_languages.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_patents.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_patents_inventors.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_patents_office.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_patents_status.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_phones.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_positions.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_providers.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_publications.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_publications_authors.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_recommendations.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_skills.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/profiles_volunteer.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/skills.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/specialties.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/status.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/years.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/getemail.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/header.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/images/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/images/linkedin-small.png XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/images/linkedinbomb_slogo.png XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/include/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/include/OAuth.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/include/formobjects.linkedinbomb.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/include/forms.a.linkedinbomb.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/include/functions.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/include/linkedin.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/index.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/blocks.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/email.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/forms.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/mail_templates/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/mail_templates/linkedin_email_user_created.html XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/main.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/language/english/modinfo.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/preloads/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/preloads/email.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/signed.php XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/sql/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/sql/mysql.sql XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/templates/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/templates/blocks/ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/templates/blocks/linkedin_block_signin.html XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/templates/linkedinbomb_get_email.html XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/xoops_version.php Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/blocks/linkedin_signin.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/blocks/linkedin_signin.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/blocks/linkedin_signin.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,15 @@ +<?php + + function b_linkedin_block_signin_show($options) { + $_SESSION['oauth']['linkedin']['authorized'] = (isset($_SESSION['oauth']['linkedin']['authorized'])) ? $_SESSION['oauth']['linkedin']['authorized'] : FALSE; + if ($_SESSION['oauth']['linkedin']['authorized']===true) + return false; + xoops_loadLanguage('blocks', 'linkedinbomb'); + return array('display' => ($_SESSION['oauth']['linkedin']['authorized']===false?true:false)); + } + + function b_linkedin_block_signin_edit($options) { + + } + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/callback/index.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/callback/index.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/callback/index.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,71 @@ +<?php + + include(dirname(dirname(dirname(dirname(__FILE__)))).'/mainfile.php'); + + $oauth_handler = xoops_getmodulehandler('oauth', 'linkedinbomb'); + + $_REQUEST[LINKEDIN::_GET_TYPE] = (isset($_REQUEST[LINKEDIN::_GET_TYPE])) ? $_REQUEST[LINKEDIN::_GET_TYPE] : ''; + switch($_REQUEST[LINKEDIN::_GET_TYPE]) { + case 'initiate': + $_GET[LINKEDIN::_GET_RESPONSE] = (isset($_GET[LINKEDIN::_GET_RESPONSE])) ? $_GET[LINKEDIN::_GET_RESPONSE] : ''; + if(!isset($_GET[LINKEDIN::_GET_RESPONSE])|empty($_GET[LINKEDIN::_GET_RESPONSE])) { + // LinkedIn hasn't sent us a response, the user is initiating the connection + // send a request for a LinkedIn access token + $response = $oauth_handler->_api->retrieveTokenRequest(); + if($response['success'] === TRUE) { + // store the request token + $_SESSION['oauth']['linkedin']['request'] = $response['linkedin']; + + // redirect the user to the LinkedIn authentication/authorisation page to initiate validation. + header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']); + } else { + // bad token request + echo "Request token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>"; + } + } else { + // LinkedIn has sent a response, user has granted permission, take the temp access token, the user's secret and the verifier to request the user's real secret key + $response = $oauth_handler->_api->retrieveTokenAccess($_SESSION['oauth']['linkedin']['request']['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']); + if($response['success'] === TRUE) { + // the request went through without an error, gather user's 'access' tokens + $_SESSION['oauth']['linkedin']['access'] = $response['linkedin']; + + // set the user as authorized for future quick reference + $_SESSION['oauth']['linkedin']['authorized'] = TRUE; + + // redirect the user back to the demo page + header('Location: ' . XOOPS_URL.'/modules/linkedinbomb/signed.php'); + } else { + // bad token access + echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>"; + } + } + break; + case 'revoke': + /** + * Handle authorization revocation. + */ + + // check the session + if(!oauth_session_exists()) { + throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.'); + } + + $oauth_handler->_api->setTokenAccess($_SESSION['oauth']['linkedin']['access']); + $response = $oauth_handler->_api->revoke(); + if($response['success'] === TRUE) { + // revocation successful, clear session + session_unset(); + $_SESSION = array(); + if(session_destroy()) { + // session destroyed + header('Location: ' . XOOPS_URL); + } else { + // session not destroyed + echo "Error clearing user's session"; + } + } else { + // revocation failed + echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>"; + } + break; + } \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/addresses.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/addresses.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/addresses.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,175 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombAddresses extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('address_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('street1', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('street2', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('city', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('postal-code', XOBJ_DTYPE_TXTBOX, null, false, 20); + $this->initVar('country_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombAddressesHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombAddresses')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + + function getName() { + return $this->getVar('street1').', '.$this->getVar('city').', '.$this->getVar('postal-code'); + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombAddressesHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_addresses', 'LinkedinbombAddresses', "address_id", "street1"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + if ($object->getVar('profile_id')>0&&$object->getVar('person_id')==0) { + $profile_handler = xoops_getmodulehandler('profiles', 'linkedinbomb'); + $profile = $profile_handler->get($object->getVar('profile_id')); + $object->setVar('person_id', $profile->getVar('person_id')); + } elseif ($object->getVar('profile_id')==0&&$object->getVar('person_id')>0) { + $persons_handler = xoops_getmodulehandler('persons', 'linkedinbomb'); + $person = $persons_handler->get($object->getVar('person_id')); + $object->setVar('profile_id', $person->getVar('profile_id')); + } + return parent::insert($object, $force); + } + + +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,174 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombAspr extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('aspr_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('profile_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('person_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('request_person_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('request_profile_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('url', XOBJ_DTYPE_URL, null, false, 500); + $this->initVar('http_headers_ids', XOBJ_DTYPE_ARRAY, array(), false); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombAsprHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombAspr')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + function getName() { + return $this->getVar('aspr_id'); + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombAsprHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_aspr', 'LinkedinbombAspr', "aspr_id", "url"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + if ($object->getVar('profile_id')>0&&$object->getVar('person_id')==0) { + $profile_handler = xoops_getmodulehandler('profiles', 'linkedinbomb'); + $profile = $profile_handler->get($object->getVar('profile_id')); + $object->setVar('person_id', $profile->getVar('person_id')); + } elseif ($object->getVar('profile_id')==0&&$object->getVar('person_id')>0) { + $persons_handler = xoops_getmodulehandler('persons', 'linkedinbomb'); + $person = $persons_handler->get($object->getVar('person_id')); + $object->setVar('profile_id', $person->getVar('profile_id')); + } + return parent::insert($object, $force); + } + +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr_http_headers.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr_http_headers.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/aspr_http_headers.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,163 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombAspr_http_headers extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('http_headers_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('aspr_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 64); + $this->initVar('value', XOBJ_DTYPE_TXTBOX, null, false, 64); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombAspr_http_headersHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombAspr_http_headers')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + + function getName() { + return $this->getVar('name').': '.$this->getVar('value').' ('.$this->getVar('aspr_id').')'; + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombAspr_http_headersHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_aspr_http_headers', 'LinkedinbombAspr_http_headers', "http_headers_id", "aspr_id"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + return parent::insert($object, $force); + } + +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/authorities.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/authorities.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/authorities.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,170 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombAuthorities extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('authority_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('id', XOBJ_DTYPE_TXTBOX, null, false, 32); + $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 198); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombAuthoritiesHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombAuthorities')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + function getName() { + return $this->getVar('name').' ('.$this->getVar('id').')'; + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombAuthoritiesHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_authorities', 'LinkedinbombAuthorities', "authority_id", "id"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $object = $this->getByCriteria($criteria); + if (is_object($object)) { + return $object->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + if ($object->getVar('profile_id')>0&&$object->getVar('person_id')==0) { + $profile_handler = xoops_getmodulehandler('profiles', 'linkedinbomb'); + $profile = $profile_handler->get($object->getVar('profile_id')); + $object->setVar('person_id', $profile->getVar('person_id')); + } elseif ($object->getVar('profile_id')==0&&$object->getVar('person_id')>0) { + $persons_handler = xoops_getmodulehandler('persons', 'linkedinbomb'); + $person = $person_handler->get($object->getVar('person_id')); + $object->setVar('profile_id', $person->getVar('profile_id')); + } + return parent::insert($object, $force); + } + +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/causes.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/causes.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/causes.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,161 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombCauses extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('cause_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('id', XOBJ_DTYPE_TXTBOX, null, false, 32); + $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 198); + $this->initVar('profile_ids', XOBJ_DTYPE_ARRAY, array(), false); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombCausesHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombCauses')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + function getName() { + return $this->getVar('name').' ('.$this->getVar('id').')'; + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombCausesHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_causes', 'LinkedinbombCauses', "cause_id", "id"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + return parent::insert($object, $force); + } +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,176 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombCompanies extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('company_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('id', XOBJ_DTYPE_TXTBOX, null, false, 32); + $this->initVar('universal-name', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('ticker', XOBJ_DTYPE_TXTBOX, null, false, 10); + $this->initVar('logo-url', XOBJ_DTYPE_URL, null, false, 500); + $this->initVar('description', XOBJ_DTYPE_TXTBOX, null, false, 500); + $this->initVar('company-type_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('industry', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('size', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('specialties_ids', XOBJ_DTYPE_ARRAY, array(), false); + $this->initVar('blog-rss-url', XOBJ_DTYPE_URL, null, false, 500); + $this->initVar('twitter-id', XOBJ_DTYPE_TXTBOX, null, false, 64); + $this->initVar('square-logo-url', XOBJ_DTYPE_URL, null, false, 500); + $this->initVar('location_ids', XOBJ_DTYPE_ARRAY, array(), false); + $this->initVar('founded-year', XOBJ_DTYPE_TXTBOX, null, false, 4); + $this->initVar('email-domain_ids', XOBJ_DTYPE_ARRAY, array(), false); + $this->initVar('website-url', XOBJ_DTYPE_URL, null, false, 500); + $this->initVar('status_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombCompaniesHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombCompanies')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + function getName() { + return $this->getVar('street1').', '.$this->getVar('city').', '.$this->getVar('postal-code'); + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombCompaniesHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_companies', 'LinkedinbombCompanies', "company_id", "name"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + return parent::insert($object, $force); + } +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies_type.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies_type.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/companies_type.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,160 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombCompanies_type extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('company-type_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('code', XOBJ_DTYPE_TXTBOX, null, false, 4); + $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 128); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); + + if ($id>0) { + $handler = new LinkedinbombCompanies_typeHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombCompanies_type')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + function getName() { + return $this->getVar('name').' ('.$this->getVar('code').')'; + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombCompanies_typeHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_companies_type', 'LinkedinbombCompanies_type', "company-type_id", "code"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + return parent::insert($object, $force); + } +} + +?> \ No newline at end of file Added: XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/connections.php =================================================================== --- XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/connections.php (rev 0) +++ XoopsModules/linkedinbomb/trunk/htdocs/modules/linkedinbomb/class/connections.php 2012-05-26 08:30:17 UTC (rev 9593) @@ -0,0 +1,184 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) { + exit(); +} +/** + * Class for Blue Room Xcenter + * @author Simon Roberts <si...@xo...> + * @copyright copyright (c) 2009-2003 XOOPS.org + * @package kernel + */ +class LinkedinbombConnections extends XoopsObject +{ + + function __construct($id = null) + { + $this->initVar('connections_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('request_profile_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('request_person_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('connection_person_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('connection_profile_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('connection_aspr_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('person_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('profile_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('aspr_id', XOBJ_DTYPE_INT, null, false); + $this->initVar('created', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + $this->initVar('updated', XOBJ_DTYPE_INT, null, false); // Removed Unicode in 2.10 + + if ($id>0) { + $handler = new LinkedinbombConnectionsHandler($GLOBALS['xoopsDB']); + $object = $handler->get($id); + if (is_object($object)) { + if (is_a($object, 'LinkedinbombConnections')) { + $this->assignVars($object->getValues()); + } + } + unset($object); + } + } + + function setVar($field, $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + + function setVars($arr, $not_gpc=false) { + foreach($arr as $field => $value) { + switch ($this->vars[$field]['data_type']) { + case XOBJ_DTYPE_ARRAY: + if (md5(serialize($value))!=md5(serialize($this->getVar($field)))) + parent::setVar($field, $value); + break; + default: + if (md5($value)!=md5($this->getVar($field))) + parent::setVar($field, $value); + break; + } + } + } + function getName() { + return $this->getVar('connections_id').', '.$this->getVar('person_id').', '.$this->getVar('request_person_id'); + } + + function getForm($as_array=false, $title='') { + $class = explode('.',basename(__FILE__)); + unset($class[sizeof($class)-1]); + $class = implode('.',$class); + // Gets Title + xoops_loadLanguage('forms', 'linkedinbomb'); + if (empty($title)) { + if ($this->isNew()) { + $title = constant("FRM_LINKEDIN_TITLE_NEW_".strtoupper($class)); + } else { + $title = sprintf(constant("FRM_LINKEDIN_TITLE_EDIT_".strtoupper($class)), $this->getName()); + } + } + // Gets Form + $func = 'linkedin_form_item_'.$class; + if (function_exists($func)) { + return $func($this, $title, $as_array); + } + } + + function toArray() { + $ret = parent::toArray(); + if (isset($ret['created'])&&$ret['created']>0) { + $ret['created'] = date(_DATESTRING, $ret['created']); + } + if (isset($ret['updated'])&&$ret['updated']>0) { + $ret['updated'] = date(_DATESTRING, $ret['updated']); + } + if (isset($ret['emailed'])&&$ret['emailed']>0) { + $ret['emailed'] = date(_DATESTRING, $ret['emailed']); + } + if (is_array($form = $this->getForm(true, ''))) { + foreach($form as $field => $element) { + $ret['form'][$field] = $form[$field]->render(); + } + } + return $ret; + } + +} + + +/** +* XOOPS policies handler class. +* This class is responsible for providing data access mechanisms to the data source +* of XOOPS user class objects. +* +* @author Simon Roberts <si...@ch...> +* @package kernel +*/ +class LinkedinbombConnectionsHandler extends XoopsPersistableObjectHandler +{ + function __construct(&$db) + { + $this->db = $db; + parent::__construct($db, 'lib_connections', 'LinkedinbombConnections', "connections_id", "person_id"); + } + + function getByCriteria($criteria = NULL) { + if ($this->getCount($criteria)==0) + return $this->create(); + $criteria->setStart(0); + $criteria->setLimit(1); + $objects = $this->getObjects($criteria, false); + if (!is_object($objects[0])) + return $this->create(); + return $objects[0]; + } + + function insert($object, $force = true) { + if($object->isNew()) { + $criteria = new CriteriaCompo(); + foreach($object->vars as $field => $values) { + if (!in_array($field, array($this->keyName, 'searched', 'polled', 'emailed', 'sms', 'synced', 'created', 'updated'))) + if ($values['type']!=XOBJ_DTYPE_ARRAY) + if (!empty($values['value'])||intval($values['value'])<>0) + $criteria->add(new Criteria('`'.$field.'`', $object->getVar($field))); + } + if ($this->getCount($criteria)>0) { + $obj = $this->getByCriteria($criteria); + if (is_object($obj)) { + return $obj->getVar($this->keyName); + } + } + $object->setVar('created', time()); + } else { + if (!$object->isDirty()) + return $object->getVar($this->keyName); + $object->setVar('updated', time()); + } + if ($object->getVar('profile_id')>0&&$object->getVar('person_id')==0) { + $profile_handler = xoops_getmodulehandler('profiles', 'linkedinbomb'); + $profile = $profile_handler->get($object->getVar('profile_id')); + $object->setVar('person_id', $profile->getVar('person_id')); + } elseif ($object->getVar('profile_id')==0&&$object->getVar('person_id')>0) { + $persons_handler = xoops_getmodulehandler('persons', 'linkedinbomb'); + $person = $persons_handler->get($object->getVar('person_id')); + $object->setVar('profile_id', $person->getVar('profile_id')); + } + if ($object->getVar('request_profile_id')>0&&$object->getVar('request_person_id')==0) { + $profile_handler = xoops_getmodulehandler('profiles', 'linkedinbomb'); + $profile = $profile_handler->get($object->getVar('request_profile_id')); + ... [truncated message content] |