function _comments($id, $ref, $element) { $element_tag = TTwiiit::getTag($element, $ref); $PDOdb = new TPDOdb(); $r = ''; $Tab = $PDOdb->ExecuteAsArray("SELECT DISTINCT t.rowid\n\tFROM " . MAIN_DB_PREFIX . "twiiit t \n\t WHERE (t.fk_object=" . (int) $id . " AND t.type_object='" . $element . "') OR (t.comment LIKE '%" . $element_tag . "%')\n\t ORDER BY t.date_cre DESC"); foreach ($Tab as &$row) { $twiiit = new TTwiiit(); $twiiit->load($PDOdb, $row->rowid); $r .= '<div class="comm">'; if ($id != $twiiit->fk_object || $element != $twiiit->type_object) { $origin_element = $twiiit->getNomUrl(); if (!empty($origin_element)) { $r .= '<div class="object">' . $origin_element . '</div> '; } } $r .= $twiiit->getComment(); $r .= '<div class="date">' . dol_print_date($twiiit->date_cre, 'dayhourtextshort') . '</div>'; $r .= '</div>'; } return $r; }
/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function formObjectOptions($parameters, &$object, &$action, $hookmanager) { if (empty($object->element)) { return 0; } if (defined('TWIIITOR_ADDED')) { return 0; } define('TWIIITOR_ADDED', true); define('INC_FROM_DOLIBARR', true); dol_include_once('/twiiitor/config.php'); dol_include_once('/twiiitor/class/twiiitor.class.php'); $ref = TTwiiit::getRefByObject($object); if (empty($ref)) { return 0; } ?> <script type="text/javascript" src="<?php echo dol_buildpath('/twiiitor/js/twiiitor.js.php?element=' . $object->element . '&id=' . $object->id . '&ref=' . $ref, 1); ?> "></script> <?php }
static function getLinkFor(&$Tab, $fk_object = 0, $element = '', $tag = '', $level = 1) { global $db; if ($level > 5 || strlen($tag) <= 1) { return false; } $res = $db->query("SELECT fk_object, type_object, comment \n\t\t\t\tFROM " . MAIN_DB_PREFIX . "twiiit WHERE \n\t\t\t\t(fk_object = " . (int) $fk_object . " AND type_object='" . $db->escape($element) . "')\n\t\t\t\tOR comment LIKE '%" . $db->escape($tag) . "%'"); while ($obj = $db->fetch_object($res)) { $TTag = TTwiiit::extractTags($obj->comment, array('/@(\\w+)/', '/#(\\w+)/')); if ($obj->fk_object > 0 && !empty($obj->type_object)) { $TTag[] = TTwiiit::getTag($element, TTwiiit::getRef($obj->fk_object, $obj->type_object)); } $TTagRel = TTwiiit::extractTags($obj->comment, array('/:(\\w+)/')); if (empty($TTagRel)) { $TTagRel = array(' '); } //var_dump($tag,$TTag,$TTagRel); foreach ($TTag as $t) { if ($tag == $t || strlen($tag) <= 1) { continue; } foreach ($TTagRel as $rel) { if (empty($rel)) { continue; } $checksum = md5($tag . '.' . $t . '.' . $rel); if (!isset($Tab[$checksum])) { $Tab[$checksum] = array('from' => $tag, 'to' => $t, 'label' => $rel); TTwiiit::getLinkFor($Tab, 0, '', $t, $level + 1); } } } } }
<?php /* * Script créant et vérifiant que les champs requis s'ajoutent bien */ if (!defined('INC_FROM_DOLIBARR')) { define('INC_FROM_CRON_SCRIPT', true); require '../config.php'; } dol_include_once('/twiiitor/class/twiiitor.class.php'); $PDOdb = new TPDOdb(); $o = new TTwiiit($db); $o->init_db_by_vars($PDOdb);
<?php require '../config.php'; dol_include_once('/twiiitor/class/twiiitor.class.php'); if (empty($user->rights->twiiitor->read)) { exit; } // pas les droit de lecture $langs->load('twiiitor@twiiitor'); $element_tag = TTwiiit::getTag(GETPOST('element'), GETPOST('ref')); ?> var cache = []; $(document).ready(function() { $div = $('<div class="tabBar"><strong><?php echo $langs->trans('NanoSocial'); ?> <?php echo $element_tag; ?> </strong> <a href="javascript:showSociogram();"><img src="<?php echo dol_buildpath('/twiiitor/img/users_relation.png', 1); ?> " border="0" align="absmiddle" /></a></div>'); $div.attr('id','twittor-panel'); <?php if (!empty($user->rights->twiiitor->write)) { ?> $div.append('<textarea name="comment"></textarea>');
$o->fetch($obj->rowid); $Tab[] = array('link' => $o->getNomUrl(1), 'link0' => $o->getNomUrl(0), 'type' => 'societe'); } list($code, $nom) = explode('_', $tag); $res = $db->query("SELECT p.rowid \n\t\t\t\t\tFROM " . MAIN_DB_PREFIX . "socpeople p LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON (p.fk_soc=s.rowid)\n\t\t\t\t\tWHERE (s.code_client = '" . $db->escape($code) . "' OR s.nom='" . $db->escape($code) . "' ) AND p.lastname='" . $db->escape($nom) . "'"); while ($obj = $db->fetch_object($res)) { $o = new Contact($db); $o->fetch($obj->rowid); $Tab[] = array('link' => $o->getNomUrl(1), 'link0' => $o->getNomUrl(0), 'type' => 'contact'); } } else { if ($type_tag == 'rel') { $res = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "twiiit WHERE comment LIKE '%:" . $db->escape($tag) . "%'"); $PDOdb = new TPDOdb(); while ($obj = $db->fetch_object($res)) { $twiiit = new TTwiiit(); $twiiit->load($PDOdb, $obj->rowid); $Tab[] = array('link' => $twiiit->getNomUrl(), 'text' => $twiiit->getComment()); } } else { if ($type_tag == 'hashtag') { $res = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "propal WHERE ref = '" . $db->escape($tag) . "'"); while ($obj = $db->fetch_object($res)) { $o = new Propal($db); $o->fetch($obj->rowid); $Tab[] = array('link' => $o->getNomUrl(1), 'link0' => $o->getNomUrl(0), 'type' => 'user'); } $res = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "facture WHERE facnumber = '" . $db->escape($tag) . "'"); while ($obj = $db->fetch_object($res)) { $o = new Facture($db); $o->fetch($obj->rowid);