Beispiel #1
1
 public function view($fID = 0)
 {
     if ($fID > 0) {
         $sessionFormID = $fID;
         Session::set('formifyFormID', $fID);
     } else {
         $sessionFormID = Session::get('formifyFormID');
     }
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($sessionFormID);
     $this->set('f', $f);
     if (!$f) {
         $this->redirect('/dashboard/formify/forms');
     }
     $html = Loader::helper('html');
     $uh = Loader::helper('concrete/urls');
     $this->addHeaderItem($html->css('formify.css', 'formify'));
     $this->addHeaderItem($html->css('attributes.css', 'formify'));
     $this->addFooterItem($html->javascript('angular.min.js', 'formify'));
     $this->addFooterItem($html->javascript('ui-bootstrap-custom-tpls-0.13.0.min.js', 'formify'));
     $this->addFooterItem($html->javascript('formify.js', 'formify'));
 }
Beispiel #2
1
 public function loadFooterItems($fID = 0)
 {
     $uh = Loader::helper('concrete/urls');
     $html = Loader::helper('html');
     $footerItems = array();
     if ($fID == 0) {
         $f = \Concrete\Package\Formify\Src\FormifyForm::get($this->fID);
     } else {
         $f = \Concrete\Package\Formify\Src\FormifyForm::get($fID);
     }
     if (is_object($f)) {
         foreach ($f->getFields() as $ff) {
             $ft = $ff->getType();
             foreach ($ft->getFooterItems() as $item) {
                 if ($item['type'] == 'javascript') {
                     $footerItems[] = $html->javascript($item['file'], $item['package']);
                 } else {
                     $footerItems[] = $html->css($item['file'], $item['package']);
                 }
             }
         }
     }
     foreach ($footerItems as $item) {
         $this->addFooterItem($item);
     }
 }
Beispiel #3
1
 public function reject($rID)
 {
     $r = \Concrete\Package\Formify\Src\FormifyRecord::get($rID);
     $r->reject();
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($r->fID);
     foreach ($f->getNotifications('reject') as $n) {
         $n->send($r);
     }
 }
Beispiel #4
0
 public function all($fID)
 {
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($fID);
     $notifications = $f->getNotifications();
     $json = Loader::helper('json');
     echo $json->encode($notifications);
 }
Beispiel #5
0
 public function edit($fID, $rID = '', $token = '')
 {
     if ($fID > 0) {
         $sessionFormID = $fID;
         Session::set('formifyFormID', $fID);
     } else {
         $sessionFormID = Session::get('formifyFormID');
     }
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($sessionFormID);
     $this->set('f', $f);
     $this->set('rID', $rID);
     $this->set('token', $token);
     if (!$f) {
         $this->redirect('/dashboard/formify/forms');
     }
     $html = Loader::helper('html');
     $this->addHeaderItem($html->css('formify.css', 'formify'));
     $this->addHeaderItem($html->css('records.css', 'formify'));
     $this->addFooterItem($html->javascript('angular.min.js', 'formify'));
     $this->addFooterItem($html->javascript('ui-bootstrap-custom-tpls-0.13.0.min.js', 'formify'));
     $this->addFooterItem($html->javascript('formify.js', 'formify'));
     $this->addFooterItem($html->javascript('records.js', 'formify'));
     $this->addFooterItem($html->javascript('controllers/records.js', 'formify'));
     $formifyBT = BlockType::getByHandle('formify_form');
     $formifyBT->controller->view();
     $this->set('action', 'edit');
 }
Beispiel #6
0
 public function view($fID = 0)
 {
     if ($fID > 0) {
         $sessionFormID = $fID;
         Session::set('formifyFormID', $fID);
     } else {
         $sessionFormID = Session::get('formifyFormID');
     }
     $gl = new GroupList();
     $gl->includeAllGroups();
     $this->set('groups', $gl->get());
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($sessionFormID);
     $this->set('f', $f);
     if (!$f) {
         $this->redirect('/dashboard/formify/forms');
     }
     $html = Loader::helper('html');
     $this->addHeaderItem($html->css('formify.css', 'formify'));
     $this->addHeaderItem($html->css('settings.css', 'formify'));
     $this->addFooterItem($html->javascript('angular.min.js', 'formify'));
     $this->addFooterItem($html->javascript('ui-bootstrap-custom-tpls-0.13.0.min.js', 'formify'));
     $this->addFooterItem($html->javascript('formify.js', 'formify'));
     $this->addFooterItem($html->javascript('settings.js', 'formify'));
     $this->addFooterItem($html->javascript('controllers/settings.js', 'formify'));
 }
Beispiel #7
0
 public function view($fID = 0)
 {
     if ($fID > 0) {
         $sessionFormID = $fID;
         Session::set('formifyFormID', $fID);
     } else {
         $sessionFormID = Session::get('formifyFormID');
     }
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($sessionFormID);
     $this->set('f', $f);
     $userAttributes = UserKey::getList();
     $this->set('userAttributes', $userAttributes);
     $fsl = new FileSetList();
     $fsl->filterByType(FileSet::TYPE_PUBLIC);
     $fileSets = $fsl->getPage();
     $this->set('fileSets', $fileSets);
     if (!$f) {
         $this->redirect('/dashboard/formify/forms');
     }
     $html = Loader::helper('html');
     $this->addHeaderItem($html->css('formify.css', 'formify'));
     $this->addHeaderItem($html->css('fields.css', 'formify'));
     $this->addFooterItem($html->javascript('angular.min.js', 'formify'));
     $this->addFooterItem($html->javascript('ui-bootstrap-custom-tpls-0.13.0.min.js', 'formify'));
     $this->addFooterItem($html->javascript('formify.js', 'formify'));
     $this->addFooterItem($html->javascript('fields.js', 'formify'));
     $this->addFooterItem($html->javascript('controllers/fields.js', 'formify'));
 }
Beispiel #8
0
 public function all($fID)
 {
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($fID);
     $fields = $f->getFields();
     $json = Loader::helper('json');
     echo $json->encode($fields);
 }
 public function create($fID)
 {
     $db = Loader::db();
     $f = \Concrete\Package\Formify\Src\FormifyForm::get($fID);
     $fromName = Config::get('concrete.site');
     $subject = $f->name . ' Notification';
     $u = new User();
     $ui = UserInfo::getByID($u->getUserID());
     $toAddress = $ui->getUserEmail();
     $db->execute("INSERT INTO " . TABLE_FORMIFY_NOTIFICATIONS . " (nID,fID,fromName,toAddress,subject) VALUES (0,?,?,?,?)", array($fID, $fromName, $toAddress, $subject));
     $n = self::get($db->Insert_ID());
     return $n;
 }
 function setRecordData()
 {
     //Task:		Determine which records to get without getting the full record data
     //Reason: 	Outside of the filtering, we could just setup a long SQL query, but the
     //			filtering requires some extra SQL queries to check the actual record data.
     $db = Loader::db();
     $SQLvars = array();
     $SQLvars[] = $this->fID;
     // Run some checks before setting up the query
     // 1. Setup sort order SQL
     if ($this->getSortFieldID() != 0) {
         $SQLvars[] = intval($this->getSortFieldID());
         $sortField = \Concrete\Package\Formify\Src\FormifyField::get($this->getSortFieldID());
         if ($sortField->type == 'Date') {
             $sortType = "STR_TO_DATE(a.value,'" . $this->getDateFormat() . "')";
         } elseif ($sortField->type == 'Number') {
             $sortType = '(a.value + 0)';
         } else {
             $sortType = 'a.value';
         }
     } else {
         $sortType = 'a.value';
     }
     $sortOrderField = 'sortPriority';
     if ($this->getSortOrder() == 'RAND') {
         $sortOrderSQL = 'RAND()';
         $sortOrderField = '';
     } else {
         $sortOrderSQL = $this->getSortOrder();
     }
     // 2. Include expired records?
     if ($this->includeExpired) {
         $expiredSQL = '';
     } else {
         $expiredSQL = "AND (expiration > '" . time() . "' OR expiration IS NULL)";
     }
     // 3. Get approved records only?
     if ($this->requireApproval) {
         $approvalSQL = 'AND approval = 1';
     } else {
         $approvalSQL = '';
     }
     // 4. Only show records owned by the current user?
     if ($this->requireOwnership) {
         $owner = new User();
         $ownershipSQL = "AND uID = " . intval($owner->getUserID());
     } else {
         $ownershipSQL = '';
     }
     // 5. Only show records that have not yet been exported?
     if (!$this->includeExported) {
         $f = \Concrete\Package\Formify\Src\FormifyForm::get($this->fID);
         if ($this->includeUpdated) {
             $exportedSQL = "AND created > " . intval($f->properties['exportTimestamp']);
         } else {
             $exportedSQL = "AND created > " . intval($f->properties['exportTimestamp']);
         }
     } else {
         $exportedSQL = '';
     }
     // 6. Search according to the date range specified
     if ($this->startDate != '') {
         $startDateSQL = "AND created >= " . intval($this->startDate);
     } else {
         $startDateSQL = '';
     }
     if ($this->endDate != '') {
         $endDateSQL = "AND created <= " . intval($this->endDate);
     } else {
         $endDateSQL = '';
     }
     // 7. Is there are search query?
     $q = $this->getQuery();
     if ($q) {
         if (count($q) == 1) {
             $searchSQL = "AND searchIndex LIKE ?";
             $SQLvars[] = '%' . $q[0] . '%';
         } else {
             $searchSQL = "AND (";
             $i = 0;
             foreach ($q as $word) {
                 if ($i > 0) {
                     $searchSQL .= ' AND ';
                 }
                 $searchSQL .= "searchIndex LIKE ?";
                 $SQLvars[] = '%' . $word . '%';
                 $i++;
             }
             $searchSQL .= ')';
         }
     }
     // 8. Setup matching filters
     // 		1. Get the filters
     //		2. Get answers that match the filter
     //		3. Add the filter ID to "matchingFilters" field for the records that match the filter
     //		4. Set $filterSQL = '(matchingFilters = X) OR (matchingFilters = X)…'
     $filters = $this->getFilters();
     if (count($filters) > 0) {
         foreach ($filters as $filter) {
             if ($filter['exact'] == true) {
                 $matchingAnswers = $db->getAll("SELECT rID FROM " . TABLE_FORMIFY_ANSWERS . " WHERE ffID = ? AND value = ?", array($filter['ffID'], $filter['value']));
             } else {
                 $matchingAnswers = $db->getAll("SELECT rID FROM " . TABLE_FORMIFY_ANSWERS . " WHERE ffID = ? AND value LIKE ?", array($filter['ffID'], '%' . $filter['value'] . '%'));
             }
             if (is_array($matchingAnswers)) {
                 foreach ($matchingAnswers as $ma) {
                     $asRow = $db->getRow("SELECT count(rID) as total FROM " . TABLE_FORMIFY_RECORDS . " WHERE rID=? AND matchingFilters LIKE ?", array($ma['rID'], '%,' . $filter['filterID'] . ',%'));
                     if (intval($asRow['total']) == 0) {
                         $db->execute('UPDATE ' . TABLE_FORMIFY_RECORDS . ' SET matchingFilters=CONCAT_WS(",",matchingFilters,?) WHERE rID=?', array($filter['filterID'] . ',', $ma['rID']));
                     }
                 }
             }
             $filterSQL .= 'AND matchingFilters LIKE ?';
             $SQLvars[] = '%,' . $filter['filterID'] . ',%';
         }
     }
     // 9. Get the record ID's
     $pageSize = $this->getPageSize();
     $startAt = ($this->getPage() - 1) * $pageSize;
     if ($startAt < 0) {
         $startAt = 0;
     }
     if ($this->getPageSize() == 0) {
         $limitSQL = '';
     } else {
         $limitSQL = "LIMIT {$startAt}, {$pageSize}";
     }
     if ($this->getSortFieldID() == 0 || $sortOrderField == '') {
         $query = "SELECT * FROM " . TABLE_FORMIFY_RECORDS . " WHERE fID = ? AND isDeleted != 1 {$expiredSQL} {$approvalSQL} {$ownershipSQL} {$exportedSQL} {$startDateSQL} {$endDateSQL} {$searchSQL} {$filterSQL} ORDER BY {$sortOrderField} {$sortOrderSQL} {$limitSQL}";
     } else {
         $query = "SELECT *, ans.rID, a.value FROM " . TABLE_FORMIFY_RECORDS . " ans, " . TABLE_FORMIFY_ANSWERS . " a WHERE ans.fID = ? AND a.ffID = ? AND a.rID = ans.rID AND ans.isDeleted != 1 {$expiredSQL} {$approvalSQL} {$ownershipSQL} {$exportedSQL} {$startDateSQL} {$endDateSQL} {$searchSQL} {$filterSQL} ORDER BY {$sortType} {$sortOrderSQL} {$limitSQL}";
     }
     $this->records = $db->getAll($query, $SQLvars);
     $this->isPrePopulated = true;
 }
 public function getAvailablePlaceholders()
 {
     if (count($this->placeholders) > 0) {
         return $this->placeholders;
     } else {
         $placeholders = array();
         $placeholders[] = array('label' => 'Username', 'handle' => '{{ user }}');
         $placeholders[] = array('label' => 'User Email', 'handle' => '{{ user.email }}');
         $placeholders[] = array('label' => 'User ID', 'handle' => '{{ user.id }}');
         $placeholders[] = array('label' => 'Timestamp', 'handle' => '{{ timestamp }}');
         $placeholders[] = array('label' => 'IP Address', 'handle' => '{{ ip }}');
         $placeholders[] = array('label' => 'Record ID', 'handle' => '{{ id }}');
         $placeholders[] = array('label' => 'Detail URL', 'handle' => '{{ detailurl }}');
         $placeholders[] = array('label' => 'List URL', 'handle' => '{{ listurl }}');
         $placeholders[] = array('label' => 'Primary Field Value', 'handle' => '{{ primary }}');
         if ($f = \Concrete\Package\Formify\Src\FormifyForm::get($this->fID)) {
             foreach ($f->getFields() as $ff) {
                 $placeholders[] = array('label' => $ff->label, 'handle' => '{{ ' . $ff->handle . ' }}');
             }
         }
         return $placeholders;
     }
 }
Beispiel #12
-1
 public function delete($fID)
 {
     if ($f = \Concrete\Package\Formify\Src\FormifyForm::get($fID)) {
         $f->delete();
     }
 }