Foren / Cotonti / Core Labs / Archive / page edit hooks

esclkm
#1 7. Februar 2009, 09:46
we now have available are too few opportunities to hook code into page.edit

example:
now:
list ($ usr [ 'auth_read'], $ usr [ 'auth_write'], $ usr [ 'isadmin']) = sed_auth ( 'page', 'any');
sed_block ($ usr [ 'auth_read']);

$ id = sed_import ( 'id', 'G', 'INT');
$ c = sed_import ( 'c', 'G', 'TXT');

/ / Extra fields - getting
$ extrafields = array ();
$ fieldsres = sed_sql_query ( "SELECT * FROM $ db_extra_fields WHERE field_location = 'pages'");
while ($ row = sed_sql_fetchassoc ($ fieldsres)) $ extrafields [] = $ row;

if ($ a == 'update')
(
$ sql1 = sed_sql_query ( "SELECT page_cat, page_ownerid FROM $ db_pages WHERE page_id = '$ id' LIMIT 1");
Sed_die (sed_sql_numrows ($ sql1) == 0);
$ Row1 = sed_sql_fetcharray ($ sql1);

list ($ usr [ 'auth_read'], $ usr [ 'auth_write'], $ usr [ 'isadmin']) = sed_auth ( 'page', $ row1 [ 'page_cat']);
Sed_block ($ usr [ 'isadmin']);

/ * === Hook === * /
$ extp = sed_getextplugins ( 'page.edit.update.first');
If (is_array ($ extp))
(Foreach ($ extp as $ k => $ pl) (include_once ($ cfg [ 'plugins_dir'].'/'.$ pl [' pl_code'].'/'.$ pl [ 'pl_file'].'. php ');))
/ * ===== * /

I believe that is more optional:
list ($ usr [ 'auth_read'], $ usr [ 'auth_write'], $ usr [ 'isadmin']) = sed_auth ( 'page', 'any');
sed_block ($ usr [ 'auth_read']);

$ id = sed_import ( 'id', 'G', 'INT');
$ c = sed_import ( 'c', 'G', 'TXT');

/ / Extra fields - getting
$ extrafields = array ();
$ fieldsres = sed_sql_query ( "SELECT * FROM $ db_extra_fields WHERE field_location = 'pages'");
while ($ row = sed_sql_fetchassoc ($ fieldsres)) $ extrafields [] = $ row;

$ sql1 = sed_sql_query ( "SELECT page_cat, page_ownerid FROM $ db_pages WHERE page_id = '$ id' LIMIT 1");
Sed_die (sed_sql_numrows ($ sql1) == 0);
$ Row1 = sed_sql_fetcharray ($ sql1);

list ($ usr [ 'auth_read'], $ usr [ 'auth_write'], $ usr [ 'isadmin']) = sed_auth ( 'page', $ row1 [ 'page_cat']);
/ * === Hook === * /
$ Extp = sed_getextplugins ( 'page.edit.first');
If (is_array ($ extp))
(Foreach ($ extp as $ k => $ pl) (include_once ($ cfg [ 'plugins_dir'].'/'.$ pl [' pl_code'].'/'.$ pl [ 'pl_file'].'. php ');))
/ * ===== * /


if ($ a == 'update')
(
Sed_block ($ usr [ 'isadmin']);
to understand why I think so: blogs and why developers do not want to sell through a simple page and make the individual plugins without using pages; or plugin for seditio "users edit own pages" - compare files of plugin and file users.edit in Seditio

analogical pages.add

What do you think about this?[/][/]
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
Trustmaster
#2 9. Februar 2009, 16:59
I think a hook before sed_block is really needed. This would eliminate duplicated code in things like eyoop. So I think we can just add the hook 'page.edit.first' and that will be fine.
May the Source be with you!
esclkm
#3 10. Februar 2009, 01:31
on my place or other?
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
Trustmaster
#4 10. Februar 2009, 01:45
Actually, this fix is not quite right for what you're going to do. What we need is to affect access privileges on a concrete item from within a plugin, an additional hook is just a dirty way to intercept the execution flow. There should be a better way to affect that auth check.
May the Source be with you!
esclkm
#5 10. Februar 2009, 03:12
your ideas?
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
Trustmaster
#6 10. Februar 2009, 04:54
Nothing brilliant at the moment, need to think it over later or see some other opinions in this topic.
May the Source be with you!
esclkm
#7 21. Februar 2009, 18:44
Simple Idea! Trustmuster or Kilandor - say what do you think about it.
now:
	list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = sed_auth('page', $row1['page_cat']);
	sed_block($usr['isadmin']);

	/* === Hook === */
	$extp = sed_getextplugins('page.edit.update.first');
	if (is_array($extp))
	{ foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
	/* ===== */

and
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = sed_auth('page', $pag['page_cat']);
sed_block($usr['isadmin']);

/* === Hook === */
$extp = sed_getextplugins('page.edit.first');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */


I think better is:
	list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = sed_auth('page', $row1['page_cat']);

	/* === Hook === */
	$extp = sed_getextplugins('page.edit.update.first');
	if (is_array($extp))
	{ foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
	/* ===== */
	sed_block($usr['isadmin']);

and
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = sed_auth('page', $pag['page_cat']);
/* === Hook === */
$extp = sed_getextplugins('page.edit.first');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */
sed_block($usr['isadmin']);


What do you think about this?
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
Trustmaster
#8 22. Februar 2009, 00:12
Yes, I approve this because currently there is no other way to overcome these limitations.
May the Source be with you!
esclkm
#9 22. Februar 2009, 00:17
thx )
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты