示例#1
0
    public function emailContacts()
    {
        Logger::getLogger("AuieoATS")->info("emailContacts:start");
        if ($this->_accessLevel == ACCESS_LEVEL_DEMO)
        {
            CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Sorry, but demo accounts are not allowed to send e-mails.');
        }
        
        if(isset($_REQUEST["idlist"]))
        {
            $db = DatabaseConnection::getInstance();
            $idlist=trim($_REQUEST["idlist"]);
            $rs = $db->getAllAssoc(sprintf(
                'SELECT contact_id, email1, email2 '
                    . 'FROM contact '
                    . 'WHERE contact_id IN (%s)',
                $idlist
            ));
            $emailTemplates = new EmailTemplates($this->_siteID);
            $emailTemplatesRS = $emailTemplates->getAll();
            $this->_template->assign('emailTemplatesRS', $emailTemplatesRS);
            $this->_template->assign('active', $this);
            $this->_template->assign('success', false);
            $this->_template->assign('recipients', $rs);
            $this->_template->display('./modules/contacts/emailContacts.php');
        }
        else
        {
            $dataGrid = DataGrid::getFromRequest();

            $contactIDs = $dataGrid->getExportIDs();

            /* Validate each ID */
            foreach ($contactIDs as $index => $contactID)
            {
                if (!$this->isRequiredIDValid($index, $contactIDs))
                {
                    Logger::getLogger("AuieoATS")->error("Invalid contact ID.");
                    CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.');
                    return;
                }
            }

            $db_str = implode(", ", $contactIDs);

            $db = DatabaseConnection::getInstance();

            $rs = $db->getAllAssoc(sprintf(
                'SELECT contact_id, email1, email2 '
                    . 'FROM contact '
                    . 'WHERE contact_id IN (%s)',
                $db_str
            ));

            //$this->_template->assign('privledgedUser', $privledgedUser);
            $emailTemplates = new EmailTemplates($this->_siteID);
            $emailTemplatesRS = $emailTemplates->getAll();
            $this->_template->assign('emailTemplatesRS', $emailTemplatesRS);
            $this->_template->assign('active', $this);
            $this->_template->assign('success', false);
            $this->_template->assign('recipients', $rs);
            $this->_template->display('./modules/contacts/emailContacts.php');
        }
        Logger::getLogger("AuieoATS")->info("emailContacts:end");
    }
示例#2
0
    /**
     * Gets a datagrid and calls its drawCSV member function to output a CSV file.
     *
     * @return void
     */

    public function onExportByDataGrid()
    {
        $dataGrid = DataGrid::getFromRequest();

        $dataGrid->drawCSV();
    }
示例#3
0
 private function onEmailCandidates()
 {
     if ($this->_accessLevel == ACCESS_LEVEL_DEMO) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Sorry, but demo accounts are not allowed to send e-mails.');
     }
     if (isset($_POST['postback'])) {
         $emailTo = $_POST['emailTo'];
         $emailSubject = $_POST['emailSubject'];
         $emailBody = $_POST['emailBody'];
         $tmpDestination = explode(', ', $emailTo);
         $destination = array();
         foreach ($tmpDestination as $emailDest) {
             $destination[] = array($emailDest, $emailDest);
         }
         $mailer = new Mailer(CATS_ADMIN_SITE);
         // FIXME: Use sendToOne()?
         $mailerStatus = $mailer->send(array($_SESSION['CATS']->getEmail(), $_SESSION['CATS']->getEmail()), $destination, $emailSubject, $emailBody, true, true);
         $this->_template->assign('active', $this);
         $this->_template->assign('success', true);
         $this->_template->assign('success_to', $emailTo);
         $this->_template->display('./modules/candidates/SendEmail.tpl');
     } else {
         $dataGrid = DataGrid::getFromRequest();
         $candidateIDs = $dataGrid->getExportIDs();
         /* Validate each ID */
         foreach ($candidateIDs as $index => $candidateID) {
             if (!$this->isRequiredIDValid($index, $candidateIDs)) {
                 CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.');
                 return;
             }
         }
         $db_str = implode(", ", $candidateIDs);
         $db = DatabaseConnection::getInstance();
         $rs = $db->getAllAssoc(sprintf('SELECT candidate_id, email1, email2 ' . 'FROM candidate ' . 'WHERE candidate_id IN (%s)', $db_str));
         //$this->_template->assign('privledgedUser', $privledgedUser);
         $this->_template->assign('active', $this);
         $this->_template->assign('success', false);
         $this->_template->assign('recipients', $rs);
         $this->_template->display('./modules/candidates/SendEmail.tpl');
     }
 }
示例#4
0
    public function removeFromListDatagrid()
    {
        /* Bail out if we don't have a valid type. */
        if (!$this->isRequiredIDValid('dataItemType', $_GET))
        {
            CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this);
            return;
        }

        $dataGrid = DataGrid::getFromRequest();

        $dataItemIDArray = $dataGrid->getExportIDs();

        /* Validate each ID */
        foreach ($dataItemIDArray as $index => $dataItemID)
        {
            if (!$this->isRequiredIDValid($index, $dataItemIDArray))
            {
                CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid data item ID.');
                return;
            }
        }

        $dataItemType = $_GET['dataItemType'];

        $dataItemDesc = TemplateUtility::getDataItemTypeDescription($dataItemType);

        if (!$this->isRequiredIDValid('savedListID', $_GET))
        {
            CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid saved list ID.');
            return;
        }

        $savedListID = $_GET['savedListID'];

        /* Remove the items */
        $savedLists = new SavedLists($this->_siteID);

        $dataItemIDArrayTemp = array();
        foreach ($dataItemIDArray as $dataItemID)
        {
            $dataItemIDArrayTemp[] = $dataItemID;
            /* Because its too slow adding 1 item at a time, we do it in spurts of 200 items. */
            if (count($dataItemIDArrayTemp) > 200)
            {
                $savedLists->removeEntryMany($savedListID, $dataItemIDArrayTemp);
                $dataItemIDArrayTemp = array();
            }
        }
        if (count($dataItemIDArrayTemp) > 0)
        {
            $savedLists->removeEntryMany($savedListID, $dataItemIDArrayTemp);
        }

        /* Redirect to the saved list page we were on. */
        /* FIXME: What if we are on the last page? */
        CATSUtility::transferRelativeURI('m=lists&a=showList&savedListID='.$savedListID);
    }
示例#5
0
    public function onEmailCandidates()
    {
        if ($this->_accessLevel == ACCESS_LEVEL_DEMO)
        {
            CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Sorry, but demo accounts are not allowed to send e-mails.');
        }
        Logger::getLogger("AuieoATS")->info("inside onEmailCandidates");
        if (isset($_POST['postback']))
        {
            $templateid = $_POST['titleSelect'];
            
            $emailTo = $_POST['emailTo'];
            $emailSubject = $_POST['emailSubject'];
            
            $idlist=$_POST["idlist"];
            $obj=json_decode(urldecode($idlist),true);
            foreach($obj as $candid=>$details)
            {
                $emailBody = $_POST['emailBody'];
                $emailData=array();
                $emailData["id"]=$candid;
                $emailData["email"]=array();
                foreach($details["email"] as $emailind=>$data)
                {
                    //$objTemplate=new EmailTemplates($this->_siteID); 
                    //$rowTemplate=$objTemplate->get($templateid);
                    $emailBody=$this->renderTemplateVars($emailBody, $candid);

                    $tmpDestination = $data["email"];
                    $emailData["email"][]=array("email"=>$tmpDestination,"name"=>$tmpDestination);
                    $mailer = new Mailer($this->_siteID);
                    // FIXME: Use sendToOne()?
                    $mailerStatus = $mailer->send(
                        array($_SESSION['CATS']->getEmail(), $_SESSION['CATS']->getEmail()),
                        $emailData,
                        $emailSubject,
                        $emailBody,
                        true,
                        true
                    );
                }
            }

            $this->_template->assign('active', $this);
            $this->_template->assign('success_to', $emailTo);
            if($mailer->getError())
            {
                $this->_template->assign('error', $mailer->getError());
                $this->_template->display('./modules/candidates/emailFail.php');
            }
            else
            {
                $this->_template->assign('success', true);
                $this->_template->display('./modules/candidates/emailSuccess.php');
            }
            return;
        }
        else
        {
            if(isset($_REQUEST["idlist"]))
            {
                $db = DatabaseConnection::getInstance();
                $idlist=trim($_REQUEST["idlist"]);
                $rs = $db->getAllAssoc(sprintf(
                    'SELECT candidate_id, email1, email2, last_name, first_name '
                    . 'FROM candidate '
                    . 'WHERE candidate_id IN (%s)',
                    $idlist
                ));
				
                $emailTemplates = new EmailTemplates($this->_siteID);
                $emailTemplatesRS = $emailTemplates->getAll();
                $this->_template->assign('emailTemplatesRS', $emailTemplatesRS);
                $this->_template->assign('active', $this);
                $this->_template->assign('success', true);
                $this->_template->assign('recipients', $rs);
                $this->_template->display('./modules/candidates/emailCandidates.php');
                return;
            }
            else
            {
                $dataGrid = DataGrid::getFromRequest();

                $candidateIDs = $dataGrid->getExportIDs();

                /* Validate each ID */
                foreach ($candidateIDs as $index => $candidateID)
                {
                    if (!$this->isRequiredIDValid($index, $candidateIDs))
                    {
                        CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.');
                        return;
                    }
                }

                $db_str = implode(", ", $candidateIDs);

                $db = DatabaseConnection::getInstance();

                $rs = $db->getAllAssoc(sprintf(
                    'SELECT candidate_id, email1, email2, last_name, first_name '
                    . 'FROM candidate '
                    . 'WHERE candidate_id IN (%s)',
                    $db_str
                ));

                if(!$mailerStatus)
                {
                    CommonErrors::fatal(COMMONERROR_EMAILFAILED, NULL, $mailer->getError());
                }
                $this->_template->assign('active', $this);
                $this->_template->assign('success', true);
                $this->_template->assign('success_to', $emailTo);
                $this->_template->display('./modules/candidates/emailSuccess.php');

                //$arrTpl["privledgedUser"]=$privledgedUser;
                /*$emailTemplates = new EmailTemplates($this->_siteID);
                $emailTemplatesRS = $emailTemplates->getAll();
                $arrTpl["emailTemplatesRS"]=$emailTemplatesRS;
                $arrTpl["active"]=$this;
                $arrTpl["success"]=false;
                $arrTpl["recipients"]=$rs;
                return $arrTpl;*/
            }
        }
    }