Order of installation module "Private messages"

1. Contents of folder "upload" you must upload to root of site;
2. Creating MySQL tables of module. For this with helping of PhpMyAdmin opload contents of file pm.sql to db. If your Eleanor CMS MySQL tables has prefix other than "el_", before uploading change prefix in cretaing-tables-query if file pm.db to your;
3. Creating module in admin panel. Go to Management => Modules => Create module fill fields as in image add-module.png;
4. Upload settings of module to admin panel. Go to Settings (in head menu) -> Import -> Selecting file options.txt and import;
5. Theen in admin go to http://eleanor-cms.ru/admin.php?section=modules&module=pm and click to menu item "group rights". http://eleanor-cms.ru/admin.php?section=modules&do=groups
6. Append to file templates/Uniel/style/main.css:

/* Private messages */
a.isnewpm { font-weight:bold }
#pm div.status { text-align:center; padding:7px;margin:7px 0; display:none; border:1px gray dotted; }
#pm div.ok { background-color:lightgreen; }
#pm div.error { background-color:#f88; }
#pm div.load { background-color:lightblue; }
#pm .files, #pm .images { margin-top:10px;  }
#pm .files ul, #pm .images ul { list-style-type:none;  }

7. Open file js/core.js, find:

	//CTRL + Enter для всех форм
	$(document).on("keypress","form textarea",function(e){
		if(e.keyCode==13 && e.ctrlKey)
			$(this).closest("form").submit();
	})

add after:

	//New messages
	var pmi=$("#pm-indicator");
	if(pmi.size()>0)
	{
		var to,
			already=parseInt($("#pm-indicator a:first").text())||0,
			Pmf;
		Pmf=function(){
			if(CORE.PM && CORE.PM.noupdate)
				return;
			CORE.Ajax(
				{
					module:pmi.data("m"),
					language:CORE.lang_name,
					event:"has-new-posts",
					already:already
				},
				{
					OnBegin:function(){},
					OnEnd:function(){},
					OnFail:function(){},
					OnSuccess:function(r)
					{
						if(r && r.news>already)
						{
							if(confirm(r.text))
								with(window.location)
								{
									href=protocol+"//"+hostname+(port ? ":"+port : "")+CORE.site_path+r.link;
								}
						}
						else
							setTimeout(Pmf,30000);
					}
				}
			);
		}
		setTimeout(Pmf,30000);
	}

8. Open file templates/Uniel/Static/login.php, find:

<div><?php if(Eleanor::$Permissions->IsAdmin()):?><a href="<?php echo Eleanor::$services['admin']['file']?>"><?php echo Eleanor::$Language['main']['adminka']?></a> | <?php endif; ?><a href="<?php echo$Eleanor->Url->special.$Eleanor->Url->Construct(array('module'=>$ma,'do'=>'logout'),false,'')?>"><?php echo Eleanor::$Language['main']['exit']?></a>

Add after:

<?php
$mpm=array_keys($Eleanor->modules['sections'],'pm');
if($mpm)
{
	$pmc=include Eleanor::$root.'modules/pm/config.php';
	$pml=Eleanor::$Language->Load(Eleanor::$root.'modules/pm/lang-*.php',false);
	$mpm=reset($mpm);
	Eleanor::$Db->Query('SELECT COUNT(`status`) FROM `'.$pmc['pd'].'` WHERE `owner`='.(int)Eleanor::$Login->GetUserValue('id').' AND `status`&1=1');
	list($newpm)=Eleanor::$Db->FetchRow();
	echo'<div id="pm-indicator" data-m="'.$mpm.'" style="padding:5px">'.sprintf($pml['pm'],'<a href="'.$Eleanor->Url->special.$Eleanor->Url->Construct(array('module'=>$mpm),false).'"'.($newpm>0 ? ' class="isnewpm"' : '').'>'.($newpm>0 ? $pml['hasnew']($newpm) : $pml['nonew']).'</a>').'</div>';
}
?>

At this time, formed strings:

?>
<?php

 need to be removed.

9. Open file core/others/usermanager.php. Find:

				Eleanor::$Cache->Put('deleted-users',$lastid,true);
			}
		}

Add after:

		if(!class_exists('ApiPm',false))
			include Eleanor::$root.'modules/pm/api.php';
		$PM=new ApiPm();
		$PM->DeleteUser($ids);

10. Open file modules/account/user/guest/register.php find:

				Eleanor::Mail(
					$values['email'],
					Eleanor::ExecBBLogic($l['reg_t'],$repl),
					Eleanor::ExecBBLogic($l['reg_fin'],$repl)
				);

add after:

				if(!class_exists('ApiPm',false))
					include Eleanor::$root.'modules/pm/api.php';
				$PM=new ApiPm();
				$PM->SendRegLetter($id);

11. Open file modules/account/user/user/activate.php find:

Eleanor::$Db->Delete(P.'confirmation','`id`='.(int)$_GET['id'].' LIMIT 1');

add after:

			if(!class_exists('ApiPm',false))
				include Eleanor::$root.'modules/pm/api.php';
			$PM=new ApiPm();
			$PM->SendRegLetter($uinfo['id']);


All bugs send me to a@eleanor-cms.ru .

© Alexander