コード例 #1
0
ファイル: categories.php プロジェクト: vazahat/dudex
 public function __construct()
 {
     parent::__construct();
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $categories = $service->getCategoryList();
     $this->assign('categories', $categories);
     $counters = $service->getCategoriesProjectCount();
     $this->assign('counters', $counters);
 }
コード例 #2
0
ファイル: goal_edit.php プロジェクト: vazahat/dudex
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct('edit-goal-form');
     $this->setAction(OW::getRouter()->urlFor('OCSFUNDRAISING_CTRL_Admin', 'editGoal'));
     $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $lang = OW::getLanguage();
     $id = new HiddenField('goalId');
     $this->addElement($id);
     $name = new TextField('name');
     $name->setRequired(true);
     $name->setLabel($lang->text('ocsfundraising', 'name'));
     $this->addElement($name);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $desc = new WysiwygTextarea('description', $btnSet);
     $desc->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $desc->addValidator($sValidator);
     $desc->setLabel($lang->text('ocsfundraising', 'description'));
     $this->addElement($desc);
     $category = new Selectbox('category');
     $category->setLabel($lang->text('ocsfundraising', 'category'));
     $list = OCSFUNDRAISING_BOL_Service::getInstance()->getCategoryList();
     if ($list) {
         foreach ($list as $cat) {
             $category->addOption($cat->id, $lang->text('ocsfundraising', 'category_' . $cat->id));
         }
     }
     $this->addElement($category);
     $target = new TextField('target');
     $target->setRequired(true);
     $target->setLabel($lang->text('ocsfundraising', 'target_amount'));
     $this->addElement($target);
     $current = new TextField('current');
     $current->setRequired(true);
     $current->setLabel($lang->text('ocsfundraising', 'current_amount'));
     $this->addElement($current);
     $min = new TextField('min');
     $min->setLabel($lang->text('ocsfundraising', 'min_amount'));
     $this->addElement($min);
     $end = new DateField('end');
     $end->setMinYear(date('Y'));
     $end->setMaxYear(date('Y') + 2);
     $end->setLabel($lang->text('ocsfundraising', 'end_date'));
     $this->addElement($end);
     $imageField = new FileField('image');
     $imageField->setLabel($lang->text('ocsfundraising', 'image_label'));
     $this->addElement($imageField);
     $submit = new Submit('update');
     $submit->setLabel($lang->text('base', 'save'));
     $this->addElement($submit);
 }
コード例 #3
0
ファイル: donate.php プロジェクト: vazahat/dudex
 public function index(array $params)
 {
     if (!($goalId = $params['goalId'])) {
         throw new Redirect404Exception();
     }
     $fundraisingService = OCSFUNDRAISING_BOL_Service::getInstance();
     $billingService = BOL_BillingService::getInstance();
     $this->assign('currency', $billingService->getActiveCurrency());
     if (!($goal = $fundraisingService->getGoalById($goalId))) {
         throw new Redirect404Exception();
     }
     $this->assign('goal', $goal);
     $lang = OW::getLanguage();
     $userId = OW::getUser()->getId();
     $this->assign('userId', $userId);
     $form = new DonateForm($userId);
     $this->addForm($form);
     $form->getElement('amount')->setValue(floatval($goal['dto']->amountMin));
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         if (empty($values['gateway']['url']) || empty($values['gateway']['key']) || !($gateway = $billingService->findGatewayByKey($values['gateway']['key']) || !$gateway->active)) {
             OW::getFeedback()->error($lang->text('base', 'billing_gateway_not_found'));
             $this->redirectToAction('index');
         }
         // create donation product adapter object
         $productAdapter = new OCSFUNDRAISING_CLASS_DonationProductAdapter();
         // sale object
         $sale = new BOL_BillingSale();
         $sale->pluginKey = 'ocsfundraising';
         $sale->entityDescription = $goal['dto']->name;
         $sale->entityKey = $productAdapter->getProductKey();
         $sale->entityId = $goalId;
         $sale->price = floatval($values['amount']);
         $sale->userId = $userId ? $userId : 0;
         $sale->recurring = false;
         if (!$userId && !empty($values['username'])) {
             $sale->setExtraData(array('username' => $values['username']));
         }
         $saleId = $billingService->initSale($sale, $values['gateway']['key']);
         if ($saleId) {
             // sale Id is temporarily stored in session
             $billingService->storeSaleInSession($saleId);
             $billingService->setSessionBackUrl(OW::getRouter()->urlForRoute(OCSFUNDRAISING_CLASS_DonationProductAdapter::RETURN_ROUTE, array('goalId' => $goalId)));
             // redirect to gateway form page
             $this->redirect($values['gateway']['url']);
         }
     }
     $this->setPageHeading($goal['dto']->name);
     $this->setPageHeadingIconClass('ow_ic_user');
 }
コード例 #4
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $userId = $params->additionalParamList['entityId'];
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $projects = $service->getUserGoalsList($userId, 1, 2);
     $this->assign('projects', $projects);
     $this->assign('currency', BOL_BillingService::getInstance()->getActiveCurrency());
     /*$js = UTIL_JsGenerator::newInstance()
                 ->jQueryEvent('.btn-donate-goal-'.$goal['dto']->id, 'click', 'document.location.href = e.data.href', array('e'),
                     array('href' => OW::getRouter()->urlForRoute('ocsfundraising.donate', array('goalId' => $goal['dto']->id))
                 ));
     
             OW::getDocument()->addOnloadScript($js);*/
 }
コード例 #5
0
ファイル: event_handler.php プロジェクト: vazahat/dudex
 public function feedOnProjectAdd(OW_Event $e)
 {
     $params = $e->getParams();
     if ($params['entityType'] != 'ocsfundraising_project') {
         return;
     }
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $project = $service->getGoalById($params['entityId']);
     if (!$project) {
         return;
     }
     $content = array("format" => "image_content", "vars" => array("image" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image, false) : null, "thumbnail" => $project['dto']->image ? $service->generateImageUrl($project['dto']->image) : null, "title" => UTIL_String::truncate(strip_tags($project['dto']->name), 100, '...'), "description" => UTIL_String::truncate(strip_tags($project['dto']->description), 150, '...'), "url" => array("routeName" => "ocsfundraising.project", "vars" => array('id' => $project['dto']->id)), "iconClass" => "ow_ic_folder"));
     $data = array('time' => (int) $project['dto']->startStamp, 'ownerId' => $project['dto']->ownerId, 'string' => array('key' => 'ocsfundraising+feed_add_project_label'), 'content' => $content, 'view' => array('iconClass' => 'ow_ic_folder'));
     $e->setData($data);
 }
コード例 #6
0
ファイル: goal_widget.php プロジェクト: vazahat/dudex
 public static function getSettingList()
 {
     $settingList = array();
     $settingList['goal'] = array('presentation' => self::PRESENTATION_SELECT, 'label' => OW::getLanguage()->text('ocsfundraising', 'widget_goal'), 'optionList' => array('0' => OW::getLanguage()->text('ocsfundraising', 'no_goals')), 'value' => null);
     $list = OCSFUNDRAISING_BOL_Service::getInstance()->getGoalsList();
     if ($list) {
         $optList = array();
         foreach ($list as $goal) {
             $optList[$goal->id] = $goal->name;
         }
         $settingList['goal']['optionList'] = $optList;
     }
     $settingList['show_top'] = array('presentation' => self::PRESENTATION_CHECKBOX, 'label' => OW::getLanguage()->text('ocsfundraising', 'show_top_donations'), 'value' => false);
     $settingList['show_latest'] = array('presentation' => self::PRESENTATION_CHECKBOX, 'label' => OW::getLanguage()->text('ocsfundraising', 'show_latest_donations'), 'value' => false);
     return $settingList;
 }
コード例 #7
0
 public function deliverSale(BOL_BillingSale $sale)
 {
     $goalId = $sale->entityId;
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $goal = $service->getGoalById($goalId);
     if (!$goal) {
         return false;
     }
     $extra = $sale->getExtraData();
     $donation = new OCSFUNDRAISING_BOL_Donation();
     $donation->amount = $sale->totalAmount;
     $donation->userId = !empty($sale->userId) ? $sale->userId : null;
     $donation->donationStamp = time();
     $donation->goalId = $sale->entityId;
     $donation->username = !empty($extra['username']) ? $extra['username'] : null;
     $service->registerDonation($donation);
     $goal['dto']->amountCurrent += $donation->amount;
     $service->update($goal['dto']);
     return true;
 }
コード例 #8
0
ファイル: project.php プロジェクト: vazahat/dudex
 public function ajaxDeleteProject()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect403Exception();
     }
     if (empty($_POST['projectId'])) {
         throw new Redirect404Exception();
     }
     $projectId = (int) $_POST['projectId'];
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $proj = $service->getGoalById($projectId);
     if (!$proj) {
         throw new Redirect404Exception();
     }
     $viewerId = OW::getUser()->getId();
     if ($viewerId && $viewerId != $proj['dto']->ownerId) {
         throw new Redirect403Exception();
     }
     $service->deleteGoal($projectId);
     exit(json_encode(array('result' => true, 'url' => OW::getRouter()->urlForRoute('ocsfundraising.list'))));
 }
コード例 #9
0
ファイル: cron.php プロジェクト: vazahat/dudex
 public function goalsCheckProcess()
 {
     OCSFUNDRAISING_BOL_Service::getInstance()->checkCompleteGoals();
 }