Example #1
0
 /**
  * synchronize_muc_and_grp_together
  */
 function synchronize_muc_and_grp()
 {
     $request =& HTTPRequest::instance();
     $unix_group_name = $request->get('unix_group_name');
     $group_id = $request->get('group_id');
     $group_Owner_name = $request->get('group_Owner_name');
     $group_name = $request->get('group_name');
     if (!(isset($group_name) && $group_name != null)) {
         $group_name = $unix_group_name;
     }
     $group_description = $request->get('group_description');
     if (!(isset($group_description) && $group_description != null)) {
         $group_description = 'No description';
     }
     $dao = new IMDao(IMDataAccess::instance($this->getControler()));
     try {
         $dao->synchronize_muc_only($unix_group_name, $group_name, $group_description, $group_Owner_name, $group_id);
         $GLOBALS['Response']->addFeedback('info', $group_name . ' ' . $GLOBALS['Language']->getText('plugin_im_admin', 'synchronise_muc_msg'));
     } catch (Exception $e) {
         $GLOBALS['Response']->addFeedback('error', $group_name . ' ' . $GLOBALS['Language']->getText('plugin_im_admin', 'synchronise_muc_error') . $e->getMessage());
     }
     try {
         $dao->synchronize_grp_only($unix_group_name, $group_name);
         $GLOBALS['Response']->addFeedback('info', $group_name . ' ' . $GLOBALS['Language']->getText('plugin_im_admin', 'synchronise_grp_msg'));
     } catch (Exception $e) {
         $GLOBALS['Response']->addFeedback('error', $group_name . ' ' . $GLOBALS['Language']->getText('plugin_im_admin', 'synchronise_grp_error') . $e->getMessage());
     }
 }
Example #2
0
 function _this_muc_exist($unix_project_name)
 {
     require_once "IM.class.php";
     require_once "IMDao.class.php";
     require_once 'IMDataAccess.class.php';
     $controler = new IM($this);
     $dao =& new IMDao(IMDataAccess::instance($controler));
     $roomID = $dao->get_room_id_by_unix_name($unix_project_name);
     return isset($roomID) && $roomID;
 }
Example #3
0
    /**
     * Display forms to synchronize projects (site admin view)
     */
    private function _admin_synchronize_muc_and_grp()
    {
        $action = '';
        $nb_grp = 0;
        $nb_muc = 0;
        $im_dao = new IMDao(IMDataAccess::instance($this->getControler()));
        $res_grp = $im_dao->search_group_without_shared_group();
        $res_grp = $res_grp->query;
        $res_muc = $im_dao->search_group_without_muc();
        $res_muc = $res_muc->query;
        // number of shared group to synchronize
        $nb_grp = db_numrows($res_grp);
        // number of muc room to synchronize
        $nb_muc = db_numrows($res_muc);
        $array_grp = array();
        if ($nb_grp > 0) {
            $array_grp = result_column_to_array($res_grp, 0);
        }
        $array_muc = array();
        if ($nb_muc > 0) {
            $array_muc = result_column_to_array($res_muc, 0);
        }
        $array_muc_and_grp = array_intersect($array_grp, $array_muc);
        if (sizeof($array_muc_and_grp)) {
            $array_muc_only = array_diff($array_muc, $array_muc_and_grp);
            $array_grp_only = array_diff($array_grp, $array_muc_and_grp);
        } else {
            $array_muc_only = $array_muc;
            $array_grp_only = $array_grp;
        }
        $pm = ProjectManager::instance();
        $purifier = Codendi_HTMLPurifier::instance();
        echo '<fieldset>';
        echo '<legend class="im_synchronize">' . $GLOBALS["Language"]->getText('plugin_im_admin', 'projects_to_sync') . '</legend>';
        if ($nb_grp != 0 || $nb_muc) {
            //************form
            if (sizeof($array_muc_and_grp)) {
                foreach ($array_muc_and_grp as $key => $val) {
                    $project = $pm->getProject($val);
                    $unix_group_name = $purifier->purify(strtolower($project->getUnixName()));
                    $group_name = $purifier->purify($project->getPublicName());
                    $group_description = $purifier->purify($project->getDescription());
                    $grp = $pm->getProject($val);
                    // $val = group_id;
                    $group_id = $grp->getID();
                    $project_members_ids = $grp->getMembersId();
                    foreach ($project_members_ids as $key => $id) {
                        $group_Owner_object = UserManager::instance()->getUserById($id);
                        if ($group_Owner_object->isMember($val, 'A')) {
                            $group_Owner_name = $purifier->purify(trim($group_Owner_object->getName()));
                        }
                    }
                    //field label
                    $unix_group_name_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'unix_group_name_label');
                    $group_description_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'group_description_label');
                    $group_Owner_name_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'group_Owner_name_label');
                    $action_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'action_label');
                    //plugin_im_admin - unix_group_name_label
                    $action_on = $GLOBALS["Language"]->getText('plugin_im_admin', 'action_on_muc_and_grp');
                    echo '<fieldset>';
                    echo '<legend class="project_sync">' . $group_name . '</legend>';
                    echo $unix_group_name_label . $unix_group_name . '<br>';
                    echo $group_description_label . $group_description . '<br>';
                    echo $group_Owner_name_label . $group_Owner_name . '<br>';
                    echo $action_label . $action_on . '<br>';
                    echo '
					        <FORM class="project_sync" action="/plugins/IM/?action=codendi_im_admin" method="POST">
					         <INPUT TYPE="HIDDEN" NAME="action" VALUE="synchronize_muc_and_grp">
                             <INPUT TYPE="HIDDEN" NAME="unix_group_name" VALUE="' . $unix_group_name . '">
					         <INPUT TYPE="HIDDEN" NAME="group_name" VALUE="' . $group_name . '">
					         <INPUT TYPE="HIDDEN" NAME="group_id" VALUE=' . $group_id . '>
					         <INPUT TYPE="HIDDEN" NAME="group_description" VALUE="' . $group_description . '">
					       	 <INPUT TYPE="HIDDEN" NAME="group_Owner_name" VALUE="' . $group_Owner_name . '">
					       	 <INPUT type="submit" name="submit" value="' . $GLOBALS["Language"]->getText('plugin_im_admin', 'im_admin_synchro_muc') . '">
					        </FORM>
					        ';
                    echo '</fieldset>';
                }
            }
            if (sizeof($array_grp_only)) {
                $pm = ProjectManager::instance();
                foreach ($array_grp_only as $key => $val) {
                    $project = $pm->getProject($val);
                    $unix_group_name = $purifier->purify(strtolower($project->getUnixName()));
                    $group_name = $purifier->purify($project->getPublicName());
                    $group_description = $purifier->purify($project->getDescription());
                    $grp = $pm->getProject($val);
                    // $val = group_id;
                    $group_id = $grp->getID();
                    $project_members_ids = $grp->getMembersId();
                    foreach ($project_members_ids as $key => $id) {
                        $group_Owner_object = UserManager::instance()->getUserById($id);
                        if ($group_Owner_object->isMember($val, 'A')) {
                            $group_Owner_name = $purifier->purify($group_Owner_object->getName());
                        }
                    }
                    //field label
                    $unix_group_name_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'unix_group_name_label');
                    $group_description_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'group_description_label');
                    $group_Owner_name_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'group_Owner_name_label');
                    $action_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'action_label');
                    $action_on = $GLOBALS["Language"]->getText('plugin_im_admin', 'action_on_grp');
                    echo '<fieldset>';
                    echo '<legend class="project_sync">' . $group_name . '</legend>';
                    echo $unix_group_name_label . $unix_group_name . '<br>';
                    echo $group_description_label . $group_description . '<br>';
                    echo $group_Owner_name_label . $group_Owner_name . '<br>';
                    echo $action_label . $action_on . '<br>';
                    echo '
					        <FORM class="project_sync" action="/plugins/IM/?action=codendi_im_admin" method="POST">
					         <INPUT TYPE="HIDDEN" NAME="action" VALUE="synchronize_grp_only">
                             <INPUT TYPE="HIDDEN" NAME="unix_group_name" VALUE="' . $unix_group_name . '">
					         <INPUT TYPE="HIDDEN" NAME="group_name" VALUE="' . $group_name . '">
					         <INPUT TYPE="HIDDEN" NAME="group_id" VALUE=' . $group_id . '>
					         <INPUT TYPE="HIDDEN" NAME="group_description" VALUE="' . $group_description . '">
					      	 <INPUT TYPE="HIDDEN" NAME="group_Owner_name" VALUE="' . $group_Owner_name . '">
					     	 <INPUT type="submit" name="submit" value="' . $GLOBALS["Language"]->getText('plugin_im_admin', 'im_admin_synchro_muc') . '">
					        </FORM>
					        ';
                    echo '</fieldset>';
                }
            }
            if (sizeof($array_muc_only)) {
                $pm = ProjectManager::instance();
                foreach ($array_muc_only as $key => $val) {
                    $project = $pm->getProject($val);
                    $unix_group_name = $purifier->purify(strtolower($project->getUnixName()));
                    $group_name = $purifier->purify($project->getPublicName());
                    $group_description = $purifier->purify($project->getDescription());
                    $grp = $pm->getProject($val);
                    // $val = group_id;
                    $group_id = $grp->getID();
                    $project_members_ids = $grp->getMembersId();
                    foreach ($project_members_ids as $key => $id) {
                        $group_Owner_object = UserManager::instance()->getUserById($id);
                        if ($group_Owner_object->isMember($val, 'A')) {
                            $group_Owner_name = $purifier->purify($group_Owner_object->getName());
                        }
                    }
                    //field label
                    $unix_group_name_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'unix_group_name_label');
                    $group_description_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'group_description_label');
                    $group_Owner_name_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'group_Owner_name_label');
                    $action_label = $GLOBALS["Language"]->getText('plugin_im_admin', 'action_label');
                    $action_on = $GLOBALS["Language"]->getText('plugin_im_admin', 'action_on_muc');
                    echo '<fieldset>';
                    echo '<legend class="project_sync">' . $group_name . '</legend>';
                    echo $unix_group_name_label . $unix_group_name . '<br>';
                    echo $group_description_label . $group_description . '<br>';
                    echo $group_Owner_name_label . $group_Owner_name . '<br>';
                    echo $action_label . $action_on . '<br>';
                    echo '
					     <FORM class="project_sync" action="/plugins/IM/?action=codendi_im_admin" method="POST">
					      <INPUT TYPE="HIDDEN" NAME="action" VALUE="synchronize_muc_only">
                          <INPUT TYPE="HIDDEN" NAME="unix_group_name" VALUE="' . $unix_group_name . '">
					      <INPUT TYPE="HIDDEN" NAME="group_name" VALUE="' . $group_name . '">
					      <INPUT TYPE="HIDDEN" NAME="group_id" VALUE=' . $group_id . '>
					      <INPUT TYPE="HIDDEN" NAME="group_description" VALUE="' . $group_description . '">
					   	  <INPUT TYPE="HIDDEN" NAME="group_Owner_name" VALUE="' . $group_Owner_name . '">
					   	  <INPUT type="submit" name="submit" value="' . $GLOBALS["Language"]->getText('plugin_im_admin', 'im_admin_synchro_muc') . '">
					     </FORM>
					     ';
                    echo '</fieldset>';
                }
            }
            echo '
				 <FORM class="project_sync" action="/plugins/IM/?action=codendi_im_admin" method="POST">
				  <INPUT TYPE="HIDDEN" NAME="action" VALUE="synchronize_all"> 
				  <INPUT type="submit" name="submit" value="' . $GLOBALS["Language"]->getText('plugin_im_admin', 'im_admin_synchro_all') . '">
				 </FORM>';
        } else {
            echo $GLOBALS["Language"]->getText('plugin_im_admin', 'no_project_to_synchronized');
        }
        echo '</fieldset>';
    }
 public function getLogsByGroupNameBetweenDates($codendi_unix_group_name, $start_date, $end_date)
 {
     $logs = array();
     // user messages
     $dao = new PluginIMMucConversationLogDao(IMDataAccess::instance($this->_controler));
     $dar = $dao->searchByMucNameBetweenDates($codendi_unix_group_name, $start_date, $end_date);
     if ($dar && $dar->valid()) {
         while ($dar->valid()) {
             $row = $dar->current();
             if ($row['body'] != null) {
                 $current_conv = new IMMucConversationLog($row['sentDate'], $row['nickname'], $row['nickname'], $row['body']);
                 $logs[$row['sentDate']] = $current_conv;
             }
             $dar->next();
         }
     }
     //
     // system messages
     //
     // Change Topic
     $dao = new PluginIMMucChangeTopicLogDao(IMDataAccess::instance($this->_controler));
     $dar = $dao->searchByMucNameBetweenDates($codendi_unix_group_name, $start_date, $end_date);
     if ($dar && $dar->valid()) {
         while ($dar->valid()) {
             $row = $dar->current();
             if ($row['subject'] != null) {
                 $current_conv = new IMMucChangeTopicSystemLog($row['logTime'], $row['nickname'], $row['subject']);
                 $logs[$row['logTime']] = $current_conv;
             }
             $dar->next();
         }
     }
     // join the room
     $dao = new PluginIMMucJoinTheRoomLogDao(IMDataAccess::instance($this->_controler));
     $dar = $dao->searchByMucNameBetweenDates($codendi_unix_group_name, $start_date, $end_date);
     if ($dar && $dar->valid()) {
         while ($dar->valid()) {
             $row = $dar->current();
             $current_conv = new IMMucJoinTheRoomSystemLog($row['joinedDate'], $row['nickname']);
             $logs[$row['joinedDate']] = $current_conv;
             $dar->next();
         }
     }
     // left the room
     $dao = new PluginIMMucLeftTheRoomLogDao(IMDataAccess::instance($this->_controler));
     $dar = $dao->searchByMucNameBetweenDates($codendi_unix_group_name, $start_date, $end_date);
     if ($dar && $dar->valid()) {
         while ($dar->valid()) {
             $row = $dar->current();
             $current_conv = new IMMucLeftTheRoomSystemLog($row['leftDate'], $row['nickname']);
             $logs[$row['leftDate']] = $current_conv;
             $dar->next();
         }
     }
     // sort the events by date
     ksort($logs);
     return $logs;
 }