import v1.0.0-RC4 | 2009-05-20
This commit is contained in:
15
modules/default/models/Association.php
Normal file
15
modules/default/models/Association.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Association extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
26
modules/default/models/Associations.php
Normal file
26
modules/default/models/Associations.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Associations extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'associations';
|
||||
protected $_primary = 'handle';
|
||||
protected $_rowClass = 'Association';
|
||||
|
||||
public function getAssociationGivenHandle($handle)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('handle=?', $handle);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
}
|
68
modules/default/models/Field.php
Normal file
68
modules/default/models/Field.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Field extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const TYPE_TEXT = 1;
|
||||
const TYPE_DATE = 2;
|
||||
const TYPE_GENDER = 3;
|
||||
const TYPE_COUNTRY = 4;
|
||||
const TYPE_LANGUAGE = 5;
|
||||
const TYPE_TIMEZONE = 6;
|
||||
const TYPE_EMAIL = 7;
|
||||
|
||||
public function getFormElement()
|
||||
{
|
||||
$varname = 'field_' . $this->id;
|
||||
|
||||
switch ($this->type) {
|
||||
case self::TYPE_TEXT:
|
||||
$el = new Monkeys_Form_Element_Text($varname);
|
||||
break;
|
||||
case self::TYPE_DATE:
|
||||
$el = new Monkeys_Form_Element_Date($varname);
|
||||
$el->addValidator('date')
|
||||
->setShowEmptyValues(true)
|
||||
->setStartEndYear(1900, date('Y') - 7)
|
||||
->setReverseYears(true);
|
||||
break;
|
||||
case self::TYPE_GENDER:
|
||||
translate('Male');
|
||||
translate('Female');
|
||||
$el = new Monkeys_Form_Element_Radio($varname);
|
||||
$el->setSeparator('  ')
|
||||
->addMultiOption('M', 'Male')
|
||||
->addMultiOption('F', 'Female');
|
||||
break;
|
||||
case self::TYPE_COUNTRY:
|
||||
$el = new Monkeys_Form_Element_Country($varname);
|
||||
break;
|
||||
case self::TYPE_LANGUAGE:
|
||||
$el = new Monkeys_Form_Element_Language($varname);
|
||||
break;
|
||||
case self::TYPE_TIMEZONE:
|
||||
$el = new Monkeys_Form_Element_Timezone($varname);
|
||||
break;
|
||||
case self::TYPE_EMAIL:
|
||||
$el = new Monkeys_Form_Element_Text($varname);
|
||||
$el->addValidator('EmailAddress');
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Unknown field type: ' . $this->type);
|
||||
break;
|
||||
}
|
||||
$el->setLabel($this->name);
|
||||
$el->setValue($this->value);
|
||||
|
||||
return $el;
|
||||
}
|
||||
}
|
55
modules/default/models/Fields.php
Normal file
55
modules/default/models/Fields.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Fields extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'fields';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Field';
|
||||
|
||||
private $_fieldsNames= array();
|
||||
|
||||
public function getValues(User $user)
|
||||
{
|
||||
$userId = (int)$user->id;
|
||||
$select = $this->select()
|
||||
->setIntegrityCheck(false)
|
||||
->from('fields')
|
||||
->joinLeft('fields_values', "fields_values.field_id=fields.id AND fields_values.user_id=".$user->id);
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getFieldName($fieldIdentifier)
|
||||
{
|
||||
if (!$this->_fieldsNames) {
|
||||
foreach ($this->fetchAll($this->select()) as $field) {
|
||||
$this->_fieldsNames[$field->openid] = $field->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_fieldsNames[$fieldIdentifier];
|
||||
}
|
||||
|
||||
private function _translationPlaceholders()
|
||||
{
|
||||
translate('Nickname');
|
||||
translate('E-mail');
|
||||
translate('Full Name');
|
||||
translate('Date of Birth');
|
||||
translate('Gender');
|
||||
translate('Postal Code');
|
||||
translate('Country');
|
||||
translate('Language');
|
||||
translate('Time Zone');
|
||||
}
|
||||
}
|
15
modules/default/models/FieldsValue.php
Normal file
15
modules/default/models/FieldsValue.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class FieldsValue extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
24
modules/default/models/FieldsValues.php
Normal file
24
modules/default/models/FieldsValues.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class FieldsValues extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'fields_values';
|
||||
protected $_primary = array('user_id', 'field_id');
|
||||
protected $_rowClass = 'FieldsValue';
|
||||
|
||||
public function deleteForUser(User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('user_id=?', $user->id);
|
||||
$this->delete($where);
|
||||
}
|
||||
}
|
51
modules/default/models/Histories.php
Executable file
51
modules/default/models/Histories.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Histories extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'history';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'History';
|
||||
|
||||
public function get(User $user, $startIndex, $results)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
if ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumHistories(User $user)
|
||||
{
|
||||
$sites = $this->get($user, false, false);
|
||||
|
||||
return count($sites);
|
||||
}
|
||||
|
||||
public function clear(User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('user_id=?', $user->id);
|
||||
$this->delete($where);
|
||||
}
|
||||
|
||||
public function clearOldEntries()
|
||||
{
|
||||
$days = Zend_Registry::get('config')->environment->keep_history_days;
|
||||
|
||||
$where = $this->getAdapter()->quoteInto('date < ?', date('Y-m-d', time() - $days * 86400));
|
||||
$this->delete($where);
|
||||
}
|
||||
}
|
17
modules/default/models/History.php
Executable file
17
modules/default/models/History.php
Executable file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class History extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const DENIED = 0;
|
||||
const AUTHORIZED = 1;
|
||||
}
|
38
modules/default/models/Settings.php
Normal file
38
modules/default/models/Settings.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Settings extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'settings';
|
||||
protected $_primary = 'name';
|
||||
|
||||
const MAINTENANCE_MODE = 'maintenance_mode';
|
||||
|
||||
public function get($name)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('name=?', $name);
|
||||
|
||||
$row = $this->fetchRow($select);
|
||||
|
||||
return $row->value;
|
||||
}
|
||||
|
||||
public function set($name, $value)
|
||||
{
|
||||
$this->update(array('value' => $value), $this->getAdapter()->quoteInto('name=?', $name));
|
||||
}
|
||||
|
||||
public function isMaintenanceMode()
|
||||
{
|
||||
return $this->get(self::MAINTENANCE_MODE);
|
||||
}
|
||||
}
|
15
modules/default/models/Site.php
Normal file
15
modules/default/models/Site.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Site extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
}
|
52
modules/default/models/Sites.php
Normal file
52
modules/default/models/Sites.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Sites extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'sites';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'Site';
|
||||
|
||||
public function deleteForUserSite(User $user, $site)
|
||||
{
|
||||
$where1 = $this->getAdapter()->quoteInto('user_id=?',$user->id);
|
||||
$where2 = $this->getAdapter()->quoteInto('site=?', $site);
|
||||
$this->delete("$where1 AND $where2");
|
||||
}
|
||||
|
||||
public function get(User $user, $startIndex, $results)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
if ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumSites(User $user)
|
||||
{
|
||||
$sites = $this->get($user, false, false);
|
||||
|
||||
return count($sites);
|
||||
}
|
||||
|
||||
public function getTrusted(User $user)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('user_id=?', $user->id);
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user