Exemple #1
0
 $db->query();
 $catkunena = $db->loadResult();
 $sql = "select `id` from #__kunena_topics WHERE `subject`='" . addslashes(trim($step->name)) . "' order by `id` asc limit 0,1";
 $db->setQuery($sql);
 $db->query();
 $idmess = $db->loadResult();
 for ($i = 0; $i < count($resultid); $i++) {
     $sql = "select `message` from #__kunena_messages_text WHERE `mesid`=" . $resultid[$i]["id"];
     $db->setQuery($sql);
     $db->query();
     $result = $db->loadResult();
     $sql = "select `time` from #__kunena_messages WHERE `id`=" . $resultid[$i]["id"];
     $db->setQuery($sql);
     $db->query();
     $datestart = $db->loadResult();
     $timepast = $guruModelguruTask->get_time_difference($datestart, $int_current_datek);
     if ($timepast["days"] == 0) {
         if ($timepast["hours"] == 0) {
             if ($timepast["minutes"] == 0) {
                 $difference = "a few seconds ago";
             } else {
                 $difference = $timepast["minutes"] . " " . JText::_("GURU_REAL_MINUTES") . " " . JText::_("GURU_AGO");
             }
         } else {
             $difference = $timepast["hours"] . " " . JText::_("GURU_REAL_HOURS") . ", " . $timepast["minutes"] . " " . JText::_("GURU_REAL_MINUTES") . " " . JText::_("GURU_AGO");
         }
     } else {
         $difference = $timepast["days"] . " " . JText::_("GURU_REAL_DAYS") . ", " . ($difference = $timepast["hours"] . " " . JText::_("GURU_REAL_HOURS") . ", " . $timepast["minutes"] . " " . JText::_("GURU_REAL_MINUTES") . " " . JText::_("GURU_AGO"));
     }
     if ($deviceType != 'phone') {
         $rows_cols = ' rows="2" cols="90"';
Exemple #2
0
    function deletecom()
    {
        $db = JFactory::getDBO();
        $comid = JRequest::getVar("comid", "");
        $uid = JRequest::getVar("uid", "");
        $lid = JRequest::getVar("lessonid", "");
        $user = JFactory::getUser();
        $jnow = JFactory::getDate();
        $date_currentk = $jnow->toSQL();
        $int_current_datek = strtotime($date_currentk);
        $sql = "SELECT name from #__guru_task WHERE id=" . intval($lid);
        $db->setQuery($sql);
        $db->query();
        $name = $db->loadResult();
        $sql = "DELETE from #__kunena_messages WHERE id =" . $comid . " and userid=" . $uid . " ";
        $db->setQuery($sql);
        $db->query();
        $sql = "SELECT id FROM  #__kunena_topics WHERE subject='" . $name . "'";
        $db->setQuery($sql);
        $db->query();
        $idtopic = $db->loadResult();
        $sql = "SELECT id from #__kunena_messages WHERE subject ='" . $name . "' order by id desc limit 0,1 ";
        $db->setQuery($sql);
        $db->query();
        $idmessage = $db->loadResult();
        $sql = "SELECT id from #__kunena_categories WHERE name ='" . $name . "'";
        $db->setQuery($sql);
        $db->query();
        $idcat = $db->loadResult();
        $sql = "UPDATE  #__kunena_categories set last_topic_id ='" . intval($idtopic) . "' ,`last_post_id`=" . intval($idmessage) . ", `last_post_time`='" . $int_current_datek . "'  where id =" . $idcat . " and name ='" . $name . "' ";
        $db->setQuery($sql);
        $db->query();
        $sql = "UPDATE  #__kunena_topics set first_post_id ='" . $idmessage . "' where id =" . $idtopic . " ";
        $db->setQuery($sql);
        $db->query();
        $sql = "select id, name, userid from #__kunena_messages WHERE subject='" . $name . "' order by id desc";
        $db->setQuery($sql);
        $db->query();
        $resultid = $db->loadAssocList();
        $sql = "select id from #__kunena_categories WHERE name='" . $name . "' order by id desc limit 0,1";
        $db->setQuery($sql);
        $db->query();
        $catkunena = $db->loadResult();
        $sql = "select id from #__kunena_topics WHERE subject='" . $name . "' order by id asc limit 0,1";
        $db->setQuery($sql);
        $db->query();
        $idmess = $db->loadResult();
        for ($i = 0; $i < count($resultid); $i++) {
            $sql = "select message from #__kunena_messages_text WHERE mesid=" . $resultid[$i]["id"];
            $db->setQuery($sql);
            $db->query();
            $result = $db->loadResult();
            $sql = "select time from #__kunena_messages WHERE id=" . $resultid[$i]["id"];
            $db->setQuery($sql);
            $db->query();
            $datestart = $db->loadResult();
            $timepast = guruModelguruTask::get_time_difference($datestart, $int_current_datek);
            if ($timepast["days"] == 0) {
                if ($timepast["hours"] == 0) {
                    if ($timepast["minutes"] == 0) {
                        $difference = "a few seconds ago";
                    } else {
                        $difference = $timepast["minutes"] . " " . JText::_("GURU_REAL_MINUTES") . " " . JText::_("GURU_AGO");
                    }
                } else {
                    $difference = $timepast["hours"] . " " . JText::_("GURU_REAL_HOURS") . ", " . $timepast["minutes"] . " " . JText::_("GURU_REAL_MINUTES") . " " . JText::_("GURU_AGO");
                }
            } else {
                $difference = $timepast["days"] . " " . JText::_("GURU_REAL_DAYS") . ", " . ($difference = $timepast["hours"] . " " . JText::_("GURU_REAL_HOURS") . ", " . $timepast["minutes"] . " " . JText::_("GURU_REAL_MINUTES") . " " . JText::_("GURU_AGO"));
            }
            if ($user->id == $resultid[$i]["userid"]) {
                if ($allow_delete == 0) {
                    $concat = 1;
                    $buttonsd = '<span style="display:block; float:left;"><a href="#" id="delete' . $resultid[$i]["id"] . '" onclick="javascript:deletegurucomment(' . $lid . ', ' . $resultid[$i]["userid"] . ', ' . $resultid[$i]["id"] . '); return false;">' . JText::_("GURU_DELETE") . '</a></span>';
                } else {
                    $concat = 0;
                }
                if ($allow_edit == 0) {
                    if ($concat == 0) {
                        $buttonsd = '<span style="float:right;display:block"><a href="#" id="edit' . $resultid[$i]["id"] . '" onclick="javascript:editgurucomment1(' . $resultid[$i]["id"] . '); return false;">' . JText::_("GURU_EDIT") . '</a></span>';
                    } else {
                        $buttonsd .= '<span style="float:right;display:block"><a href="#" id="edit' . $resultid[$i]["id"] . '" onclick="javascript:editgurucomment1(' . $resultid[$i]["id"] . '); return false;">' . JText::_("GURU_EDIT") . '</a></span>';
                    }
                }
            } else {
                $buttonsd = " ";
            }
            echo '<div class="guru-header">
							<span><img  src="' . JUri::base() . 'components/com_guru/images/guru_comment.gif' . '"</span>
							<span>' . JText::_("GURU_POSTED") . ':' . $difference . '</span>
							<span style="float:right;"><a href=' . JUri::base() . 'index.php?option=com_kunena&view=topic&catid=' . $catkunena . '&id=' . $idmess . '&Itemid=0#' . $resultid[$i]["id"] . '>#' . $resultid[$i]["id"] . '</a></span>
							<span>' . JText::_("GURU_COMMENTED_BY") . ' ' . $resultid[$i]["name"] . '</span>
							</div>
							<div class="guru-reply-body clearfix">
								<div style="display:block;" class="guru-text" id="gurupostcomment' . $resultid[$i]["id"] . '">' . $result . '</div>
								<textarea style="display:none;" style="width:100%" name="message1' . $resultid[$i]["id"] . '" id="message1' . $resultid[$i]["id"] . '" rows="2" cols="90"></textarea>
                                 <input class="btn btn-success" style="display:none;" id="save' . $resultid[$i]["id"] . '" name="save" type="button" onclick="javascript:savegurucomment(' . $lid . ',' . $resultid[$i]["id"] . ');" value="' . JText::_('GURU_SAVE') . '" />
								<div>' . $buttonsd . '</div>
						   </div>';
        }
    }