определенное количество друзей.
За основу взял инструкцию instantcms.ru/forum/thread4625.html
Но для Instantcms 1.10.4 она определенно немного устарела.
Начнем:
1) Делаем запрос в базу(добавляем поле друзей).
ALTER TABLE cms_user_autoawards ADD p_friends int(11) AFTER p_karma
admin\components\autoawards\backend.php
Находим код:
if ($opt == 'submit' || $opt == 'update'){ if (!cmsCore::validateForm()) { cmsCore::error404(); } $title = cmsCore::request('title', 'str', $_LANG['AD_AWARD']); $description = cmsCore::request('description', 'str', ''); $published = cmsCore::request('published', 'int', 0); $p_comment = cmsCore::request('p_comment', 'int', 0); $p_forum = cmsCore::request('p_forum', 'int', 0); $p_content = cmsCore::request('p_content', 'int', 0); $p_blog = cmsCore::request('p_blog', 'int', 0); $p_karma = cmsCore::request('p_karma', 'int', 0); $p_photo = cmsCore::request('p_photo', 'int', 0); $p_privphoto = cmsCore::request('p_privphoto', 'int', 0);
$p_privphoto = cmsCore::request('p_privphoto', 'int', 0);
$p_friends = cmsCore::request('p_friends', 'int', 0);
$sql = "INSERT INTO cms_user_autoawards (title, description, imageurl, p_comment, p_blog, p_forum, p_photo, p_privphoto, p_content, p_karma, published) VALUES ('$title', '$description', '$imageurl', $p_comment, $p_blog, $p_forum, $p_photo, $p_privphoto, $p_content, $p_karma, $published)"; $inDB->query($sql);
$sql = "INSERT INTO cms_user_autoawards (title, description, imageurl, p_comment, p_blog, p_forum, p_photo, p_privphoto, p_content, p_karma, p_friends, published) VALUES ('$title', '$description', '$imageurl', $p_comment, $p_blog, $p_forum, $p_photo, $p_privphoto, $p_content, $p_karma, $p_friends, $published)"; $inDB->query($sql);
$sql = "UPDATE cms_user_autoawards SET title='$title', description='$description', imageurl='$imageurl', p_comment=$p_comment, p_blog=$p_blog, p_forum=$p_forum, p_photo=$p_photo, p_privphoto=$p_privphoto, p_content=$p_content, p_karma=$p_karma, published=$published WHERE id = '$item_id'";
$sql = "UPDATE cms_user_autoawards SET title='$title', description='$description', imageurl='$imageurl', p_comment=$p_comment, p_blog=$p_blog, p_forum=$p_forum, p_photo=$p_photo, p_privphoto=$p_privphoto, p_content=$p_content, p_karma=$p_karma, p_friends=$p_friends, published=$published WHERE id = '$item_id'";
if ($opt=='add'){ cpAddPathway($_LANG['AD_NEW_AWARD']); echo '<h3>'.$_LANG['AD_NEW_AWARD'].'</h3>'; $mod['p_comment'] = 0; $mod['p_content'] = 0; $mod['p_blog'] = 0; $mod['p_karma'] = 0; $mod['p_forum'] = 0; $mod['p_photo'] = 0; $mod['p_privphoto'] = 0;
$mod['p_privphoto'] = 0;
$mod['p_friends'] = 0;
<tr> <td><img src="/admin/components/autoawards/images/p_privphoto.gif" width="16" height="16" /></td> <td><input name="p_privphoto" type="text" id="p_input" size="5" value="<?php echo @$mod['p_privphoto'];?>" /></td> <td><?php echo $_LANG['AD_PRIVATE_PHOTOS']; ?></td> </tr>
<tr> <td><img src="/admin/components/autoawards/images/p_friends.gif" width="16" height="16" /></td> <td><input name="p_friends" type="text" id="p_input" size="5" value="<?php echo @$mod['p_friends'];?>" /></td> <td><?php echo $_LANG['AD_FRIENDS_AUTOAW']; ?></td> </tr>
/admin/components/autoawards/images/
закидываем картинку с названием p_friends.gif(иконка друзья 16*16 изображение человечка 😂)4) В файлике по адресу
/languages/ru/admin/components/autoawards.php
добавляем код:
$_LANG['AD_FRIENDS_AUTOAW'] ='друзей на сайте';
core\classes\user.class.php
Ищем код:
if (!$awards){ return false; } $p_content = $inDB->rows_count('cms_content', "user_id='$user_id' AND published = 1"); $p_comment = $inDB->rows_count('cms_comments', "user_id='$user_id' AND published = 1"); $p_blog = $inDB->rows_count('cms_blog_posts', "user_id='$user_id' AND published = 1"); $p_forum = $inDB->rows_count('cms_forum_posts', "user_id='$user_id'"); $p_photo = $inDB->rows_count('cms_photo_files', "user_id='$user_id' AND published = 1"); $p_privphoto = $inDB->rows_count('cms_user_photos', "user_id='$user_id'"); $p_karma = $inDB->get_field('cms_user_profiles', "user_id='$user_id'", 'karma');
$p_friends = $inDB->rows_count('cms_user_friends', "(from_id = '$user_id' OR to_id = '$user_id') AND is_accepted =1");
$granted = ($award['p_content'] <= $p_content) && ($award['p_comment'] <= $p_comment) && ($award['p_blog'] <= $p_blog) && ($award['p_forum'] <= $p_forum) && ($award['p_photo'] <= $p_photo) && ($award['p_privphoto'] <= $p_privphoto) && ($award['p_karma'] <= $p_karma);
$granted = ($award['p_content'] <= $p_content) && ($award['p_comment'] <= $p_comment) && ($award['p_blog'] <= $p_blog) && ($award['p_forum'] <= $p_forum) && ($award['p_photo'] <= $p_photo) && ($award['p_privphoto'] <= $p_privphoto) && ($award['p_karma'] <= $p_karma) && ($award['p_friends'] <= $p_friends);
5) Открываем следующий файл по адресу
\components\users\frontend.php
Ищем код:
$inDB->query("UPDATE cms_user_friends SET is_accepted = 1 WHERE id = '{$is_need_accept_id}'"); //регистрируем событие 'object' => $inUser->nickname, 'user_id' => $usr['id'], 'object_url' => cmsUser::getProfileURL($inUser->login), 'object_id' => $is_need_accept_id, 'target' => '', 'target_url' => '', 'target_id' => 0, 'description' => '' ));
//проверяем и выдаем награду если нужно cmsUser::checkAwards($inUser->id); cmsUser::checkAwards($id);
/templates/_default_/components/com_users_awards_site.tpl
Находим код:
{if $aw.p_privphoto} <tr> <td><img src="/images/autoawards/p_privphoto.gif" width="16" height="16" /></td> <td> {$aw.p_privphoto} {$LANG.PHOTOS_IN_PRIVATE_ALBUM}</td> </tr> {/if}
{if $aw.p_friends} <tr>