Index: branches/5.2.x/core/units/users/users_item.php =================================================================== diff -u -N -r14447 -r14596 --- branches/5.2.x/core/units/users/users_item.php (.../users_item.php) (revision 14447) +++ branches/5.2.x/core/units/users/users_item.php (.../users_item.php) (revision 14596) @@ -1,6 +1,6 @@ GetDBField('Status')) { + switch ( $this->GetDBField('Status') ) { case STATUS_ACTIVE: $event_name = $this->Application->ConfigValue('User_Password_Auto') ? 'USER.VALIDATE' : 'USER.ADD'; $this->Application->EmailEventAdmin($event_name); @@ -62,45 +62,87 @@ * * @return bool */ - function isSubscriberOnly() + public function isSubscriberOnly() { return $this->GetDBField('PrimaryGroupId') == $this->Application->ConfigValue('User_SubscriberGroup'); } - function Create($force_id=false, $system_create=false) + /** + * Checks that user is subscribed + * + * @return bool + */ + public function isSubscribed() { + $group_id = $this->Application->ConfigValue('User_SubscriberGroup'); + + $sql = 'SELECT GroupId + FROM ' . TABLE_PREFIX . 'UserGroup + WHERE (PortalUserId = ' . $this->GetID() . ') AND (GroupId = ' . $group_id . ')'; + + return $this->Conn->GetOne($sql); + } + + /** + * Creates a record in the database table with current item' values + * + * @param mixed $force_id Set to TRUE to force creating of item's own ID or to value to force creating of passed id. Do not pass 1 for true, pass exactly TRUE! + * @param bool $system_create + * @return bool + * @access public + */ + public function Create($force_id = false, $system_create = false) + { $ret = parent::Create($force_id, $system_create); - if ($ret) { - // find out how to syncronize user only when it's copied to live table - $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); + if ( $ret ) { + // find out how to synchronize user only when it's copied to live table + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array (), Array ('InPortalSyncronize')); + /* @var $sync_manager UsersSyncronizeManager */ + $sync_manager->performAction('createUser', $this->FieldValues); } return $ret; } - - function Update($id=null, $system_update=false) + /** + * Updates previously loaded record with current item' values + * + * @access public + * @param int $id Primary Key Id to update + * @param bool $system_update + * @return bool + * @access public + */ + public function Update($id = null, $system_update = false) { $ret = parent::Update($id, $system_update); - if ($ret) { - // find out how to syncronize user only when it's copied to live table - $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); + + if ( $ret ) { + // find out how to synchronize user only when it's copied to live table + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array (), Array ('InPortalSyncronize')); + /* @var $sync_manager UsersSyncronizeManager */ + $sync_manager->performAction('updateUser', $this->FieldValues); } + return $ret; } /** - * Deletes the record from databse - * - * @access public - * @return bool - */ - function Delete($id = null) + * Deletes the record from database + * + * @param int $id + * @return bool + * @access public + */ + public function Delete($id = null) { $ret = parent::Delete($id); - if ($ret) { - $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); + + if ( $ret ) { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array (), Array ('InPortalSyncronize')); + /* @var $sync_manager UsersSyncronizeManager */ + $sync_manager->performAction('deleteUser', $this->FieldValues); }